diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53a9be4e4a..94e08ef762 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,8 @@ jobs: # The warm build runs as one `cache warm /6` leg per shard, in parallel (each builds what # its shard builds), and `cache warm` puts their files into the one entry it saves. warm-split: true - # The dependency cache also keeps the compiled workspace crates and test executables, so a + # The dependency cache also keeps the compiled workspace crates and their library and binary + # test executables (not the integration tests' executables), so a # pull request's shards rebuild only the crates its changes reach. Each main run's `cache # warm` leg saves a rolling entry of its own, every leg restores the newest one, and # cache-prune.yml deletes the one it replaced after each attempt. The nightly run restores diff --git a/Cargo.lock b/Cargo.lock index ab8d5d83c3..b878d75456 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,8 @@ version = 4 [[package]] name = "acadrust" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8923c99ea1f151cb7fc17ce2fc14f8b1e330fa22611e535602d985c0cc3c89a2" +version = "0.6.9" +source = "git+https://github.com/storytold/acadrust.git?rev=468b9d8e317755209020d5d3f2f1c8a76210c47f#468b9d8e317755209020d5d3f2f1c8a76210c47f" dependencies = [ "anyhow", "bitflags 2.13.2", @@ -16,6 +15,7 @@ dependencies = [ "foldhash 0.2.0", "indexmap", "itoa", + "memchr", "memmap2", "nom 7.1.3", "oem_cp", @@ -24,6 +24,7 @@ dependencies = [ "ryu", "thiserror 2.0.21", "web-time", + "whichever", ] [[package]] @@ -1255,7 +1256,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-automation", "craft-behavior", @@ -1297,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "crc32fast", "flate2", @@ -1318,7 +1319,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1330,7 +1331,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "rustix 1.1.6", ] @@ -1338,7 +1339,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1363,11 +1364,12 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "accesskit", "bitflags 2.13.2", "craft-host", + "craft-i18n", "craft-keymap", "craft-theme", "craft-tracked", @@ -1381,7 +1383,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-docpath", @@ -1399,7 +1401,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "crc32fast", "flate2", @@ -1408,7 +1410,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "egui", ] @@ -1416,7 +1418,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "md-5", "rayon", @@ -1425,12 +1427,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-cms", @@ -1450,7 +1452,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-ai-agents", "craft-atomic", @@ -1466,7 +1468,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1476,7 +1478,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "rayon", ] @@ -1484,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1510,7 +1512,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "blake3", "craft-ecproj-format", @@ -1526,7 +1528,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "serde", ] @@ -1534,7 +1536,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1553,16 +1555,17 @@ dependencies = [ [[package]] name = "craft-dwg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "acadrust", + "craft-dxf", "log", ] [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-codepage", "encoding_rs", @@ -1574,7 +1577,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "serde", "serde_json", @@ -1584,12 +1587,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" [[package]] name = "craft-flags" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-atomic", "dirs", @@ -1599,7 +1602,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1614,7 +1617,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1633,7 +1636,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1642,7 +1645,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "cap-primitives", "craft-atomic", @@ -1665,12 +1668,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "gif", ] @@ -1678,7 +1681,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "flate2", ] @@ -1686,7 +1689,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1699,7 +1702,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -1729,7 +1732,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-dds", "craft-jpeg", @@ -1756,7 +1759,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1774,7 +1777,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "thiserror 2.0.21", ] @@ -1782,7 +1785,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1793,7 +1796,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-host", "craft-i18n", @@ -1808,7 +1811,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-i18n", @@ -1822,7 +1825,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-host", @@ -1840,7 +1843,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1852,7 +1855,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "encoding_rs", "image", @@ -1863,7 +1866,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "chrono", "craft-codepage", @@ -1873,7 +1876,7 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "uds_windows", "winsafe", @@ -1882,7 +1885,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-keymap", @@ -1898,7 +1901,7 @@ dependencies = [ [[package]] name = "craft-pbr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-texture", "thiserror 2.0.21", @@ -1907,7 +1910,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "flate2", "serde", @@ -1918,7 +1921,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1930,7 +1933,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "async-channel", "async-io", @@ -1963,7 +1966,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1972,7 +1975,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-host", @@ -1996,7 +1999,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -2007,7 +2010,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-eps", "flate2", @@ -2021,7 +2024,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "encoding_rs", "flate2", @@ -2032,7 +2035,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "dispatch2", "egui", @@ -2045,7 +2048,7 @@ dependencies = [ [[package]] name = "craft-raster3d" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "rayon", "thiserror 2.0.21", @@ -2054,7 +2057,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -2073,7 +2076,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-atomic", "craft-host", @@ -2090,7 +2093,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "fax", "hayro-ccitt", @@ -2101,7 +2104,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2122,7 +2125,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-keymap", @@ -2134,7 +2137,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2159,7 +2162,7 @@ dependencies = [ [[package]] name = "craft-texture" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "thiserror 2.0.21", ] @@ -2167,7 +2170,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2182,7 +2185,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-atomic", "craft-behavior", @@ -2197,7 +2200,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "serde", "thiserror 2.0.21", @@ -2207,7 +2210,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "serde", "thiserror 2.0.21", @@ -2216,7 +2219,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-keymap", @@ -2231,12 +2234,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2250,7 +2253,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -2267,7 +2270,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "accesskit", "craft-behavior", @@ -2305,7 +2308,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2316,7 +2319,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-host", @@ -2334,7 +2337,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-host", @@ -2355,7 +2358,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-host", @@ -2376,7 +2379,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-behavior", "craft-host", @@ -2395,7 +2398,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "base64 0.22.1", "chrono", @@ -2427,7 +2430,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "flate2", "serde", @@ -2438,7 +2441,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2448,7 +2451,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "js-sys", "serde_json", @@ -2459,7 +2462,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "winsafe", ] @@ -2467,7 +2470,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "craft-appkit", "craft-atomic", @@ -2499,7 +2502,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2844,7 +2847,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "bytemuck", "emath", @@ -2877,7 +2880,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "ahash", "bytemuck", @@ -2912,7 +2915,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "accesskit", "ahash", @@ -2931,7 +2934,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "ahash", "bytemuck", @@ -2950,7 +2953,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "accesskit_winit", "arboard", @@ -2976,7 +2979,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "ahash", "egui", @@ -2990,7 +2993,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "bytemuck", "egui", @@ -3003,7 +3006,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "dify", "eframe", @@ -3029,7 +3032,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "bytemuck", ] @@ -3110,7 +3113,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "ahash", "bytemuck", @@ -3136,7 +3139,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" +source = "git+https://github.com/storytold/egui.git?rev=399fc6e0ea65059e37de680f11ebbd177bf7d4ff#399fc6e0ea65059e37de680f11ebbd177bf7d4ff" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -3859,7 +3862,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "brotli 8.0.4", "hayro-postscript", @@ -3868,7 +3871,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3886,7 +3889,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3904,12 +3907,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "flate2", "hayro-ccitt", @@ -4892,7 +4895,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "base64 0.22.1", "bumpalo", @@ -5049,7 +5052,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=c2a47dfea38b215245f739c675da3662c89f1e09#c2a47dfea38b215245f739c675da3662c89f1e09" +source = "git+https://github.com/storytold/craft-libs?rev=4c330f6bd1f38dd536f830483ea9618db2cb2bd8#4c330f6bd1f38dd536f830483ea9618db2cb2bd8" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -9663,19 +9666,6 @@ dependencies = [ "wayland-scanner", ] -[[package]] -name = "wayland-protocols-plasma" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" -dependencies = [ - "bitflags 2.13.2", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - [[package]] name = "wayland-protocols-wlr" version = "0.3.12" @@ -9976,6 +9966,26 @@ dependencies = [ "web-sys", ] +[[package]] +name = "whichever" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68887c9512981e597d730f1d95b2eb6abdd53385e4e76c35a95e7121e16232b0" +dependencies = [ + "whichever-macros", +] + +[[package]] +name = "whichever-macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb15ad553239d9fdefac12e31e16c7682dc62a2106ba035aec69c5dd15835a7b" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + [[package]] name = "widestring" version = "1.2.1" @@ -10219,7 +10229,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" version = "0.30.13" -source = "git+https://github.com/storytold/winit.git?rev=0dfcec0eb62fda5904137a63a6dd0c3d83295f45#0dfcec0eb62fda5904137a63a6dd0c3d83295f45" +source = "git+https://github.com/storytold/winit.git?rev=3fd7ae64762f82a73b78bd24f453f82c4291067d#3fd7ae64762f82a73b78bd24f453f82c4291067d" dependencies = [ "ahash", "android-activity", @@ -10258,7 +10268,6 @@ dependencies = [ "wayland-backend", "wayland-client", "wayland-protocols", - "wayland-protocols-plasma", "web-sys", "web-time", "windows-sys 0.52.0", diff --git a/Cargo.toml b/Cargo.toml index ebd1b3df6b..a48e3c1330 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,57 +10,57 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -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" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # 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 = "c2a47dfea38b215245f739c675da3662c89f1e09" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # DWG to DXF bytes, in a child process on desktop builds (acadrust 0.6.6, MPL-2.0, unmodified). -craft-dwg = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-dwg = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # WMF, EMF and EMF+ reader (craft-libs#778). -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" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # The metallic-roughness BRDF and environment light the 3D effects' Roughness and Metallic shade with. -craft-pbr = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-pbr = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # The CPU rasterizer that draws a 3D effect's Render Settings › Rendered image: depth-buffered triangles, shadow maps. -craft-raster3d = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-raster3d = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # 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 = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # 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 = "c2a47dfea38b215245f739c675da3662c89f1e09" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # Nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "c2a47dfea38b215245f739c675da3662c89f1e09" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -200,24 +200,25 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -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" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8" } # skrifa 0.44 (epaint, glifo, usvg) with the automatic hinter's long blue-zone exit (craft-libs vendor/skrifa). +# It stays at this rev until craft-libs#5222 merges. skrifa = { git = "https://github.com/storytold/craft-libs", rev = "37d0532f42eb3421769c8a454e3e25a20fbcff97" } -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" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } -egui = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } -winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +emath = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +egui = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } +winit = { git = "https://github.com/storytold/winit.git", rev = "3fd7ae64762f82a73b78bd24f453f82c4291067d" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index e439dc8be6..4db9a1dac2 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 = "c2a47dfea38b215245f739c675da3662c89f1e09", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "4c330f6bd1f38dd536f830483ea9618db2cb2bd8", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/cad/src/blocks_compat.rs b/crates/cad/src/blocks_compat.rs new file mode 100644 index 0000000000..bcc4860314 --- /dev/null +++ b/crates/cad/src/blocks_compat.rs @@ -0,0 +1,115 @@ +//! Block definitions and INSERT entities for the DXF writer. +//! +//! Temporary: `craft_dxf::drawing` at the pinned craft-libs revision writes only the model and +//! paper space blocks. storytold/craft-libs#5381 adds `Block`, `Drawing::blocks` and +//! `Codes::insert`; once it merges and the pin moves past it, this module is removed and +//! `scene.rs` uses those instead. Until then [`write`] adds the user blocks to the file that +//! `Drawing::write` returns, with the same group codes #5381 writes. + +use craft_dxf::drawing::{Codes, Drawing, Handle, fixed}; + +/// A block definition: entities written once, which INSERT entities place ([`insert`]). Its base +/// point is the origin. +#[derive(Clone, Debug)] +pub struct Block { + pub name: String, + /// The handle of its BLOCK_RECORD (from R13), which owns its entities. + pub record: Handle, + /// The handles of its BLOCK and ENDBLK records. + pub begin: Handle, + pub end: Handle, + /// The entities' group codes, written with `record` as their owner. + pub entities: String, +} + +/// The start of an object: its type, and from R13 its handle, owner and first subclass. +fn object(c: &mut Codes, kind: &str, h: Handle, owner: Handle, subclass: &str) { + c.raw(0, kind); + if c.v.handles() { + c.handle(5, h); + c.handle(330, owner); + c.raw(100, subclass); + } +} + +/// An INSERT entity owned by `owner` on `layer` that places block `block` at the origin, unscaled +/// and unrotated. It has no color of its own (ByLayer). +pub fn insert(c: &mut Codes, h: Handle, owner: Handle, layer: &str, block: &str) { + object(c, "INSERT", h, owner, "AcDbEntity"); + c.str(8, layer); + if c.v.handles() { + c.raw(100, "AcDbBlockReference"); + } + c.str(2, block); + c.xyz(10, 0.0, 0.0); +} + +/// The whole file of `d` with `blocks` written after the model and paper space blocks. +pub fn write(d: Drawing, blocks: &[Block]) -> String { + let v = d.version; + let out = d.write(); + if blocks.is_empty() { + return out; + } + let mut defs = Codes::new(v); + for b in blocks { + object(&mut defs, "BLOCK", b.begin, b.record, "AcDbEntity"); + defs.raw(8, "0"); + if v.handles() { + defs.raw(100, "AcDbBlockBegin"); + } + defs.str(2, &b.name); + defs.int(70, 0); + defs.xyz(10, 0.0, 0.0); + defs.str(3, &b.name); + defs.raw(1, ""); + defs.append(&b.entities); + object(&mut defs, "ENDBLK", b.end, b.record, "AcDbEntity"); + defs.raw(8, "0"); + if v.handles() { + defs.raw(100, "AcDbBlockEnd"); + } + } + let defs = defs.into_string(); + if !v.handles() { + // R12 has no model and paper space blocks: its BLOCKS section holds the user blocks only. + let at = " 0\nSECTION\n 2\nENTITIES\n"; + return match out.find(at) { + Some(i) => format!("{} 0\nSECTION\n 2\nBLOCKS\n{defs} 0\nENDSEC\n{}", &out[..i], &out[i..]), + None => out, + }; + } + let mut records = Codes::new(v); + for b in blocks { + object(&mut records, "BLOCK_RECORD", b.record, fixed::BLOCK_RECORD_TABLE, "AcDbSymbolTableRecord"); + records.raw(100, "AcDbBlockTableRecord"); + records.str(2, &b.name); + if v.r2000() { + records.handle(340, Handle(0)); + records.int(70, 0); + records.int(280, 1); + records.int(281, 0); + } + } + let records = records.into_string(); + let (Some(table), Some(blocks_at)) = (out.find(" 0\nTABLE\n 2\nBLOCK_RECORD\n"), out.find(" 0\nSECTION\n 2\nBLOCKS\n")) else { + return out; + }; + let count = " 70\n2\n"; + let (Some(c), Some(t_end), Some(b_end)) = ( + out[table..].find(count).map(|i| table + i), + out[table..].find(" 0\nENDTAB\n").map(|i| table + i), + out[blocks_at..].find(" 0\nENDSEC\n").map(|i| blocks_at + i), + ) else { + return out; + }; + let mut s = String::with_capacity(out.len() + records.len() + defs.len()); + s.push_str(&out[..c]); + s.push_str(&format!(" 70\n{}\n", 2 + blocks.len())); + s.push_str(&out[c + count.len()..t_end]); + s.push_str(&records); + s.push_str(&out[t_end..b_end]); + s.push_str(&defs); + s.push_str(&out[b_end..]); + s +} diff --git a/crates/cad/src/lib.rs b/crates/cad/src/lib.rs index 73e30bd2a9..e4eac1b20c 100644 --- a/crates/cad/src/lib.rs +++ b/crates/cad/src/lib.rs @@ -5,7 +5,8 @@ //! layer (hidden ones switched off, locked ones locked, non-printing ones not plotted), paths //! become polylines (straight segments) or cubic splines (curves), fills their outlines and solid //! hatches, type text entities or glyph outlines, and placed images image entities linked to PNG -//! or JPEG files the caller writes next to the drawing. Coordinates are y-up, in drawing units: `scale` units per +//! or JPEG files the caller writes next to the drawing; with [`DxfOptions::group_blocks`] groups +//! become blocks placed by INSERT entities. Coordinates are y-up, in drawing units: `scale` units per //! `unit` of the art, with the origin at the bottom-left corner of [`DxfOptions::region`]. //! [`export_drawings`] writes one such drawing for each of several regions, applying the live //! effects once for all of them. @@ -26,6 +27,8 @@ #![doc(test(attr(deny(unsafe_code))))] mod aci; +// Temporary until storytold/craft-libs#5381 merges and the craft-libs pin moves past it. +mod blocks_compat; pub mod dwg; #[cfg(test)] mod expansion_test; @@ -316,6 +319,10 @@ pub struct DxfOptions { pub alter_paths: bool, /// Type is written as glyph outlines (always with [`Preserve::Appearance`]). pub outline_text: bool, + /// Always Export Group as Block Reference: each group is written as a block definition of its + /// contents, placed by an INSERT entity on the group's layer (groups inside it are blocks + /// placed inside that block). Off: a group's contents are written as plain entities. + pub group_blocks: bool, /// The drawing's origin is this region's bottom-left corner (document space). pub region: Rect, /// Leave out objects entirely outside `region` (one drawing per artboard). @@ -336,6 +343,7 @@ impl Default for DxfOptions { preserve: Preserve::default(), alter_paths: false, outline_text: false, + group_blocks: false, region: Rect::ZERO, crop: false, } diff --git a/crates/cad/src/scene.rs b/crates/cad/src/scene.rs index 26025f2544..45d2fcf234 100644 --- a/crates/cad/src/scene.rs +++ b/crates/cad/src/scene.rs @@ -2,7 +2,8 @@ //! order. Fills are their outlines then solid hatches (the outlines alone in R12 or with //! hatches left out), placed images are linked image files unless left out, strokes //! polylines (with bulges for circular arcs) and cubic splines with a lineweight and dashes, or -//! filled outlines where the look needs them. +//! filled outlines where the look needs them. With [`DxfOptions::group_blocks`] each group is a +//! block, placed by an INSERT. use std::collections::HashMap; @@ -14,6 +15,8 @@ use vectorcraft_geom::{Affine, BezPath, FillRule, PathData, Point, Rect, Vec2}; use crate::aci::nearest_aci; use crate::{CAP_HEIGHT, ColorDepth, DxfImage, DxfOptions, DxfOutput, MAX_NEST, Preserve, RasterFormat}; +// Block and the INSERT writer come from craft-libs#5381 once it merges; see `blocks_compat`. +use crate::blocks_compat::Block; use craft_dxf::drawing::{Codes, Drawing, EntityStyle, Handle, ImageDef, Layer, LineType, STANDARD_STYLE, fixed}; /// Curves are flattened to within this distance (points) where DXF needs straight segments @@ -503,8 +506,13 @@ pub(crate) struct Scene<'a> { to_dxf: Affine, /// Drawing units per point. k: f64, - /// The entities written so far. + /// The entities written so far: those of model space, or of the group block being written. e: Codes, + /// The owner of the entities in `e`: model space, or the group block's record. + owner: Handle, + /// Group blocks written so far ([`DxfOptions::group_blocks`]), each after the blocks it inserts. + blocks: Vec, + block_names: Names, next: u32, layers: Vec, layer_names: Names, @@ -544,6 +552,9 @@ impl<'a> Scene<'a> { to_dxf: Affine::new([k, 0.0, 0.0, -k, -r.x0 * k, r.y1 * k]), k, e: Codes::new(o.version.into()), + owner: fixed::MODEL_RECORD, + blocks: vec![], + block_names: Names::with(&["*Model_Space", "*Paper_Space"]), next: fixed::FIRST_FREE, layers: vec![], layer_names: Names::with(&["0", "Defpoints"]), @@ -593,7 +604,12 @@ impl<'a> Scene<'a> { metric: matches!(self.o.unit, Unit::Millimeters | Unit::Centimeters | Unit::Meters), next: self.next, }; - DxfOutput { bytes: drawing.write().into_bytes(), images: self.files, warnings: self.warnings, setting_notes: self.setting_notes } + DxfOutput { + bytes: crate::blocks_compat::write(drawing, &self.blocks).into_bytes(), + images: self.files, + warnings: self.warnings, + setting_notes: self.setting_notes, + } } /// Note `w`, once, about something of the document that the drawing leaves out or that reaches @@ -660,6 +676,7 @@ impl<'a> Scene<'a> { self.children(children, *clip); (self.layer, self.flags) = outer; } + NodeKind::Group { children, clip } if self.o.group_blocks => self.group_block(n, children, *clip), NodeKind::Group { children, clip } => self.children(children, *clip), NodeKind::Path { path, rule, guide, .. } => { if !*guide { @@ -754,6 +771,27 @@ impl<'a> Scene<'a> { } } + /// Group `n` as a block of its children's entities and an INSERT that places it on the current + /// layer ([`DxfOptions::group_blocks`]). The block's base point is the drawing's origin, so its + /// entities keep their coordinates. A group that writes no entity writes no block. + fn group_block(&mut self, n: &Node, children: &[std::sync::Arc], clip: bool) { + let (record, begin, end, insert) = (self.handle(), self.handle(), self.handle(), self.handle()); + let outer = std::mem::replace(&mut self.e, Codes::new(self.o.version.into())); + let owner = std::mem::replace(&mut self.owner, record); + self.children(children, clip); + let entities = std::mem::replace(&mut self.e, outer).into_string(); + self.owner = owner; + if entities.is_empty() { + return; + } + let long = self.o.version.r2000(); + let base = symbol_name(n.name.as_deref().unwrap_or_default(), long); + let base = if base.is_empty() { symbol_name("Group", long) } else { base }; + let name = self.block_names.unique(&base, if long { 255 } else { 31 }); + crate::blocks_compat::insert(&mut self.e, insert, self.owner, &self.layer, &name); + self.blocks.push(Block { name, record, begin, end, entities }); + } + /// Warn about what DXF can't hold in `n`'s look. fn note_losses(&mut self, n: &Node) { if n.blend != vectorcraft_color::BlendMode::Normal { @@ -959,7 +997,7 @@ impl<'a> Scene<'a> { } let h = self.handle(); let layer = self.layer.clone(); - self.e.entity("HATCH", h, fixed::MODEL_RECORD, &layer, style, "AcDbHatch"); + self.e.entity("HATCH", h, self.owner, &layer, style, "AcDbHatch"); self.e.xyz(10, 0.0, 0.0); self.e.normal(); self.e.raw(2, "SOLID"); @@ -1040,7 +1078,7 @@ impl<'a> Scene<'a> { let (a, b) = (self.pt(a), self.pt(b)); let layer = self.layer.clone(); let h = self.handle(); - self.e.entity("LINE", h, fixed::MODEL_RECORD, &layer, style, "AcDbLine"); + self.e.entity("LINE", h, self.owner, &layer, style, "AcDbLine"); self.e.xyz(10, a.x, a.y); self.e.xyz(11, b.x, b.y); } @@ -1058,7 +1096,7 @@ impl<'a> Scene<'a> { // Bit 128: a linetype runs on through the vertices instead of restarting at each one. let flags = i64::from(closed) | if style.linetype.is_some() { 128 } else { 0 }; if self.o.version.lwpolyline() { - self.e.entity("LWPOLYLINE", h, fixed::MODEL_RECORD, &layer, style, "AcDbPolyline"); + self.e.entity("LWPOLYLINE", h, self.owner, &layer, style, "AcDbPolyline"); self.e.int(90, pts.len() as i64); self.e.int(70, flags); if let Some(w) = width { @@ -1072,7 +1110,7 @@ impl<'a> Scene<'a> { } return; } - self.e.entity("POLYLINE", h, fixed::MODEL_RECORD, &layer, style, "AcDb2dPolyline"); + self.e.entity("POLYLINE", h, self.owner, &layer, style, "AcDb2dPolyline"); self.e.int(66, 1); self.e.xyz(10, 0.0, 0.0); self.e.int(70, flags); @@ -1134,7 +1172,7 @@ impl<'a> Scene<'a> { let layer = self.layer.clone(); let h = self.handle(); if sub.closed { - self.e.entity("CIRCLE", h, fixed::MODEL_RECORD, &layer, style, "AcDbCircle"); + self.e.entity("CIRCLE", h, self.owner, &layer, style, "AcDbCircle"); self.e.xyz(10, centre.x, centre.y); self.e.num(40, radius); self.e.normal(); @@ -1150,7 +1188,7 @@ impl<'a> Scene<'a> { if !on_ccw_arc(a0, a1, am) { std::mem::swap(&mut a0, &mut a1); } - self.e.entity("ARC", h, fixed::MODEL_RECORD, &layer, style, "AcDbCircle"); + self.e.entity("ARC", h, self.owner, &layer, style, "AcDbCircle"); self.e.xyz(10, centre.x, centre.y); self.e.num(40, radius); self.e.normal(); @@ -1197,7 +1235,7 @@ impl<'a> Scene<'a> { let layer = self.layer.clone(); let h = self.handle(); - self.e.entity("ELLIPSE", h, fixed::MODEL_RECORD, &layer, style, "AcDbEllipse"); + self.e.entity("ELLIPSE", h, self.owner, &layer, style, "AcDbEllipse"); self.e.xyz(10, centre.x, centre.y); self.e.xyz(11, axis.x, axis.y); self.e.normal(); @@ -1232,7 +1270,7 @@ impl<'a> Scene<'a> { let ctrl: Vec = ctrl.iter().map(|p| self.pt(*p)).collect(); let layer = self.layer.clone(); let h = self.handle(); - self.e.entity("SPLINE", h, fixed::MODEL_RECORD, &layer, style, "AcDbSpline"); + self.e.entity("SPLINE", h, self.owner, &layer, style, "AcDbSpline"); self.e.normal(); // Planar (bit 3) and, if the subpath is closed, also closed (bit 0). A geometrically // closed cut needs the closed flag set so CAM/CAM tools (e.g. VCarve) treat it as a @@ -1308,7 +1346,7 @@ impl<'a> Scene<'a> { let p = self.pt(t.xf * origin); let layer = self.layer.clone(); let h = self.handle(); - self.e.entity("TEXT", h, fixed::MODEL_RECORD, &layer, &style, "AcDbText"); + self.e.entity("TEXT", h, self.owner, &layer, &style, "AcDbText"); self.e.xyz(10, p.x, p.y); self.e.num(40, height); let s: String = s.chars().take(MAX_TEXT).collect(); @@ -1368,7 +1406,7 @@ impl<'a> Scene<'a> { let def = def.handle; let layer = self.layer.clone(); let style = EntityStyle { aci: 7, ..EntityStyle::default() }; - self.e.entity("IMAGE", handle, fixed::MODEL_RECORD, &layer, &style, "AcDbRasterImage"); + self.e.entity("IMAGE", handle, self.owner, &layer, &style, "AcDbRasterImage"); self.e.int(90, 0); self.e.xyz(10, at.x, at.y); self.e.xyz(11, u.x, u.y); diff --git a/crates/cad/src/tests.rs b/crates/cad/src/tests.rs index 16f4f97082..216dc1a088 100644 --- a/crates/cad/src/tests.rs +++ b/crates/cad/src/tests.rs @@ -8,6 +8,8 @@ use vectorcraft_geom::{Affine, ParamCurve, PathData, Point, Rect, Shape, shapes} use crate::*; +mod blocks; + type Pairs = Vec<(i32, String)>; /// The `(code, value)` pairs of a DXF file. diff --git a/crates/cad/src/tests/blocks.rs b/crates/cad/src/tests/blocks.rs new file mode 100644 index 0000000000..b0ac7a9fe4 --- /dev/null +++ b/crates/cad/src/tests/blocks.rs @@ -0,0 +1,125 @@ +//! Always Export Group as Block Reference: groups written as blocks placed by INSERT entities. + +use super::*; + +/// The user blocks of a drawing (not model or paper space): each its name and the entities +/// between its BLOCK and its ENDBLK. +fn blocks(out: &DxfOutput) -> Vec<(String, Vec)> { + let mut found: Vec<(String, Vec)> = vec![]; + let mut open = false; + for o in section(&pairs(&out.bytes), "BLOCKS") { + match kind(&o) { + "BLOCK" => { + found.push((get(&o, 2).unwrap_or_default().to_string(), vec![])); + open = true; + } + "ENDBLK" => open = false, + _ if open => found.last_mut().expect("a block").1.push(o), + _ => {} + } + } + found.retain(|(name, _)| !name.starts_with('*')); + found +} + +/// A filled square outside any group; the group `Frame` holding a stroked rectangle and the group +/// `Ring` holding a circle, on a second layer `Parts`. +fn grouped_doc() -> Document { + let mut d = doc_with(|d| vec![path(d, shapes::rectangle(Rect::new(150.0, 10.0, 170.0, 30.0)), Paint::solid(Color::BLACK), Paint::None, 0.0)]); + let parts = d.add_layer(Some("Parts")); + let rect = path(&mut d, shapes::rectangle(Rect::new(10.0, 10.0, 110.0, 60.0)), Paint::None, Paint::solid(Color::BLACK), 1.0); + let circle = path(&mut d, shapes::ellipse(Rect::new(40.0, 20.0, 70.0, 50.0)), Paint::None, Paint::solid(Color::rgb(0.0, 0.0, 1.0)), 1.0); + let mut ring = Node::group(d.alloc_id(), vec![Arc::new(circle)]); + ring.name = Some("Ring".into()); + let mut frame = Node::group(d.alloc_id(), vec![Arc::new(rect), Arc::new(ring)]); + frame.name = Some("Frame".into()); + d.insert(Some(parts), usize::MAX, frame).unwrap(); + d +} + +#[test] +fn groups_are_blocks_placed_by_inserts_in_every_version() { + let d = grouped_doc(); + for v in DxfVersion::ALL { + let out = export(&d, &DxfOptions { version: v, group_blocks: true, ..opts(&d) }).unwrap(); + let top = entities(&out); + let inserts: Vec<&Pairs> = top.iter().filter(|e| kind(e) == "INSERT").collect(); + assert_eq!(inserts.len(), 1, "{v:?}: the outer group alone is placed in model space"); + // Before 2000, names are capitals, letters, digits and $-_ only. + let long = v >= DxfVersion::R2000; + let (frame, ring, parts, first) = if long { ("Frame", "Ring", "Parts", "Layer 1") } else { ("FRAME", "RING", "PARTS", "LAYER_1") }; + assert_eq!((get(inserts[0], 2), get(inserts[0], 8)), (Some(frame), Some(parts)), "{v:?}"); + assert!(top.iter().any(|e| kind(e) != "INSERT" && get(e, 8) == Some(first)), "{v:?}: the loose square stays in model space"); + let found = blocks(&out); + let names: Vec<&str> = found.iter().map(|b| b.0.as_str()).collect(); + assert_eq!(names, [ring, frame], "{v:?}: the inner block comes first"); + let (ring_entities, frame_entities) = (&found[0].1, &found[1].1); + assert!(!ring_entities.is_empty() && ring_entities.iter().all(|e| kind(e) != "INSERT"), "{v:?}: the circle is in its group's block"); + let nested: Vec<&Pairs> = frame_entities.iter().filter(|e| kind(e) == "INSERT").collect(); + assert_eq!(nested.len(), 1, "{v:?}: the inner group is placed inside the outer block"); + assert_eq!(get(nested[0], 2), Some(ring), "{v:?}"); + assert!(frame_entities.iter().any(|e| kind(e) != "INSERT"), "{v:?}: the rectangle is in the outer block"); + if v >= DxfVersion::R13 { + // Each block's entities are owned by its BLOCK_RECORD, and the INSERTs by what holds them. + let records = table(&out, "BLOCK_RECORD"); + let record = |name: &str| records.iter().find(|r| get(r, 2) == Some(name)).and_then(|r| get(r, 5).map(str::to_string)); + for (name, ents) in &found { + let owner = record(name).unwrap_or_else(|| panic!("{v:?}: no BLOCK_RECORD for {name}")); + // A polyline's vertices and its SEQEND are owned by the polyline. + let owned: Vec<&Pairs> = ents.iter().filter(|e| !matches!(kind(e), "VERTEX" | "SEQEND")).collect(); + assert!(!owned.is_empty() && owned.iter().all(|e| get(e, 330) == Some(owner.as_str())), "{v:?}: {name}"); + } + assert_eq!(get(inserts[0], 330).map(str::to_string), record("*Model_Space"), "{v:?}: the outer INSERT is in model space"); + assert_eq!(get(nested[0], 330).map(str::to_string), record(frame), "{v:?}: the inner INSERT is in the outer block"); + } + } +} + +#[test] +fn without_the_option_groups_are_written_as_their_contents() { + let d = grouped_doc(); + let out = export(&d, &opts(&d)).unwrap(); + assert!(blocks(&out).is_empty()); + assert!(!kinds(&out).iter().any(|k| k == "INSERT")); + let with = export(&d, &DxfOptions { group_blocks: true, ..opts(&d) }).unwrap(); + // The same entities are written, moved into blocks. + let count = |o: &DxfOutput| { + let drawn = |ents: &[Pairs]| ents.iter().filter(|e| kind(e) != "INSERT").count(); + drawn(&entities(o)) + blocks(o).iter().map(|b| drawn(&b.1)).sum::() + }; + assert_eq!(count(&out), count(&with)); + assert_eq!(header(&pairs(&out.bytes), "$EXTMIN"), header(&pairs(&with.bytes), "$EXTMIN")); + assert_eq!(header(&pairs(&out.bytes), "$EXTMAX"), header(&pairs(&with.bytes), "$EXTMAX")); +} + +#[test] +fn blocks_read_back_at_the_place_their_group_was() { + let d = grouped_doc(); + let o = ImportOptions { unit: Some(Unit::Points), scale: Some(1.0), center: false, ..ImportOptions::default() }; + let plain = import(&export(&d, &opts(&d)).unwrap().bytes, &o).unwrap().document; + let blocked = import(&export(&d, &DxfOptions { group_blocks: true, ..opts(&d) }).unwrap().bytes, &o).unwrap().document; + let names: Vec<&str> = blocked.symbols.iter().map(|s| s.name.as_str()).collect(); + assert!(names.contains(&"Frame") && names.contains(&"Ring"), "{names:?}"); + let (a, b) = (plain.art_bounds().unwrap(), blocked.art_bounds().unwrap()); + assert!(close_to(&[a.x0, a.y0, a.x1, a.y1], &[b.x0, b.y0, b.x1, b.y1], 1e-6), "{a:?} against {b:?}"); +} + +#[test] +fn a_group_with_nothing_written_is_no_block_and_names_stay_unique() { + let mut d = Document::new(200.0, 100.0); + let layer = d.layers[0].id; + let mut hidden = path(&mut d, shapes::rectangle(Rect::new(0.0, 0.0, 5.0, 5.0)), Paint::solid(Color::BLACK), Paint::None, 0.0); + hidden.visible = false; + let empty = Node::group(d.alloc_id(), vec![Arc::new(hidden)]); + d.insert(Some(layer), usize::MAX, empty).unwrap(); + for name in [Some("Part"), Some("part"), None, Some("*Model_Space")] { + let p = path(&mut d, shapes::rectangle(Rect::new(10.0, 10.0, 20.0, 20.0)), Paint::solid(Color::BLACK), Paint::None, 0.0); + let mut g = Node::group(d.alloc_id(), vec![Arc::new(p)]); + g.name = name.map(str::to_string); + d.insert(Some(layer), usize::MAX, g).unwrap(); + } + let out = export(&d, &DxfOptions { group_blocks: true, ..opts(&d) }).unwrap(); + let names: Vec = blocks(&out).into_iter().map(|b| b.0).collect(); + assert_eq!(names, ["Part", "part_2", "Group", "_Model_Space"], "the hidden-only group writes no block"); + assert_eq!(kinds(&out).iter().filter(|k| *k == "INSERT").count(), 4); +} diff --git a/crates/doc/src/corners.rs b/crates/doc/src/corners.rs index ba12eafabb..56bbb29845 100644 --- a/crates/doc/src/corners.rs +++ b/crates/doc/src/corners.rs @@ -28,12 +28,19 @@ pub fn resolve_stored_radii(base: &PathData, stored: &[f64], relative: bool) -> out } +fn dormant_radius_scale(base: &PathData) -> f64 { + base.length().max(1e-12) +} + /// Turn stored absolute radii into fractions of each corner's maximum, or the other way. +/// Anchors without a cuttable corner use the outline's length (at least 1e-12 document units). +/// Their fractions are not capped at 1. +/// When an anchor edit straightens or bends a corner, [`edit_corner_anchors`] converts its +/// radius between these reference lengths, preserving its document length at that edit. pub fn convert_radii_relative(live: &mut LiveShape, relative: bool) { if live.radii_relative() == relative { return; } - let was_relative = live.radii_relative(); let base = match live { LiveShape::Rectangle { w, h, .. } => shapes::rectangle(Rect::new(0.0, 0.0, *w, *h)), LiveShape::Polygon { .. } | LiveShape::Star { .. } => live.polygon_outline(), @@ -41,22 +48,22 @@ pub fn convert_radii_relative(live: &mut LiveShape, relative: bool) { LiveShape::Ellipse { .. } | LiveShape::Line { .. } => return, }; let corners = path_corners(&base); + let dormant_scale = dormant_radius_scale(&base); let radii: &mut [f64] = match live { LiveShape::Rectangle { radii, .. } => radii, LiveShape::Polygon { radii, .. } | LiveShape::Star { radii, .. } => radii, LiveShape::Path { radii, .. } => radii, LiveShape::Ellipse { .. } | LiveShape::Line { .. } => return, }; - for c in corners { - if let Some(r) = radii.get(c.index) { - let max = c.max_radius(); - radii[c.index] = if relative { - if max > 1e-12 && !was_relative { (*r / max).clamp(0.0, 1.0) } else { *r } - } else if was_relative { - (*r).clamp(0.0, 1.0) * max - } else { - *r - }; + for (index, r) in radii.iter_mut().enumerate() { + let corner = corners.binary_search_by_key(&index, |c| c.index).ok().map(|i| &corners[i]); + let max = corner.map_or(dormant_scale, Corner::max_radius); + if relative { + if max > 0.0 { + *r = if corner.is_some() { (*r / max).clamp(0.0, 1.0) } else { (*r / max).max(0.0) }; + } + } else { + *r = if corner.is_some() { (*r).clamp(0.0, 1.0) } else { (*r).max(0.0) } * max; } } match live { @@ -143,7 +150,8 @@ impl<'a> LiveCorners<'a> { } /// The radius corner `index` is stored at: document lengths, or a fraction in 0..1 when - /// [`LiveCorners::radii_relative`]. + /// [`LiveCorners::radii_relative`]. Dormant anchors use the reference length documented in + /// [`convert_radii_relative`], and their fractions can exceed 1. pub fn radius(&self, index: usize) -> f64 { self.radii.get(index).copied().unwrap_or(0.0) } @@ -206,8 +214,8 @@ impl<'a> LiveCorners<'a> { /// Set `radius` (document units; negative: 0) and/or `kind` on the `corners` (anchor indices of /// the uncut outline, see [`LiveCorners`]) of a path and its live shape, then cut the path again. /// A path that isn't a live shape keeps its uncut outline as a [`LiveShape::Path`], which is a -/// plain path again once no corner is cut. Ellipses and lines have no corners: they stay as they -/// are. +/// plain path again once no radius or nondefault corner kind is stored. A straight anchor keeps +/// its stored radius. Ellipses and lines have no corners: they stay as they are. pub fn set_corners(path: &mut PathData, live: &mut Option>, corners: &BTreeSet, radius: Option, kind: Option) { fn edit( base: &PathData, @@ -286,13 +294,31 @@ pub fn set_corners(path: &mut PathData, live: &mut Option>, corne } } +/// Convert relative `radii` (fractions, one per anchor of the outline) after the outline changed +/// from `before` to `after`: a corner that straightened keeps its document length as a fraction of +/// `after`'s length, and a corner that bent again takes that length back as a fraction of its new +/// maximum. Other radii are left as they are. +pub fn rebase_relative_radii(before: &PathData, after: &PathData, radii: &mut [f64]) { + let (old_corners, new_corners) = (path_corners(before), path_corners(after)); + let (old_dormant_scale, new_dormant_scale) = (dormant_radius_scale(before), dormant_radius_scale(after)); + for (index, r) in radii.iter_mut().enumerate() { + let old = old_corners.binary_search_by_key(&index, |c| c.index).ok().map(|i| &old_corners[i]); + let new = new_corners.binary_search_by_key(&index, |c| c.index).ok().map(|i| &new_corners[i]); + match (old, new) { + (Some(c), None) => *r = (*r).clamp(0.0, 1.0) * c.max_radius() / new_dormant_scale, + (None, Some(c)) => *r = (*r * old_dormant_scale / c.max_radius()).clamp(0.0, 1.0), + _ => {} + } + } +} + /// Edit the anchors of the uncut outline that `anchors` (of the path as drawn) come from, while the /// path keeps its Live Corners: `edit` gets the outline in document space and those of its anchors, /// and the path is cut again with the same radii and kinds. A live rectangle or polygon becomes a /// [`LiveShape::Path`] with that outline. [`LiveCorners::sources`] before and after the edit map /// the anchors as drawn to the corners they come from. /// Returns `None`, leaving the path unchanged, when the path has no live shape or -/// no cut corner, or is a rectangle sheared or scaled unevenly. +/// no corner with a radius, or is a rectangle sheared or scaled unevenly. pub fn edit_corner_anchors( path: &mut PathData, live: &mut Option>, @@ -307,9 +333,11 @@ pub fn edit_corner_anchors( return None; } } - let (mut base, moved, radii, kinds, relative) = { + let (mut base, moved, mut radii, kinds, relative) = { let lc = LiveCorners::new(path, live.as_deref())?; - if !lc.drawn.iter().any(|r| *r > 0.0) { + // The stored radii decide, not the drawn ones: a corner the edit straightened draws no + // arc but keeps its radius, and rounds again when a later edit bends it. + if !lc.radii.iter().any(|r| *r > 0.0) { return None; } let moved: BTreeSet = anchors.iter().filter_map(|(si, ai)| lc.sources.get(*si)?.get(*ai).copied()).collect(); @@ -330,7 +358,11 @@ pub fn edit_corner_anchors( k += 1; } } + let before = relative.then(|| base.clone()); edit(&mut base, &on_base); + if let Some(before) = before { + rebase_relative_radii(&before, &base, &mut radii); + } let l = LiveShape::Path { base, radii, kinds, radii_relative: relative }; *path = l.to_path(); *live = Some(Box::new(l)); @@ -423,6 +455,48 @@ mod tests { assert!(!p.transform(Affine::translate((5.0, 0.0))), "a move needs no new cuts"); } + /// Moving the anchor of the only rounded corner into a straight line and back keeps its + /// stored radius, so the corner is rounded again. + #[test] + fn a_straightened_corner_rounds_again_when_it_bends_back() { + let pen = PathData::single(SubPath::polyline(&[Point::new(0.0, 0.0), Point::new(100.0, 0.0), Point::new(100.0, 80.0)], false)); + let (mut path, mut live) = (pen.clone(), None); + set_corners(&mut path, &mut live, &set(&[1]), Some(10.0), None); + let corner = LiveCorners::new(&path, live.as_deref()).unwrap().anchors_of(&set(&[1])); + let move_corner = |path: &mut PathData, live: &mut Option>, to: Point| { + let sel = LiveCorners::new(path, live.as_deref()).unwrap().anchors_of(&set(&[1])); + let sel = if sel.is_empty() { anchors(&[1]) } else { sel }; + edit_corner_anchors(path, live, &sel, |base, on_base| { + for &(si, ai) in on_base { + if let Some(a) = base.anchor_mut(si, ai) { + (a.p, a.h_in, a.h_out) = (to, to, to); + } + } + }) + }; + assert_eq!(corner.len(), 2, "the corner is cut"); + // Straight: the corner has nothing to cut. + assert!(move_corner(&mut path, &mut live, Point::new(50.0, 40.0)).is_some()); + assert!(matches!(live.as_deref(), Some(LiveShape::Path { radii, .. }) if radii.get(1) == Some(&10.0))); + assert_eq!(LiveCorners::new(&path, live.as_deref()).unwrap().drawn_radius(1), 0.0, "the straight corner draws no arc"); + // Bent again: the stored radius cuts it again. + assert!(move_corner(&mut path, &mut live, Point::new(100.0, 0.0)).is_some(), "the straightened corner stays live"); + let c = LiveCorners::new(&path, live.as_deref()).unwrap(); + assert!((c.drawn_radius(1) - 10.0).abs() < 1e-6, "the corner keeps its radius: {live:?}"); + + for relative in [true, false] { + assert!(move_corner(&mut path, &mut live, Point::new(50.0, 40.0)).is_some()); + assert_eq!(LiveCorners::new(&path, live.as_deref()).unwrap().drawn_radius(1), 0.0); + let l = live.as_deref_mut().unwrap(); + convert_radii_relative(l, relative); + assert_eq!(l.radii_relative(), relative); + path = l.to_path(); + assert!(move_corner(&mut path, &mut live, Point::new(100.0, 0.0)).is_some()); + let c = LiveCorners::new(&path, live.as_deref()).unwrap(); + assert!((c.drawn_radius(1) - 10.0).abs() < 1e-6, "the corner keeps its radius after changing modes: {live:?}"); + } + } + #[test] fn relative_radii_scale_with_rectangle_size() { let l = LiveShape::Rectangle { diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index 059a3d4bdc..7bddc2c482 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -103,7 +103,7 @@ pub use appearance::{ }; pub use assets::ExportAsset; pub use compound_shape::ShapeMode; -pub use corners::{LiveCorners, edit_corner_anchors}; +pub use corners::{LiveCorners, edit_corner_anchors, rebase_relative_radii}; pub use depth::{MAX_DEPTH, MAX_SYMBOL_NODES}; pub use graph::{ ColumnDesign, ColumnType, DEFAULT_FILLED_LINE_WIDTH, FILLED_LINE_OUTLINE_WIDTH, Fractions, GraphDesign, GraphKind, GraphSpec, LabelRows, diff --git a/crates/engine/src/cmd/addons/arrange/artboard_guides.rs b/crates/engine/src/cmd/addons/arrange/artboard_guides.rs index d849047fb9..982b3cd757 100644 --- a/crates/engine/src/cmd/addons/arrange/artboard_guides.rs +++ b/crates/engine/src/cmd/addons/arrange/artboard_guides.rs @@ -117,13 +117,17 @@ fn traces(path: &PathData, corners: &[Point; 4]) -> bool { if (0..n).any(|i| !straight(&sp.anchors[i], &sp.anchors[(i + 1) % n])) { return false; } + // A last anchor on the first one only closes the path: the check above has kept its handles on that + // point, so the corners are read without it. + let m = if sp.anchors[n - 1].p == sp.anchors[0].p { n - 1 } else { n }; let points: Vec = sp .anchors .iter() + .take(m) .enumerate() .filter_map(|(i, a)| { - let prev = sp.anchors[(i + sp.anchors.len() - 1) % sp.anchors.len()].p; - let next = sp.anchors[(i + 1) % sp.anchors.len()].p; + let prev = sp.anchors[(i + m - 1) % m].p; + let next = sp.anchors[(i + 1) % m].p; let interior = (prev.x == a.p.x && a.p.x == next.x && a.p.y > prev.y.min(next.y) && a.p.y < prev.y.max(next.y)) || (prev.y == a.p.y && a.p.y == next.y && a.p.x > prev.x.min(next.x) && a.p.x < prev.x.max(next.x)); (!interior).then_some(a.p) diff --git a/crates/engine/src/cmd/addons/arrange/artboard_guides/tests.rs b/crates/engine/src/cmd/addons/arrange/artboard_guides/tests.rs index 5152dcffe9..492af2a371 100644 --- a/crates/engine/src/cmd/addons/arrange/artboard_guides/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/artboard_guides/tests.rs @@ -198,6 +198,30 @@ fn collinear_midpoints_do_not_add_another_guide_or_history_step() { } } +#[test] +fn a_closing_anchor_on_the_first_one_does_not_add_another_guide_or_history_step() { + let mut s = session(); + let r = s.execute(COMMAND, &json!({})).unwrap(); + let [id] = ids(&r)[..] else { panic!("one guide: {r}") }; + let b = board(&s, 0); + let corners = [Point::new(b.x0, b.y0), Point::new(b.x1, b.y0), Point::new(b.x1, b.y1), Point::new(b.x0, b.y1)]; + for reverse in [false, true] { + let mut points = corners.to_vec(); + if reverse { + points.reverse(); + } + points.push(points[0]); + let d = Arc::make_mut(&mut s.doc_mut().unwrap().doc); + let NodeKind::Path { path, .. } = &mut d.node_mut(id).unwrap().kind else { panic!("guide path") }; + *path = PathData::single(SubPath::polyline(&points, true)); + let (before, n) = (s.doc().unwrap().doc.clone(), steps(&s)); + let again = s.execute(COMMAND, &json!({})).unwrap(); + assert_eq!(again, json!({"ids": [], "layer": r["layer"], "skipped": 1}), "reverse: {reverse}"); + assert_eq!(steps(&s), n); + assert_eq!(s.doc().unwrap().doc, before); + } +} + #[test] fn handles_along_a_side_still_match_and_handles_off_it_do_not() { let mut s = session(); diff --git a/crates/engine/src/cmd/addons/cleanup.rs b/crates/engine/src/cmd/addons/cleanup.rs index d5f241b4ee..8f4def2dcd 100644 --- a/crates/engine/src/cmd/addons/cleanup.rs +++ b/crates/engine/src/cmd/addons/cleanup.rs @@ -1,9 +1,10 @@ //! Artwork Cleanup (`addon.cleanup.*`), a built-in add-on: Simplify Anchors (Keep Shape), the -//! Document Health Check (check, show and fix the issues it finds), Deep Ungroup and Rejoin Path -//! Pieces, and its text tools ([`text`]). Its panel and its submenu, Object › Plug-ins › Artwork -//! Cleanup, are the UI's. +//! Document Health Check (check, show and fix the issues it finds), Deep Ungroup, Release All +//! Containers ([`release`]) and Rejoin Path Pieces, and its text tools ([`text`]). Its panel and +//! its submenu, Object › Plug-ins › Artwork Cleanup, are the UI's. mod checks; +mod release; #[cfg(test)] mod tests; mod text; @@ -87,6 +88,7 @@ pub fn specs() -> Vec { rejoin ), ]; + v.extend(release::specs()); v.extend(text::specs()); v } diff --git a/crates/engine/src/cmd/addons/cleanup/release.rs b/crates/engine/src/cmd/addons/cleanup/release.rs new file mode 100644 index 0000000000..2e09151866 --- /dev/null +++ b/crates/engine/src/cmd/addons/cleanup/release.rs @@ -0,0 +1,422 @@ +//! Artwork Cleanup's Release All Containers (`addon.cleanup.releaseAll`): every group, clipping +//! mask and compound path in the selection, the objects named or the whole document, taken apart +//! at every level of nesting as one undo step, so that only the objects they held are left. + +#[cfg(test)] +mod tests; + +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; + +use serde_json::{Value, json}; +use vectorcraft_doc::{Document, LiveShape, LockedArtboards, Node, NodeId, NodeKind}; +use vectorcraft_geom::PathData; +use vectorcraft_tools::builder::is_live_paint; + +use super::checks::{MAX_OBJECTS, Scope}; +use super::{named, retain_targets, scope_of}; +use crate::cmd::{CommandSpec, bad, checked_ids_or_selection, cmd, has_doc, switch_or}; +use crate::{EngineError, Result, Session}; + +/// The command. +const COMMAND: &str = "addon.cleanup.releaseAll"; + +pub(super) fn specs() -> Vec { + vec![cmd!( + "addon.cleanup.releaseAll", + "Release All Containers…", + ["Object", "Plug-ins", "Artwork Cleanup"], + None, + "{scope?: \"selection\"|\"document\" (default: the selection, or the document while nothing is selected), ids?: [id…] (the objects, groups and layers to release in, instead of `scope`; duplicate ids are an error), groups?: bool (true: groups are ungrouped), clipGroups?: bool (true: clipping groups are ungrouped and layers stop clipping unless their clipping path or clipped artwork overlaps a locked artboard, their released clipping paths kept as plain paths), compoundPaths?: bool (true: compound paths, and paths of several subpaths, become one path per subpath); at least one of the three true; `scope` and the three are never null} take apart every container of the kinds asked for, at every level of nesting, as one undo step when one goes; layers stay; each object keeps the opacity of the groups and compound paths it was in, and a compound path's paths take its paint; objects with live effects on their appearance or fill and stroke rows, groups with fill or stroke rows of their own, objects with an opacity mask, compound shapes, Live Paint groups, graphs, dimensions, flares, Objects on Path, generated art, Shaper Groups, Image Trace objects, paths with Live Corners, blends, envelopes, repeats, intertwines and other live objects stay whole, including directly selected or named descendants; the entire clipping mask subtree of a clipping group or layer that stays is left as it is, including directly selected or named descendants; from the selection or the document, locked and hidden objects, and objects on a locked artboard, stay whole; named by `ids`, locked and hidden ones are taken apart too (their objects become locked or hidden as they were), but not those on a locked artboard; the selection keeps what it held, each object taken apart replaced by what it left, locked and hidden objects left out → {scope (\"selection\", \"document\" or \"ids\"), ids (the objects selected), groups, clipGroups, compoundPaths (how many of each were released)}", + has_doc, + release_all + )] +} + +/// The kinds of container a request takes apart. +#[derive(Clone, Copy)] +struct Kinds { + groups: bool, + clips: bool, + compounds: bool, +} + +impl Kinds { + /// Whether a group is taken apart: a clipping group (`clip`) with `clips`, another with `groups`. + fn takes_group(self, clip: bool) -> bool { + if clip { self.clips } else { self.groups } + } +} + +/// One run over the objects: what it takes apart and what it found. +struct Release<'a> { + kinds: Kinds, + /// Locked and hidden objects are taken apart too. + named: bool, + /// The artwork on a locked artboard, which stays whole. + held: &'a HashSet, + /// Groups, clipping groups and layers, and compound paths released. + counts: [usize; 3], + /// Objects made from the containers taken apart. + made: usize, + /// Each container taken apart and the objects left in its place. + left: HashMap>, +} + +/// Whether `n` stays whole whatever is asked: a live object kept as a group or compound path +/// (a compound shape, Live Paint group, graph, dimension, flare, Objects on Path, generated art, +/// Shaper Group, Image Trace object, a clipping path's painted pieces), a path with Live Corners, +/// whose parts would lose their editable corners, one with an opacity mask or live effects +/// on its appearance or fill and stroke rows, or a group with fill or stroke rows of its own. +fn live(n: &Node) -> bool { + let x = n.extras(); + matches!(&n.kind, NodeKind::Blend { .. } | NodeKind::Envelope { .. } | NodeKind::Repeat(_) | NodeKind::Intertwine { .. }) + || matches!(&n.kind, NodeKind::Path { live: Some(l), .. } if matches!(**l, LiveShape::Path { .. })) + || !n.appearance.effects.is_empty() + || n.appearance.items.iter().any(|item| !item.effects().is_empty()) + || x.mask.is_some() + || x.shaper.is_some() + || x.trace.is_some() + || x.graph.is_some() + || x.dimension.is_some() + || x.flare.is_some() + || x.objects_on_path.is_some() + || x.generated.is_some() + || x.live_paint_gaps.is_some() + || x.clip_pieces + || (matches!(&n.kind, NodeKind::Group { .. }) && !n.appearance.items.is_empty()) + || n.is_compound_shape() + || is_live_paint(n) +} + +/// The artwork under `n` is added to `out`. +fn candidates(n: &Node, clips: bool, out: &mut Vec) { + let candidate = match &n.kind { + NodeKind::Layer { .. } => false, + NodeKind::Group { .. } | NodeKind::Compound { .. } => true, + NodeKind::Path { path, .. } => clips || path.subpaths.len() > 1, + _ => clips, + }; + if candidate { + out.push(n.id); + } + if let Some(children) = n.children() { + children.iter().for_each(|c| candidates(c, clips, out)); + } +} + +impl Release<'_> { + fn total(&self) -> usize { + self.counts.iter().sum() + } + + /// Whether `n` is left as it is: locked or hidden (unless named), on a locked artboard, or live. + fn keeps(&self, n: &Node) -> bool { + (!self.named && (n.locked || !n.visible)) || self.held.contains(&n.id) || live(n) + } + + /// `n` with the containers in it released, into `out`; `member` counts what a container left. + fn node(&mut self, d: &mut Document, n: Arc, member: bool, out: &mut Vec>) -> Result<()> { + if self.keeps(&n) { + if member { + self.made(1)?; + } + out.push(n); + return Ok(()); + } + match &n.kind { + NodeKind::Group { clip, .. } if self.kinds.takes_group(*clip) => { + let clip = *clip; + self.counts[usize::from(clip)] += 1; + self.take_apart(d, n, clip, false, out) + } + NodeKind::Compound { .. } if self.kinds.compounds => { + self.counts[2] += 1; + self.take_apart(d, n, false, true, out) + } + NodeKind::Path { path, clipping: false, guide: false, .. } if self.kinds.compounds && path.subpaths.len() > 1 => { + self.counts[2] += 1; + self.split(d, (*n).clone(), out) + } + NodeKind::Group { .. } | NodeKind::Layer { .. } => self.keep(d, n, member, out), + _ => { + if member { + self.made(1)?; + } + out.push(n); + Ok(()) + } + } + } + + /// Group or compound path `n` replaced by its members, released in turn. Members take on the + /// container's opacity, are hidden when it was hidden and locked when it was locked; a + /// compound path's take its paint; a clipping group's clipping path becomes a plain path. + fn take_apart(&mut self, d: &mut Document, n: Arc, clip: bool, compound: bool, out: &mut Vec>) -> Result<()> { + let Some(children) = n.children() else { return Ok(()) }; + let mut parts = vec![]; + for (k, c) in children.iter().enumerate() { + let mut c = (**c).clone(); + if clip + && k == 0 + && let NodeKind::Path { clipping, .. } = &mut c.kind + { + *clipping = false; + } + if compound { + c.appearance = n.appearance.clone(); + if n.extras().pixel_aligned { + c.extras_mut().pixel_aligned = true; + } + } + c.opacity *= n.opacity; + c.visible &= n.visible; + c.locked |= n.locked; + self.node(d, Arc::new(c), true, &mut parts)?; + } + self.left.insert(n.id, parts.iter().map(|p| p.id).collect()); + out.extend(parts); + Ok(()) + } + + /// Path `n` of several subpaths as one path per subpath with its paint, in the same stacking + /// order; the first keeps its id. + fn split(&mut self, d: &mut Document, n: Node, out: &mut Vec>) -> Result<()> { + let Some(path) = n.path_data() else { return Ok(()) }; + if self.made.saturating_add(path.subpaths.len()) > MAX_OBJECTS { + return Err(EngineError::Other("Release All Containers: too many objects to release at once".into())); + } + let mut template = n.clone(); + if let NodeKind::Path { path, live, .. } = &mut template.kind { + (*path, *live) = (PathData::single(Default::default()), None); + } + let mut parts = Vec::with_capacity(path.subpaths.len()); + for (k, sp) in path.subpaths.iter().enumerate() { + let mut c = if k == 0 { template.clone() } else { d.reid(&template) }; + if let NodeKind::Path { path, live, .. } = &mut c.kind { + (*path, *live) = (PathData::single(sp.clone()), None); + } + parts.push(Arc::new(c)); + } + self.made(parts.len())?; + self.left.insert(n.id, parts.iter().map(|p| p.id).collect()); + out.extend(parts); + Ok(()) + } + + /// Group or layer `n` kept, with the containers in it released. A layer stops clipping when + /// clipping groups are released; the clipping path of a group or layer that still clips is + /// left as it is. Unchanged, `n` itself goes to `out`. + fn keep(&mut self, d: &mut Document, mut n: Arc, member: bool, out: &mut Vec>) -> Result<()> { + if member { + self.made(1)?; + } + let before = self.total(); + let mut clips = n.clips(); + if clips && n.is_layer() && self.kinds.clips && !n.children().is_some_and(|children| children.iter().any(|c| self.holds_art(c))) { + self.counts[1] += 1; + let n = Arc::make_mut(&mut n); + n.set_clips(false); + clips = false; + if let Some(first) = n.children_mut().and_then(|c| c.first_mut()) + && let NodeKind::Path { clipping, .. } = &mut Arc::make_mut(first).kind + { + *clipping = false; + } + } + let Some(children) = n.children() else { + out.push(n); + return Ok(()); + }; + let mut kept = Vec::with_capacity(children.len()); + for (k, c) in children.iter().enumerate() { + if clips && k == 0 { + if member { + self.made(1)?; + } + kept.push(Arc::clone(c)); + } else { + self.node(d, Arc::clone(c), member, &mut kept)?; + } + } + if self.total() != before + && let Some(ch) = Arc::make_mut(&mut n).children_mut() + { + *ch = kept; + } + out.push(n); + Ok(()) + } + + fn holds_art(&self, n: &Node) -> bool { + self.held.contains(&n.id) || n.children().is_some_and(|children| children.iter().any(|c| self.holds_art(c))) + } + + /// Counts the objects made, refusing a run that makes too many. + fn made(&mut self, count: usize) -> Result<()> { + self.made += count; + if self.made > MAX_OBJECTS { + return Err(EngineError::Other("Release All Containers: too many objects to release at once".into())); + } + Ok(()) + } + + /// `id`, or the objects left in its place when it was taken apart. + fn replaced(&self, id: NodeId, into: &mut Vec) { + match self.left.get(&id) { + Some(ids) => into.extend(ids), + None => into.push(id), + } + } +} + +/// Whether shown artwork in `n` overlaps a locked artboard: a plain group that is not live +/// ([`live`]) by its shown members, anything else by its own bounds. +fn shows_on(locks: &LockedArtboards<'_>, n: &Node) -> bool { + if !n.visible { + return false; + } + match (&n.kind, n.children()) { + (NodeKind::Group { clip: false, .. }, Some(children)) if !live(n) => children.iter().any(|c| shows_on(locks, c)), + _ => locks.holds(n), + } +} + +/// Whether `id` is in the clipping mask subtree of a clipping group or layer. +fn in_clipping_mask(d: &Document, id: NodeId) -> bool { + d.ancestry(id).is_some_and(|chain| { + chain + .windows(2) + .any(|pair| d.node(pair[0]).is_some_and(|p| p.clips() && p.children().and_then(|c| c.first()).is_some_and(|c| c.id == pair[1]))) + }) +} + +fn release_all(s: &mut Session, p: &Value) -> Result { + if !p.is_object() { + return Err(bad(COMMAND, "parameters must be an object")); + } + for key in ["groups", "clipGroups", "compoundPaths"] { + if p.get(key).is_some_and(|v| !v.is_boolean()) { + return Err(bad(COMMAND, format!("`{key}` must be true or false"))); + } + } + if p.get("scope").is_some_and(|v| !matches!(v.as_str(), Some("selection" | "document"))) { + return Err(bad(COMMAND, "`scope` must be \"selection\" or \"document\"")); + } + if let Some(ids) = p.get("ids").filter(|v| !v.is_null()) { + let ids = ids.as_array().ok_or_else(|| bad(COMMAND, "`ids` must be an array of non-negative integer object ids"))?; + let mut seen = HashSet::new(); + for id in ids { + let id = id.as_u64().ok_or_else(|| bad(COMMAND, "`ids` must contain non-negative integer object ids"))?; + if !seen.insert(id) { + return Err(bad(COMMAND, format!("duplicate object id {id} in `ids`"))); + } + } + } + let kinds = Kinds { + groups: switch_or(p, "groups", true, COMMAND)?, + clips: switch_or(p, "clipGroups", true, COMMAND)?, + compounds: switch_or(p, "compoundPaths", true, COMMAND)?, + }; + if !(kinds.groups || kinds.clips || kinds.compounds) { + return Err(bad(COMMAND, "`groups`, `clipGroups` and `compoundPaths` are all false: there is nothing to release")); + } + let named = named(p); + if named && p.get("scope").is_some() { + return Err(bad(COMMAND, "give `scope` or `ids`, not both")); + } + let (roots, name) = if named { + let mut roots = checked_ids_or_selection(s, p, COMMAND)?; + retain_targets(&s.doc()?.doc, &mut roots, true, |id| *id); + (roots, "ids") + } else { + match scope_of(s, p, COMMAND)? { + (Scope::Document, name) => (s.doc()?.doc.layers.iter().map(|l| l.id).collect(), name), + (Scope::Objects(mut roots), name) => { + retain_targets(&s.doc()?.doc, &mut roots, false, |id| *id); + (roots, name) + } + } + }; + let st = s.doc()?; + let (mut d, mut sel) = ((*st.doc).clone(), st.selection.clone()); + // The artwork on a locked artboard, found while nothing is changed yet. + let held: HashSet = if d.artboards.iter().any(|a| a.locked) { + let mut found = vec![]; + for n in roots.iter().filter_map(|id| d.node(*id)) { + candidates(n, kinds.clips, &mut found); + } + let locks = d.locked_artboards(); + let mut held: HashSet = found.iter().copied().filter(|id| locks.holds_id(*id)).collect(); + // A shown clipping group whose clipped artwork overlaps a locked artboard stays whole, + // wherever its clipping path lies, when clipping groups are released; the clipping groups + // the targets are in count too. + let ancestors = roots.iter().filter_map(|id| d.ancestry(*id)).flatten(); + let clip_groups: HashSet = found + .iter() + .copied() + .chain(ancestors) + .filter(|id| kinds.clips && d.node(*id).is_some_and(|n| matches!(&n.kind, NodeKind::Group { clip: true, .. }))) + .collect(); + // Pattern editing mode's art is on no artboard. + let pattern_layer = d.pattern_edit.as_ref().map(|e| e.layer); + for id in clip_groups { + let shown = d.ancestry(id).is_some_and(|chain| chain.iter().all(|a| Some(*a) != pattern_layer && d.node(*a).is_some_and(|n| n.visible))); + if shown + && let Some(n) = d.node(id) + && n.children().is_some_and(|c| c.iter().skip(1).any(|c| shows_on(&locks, c))) + { + held.insert(id); + } + } + held + } else { + HashSet::new() + }; + let mut run = Release { kinds, named, held: &held, counts: [0; 3], made: 0, left: HashMap::new() }; + let mut items = vec![]; + for id in roots { + // Direct targets inside a live object or clipping mask stay whole. + let protected = + d.ancestry(id).is_some_and(|chain| chain.iter().take(chain.len().saturating_sub(1)).filter_map(|id| d.node(*id)).any(|n| run.keeps(n))); + if in_clipping_mask(&d, id) || protected { + continue; + } + let Some(n) = d.node_arc(id).cloned() else { continue }; + let before = run.total(); + let mut out = vec![]; + run.node(&mut d, n, false, &mut out)?; + if run.total() != before { + items.push((id, out.into_iter().map(Arc::unwrap_or_clone).collect())); + } + } + let [groups, clips, compounds] = run.counts; + // With nothing to release, the document, the selection and the undo history stay as they are. + if run.total() == 0 { + let ids: Vec = sel.objects.iter().map(|i| i.0).collect(); + return Ok(json!({ "scope": name, "ids": ids, "groups": 0, "clipGroups": 0, "compoundPaths": 0 })); + } + d.insert_beside(items, true)?; + let mut ids = vec![]; + for id in sel.objects.iter() { + run.replaced(*id, &mut ids); + } + // Locked and hidden objects, and those in locked or hidden groups, are not selected. + { + let editable = d.editable(); + ids.retain(|id| editable(*id)); + } + let kept: HashSet = ids.iter().copied().collect(); + let removed: Vec = sel.objects.iter().copied().filter(|id| run.left.contains_key(id) || !kept.contains(id)).collect(); + sel.remove_all(removed); + let mut seen = HashSet::new(); + sel.objects = ids.into_iter().filter(|id| seen.insert(*id)).collect(); + sel.prune(&d); + let ids: Vec = sel.objects.iter().map(|i| i.0).collect(); + s.edit("Release All Containers", |doc, selection| { + *doc = d; + *selection = sel; + Ok(()) + })?; + Ok(json!({ "scope": name, "ids": ids, "groups": groups, "clipGroups": clips, "compoundPaths": compounds })) +} diff --git a/crates/engine/src/cmd/addons/cleanup/release/tests.rs b/crates/engine/src/cmd/addons/cleanup/release/tests.rs new file mode 100644 index 0000000000..991e74f854 --- /dev/null +++ b/crates/engine/src/cmd/addons/cleanup/release/tests.rs @@ -0,0 +1,860 @@ +//! Release All Containers: every level taken apart as one undo step, the kinds asked for only, +//! the selection, the document and named objects, clipping layers, what stays whole, and refusals. + +use serde_json::{Value, json}; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_doc::{Appearance, LiveShape, Node, NodeId, NodeKind}; + +use crate::Session; + +const C: &str = "addon.cleanup.releaseAll"; + +fn session() -> Session { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + s +} + +fn id_of(v: &Value) -> NodeId { + NodeId(v["id"].as_u64().unwrap()) +} + +fn rect(s: &mut Session, x: f64, y: f64) -> NodeId { + id_of(&s.execute("shape.rectangle", &json!({"x": x, "y": y, "width": 20, "height": 20})).unwrap()) +} + +fn node(s: &Session, id: NodeId) -> Option { + s.doc().unwrap().doc.node(id).cloned() +} + +fn change(s: &mut Session, id: NodeId, f: impl FnOnce(&mut Node)) { + s.edit("t", |d, _| { + f(d.node_mut(id).unwrap()); + Ok(()) + }) + .unwrap(); +} + +fn select(s: &mut Session, ids: &[NodeId]) { + s.select(|_, sel| sel.set(ids.iter().copied())).unwrap(); +} + +fn selected(s: &Session) -> Vec { + s.doc().unwrap().selection.objects.to_vec() +} + +fn undo_steps(s: &Session) -> usize { + s.doc().unwrap().history.undo.len() +} + +/// The objects directly in layer `k`. +fn layer(s: &Session, k: usize) -> Vec { + s.doc().unwrap().doc.layers[k].children().unwrap().iter().map(|n| n.id).collect() +} + +fn group(s: &mut Session, ids: &[NodeId]) -> NodeId { + select(s, ids); + id_of(&s.execute("object.group", &json!({})).unwrap()) +} + +fn compound(s: &mut Session, ids: &[NodeId]) -> NodeId { + select(s, ids); + id_of(&s.execute("object.compoundPath.make", &json!({})).unwrap()) +} + +/// A clipping group of `ids`, the last of them the clipping path. +fn clip_group(s: &mut Session, ids: &[NodeId]) -> NodeId { + select(s, ids); + id_of(&s.execute("object.clippingMask.make", &json!({})).unwrap()) +} + +fn counts(r: &Value) -> (u64, u64, u64) { + (r["groups"].as_u64().unwrap(), r["clipGroups"].as_u64().unwrap(), r["compoundPaths"].as_u64().unwrap()) +} + +fn plain(s: &Session, id: NodeId) -> bool { + matches!(node(s, id).unwrap().kind, NodeKind::Path { clipping: false, ref path, .. } if path.subpaths.len() == 1) +} + +fn red() -> Appearance { + Appearance::basic(Paint::solid(Color::rgb(1.0, 0.0, 0.0)), Paint::None, 1.0) +} + +#[test] +fn release_all_takes_apart_every_level_as_one_step() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let p = rect(&mut s, 70.0, 10.0); + let q = rect(&mut s, 75.0, 15.0); + let holes = compound(&mut s, &[p, q]); + change(&mut s, holes, |n| n.appearance = red().into()); + let inner = group(&mut s, &[b, holes]); + change(&mut s, inner, |n| n.opacity = 0.5); + let clipped = rect(&mut s, 110.0, 10.0); + let clip = rect(&mut s, 105.0, 5.0); + let masked = clip_group(&mut s, &[clipped, clip]); + let outer = group(&mut s, &[a, inner, masked]); + select(&mut s, &[outer]); + let steps = undo_steps(&s); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!(counts(&r), (2, 1, 1), "{r}"); + assert_eq!(r["scope"], "selection"); + assert_eq!(undo_steps(&s), steps + 1, "one undo step"); + assert_eq!(s.doc().unwrap().history.undo.last().unwrap().label, "Release All Containers"); + assert_eq!(layer(&s, 0), [a, b, p, q, clip, clipped], "only paths are left, in their stacking order"); + assert!([a, b, p, q, clip, clipped].iter().all(|id| plain(&s, *id)), "the clipping path is a plain path"); + assert!(node(&s, outer).is_none() && node(&s, inner).is_none() && node(&s, holes).is_none() && node(&s, masked).is_none()); + assert_eq!((node(&s, b).unwrap().opacity, node(&s, p).unwrap().opacity), (0.5, 0.5), "members keep their groups' opacity"); + assert_eq!(*node(&s, q).unwrap().appearance, red(), "a compound path's paths take its paint"); + assert_eq!(selected(&s), [a, b, p, q, clip, clipped], "what the selected group left is selected"); + assert_eq!(r["ids"], json!([a.0, b.0, p.0, q.0, clip.0, clipped.0])); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(layer(&s, 0), [outer]); +} + +#[test] +fn release_all_counts_each_object_left_once() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let c = rect(&mut s, 70.0, 10.0); + let p = rect(&mut s, 100.0, 10.0); + let second = node(&s, p).unwrap().path_data().unwrap().subpaths[0].clone(); + change(&mut s, p, |n| { + if let NodeKind::Path { path, .. } = &mut n.kind { + path.subpaths.push(second); + } + }); + let inner = group(&mut s, &[a, b, c, p]); + change(&mut s, inner, |n| n.set_clips(true)); + let middle = group(&mut s, &[inner]); + let outer = group(&mut s, &[middle]); + let held = std::collections::HashSet::new(); + for clips in [true, false] { + let mut d = (*s.doc().unwrap().doc).clone(); + let n = d.node_arc(outer).unwrap().clone(); + let mut run = super::Release { + kinds: super::Kinds { groups: true, clips, compounds: true }, + named: false, + held: &held, + counts: [0; 3], + made: 0, + left: std::collections::HashMap::new(), + }; + let mut out = vec![]; + run.node(&mut d, n, false, &mut out).unwrap(); + if clips { + assert_eq!(out.len(), 5); + assert_eq!(run.made, out.len(), "each path is counted once"); + } else { + assert_eq!(out.len(), 1); + let children = out[0].children().unwrap(); + assert_eq!(children.len(), 5); + assert_eq!(run.made, out.len() + children.len(), "the kept group and its paths are counted once"); + } + } +} + +#[test] +fn release_all_takes_only_the_kinds_asked_for() { + let mut s = session(); + let p = rect(&mut s, 10.0, 10.0); + let q = rect(&mut s, 15.0, 15.0); + let holes = compound(&mut s, &[p, q]); + let clipped = rect(&mut s, 110.0, 10.0); + let e = rect(&mut s, 105.0, 5.0); + let f = rect(&mut s, 108.0, 8.0); + let clip = compound(&mut s, &[e, f]); + let masked = clip_group(&mut s, &[clipped, clip]); + let outer = group(&mut s, &[holes, masked]); + // Without groups, the group stays and what is inside it is still released, but for the + // clipping path of the clipping group that stays. + select(&mut s, &[outer]); + let r = s.execute(C, &json!({"groups": false, "clipGroups": false})).unwrap(); + assert_eq!(counts(&r), (0, 0, 1), "{r}"); + let d = &s.doc().unwrap().doc; + assert_eq!(d.parent_of(p), Some(outer)); + assert!(d.node(holes).is_none() && d.node(clip).is_some() && d.node(masked).is_some()); + assert_eq!(selected(&s), [outer]); + // Without compound paths, the groups go and the compound path stays. + let r = s.execute(C, &json!({"compoundPaths": false})).unwrap(); + assert_eq!(counts(&r), (1, 1, 0), "{r}"); + assert_eq!(layer(&s, 0), [p, q, clip, clipped]); + assert!(matches!(node(&s, clip).unwrap().kind, NodeKind::Compound { .. })); + // Then only compound paths: the clipping path's paths, unpainted as it was. + select(&mut s, &[clip]); + let r = s.execute(C, &json!({"groups": false, "clipGroups": false})).unwrap(); + assert_eq!(counts(&r), (0, 0, 1), "{r}"); + assert_eq!(layer(&s, 0), [p, q, e, f, clipped]); +} + +#[test] +fn release_all_splits_paths_of_several_subpaths() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let second = node(&s, b).unwrap().path_data().unwrap().subpaths[0].clone(); + change(&mut s, a, |n| { + if let NodeKind::Path { path, .. } = &mut n.kind { + path.subpaths.push(second); + } + }); + s.edit("t", |d, _| Ok(d.remove_many(&[b])?)).unwrap(); + select(&mut s, &[a]); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!(counts(&r), (0, 0, 1), "{r}"); + let left = layer(&s, 0); + assert_eq!(left.len(), 2); + assert_eq!(left[0], a, "the first subpath keeps the path's id"); + assert!(left.iter().all(|id| plain(&s, *id))); + assert_eq!(selected(&s), left); + assert_eq!(node(&s, left[1]).unwrap().appearance, node(&s, a).unwrap().appearance, "each part keeps the path's paint"); +} + +#[test] +fn release_all_keeps_a_path_of_several_subpaths_with_live_corners_whole() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let plain_path = rect(&mut s, 80.0, 10.0); + let second = node(&s, b).unwrap().path_data().unwrap().subpaths[0].clone(); + for id in [a, plain_path] { + let second = second.clone(); + change(&mut s, id, |n| { + if let NodeKind::Path { path, live, .. } = &mut n.kind { + path.subpaths.push(second); + *live = None; + } + }); + } + change(&mut s, a, |n| { + if let NodeKind::Path { path, live, .. } = &mut n.kind { + let base = path.clone(); + *live = Some(Box::new(LiveShape::Path { base, radii: vec![4.0], kinds: vec![], radii_relative: false })); + } + }); + s.edit("t", |d, _| Ok(d.remove_many(&[b])?)).unwrap(); + select(&mut s, &[a, plain_path]); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!(counts(&r), (0, 0, 1), "only the plain path is split: {r}"); + let kept = node(&s, a).unwrap(); + assert!(matches!(kept.kind, NodeKind::Path { live: Some(_), ref path, .. } if path.subpaths.len() == 2), "Live Corners stay"); + assert_eq!(layer(&s, 0).len(), 3); +} + +#[test] +fn release_all_runs_on_the_document_while_nothing_is_selected() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let c = rect(&mut s, 70.0, 10.0); + let e = rect(&mut s, 100.0, 10.0); + let plain_group = group(&mut s, &[a]); + let locked = group(&mut s, &[b]); + change(&mut s, locked, |n| n.locked = true); + let hidden = group(&mut s, &[c]); + change(&mut s, hidden, |n| n.visible = false); + // A second layer that clips its art by its first path. + let second = id_of(&s.execute("layer.new", &json!({})).unwrap()); + let mask = rect(&mut s, 0.0, 100.0); + let art = rect(&mut s, 10.0, 110.0); + let art_group = group(&mut s, &[art]); + s.edit("t", |d, _| { + let layer = d.node_mut(second).unwrap(); + layer.set_clips(true); + if let Some(NodeKind::Path { clipping, .. }) = layer.children_mut().unwrap().first_mut().map(|c| &mut std::sync::Arc::make_mut(c).kind) { + *clipping = true; + } + Ok(()) + }) + .unwrap(); + select(&mut s, &[]); + assert!(s.execute(C, &json!({"scope": "selection"})).is_err(), "nothing selected"); + let steps = undo_steps(&s); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!(r["scope"], "document"); + assert_eq!(counts(&r), (2, 1, 0), "{r}"); + assert_eq!(undo_steps(&s), steps + 1); + assert_eq!(layer(&s, 0), [a, locked, hidden, e], "locked and hidden groups stay whole"); + assert!(node(&s, plain_group).is_none() && node(&s, art_group).is_none()); + let d = &s.doc().unwrap().doc; + assert!(!d.node(second).unwrap().clips(), "the layer stays and stops clipping"); + assert!(plain(&s, mask), "its clipping path is a plain path"); + assert_eq!(layer(&s, 1), [mask, art]); + assert!(selected(&s).is_empty(), "nothing was selected"); + // Asked for the document with a selection, the selection keeps what it held. + let g = group(&mut s, &[e]); + select(&mut s, &[g]); + let r = s.execute(C, &json!({"scope": "document"})).unwrap(); + assert_eq!(counts(&r), (1, 0, 0), "{r}"); + assert_eq!(selected(&s), [e]); +} + +#[test] +fn release_all_takes_named_locked_and_hidden_containers() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let locked = group(&mut s, &[a]); + change(&mut s, locked, |n| n.locked = true); + let hidden = group(&mut s, &[b]); + change(&mut s, hidden, |n| n.visible = false); + select(&mut s, &[locked, hidden]); + let steps = undo_steps(&s); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!((counts(&r), undo_steps(&s)), ((0, 0, 0), steps), "from the selection, they stay whole"); + let r = s.execute(C, &json!({"ids": [locked.0, hidden.0]})).unwrap(); + assert_eq!(r["scope"], "ids"); + assert_eq!(counts(&r), (2, 0, 0), "{r}"); + assert_eq!(undo_steps(&s), steps + 1); + let (na, nb) = (node(&s, a).unwrap(), node(&s, b).unwrap()); + assert!(na.locked && na.visible && !nb.visible && !nb.locked, "their objects become locked or hidden as they were"); + assert!(selected(&s).is_empty(), "locked and hidden objects are not selected"); + // On a locked artboard, a named group stays whole. + let c = rect(&mut s, 10.0, 200.0); + let on_board = group(&mut s, &[c]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let steps = undo_steps(&s); + let r = s.execute(C, &json!({"ids": [on_board.0]})).unwrap(); + assert_eq!((counts(&r), undo_steps(&s)), ((0, 0, 0), steps)); + assert!(node(&s, on_board).is_some()); + // Nor does one inside a named layer. + let layer_id = s.doc().unwrap().doc.layers[0].id; + let r = s.execute(C, &json!({"ids": [layer_id.0]})).unwrap(); + assert_eq!((counts(&r), undo_steps(&s)), ((0, 0, 0), steps)); +} + +#[test] +fn release_all_leaves_masked_groups_whole_and_changes_nothing_without_a_container() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 15.0, 15.0); + let held = group(&mut s, &[a, b]); + let m = rect(&mut s, 0.0, 0.0); + s.execute("transparency.makeOpacityMask", &json!({"ids": [held.0, m.0]})).unwrap(); + let masked = layer(&s, 0)[0]; + assert!(node(&s, masked).unwrap().extras().mask.is_some()); + let c = rect(&mut s, 100.0, 10.0); + select(&mut s, &[masked, c]); + let steps = undo_steps(&s); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!((counts(&r), undo_steps(&s)), ((0, 0, 0), steps), "no step when nothing is released"); + assert_eq!(r["ids"], json!([masked.0, c.0]), "the selection stays"); + assert_eq!(layer(&s, 0), [masked, c]); + // A compound shape is a group that stays whole too. + let e = rect(&mut s, 200.0, 10.0); + let f = rect(&mut s, 210.0, 15.0); + select(&mut s, &[e, f]); + s.execute("object.compoundShape.make", &json!({})).unwrap(); + let shape = selected(&s)[0]; + assert!(node(&s, shape).unwrap().is_compound_shape()); + let steps = undo_steps(&s); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!((counts(&r), undo_steps(&s)), ((0, 0, 0), steps)); + assert!(node(&s, shape).unwrap().is_compound_shape()); +} + +#[test] +fn release_all_leaves_a_picked_clipping_path_of_a_clipping_group_that_stays() { + let mut s = session(); + let clipped = rect(&mut s, 10.0, 10.0); + let e = rect(&mut s, 5.0, 5.0); + let f = rect(&mut s, 8.0, 8.0); + let clip = compound(&mut s, &[e, f]); + let masked = clip_group(&mut s, &[clipped, clip]); + let steps = undo_steps(&s); + for p in [json!({"ids": [clip.0]}), json!({"ids": [clip.0], "clipGroups": false})] { + let r = s.execute(C, &p).unwrap(); + assert_eq!((counts(&r), undo_steps(&s)), ((0, 0, 0), steps), "{p}"); + } + select(&mut s, &[clip]); + let r = s.execute(C, &json!({})).unwrap(); + assert_eq!((counts(&r), undo_steps(&s)), ((0, 0, 0), steps)); + let d = &s.doc().unwrap().doc; + assert_eq!(d.parent_of(clip), Some(masked)); + assert!(matches!(d.node(clip).unwrap().kind, NodeKind::Compound { .. })); +} + +#[test] +fn release_all_keeps_a_directly_named_descendant_of_a_live_object() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let inner = group(&mut s, &[a]); + let sources = group(&mut s, &[inner]); + change(&mut s, sources, |n| n.name = Some("Live Paint Sources".into())); + let live = group(&mut s, &[sources]); + change(&mut s, live, |n| n.name = Some("Live Paint Group".into())); + change(&mut s, sources, |n| n.visible = false); + assert!(vectorcraft_tools::builder::is_live_paint(&node(&s, live).unwrap())); + let steps = undo_steps(&s); + for id in [sources, inner] { + let r = s.execute(C, &json!({"ids": [id.0]})).unwrap(); + assert_eq!((counts(&r), undo_steps(&s)), ((0, 0, 0), steps)); + assert!(vectorcraft_tools::builder::is_live_paint(&node(&s, live).unwrap())); + assert_eq!(s.doc().unwrap().doc.parent_of(inner), Some(sources)); + assert_eq!(s.doc().unwrap().doc.parent_of(a), Some(inner)); + } +} + +#[test] +fn release_all_keeps_appearance_effects_and_directly_targeted_descendants() { + for item in [None, Some(0), Some(1)] { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 15.0, 15.0); + let inner = compound(&mut s, &[a, b]); + let c = rect(&mut s, 20.0, 20.0); + select(&mut s, &[inner, c]); + let applied = s.execute("effect.apply", &json!({"effect": "pathfinder.add"})).unwrap(); + assert_eq!(applied["grouped"], true); + let live = selected(&s)[0]; + assert!(matches!(node(&s, live).unwrap().kind, NodeKind::Group { clip: false, .. })); + assert!(!node(&s, live).unwrap().is_compound_shape()); + assert_eq!(node(&s, live).unwrap().appearance.effects[0].id, "pathfinder.add"); + if let Some(item) = item { + change(&mut s, live, |n| { + let effects = n.appearance.effects.clone(); + *n.appearance = red(); + *n.appearance.effects_mut(Some(item)).unwrap() = effects; + }); + } + let before = s.doc().unwrap().doc.clone(); + let steps = undo_steps(&s); + for (target, params) in [ + (live, json!({})), + (live, json!({"scope": "document"})), + (live, json!({"ids": [live.0]})), + (inner, json!({})), + (inner, json!({"ids": [inner.0]})), + ] { + select(&mut s, &[target]); + let r = s.execute(C, ¶ms).unwrap(); + assert_eq!(counts(&r), (0, 0, 0), "{item:?}: {params}: {r}"); + assert!(std::sync::Arc::ptr_eq(&before, &s.doc().unwrap().doc)); + assert_eq!(selected(&s), [target]); + assert_eq!(undo_steps(&s), steps); + assert_eq!(s.doc().unwrap().doc.parent_of(inner), Some(live)); + assert_eq!(s.doc().unwrap().doc.parent_of(a), Some(inner)); + } + } +} + +#[test] +fn release_all_keeps_a_layer_mask_over_locked_artboard_artwork() { + for named in [false, true] { + let mut s = session(); + let mask = rect(&mut s, 0.0, 0.0); + let art = rect(&mut s, 10.0, 10.0); + let outside = rect(&mut s, 500.0, 10.0); + let g = group(&mut s, &[outside]); + let layer_id = s.doc().unwrap().doc.layers[0].id; + change(&mut s, layer_id, |n| n.set_clips(true)); + change(&mut s, mask, |n| { + if let NodeKind::Path { clipping, .. } = &mut n.kind { + *clipping = true; + } + }); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let p = if named { json!({"ids": [layer_id.0]}) } else { json!({"scope": "document"}) }; + let r = s.execute(C, &p).unwrap(); + assert_eq!(counts(&r), (1, 0, 0), "{p}: {r}"); + assert!(node(&s, layer_id).unwrap().clips()); + assert!(matches!(node(&s, mask).unwrap().kind, NodeKind::Path { clipping: true, .. })); + assert_eq!(layer(&s, 0), [mask, art, outside]); + assert!(node(&s, g).is_none()); + } +} + +#[test] +fn release_all_keeps_a_layer_mask_that_alone_overlaps_a_locked_artboard() { + for named in [false, true] { + let mut s = session(); + let mask = rect(&mut s, 0.0, 0.0); + let outside = rect(&mut s, 500.0, 10.0); + let g = group(&mut s, &[outside]); + let layer_id = s.doc().unwrap().doc.layers[0].id; + change(&mut s, layer_id, |n| n.set_clips(true)); + change(&mut s, mask, |n| { + if let NodeKind::Path { clipping, .. } = &mut n.kind { + *clipping = true; + } + }); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let original_mask = s.doc().unwrap().doc.node_arc(mask).unwrap().clone(); + let steps = undo_steps(&s); + let p = if named { json!({"ids": [layer_id.0]}) } else { json!({"scope": "document"}) }; + let r = s.execute(C, &p).unwrap(); + assert_eq!(counts(&r), (1, 0, 0), "{p}: {r}"); + assert_eq!(undo_steps(&s), steps + 1); + assert!(node(&s, layer_id).unwrap().clips()); + assert!(matches!(node(&s, mask).unwrap().kind, NodeKind::Path { clipping: true, .. })); + assert!(std::sync::Arc::ptr_eq(&original_mask, s.doc().unwrap().doc.node_arc(mask).unwrap())); + assert_eq!(layer(&s, 0), [mask, outside]); + assert!(node(&s, g).is_none()); + } +} + +#[test] +fn release_all_keeps_a_clipping_group_whose_clipped_art_overlaps_a_locked_artboard() { + let mut s = session(); + let art = rect(&mut s, 10.0, 10.0); + let mask = rect(&mut s, 500.0, 10.0); + let g = clip_group(&mut s, &[art, mask]); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let r = s.execute(C, &json!({"scope": "document"})).unwrap(); + assert_eq!(counts(&r), (0, 0, 0), "{r}"); + assert_eq!(s.doc().unwrap().doc.parent_of(art), Some(g)); + assert!(node(&s, g).unwrap().clips()); +} + +#[test] +fn release_all_keeps_a_named_group_in_a_clipping_group_over_a_locked_artboard() { + let mut s = session(); + let art = rect(&mut s, 10.0, 10.0); + let other = rect(&mut s, 40.0, 10.0); + let inner = group(&mut s, &[art, other]); + let mask = rect(&mut s, 500.0, 10.0); + let g = clip_group(&mut s, &[inner, mask]); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let r = s.execute(C, &json!({"ids": [inner.0]})).unwrap(); + assert_eq!(counts(&r), (0, 0, 0), "{r}"); + assert_eq!(s.doc().unwrap().doc.parent_of(art), Some(inner)); + assert_eq!(s.doc().unwrap().doc.parent_of(inner), Some(g)); +} + +#[test] +fn release_all_takes_apart_a_named_hidden_clipping_group_with_visible_art() { + let mut s = session(); + let art = rect(&mut s, 10.0, 10.0); + let mask = rect(&mut s, 500.0, 10.0); + let g = clip_group(&mut s, &[art, mask]); + change(&mut s, g, |n| n.visible = false); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let r = s.execute(C, &json!({"ids": [g.0]})).unwrap(); + assert_eq!(counts(&r), (0, 1, 0), "{r}"); + assert!(node(&s, g).is_none()); + assert!(!node(&s, art).unwrap().visible); +} + +#[test] +fn release_all_takes_apart_a_clipping_group_in_a_named_hidden_group() { + let mut s = session(); + let art = rect(&mut s, 10.0, 10.0); + let mask = rect(&mut s, 500.0, 10.0); + let g = clip_group(&mut s, &[art, mask]); + let other = rect(&mut s, 40.0, 10.0); + let outer = group(&mut s, &[g, other]); + change(&mut s, outer, |n| n.visible = false); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let r = s.execute(C, &json!({"ids": [outer.0]})).unwrap(); + assert_eq!(counts(&r), (1, 1, 0), "{r}"); + assert!(node(&s, g).is_none()); +} + +#[test] +fn release_all_ignores_hidden_clipped_art_over_a_locked_artboard() { + let mut s = session(); + let hidden = rect(&mut s, 10.0, 10.0); + let shown = rect(&mut s, 600.0, 10.0); + let inner = group(&mut s, &[hidden, shown]); + change(&mut s, hidden, |n| n.visible = false); + let mask = rect(&mut s, 500.0, 10.0); + let g = clip_group(&mut s, &[inner, mask]); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let r = s.execute(C, &json!({"scope": "document"})).unwrap(); + assert_eq!(counts(&r), (1, 1, 0), "{r}"); + assert!(node(&s, g).is_none()); + assert!(!node(&s, hidden).unwrap().visible); +} + +#[test] +fn release_all_keeps_a_clipping_group_whose_group_stroke_reaches_a_locked_artboard() { + let mut s = session(); + let a = rect(&mut s, 600.0, 10.0); + let b = rect(&mut s, 640.0, 10.0); + let inner = group(&mut s, &[a, b]); + change(&mut s, inner, |n| n.appearance = Appearance::basic(Paint::None, Paint::solid(Color::rgb(0.0, 0.0, 0.0)), 500.0).into()); + let mask = rect(&mut s, 500.0, 10.0); + let g = clip_group(&mut s, &[inner, mask]); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let r = s.execute(C, &json!({"scope": "document"})).unwrap(); + assert_eq!(counts(&r), (0, 0, 0), "{r}"); + assert_eq!(s.doc().unwrap().doc.parent_of(inner), Some(g)); +} + +#[test] +fn release_all_ungroups_off_artboard_groups_in_a_kept_clipping_group() { + let mut s = session(); + let a = rect(&mut s, 600.0, 10.0); + let b = rect(&mut s, 640.0, 10.0); + let inner = group(&mut s, &[a, b]); + let on = rect(&mut s, 10.0, 10.0); + let mask = rect(&mut s, 500.0, 10.0); + let g = clip_group(&mut s, &[inner, on, mask]); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let r = s.execute(C, &json!({"scope": "document", "clipGroups": false})).unwrap(); + assert_eq!(counts(&r), (1, 0, 0), "{r}"); + assert!(node(&s, inner).is_none()); + assert_eq!(s.doc().unwrap().doc.parent_of(a), Some(g)); +} + +#[test] +fn release_all_takes_apart_pattern_editing_art_over_a_locked_artboard() { + let mut s = session(); + let art = rect(&mut s, 10.0, 10.0); + let mask = rect(&mut s, 500.0, 10.0); + let g = clip_group(&mut s, &[art, mask]); + select(&mut s, &[]); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + let layer = d.layers[0].id; + d.pattern_edit = Some(vectorcraft_doc::PatternEdit { pattern: "Checks".into(), layer, original: None }); + Ok(()) + }) + .unwrap(); + let r = s.execute(C, &json!({"scope": "document"})).unwrap(); + assert_eq!(counts(&r), (0, 1, 0), "{r}"); + assert!(node(&s, g).is_none()); +} + +#[test] +fn release_all_keeps_a_group_with_its_own_fill_or_stroke() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let g = group(&mut s, &[a, b]); + change(&mut s, g, |n| n.appearance = red().into()); + let r = s.execute(C, &json!({"scope": "document"})).unwrap(); + assert_eq!(counts(&r), (0, 0, 0), "{r}"); + assert_eq!(s.doc().unwrap().doc.parent_of(a), Some(g)); + assert_eq!(*node(&s, g).unwrap().appearance, red()); +} + +#[test] +fn release_all_reuses_unchanged_siblings_when_rebuilding_a_layer() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let g = group(&mut s, &[b]); + let original = s.doc().unwrap().doc.node_arc(a).unwrap().clone(); + let r = s.execute(C, &json!({"scope": "document"})).unwrap(); + assert_eq!(counts(&r), (1, 0, 0)); + assert!(node(&s, g).is_none()); + assert!(std::sync::Arc::ptr_eq(&original, s.doc().unwrap().doc.node_arc(a).unwrap())); +} + +#[test] +fn release_all_keeps_selection_details_for_untouched_artwork() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let c = rect(&mut s, 70.0, 10.0); + let g = group(&mut s, &[c]); + s.execute("guide.add", &json!({"vertical": true, "pos": 150})).unwrap(); + let guide = s.doc().unwrap().doc.ruler_guides()[0].id.unwrap(); + s.select(|_, sel| { + sel.set([a, b, g]); + sel.anchors.insert(a, [(0, 0), (0, 2)].into_iter().collect()); + sel.anchors.insert(b, [(0, 0), (0, 1)].into_iter().collect()); + sel.segments.insert(b, [(0, 0)].into_iter().collect()); + sel.guides.push(guide); + sel.key_anchor = Some((a, (0, 0))); + }) + .unwrap(); + let before = s.doc().unwrap().selection.clone(); + let r = s.execute(C, &json!({"scope": "document"})).unwrap(); + assert_eq!(counts(&r), (1, 0, 0)); + let after = &s.doc().unwrap().selection; + assert_eq!(after.objects, [a, b, c]); + assert_eq!(after.anchors, before.anchors); + assert_eq!(after.segments, before.segments); + assert_eq!(after.guides, before.guides); + assert_eq!(after.key_anchor, before.key_anchor); + assert!(!after.objects.contains(&g)); + change(&mut s, c, |n| { + if let NodeKind::Path { path, live, .. } = &mut n.kind { + path.subpaths.push(path.subpaths[0].clone()); + *live = None; + } + }); + s.select(|_, sel| { + sel.anchors.insert(c, [(0, 0), (0, 1)].into_iter().collect()); + sel.segments.insert(c, [(0, 0)].into_iter().collect()); + }) + .unwrap(); + let r = s.execute(C, &json!({"ids": [c.0]})).unwrap(); + assert_eq!(counts(&r), (0, 0, 1)); + let after = &s.doc().unwrap().selection; + assert_eq!(after.anchors, before.anchors); + assert_eq!(after.segments, before.segments); + assert_eq!(after.guides, before.guides); +} + +#[test] +fn release_all_keeps_a_directly_named_blend_key() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let b = rect(&mut s, 40.0, 10.0); + let key = group(&mut s, &[a, b]); + let c = rect(&mut s, 100.0, 10.0); + select(&mut s, &[key, c]); + let blend = id_of(&s.execute("object.blend.make", &json!({})).unwrap()); + assert_eq!(s.doc().unwrap().doc.parent_of(key), Some(blend)); + let before = s.doc().unwrap().doc.clone(); + let selection = selected(&s); + let steps = undo_steps(&s); + let r = s.execute(C, &json!({"ids": [key.0]})).unwrap(); + assert_eq!(counts(&r), (0, 0, 0)); + assert!(std::sync::Arc::ptr_eq(&before, &s.doc().unwrap().doc)); + assert_eq!(selected(&s), selection); + assert_eq!(undo_steps(&s), steps); +} + +#[test] +fn release_all_keeps_a_direct_target_inside_a_compound_clipping_mask() { + for clipping_layer in [false, true] { + let mut s = session(); + let art = rect(&mut s, 10.0, 10.0); + let a = rect(&mut s, 5.0, 5.0); + let b = rect(&mut s, 8.0, 8.0); + change(&mut s, a, |n| { + if let NodeKind::Path { path, live, .. } = &mut n.kind { + path.subpaths.push(path.subpaths[0].clone()); + *live = None; + } + }); + let mask = compound(&mut s, &[a, b]); + let container = if clipping_layer { + let id = s.doc().unwrap().doc.layers[0].id; + change(&mut s, id, |n| { + n.children_mut().unwrap().swap(0, 1); + n.set_clips(true); + }); + id + } else { + clip_group(&mut s, &[art, mask]) + }; + assert_eq!(node(&s, container).unwrap().children().unwrap()[0].id, mask); + let before = s.doc().unwrap().doc.clone(); + let steps = undo_steps(&s); + for named in [false, true] { + select(&mut s, &[a]); + let p = if named { json!({"ids": [a.0]}) } else { json!({"clipGroups": false}) }; + let r = s.execute(C, &p).unwrap(); + assert_eq!(counts(&r), (0, 0, 0), "{p}"); + assert!(std::sync::Arc::ptr_eq(&before, &s.doc().unwrap().doc)); + assert_eq!(selected(&s), [a]); + assert_eq!(undo_steps(&s), steps); + } + } +} + +#[test] +fn release_all_rejects_null_options_without_editing_artwork() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let g = group(&mut s, &[a]); + for selection in [vec![], vec![g]] { + select(&mut s, &selection); + let before = s.doc().unwrap().doc.clone(); + let steps = undo_steps(&s); + for key in ["scope", "groups", "clipGroups", "compoundPaths"] { + let mut p = json!({}); + p[key] = Value::Null; + let error = s.execute(C, &p).unwrap_err(); + assert!(matches!(error, crate::EngineError::BadParams { ref cmd, .. } if cmd == C), "{p}: {error}"); + assert!(std::sync::Arc::ptr_eq(&before, &s.doc().unwrap().doc)); + assert_eq!(selected(&s), selection); + assert_eq!(undo_steps(&s), steps); + } + } +} + +#[test] +fn release_all_rejects_duplicate_ids_before_traversal() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let g = group(&mut s, &[a]); + let b = rect(&mut s, 50.0, 10.0); + select(&mut s, &[g]); + let before = s.doc().unwrap().doc.clone(); + let steps = undo_steps(&s); + for ids in [vec![g.0, g.0], vec![b.0, b.0], vec![g.0, a.0, a.0]] { + let error = s.execute(C, &json!({"ids": ids})).unwrap_err(); + assert!(matches!(error, crate::EngineError::BadParams { ref cmd, ref msg } if cmd == C && msg.contains("duplicate")), "{error}"); + assert!(std::sync::Arc::ptr_eq(&before, &s.doc().unwrap().doc)); + assert_eq!(selected(&s), [g]); + assert_eq!(undo_steps(&s), steps); + } +} + +#[test] +fn release_all_refuses_bad_params() { + let mut s = session(); + let a = rect(&mut s, 10.0, 10.0); + let g = group(&mut s, &[a]); + select(&mut s, &[g]); + let steps = undo_steps(&s); + for bad in [ + json!({"groups": false, "clipGroups": false, "compoundPaths": false}), + json!({"groups": "yes"}), + json!({"compoundPaths": 1}), + json!({"scope": "layer"}), + json!({"scope": "document", "ids": [g.0]}), + json!({"ids": [999_999]}), + ] { + assert!(s.execute(C, &bad).is_err(), "{bad}"); + } + assert_eq!(undo_steps(&s), steps); + assert!(node(&s, g).is_some()); +} diff --git a/crates/engine/src/cmd/compositefonts.rs b/crates/engine/src/cmd/compositefonts.rs index 54c1db0f41..3b15730f9a 100644 --- a/crates/engine/src/cmd/compositefonts.rs +++ b/crates/engine/src/cmd/compositefonts.rs @@ -99,12 +99,19 @@ fn family_names(d: &Document) -> Result> { note(family); } } - let mut graphs = Vec::new(); + let (mut graphs, mut dimensions) = (Vec::new(), Vec::new()); view.visit_stored(|node, _| { + // A dimension's options name the family its label is redrawn in. + if let Some(dimension) = &node.extras().dimension { + dimensions.push(dimension.options.font_family.clone()); + } if node.extras().graph.is_some() { graphs.push(node.id); } }); + for mut family in dimensions { + note(&mut family); + } for id in graphs { if let Some(node) = view.stored_node_mut(id) { graph_families(node, &mut note); @@ -112,6 +119,9 @@ fn family_names(d: &Document) -> Result> { } fn brush_graphs(node: &mut Node, note: &mut impl FnMut(&mut String)) { graph_families(node, note); + if let Some(dimension) = node.extras_if_any().and_then(|extras| extras.dimension.as_mut()) { + note(&mut dimension.options.font_family); + } if let Some(mask) = node.extras_if_any().and_then(|extras| extras.mask.as_mut()) { brush_graphs(Arc::make_mut(&mut mask.art), note); } @@ -145,9 +155,15 @@ pub(super) fn node_families(node: &mut Node, visit: &mut impl FnMut(&mut String) visit(&mut font.family); } } - // A live dimension makes its label again from its options. - if let Some(dimension) = node.extras_if_any().and_then(|extras| extras.dimension.as_deref_mut()) { - visit(&mut dimension.options.font_family); + // A dimension redraws its label from its own options, so they follow the label's family. + // A spelling that already names the same font, or one too long for the options, is kept. + if let Some(dimension) = node.extras_if_any().and_then(|extras| extras.dimension.as_mut()) { + let family = &mut dimension.options.font_family; + let mut renamed = family.clone(); + visit(&mut renamed); + if !CompositeFont::same_name(&renamed, family) && renamed.len() <= ALIAS_BYTES_MAX { + *family = renamed; + } } graph_families(node, visit); } @@ -170,12 +186,22 @@ impl CompositeImport { } } +/// The longest family name in bytes that a dimension's options keep (`DimensionOptions::validate`). +const ALIAS_BYTES_MAX: usize = 256; + fn composite_alias(base: &str, reserved: &BTreeSet, cmd: &str) -> Result { let db = FontDb::global(); let mut number = 2_u64; loop { let suffix = format!(" {number}"); - let stem: String = base.chars().take(COMPOSITE_NAME_MAX.saturating_sub(suffix.chars().count())).collect(); + let bytes = ALIAS_BYTES_MAX.saturating_sub(suffix.len()); + let mut stem = String::new(); + for c in base.chars().take(COMPOSITE_NAME_MAX.saturating_sub(suffix.chars().count())) { + if stem.len() + c.len_utf8() > bytes { + break; + } + stem.push(c); + } let name = format!("{}{suffix}", stem.trim_end()); if CompositeFont::clean_name(&name).as_deref() == Some(name.as_str()) && !reserved.contains(&name.to_lowercase()) @@ -189,7 +215,13 @@ fn composite_alias(base: &str, reserved: &BTreeSet, cmd: &str) -> Result /// Plan used incoming definitions before changing either document or the font database. /// Keep existing meanings even for an uninstalled family that destination art still names. -pub(super) fn plan_import(source: Vec, source_families: BTreeSet, target: &Document, cmd: &str) -> Result { +pub(super) fn plan_import( + source: Vec, + source_families: BTreeSet, + dimension_families: BTreeSet, + target: &Document, + cmd: &str, +) -> Result { if source.len() > COMPOSITE_FONTS_MAX || target.composite_fonts.len() > COMPOSITE_FONTS_MAX { return Err(bad(cmd, format!("a document keeps at most {COMPOSITE_FONTS_MAX} composite fonts"))); } @@ -230,12 +262,15 @@ pub(super) fn plan_import(source: Vec, source_families: BTreeSet< let mut names = BTreeMap::new(); let mut combined = target.composite_fonts.to_vec(); for font in source { - let equivalent = |other: &&CompositeFont| other.parts == font.parts && other.custom == font.custom; - let mut reused = CompositeFont::named(&target.composite_fonts, &font.name).filter(equivalent); + let dimension = dimension_families.contains(&font.name.to_lowercase()); + let equal = |other: &&CompositeFont| other.parts == font.parts && other.custom == font.custom; + // A dimension keeps its own spelling of a reused name of the same font, so only an alias + // under another name has to fit the bytes its options keep. + let mut reused = CompositeFont::named(&target.composite_fonts, &font.name).filter(equal); let needs_alias = reused.is_none() && (target_taken.contains(&font.name.to_lowercase()) || db.has_installed_family(&font.name)); if needs_alias { // A repeated import reuses its already-installed equal alias. - reused = target.composite_fonts.iter().find(equivalent); + reused = target.composite_fonts.iter().find(|other| equal(other) && (!dimension || other.name.len() <= ALIAS_BYTES_MAX)); } let name = match reused { Some(other) => other.name.clone(), diff --git a/crates/engine/src/cmd/fileio.rs b/crates/engine/src/cmd/fileio.rs index 1a24bf623b..9e67ab1916 100644 --- a/crates/engine/src/cmd/fileio.rs +++ b/crates/engine/src/cmd/fileio.rs @@ -117,8 +117,8 @@ pub use save::{ }; pub(crate) use screens::{ PARAM_KEYS as SCREEN_PARAM_KEYS, ROW_KEYS as SCREEN_ROW_KEYS, UNWRITTEN_FORMATS as SCREEN_UNWRITTEN_FORMATS, - check_settings as check_screen_settings, export as export_screens, safe_file_name, store_settings as store_screen_settings, - with_export_preset as with_screen_export_preset, + check_settings as check_screen_settings, export as export_screens, safe_file_name, sharing_names as sharing_screen_names, + store_settings as store_screen_settings, with_export_preset as with_screen_export_preset, }; pub use screens::{ PRESET_FILE_EXTS as SCREEN_EXPORT_PRESET_EXTS, PRESET_FILE_FORMAT as SCREEN_EXPORT_PRESET_FORMAT, PRESET_KEYS as SCREEN_EXPORT_PRESET_KEYS, @@ -184,7 +184,7 @@ pub use formats::{ DOC_EXTS, DOCX_EXTS, FORMATS, Format, FormatOption, OPEN_EXTS, PLACE_EXTS, RTF_EXTS, TEXT_EXTS, UNASSOCIATED_EXTS, builtin_open_filters, export_extensions, extension, file_stem, format, format_for_name, has_own_title, importer_formats, library_open_filters, open_extensions, open_filters, opens_as_other, opens_with_importer, place_dialog_filters, place_filters, places_with_importer, plugin_formats, read_extensions, - readable_format, readable_format_for_name, titled_for_export, writable_format, + readable_format, readable_format_for_name, reads_as_dwg, titled_for_export, writable_format, }; #[cfg(test)] diff --git a/crates/engine/src/cmd/fileio/batch.rs b/crates/engine/src/cmd/fileio/batch.rs index dcb26b94b5..821c74acb0 100644 --- a/crates/engine/src/cmd/fileio/batch.rs +++ b/crates/engine/src/cmd/fileio/batch.rs @@ -28,6 +28,7 @@ pub(super) fn batch(s: &mut Session, p: &Value) -> Result { // file, format and saved state share their data with the open ones until a step changes them. let start = s.docs.clone(); let active = s.active; + let style_trail = s.script_in_run.then(|| s.script_style_trail.clone()); // A rollback puts back the swatch renames recorded before the batch, including any its steps pushed out of the record. let swatch_renames = s.swatch_renames.clone(); let opens = s.plugin_events_mark(); @@ -46,6 +47,10 @@ pub(super) fn batch(s: &mut Session, p: &Value) -> Result { Err(e) => { s.swatch_renames = swatch_renames; roll_back(s, start, &stash); + if let Some(mut trail) = style_trail { + trail.resources_scanned = s.script_style_trail.resources_scanned; + s.script_style_trail = trail; + } // The documents the steps opened are closed again: plug-ins are not told of them. s.forget_plugin_opens_since(opens); s.notify_text_tool("batch.rollBack"); diff --git a/crates/engine/src/cmd/fileio/commands.rs b/crates/engine/src/cmd/fileio/commands.rs index c35ad702f4..0d7cfd03c7 100644 --- a/crates/engine/src/cmd/fileio/commands.rs +++ b/crates/engine/src/cmd/fileio/commands.rs @@ -36,7 +36,7 @@ pub fn specs() -> Vec { "Export Document", [], None, - "{path?, format?: svg|svgz|pdf|ai|png|jpg|webp|gif|png8|txt|dxf|eps|emf|wmf|hpgl|tiff|bmp|tga|psd|cmx|vectorcraft|template (default: from the path's extension, else png; png8 writes an indexed .png; ait, a .ait template, is written by file.saveAsTemplate; an exporter plug-in's format is plugin., which an extension only it lists picks too), params?: {…} (an exporter plug-in's parameters; missing ones take their defaults, see plugin.info), selectedOnly?: false (the selected objects alone, in the layers and groups that hold them; an object of a blend, envelope, repeat or intertwine on its own), includeArtboardFill?: true (raster, PDF, SVG and EPS draw each exported artboard's background color behind its art, a transparent background too; false leaves it out), artboard?: 0, artboards?: [i…], rect?: [x, y, width, height] (raster formats: that area of the page in points, y down, instead of an artboard; not with artboard, artboards, range or useArtboards), range?: \"1-3, 5\" | \"all\" (1-based; PDF and .ai write one page per artboard, default all; SVG writes one file per artboard, {stem}-{artboard}.svg; raster formats write one artboard), useArtboards?: true (raster: one file per chosen artboard, default all, {stem}-{artboard}.{ext}; pdf/ai: every page) | false (pdf/ai/raster: the bounds of the visible art; pdf/ai: of the layers the file draws, without editing data, with a warning, and ai refuses pdfCompatible: false; SVG has it as an SVG option), ppi?: number (raster formats: pixels per inch, stored in the file; wins over scale; without either, the document's raster effects resolution), scale?: number (pixels per point), background?: transparent|white|black|\"#rrggbb\" (jpg: white when transparent; #rrggbbaa and #rgba are refused here and in matte), antiAlias?: none|art (default)|type (text snapped to pixels), interlaced?: false (png, Adam7), embedIcc?: true (png: an sRGB chunk marks the colours as sRGB), quality?: 90 (jpg: 0–100), colorModel?: rgb|cmyk|gray (jpg), method?: baseline|optimized|progressive, scans?: 3 (3–5, progressive), embedIcc?: true, imageMap?: none|client|server (an HTML or NCSA map of the objects with a URL, written as .html / .map), colors?: 256 (gif/png8: 2–256), reduction?: perceptual|selective (default)|adaptive|web|blackWhite|gray, dither?: none|diffusion (default)|pattern|noise, ditherAmount?: 100, transparency?: true, transparencyDither?: none (default: pixels under half opacity become transparent)|diffusion|pattern|noise (with transparency: as document.exportForWeb), transparencyDitherAmount?: 100 (0–100: the diffusion transparency dither's strength), matte?: white|\"#rrggbb\"|none, interlaced?, lossless?: true (webp: every pixel kept exactly; false writes lossy WebP, a smaller file that loses some detail), quality?: 90 (webp with lossless: false: 0–100, higher keeps more detail in a larger file; more than 100 is refused), encoding?: utf8|utf16 (txt: the stories in stacking order, back to front, a thread once; utf16 with a byte order mark), lineEndings?: lf|crlf, selectionOnly?: false, svg?: {styling, outlineText, images, objectIds, decimals, minify, responsive, units, useArtboards, preserveEditing, metadata, fewerTspans, hiddenLayers, encoding, profile, embedFonts, variableData} (see document.formats), …the SVG options given flat instead, …the PDF options of document.exportPdf, …the DXF options of document.exportDxf (useArtboards: one drawing per artboard), …the EPS options of document.exportEps (useArtboards: one file per artboard, {stem}_{artboard}.eps, after a central {stem}.eps of the whole document when there are two or more and art shows; else the visible art), …emf and wmf write one picture of the artboard (useArtboards: true one file per chosen artboard, false the bounds of the visible art; EMF keeps curves, clipping, transparent images and gradients as images clipped to their shape; WMF flattens curves into polygons behind a placeable header; what a format leaves out comes back in warnings), …hpgl writes a plot of the artboard as pen moves for plotters and cutters (each visible path once along its line in plotter units; useArtboards: true one file per chosen artboard, false the bounds of the art it plots, without placed images, unpainted paths and art at 0% opacity), hpglVersion?: hpgl (default: IN, SP, PU, PD) | hpgl2 (also NP and PC pen colors, each pen's paths as one encoded polyline PE), curveTolerance?: 0.1 (points, 0.01 to 10), pens?: [\"#rrggbb\"…] (pen 1 first, up to 255; each path takes the nearest; default a pen per color in the order the art first draws in it, numbered alike in every file), origin?: bottomLeft (default) | center, sortPaths?: false (each pen's next path the nearest), insideFirst?: false (a path after the pen's paths that lie inside it), …cmx writes one file with a page for the artboard (useArtboards: true a page for each chosen artboard, false the bounds of the visible art; a layer for each layer with art on the page, holding the art's fills and strokes as curves in their colors: CMYK, RGB, gray, spot colors at their tints, Registration; type as outlines, gradients and patterns as one color, nonzero fills as even-odd, dashes in whole stroke widths, no miter limit, art across a page's edge written whole, without images, clipping masks or transparency; warnings name each of these losses), colorModel?: rgb|cmyk|gray (tiff: rgb keeps transparency as an alpha channel), lzw?: true, byteOrder?: little|big, embedIcc?: true, colorModel?: rgb|gray (bmp), depth?: 24 (bmp: 1 black and white, 4|8 a palette by reduction and dither, 16, 24, 32 with alpha), fileFormat?: windows|os2 (1, 4, 8 or 24 bits), rle?: false (4 and 8 bits, windows), flipRows?: false (top-down rows), depth?: 24 (tga: 16 one-bit alpha, 24, 32 with alpha), colorModel?: rgb|cmyk|gray (psd), layers?: true (each top-level layer a pixel layer with its opacity and blend mode; a background colour is a Background layer; false: one flat image, on white), preserveText?: false (with layers: horizontal and vertical point type in solid colors, with left-to-right paragraphs that set only their alignment, without strokes, effects or an appearance of its own, becomes editable type layers with their pixels; a layer holding it becomes a group, unless other art in it blends in a mode other than normal; refused with layers: false), maxEditability?: false (layers and sublayers become groups, each object a layer named as in the Layers panel, text by its text; clipping, masked or knockout layers stay one layer), hiddenLayers?: false (hidden layers and objects written hidden instead of left out), embedIcc?: true (at most 30000 pixels a side; formats without alpha are flattened on white)} → {path, format, bytes, warnings, files?: [path…] (several), linked?: [path…] (linked images, image maps)}; no path → {dataBase64, format, bytes, warnings, files?: [{name, dataBase64}], linked?: [{name, dataBase64}]}. A key no format takes, and an unknown key inside a PDF or EPS option's object, are refused; a key only another format takes is not used, and warnings name it. Under automation read roots, svg and svgz, and the files that carry the native document (vectorcraft, template, eps, ai of every artboard with useArtboards not false but a version 7 file, pdf of every artboard with preserveEditing on and useArtboards not false), are refused, before any file is written, while the document links a JavaScript file outside them (svgInteractivity; a URL is not checked), or while the file would name a linked image's file outside them (images: link, preserveEditing, or an image whose pixels the document doesn't hold; a URL is not checked). Never changes the document's path", + "{path?, format?: svg|svgz|pdf|ai|png|jpg|webp|gif|png8|txt|dxf|eps|emf|wmf|hpgl|tiff|bmp|tga|psd|cmx|vectorcraft|template (default: from the path's extension, else png; png8 writes an indexed .png; ait, a .ait template, is written by file.saveAsTemplate; an exporter plug-in's format is plugin., which an extension only it lists picks too), params?: {…} (an exporter plug-in's parameters; missing ones take their defaults, see plugin.info), selectedOnly?: false (the selected objects alone, in the layers and groups that hold them; an object of a blend, envelope, repeat or intertwine on its own), includeArtboardFill?: true (raster, PDF, SVG and EPS draw each exported artboard's background color behind its art, a transparent background too; false leaves it out), artboard?: 0, artboards?: [i…], rect?: [x, y, width, height] (raster formats: that area of the page in points, y down, instead of an artboard; not with artboard, artboards, range or useArtboards), range?: \"1-3, 5\" | \"all\" (1-based; PDF and .ai write one page per artboard, default all; SVG writes one file per artboard, {stem}-{artboard}.svg; raster formats write one artboard), useArtboards?: true (raster: one file per chosen artboard, default all, {stem}-{artboard}.{ext}; pdf/ai: every page) | false (pdf/ai/raster: the bounds of the visible art; pdf/ai: of the layers the file draws, without editing data, with a warning, and ai refuses pdfCompatible: false; SVG has it as an SVG option), ppi?: number (raster formats: pixels per inch, stored in the file; wins over scale; without either, the document's raster effects resolution), scale?: number (pixels per point), background?: transparent|white|black|\"#rrggbb\" (jpg: white when transparent; #rrggbbaa and #rgba are refused here and in matte), antiAlias?: none|art (default)|type (text snapped to pixels), interlaced?: false (png, Adam7), embedIcc?: true (png: an sRGB chunk marks the colours as sRGB), quality?: 90 (jpg: 0–100), colorModel?: rgb|cmyk|gray (jpg), method?: baseline|optimized|progressive, scans?: 3 (3–5, progressive), embedIcc?: true, imageMap?: none|client|server (an HTML or NCSA map of the objects with a URL, written as .html / .map), colors?: 256 (gif/png8: 2–256), reduction?: perceptual|selective (default)|adaptive|web|blackWhite|gray, dither?: none|diffusion (default)|pattern|noise, ditherAmount?: 100, transparency?: true, transparencyDither?: none (default: pixels under half opacity become transparent)|diffusion|pattern|noise (with transparency: as document.exportForWeb), transparencyDitherAmount?: 100 (0–100: the diffusion transparency dither's strength), matte?: white|\"#rrggbb\"|none, interlaced?, lossless?: true (webp: every pixel kept exactly; false writes lossy WebP, a smaller file that loses some detail), quality?: 90 (webp with lossless: false: 0–100, higher keeps more detail in a larger file; more than 100 is refused), embedIcc?: true (webp: the sRGB profile in an ICCP chunk), encoding?: utf8|utf16 (txt: the stories in stacking order, back to front, a thread once; utf16 with a byte order mark), lineEndings?: lf|crlf, selectionOnly?: false, svg?: {styling, outlineText, images, objectIds, decimals, minify, responsive, units, useArtboards, preserveEditing, metadata, fewerTspans, hiddenLayers, encoding, profile, embedFonts, variableData} (see document.formats), …the SVG options given flat instead, …the PDF options of document.exportPdf, …the DXF options of document.exportDxf (useArtboards: one drawing per artboard), …the EPS options of document.exportEps (useArtboards: one file per artboard, {stem}_{artboard}.eps, after a central {stem}.eps of the whole document when there are two or more and art shows; else the visible art), …emf and wmf write one picture of the artboard (useArtboards: true one file per chosen artboard, false the bounds of the visible art; EMF keeps curves, clipping, transparent images and gradients as images clipped to their shape; WMF flattens curves into polygons behind a placeable header; what a format leaves out comes back in warnings), …hpgl writes a plot of the artboard as pen moves for plotters and cutters (each visible path once along its line in plotter units; useArtboards: true one file per chosen artboard, false the bounds of the art it plots, without placed images, unpainted paths and art at 0% opacity), hpglVersion?: hpgl (default: IN, SP, PU, PD) | hpgl2 (also NP and PC pen colors, each pen's paths as one encoded polyline PE), curveTolerance?: 0.1 (points, 0.01 to 10), pens?: [\"#rrggbb\"…] (pen 1 first, up to 255; each path takes the nearest; default a pen per color in the order the art first draws in it, numbered alike in every file), origin?: bottomLeft (default) | center, sortPaths?: false (each pen's next path the nearest), insideFirst?: false (a path after the pen's paths that lie inside it), …cmx writes one file with a page for the artboard (useArtboards: true a page for each chosen artboard, false the bounds of the visible art; a layer for each layer with art on the page, holding the art's fills and strokes as curves in their colors: CMYK, RGB, gray, spot colors at their tints, Registration; type as outlines, gradients and patterns as one color, nonzero fills as even-odd, dashes in whole stroke widths, no miter limit, art across a page's edge written whole, without images, clipping masks or transparency; warnings name each of these losses), colorModel?: rgb|cmyk|gray (tiff: rgb keeps transparency as an alpha channel), lzw?: true, byteOrder?: little|big, embedIcc?: true, colorModel?: rgb|gray (bmp), depth?: 24 (bmp: 1 black and white, 4|8 a palette by reduction and dither, 16, 24, 32 with alpha), fileFormat?: windows|os2 (1, 4, 8 or 24 bits), rle?: false (4 and 8 bits, windows), flipRows?: false (top-down rows), depth?: 24 (tga: 16 one-bit alpha, 24, 32 with alpha), colorModel?: rgb|cmyk|gray (psd), layers?: true (each top-level layer a pixel layer with its opacity and blend mode; a background colour is a Background layer; false: one flat image, on white), preserveText?: false (with layers: horizontal and vertical point type in solid colors, with left-to-right paragraphs that set only their alignment, without strokes, effects or an appearance of its own, becomes editable type layers with their pixels; a layer holding it becomes a group, unless other art in it blends in a mode other than normal; refused with layers: false), maxEditability?: false (layers and sublayers become groups, each object a layer named as in the Layers panel, text by its text; clipping, masked or knockout layers stay one layer), hiddenLayers?: false (hidden layers and objects written hidden instead of left out), embedIcc?: true (at most 30000 pixels a side; formats without alpha are flattened on white)} → {path, format, bytes, warnings, files?: [path…] (several), linked?: [path…] (linked images, image maps)}; no path → {dataBase64, format, bytes, warnings, files?: [{name, dataBase64}], linked?: [{name, dataBase64}]}. A key no format takes, and an unknown key inside a PDF or EPS option's object, are refused; a key only another format takes is not used, and warnings name it. Under automation read roots, svg and svgz, and the files that carry the native document (vectorcraft, template, eps, ai of every artboard with useArtboards not false but a version 7 file, pdf of every artboard with preserveEditing on and useArtboards not false), are refused, before any file is written, while the document links a JavaScript file outside them (svgInteractivity; a URL is not checked), or while the file would name a linked image's file outside them (images: link, preserveEditing, or an image whose pixels the document doesn't hold; a URL is not checked). Never changes the document's path", has_doc, export::export ), @@ -54,7 +54,7 @@ pub fn specs() -> Vec { "Export for Screens", ["File", "Export"], None, - "{folder?, zip?: false (one .zip of every file, each deflated or stored, whichever is smaller: no folder → {name, dataBase64, bytes, files: [name…]}; with a folder it is written there → {path, bytes, files}), artboard?: index | artboards?: [index…] | range?: \"1-3\" (default all), assets?: [asset id…] (instead of artboards: each asset's art alone, cropped to its bounds and named after the asset; see assets.list), layers?: [layer id…] (instead of artboards: each layer's art alone, sublayers included, named after the layer), selection?: one|each (instead of artboards: the selected art as one file, or a file per selected object, named after it), fullDocument?: false (one file per format instead: a PDF of every artboard, other formats the bounds of all visible art, named after the document), includeBleed?: false (artboards grown by the document's bleed; a PDF page keeps the artboard as its TrimBox and puts its row's bleed around it once, the document's bleed when the row sets none and its preset gives none or 0; a native, .ai or EPS file of an artboard holds the grown artboard with a bleed of 0), includeArtboardFill?: true (Include Artboard Fill: each artboard's background color behind its art; false leaves it out), pdfs?: multiple|single (Export PDFs As: with several artboards, single writes them as the pages of one PDF per PDF row, named after the document; refused with assets, layers or selection: each), exportPreset?: (a preset of document.exportPresets.list: its settings, under these params), subfolders?: false (each row's files in a sub-folder: its folder, else its size for raster (1x, 2x, 100w…) or its format (SVG, PDF)), folders?: none|rows (as subfolders)|format (a folder per extension: png, svg, pdf…)|item (a folder per artboard, asset, layer or object)|itemFormat (item/extension) (default: rows with subfolders or a preset, else none), name?: (a file name pattern instead of the item's name, with for the document, for the artboard, asset, layer or object, from 1, #### for the counter zero-padded to the run of #, , , (else the row's suffix ends the name), YYYYMMDD, YYYY-MM-DD, YYYY, ,