From df634f8a0b0d3877470caf5cb4aef2eae037109e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 2 Dec 2026 16:26:28 -0800 Subject: [PATCH 01/10] Panels: the Color and Gradient pop-outs run one pass a frame With the Color or Gradient panel open as a pop-out, every second frame at rest ran the whole window twice: egui discarded the first pass because a content column in the panel body measured differently from the transcript its flyout kept. storytold/craft-libs#4932 fixes the layout memory, and this moves the craft-libs pin to its head c2a47dfe, which is craft-libs main 092a2c6b with the fix. The egui and winit revisions are unchanged. The bump also brings in craft-libs #4584, #4804, #2415, #4531, #4676, #3061 and #4050. Test: with either pop-out open, each of 10 frames at rest runs one pass. --- Cargo.lock | 172 +++++++++++------------ Cargo.toml | 76 +++++----- apps/vectorcraft-web/Cargo.toml | 2 +- crates/ui-egui/src/panels/color/tests.rs | 30 ++++ xtask/src/pdf_deps.rs | 2 +- 5 files changed, 156 insertions(+), 126 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0216e2962..80e136673a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-automation", "craft-behavior", @@ -1272,7 +1272,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "crc32fast", "flate2", @@ -1283,7 +1283,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1295,7 +1295,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "rustix 1.1.6", ] @@ -1303,7 +1303,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1328,7 +1328,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1346,7 +1346,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-docpath", @@ -1364,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "crc32fast", "flate2", @@ -1373,7 +1373,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "egui", ] @@ -1381,7 +1381,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "md-5", "rayon", @@ -1390,12 +1390,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-cms", @@ -1415,7 +1415,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1426,7 +1426,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1436,7 +1436,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "rayon", ] @@ -1444,7 +1444,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1470,7 +1470,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "blake3", "craft-ecproj-format", @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "serde", ] @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-codepage", "encoding_rs", @@ -1525,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "serde", "serde_json", @@ -1535,12 +1535,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1555,7 +1555,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1574,7 +1574,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "cap-primitives", "craft-atomic", @@ -1606,12 +1606,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "gif", ] @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "flate2", ] @@ -1627,7 +1627,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -1670,7 +1670,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-dds", "craft-jpeg", @@ -1697,7 +1697,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "thiserror 2.0.21", ] @@ -1723,7 +1723,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1734,7 +1734,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-host", "craft-i18n", @@ -1749,7 +1749,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-i18n", @@ -1763,7 +1763,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-host", @@ -1781,7 +1781,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1793,7 +1793,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "encoding_rs", "image", @@ -1804,7 +1804,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "chrono", "craft-codepage", @@ -1814,7 +1814,7 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "uds_windows", "winsafe", @@ -1823,7 +1823,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-keymap", @@ -1839,7 +1839,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "flate2", "serde", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1862,7 +1862,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "async-channel", "async-io", @@ -1895,7 +1895,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1904,7 +1904,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-host", @@ -1928,7 +1928,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1939,7 +1939,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-eps", "flate2", @@ -1953,7 +1953,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "encoding_rs", "flate2", @@ -1964,7 +1964,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "dispatch2", "egui", @@ -1977,7 +1977,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1996,7 +1996,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-atomic", "craft-host", @@ -2013,7 +2013,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "fax", "hayro-ccitt", @@ -2024,7 +2024,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2045,7 +2045,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-keymap", @@ -2057,7 +2057,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2082,7 +2082,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2097,7 +2097,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-atomic", "craft-behavior", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "serde", "thiserror 2.0.21", @@ -2122,7 +2122,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "serde", "thiserror 2.0.21", @@ -2131,7 +2131,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-keymap", @@ -2146,12 +2146,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2165,7 +2165,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -2182,7 +2182,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "accesskit", "craft-behavior", @@ -2220,7 +2220,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2231,7 +2231,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-host", @@ -2249,7 +2249,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-host", @@ -2270,7 +2270,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-host", @@ -2291,7 +2291,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-behavior", "craft-host", @@ -2310,7 +2310,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "base64 0.22.1", "chrono", @@ -2342,7 +2342,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "flate2", "serde", @@ -2353,7 +2353,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2363,7 +2363,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "js-sys", "serde_json", @@ -2374,7 +2374,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "winsafe", ] @@ -2382,7 +2382,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "craft-appkit", "craft-atomic", @@ -2414,7 +2414,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3773,7 +3773,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "brotli 8.0.4", "hayro-postscript", @@ -3782,7 +3782,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3800,7 +3800,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3818,12 +3818,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "flate2", "hayro-ccitt", @@ -4806,7 +4806,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4963,7 +4963,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=77ade517ecb2a6ad86feb2f9983a098ad5738fc6#77ade517ecb2a6ad86feb2f9983a098ad5738fc6" +source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 843f9cbb53..d14fd9004f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,51 +10,51 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # Nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -194,13 +194,13 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } emath = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } epaint = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 70aae32f73..e439dc8be6 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/ui-egui/src/panels/color/tests.rs b/crates/ui-egui/src/panels/color/tests.rs index d354702ef2..a36c95f13a 100644 --- a/crates/ui-egui/src/panels/color/tests.rs +++ b/crates/ui-egui/src/panels/color/tests.rs @@ -429,3 +429,33 @@ fn the_wells_show_a_gradient_and_none_as_the_tools_proxy_does() { assert!(color.shows_value(well), "the Color panel shows a well that reads as {well:?}"); } } + +/// With the Color or the Gradient panel open as a pop-out, each frame at rest runs one pass of the window: no frame +/// runs a second pass that egui discards. +#[test] +fn an_open_color_or_gradient_pop_out_runs_one_pass_a_frame() { + for panel in ["color", "gradient"] { + let mut app = app(); + app.run("window.panel", json!({"panel": panel})).unwrap(); + let ctx = crate::testing::ui_context(); + let mut time = 0.0; + let mut passes = |app: &mut VectorcraftApp| { + time += 1.0 / 60.0; + let raw = egui::RawInput { + time: Some(time), + screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), + focused: true, + ..Default::default() + }; + let before = ctx.cumulative_pass_nr(); + let _ = crate::testing::app_frame(app, &ctx, raw); + ctx.cumulative_pass_nr() - before + }; + for _ in 0..4 { + passes(&mut app); + } + assert_eq!(app.ui.open_panel.as_deref(), Some(panel), "the {panel} pop-out is open"); + let counted: Vec = (0..10).map(|_| passes(&mut app)).collect(); + assert_eq!(counted, vec![1; 10], "the {panel} pop-out: one pass in each of 10 frames at rest"); + } +} diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 542a3e8c41..1abbfba86a 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "77ade517ecb2a6ad86feb2f9983a098ad5738fc6"; +const REV: &str = "c2a47dfea38b215245f739c675da3662c89f1e09"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 231d90614b70787a6e700f413e12f4df54cafcf3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 05:32:37 -0800 Subject: [PATCH 02/10] Docs: the save-changes question takes choice dontSave, not discard The question that Close, Close All and Quit open for a modified document takes `choice` (`save`, `dontSave` or `cancel`) and, while more documents wait, `applyToAll`. A `discard` field is refused with "unknown field `discard`". docs/control-protocol.md, the answer_dialog row of docs/mcp.md and the control module's doc comment still told clients to set `discard: true`. Each text now gives `{field: "choice", value: "dontSave"}`, lists the values `choice` takes and describes `applyToAll`. The answer_dialog row gives the choice in one call and the confirm in a second one: the app answers a `set` with `action` by returning the confirm's result alone, and answer_dialog then sends a second confirm, which can fail after the document closed or answer the next document's question. A test in unsaved.rs checks the requests on the lines that describe the `{"pending": "saveChanges"}` reply in both docs and sends the same requests through the control handler: the modified documents close and no file is written. --- crates/ui-egui/Cargo.toml | 2 + crates/ui-egui/src/control.rs | 3 +- crates/ui-egui/src/unsaved.rs | 76 +++++++++++++++++++++++++++++++++++ docs/control-protocol.md | 2 +- docs/mcp.md | 2 +- 5 files changed, 82 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 49fad8d56f..1582da283e 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -116,6 +116,8 @@ toml = "1" reads = [ "crates/engine/src/cmd/addons/cutting/banner.rs", "crates/plugins/tests/fixtures/desaturate.wasm", + "docs/control-protocol.md", + "docs/mcp.md", "packaging/macos/nightly-lib.sh", "packaging/macos/nightly_plist.py", ] diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 158cf852f8..ddf6055c2c 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -28,7 +28,8 @@ //! a path, or with `data: true`, as `pngBase64`) //! - `app.open {path}` (any readable format) / `app.save {path?, svg?: {…SVG options}}` / `app.quit` //! (`file.close`, `file.closeAll` and `app.quit` first open a `saveChanges` dialog for each -//! modified document: `ui.dialog.confirm` saves, set `discard: true` then confirm to discard) +//! modified document: `ui.dialog.confirm` saves, set `choice: "dontSave"` then confirm to close +//! without saving) //! - `app.export {path?, format?, …document.export options}`: encoded by the engine, written through //! the host; the document keeps its path. No path → `{dataBase64, format, bytes}` (as headless) //! - `wait: true` on `app.save` and `app.export`: the file is written before the reply, even with diff --git a/crates/ui-egui/src/unsaved.rs b/crates/ui-egui/src/unsaved.rs index 9d5a7230a0..252f3cc8a5 100644 --- a/crates/ui-egui/src/unsaved.rs +++ b/crates/ui-egui/src/unsaved.rs @@ -399,6 +399,82 @@ mod tests { assert_eq!((docs(&app), app.views.len()), (1, 1)); } + const CONTROL_DONT_SAVE: &str = r#"`ui.dialog.set {field: "choice", value: "dontSave"}` then confirm"#; + const CONTROL_APPLY_TO_ALL: &str = r#"`ui.dialog.set {field: "applyToAll", value: true}` before confirm"#; + const MCP_DONT_SAVE: &str = r#"`{set: [{field: "choice", value: "dontSave"}]}` followed by a second call with `{action: "confirm"}`"#; + const MCP_APPLY_TO_ALL: &str = r#"adding `{field: "applyToAll", value: true}` to `set`"#; + + /// Each documented Don't Save sequence closes the requested documents without writing a file, + /// including Apply to All for multiple modified documents. The documented requests are read + /// from the lines describing the `{"pending": "saveChanges"}` reply. + #[test] + fn the_documented_dont_save_answer_closes_without_saving() { + for (name, text, snippets) in [ + ("docs/control-protocol.md", include_str!("../../../docs/control-protocol.md"), [CONTROL_DONT_SAVE, CONTROL_APPLY_TO_ALL]), + ("docs/mcp.md", include_str!("../../../docs/mcp.md"), [MCP_DONT_SAVE, MCP_APPLY_TO_ALL]), + ] { + // Check the requests on every line describing the pending Save Changes reply. + let lines: Vec<_> = text.lines().filter(|line| line.contains(r#"{"pending": "saveChanges"}"#)).collect(); + assert!(!lines.is_empty(), "{name}: missing a line describing the pending Save Changes reply"); + for line in lines { + for snippet in snippets { + assert!(line.contains(snippet), "{name}: missing {snippet}; the test's requests must be updated with the docs"); + } + assert!(!line.contains("\"discard\""), "{name}: saveChanges must use choice instead of discard: {line}"); + } + } + + let control = |app: &mut VectorcraftApp, ctx: &egui::Context, method: &str, params: Value| { + let (req, _) = craft::automation::ControlRequest::new(method, params); + let craft::automation::Reply::Done(r) = crate::control::handle(app, ctx, &req) else { panic!("{method} answers at once") }; + r + }; + for (name, apply_to_all, requests) in [ + ( + "control protocol Don't Save", + false, + vec![("ui.dialog.set", json!({ "field": "choice", "value": "dontSave" })), ("ui.dialog.confirm", json!({}))], + ), + ( + "control protocol applyToAll", + true, + vec![ + ("ui.dialog.set", json!({ "field": "choice", "value": "dontSave" })), + ("ui.dialog.set", json!({ "field": "applyToAll", "value": true })), + ("ui.dialog.confirm", json!({})), + ], + ), + ( + "MCP Don't Save", + false, + vec![("ui.dialog.set", json!({ "fields": [{ "field": "choice", "value": "dontSave" }] })), ("ui.dialog.confirm", json!({}))], + ), + ( + "MCP applyToAll", + true, + vec![ + ("ui.dialog.set", json!({ "fields": [{ "field": "choice", "value": "dontSave" }, { "field": "applyToAll", "value": true }] })), + ("ui.dialog.confirm", json!({})), + ], + ), + ] { + let mut app = app(); + new_doc(&mut app, true); + new_doc(&mut app, apply_to_all); + let (ctx, picker) = ready_with_picks(&mut app); + let (method, params) = if apply_to_all { ("file.closeAll", json!({})) } else { ("file.close", json!({ "index": 0 })) }; + assert_eq!(app.run(method, params).unwrap(), json!({ "pending": KIND }), "{name}: closing asks first"); + for (method, params) in requests { + let r = control(&mut app, &ctx, method, params.clone()); + assert!(r.get("error").is_none_or(Value::is_null), "{name}: {method} {params} is refused: {r}"); + } + pump(&mut app, &ctx); + assert_eq!(docs(&app), if apply_to_all { 0 } else { 1 }, "{name}: the requested documents close"); + assert!(picker.written().is_empty(), "{name}: no file is written"); + assert!(app.closing.is_none() && !question_open(&app), "{name}: no question remains open"); + } + } + #[test] fn closing_a_modified_background_tab_keeps_the_front_document_after_dont_save() { let mut app = app(); diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 71e3d0fae9..783c686f45 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -107,7 +107,7 @@ the two can still win that race. | `ui.render` | `{path?, scale?, artboard?, data?, traceViews?}` | render an artboard headlessly (PNG with the pixels of `app.export {format: "png", background: "white"}` at the same scale; `artboard`: its 0-based index, default the first; `traceViews: true`: Image Trace objects draw in their View, as on the canvas, instead of their tracing result): written to `path`, else (or with `data: true` as well) sent back as `pngBase64` | | `ui.resize` | `{width?, height?}` | request the window's inner size; omitted or null `width` and `height` default to 1440 and 900. Returns `null` | | `ui.focus` | `{}` | request keyboard focus for the window. Returns `null` | -| `app.open` / `app.save` / `app.export` / `app.quit` | `{path, importer?, params?}` / `{path?}` / `{path?, format?, artboard?, range?, scale?, …}` | `app.open` reads every format `document.open` reads (see `document.formats`) and returns its result (`{index, title, format, warnings, …}`; `warnings` say what didn't come in as it was, such as an EPS shown as its preview image and why its PostScript couldn't be read), or null when a dialog asks first or a library loads. The status bar (`ui.inspect` → `ui.status`), after a line about the document's linked files when there is one (Missing linked files below), counts the `warnings` and names the first that says reading the file left something out (the notes that make Save ask before writing over it), else the first; with several, hovering it lists them in that order, as many as fit in the window (at most 30), then how many more. After `app.save`, and `app.export` with a `path`, the status bar counts the reply's `warnings` and names the first, and with several, hovering it lists them in the reply's order (a save's notes start with what the format loses). With `importer` (an importer plug-in's format id, `plugin.`) it runs `file.openWith`: the file opens with that importer, also when a built-in format reads its extension, with the importer's parameters `params` (their defaults when omitted; no dialog asks for them). Without `importer`, `params` go to the importer that opens the file, and a built-in format does not read them. `app.export` encodes through the engine's `document.export` (same options; the document keeps its path) and writes `path` through the host; without `path` it returns `{dataBase64, format, bytes}`, as headless mode does. It refuses a key that no format takes, and an unknown key inside a PDF or EPS option object, before it writes anything (`docs/mcp.md`, Parameter keys). It accepts a key that only another format takes and does not use it: the reply's `warnings` and the status bar name the key ("`quality` was not used: PDF files don't read it"). `app.save` refuses a key that no save format takes, beside the path or in `options`, the same way. `app.quit`, `file.close` and `file.closeAll` first open a `saveChanges` dialog for each modified document (they return `{"pending": "saveChanges"}`): `ui.dialog.confirm` saves, `ui.dialog.set {field: "discard", value: true}` then confirm discards, `ui.dialog.cancel` cancels the whole close or quit | +| `app.open` / `app.save` / `app.export` / `app.quit` | `{path, importer?, params?}` / `{path?}` / `{path?, format?, artboard?, range?, scale?, …}` | `app.open` reads every format `document.open` reads (see `document.formats`) and returns its result (`{index, title, format, warnings, …}`; `warnings` say what didn't come in as it was, such as an EPS shown as its preview image and why its PostScript couldn't be read), or null when a dialog asks first or a library loads. The status bar (`ui.inspect` → `ui.status`), after a line about the document's linked files when there is one (Missing linked files below), counts the `warnings` and names the first that says reading the file left something out (the notes that make Save ask before writing over it), else the first; with several, hovering it lists them in that order, as many as fit in the window (at most 30), then how many more. After `app.save`, and `app.export` with a `path`, the status bar counts the reply's `warnings` and names the first, and with several, hovering it lists them in the reply's order (a save's notes start with what the format loses). With `importer` (an importer plug-in's format id, `plugin.`) it runs `file.openWith`: the file opens with that importer, also when a built-in format reads its extension, with the importer's parameters `params` (their defaults when omitted; no dialog asks for them). Without `importer`, `params` go to the importer that opens the file, and a built-in format does not read them. `app.export` encodes through the engine's `document.export` (same options; the document keeps its path) and writes `path` through the host; without `path` it returns `{dataBase64, format, bytes}`, as headless mode does. It refuses a key that no format takes, and an unknown key inside a PDF or EPS option object, before it writes anything (`docs/mcp.md`, Parameter keys). It accepts a key that only another format takes and does not use it: the reply's `warnings` and the status bar name the key ("`quality` was not used: PDF files don't read it"). `app.save` refuses a key that no save format takes, beside the path or in `options`, the same way. `app.quit`, `file.close` and `file.closeAll` first open a `saveChanges` dialog for each modified document (they return `{"pending": "saveChanges"}`): `ui.dialog.confirm` saves, `ui.dialog.set {field: "choice", value: "dontSave"}` then confirm closes the document without saving, `ui.dialog.cancel` cancels the whole close or quit. `choice` takes `save`, `dontSave` or `cancel`, and any other field or value is an error. While more modified documents wait to be asked about, the dialog also has `applyToAll`: `ui.dialog.set {field: "applyToAll", value: true}` before confirm gives the same answer for each of them | | `app.export` with `useArtboards` | `{path, useArtboards: true, range? \| artboards?, …}` | Export As: PNG, JPEG and WebP write one file per chosen artboard (default all; SVG does so for a `range`), `-.`, and return `{path, files: [path…]}`; a PDF keeps them as pages of `path`. `useArtboards: false` covers the bounds of the visible art. The menu's Export As… is `file.exportAs`: the `exportAs` dialog (`format`, `useArtboards`, `all`, `range`), then a save dialog and the format's options: `pngOptions` / `jpgOptions` / `webpOptions`, `svgOptions`, or `savePdf` for a PDF | | `ui.dialog.*` on `gradientStop` | `{field: "color" \| "opacity" \| "location", value}` | double-clicking a stop on the Gradient tool's annotator opens its popover (fields `index`, `x`, `y`, `tab`); set `color` (hex), `opacity` or `location` (percentages) and `ui.dialog.confirm` to apply them to the selected stop. `gradient.selectStop {index}` picks the stop the annotator, the panels and Delete/←/→ (`ui.key`) act on | | `engine.execute` `ui.savePdfDialog` | `{path?, preset?, range?, …document.exportPdf options}` | opens the Save PDF dialog (`file.export.pdf` with no params opens it too). Its fields are the `document.exportPdf` options: set `compatibility` with `ui.dialog.set {field: "compatibility", value: "1.5"}`, a section with `{field: "compression", value: {…}}` (the options it leaves out keep the dialog's values, in Save PDF and in the preset editor, and in an object inside a section such as `compression.color`; a value that isn't an object, null included, is an error), the artboards with `__allArtboards: false` and `range`, the visible section with `__section` (General, Compression, Marks and Bleeds, Output, Advanced, Security, Summary), and the bleed link with `__bleedLinked` (true gives every side the top value; any value other than true or false is an error; setting `bleed` turns the link on when its four sides are equal and off when they differ). In Advanced, Custom… beside Flattener preset (enabled when the file is flattened: PDF 1.3, PDF/X-1a, PDF/X-3) opens the `pdfFlattenerOptions` dialog over Save PDF on the flattener options the save would use; its fields are those options, with `clipComplexRegions`, `preserveAlpha` and `preserveOverprints` set by the writer and Overprint. Its `ui.dialog.confirm` sets `flattener` (the preset then shows [Custom]; options equal to the preset's leave it unset) and goes back to Save PDF, and `ui.dialog.cancel` goes back unchanged. Setting `flattenerPreset` drops `flattener`. `useArtboards: false` opens it for one page of the visible art's bounds, as Export As with Use Artboards off does: the dialog has no Artboards section and its `__artBounds` field is true. `ui.dialog.confirm` writes `path` (else asks for one), returns `{path, bytes, warnings}` and opens the file when `viewAfterSaving` is set. With `useArtboards: false` it writes the page as `app.export` does and returns `{path, warnings}`, or `{background: true, status}` while Background Export writes it | diff --git a/docs/mcp.md b/docs/mcp.md index 85e35043df..2eb69df0ef 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -818,7 +818,7 @@ ends the wait, so the sampler can be shown again. The BSDs and headless sessions | `set_paint` | `{fill?, stroke?, strokeWidth?, ids?}` | Applies to the selection (or `ids`) and becomes the default for new art. Returns `{applied, objects}`: `objects` is the number of objects painted, as the `objects` of the `paint.setFill`, `paint.setStroke` and `stroke.set` replies (the largest of them): a selected group counts the objects inside it. When it is 0, a `note` says that only the paint for new art changed. When some of those commands painted objects and others painted none (a fill while the Shape Builder is the active tool, say), `unpainted` lists the commands that painted none, with a `note`. | | `press_key` | `{key, mods?}` | Remote: a real key event. Headless: runs the command or tool bound to that shortcut, or sends the key to the busy tool (digits too: `5` while dragging with the Perspective Selection tool; `e` while dragging a Selection or Group Selection marquee; `c` and `f` while dragging out an arc; `f`, `v`, `x` and `c` while dragging out a rectangular or polar grid). | | `type_text` | `{text}` | Remote only. | -| `answer_dialog` | `{set?: [{field, value?}], action?}` | Remote only. Sets fields of the app's open dialog in the order given with one `ui.dialog.set {fields, action?}` (a missing `value` is `null`). The app stores all of them or none, then answers that same dialog with `action` in the same request: `confirm` (OK) or `cancel`. Another connection cannot open a dialog between the two steps. When the app refuses the `ui.dialog.set`, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. `set` cannot change a `__` field other than the dialog's controls held under a `__` name (such as Save PDF's `__section` or the Preferences `__search`): the `__command` and `__params` of a `confirm` or `command` dialog, and every other `__` field that holds what OK acts on, are refused with "the `` dialog cannot set protected field ``", so OK runs what the dialog was opened for. `action` alone is sent as `ui.dialog.confirm` or `ui.dialog.cancel`. Give `set`, `action` or both; `set` holds at most 256 fields. `inspect_ui` shows the open dialog and its fields as `ui.dialog`. Returns `{dialog, result}`: the dialog after the fields were set (or `null`) and the reply to `confirm` or `cancel` (or `null`). After `invoke_menu` `app.quit`, `file.close` or `file.closeAll` replies `{"pending": "saveChanges"}`, `{action: "confirm"}` saves, `{set: [{field: "discard", value: true}], action: "confirm"}` closes without saving and `{action: "cancel"}` cancels the close or quit. | +| `answer_dialog` | `{set?: [{field, value?}], action?}` | Remote only. Sets fields of the app's open dialog in the order given with one `ui.dialog.set {fields, action?}` (a missing `value` is `null`). The app stores all of them or none, then answers that same dialog with `action` in the same request: `confirm` (OK) or `cancel`. Another connection cannot open a dialog between the two steps. When the app refuses the `ui.dialog.set`, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. `set` cannot change a `__` field other than the dialog's controls held under a `__` name (such as Save PDF's `__section` or the Preferences `__search`): the `__command` and `__params` of a `confirm` or `command` dialog, and every other `__` field that holds what OK acts on, are refused with "the `` dialog cannot set protected field ``", so OK runs what the dialog was opened for. `action` alone is sent as `ui.dialog.confirm` or `ui.dialog.cancel`. Give `set`, `action` or both; `set` holds at most 256 fields. `inspect_ui` shows the open dialog and its fields as `ui.dialog`. Returns `{dialog, result}`: the dialog after the fields were set (or `null`) and the reply to `confirm` or `cancel` (or `null`). After `invoke_menu` `app.quit`, `file.close` or `file.closeAll` replies `{"pending": "saveChanges"}`, `{action: "confirm"}` saves, `{set: [{field: "choice", value: "dontSave"}]}` followed by a second call with `{action: "confirm"}` closes without saving, and `{action: "cancel"}` cancels the close or quit. `choice` takes `save`, `dontSave` or `cancel`; while more modified documents wait to be asked about, adding `{field: "applyToAll", value: true}` to `set` gives the same answer for each of them. The second call answers whichever dialog is open when it arrives, so a dialog that another client or the user opens between the two calls is answered instead. | | `invoke_menu` | `{command, params?}` | Invokes a menu item by command id. UI commands such as `view.*` and `window.*` are in `command_list` with `ui: true`; running them needs the desktop app (`--connect`). The app refuses `attributes.openUrl`, `file.export.svg.browser`, `file.saveForWeb.browser` and `file.showPackage` for every control and MCP request, since each opens another app, so the headless error for them does not suggest `--connect`. | | `open_panel` | `{panel}` | Remote only. `panel` is a panel id (`layers`, `swatches`, `colorGuide`, …, as `window.panel` takes) or its display label (`"Color Guide"`), in any case. | | `screenshot` | `{path?, scale?, artboard?, window?, max_side?, traceViews?}` | Returns MCP image content (`image/png`, base64) plus a text block. Renders the artboard with the pixels of a PNG `export` with `background: "white"` at the same scale; `traceViews:true` draws Image Trace objects in the view set with `imageTrace.setView`, as in the app's window; `window:true` captures the app window (remote only), as `ui_screenshot` does, and `max_side` (1–4096, window captures only) scales the returned image down as described for `ui_screenshot`. With `path` the backend (the headless session or the app) writes the PNG there too; a window capture written there keeps its full size with `max_side`. An app that does not send the image back writes a window capture without `path` to a file in a new folder inside the system's temporary folder (on Unix only the user can open it); the server reads the file and then removes the folder, also when the capture or the read fails. | From 4cc6d9c0d16477c87be2b9452835e9fe9b609659 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 11:10:01 -0800 Subject: [PATCH 03/10] MCP: answer_dialog describes Don't Save as two calls, with applyToAll The answer_dialog tool description, which MCP clients read from tools/list, still gave Don't Save for the save-changes question as one call that sets `choice` and confirms. The app answers that request with the confirm's result alone, so answer_dialog sends a second confirm, which fails once the document has closed or, during Close All or Quit, answers the next document's question with Save. The description now gives the same sequence as docs/mcp.md: set `choice` to `dontSave`, then confirm in a second call. It names file.closeAll beside app.quit and file.close, lists the values `choice` takes, describes `applyToAll`, and says to give `set` and `action` in separate calls for this question. The answer_dialog row of docs/mcp.md says the same. A test in the MCP crate checks that the description gives the two-call sequence and applyToAll, and does not give the one-call form or `discard`. --- crates/mcp/src/tests/conventions.rs | 17 +++++++++++++++++ crates/mcp/src/tools/definitions.rs | 2 +- docs/mcp.md | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/mcp/src/tests/conventions.rs b/crates/mcp/src/tests/conventions.rs index 9020370c26..839c740ec1 100644 --- a/crates/mcp/src/tests/conventions.rs +++ b/crates/mcp/src/tests/conventions.rs @@ -418,6 +418,23 @@ fn alias_tools_name_their_pair() { assert!(description("ui_screenshot").contains("window:true")); } +/// answer_dialog's description gives the save-changes answers that docs/mcp.md gives: Don't Save +/// sets `choice` and confirms in a second call, and `applyToAll` answers every waiting document. +#[test] +fn answer_dialog_describes_the_save_changes_answers() { + let tools = tool_definitions(); + let description = tools.iter().find(|t| t["name"] == "answer_dialog").unwrap()["description"].as_str().unwrap().to_string(); + for snippet in [ + "app.quit, file.close or file.closeAll", + r#"{set:[{field:"choice",value:"dontSave"}]} followed by a second call with {action:"confirm"}"#, + r#"{field:"applyToAll",value:true}"#, + ] { + assert!(description.contains(snippet), "answer_dialog's description is missing {snippet}: {description}"); + } + assert!(!description.contains("discard"), "the save-changes dialog takes choice, not discard: {description}"); + assert!(!description.contains(r#"value:"dontSave"}],action:"confirm"}"#), "Don't Save must confirm in a second call: {description}"); +} + #[test] fn conventions_tool_panics_are_tool_errors() { let mut s = Server::new(Box::new(Panics)); diff --git a/crates/mcp/src/tools/definitions.rs b/crates/mcp/src/tools/definitions.rs index 98267484e0..63c3dadc05 100644 --- a/crates/mcp/src/tools/definitions.rs +++ b/crates/mcp/src/tools/definitions.rs @@ -314,7 +314,7 @@ pub fn tool_definitions() -> Vec { tool( "answer_dialog", "Answer dialog", - "Set fields of the desktop app's open dialog in order, then confirm (OK) or cancel it, as the control protocol's ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel do. The app stores all the fields or none and answers that same dialog in the same request (ui.dialog.set with action). When the app refuses the ui.dialog.set, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. inspect_ui shows the open dialog and its fields (ui.dialog). After invoke_menu app.quit or file.close replies {\"pending\":\"saveChanges\"}: {action:\"confirm\"} saves, {set:[{field:\"choice\",value:\"dontSave\"}],action:\"confirm\"} closes without saving, {action:\"cancel\"} cancels. Returns {dialog, result}: the dialog after the fields were set, and the reply to confirm or cancel. Desktop app only.", + "Set fields of the desktop app's open dialog in order, then confirm (OK) or cancel it, as the control protocol's ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel do. The app stores all the fields or none and answers that same dialog in the same request (ui.dialog.set with action). When the app refuses the ui.dialog.set, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. inspect_ui shows the open dialog and its fields (ui.dialog). After invoke_menu app.quit, file.close or file.closeAll replies {\"pending\":\"saveChanges\"}: {action:\"confirm\"} saves, {set:[{field:\"choice\",value:\"dontSave\"}]} followed by a second call with {action:\"confirm\"} closes without saving, and {action:\"cancel\"} cancels the close or quit. choice takes save, dontSave or cancel; while more modified documents wait to be asked about, adding {field:\"applyToAll\",value:true} to set gives the same answer for each of them. Give set and action in separate calls for this question: in one call, answer_dialog sends a second confirm, which fails once the document has closed or answers the next document's question. The second call answers whichever dialog is open when it arrives. Returns {dialog, result}: the dialog after the fields were set, and the reply to confirm or cancel. Desktop app only.", obj( json!({ "set": { diff --git a/docs/mcp.md b/docs/mcp.md index 2eb69df0ef..b6ea0dc8a2 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -818,7 +818,7 @@ ends the wait, so the sampler can be shown again. The BSDs and headless sessions | `set_paint` | `{fill?, stroke?, strokeWidth?, ids?}` | Applies to the selection (or `ids`) and becomes the default for new art. Returns `{applied, objects}`: `objects` is the number of objects painted, as the `objects` of the `paint.setFill`, `paint.setStroke` and `stroke.set` replies (the largest of them): a selected group counts the objects inside it. When it is 0, a `note` says that only the paint for new art changed. When some of those commands painted objects and others painted none (a fill while the Shape Builder is the active tool, say), `unpainted` lists the commands that painted none, with a `note`. | | `press_key` | `{key, mods?}` | Remote: a real key event. Headless: runs the command or tool bound to that shortcut, or sends the key to the busy tool (digits too: `5` while dragging with the Perspective Selection tool; `e` while dragging a Selection or Group Selection marquee; `c` and `f` while dragging out an arc; `f`, `v`, `x` and `c` while dragging out a rectangular or polar grid). | | `type_text` | `{text}` | Remote only. | -| `answer_dialog` | `{set?: [{field, value?}], action?}` | Remote only. Sets fields of the app's open dialog in the order given with one `ui.dialog.set {fields, action?}` (a missing `value` is `null`). The app stores all of them or none, then answers that same dialog with `action` in the same request: `confirm` (OK) or `cancel`. Another connection cannot open a dialog between the two steps. When the app refuses the `ui.dialog.set`, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. `set` cannot change a `__` field other than the dialog's controls held under a `__` name (such as Save PDF's `__section` or the Preferences `__search`): the `__command` and `__params` of a `confirm` or `command` dialog, and every other `__` field that holds what OK acts on, are refused with "the `` dialog cannot set protected field ``", so OK runs what the dialog was opened for. `action` alone is sent as `ui.dialog.confirm` or `ui.dialog.cancel`. Give `set`, `action` or both; `set` holds at most 256 fields. `inspect_ui` shows the open dialog and its fields as `ui.dialog`. Returns `{dialog, result}`: the dialog after the fields were set (or `null`) and the reply to `confirm` or `cancel` (or `null`). After `invoke_menu` `app.quit`, `file.close` or `file.closeAll` replies `{"pending": "saveChanges"}`, `{action: "confirm"}` saves, `{set: [{field: "choice", value: "dontSave"}]}` followed by a second call with `{action: "confirm"}` closes without saving, and `{action: "cancel"}` cancels the close or quit. `choice` takes `save`, `dontSave` or `cancel`; while more modified documents wait to be asked about, adding `{field: "applyToAll", value: true}` to `set` gives the same answer for each of them. The second call answers whichever dialog is open when it arrives, so a dialog that another client or the user opens between the two calls is answered instead. | +| `answer_dialog` | `{set?: [{field, value?}], action?}` | Remote only. Sets fields of the app's open dialog in the order given with one `ui.dialog.set {fields, action?}` (a missing `value` is `null`). The app stores all of them or none, then answers that same dialog with `action` in the same request: `confirm` (OK) or `cancel`. Another connection cannot open a dialog between the two steps. When the app refuses the `ui.dialog.set`, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. `set` cannot change a `__` field other than the dialog's controls held under a `__` name (such as Save PDF's `__section` or the Preferences `__search`): the `__command` and `__params` of a `confirm` or `command` dialog, and every other `__` field that holds what OK acts on, are refused with "the `` dialog cannot set protected field ``", so OK runs what the dialog was opened for. `action` alone is sent as `ui.dialog.confirm` or `ui.dialog.cancel`. Give `set`, `action` or both; `set` holds at most 256 fields. `inspect_ui` shows the open dialog and its fields as `ui.dialog`. Returns `{dialog, result}`: the dialog after the fields were set (or `null`) and the reply to `confirm` or `cancel` (or `null`). After `invoke_menu` `app.quit`, `file.close` or `file.closeAll` replies `{"pending": "saveChanges"}`, `{action: "confirm"}` saves, `{set: [{field: "choice", value: "dontSave"}]}` followed by a second call with `{action: "confirm"}` closes without saving, and `{action: "cancel"}` cancels the close or quit. `choice` takes `save`, `dontSave` or `cancel`; while more modified documents wait to be asked about, adding `{field: "applyToAll", value: true}` to `set` gives the same answer for each of them. Give `set` and `action` in separate calls for this question: in one call, `answer_dialog` sends a second `confirm`, which fails once the document has closed or answers the next document's question. The second call answers whichever dialog is open when it arrives, so a dialog that another client or the user opens between the two calls is answered instead. | | `invoke_menu` | `{command, params?}` | Invokes a menu item by command id. UI commands such as `view.*` and `window.*` are in `command_list` with `ui: true`; running them needs the desktop app (`--connect`). The app refuses `attributes.openUrl`, `file.export.svg.browser`, `file.saveForWeb.browser` and `file.showPackage` for every control and MCP request, since each opens another app, so the headless error for them does not suggest `--connect`. | | `open_panel` | `{panel}` | Remote only. `panel` is a panel id (`layers`, `swatches`, `colorGuide`, …, as `window.panel` takes) or its display label (`"Color Guide"`), in any case. | | `screenshot` | `{path?, scale?, artboard?, window?, max_side?, traceViews?}` | Returns MCP image content (`image/png`, base64) plus a text block. Renders the artboard with the pixels of a PNG `export` with `background: "white"` at the same scale; `traceViews:true` draws Image Trace objects in the view set with `imageTrace.setView`, as in the app's window; `window:true` captures the app window (remote only), as `ui_screenshot` does, and `max_side` (1–4096, window captures only) scales the returned image down as described for `ui_screenshot`. With `path` the backend (the headless session or the app) writes the PNG there too; a window capture written there keeps its full size with `max_side`. An app that does not send the image back writes a window capture without `path` to a file in a new folder inside the system's temporary folder (on Unix only the user can open it); the server reads the file and then removes the folder, also when the capture or the read fails. | From 9251d4a129b8feb9f610bfbf2fd2c3129abe2baf Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 11:11:17 -0800 Subject: [PATCH 04/10] Agents: control clients can't change the agent settings A window started with --control and no automation roots answers its control requests unconfined, so `prefs.agents` saved any readRoot, writeRoot or controlPort such a client sent. The agent folders it widened then held for every later agent session. `prefs.agents` now refuses a change whenever automation sent the request (a control or MCP request, or a pass that carries injected input), as `automation_is_acting` already does for commands that open another app. Reading the settings still works. The params text, its MCP mirror and docs/mcp.md say so. --- crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/agents.rs | 6 ++++-- crates/ui-egui/src/agents/tests.rs | 24 ++++++++++++++++++++++++ crates/ui-egui/src/menus/ui_commands.rs | 2 +- docs/mcp.md | 2 +- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 391c861e66..681bdf01ee 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -175,7 +175,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "prefs.agents", "AI Integrations", "", - "{controlPort?: 0–65535, readRoot?: string, writeRoot?: string, whenAppClosed?: launch|headless|error} the agent settings of Preferences › AI Integrations (agents in the open window through the ArtCraft Launcher's switch); given keys are saved where vectorcraft-cli mcp reads them, refused from an agent's request → {settings, status: {port, launchFlags, error}, allowed, mcpFlag}; an error in the web build and in a run without preferences", + "{controlPort?: 0–65535, readRoot?: string, writeRoot?: string, whenAppClosed?: launch|headless|error} the agent settings of Preferences › AI Integrations (agents in the open window through the ArtCraft Launcher's switch); given keys are saved where vectorcraft-cli mcp reads them, refused from an agent's or a control client's request → {settings, status: {port, launchFlags, error}, allowed, mcpFlag}; an error in the web build and in a run without preferences", ), ("edit.keyboardShortcuts", "Keyboard Shortcuts…", "Cmd+Alt+Shift+K", "{}"), ( diff --git a/crates/ui-egui/src/agents.rs b/crates/ui-egui/src/agents.rs index 4ab629e70a..3f6fae9bae 100644 --- a/crates/ui-egui/src/agents.rs +++ b/crates/ui-egui/src/agents.rs @@ -147,8 +147,10 @@ const KEYS: [&str; 4] = ["controlPort", "readRoot", "writeRoot", "whenAppClosed" /// `prefs.agents`: the agent settings of Preferences › AI Integrations, the link's status and the /// launcher's switch. `{controlPort?, readRoot?, writeRoot?, whenAppClosed?}` changes and saves those /// settings first. Agents can't change them: their requests run confined to the agent folders, and -/// widening those is the person's choice. +/// widening those is the person's choice. A control client started without automation roots can't +/// change them either. pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result { + let automated = app.automation_is_acting() || file_access::current().is_some(); let Some(agents) = app.agents.as_mut() else { return Err("agents can't use this window: it keeps no preferences (VECTORCRAFT_NO_PREFS), or it is a nightly".into()); }; @@ -157,7 +159,7 @@ pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result Date: Fri, 4 Dec 2026 12:21:49 -0800 Subject: [PATCH 05/10] MCP: answer_dialog's Save Changes answer drops the one-call failure claim The answer_dialog row in docs/mcp.md and the tool description still give Don't Save as two calls and say to give set and action in separate calls for this question. They no longer state that a single call sends a second confirm: that holds only while ui.dialog.set with an action replies without a dialog key, and the two-call sequence works either way. The conventions test no longer rejects the one-call form. --- crates/mcp/src/tests/conventions.rs | 1 - crates/mcp/src/tools/definitions.rs | 2 +- docs/mcp.md | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/mcp/src/tests/conventions.rs b/crates/mcp/src/tests/conventions.rs index 839c740ec1..216e6279ee 100644 --- a/crates/mcp/src/tests/conventions.rs +++ b/crates/mcp/src/tests/conventions.rs @@ -432,7 +432,6 @@ fn answer_dialog_describes_the_save_changes_answers() { assert!(description.contains(snippet), "answer_dialog's description is missing {snippet}: {description}"); } assert!(!description.contains("discard"), "the save-changes dialog takes choice, not discard: {description}"); - assert!(!description.contains(r#"value:"dontSave"}],action:"confirm"}"#), "Don't Save must confirm in a second call: {description}"); } #[test] diff --git a/crates/mcp/src/tools/definitions.rs b/crates/mcp/src/tools/definitions.rs index 63c3dadc05..9eb55a846f 100644 --- a/crates/mcp/src/tools/definitions.rs +++ b/crates/mcp/src/tools/definitions.rs @@ -314,7 +314,7 @@ pub fn tool_definitions() -> Vec { tool( "answer_dialog", "Answer dialog", - "Set fields of the desktop app's open dialog in order, then confirm (OK) or cancel it, as the control protocol's ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel do. The app stores all the fields or none and answers that same dialog in the same request (ui.dialog.set with action). When the app refuses the ui.dialog.set, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. inspect_ui shows the open dialog and its fields (ui.dialog). After invoke_menu app.quit, file.close or file.closeAll replies {\"pending\":\"saveChanges\"}: {action:\"confirm\"} saves, {set:[{field:\"choice\",value:\"dontSave\"}]} followed by a second call with {action:\"confirm\"} closes without saving, and {action:\"cancel\"} cancels the close or quit. choice takes save, dontSave or cancel; while more modified documents wait to be asked about, adding {field:\"applyToAll\",value:true} to set gives the same answer for each of them. Give set and action in separate calls for this question: in one call, answer_dialog sends a second confirm, which fails once the document has closed or answers the next document's question. The second call answers whichever dialog is open when it arrives. Returns {dialog, result}: the dialog after the fields were set, and the reply to confirm or cancel. Desktop app only.", + "Set fields of the desktop app's open dialog in order, then confirm (OK) or cancel it, as the control protocol's ui.dialog.set, ui.dialog.confirm and ui.dialog.cancel do. The app stores all the fields or none and answers that same dialog in the same request (ui.dialog.set with action). When the app refuses the ui.dialog.set, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. inspect_ui shows the open dialog and its fields (ui.dialog). After invoke_menu app.quit, file.close or file.closeAll replies {\"pending\":\"saveChanges\"}: {action:\"confirm\"} saves, {set:[{field:\"choice\",value:\"dontSave\"}]} followed by a second call with {action:\"confirm\"} closes without saving, and {action:\"cancel\"} cancels the close or quit. choice takes save, dontSave or cancel; while more modified documents wait to be asked about, adding {field:\"applyToAll\",value:true} to set gives the same answer for each of them. Give set and action in separate calls for this question. The second call answers whichever dialog is open when it arrives. Returns {dialog, result}: the dialog after the fields were set, and the reply to confirm or cancel. Desktop app only.", obj( json!({ "set": { diff --git a/docs/mcp.md b/docs/mcp.md index b6ea0dc8a2..5f257f280a 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -818,7 +818,7 @@ ends the wait, so the sampler can be shown again. The BSDs and headless sessions | `set_paint` | `{fill?, stroke?, strokeWidth?, ids?}` | Applies to the selection (or `ids`) and becomes the default for new art. Returns `{applied, objects}`: `objects` is the number of objects painted, as the `objects` of the `paint.setFill`, `paint.setStroke` and `stroke.set` replies (the largest of them): a selected group counts the objects inside it. When it is 0, a `note` says that only the paint for new art changed. When some of those commands painted objects and others painted none (a fill while the Shape Builder is the active tool, say), `unpainted` lists the commands that painted none, with a `note`. | | `press_key` | `{key, mods?}` | Remote: a real key event. Headless: runs the command or tool bound to that shortcut, or sends the key to the busy tool (digits too: `5` while dragging with the Perspective Selection tool; `e` while dragging a Selection or Group Selection marquee; `c` and `f` while dragging out an arc; `f`, `v`, `x` and `c` while dragging out a rectangular or polar grid). | | `type_text` | `{text}` | Remote only. | -| `answer_dialog` | `{set?: [{field, value?}], action?}` | Remote only. Sets fields of the app's open dialog in the order given with one `ui.dialog.set {fields, action?}` (a missing `value` is `null`). The app stores all of them or none, then answers that same dialog with `action` in the same request: `confirm` (OK) or `cancel`. Another connection cannot open a dialog between the two steps. When the app refuses the `ui.dialog.set`, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. `set` cannot change a `__` field other than the dialog's controls held under a `__` name (such as Save PDF's `__section` or the Preferences `__search`): the `__command` and `__params` of a `confirm` or `command` dialog, and every other `__` field that holds what OK acts on, are refused with "the `` dialog cannot set protected field ``", so OK runs what the dialog was opened for. `action` alone is sent as `ui.dialog.confirm` or `ui.dialog.cancel`. Give `set`, `action` or both; `set` holds at most 256 fields. `inspect_ui` shows the open dialog and its fields as `ui.dialog`. Returns `{dialog, result}`: the dialog after the fields were set (or `null`) and the reply to `confirm` or `cancel` (or `null`). After `invoke_menu` `app.quit`, `file.close` or `file.closeAll` replies `{"pending": "saveChanges"}`, `{action: "confirm"}` saves, `{set: [{field: "choice", value: "dontSave"}]}` followed by a second call with `{action: "confirm"}` closes without saving, and `{action: "cancel"}` cancels the close or quit. `choice` takes `save`, `dontSave` or `cancel`; while more modified documents wait to be asked about, adding `{field: "applyToAll", value: true}` to `set` gives the same answer for each of them. Give `set` and `action` in separate calls for this question: in one call, `answer_dialog` sends a second `confirm`, which fails once the document has closed or answers the next document's question. The second call answers whichever dialog is open when it arrives, so a dialog that another client or the user opens between the two calls is answered instead. | +| `answer_dialog` | `{set?: [{field, value?}], action?}` | Remote only. Sets fields of the app's open dialog in the order given with one `ui.dialog.set {fields, action?}` (a missing `value` is `null`). The app stores all of them or none, then answers that same dialog with `action` in the same request: `confirm` (OK) or `cancel`. Another connection cannot open a dialog between the two steps. When the app refuses the `ui.dialog.set`, for example because no dialog is open, the call is an error and the dialog is not confirmed or canceled. `set` cannot change a `__` field other than the dialog's controls held under a `__` name (such as Save PDF's `__section` or the Preferences `__search`): the `__command` and `__params` of a `confirm` or `command` dialog, and every other `__` field that holds what OK acts on, are refused with "the `` dialog cannot set protected field ``", so OK runs what the dialog was opened for. `action` alone is sent as `ui.dialog.confirm` or `ui.dialog.cancel`. Give `set`, `action` or both; `set` holds at most 256 fields. `inspect_ui` shows the open dialog and its fields as `ui.dialog`. Returns `{dialog, result}`: the dialog after the fields were set (or `null`) and the reply to `confirm` or `cancel` (or `null`). After `invoke_menu` `app.quit`, `file.close` or `file.closeAll` replies `{"pending": "saveChanges"}`, `{action: "confirm"}` saves, `{set: [{field: "choice", value: "dontSave"}]}` followed by a second call with `{action: "confirm"}` closes without saving, and `{action: "cancel"}` cancels the close or quit. `choice` takes `save`, `dontSave` or `cancel`; while more modified documents wait to be asked about, adding `{field: "applyToAll", value: true}` to `set` gives the same answer for each of them. Give `set` and `action` in separate calls for this question. The second call answers whichever dialog is open when it arrives, so a dialog that another client or the user opens between the two calls is answered instead. | | `invoke_menu` | `{command, params?}` | Invokes a menu item by command id. UI commands such as `view.*` and `window.*` are in `command_list` with `ui: true`; running them needs the desktop app (`--connect`). The app refuses `attributes.openUrl`, `file.export.svg.browser`, `file.saveForWeb.browser` and `file.showPackage` for every control and MCP request, since each opens another app, so the headless error for them does not suggest `--connect`. | | `open_panel` | `{panel}` | Remote only. `panel` is a panel id (`layers`, `swatches`, `colorGuide`, …, as `window.panel` takes) or its display label (`"Color Guide"`), in any case. | | `screenshot` | `{path?, scale?, artboard?, window?, max_side?, traceViews?}` | Returns MCP image content (`image/png`, base64) plus a text block. Renders the artboard with the pixels of a PNG `export` with `background: "white"` at the same scale; `traceViews:true` draws Image Trace objects in the view set with `imageTrace.setView`, as in the app's window; `window:true` captures the app window (remote only), as `ui_screenshot` does, and `max_side` (1–4096, window captures only) scales the returned image down as described for `ui_screenshot`. With `path` the backend (the headless session or the app) writes the PNG there too; a window capture written there keeps its full size with `max_side`. An app that does not send the image back writes a window capture without `path` to a file in a new folder inside the system's temporary folder (on Unix only the user can open it); the server reads the file and then removes the folder, also when the capture or the read fails. | From 6c314c4cd68ee5208689f2d4ef443612f5f3b16a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 12:57:51 -0800 Subject: [PATCH 06/10] Docs: the control protocol gives Don't Save in one ui.dialog.set request ui.dialog.set with fields and action "confirm" sets choice (and applyToAll) and confirms the same Save Changes question in one request, so no other dialog is answered between the two. The control-protocol row now gives that form beside the two-request one, and the Save Changes test checks the line and sends both one-request forms through the control handler. --- crates/ui-egui/src/unsaved.rs | 22 ++++++++++++++++++++-- docs/control-protocol.md | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/unsaved.rs b/crates/ui-egui/src/unsaved.rs index 252f3cc8a5..5259c30efb 100644 --- a/crates/ui-egui/src/unsaved.rs +++ b/crates/ui-egui/src/unsaved.rs @@ -401,6 +401,7 @@ mod tests { const CONTROL_DONT_SAVE: &str = r#"`ui.dialog.set {field: "choice", value: "dontSave"}` then confirm"#; const CONTROL_APPLY_TO_ALL: &str = r#"`ui.dialog.set {field: "applyToAll", value: true}` before confirm"#; + const CONTROL_ONE_REQUEST: &str = r#"`ui.dialog.set {fields: [{field: "choice", value: "dontSave"}], action: "confirm"}`"#; const MCP_DONT_SAVE: &str = r#"`{set: [{field: "choice", value: "dontSave"}]}` followed by a second call with `{action: "confirm"}`"#; const MCP_APPLY_TO_ALL: &str = r#"adding `{field: "applyToAll", value: true}` to `set`"#; @@ -410,8 +411,12 @@ mod tests { #[test] fn the_documented_dont_save_answer_closes_without_saving() { for (name, text, snippets) in [ - ("docs/control-protocol.md", include_str!("../../../docs/control-protocol.md"), [CONTROL_DONT_SAVE, CONTROL_APPLY_TO_ALL]), - ("docs/mcp.md", include_str!("../../../docs/mcp.md"), [MCP_DONT_SAVE, MCP_APPLY_TO_ALL]), + ( + "docs/control-protocol.md", + include_str!("../../../docs/control-protocol.md"), + &[CONTROL_DONT_SAVE, CONTROL_APPLY_TO_ALL, CONTROL_ONE_REQUEST][..], + ), + ("docs/mcp.md", include_str!("../../../docs/mcp.md"), &[MCP_DONT_SAVE, MCP_APPLY_TO_ALL][..]), ] { // Check the requests on every line describing the pending Save Changes reply. let lines: Vec<_> = text.lines().filter(|line| line.contains(r#"{"pending": "saveChanges"}"#)).collect(); @@ -444,6 +449,19 @@ mod tests { ("ui.dialog.confirm", json!({})), ], ), + ( + "control protocol one request", + false, + vec![("ui.dialog.set", json!({ "fields": [{ "field": "choice", "value": "dontSave" }], "action": "confirm" }))], + ), + ( + "control protocol one request applyToAll", + true, + vec![( + "ui.dialog.set", + json!({ "fields": [{ "field": "choice", "value": "dontSave" }, { "field": "applyToAll", "value": true }], "action": "confirm" }), + )], + ), ( "MCP Don't Save", false, diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 783c686f45..5b280ec8f8 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -107,7 +107,7 @@ the two can still win that race. | `ui.render` | `{path?, scale?, artboard?, data?, traceViews?}` | render an artboard headlessly (PNG with the pixels of `app.export {format: "png", background: "white"}` at the same scale; `artboard`: its 0-based index, default the first; `traceViews: true`: Image Trace objects draw in their View, as on the canvas, instead of their tracing result): written to `path`, else (or with `data: true` as well) sent back as `pngBase64` | | `ui.resize` | `{width?, height?}` | request the window's inner size; omitted or null `width` and `height` default to 1440 and 900. Returns `null` | | `ui.focus` | `{}` | request keyboard focus for the window. Returns `null` | -| `app.open` / `app.save` / `app.export` / `app.quit` | `{path, importer?, params?}` / `{path?}` / `{path?, format?, artboard?, range?, scale?, …}` | `app.open` reads every format `document.open` reads (see `document.formats`) and returns its result (`{index, title, format, warnings, …}`; `warnings` say what didn't come in as it was, such as an EPS shown as its preview image and why its PostScript couldn't be read), or null when a dialog asks first or a library loads. The status bar (`ui.inspect` → `ui.status`), after a line about the document's linked files when there is one (Missing linked files below), counts the `warnings` and names the first that says reading the file left something out (the notes that make Save ask before writing over it), else the first; with several, hovering it lists them in that order, as many as fit in the window (at most 30), then how many more. After `app.save`, and `app.export` with a `path`, the status bar counts the reply's `warnings` and names the first, and with several, hovering it lists them in the reply's order (a save's notes start with what the format loses). With `importer` (an importer plug-in's format id, `plugin.`) it runs `file.openWith`: the file opens with that importer, also when a built-in format reads its extension, with the importer's parameters `params` (their defaults when omitted; no dialog asks for them). Without `importer`, `params` go to the importer that opens the file, and a built-in format does not read them. `app.export` encodes through the engine's `document.export` (same options; the document keeps its path) and writes `path` through the host; without `path` it returns `{dataBase64, format, bytes}`, as headless mode does. It refuses a key that no format takes, and an unknown key inside a PDF or EPS option object, before it writes anything (`docs/mcp.md`, Parameter keys). It accepts a key that only another format takes and does not use it: the reply's `warnings` and the status bar name the key ("`quality` was not used: PDF files don't read it"). `app.save` refuses a key that no save format takes, beside the path or in `options`, the same way. `app.quit`, `file.close` and `file.closeAll` first open a `saveChanges` dialog for each modified document (they return `{"pending": "saveChanges"}`): `ui.dialog.confirm` saves, `ui.dialog.set {field: "choice", value: "dontSave"}` then confirm closes the document without saving, `ui.dialog.cancel` cancels the whole close or quit. `choice` takes `save`, `dontSave` or `cancel`, and any other field or value is an error. While more modified documents wait to be asked about, the dialog also has `applyToAll`: `ui.dialog.set {field: "applyToAll", value: true}` before confirm gives the same answer for each of them | +| `app.open` / `app.save` / `app.export` / `app.quit` | `{path, importer?, params?}` / `{path?}` / `{path?, format?, artboard?, range?, scale?, …}` | `app.open` reads every format `document.open` reads (see `document.formats`) and returns its result (`{index, title, format, warnings, …}`; `warnings` say what didn't come in as it was, such as an EPS shown as its preview image and why its PostScript couldn't be read), or null when a dialog asks first or a library loads. The status bar (`ui.inspect` → `ui.status`), after a line about the document's linked files when there is one (Missing linked files below), counts the `warnings` and names the first that says reading the file left something out (the notes that make Save ask before writing over it), else the first; with several, hovering it lists them in that order, as many as fit in the window (at most 30), then how many more. After `app.save`, and `app.export` with a `path`, the status bar counts the reply's `warnings` and names the first, and with several, hovering it lists them in the reply's order (a save's notes start with what the format loses). With `importer` (an importer plug-in's format id, `plugin.`) it runs `file.openWith`: the file opens with that importer, also when a built-in format reads its extension, with the importer's parameters `params` (their defaults when omitted; no dialog asks for them). Without `importer`, `params` go to the importer that opens the file, and a built-in format does not read them. `app.export` encodes through the engine's `document.export` (same options; the document keeps its path) and writes `path` through the host; without `path` it returns `{dataBase64, format, bytes}`, as headless mode does. It refuses a key that no format takes, and an unknown key inside a PDF or EPS option object, before it writes anything (`docs/mcp.md`, Parameter keys). It accepts a key that only another format takes and does not use it: the reply's `warnings` and the status bar name the key ("`quality` was not used: PDF files don't read it"). `app.save` refuses a key that no save format takes, beside the path or in `options`, the same way. `app.quit`, `file.close` and `file.closeAll` first open a `saveChanges` dialog for each modified document (they return `{"pending": "saveChanges"}`): `ui.dialog.confirm` saves, `ui.dialog.set {field: "choice", value: "dontSave"}` then confirm closes the document without saving, `ui.dialog.cancel` cancels the whole close or quit. `choice` takes `save`, `dontSave` or `cancel`, and any other field or value is an error. While more modified documents wait to be asked about, the dialog also has `applyToAll`: `ui.dialog.set {field: "applyToAll", value: true}` before confirm gives the same answer for each of them. `ui.dialog.set {fields: [{field: "choice", value: "dontSave"}], action: "confirm"}` answers the same question in one request, so no other dialog can be answered between the set and the confirm, and `{field: "applyToAll", value: true}` can go in the same `fields` | | `app.export` with `useArtboards` | `{path, useArtboards: true, range? \| artboards?, …}` | Export As: PNG, JPEG and WebP write one file per chosen artboard (default all; SVG does so for a `range`), `-.`, and return `{path, files: [path…]}`; a PDF keeps them as pages of `path`. `useArtboards: false` covers the bounds of the visible art. The menu's Export As… is `file.exportAs`: the `exportAs` dialog (`format`, `useArtboards`, `all`, `range`), then a save dialog and the format's options: `pngOptions` / `jpgOptions` / `webpOptions`, `svgOptions`, or `savePdf` for a PDF | | `ui.dialog.*` on `gradientStop` | `{field: "color" \| "opacity" \| "location", value}` | double-clicking a stop on the Gradient tool's annotator opens its popover (fields `index`, `x`, `y`, `tab`); set `color` (hex), `opacity` or `location` (percentages) and `ui.dialog.confirm` to apply them to the selected stop. `gradient.selectStop {index}` picks the stop the annotator, the panels and Delete/←/→ (`ui.key`) act on | | `engine.execute` `ui.savePdfDialog` | `{path?, preset?, range?, …document.exportPdf options}` | opens the Save PDF dialog (`file.export.pdf` with no params opens it too). Its fields are the `document.exportPdf` options: set `compatibility` with `ui.dialog.set {field: "compatibility", value: "1.5"}`, a section with `{field: "compression", value: {…}}` (the options it leaves out keep the dialog's values, in Save PDF and in the preset editor, and in an object inside a section such as `compression.color`; a value that isn't an object, null included, is an error), the artboards with `__allArtboards: false` and `range`, the visible section with `__section` (General, Compression, Marks and Bleeds, Output, Advanced, Security, Summary), and the bleed link with `__bleedLinked` (true gives every side the top value; any value other than true or false is an error; setting `bleed` turns the link on when its four sides are equal and off when they differ). In Advanced, Custom… beside Flattener preset (enabled when the file is flattened: PDF 1.3, PDF/X-1a, PDF/X-3) opens the `pdfFlattenerOptions` dialog over Save PDF on the flattener options the save would use; its fields are those options, with `clipComplexRegions`, `preserveAlpha` and `preserveOverprints` set by the writer and Overprint. Its `ui.dialog.confirm` sets `flattener` (the preset then shows [Custom]; options equal to the preset's leave it unset) and goes back to Save PDF, and `ui.dialog.cancel` goes back unchanged. Setting `flattenerPreset` drops `flattener`. `useArtboards: false` opens it for one page of the visible art's bounds, as Export As with Use Artboards off does: the dialog has no Artboards section and its `__artBounds` field is true. `ui.dialog.confirm` writes `path` (else asks for one), returns `{path, bytes, warnings}` and opens the file when `viewAfterSaving` is set. With `useArtboards: false` it writes the page as `app.export` does and returns `{path, warnings}`, or `{background: true, status}` while Background Export writes it | From a92e9610588b3f25c31ad9194ae63e7cfbdd37cd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 13:17:59 -0800 Subject: [PATCH 07/10] Docs: composite fonts that placed editable art brings, and their errors docs/mcp.md now says which composite fonts file.place and links.embed bring with editable art, when a placed font keeps its name, reuses an equal one or takes a free name, and quotes the errors that stop the placement before either document changes. --- docs/mcp.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/mcp.md b/docs/mcp.md index ee2d767223..a51225256b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -11803,6 +11803,19 @@ clipping path when placed, linked, relinked, updated, or embedded. `file.place.i report CMYK for these images. VectorCraft's native CMYK limit is 67,108,864 pixels. Composites with transparency, images beyond that limit, and native samples beyond the allocation allowance use the RGB import path, subject to its allocation limit. Importing individual layers with `layers: true` retains its existing behavior. +Editable art that `file.place` places (with `link: false` or from `dataBase64`) and that `links.embed` embeds brings +the composite fonts its type and graph labels name, including those of the symbols, patterns and brushes it uses. +Placement first reuses an equal composite font with the same name (in any case) in the document, keeping its name. +Otherwise, a composite font whose name the document already uses (for a different composite font, a part of one, or a family its +type or styles name) or that an installed font has, joins under a free name such as "Name 2", unless the document +already has an equal definition under another name, which the placed art then uses; the placed art is renamed to +match. Before either document changes, the placement fails and changes nothing with one of these errors: "a document +keeps at most 256 composite fonts" (when the placed art uses more than 256, the document has more than 256, or more +than 256 remain after equal definitions are shared); "two incoming composite fonts are named ``"; "`` is +the name of an installed font"; "the composite fonts in the placed art and document cannot stand together"; "no free +name for a placed composite font"; or an error for an invalid definition as stored in the file, such as +"`` can't name a composite font", "a composite font keeps at most 64 character sets" or a part's size out of range. +Placement does not trim composite font or character set names as `type.compositeFonts.set` does. `file.place.info` describes a file without placing it and `image.info` reports a placed image's link, colour mode and effective ppi. `file.place.queue` loads the place cursor (the `place` tool) with several files: headless, drive it From 889327e85d09c0df9caef28aa54a740b8918f167 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 14:32:59 -0800 Subject: [PATCH 08/10] Paste: read CAD apps' metafiles on Windows and copied DXF, DWG and HP-GL files Paste on Windows never read the enhanced metafile that CAD and office apps put on the clipboard as vector art: windows_formats had no entry for EMF, so the app pasted their bitmap instead, or nothing. The Windows clipboard holds an EMF as a handle (CF_ENHMETAFILE, which Windows also makes from CF_METAFILEPICT), so the app now copies its records with GetEnhMetaFileBits, at most 64 MiB, and pastes them through clipboard.importEmf. A .dxf, .dwg or HP-GL plot file copied in a file manager did not paste, because file_flavour had no flavour for them, though Open and Place read all three. They now paste as image/vnd.dxf, image/vnd.dwg and application/vnd.hp-hpgl through the new command clipboard.importCad {dataBase64, format: dxf|dwg|hpgl, center?}, read as document.open reads the file. A file pastes this way only when its bytes are the format, so a chart script named .plt is not taken for a plot. Fixes #10819. --- ROADMAP.md | 2 + apps/vectorcraft/src/clipboard.rs | 91 +++++++++++++++++-- crates/cad/src/hpgl.rs | 6 ++ crates/engine/src/cmd/clipboard.rs | 4 +- crates/engine/src/cmd/clipboard/flavours.rs | 71 ++++++++++++--- .../engine/src/cmd/fileio/tests_dwgimport.rs | 29 ++++++ .../engine/src/cmd/fileio/tests_dxfimport.rs | 27 ++++++ crates/engine/src/cmd/fileio/tests_hpgl.rs | 28 ++++++ crates/engine/tests/import_fuzz.rs | 10 ++ crates/ui-egui/src/sysclip.rs | 14 ++- crates/ui-egui/src/tests/sysclip_emf.rs | 26 +++++- docs/mcp.md | 9 +- 12 files changed, 286 insertions(+), 31 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 616e6eea9d..b59eea470a 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -124,6 +124,8 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap ## Progress log +- 2026-12-04: Paste from CAD apps: on Windows, Paste reads the enhanced metafile CAD and office apps copy as vector art, and a `.dxf`, `.dwg` or HP-GL plot file copied in a file manager pastes as its drawing through the new command `clipboard.importCad` (#10819). Headline numbers unchanged. + - 2026-12-03: View › Show Curvature Comb (`view.curvatureComb`) draws the curvature comb of the selected paths and compound paths: teeth along the normal as long as the curvature, and a line through their tips that starts again where the path turns back on itself at a cusp, a straight segment included (#10659). Headline numbers unchanged. - 2026-12-02: The desktop Print dialog looks up installed printers in the background. Named printers become selectable after the lookup returns and the dialog applies the list. PDF File is available at once. Physical printing waits for the list to be applied, and Done can save settings while the lookup runs. The dialog shows and announces discovery and disables physical Print until the list is applied. diff --git a/apps/vectorcraft/src/clipboard.rs b/apps/vectorcraft/src/clipboard.rs index 0d886789e2..e9737ab251 100644 --- a/apps/vectorcraft/src/clipboard.rs +++ b/apps/vectorcraft/src/clipboard.rs @@ -2,8 +2,10 @@ //! (`Services::clipboard`). //! //! - Windows: text, SVG, PDF, PNG and an opaque bitmap (for apps that don't read PNG) in one go; -//! Paste reads each of them and EPS, a bitmap as PNG, else as the device-independent bitmap that -//! screenshots and most apps copy (`CF_DIBV5`, `CF_DIB`; the system makes them of a `CF_BITMAP`). +//! Paste reads each of them and EPS, the enhanced metafile that CAD and office apps copy as +//! vector art (`CF_ENHMETAFILE`; the system makes one of a `CF_METAFILEPICT`), a bitmap as PNG, +//! else as the device-independent bitmap that screenshots and most apps copy (`CF_DIBV5`, +//! `CF_DIB`; the system makes them of a `CF_BITMAP`). //! - macOS: text, SVG, PDF and PNG in one go: arboard writes the text, else the PNG as TIFF, and //! the other formats are added to the same pasteboard item ([`pasteboard_additions`]); Paste //! reads text and bitmaps, the pasteboard's SVG, PDF and EPS as vector art (#1499) and its PNG @@ -19,7 +21,8 @@ //! that copied to send its data (a bitmap 10 s), and until that app answers, later reads fail at //! once; a paste then waits for that read's answer off the UI thread. //! - Everywhere: files copied in a file manager paste as the first one that is art (SVG, PDF, EPS, -//! a metafile or a bitmap), before the clipboard's other formats (the files' paths as text). A +//! a metafile, a DXF or DWG drawing, an HP-GL plot file or a bitmap), before the clipboard's +//! other formats (the files' paths as text). A //! file of more than 64 MiB is skipped before it is read. use std::io::{Cursor, Read}; @@ -303,6 +306,23 @@ fn copy_within(size: Option, limit: usize, copy: impl FnOnce() -> Option< copy().filter(|data| data.len() <= limit) } +/// The records of an enhanced metafile, which the Windows clipboard holds as a handle +/// (`CF_ENHMETAFILE`) whose records `GetEnhMetaFileBits` copies: `bits` called without a buffer +/// gives their size, and with a buffer copies them and gives how many bytes it copied (0 when it +/// failed). Nothing is copied when the size is 0 or more than `limit` bytes ([`copy_within`]). +#[cfg_attr(not(windows), allow(dead_code))] +fn enhmetafile_bits(mut bits: impl FnMut(Option<&mut [u8]>) -> u32, limit: usize) -> Option> { + let size = usize::try_from(bits(None)).ok(); + copy_within(size, limit, || { + let mut data = vec![0; size?]; + let copied = usize::try_from(bits(Some(&mut data))).ok()?; + (copied > 0 && copied <= data.len()).then(|| { + data.truncate(copied); + data + }) + }) +} + /// The most bytes of UTF-8 that `utf16` bytes of UTF-16 text come to: a code unit (2 bytes) is at /// most 3 bytes of UTF-8, and a surrogate pair (4 bytes) is 4. #[cfg_attr(not(windows), allow(dead_code))] @@ -428,10 +448,12 @@ mod win { use std::path::PathBuf; + use windows::Win32::Graphics::Gdi::{GetEnhMetaFileBits, HENHMETAFILE}; + use super::{ - BITMAP, ClipboardBackend, ClipboardError, ClipboardImage, ClipboardRead, Cursor, Flavor, Flavour, LaterFlavor, MAX_BYTES, MAX_URIS, PNG, SVG, - TEXT, copied_file, copy_within, decode_png, dib_image, drop_files_within, png_flavour, read_flavor, read_image_flavor, read_later_flavor, - utf8_most, windows_formats, + BITMAP, ClipboardBackend, ClipboardError, ClipboardImage, ClipboardRead, Cursor, EMF, Flavor, Flavour, LaterFlavor, MAX_BYTES, MAX_URIS, PNG, + SVG, TEXT, copied_file, copy_within, decode_png, dib_image, drop_files_within, enhmetafile_bits, png_flavour, read_flavor, read_image_flavor, + read_later_flavor, utf8_most, windows_formats, }; /// The device-independent bitmaps, the one that carries alpha first. Each is there whenever the @@ -533,6 +555,7 @@ mod win { || mimes.iter().any(|m| match *m { TEXT => raw::is_format_avail(formats::CF_UNICODETEXT), BITMAP => DIBS.into_iter().chain(formats_of(PNG)).any(raw::is_format_avail), + EMF => raw::is_format_avail(formats::CF_ENHMETAFILE), m => formats_of(m).any(raw::is_format_avail), }) } @@ -571,6 +594,19 @@ mod win { formats_of(mime).filter(|id| raw::is_format_avail(*id)).find_map(|id| copy_registered(id, MAX_BYTES).filter(|data| !data.is_empty())) } + /// The enhanced metafile the clipboard holds, while it is open, as the bytes of an EMF file; at + /// most [`MAX_BYTES`] of them ([`enhmetafile_bits`]). + #[allow(unsafe_code)] + fn read_enhmetafile() -> Option> { + if !raw::is_format_avail(formats::CF_ENHMETAFILE) { + return None; + } + let emf = HENHMETAFILE(raw::get_clipboard_data(formats::CF_ENHMETAFILE).ok()?.as_ptr()); + // SAFETY: `emf` is the clipboard's metafile handle, which stays valid while the clipboard is + // open; the call writes at most the length of the buffer it is given. + enhmetafile_bits(|buffer| unsafe { GetEnhMetaFileBits(emf, buffer) }, MAX_BYTES) + } + /// A device-independent bitmap as a PNG flavour. fn dib_png(dib: &[u8]) -> Option { png_flavour(&dib_image(dib)?) @@ -607,6 +643,7 @@ mod win { })?; (TEXT, text) } + EMF => (EMF, read_enhmetafile()?), m => (m, read_registered(m)?), }; // Memory blocks can be longer than the data: SVG text ends at its first NUL. @@ -3545,6 +3582,48 @@ mod tests { assert!(copied_file(vec![eps], &[BITMAP, TEXT]).is_none()); } + /// A DXF drawing or an HP-GL plot file copied in a file manager pastes as vector art. + #[test] + fn a_copied_cad_file_pastes() { + use vectorcraft_engine::cmd::clipboard::{DXF, HPGL}; + let d = dir("cad"); + let (dxf, plot) = (d.path().join("plan.dxf"), d.path().join("part.plt")); + std::fs::write(&dxf, "0\nSECTION\n2\nENTITIES\n0\nLINE\n8\n0\n10\n0\n20\n0\n11\n10\n21\n0\n0\nENDSEC\n0\nEOF\n").unwrap(); + std::fs::write(&plot, "IN;SP1;PA0,0;PD1016,0;PU;").unwrap(); + assert_eq!(copied_file(vec![dxf.clone()], &PASTE_ORDER).map(|f| f.mime), Some(DXF)); + assert_eq!(copied_file(vec![plot.clone()], &PASTE_ORDER).map(|f| f.mime), Some(HPGL)); + assert!(copied_file(vec![dxf, plot], &[BITMAP, TEXT]).is_none()); + } + + /// The enhanced metafile the Windows clipboard holds is copied whole, into a buffer of the size + /// it gives; one of no records or of more than the limit is not copied, and a failed copy gives + /// nothing. + #[test] + fn an_enhanced_metafile_is_copied_within_the_limit() { + let records: Vec = (0..40).collect(); + let read = |records: &[u8], fails: bool, limit: usize| { + let mut copies = 0; + let got = enhmetafile_bits( + |buffer| match buffer { + None => records.len() as u32, + Some(_) if fails => 0, + Some(buffer) => { + copies += 1; + assert_eq!(buffer.len(), records.len()); + buffer.copy_from_slice(records); + records.len() as u32 + } + }, + limit, + ); + (got, copies) + }; + assert_eq!(read(&records, false, 40), (Some(records.clone()), 1)); + assert_eq!(read(&records, false, 39), (None, 0)); + assert_eq!(read(&[], false, 40), (None, 0)); + assert_eq!(read(&records, true, 40), (None, 0)); + } + #[test] fn a_crlf_left_by_the_uri_list_is_ignored() { let d = dir("crlf"); diff --git a/crates/cad/src/hpgl.rs b/crates/cad/src/hpgl.rs index 9494fbee46..eefca332b0 100644 --- a/crates/cad/src/hpgl.rs +++ b/crates/cad/src/hpgl.rs @@ -76,6 +76,12 @@ pub fn is_hpgl(bytes: &[u8]) -> bool { holds_instructions(bytes, true) } +/// Does `bytes` start like a file named as an HP-GL plot file ([`import`] reads it)? As +/// [`is_hpgl`] checks, but any instruction may come first. +pub fn is_named_hpgl(bytes: &[u8]) -> bool { + holds_instructions(bytes, false) +} + /// Does `bytes` hold HP-GL instructions as [`is_hpgl`] checks? When `strict` is false, any of them /// may come first: a file picked by its extension may start with one a plot file seldom starts /// with (`SI`, `DI`). Either way, at least one of the instructions checked must be one the reader diff --git a/crates/engine/src/cmd/clipboard.rs b/crates/engine/src/cmd/clipboard.rs index 28a9fbaaa9..59f36b835a 100644 --- a/crates/engine/src/cmd/clipboard.rs +++ b/crates/engine/src/cmd/clipboard.rs @@ -22,7 +22,9 @@ use vectorcraft_color::Swatch; use vectorcraft_doc::{Document, GraphDesign, GraphicStyle, ImageBlob, Node, NodeId, NodeKind, PatternDef, Selection, Symbol, TextStyleDef}; use vectorcraft_geom::{PathData, Rect}; -pub use flavours::{AI, BITMAP, EMF, EPS, FILE_HEAD, Flavour, PASTE_ORDER, PDF, PNG, SVG, TEXT, file_flavour, is_address, names_a_picture}; +pub use flavours::{ + AI, BITMAP, DWG, DXF, EMF, EPS, FILE_HEAD, Flavour, HPGL, PASTE_ORDER, PDF, PNG, SVG, TEXT, file_flavour, is_address, names_a_picture, +}; pub use flavours::{ImageRead, read_image, read_pixels}; pub(crate) use resources::SwatchChoices; pub use resources::{ArtResources, SymbolOptions, art_resources}; diff --git a/crates/engine/src/cmd/clipboard/flavours.rs b/crates/engine/src/cmd/clipboard/flavours.rs index 80e31e849e..8201d8f915 100644 --- a/crates/engine/src/cmd/clipboard/flavours.rs +++ b/crates/engine/src/cmd/clipboard/flavours.rs @@ -1,5 +1,6 @@ //! Clipboard flavours: what Copy offers other apps besides SVG (PNG, PDF and plain text) and what -//! Paste takes from them (bitmaps, plain text, PDF, EPS and Windows metafiles). +//! Paste takes from them (bitmaps, plain text, PDF, EPS, Windows metafiles, and copied CAD drawing +//! and plot files). //! //! The UI owns the platform clipboard (`Services::system_clipboard` in the egui frontend): on Copy //! it publishes [`Session::clipboard_flavours`]; before a Paste it turns what another app put on @@ -34,9 +35,20 @@ pub const EPS: &str = "application/postscript"; /// reads it as `document.open` does, from its editing data. The type is VectorCraft's own: no /// system clipboard carries it, and Paste asks for [`PDF`] to get it. pub const AI: &str = "application/x-ai"; +/// A DXF drawing file copied in a file manager ([`file_flavour`]): Paste reads it with +/// `clipboard.importCad`. No system clipboard carries it, and Paste takes it when it asks for any +/// vector art. +pub const DXF: &str = "image/vnd.dxf"; +/// A DWG drawing file copied in a file manager, read as [`DXF`] is. +pub const DWG: &str = "image/vnd.dwg"; +/// An HP-GL plot file (`.plt`, `.hpgl`…) copied in a file manager, read as [`DXF`] is. +pub const HPGL: &str = "application/vnd.hp-hpgl"; /// What Paste reads from other apps, best first: vector art before text, text before bitmaps /// (word processors offer a picture of copied text too). pub const PASTE_ORDER: [&str; 6] = [SVG, PDF, EPS, EMF, TEXT, BITMAP]; +/// The types Paste asks for that a copied CAD drawing or plot file ([`DXF`], [`DWG`], [`HPGL`]) +/// pastes as. +const VECTOR_ART: [&str; 4] = [SVG, PDF, EPS, EMF]; /// Is `text` only an address (a web page's, an image's, a file's)? A browser's Copy Image puts the /// image's address as text next to the picture: then the picture is what Paste takes (#597). An /// address alone pastes as text, and nothing is fetched. @@ -76,25 +88,31 @@ pub const FILE_HEAD: usize = 4096; /// What a file copied in a file manager pastes as, if one of `mimes` (`image/*`: any bitmap): /// SVG, PDF, EPS, a Windows metafile or a bitmap (its own `image/…` type), told from its first /// [`FILE_HEAD`] bytes and its name. A `.ai` or `.ait` file is [`AI`] when its bytes are a PDF (it -/// pastes when PDF is asked for) and EPS when they are PostScript. The file's bytes are that -/// flavour's data. +/// pastes when PDF is asked for) and EPS when they are PostScript. A DXF or DWG drawing or an +/// HP-GL plot file is [`DXF`], [`DWG`] or [`HPGL`], and pastes when any vector art (SVG, PDF, EPS +/// or EMF) is asked for. The file's bytes are that flavour's data. pub fn file_flavour(name: &str, head: &[u8], mimes: &[&str]) -> Option<&'static str> { let f = fileio::detect(name, head)?; - let (asked, mime) = match f.id { - "svg" => (SVG, SVG), + let (asked, mime): (&[&str], _) = match f.id { + "svg" => (&[SVG], SVG), // `detect` names gzip data SVGZ (a compressed native file aside); `clipboard.importSvg` // reads SVGZ data. - "svgz" if unpacks_to_svg(head) => (SVG, SVG), - "pdf" => (PDF, PDF), - "ps" => (EPS, EPS), - "eps" => (EPS, EPS), - "ai" | "ait" if head.starts_with(b"%PDF") => (PDF, AI), - "ai" | "ait" if vectorcraft_pdf::is_postscript(head) => (EPS, EPS), - "emf" | "wmf" => (EMF, EMF), - _ if f.raster => (BITMAP, f.mime), + "svgz" if unpacks_to_svg(head) => (&[SVG], SVG), + "pdf" => (&[PDF], PDF), + "ps" => (&[EPS], EPS), + "eps" => (&[EPS], EPS), + "ai" | "ait" if head.starts_with(b"%PDF") => (&[PDF], AI), + "ai" | "ait" if vectorcraft_pdf::is_postscript(head) => (&[EPS], EPS), + "emf" | "wmf" => (&[EMF], EMF), + // A file with a drawing's or a plot file's name may hold something else (`.plt` is also a + // chart program's script): it pastes only when its bytes are a drawing or a plot. + "dxf" if vectorcraft_cad::is_dxf(head) => (&VECTOR_ART, DXF), + "dwg" if vectorcraft_cad::is_dwg(head) => (&VECTOR_ART, DWG), + "hpgl" if vectorcraft_cad::hpgl::is_named_hpgl(head) => (&VECTOR_ART, HPGL), + _ if f.raster => (&[BITMAP], f.mime), _ => return None, }; - mimes.contains(&asked).then_some(mime) + mimes.iter().any(|m| asked.contains(m)).then_some(mime) } /// Does gzip data `head` (a file's first bytes, often a stream cut short) unpack to SVG markup? @@ -222,6 +240,15 @@ pub fn specs() -> Vec { has_doc, import_eps ), + cmd!( + query "clipboard.importCad", + "Load CAD Drawing into Clipboard", + [], + None, + "{dataBase64 (a DXF or DWG drawing, or an HP-GL plot file), format: dxf|dwg|hpgl (what the data is; data of another format is refused), center?: [x, y]} replace the clipboard with the drawing's objects as document.open reads the file (DXF and DWG: the Model layout at 1:1 in its own unit), centred on `center` (default: the first artboard) → {count, warnings}; then run edit.paste. The app runs it for a .dxf, .dwg or HP-GL file copied in a file manager", + has_doc, + import_cad + ), ] } @@ -565,6 +592,22 @@ fn import_eps(s: &mut Session, p: &Value) -> Result { import_picture(s, p, C, "Clipboard.eps", &bytes) } +fn import_cad(s: &mut Session, p: &Value) -> Result { + const C: &str = "clipboard.importCad"; + let (is_it, name, not_it): (fn(&[u8]) -> bool, _, _) = match p.get("format").and_then(Value::as_str) { + Some("dxf") => (vectorcraft_cad::is_dxf, "Clipboard.dxf", "the data isn't a DXF drawing"), + Some("dwg") => (vectorcraft_cad::is_dwg, "Clipboard.dwg", "the data isn't a DWG drawing"), + Some("hpgl") => (vectorcraft_cad::hpgl::is_named_hpgl, "Clipboard.plt", "the data isn't an HP-GL plot file"), + _ => return Err(bad(C, "format must be dxf, dwg or hpgl")), + }; + let bytes = data_param(p, C)?; + // Data of another format is refused, not read as the format its name gives. + if !is_it(&bytes) { + return Err(bad(C, not_it)); + } + import_picture(s, p, C, name, &bytes) +} + /// Replace the clipboard with the objects of the picture `bytes`, read as the file `name` is /// opened (command `cmd`). fn import_picture(s: &mut Session, p: &Value, cmd: &str, name: &str, bytes: &[u8]) -> Result { diff --git a/crates/engine/src/cmd/fileio/tests_dwgimport.rs b/crates/engine/src/cmd/fileio/tests_dwgimport.rs index d4aa2ad348..e858530c4b 100644 --- a/crates/engine/src/cmd/fileio/tests_dwgimport.rs +++ b/crates/engine/src/cmd/fileio/tests_dwgimport.rs @@ -62,6 +62,35 @@ fn document_open_reads_a_dwg_drawing_as_its_dxf() { assert!(open(&mut s, "plan.dwg", &plan_dwg(), json!({"dxf": {"layout": "Sheet 9"}})).is_err()); } +/// A DWG drawing copied in a file manager pastes the objects its DXF pastes; a DXF given as DWG is +/// refused. +#[test] +fn a_copied_dwg_drawing_pastes_as_its_dxf_does() { + use crate::cmd::clipboard::{DWG, PASTE_ORDER, file_flavour}; + let dwg = plan_dwg(); + assert_eq!(file_flavour("plan.dwg", &dwg, &PASTE_ORDER), Some(DWG)); + let pasted = |data: &[u8], format: &str| { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 600, "height": 400})).unwrap(); + s.execute("clipboard.importCad", &json!({"dataBase64": b64(data), "format": format})).unwrap(); + s.execute("edit.paste", &json!({"center": [300, 200]})).unwrap(); + leaves(&s).iter().map(|n| n.geometric_bounds()).collect::>() + }; + let (from_dwg, from_dxf) = (pasted(&dwg, "dwg"), pasted(&plan(), "dxf")); + assert!(!from_dwg.is_empty()); + assert_eq!(from_dwg.len(), from_dxf.len()); + for (a, b) in from_dwg.iter().zip(&from_dxf) { + let close = match (a, b) { + (Some(a), Some(b)) => [a.x0 - b.x0, a.y0 - b.y0, a.x1 - b.x1, a.y1 - b.y1].iter().all(|d| d.abs() < 1e-3), + (a, b) => a.is_none() && b.is_none(), + }; + assert!(close, "{a:?} {b:?}"); + } + let mut s = Session::new(); + s.execute("file.new", &json!({})).unwrap(); + assert!(s.execute("clipboard.importCad", &json!({"dataBase64": b64(&plan()), "format": "dwg"})).is_err()); +} + #[test] fn a_dwg_opened_is_never_written_back_as_dwg() { let dir = std::env::temp_dir().join(format!("vc-dwg-save-{}", std::process::id())); diff --git a/crates/engine/src/cmd/fileio/tests_dxfimport.rs b/crates/engine/src/cmd/fileio/tests_dxfimport.rs index 524913dcb7..83bf8a5ea3 100644 --- a/crates/engine/src/cmd/fileio/tests_dxfimport.rs +++ b/crates/engine/src/cmd/fileio/tests_dxfimport.rs @@ -184,6 +184,33 @@ fn dxf_is_readable_and_detected_by_content() { assert!(r["readable"].as_array().unwrap().contains(&json!("dxf"))); } +/// A DXF drawing copied in a file manager pastes as its objects at 1:1, centred where the paste +/// puts it; data that isn't a DXF drawing, and a format `clipboard.importCad` doesn't read, are +/// refused. +#[test] +fn a_copied_dxf_drawing_pastes_as_its_objects() { + use crate::cmd::clipboard::{BITMAP, DXF, PASTE_ORDER, TEXT, file_flavour}; + let dxf = plan(); + assert_eq!(file_flavour("plan.dxf", &dxf, &PASTE_ORDER), Some(DXF)); + assert_eq!(file_flavour("plan.txt", &dxf, &PASTE_ORDER), Some(DXF), "the content tells"); + assert_eq!(file_flavour("plan.dxf", &dxf, &[TEXT, BITMAP]), None, "not when only text or a bitmap is asked for"); + assert_eq!(file_flavour("plan.dxf", b"a note, not a drawing", &PASTE_ORDER), None, "by its bytes, not its name"); + let mut s = page(); + let r = s.execute("clipboard.importCad", &json!({"dataBase64": b64(&dxf), "format": "dxf"})).unwrap(); + assert!(r["count"].as_u64().is_some_and(|n| n > 0), "{r}"); + s.execute("edit.paste", &json!({"center": [300, 200]})).unwrap(); + let doc = &s.doc().unwrap().doc; + let pasted: Vec<_> = doc.layers.iter().flat_map(|l| l.children().into_iter().flatten()).collect(); + let b = pasted.iter().fold(None, |b, n| vectorcraft_geom::union_opt(b, n.geometric_bounds())).unwrap(); + assert!((b.width() - 200.0 * MM).abs() < 1e-6 && (b.height() - 100.0 * MM).abs() < 1e-6, "{b:?}"); + assert!((b.center().x - 300.0).abs() < 1e-6 && (b.center().y - 200.0).abs() < 1e-6, "{b:?}"); + let mut refused = |p: Value| s.execute("clipboard.importCad", &p).unwrap_err().to_string(); + let plot = b64(b"IN;SP1;PA0,0;PD100,0;"); + assert!(refused(json!({"dataBase64": plot, "format": "dxf"})).contains("isn't a DXF drawing")); + assert!(refused(json!({"dataBase64": b64(&dxf), "format": "svg"})).contains("format must be")); + assert!(refused(json!({"dataBase64": b64(&dxf)})).contains("format must be")); +} + /// A document of one 600 × 400 artboard. fn page() -> Session { let mut s = Session::new(); diff --git a/crates/engine/src/cmd/fileio/tests_hpgl.rs b/crates/engine/src/cmd/fileio/tests_hpgl.rs index 9a74b8513b..ea1201b837 100644 --- a/crates/engine/src/cmd/fileio/tests_hpgl.rs +++ b/crates/engine/src/cmd/fileio/tests_hpgl.rs @@ -80,6 +80,34 @@ fn files_that_are_not_hpgl_are_refused() { assert_eq!(text["format"], "txt", "{text}"); } +/// A plot file copied in a file manager pastes as its paths, also one named as a plot file that +/// starts with an instruction plot files seldom start with; a file of that name holding something +/// else does not paste as a plot, and data that isn't one is refused. +#[test] +fn a_copied_plot_file_pastes_as_its_paths() { + use crate::cmd::clipboard::{BITMAP, HPGL, PASTE_ORDER, TEXT, file_flavour}; + let script = b"set terminal png\nplot sin(x)\n"; + assert_eq!(file_flavour("part.plt", PLOT, &PASTE_ORDER), Some(HPGL)); + assert_eq!(file_flavour("part.plt", b"SI0.2,0.3;SP1;PA0,0;PD1016,0;", &PASTE_ORDER), Some(HPGL)); + assert_eq!(file_flavour("graph.plt", script, &PASTE_ORDER), None); + assert_eq!(file_flavour("part.plt", PLOT, &[TEXT, BITMAP]), None); + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 300, "height": 200})).unwrap(); + s.execute("clipboard.importCad", &json!({"dataBase64": b64(PLOT), "format": "hpgl"})).unwrap(); + s.execute("edit.paste", &json!({"center": [150, 100]})).unwrap(); + let mut paths = vec![]; + s.doc().unwrap().doc.walk(|n| { + if let NodeKind::Path { .. } = n.kind { + paths.extend(n.geometric_bounds()); + } + }); + assert_eq!(paths.len(), 2, "{paths:?}"); + assert!(paths.iter().all(|b| (b.width() - 72.0).abs() < 0.5), "an inch wide: {paths:?}"); + for (data, format) in [(&script[..], "hpgl"), (PLOT, "dwg")] { + assert!(s.execute("clipboard.importCad", &json!({"dataBase64": b64(data), "format": format})).is_err(), "{format}"); + } +} + /// A plot file named as one opens when its first instruction is one a plot file seldom starts with; /// under another name it isn't taken for HP-GL. #[test] diff --git a/crates/engine/tests/import_fuzz.rs b/crates/engine/tests/import_fuzz.rs index c6f02b9240..8de5215892 100644 --- a/crates/engine/tests/import_fuzz.rs +++ b/crates/engine/tests/import_fuzz.rs @@ -3920,6 +3920,16 @@ proptest! { fn pasted_metafiles_never_panic(which in 0usize..2, cut in 0usize..200_000, edits in prop::collection::vec((0usize..200_000, any::()), 0..12)) { paste_from_elsewhere("clipboard.importEmf", json!({"dataBase64": mutated_b64(metafile_samples()[which].clone(), cut, &edits)}))?; } + + #[test] + fn pasted_cad_files_never_panic(r12 in any::(), cut in 0usize..60_000, edits in prop::collection::vec((0usize..60_000, any::()), 0..12)) { + static SAMPLES: std::sync::OnceLock<[Vec; 2]> = std::sync::OnceLock::new(); + let samples = SAMPLES.get_or_init(|| [rich_dxf("2018"), rich_dxf("R12")]); + let dxf = mutated_b64(samples[usize::from(r12)].clone(), cut, &edits); + paste_from_elsewhere("clipboard.importCad", json!({"dataBase64": dxf, "format": "dxf"}))?; + let plot = mutated_b64(b"IN;SP1;PA0,0;PD1016,0,1016,1016,0,1016,0,0;PU;LBText\x03;".to_vec(), cut % 64, &edits); + paste_from_elsewhere("clipboard.importCad", json!({"dataBase64": plot, "format": "hpgl"}))?; + } } // ---------- PICT pictures: opened and placed ---------- diff --git a/crates/ui-egui/src/sysclip.rs b/crates/ui-egui/src/sysclip.rs index 9c8b7662c1..7acbe18c5b 100644 --- a/crates/ui-egui/src/sysclip.rs +++ b/crates/ui-egui/src/sysclip.rs @@ -1,8 +1,8 @@ //! The system clipboard's formats: Copy and Cut publish every flavour the engine makes //! ([`Session::clipboard_flavours`](vectorcraft_engine::Session::clipboard_flavours): text, SVG, //! PDF, PNG), and a Paste first turns what another app copied (SVG, PDF, EPS, an EMF, text, a bitmap, -//! or a copied file that is one of them) into the internal clipboard with the `clipboard.import*` -//! commands. Both go through [`VectorcraftApp::clipboard`]. Where the host can read its clipboard only +//! or a copied file that is one of them or a DXF, DWG or HP-GL file) into the internal clipboard +//! with the `clipboard.import*` commands. Both go through [`VectorcraftApp::clipboard`]. Where the host can read its clipboard only //! inside a paste event (the web) Copy publishes SVG text and Paste takes SVG text, and the pictures //! and files the host reads from a paste itself ([`VectorcraftApp::paste_from_host`]). @@ -15,7 +15,8 @@ use std::sync::mpsc::channel; use craft::platform::clipboard::{Clipboard, Flavor, RGBA8, Written}; use serde_json::{Value, json}; use vectorcraft_engine::cmd::clipboard::{ - AI, BITMAP, EMF, EPS, Flavour, ImageRead, PASTE_ORDER, PDF, PNG, SVG, TEXT, looks_like_svg, names_a_picture, read_image, read_pixels, + AI, BITMAP, DWG, DXF, EMF, EPS, Flavour, HPGL, ImageRead, PASTE_ORDER, PDF, PNG, SVG, TEXT, looks_like_svg, names_a_picture, read_image, + read_pixels, }; use crate::VectorcraftApp; @@ -45,7 +46,7 @@ pub(crate) fn engine_flavour(f: Flavor) -> Option { if f.mime == RGBA8 { return rgba8_png(&f.data); } - let own = [TEXT, SVG, PDF, EPS, EMF, AI, PNG].into_iter().find(|m| *m == f.mime); + let own = [TEXT, SVG, PDF, EPS, EMF, AI, DXF, DWG, HPGL, PNG].into_iter().find(|m| *m == f.mime); let mime = own.or(match f.mime { Cow::Borrowed(m) if m.starts_with("image/") => Some(m), _ => None, @@ -230,7 +231,7 @@ pub(crate) fn show_copy_notes(app: &mut VectorcraftApp, cut: bool, notes: Vec bool { - ![TEXT, SVG, PDF, AI, EPS, EMF].contains(&mime) + ![TEXT, SVG, PDF, AI, EPS, EMF, DXF, DWG, HPGL].contains(&mime) } /// The command (and its params) that loads `f` into the internal clipboard, centred on `center`. @@ -250,6 +251,9 @@ pub(crate) fn import_command(f: &Flavour, center: Option<[f64; 2]>) -> (&'static AI => ("clipboard.importPdf", json!({ "dataBase64": b64(), "editingData": true, "center": center })), EPS => ("clipboard.importEps", json!({ "dataBase64": b64(), "center": center })), EMF => ("clipboard.importEmf", json!({ "dataBase64": b64(), "center": center })), + DXF => ("clipboard.importCad", json!({ "dataBase64": b64(), "format": "dxf", "center": center })), + DWG => ("clipboard.importCad", json!({ "dataBase64": b64(), "format": "dwg", "center": center })), + HPGL => ("clipboard.importCad", json!({ "dataBase64": b64(), "format": "hpgl", "center": center })), mime => ("clipboard.importImage", json!({ "dataBase64": b64(), "mime": mime, "center": center })), } } diff --git a/crates/ui-egui/src/tests/sysclip_emf.rs b/crates/ui-egui/src/tests/sysclip_emf.rs index 0f7840387e..985e4d167d 100644 --- a/crates/ui-egui/src/tests/sysclip_emf.rs +++ b/crates/ui-egui/src/tests/sysclip_emf.rs @@ -1,13 +1,14 @@ //! Windows metafiles another app copied paste as vector art (M4.95, through the system clipboard -//! service of M4.57). +//! service of M4.57), and so do copied EPS, `.ai` and CAD drawing files. +use craft::platform::clipboard::Flavor; use serde_json::json; use vectorcraft_doc::NodeKind; use vectorcraft_engine::Session; -use vectorcraft_engine::cmd::clipboard::{AI, EMF, EPS, Flavour, PASTE_ORDER, PDF, PNG, TEXT, file_flavour}; +use vectorcraft_engine::cmd::clipboard::{AI, DWG, DXF, EMF, EPS, Flavour, HPGL, PASTE_ORDER, PDF, PNG, TEXT, file_flavour}; use vectorcraft_testkit::ai; -use crate::sysclip::import_command; +use crate::sysclip::{engine_flavour, import_command, imports_as_image}; use crate::tests_sysclip::{app, blue_png, copy_elsewhere, pasted, run}; #[test] @@ -73,3 +74,22 @@ fn a_copied_ai_file_pastes_from_its_editing_data() { let names: Vec = pasted(&app).iter().map(|n| n.name.clone().unwrap_or_default()).collect(); assert_eq!(names, ["Pair", "Ring", "Window", "Shaded", "", "Sub", ""]); } + +/// A DXF or DWG drawing or an HP-GL plot file copied in a file manager keeps its type through the +/// platform clipboard and pastes through `clipboard.importCad` as vector art. +#[test] +fn a_copied_cad_file_pastes_as_its_drawing() { + for (mime, format) in [(DXF, "dxf"), (DWG, "dwg"), (HPGL, "hpgl")] { + let (cmd, params) = import_command(&Flavour { mime, data: vec![1] }, None); + assert_eq!((cmd, ¶ms["format"]), ("clipboard.importCad", &json!(format))); + assert!(!imports_as_image(mime), "{mime}"); + assert_eq!(engine_flavour(Flavor::new(mime.to_string(), vec![1])).map(|f| f.mime), Some(mime)); + } + let plot = b"IN;SP1;PA0,0;PD1016,0,1016,1016,0,1016,0,0;PU;".to_vec(); + let (mut app, _) = app(); + app.paste_from_host(&crate::testing::ui_context(), Flavour { mime: HPGL, data: plot }, egui::Modifiers::COMMAND); + let p = pasted(&app); + assert!(!p.is_empty() && p.iter().all(|n| matches!(n.kind, NodeKind::Path { .. } | NodeKind::Group { .. })), "{p:?}"); + let b = p[0].geometric_bounds().unwrap(); + assert!((b.width() - 72.0).abs() < 0.5, "an inch wide: {b:?}"); +} diff --git a/docs/mcp.md b/docs/mcp.md index 2fd8648262..a86bd87354 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -13253,8 +13253,13 @@ Each of these adds one warning, with a count: images and pattern brushes whose b out; clips that can't be applied as the file sets them; and raster operations other than a plain copy, drawn as a plain copy or left out. `clipboard.importEmf {dataBase64, center?}` loads an EMF or WMF picture into the clipboard for `edit.paste`; the app -pastes `image/emf` from the system clipboard ahead of text and bitmaps when the platform's clipboard service offers it -(the Windows desktop service doesn't read metafiles yet). +pastes `image/emf` from the system clipboard ahead of text and bitmaps when the platform's clipboard service offers it. +On Windows the desktop app reads the enhanced metafile (`CF_ENHMETAFILE`) that CAD and office apps copy as vector art; +Windows makes one from an older metafile (`CF_METAFILEPICT`) too. +`clipboard.importCad {dataBase64, format: "dxf"|"dwg"|"hpgl", center?}` loads a DXF or DWG drawing or an HP-GL plot +file into the clipboard for `edit.paste`, read as `document.open` reads the file (DXF and DWG: the Model layout at 1:1 +in the drawing's unit); data that is not the format named is refused. The app runs it for a `.dxf`, `.dwg` or HP-GL file +copied in a file manager, when the paste asks for vector art. The type size comes from the font's height. A negative height is the em. A positive height is the character cell, and the em is the cell times the face's units per em divided by its OS/2 `usWinAscent` plus `usWinDescent`, with a From 26f5b4ae5890226beb4453986b85ec505f1c45e8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 14:21:52 -0800 Subject: [PATCH 09/10] i18n: embed the interface language catalogs Brotli-compressed The 29 catalogs in crates/ui-egui/src/i18n were embedded with include_str!, 21,861,200 bytes of text in every build. build.rs now compresses each *.tsv with Brotli (quality 9, 4 MiB window) into OUT_DIR, and the interface unpacks them when it first needs its catalogs and hands them to I18n::from_owned. The embedded catalogs take 5,316,158 bytes. - build.rs finds the catalogs in the folder, so adding a language is adding its .tsv. A catalog over 8 MiB, or one it can't read, stops the build. - A catalog that does not unpack to exactly its recorded length of UTF-8 is left out and logged, and its language is not offered. - On the desktop the catalogs are unpacked on several threads. --- Cargo.lock | 2 + crates/ui-egui/Cargo.toml | 7 ++ crates/ui-egui/build.rs | 60 ++++++++++++++++ crates/ui-egui/src/i18n.rs | 118 ++++++++++++++++++++----------- crates/ui-egui/src/i18n/tests.rs | 66 +++++++++++++++-- 5 files changed, 208 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b53df9115b..ff9dd65f3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9272,6 +9272,8 @@ dependencies = [ name = "vectorcraft-ui-egui" version = "0.25.1" dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.2", "bytemuck", "chrono", "craft", diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index fe411e7c59..8d5d5c4a18 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -74,6 +74,9 @@ craft-image-codecs = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } log = { workspace = true } +# Unpacks the interface language catalogs, which build.rs stores Brotli-compressed (src/i18n.rs). +# Pure Rust, builds for wasm32, and already in Cargo.lock through craft-i18n. +brotli-decompressor = { version = "6", default-features = false, features = ["std"] } # Floating panels open in OS windows of their own on the desktop; on the web they stay in the page. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -110,10 +113,14 @@ vectorcraft-tools = { workspace = true, features = ["testing"] } vectorcraft-text = { workspace = true, features = ["test-fonts"] } vectorcraft-plugins = { workspace = true, features = ["test-steady"] } wat = { workspace = true } +# Compresses bad catalogs for the i18n unpacking tests. +brotli = { version = "9", default-features = false, features = ["std"] } [build-dependencies] serde_json = { workspace = true } toml = "1" +# Compresses the interface language catalogs (src/i18n/*.tsv); already in Cargo.lock through craft-i18n. +brotli = { version = "9", default-features = false, features = ["std"] } # The files of other crates that this crate's tests read, for CI's test selection. [package.metadata.craft] diff --git a/crates/ui-egui/build.rs b/crates/ui-egui/build.rs index 737032a551..13ee9170c6 100644 --- a/crates/ui-egui/build.rs +++ b/crates/ui-egui/build.rs @@ -6,12 +6,72 @@ //! JSON says the entry was verified (`people_entry`). //! //! A missing or malformed file gives empty tables (or no names) and a warning. +//! +//! Also compress the interface language catalogs, `src/i18n/*.tsv`, with Brotli into `OUT_DIR/i18n/`, +//! and write `i18n_catalogs.rs`, the table `src/i18n.rs` unpacks them from. A catalog that can't be +//! read or is larger than [`MAX_CATALOG_BYTES`] stops the build. use std::fmt::Write as _; +use std::io::Write as _; +use std::path::Path; use serde_json::Value; +/// The largest catalog embedded, in bytes; `src/i18n.rs` unpacks no more than this. +const MAX_CATALOG_BYTES: usize = 8 << 20; + fn main() { + if let Err(e) = pack_catalogs() { + println!("cargo::error=packing the interface language catalogs: {e}"); + } + credits(); +} + +/// Compress each `src/i18n/.tsv` to `OUT_DIR/i18n/.tsv.br` and list them, by code, in +/// `OUT_DIR/i18n_catalogs.rs` as `CATALOGS: &[(code, compressed text, text length in bytes)]`. +fn pack_catalogs() -> Result<(), String> { + let src = Path::new(env!("CARGO_MANIFEST_DIR")).join("src/i18n"); + println!("cargo::rerun-if-changed={}", src.display()); + let out = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or("OUT_DIR is not set")?); + let packed = out.join("i18n"); + std::fs::create_dir_all(&packed).map_err(|e| format!("{}: {e}", packed.display()))?; + let mut codes = Vec::new(); + for entry in std::fs::read_dir(&src).map_err(|e| format!("{}: {e}", src.display()))? { + let path = entry.map_err(|e| format!("{}: {e}", src.display()))?.path(); + if let (Some(code), Some("tsv")) = (path.file_stem().and_then(|s| s.to_str()), path.extension().and_then(|s| s.to_str())) { + codes.push(code.to_string()); + } + } + codes.sort(); + let mut table = String::from("const CATALOGS: &[(&str, &[u8], usize)] = &[\n"); + for code in codes { + let path = src.join(format!("{code}.tsv")); + println!("cargo::rerun-if-changed={}", path.display()); + let text = std::fs::read(&path).map_err(|e| format!("{}: {e}", path.display()))?; + if text.len() > MAX_CATALOG_BYTES { + return Err(format!("{} is {} bytes, over the {MAX_CATALOG_BYTES}-byte limit", path.display(), text.len())); + } + let mut compressed = Vec::new(); + { + // Quality 9, a 4 MiB window. + let mut encoder = brotli::CompressorWriter::new(&mut compressed, 4096, 9, 22); + encoder.write_all(&text).map_err(|e| format!("{}: {e}", path.display()))?; + } + let file = packed.join(format!("{code}.tsv.br")); + if std::fs::read(&file).ok().as_deref() != Some(compressed.as_slice()) { + std::fs::write(&file, &compressed).map_err(|e| format!("{}: {e}", file.display()))?; + } + let _ = writeln!(table, " ({code:?}, include_bytes!(concat!(env!(\"OUT_DIR\"), \"/i18n/{code}.tsv.br\")), {}),", text.len()); + } + table.push_str("];\n"); + let file = out.join("i18n_catalogs.rs"); + if std::fs::read_to_string(&file).is_ok_and(|old| old == table) { + return Ok(()); + } + std::fs::write(&file, table).map_err(|e| format!("{}: {e}", file.display())) +} + +fn credits() { let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../contributors"); let json = read(&dir.join("contributors.json"), "the About window shows no contributors", |t| { serde_json::from_str::(t).map_err(|e| e.to_string()) diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index b515cb802e..ae38932b65 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -8,10 +8,10 @@ //! 1. Add `xx.tsv` next to `zh-hant.tsv` (copy its header; translate from the *meaning* of the //! English text, clean-room, see `zh-hant.tsv`), with an `@id` row `language.name` holding the //! language's name in itself. -//! 2. Add one entry to [`EMBEDDED`]. //! -//! That is all: the Preferences dropdown, the system-locale match, the catalog tests (parse, -//! placeholders, plural forms) and the untranslated report pick it up from the embedded list. +//! That is all: `build.rs` embeds every `*.tsv` in that folder, Brotli-compressed, and the +//! Preferences dropdown, the system-locale match, the catalog tests (parse, placeholders, plural +//! forms) and the untranslated report pick it up from the embedded list. //! //! # Looking strings up //! - [`t`] / the `tl!` macro: a plain string in the language the UI is drawn in. [`tr`] takes the @@ -31,53 +31,87 @@ // PLAN: crates/ui-egui/Cargo.toml needs `craft-i18n = { workspace = true }`; the manifest is not in // this set's Files table. use std::borrow::Cow; +use std::io::Read as _; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Mutex, OnceLock, PoisonError}; -use craft::i18n::{Embedded, I18n, fmt_plain}; +use craft::i18n::{I18n, fmt_plain}; pub use craft::i18n::Lang; -/// The catalogs of every language but English (the source language), by code. English is reserved -/// by `craft-i18n` and has no catalog. -static EMBEDDED: &Embedded = &[ - ("hi", "", include_str!("i18n/hi.tsv")), - ("gu", "", include_str!("i18n/gu.tsv")), - ("el", "", include_str!("i18n/el.tsv")), - ("ja", "", include_str!("i18n/ja.tsv")), - ("ko", "", include_str!("i18n/ko.tsv")), - ("vi", "", include_str!("i18n/vi.tsv")), - ("cs", "", include_str!("i18n/cs.tsv")), - ("bs", "", include_str!("i18n/bs.tsv")), - ("de", "", include_str!("i18n/de.tsv")), - ("es", "", include_str!("i18n/es.tsv")), - ("fr", "", include_str!("i18n/fr.tsv")), - ("it", "", include_str!("i18n/it.tsv")), - ("ka", "", include_str!("i18n/ka.tsv")), - ("ru", "", include_str!("i18n/ru.tsv")), - ("uk", "", include_str!("i18n/uk.tsv")), - ("bg", "", include_str!("i18n/bg.tsv")), - ("hu", "", include_str!("i18n/hu.tsv")), - ("pl", "", include_str!("i18n/pl.tsv")), - ("sv", "", include_str!("i18n/sv.tsv")), - ("pt-br", "", include_str!("i18n/pt-br.tsv")), - ("zh-hant", "", include_str!("i18n/zh-hant.tsv")), - ("zh-hans", "", include_str!("i18n/zh-hans.tsv")), - ("nl", "", include_str!("i18n/nl.tsv")), - ("da", "", include_str!("i18n/da.tsv")), - ("id", "", include_str!("i18n/id.tsv")), - ("fi", "", include_str!("i18n/fi.tsv")), - ("tr", "", include_str!("i18n/tr.tsv")), - ("ca", "", include_str!("i18n/ca.tsv")), - ("ar", "", include_str!("i18n/ar.tsv")), -]; +// The catalogs of every language but English (the source language), by code: `CATALOGS`, each +// `(code, Brotli-compressed text, text length in bytes)`, which `build.rs` writes from `i18n/*.tsv`. +// English is reserved by `craft-i18n` and has no catalog. +include!(concat!(env!("OUT_DIR"), "/i18n_catalogs.rs")); -/// The codes of [`EMBEDDED`] the interface offers. Browsers cannot use the native installed-font +/// The largest catalog [`unpack`] returns, in bytes (`build.rs` embeds none larger). +const MAX_CATALOG_BYTES: usize = 8 << 20; + +/// A catalog's text from its compressed bytes, which must unpack to exactly `len` bytes of UTF-8. +fn unpack(packed: &[u8], len: usize) -> Result { + if len > MAX_CATALOG_BYTES { + return Err(format!("{len} bytes is over the {MAX_CATALOG_BYTES}-byte limit")); + } + let mut text = Vec::new(); + text.try_reserve_exact(len).map_err(|e| e.to_string())?; + brotli_decompressor::Decompressor::new(packed, 4096).take(len as u64 + 1).read_to_end(&mut text).map_err(|e| e.to_string())?; + if text.len() != len { + return Err(format!("unpacked {} bytes instead of {len}", text.len())); + } + String::from_utf8(text).map_err(|e| e.to_string()) +} + +/// The embedded catalogs unpacked, as `I18n::from_owned` takes them: (code, shared catalog (none), +/// the app's catalog). A catalog that can't be unpacked is left out and comes back as a problem. +fn catalogs() -> (Vec<(String, String, String)>, Vec) { + unpack_catalogs(CATALOGS) +} + +/// [`catalogs`] for the given `(code, compressed text, text length)` list; on the desktop the +/// catalogs are unpacked on several threads. +fn unpack_catalogs(list: &[(&str, &[u8], usize)]) -> (Vec<(String, String, String)>, Vec) { + let unpack_all = + |piece: &[(&str, &[u8], usize)]| piece.iter().map(|&(code, packed, len)| (code.to_string(), unpack(packed, len))).collect::>(); + #[cfg(not(target_arch = "wasm32"))] + let unpacked = { + let threads = std::thread::available_parallelism().map_or(1, usize::from).min(16); + let per = list.len().div_ceil(threads).max(1); + std::thread::scope(|scope| { + // A piece whose thread can't be started is unpacked on this one. + let pieces: Vec<_> = list + .chunks(per) + .map(|piece| (piece, std::thread::Builder::new().name("i18n-unpack".into()).spawn_scoped(scope, move || unpack_all(piece)).ok())) + .collect(); + let stopped = + |piece: &[(&str, &[u8], usize)]| piece.iter().map(|&(code, ..)| (code.to_string(), Err("unpacking stopped".to_string()))).collect(); + pieces + .into_iter() + .flat_map(|(piece, handle)| match handle { + Some(handle) => handle.join().unwrap_or_else(|_| stopped(piece)), + None => unpack_all(piece), + }) + .collect::>() + }) + }; + #[cfg(target_arch = "wasm32")] + let unpacked = unpack_all(list); + let mut texts = Vec::with_capacity(unpacked.len()); + let mut problems = Vec::new(); + for (code, text) in unpacked { + match text { + Ok(text) => texts.push((code, String::new(), text)), + Err(e) => problems.push(format!("{code}: the embedded catalog can't be unpacked ({e}); skipped")), + } + } + (texts, problems) +} + +/// The codes of [`CATALOGS`] the interface offers. Browsers cannot use the native installed-font /// fallback, so on the web a language whose text would be missing-glyph boxes (Gujarati without a /// Gujarati face, see [`has_gujarati_face`]) is not offered, including when restoring a preference. /// Arabic is kept unavailable to users until the shared catalog in `storytold/craft-i18n` is consumed. fn offered_codes(web: bool, gujarati_font: bool) -> Vec<&'static str> { - EMBEDDED.iter().map(|(code, ..)| *code).filter(|code| *code != "ar" && (*code != "gu" || !web || gujarati_font)).collect() + CATALOGS.iter().map(|(code, ..)| *code).filter(|code| *code != "ar" && (*code != "gu" || !web || gujarati_font)).collect() } /// Whether the interface has a Gujarati face: an embedded craft-fonts face, or on the web a face @@ -96,12 +130,14 @@ fn has_gujarati_face_in<'a>(embedded: &[vectorcraft_text::EmbeddedFace], mut ser embedded.iter().any(|f| f.has_script("Gujr")) || served.any(|scripts| scripts.contains(&"Gujr")) } -/// The one catalog set of the process, built on first use. +/// The one catalog set of the process, built on first use, which is when the catalogs are unpacked. fn shared_cell() -> &'static Arc { static SHARED: OnceLock> = OnceLock::new(); SHARED.get_or_init(|| { let offered = offered_codes(cfg!(target_arch = "wasm32"), has_gujarati_face()); - let (i18n, problems) = I18n::new(EMBEDDED, &offered); + let (texts, mut problems) = catalogs(); + let (i18n, built) = I18n::from_owned(texts, &offered); + problems.extend(built); for problem in problems { log::warn!("vectorcraft: interface language catalog: {problem}"); } diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index b3910b0442..dc975ab371 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -12,6 +12,64 @@ fn translated() -> Vec { Lang::all().filter(|l| l.complete_menus()).collect() } +/// The embedded catalogs unpacked, as `I18n::from_owned` takes them; every one must unpack. +fn unpacked() -> Vec<(String, String, String)> { + let (texts, problems) = catalogs(); + assert!(problems.is_empty(), "{problems:?}"); + texts +} + +/// The embedded entry of `code`: (code, compressed text, text length). +fn packed(code: &str) -> (&'static str, &'static [u8], usize) { + CATALOGS.iter().copied().find(|c| c.0 == code).unwrap_or_else(|| panic!("{code} embedded")) +} + +/// A catalog is embedded compressed and unpacks to its source file byte for byte. +#[test] +fn embedded_catalogs_are_compressed_and_unpack_to_their_source() { + for code in ["de", "ja"] { + let (_, bytes, len) = packed(code); + let source = std::fs::read_to_string(format!("{}/src/i18n/{code}.tsv", env!("CARGO_MANIFEST_DIR"))).unwrap(); + assert_eq!(len, source.len(), "{code}"); + assert!(bytes.len() * 2 < len, "{code}: {} bytes embedded for {len}", bytes.len()); + assert_eq!(unpack(bytes, len).as_deref(), Ok(source.as_str()), "{code}"); + } +} + +/// Bytes that do not unpack to exactly the recorded length of UTF-8 text, or a length over the +/// limit, give an error instead of a catalog. +#[test] +fn unpacking_rejects_a_catalog_that_does_not_match_its_record() { + use std::io::Write as _; + let (_, bytes, len) = packed("de"); + assert!(unpack(bytes, len - 1).is_err(), "more text than recorded"); + assert!(unpack(bytes, len + 1).is_err(), "less text than recorded"); + assert!(unpack(&bytes[..bytes.len() / 2], len).is_err(), "cut short"); + assert!(unpack(b"not a catalog", 13).is_err(), "not Brotli"); + let over = unpack(bytes, MAX_CATALOG_BYTES + 1).unwrap_err(); + assert!(over.contains("limit"), "{over}"); + let mut not_utf8 = Vec::new(); + { + let mut encoder = brotli::CompressorWriter::new(&mut not_utf8, 4096, 9, 22); + encoder.write_all(&[b'a', 0xff, b'b']).unwrap(); + } + assert!(unpack(¬_utf8, 3).is_err(), "not UTF-8"); +} + +/// A catalog that does not unpack is left out and reported, so its language is not offered; the +/// others keep their order and load. +#[test] +fn a_catalog_that_does_not_unpack_is_left_out_and_reported() { + let (texts, problems) = unpack_catalogs(&[packed("de"), ("fr", b"not a catalog", 13), packed("ja")]); + assert_eq!(texts.iter().map(|t| t.0.as_str()).collect::>(), ["de", "ja"]); + assert_eq!(problems.len(), 1, "{problems:?}"); + assert!(problems[0].starts_with("fr: "), "{problems:?}"); + let (i18n, _) = I18n::from_owned(texts, &["de", "fr", "ja"]); + assert_eq!(i18n.from_code("fr"), None); + let de = i18n.from_code("de").unwrap(); + assert_ne!(i18n.t(de, "Layers"), "Layers"); +} + /// (language, context, English source, the term the language's glossary gives it). One row per /// rule: a term for a concept, a punctuation mark's typography. const TERMS: &[(&str, &str, &str, &str)] = &[ @@ -148,7 +206,7 @@ fn messages_translate_in_every_complete_language() { #[test] fn gujarati_web_selection_requires_a_bundled_interface_font() { let codes = |web, font| { - let (i18n, problems) = I18n::new(EMBEDDED, &offered_codes(web, font)); + let (i18n, problems) = I18n::from_owned(unpacked(), &offered_codes(web, font)); assert!(problems.is_empty(), "{problems:?}"); i18n.languages().into_iter().map(|l| i18n.code(l).to_string()).collect::>() }; @@ -199,7 +257,7 @@ fn arabic_is_preparatory_and_unavailable_to_users() { #[test] fn arabic_plural_rule_and_catalog_infrastructure() { - let (i18n, problems) = I18n::new(EMBEDDED, &["ar"]); + let (i18n, problems) = I18n::from_owned(unpacked(), &["ar"]); assert!(problems.is_empty(), "{problems:?}"); let ar = i18n.from_code("ar").expect("ar offered in custom instance"); assert_eq!(i18n.name(ar), "العربية"); @@ -236,7 +294,7 @@ fn a_language_set_by_another_test_leaves_this_one_in_english() { fn bundled_catalogs_are_consistent() { let problems = shared().check_all(); assert!(problems.is_empty(), "{problems:#?}"); - for (code, _, app) in EMBEDDED { + for (code, _, app) in unpacked() { for line in app.lines() { let mut columns = line.split('\t'); let (Some("@id"), Some(id)) = (columns.next(), columns.next()) else { continue }; @@ -275,7 +333,7 @@ fn unescaped(column: &str) -> String { #[test] fn message_translations_keep_their_english_edges() { let mut wrong = Vec::new(); - for (code, _, catalog) in EMBEDDED { + for (code, _, catalog) in unpacked() { for line in catalog.lines() { let mut columns = line.splitn(3, '\t'); let (Some(ctx @ ("@msg" | "@msgplural")), Some(src), Some(tr)) = (columns.next(), columns.next(), columns.next()) else { continue }; From 6c28ad2390c938258fd9b200843ee0c81f6f8ddf Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 15:28:40 -0800 Subject: [PATCH 10/10] Docs: composite font placement errors apply only when the placed art uses one file.place checks the composite fonts only when the placed art uses a composite font that its file defines. --- docs/mcp.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/mcp.md b/docs/mcp.md index a51225256b..7fbad35bbc 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -11809,7 +11809,8 @@ Placement first reuses an equal composite font with the same name (in any case) Otherwise, a composite font whose name the document already uses (for a different composite font, a part of one, or a family its type or styles name) or that an installed font has, joins under a free name such as "Name 2", unless the document already has an equal definition under another name, which the placed art then uses; the placed art is renamed to -match. Before either document changes, the placement fails and changes nothing with one of these errors: "a document +match. When the placed art uses a composite font that its file defines, these checks run before either document +changes, and the placement fails and changes nothing with one of these errors: "a document keeps at most 256 composite fonts" (when the placed art uses more than 256, the document has more than 256, or more than 256 remain after equal definitions are shared); "two incoming composite fonts are named ``"; "`` is the name of an installed font"; "the composite fonts in the placed art and document cannot stand together"; "no free