mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 19:51:26 -05:00
Merge main into fix/style-and-gallery-previews-keep-canvas-clear
Takes main's craft-libs rev 4f3e34d0dd. Character Style Options and Paragraph Style Options canvas support and their two tests move to #10953, which waits on storytold/craft-libs#5510.
This commit is contained in:
Generated
+91
-91
@@ -1256,7 +1256,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-automation",
|
||||
"craft-behavior",
|
||||
@@ -1298,7 +1298,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-affinity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
@@ -1319,7 +1319,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-appkit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"objc2 0.6.5",
|
||||
@@ -1331,7 +1331,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-atomic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"rustix 1.1.6",
|
||||
]
|
||||
@@ -1339,7 +1339,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-automation"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -1364,7 +1364,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-behavior"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"bitflags 2.13.2",
|
||||
@@ -1383,7 +1383,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-browse"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-docpath",
|
||||
@@ -1401,7 +1401,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cdr"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
@@ -1410,7 +1410,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cloud-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"egui",
|
||||
]
|
||||
@@ -1418,7 +1418,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-cms"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"md-5",
|
||||
"rayon",
|
||||
@@ -1427,12 +1427,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-codepage"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
|
||||
[[package]]
|
||||
name = "craft-color-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-cms",
|
||||
@@ -1452,7 +1452,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-ai-agents",
|
||||
"craft-atomic",
|
||||
@@ -1468,7 +1468,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-control-protocol"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"serde_json",
|
||||
@@ -1478,7 +1478,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dds"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
@@ -1486,7 +1486,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dialogs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"block2 0.6.2",
|
||||
"craft-appkit",
|
||||
@@ -1512,7 +1512,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-doc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"craft-ecproj-format",
|
||||
@@ -1528,7 +1528,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-docpath"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1536,7 +1536,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-draw"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1555,7 +1555,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dwg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"acadrust",
|
||||
"craft-dxf",
|
||||
@@ -1565,7 +1565,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-dxf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-codepage",
|
||||
"encoding_rs",
|
||||
@@ -1577,7 +1577,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ecproj-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1587,12 +1587,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-eps"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
|
||||
[[package]]
|
||||
name = "craft-flags"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"dirs",
|
||||
@@ -1602,7 +1602,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-catalog"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"fontique",
|
||||
"harfrust 0.13.3",
|
||||
@@ -1617,7 +1617,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-manager"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
@@ -1636,7 +1636,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-os-windows"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"windows-registry",
|
||||
"windows-sys 0.61.2",
|
||||
@@ -1645,7 +1645,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-font-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"cap-primitives",
|
||||
"craft-atomic",
|
||||
@@ -1668,12 +1668,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-fonts-build"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
|
||||
[[package]]
|
||||
name = "craft-gif"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"gif",
|
||||
]
|
||||
@@ -1681,7 +1681,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-gzip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
]
|
||||
@@ -1689,7 +1689,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-host"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-i18n",
|
||||
@@ -1702,7 +1702,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-i18n"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"brotli 9.1.3",
|
||||
"brotli-decompressor 6.3.2",
|
||||
@@ -1732,7 +1732,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-image-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-dds",
|
||||
"craft-jpeg",
|
||||
@@ -1759,7 +1759,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-imaging"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-color-ui",
|
||||
@@ -1777,7 +1777,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jpeg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -1785,7 +1785,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-jxl"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"brotli-decompressor 5.0.3",
|
||||
"jixel",
|
||||
@@ -1796,7 +1796,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-keymap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-host",
|
||||
"craft-i18n",
|
||||
@@ -1811,7 +1811,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-i18n",
|
||||
@@ -1825,7 +1825,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-menu"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1843,7 +1843,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metadata"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"brotli-decompressor 6.3.2",
|
||||
"chrono",
|
||||
@@ -1855,7 +1855,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-metafile"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"image",
|
||||
@@ -1866,7 +1866,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-mime"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"craft-codepage",
|
||||
@@ -1876,7 +1876,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-nightly"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"uds_windows",
|
||||
"winsafe",
|
||||
@@ -1885,7 +1885,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pages"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -1901,7 +1901,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pbr"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-texture",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1910,7 +1910,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pcraft-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"serde",
|
||||
@@ -1921,7 +1921,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-pdf"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"hayro-interpret",
|
||||
"hayro-syntax",
|
||||
@@ -1933,7 +1933,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-platform"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-io",
|
||||
@@ -1966,7 +1966,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-plotter"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"kurbo 0.13.1",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1975,7 +1975,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-print"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -1999,7 +1999,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-proof"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"log",
|
||||
"miniz_oxide 0.9.1",
|
||||
@@ -2010,7 +2010,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ps"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-eps",
|
||||
"flate2",
|
||||
@@ -2024,7 +2024,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-psd"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"flate2",
|
||||
@@ -2035,7 +2035,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-quit"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"dispatch2",
|
||||
"egui",
|
||||
@@ -2048,7 +2048,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-raster3d"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2057,7 +2057,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-review"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"craft-behavior",
|
||||
@@ -2076,7 +2076,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-settings"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-host",
|
||||
@@ -2093,7 +2093,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-stream-codecs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"fax",
|
||||
"hayro-ccitt",
|
||||
@@ -2104,7 +2104,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-svg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-image-codecs",
|
||||
"craft-xml",
|
||||
@@ -2125,7 +2125,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-table"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2137,7 +2137,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-text"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-manager",
|
||||
@@ -2162,7 +2162,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-texture"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
@@ -2170,7 +2170,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"craft-tracked",
|
||||
@@ -2185,7 +2185,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-theme-store"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-behavior",
|
||||
@@ -2200,7 +2200,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tiff"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2210,7 +2210,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-time"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
@@ -2219,7 +2219,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-timeline"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-keymap",
|
||||
@@ -2234,12 +2234,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-tracked"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-cloud-ui",
|
||||
"craft-ui-canvas",
|
||||
@@ -2253,7 +2253,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-canvas"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-catalog",
|
||||
@@ -2270,7 +2270,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-contract"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"craft-behavior",
|
||||
@@ -2308,7 +2308,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2319,7 +2319,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-panels"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2337,7 +2337,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-patterns"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2358,7 +2358,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-shell"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2379,7 +2379,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-ui-widgets"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-host",
|
||||
@@ -2398,7 +2398,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-update"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
@@ -2430,7 +2430,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-vectorcraft-format"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"serde",
|
||||
@@ -2441,7 +2441,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-wayland"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"raw-window-handle",
|
||||
"wayland-backend",
|
||||
@@ -2451,7 +2451,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-web-api"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde_json",
|
||||
@@ -2462,7 +2462,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-win32"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"winsafe",
|
||||
]
|
||||
@@ -2470,7 +2470,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-window"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"craft-appkit",
|
||||
"craft-atomic",
|
||||
@@ -2502,7 +2502,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"serde",
|
||||
@@ -3862,7 +3862,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
|
||||
[[package]]
|
||||
name = "hayro-cmap"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"brotli 8.0.4",
|
||||
"hayro-postscript",
|
||||
@@ -3871,7 +3871,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-interpret"
|
||||
version = "0.7.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"hayro-cmap",
|
||||
@@ -3889,7 +3889,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-jbig2"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"fearless_simd",
|
||||
"hayro-ccitt",
|
||||
@@ -3907,12 +3907,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "hayro-postscript"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
|
||||
[[package]]
|
||||
name = "hayro-syntax"
|
||||
version = "0.7.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hayro-ccitt",
|
||||
@@ -4895,7 +4895,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "krilla"
|
||||
version = "0.8.2"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bumpalo",
|
||||
@@ -5052,7 +5052,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
|
||||
[[package]]
|
||||
name = "linesweeper"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=dfd876669dd3d64f0061ab510a94b866a1ae35ab#dfd876669dd3d64f0061ab510a94b866a1ae35ab"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da#4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"kurbo 0.13.1",
|
||||
|
||||
+41
-41
@@ -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 = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab", default-features = false, features = ["interpret", "write"] }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da", default-features = false, features = ["interpret", "write"] }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# Language packs: the Craft apps' shared font store installs them (#4936).
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# 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 = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile.
|
||||
craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab", features = ["pcraft-pixels"] }
|
||||
craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da", features = ["pcraft-pixels"] }
|
||||
# Native Affinity documents (craft-libs#914).
|
||||
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778).
|
||||
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# SVG parsing, limits, SVGZ and writer (craft-libs#778).
|
||||
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab", features = ["tree"] }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da", features = ["tree"] }
|
||||
craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# EPS container, previews, ASCII85 and DSC comments (craft-libs#778).
|
||||
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# DXF tags, reader and writer (craft-libs#778, #926, #927).
|
||||
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# 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 = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-dwg = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# WMF, EMF and EMF+ reader (craft-libs#778).
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab", default-features = false, features = ["read", "write"] }
|
||||
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da", default-features = false, features = ["read", "write"] }
|
||||
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# 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 = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-pbr = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# 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 = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-raster3d = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# 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 = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# 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 = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# Nightly profile isolation, launch protocol, and security fence.
|
||||
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# internal
|
||||
vectorcraft-geom = { path = "crates/geom" }
|
||||
vectorcraft-color = { path = "crates/color" }
|
||||
@@ -200,13 +200,13 @@ lto = "thin"
|
||||
codegen-units = 1
|
||||
|
||||
[patch.crates-io]
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "dfd876669dd3d64f0061ab510a94b866a1ae35ab" }
|
||||
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
krilla = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da" }
|
||||
# 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" }
|
||||
|
||||
@@ -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 = "dfd876669dd3d64f0061ab510a94b866a1ae35ab", version = "0.1.0" }
|
||||
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da", version = "0.1.0" }
|
||||
|
||||
wasm-bindgen = "0.2"
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -151,9 +151,9 @@ mod formats;
|
||||
pub(crate) use access::FILES_READ;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) use access::list_dir;
|
||||
pub(crate) use access::{READ_TOO_LARGE, check_images_in, check_scripts_of, with_read_limit, with_readable_settings_folder};
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
pub(crate) use access::{SCRIPT_OPEN_MAX_BYTES, SCRIPT_OPEN_TOO_LARGE};
|
||||
pub(crate) use access::{check_images_in, check_scripts_of, with_readable_settings_folder};
|
||||
pub use access::{check_linked_images, check_linked_scripts, write_file_with, write_save_file, write_save_file_with};
|
||||
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
|
||||
@@ -289,6 +289,31 @@ thread_local! {
|
||||
pub(crate) static FILES_READ: std::cell::RefCell<Vec<String>> = const { std::cell::RefCell::new(Vec::new()) };
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(super) fn regular_write_target(path: &str) -> Result<()> {
|
||||
if std::fs::metadata(path).is_ok_and(|m| !m.is_file()) {
|
||||
return Err(EngineError::Other(format!("{path}: not a file")));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static READ_LIMIT: std::cell::Cell<Option<usize>> = const { std::cell::Cell::new(None) };
|
||||
}
|
||||
|
||||
pub(crate) const READ_TOO_LARGE: &str = "File exceeds scoped read limit";
|
||||
|
||||
pub(crate) fn with_read_limit<T>(max: usize, f: impl FnOnce() -> T) -> T {
|
||||
struct Restore(Option<usize>);
|
||||
impl Drop for Restore {
|
||||
fn drop(&mut self) {
|
||||
READ_LIMIT.with(|limit| limit.set(self.0));
|
||||
}
|
||||
}
|
||||
let _restore = Restore(READ_LIMIT.with(|limit| limit.replace(Some(limit.get().map_or(max, |outer| outer.min(max))))));
|
||||
f()
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) fn read_file(path: &str) -> Result<Vec<u8>> {
|
||||
use std::io::Read;
|
||||
@@ -299,27 +324,35 @@ pub(crate) fn read_file(path: &str) -> Result<Vec<u8>> {
|
||||
if !std::fs::metadata(path).map_err(|e| EngineError::Other(format!("{path}: {e}")))?.is_file() {
|
||||
return Err(EngineError::Other(format!("{path}: not a file")));
|
||||
}
|
||||
if crate::file_access::in_script_command() {
|
||||
let max = SCRIPT_OPEN_MAX_BYTES;
|
||||
let read = || -> std::io::Result<Vec<u8>> {
|
||||
let file = std::fs::File::open(path)?;
|
||||
let meta = file.metadata()?;
|
||||
if !meta.is_file() {
|
||||
return Err(std::io::Error::other("not a file"));
|
||||
}
|
||||
if meta.len() > max as u64 {
|
||||
return Err(std::io::Error::other(SCRIPT_OPEN_TOO_LARGE));
|
||||
}
|
||||
let mut bytes = Vec::new();
|
||||
file.take(max as u64 + 1).read_to_end(&mut bytes)?;
|
||||
if bytes.len() > max {
|
||||
return Err(std::io::Error::other(SCRIPT_OPEN_TOO_LARGE));
|
||||
}
|
||||
Ok(bytes)
|
||||
};
|
||||
read().map_err(|e| EngineError::Other(format!("{path}: {e}")))
|
||||
} else {
|
||||
std::fs::read(path).map_err(|e| EngineError::Other(format!("{path}: {e}")))
|
||||
// A script command reads at most `SCRIPT_OPEN_MAX_BYTES`, and a scoped limit
|
||||
// (`with_read_limit`) at most its own count, whichever is smaller.
|
||||
let script = crate::file_access::in_script_command().then_some(SCRIPT_OPEN_MAX_BYTES);
|
||||
let scoped = READ_LIMIT.with(std::cell::Cell::get);
|
||||
let Some(cap) = [script, scoped].into_iter().flatten().min() else {
|
||||
return std::fs::read(path).map_err(|e| EngineError::Other(format!("{path}: {e}")));
|
||||
};
|
||||
let too_large = |bytes: u64| {
|
||||
if script.is_some_and(|max| bytes > max as u64) {
|
||||
Some(EngineError::Other(format!("{path}: {SCRIPT_OPEN_TOO_LARGE}")))
|
||||
} else if scoped.is_some_and(|max| bytes > max as u64) {
|
||||
Some(EngineError::Other(READ_TOO_LARGE.into()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
let file = std::fs::File::open(path).map_err(|e| EngineError::Other(format!("{path}: {e}")))?;
|
||||
let meta = file.metadata().map_err(|e| EngineError::Other(format!("{path}: {e}")))?;
|
||||
if !meta.is_file() {
|
||||
return Err(EngineError::Other(format!("{path}: not a file")));
|
||||
}
|
||||
if let Some(e) = too_large(meta.len()) {
|
||||
return Err(e);
|
||||
}
|
||||
let mut bytes = Vec::new();
|
||||
file.take(cap as u64 + 1).read_to_end(&mut bytes).map_err(|e| EngineError::Other(format!("{path}: {e}")))?;
|
||||
match too_large(bytes.len() as u64) {
|
||||
Some(e) => Err(e),
|
||||
None => Ok(bytes),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,6 +781,28 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::file_access::{AutomationRoots, confine};
|
||||
|
||||
#[test]
|
||||
fn scoped_read_limit_bounds_reads_and_restores_the_previous_limit() {
|
||||
let path = std::env::temp_dir().join(format!("vc-access-read-limit-{}", std::process::id()));
|
||||
std::fs::write(&path, b"12345").unwrap();
|
||||
let path_text = path.to_str().unwrap();
|
||||
assert_eq!(read_file(path_text).unwrap(), b"12345");
|
||||
with_read_limit(5, || {
|
||||
assert_eq!(read_file(path_text).unwrap(), b"12345");
|
||||
with_read_limit(4, || {
|
||||
assert_eq!(read_file(path_text).unwrap_err().to_string(), READ_TOO_LARGE);
|
||||
with_read_limit(6, || assert!(read_file(path_text).is_err()));
|
||||
});
|
||||
assert_eq!(read_file(path_text).unwrap(), b"12345");
|
||||
std::fs::write(&path, b"123456").unwrap();
|
||||
assert_eq!(read_file(path_text).unwrap_err().to_string(), READ_TOO_LARGE);
|
||||
});
|
||||
assert_eq!(read_file(path_text).unwrap(), b"123456");
|
||||
let _ = std::panic::catch_unwind(|| with_read_limit(0, || panic!("test unwind")));
|
||||
assert_eq!(read_file(path_text).unwrap(), b"123456");
|
||||
std::fs::remove_file(path).unwrap();
|
||||
}
|
||||
|
||||
/// An error about a path the client did not give, under roots that don't let it be read: the
|
||||
/// path is named by its file name (after a `/` or a `\`), or as [`UNNAMED`] when it ends in no
|
||||
/// name or its name is not valid text, and every root and the reason stay whole. A path inside the
|
||||
|
||||
@@ -45,9 +45,10 @@ pub(crate) fn unique_file_names_keeping_dots<'a>(names: impl IntoIterator<Item =
|
||||
}))
|
||||
}
|
||||
|
||||
/// `names` with `-2`, `-3`… after a name already used (compared without case).
|
||||
/// `names` with `-2`, `-3`… after a name already used (compared without case, as
|
||||
/// [`super::screens::fold`] compares them).
|
||||
pub(super) fn distinct_names(names: impl IntoIterator<Item = String>) -> Vec<String> {
|
||||
distinct_names_by(names, str::to_lowercase)
|
||||
distinct_names_by(names, super::screens::fold)
|
||||
}
|
||||
|
||||
/// `names` with `-2`, `-3`… after a name already used, two names matching when `key` gives the same
|
||||
@@ -93,6 +94,7 @@ pub(super) fn write_encoded(path: Option<&str>, name: &str, doc: &vectorcraft_do
|
||||
return Err(super::access::save_write_error(p, std::io::Error::from(std::io::ErrorKind::PermissionDenied)));
|
||||
}
|
||||
}
|
||||
distinct_write_targets(files.iter().map(|(p, _)| p.as_str()))?;
|
||||
}
|
||||
for (p, bytes) in &files {
|
||||
write_file(p, bytes)?;
|
||||
@@ -112,6 +114,62 @@ pub(super) fn write_encoded(path: Option<&str>, name: &str, doc: &vectorcraft_do
|
||||
Ok(merge(out, extra))
|
||||
}
|
||||
|
||||
/// An error when two of `paths` are the same file. A link that leads nowhere is compared by the file
|
||||
/// its write creates; another path whose real path cannot be found (a folder that may not be read)
|
||||
/// is compared as written, and its write then reports its own error. Two names in one folder that
|
||||
/// differ only in letter case are treated as the same file on every volume.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(super) fn distinct_write_targets<'a>(paths: impl IntoIterator<Item = &'a str>) -> Result<()> {
|
||||
let mut targets = std::collections::HashSet::new();
|
||||
for path in paths {
|
||||
let real = crate::file_access::resolve(path)
|
||||
.ok()
|
||||
.or_else(|| dangling_target(path))
|
||||
.or_else(|| std::path::absolute(path).ok())
|
||||
.unwrap_or_else(|| std::path::PathBuf::from(path));
|
||||
let key = match (real.parent(), real.file_name().and_then(|n| n.to_str())) {
|
||||
(Some(dir), Some(name)) => dir.join(super::screens::fold(name)),
|
||||
_ => real,
|
||||
};
|
||||
if !targets.insert(key) {
|
||||
return Err(EngineError::Other("output destinations resolve to the same file".into()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The file a write to `path` creates when `path` is a link (or a chain of at most 40 links) that
|
||||
/// leads to a file that does not exist yet.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn dangling_target(path: &str) -> Option<std::path::PathBuf> {
|
||||
let mut at = std::path::PathBuf::from(path);
|
||||
let mut followed = false;
|
||||
for _ in 0..40 {
|
||||
if !std::fs::symlink_metadata(&at).is_ok_and(|m| m.file_type().is_symlink()) {
|
||||
break;
|
||||
}
|
||||
let next = std::fs::read_link(&at).ok()?;
|
||||
at = match at.parent() {
|
||||
Some(parent) if next.is_relative() => parent.join(next),
|
||||
_ => next,
|
||||
};
|
||||
followed = true;
|
||||
}
|
||||
if !followed {
|
||||
return None;
|
||||
}
|
||||
// Resolved as the primary destination is; a name that is not UTF-8 keeps its bytes, with its
|
||||
// folder's links followed.
|
||||
match at.to_str() {
|
||||
Some(text) => crate::file_access::resolve(text).ok(),
|
||||
None => {
|
||||
let folder = std::fs::canonicalize(at.parent()?).ok()?;
|
||||
Some(folder.join(at.file_name()?))
|
||||
}
|
||||
}
|
||||
.or_else(|| std::path::absolute(&at).ok())
|
||||
}
|
||||
|
||||
/// `a` with the fields of `b`.
|
||||
pub(crate) fn merge(mut a: Value, b: Value) -> Value {
|
||||
if let (Some(a), Value::Object(b)) = (a.as_object_mut(), b) {
|
||||
@@ -143,3 +201,37 @@ pub(crate) fn write_or_return(path: Option<&str>, bytes: &[u8], extra: Value) ->
|
||||
};
|
||||
Ok(merge(out, extra))
|
||||
}
|
||||
|
||||
#[cfg(all(test, not(target_arch = "wasm32")))]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn folder(tag: &str) -> std::io::Result<std::path::PathBuf> {
|
||||
let d = std::env::temp_dir().join(format!("vc-export-names-{tag}-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
std::fs::create_dir_all(&d)?;
|
||||
Ok(d)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn names_differing_only_in_case_are_one_file() {
|
||||
let d = folder("case").unwrap();
|
||||
let s = |n: &str| d.join(n).to_str().unwrap().to_string();
|
||||
assert!(distinct_write_targets([s("a.svg").as_str(), s("A.svg").as_str()]).is_err());
|
||||
assert!(distinct_write_targets([s("ας.svg").as_str(), s("ΑΣ.svg").as_str()]).is_err(), "a final sigma");
|
||||
assert!(distinct_write_targets([s("S.svg").as_str(), s("ſ.svg").as_str()]).is_err(), "a long s");
|
||||
assert_eq!(distinct_names(["ας".to_string(), "ασ".to_string()]), ["ας", "ασ-2"]);
|
||||
assert!(distinct_write_targets([s("a.svg").as_str(), s("b.svg").as_str()]).is_ok());
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_dangling_link_to_a_case_variant_of_another_destination_is_the_same_file() {
|
||||
let d = folder("link").unwrap();
|
||||
std::os::unix::fs::symlink("A.svg", d.join("side.svg")).unwrap();
|
||||
let (a, side) = (d.join("a.svg"), d.join("side.svg"));
|
||||
assert!(distinct_write_targets([a.to_str().unwrap(), side.to_str().unwrap()]).is_err());
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -626,7 +626,7 @@ pub(crate) fn check_settings(s: &Session, p: &Value) -> Result<()> {
|
||||
/// same key, and so do `ΟΣ`, `ος` and `οσ` (`ΟΣ`); `ᾈ` and `ᾀ` give `ᾀ`, and `ß` stays `ß`.
|
||||
/// Dotless `ı` stays `ı`, as NTFS and Unicode case folding outside Turkic languages keep it apart
|
||||
/// from `i` and `I`.
|
||||
fn fold(name: &str) -> String {
|
||||
pub(super) fn fold(name: &str) -> String {
|
||||
name.to_lowercase()
|
||||
.chars()
|
||||
.map(|c| {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
||||
//! File → Print › Advanced, what needs the renderer and the flattener (the PDF writer does the
|
||||
//! rest): Print as Bitmap renders each printed region as one image, and a flattener preset
|
||||
//! rest): Print as Bitmap renders each printed region as one image (at `advanced.bitmapResolution`,
|
||||
//! or the document's raster effects resolution), and a flattener preset
|
||||
//! flattens transparency, both on the document as it prints (only the layers that print,
|
||||
//! overprints discarded or simulated in composite output) before it is laid out on paper.
|
||||
|
||||
@@ -31,7 +32,21 @@ pub(crate) fn flattener(cmd: &str, set: &PrintSettings, saved: &[FlattenerPreset
|
||||
/// `doc` as Print as Bitmap and the flattener preset of `set` print it (from `saved` presets), or
|
||||
/// `None` when neither applies. Print as Bitmap is for composite output.
|
||||
/// `rich_black`: Appearance of Black › Printing / Exporting › Output All Blacks as Rich Black.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn prepare(cmd: &str, doc: &Document, set: &PrintSettings, saved: &[FlattenerPreset], rich_black: bool) -> Result<Option<Document>> {
|
||||
prepare_noting(cmd, doc, set, saved, rich_black, &mut vec![])
|
||||
}
|
||||
|
||||
/// [`prepare`], with the note on an image Print as Bitmap prints below `advanced.bitmapResolution`
|
||||
/// added to `notes`.
|
||||
pub(crate) fn prepare_noting(
|
||||
cmd: &str,
|
||||
doc: &Document,
|
||||
set: &PrintSettings,
|
||||
saved: &[FlattenerPreset],
|
||||
rich_black: bool,
|
||||
notes: &mut Vec<String>,
|
||||
) -> Result<Option<Document>> {
|
||||
let composite = set.output.mode == OutputMode::Composite;
|
||||
let bitmap = set.advanced.print_as_bitmap && composite;
|
||||
let flattener = flattener(cmd, set, saved)?;
|
||||
@@ -40,7 +55,9 @@ pub(crate) fn prepare(cmd: &str, doc: &Document, set: &PrintSettings, saved: &[F
|
||||
}
|
||||
let printed = vectorcraft_pdf::printed_document(doc, set);
|
||||
if bitmap {
|
||||
return bitmap_document(cmd, &printed, set, rich_black).map(Some);
|
||||
let (out, lowest) = bitmap_document(cmd, &printed, set, rich_black)?;
|
||||
notes.extend(capped_note(set, lowest));
|
||||
return Ok(Some(out));
|
||||
}
|
||||
let Some(mut o) = flattener else { return Ok(None) };
|
||||
// Composite overprints that were discarded or simulated aren't preserved either.
|
||||
@@ -62,12 +79,81 @@ fn drop_guides(nodes: &mut Vec<Arc<Node>>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The resolution Print as Bitmap renders `doc` at with `set` (ppi): `advanced.bitmapResolution`,
|
||||
/// or the document's raster effects resolution when that is 0.
|
||||
fn bitmap_ppi(doc: &Document, set: &PrintSettings) -> f64 {
|
||||
let asked = set.advanced.bitmap_resolution;
|
||||
if asked > 0.0 { asked } else { doc.raster_effects_ppi }
|
||||
}
|
||||
|
||||
/// The pixels per document point Print as Bitmap renders `area` at so that it prints at `ppi` on
|
||||
/// paper when the page scales it by `placed` on each axis (1 = 100%): at most MAX_PIXELS, and
|
||||
/// no side longer than the renderer draws (rounded up to whole pixels when it renders).
|
||||
fn bitmap_scale(area: Rect, ppi: f64, placed: (f64, f64)) -> (f64, f64) {
|
||||
let (w, h) = (area.width() * ppi / 72.0 * placed.0, area.height() * ppi / 72.0 * placed.1);
|
||||
let longest = f64::from(vectorcraft_render::MAX_RASTER_SIDE) - 2.0;
|
||||
let limit = 1.0_f64.min((MAX_PIXELS / (w * h).max(1.0)).sqrt()).min(longest / w.max(1.0)).min(longest / h.max(1.0));
|
||||
let (w, h) = (w * limit, h * limit);
|
||||
let rounding = if whole_pixels(w) * whole_pixels(h) > MAX_PIXELS { ((MAX_PIXELS - w - h - 1.0) / (w * h)).sqrt() } else { 1.0 };
|
||||
(w * rounding / area.width(), h * rounding / area.height())
|
||||
}
|
||||
|
||||
/// The whole pixels Print as Bitmap renders `len` pixels of art as: rounded up, at least 1, with
|
||||
/// the rounding error of `len` scaled down and up again left out.
|
||||
fn whole_pixels(len: f64) -> f64 {
|
||||
(len - 1e-6).ceil().max(1.0)
|
||||
}
|
||||
|
||||
/// The horizontal and vertical scales (1 = 100%) the page prints the region `r` of `printed`
|
||||
/// at with `set`, both 1 when it prints on no page.
|
||||
fn placed_scale(printed: &Document, set: &PrintSettings, r: Rect) -> (f64, f64) {
|
||||
vectorcraft_pdf::print_region_scale(printed, set, r).filter(|(x, y)| x.is_finite() && *x > 0.0 && y.is_finite() && *y > 0.0).unwrap_or((1.0, 1.0))
|
||||
}
|
||||
|
||||
/// The note on Print as Bitmap printing below the `advanced.bitmapResolution` of `set`, when the
|
||||
/// `lowest` resolution (ppi) an image prints at is lower. None when the job leaves the resolution
|
||||
/// to the document.
|
||||
fn capped_note(set: &PrintSettings, lowest: Option<f64>) -> Option<String> {
|
||||
let asked = set.advanced.bitmap_resolution;
|
||||
let lowest = lowest.filter(|l| asked > 0.0 && l.is_finite() && *l < asked - 1e-6)?;
|
||||
Some(format!(
|
||||
"Print as Bitmap prints at {} ppi, not the {asked} ppi bitmapResolution asks for: a page prints as at most 64 million pixels and 32,768 pixels a side",
|
||||
lowest.floor()
|
||||
))
|
||||
}
|
||||
|
||||
/// What [`prepare`] notes on Print as Bitmap for `doc` printed with `set`, without rendering it,
|
||||
/// for the preview: a page with art that prints whose image the pixel limits keep below
|
||||
/// `advanced.bitmapResolution`. The art is judged by its bounds, so a page holding only art that
|
||||
/// draws nothing (fully transparent) is counted, while the print itself leaves its image out.
|
||||
pub(crate) fn bitmap_notes(cmd: &str, doc: &Document, set: &PrintSettings) -> Result<Vec<String>> {
|
||||
let asked = set.advanced.bitmap_resolution;
|
||||
if !(set.advanced.print_as_bitmap && set.output.mode == OutputMode::Composite && asked > 0.0) {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
let printed = vectorcraft_pdf::printed_document(doc, set);
|
||||
let regions = vectorcraft_pdf::print_regions(&printed, set).map_err(|e| pdf_error(cmd, e))?;
|
||||
let bleed = vectorcraft_pdf::page_bleed(&set.bleed, &printed);
|
||||
let lowest = regions
|
||||
.iter()
|
||||
.map(|(_, r)| (outset(*r, bleed), placed_scale(&printed, set, *r)))
|
||||
.filter(|(area, _)| vectorcraft_pdf::prints_art_in(&printed, *area))
|
||||
.map(|(area, placed)| {
|
||||
let (x, y) = bitmap_scale(area, asked, placed);
|
||||
(x / placed.0).min(y / placed.1) * 72.0
|
||||
})
|
||||
.reduce(f64::min);
|
||||
Ok(capped_note(set, lowest).into_iter().collect())
|
||||
}
|
||||
|
||||
/// `doc` (as it prints) with its art replaced by one image of each printed region (an artboard
|
||||
/// with its bleed, or all the art), at the document's raster effects resolution; regions where
|
||||
/// nothing is drawn get none.
|
||||
fn bitmap_document(cmd: &str, doc: &Document, set: &PrintSettings, rich_black: bool) -> Result<Document> {
|
||||
/// with its bleed, or all the art), at [`bitmap_ppi`] within [`bitmap_scale`]'s limits; regions
|
||||
/// where nothing is drawn get none. Also the lowest resolution an image prints at (ppi), `None`
|
||||
/// without images.
|
||||
fn bitmap_document(cmd: &str, doc: &Document, set: &PrintSettings, rich_black: bool) -> Result<(Document, Option<f64>)> {
|
||||
let regions = vectorcraft_pdf::print_regions(doc, set).map_err(|e| pdf_error(cmd, e))?;
|
||||
let bleed = vectorcraft_pdf::page_bleed(&set.bleed, doc);
|
||||
let ppi = bitmap_ppi(doc, set);
|
||||
let mut art = doc.clone();
|
||||
drop_guides(&mut art.layers);
|
||||
let anti_alias = if doc.raster_effects.anti_alias { AntiAlias::Art } else { AntiAlias::None };
|
||||
@@ -75,37 +161,34 @@ fn bitmap_document(cmd: &str, doc: &Document, set: &PrintSettings, rich_black: b
|
||||
let mut out = doc.clone();
|
||||
let mut renderer = vectorcraft_render::Renderer::new();
|
||||
let mut images = vec![];
|
||||
let mut lowest: Option<f64> = None;
|
||||
for (_, r) in regions {
|
||||
let area = outset(r, bleed);
|
||||
// At most MAX_PIXELS, and no side longer than the renderer draws (rounded up to whole
|
||||
// pixels below).
|
||||
let side = area.width().max(area.height()).max(1.0);
|
||||
let longest = f64::from(vectorcraft_render::MAX_RASTER_SIDE) - 2.0;
|
||||
let scale = (doc.raster_effects_ppi / 72.0).min((MAX_PIXELS / (area.width() * area.height()).max(1.0)).sqrt()).min(longest / side);
|
||||
if !(scale.is_finite() && scale > 0.0) {
|
||||
let placed = placed_scale(doc, set, r);
|
||||
let scale = bitmap_scale(area, ppi, placed);
|
||||
if !(scale.0.is_finite() && scale.0 > 0.0 && scale.1.is_finite() && scale.1 > 0.0) {
|
||||
continue;
|
||||
}
|
||||
// Whole pixels.
|
||||
let region = Rect::new(
|
||||
area.x0,
|
||||
area.y0,
|
||||
area.x0 + (area.width() * scale).ceil().max(1.0) / scale,
|
||||
area.y0 + (area.height() * scale).ceil().max(1.0) / scale,
|
||||
);
|
||||
let img = renderer.render_region_with(&art, region, scale, &opts);
|
||||
let width = whole_pixels(area.width() * scale.0) as u32;
|
||||
let height = whole_pixels(area.height() * scale.1) as u32;
|
||||
let view = Affine::scale_non_uniform(scale.0, scale.1) * Affine::translate((-area.x0, -area.y0));
|
||||
let img = renderer.render(&art, width, height, view, &opts);
|
||||
if img.pixels.as_chunks::<4>().0.iter().all(|px| px[3] == 0) {
|
||||
continue;
|
||||
}
|
||||
let key = unique_key(&out, "print-bitmap");
|
||||
out.images.insert(key.clone(), ImageBlob::new("image/png", img.to_png().map_err(EngineError::Other)?));
|
||||
let xf = Affine::translate(region.origin().to_vec2()) * Affine::scale(1.0 / scale);
|
||||
let xf = Affine::translate(area.origin().to_vec2()) * Affine::scale_non_uniform(1.0 / scale.0, 1.0 / scale.1);
|
||||
let image = ImageObject { key, width: img.width, height: img.height, xf, link: None, placement: Default::default(), pixels: None };
|
||||
images.push(Arc::new(Node::new(out.alloc_id(), NodeKind::Image(Box::new(image)))));
|
||||
let printed_ppi = (scale.0 / placed.0).min(scale.1 / placed.1) * 72.0;
|
||||
lowest = Some(lowest.map_or(printed_ppi, |l| l.min(printed_ppi)));
|
||||
}
|
||||
let mut layer = Node::layer(out.alloc_id(), "Bitmap", LayerColor::Preset(0));
|
||||
if let Some(children) = layer.children_mut() {
|
||||
*children = images;
|
||||
}
|
||||
out.layers = vec![Arc::new(layer)];
|
||||
Ok(out)
|
||||
Ok((out, lowest))
|
||||
}
|
||||
|
||||
@@ -1197,6 +1197,7 @@ pub fn jobs(s: &mut Session, store: &Arc<dyn RecoveryStore>) -> Result<(Vec<Reco
|
||||
let plan = SavePlan {
|
||||
mode: SaveMode::Copy,
|
||||
path: st.path.clone(),
|
||||
path_given: false,
|
||||
format: native,
|
||||
options: serde_json::Map::from_iter([("pdfCompatible".into(), json!(false))]),
|
||||
name: format!("{file}{DOC_EXT}"),
|
||||
|
||||
@@ -647,7 +647,7 @@ pub(crate) fn finish_recording_writes(succeeded: bool) -> Vec<String> {
|
||||
|
||||
/// `path` made absolute with its links followed; for a path that doesn't exist (yet), its nearest
|
||||
/// existing folder's links followed and the rest appended.
|
||||
fn resolve(path: &str) -> Result<PathBuf, String> {
|
||||
pub(crate) fn resolve(path: &str) -> Result<PathBuf, String> {
|
||||
if path.is_empty() {
|
||||
return Err("automation path rejected: path is empty".into());
|
||||
}
|
||||
|
||||
@@ -124,6 +124,10 @@ pub(super) use colors::of_color as color_data;
|
||||
pub(crate) use paths::index_builds;
|
||||
#[cfg(test)]
|
||||
pub(crate) use paths::{PATH_LIST_BUILDS, POINT_LOOKS, REMOVE_ALL_VISITS};
|
||||
#[cfg(test)]
|
||||
pub(crate) use print::postscript_name;
|
||||
#[cfg(test)]
|
||||
pub(crate) use save_open::with_extension;
|
||||
|
||||
pub(super) use resources::{Kind as ResourceKind, gone as resources_gone, held as holds_resources};
|
||||
pub use variables::{MAX_HANDLES, STALE_DATASET, STALE_VARIABLE};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
//! - `print` with `jobOptions.file` writes a file, a `File` the script may write
|
||||
//! ([`super::super::files`]), and `printerName` does not apply. PostScript is written when the
|
||||
//! name ends with `.ps` or `postScriptOptions.postScriptLevel` is set, a print-ready PDF otherwise.
|
||||
//! The PostScript is level 2 when `postScriptLevel` is not assigned, the default it reads as.
|
||||
//! - `print` without a file prepares a job for the printer `printerName` names, or for the
|
||||
//! system's default printer when it is empty or not assigned ([`super::super::printing`]): a
|
||||
//! print-ready PDF composed when `print` is called, which the run keeps until it ends. A name
|
||||
@@ -36,6 +37,7 @@
|
||||
//! - A property the help pages list that is not mapped accepts the default its help page gives
|
||||
//! and throws an error that says it is not available yet at any other value.
|
||||
//! - `fitToPage` set to true wins over the scale factors and the tiling mode.
|
||||
//! With no scale or tiling assigned, false clears a base fit mode and preserves other base scaling modes.
|
||||
//! - With `printAllArtboards` set to false, `artboardRange` picks the artboards; without a range
|
||||
//! every artboard prints. With `printAllArtboards` not assigned, an assigned `artboardRange`
|
||||
//! replaces the range of the settings `print` starts from, which prints when those settings
|
||||
@@ -46,6 +48,9 @@
|
||||
//! with another extension.
|
||||
//! - With one of `horizontalScale` and `verticalScale` assigned, the other keeps its value in the
|
||||
//! settings `print` starts from.
|
||||
//! - `bitmapResolution` is `file.print`'s `advanced.bitmapResolution`: 0 prints at the document's
|
||||
//! raster effects resolution, and 1 to 9600 ppi at that resolution; `print` throws, before
|
||||
//! anything is written, for a value between 0 and 1.
|
||||
//! - `print` throws, before anything is written, when an assigned `artboardRange` names an artboard
|
||||
//! the document does not have, also with `printAllArtboards` true; when `printPreset` or
|
||||
//! `flattenerPreset` is not the name of a preset (any case); when `colorManagementOptions.name` is
|
||||
@@ -54,6 +59,7 @@
|
||||
//! `width` or `height` is assigned above 0. An assigned name that is empty or only spaces,
|
||||
//! or that holds `/`, `\` or a control character (also at either end), throws too. Each checked
|
||||
//! name goes to `file.print` without the spaces around it. `PPDName` takes only the empty string.
|
||||
//! Paper `width` and `height` take 0 (not assigned) or 72 to 14,400 pt.
|
||||
//! - A run makes at most [`MAX_OPTION_OBJECTS`] option objects.
|
||||
//! - `app.printerList` lists the printers the frontend listed for the run as `Printer` objects,
|
||||
//! whose `name` is read-only and whose `printerInfo` is not available yet. It throws with no
|
||||
@@ -150,8 +156,8 @@ const PDF_OVERPRINT: &[&str] = &["DISCARDPDFOVERPRINT", "PRESERVEPDFOVERPRINT"];
|
||||
const POSTSCRIPT_IMAGE_COMPRESSION: &[&str] = &["IMAGECOMPRESSIONNONE", "JPEG", "RLE"];
|
||||
const POSTSCRIPT_LEVEL: &[&str] = &["PSLEVEL1", "PSLEVEL2", "PSLEVEL3"];
|
||||
|
||||
/// The enumerations these members use, as `dom`'s are made. `PDFOverprint` comes from
|
||||
/// [`super::save_open::ENUMS`].
|
||||
/// The enumerations these members use, as `dom`'s are made. `PDFOverprint` and `PageMarksTypes`
|
||||
/// come from [`super::save_open::ENUMS`].
|
||||
pub(super) const ENUMS: &[(&str, &[&str])] = &[
|
||||
("PrintColorProfile", PRINT_COLOR_PROFILE),
|
||||
("PrintColorIntent", PRINT_COLOR_INTENT),
|
||||
@@ -163,7 +169,6 @@ pub(super) const ENUMS: &[(&str, &[&str])] = &[
|
||||
("PrintingBounds", PRINTING_BOUNDS),
|
||||
("PrintFontDownloadMode", PRINT_FONT_DOWNLOAD_MODE),
|
||||
("FontSubstitutionPolicy", FONT_SUBSTITUTION_POLICY),
|
||||
("PageMarksTypes", PAGE_MARKS_TYPES),
|
||||
("PostScriptImageCompressionType", POSTSCRIPT_IMAGE_COMPRESSION),
|
||||
("PrinterPostScriptLevelEnum", POSTSCRIPT_LEVEL),
|
||||
];
|
||||
@@ -176,6 +181,8 @@ enum Kind {
|
||||
Number(f64, f64),
|
||||
/// A whole number from the first to the second.
|
||||
Whole(u64, u64),
|
||||
/// A paper side in points: 0 (not assigned) or a custom size from 72 to 14,400.
|
||||
PaperSize,
|
||||
Text,
|
||||
/// A value of the enumeration (its name and members); only the members in the last list are
|
||||
/// available.
|
||||
@@ -209,7 +216,7 @@ impl Start {
|
||||
|
||||
fn matches(self, kind: Kind, d: &Data) -> bool {
|
||||
match (self, d) {
|
||||
(Start::Num(a), Data::Number(b)) => (a - b).abs() < 1e-9,
|
||||
(Start::Num(a), Data::Number(b)) => a == *b,
|
||||
(Start::None, _) => false,
|
||||
_ => self.value(kind) == *d,
|
||||
}
|
||||
@@ -264,7 +271,7 @@ const JOB: Class = Class {
|
||||
name: "PrintJobOptions",
|
||||
fields: &[
|
||||
f("artboardRange", Kind::Text, Start::Text("1-")),
|
||||
kept("bitmapResolution", Kind::Number(0.0, f64::MAX), Start::Num(0.0)),
|
||||
f("bitmapResolution", Kind::Number(0.0, vectorcraft_pdf::MAX_BITMAP_RESOLUTION), Start::Num(0.0)),
|
||||
f("collate", Kind::Bool, Start::Bool(false)),
|
||||
f("copies", Kind::Whole(1, 999), Start::Num(1.0)),
|
||||
f(
|
||||
@@ -355,14 +362,18 @@ const MARKS: Class = Class {
|
||||
const PAPER: Class = Class {
|
||||
name: "PrintPaperOptions",
|
||||
fields: &[
|
||||
f("height", Kind::Number(0.0, 14_400.0), Start::Num(0.0)),
|
||||
f("height", Kind::PaperSize, Start::Num(0.0)),
|
||||
f("name", Kind::Text, Start::None),
|
||||
kept("offset", Kind::Number(0.0, 14_400.0), Start::Num(0.0)),
|
||||
f("transverse", Kind::Bool, Start::Bool(false)),
|
||||
f("width", Kind::Number(0.0, 14_400.0), Start::Num(0.0)),
|
||||
f("width", Kind::PaperSize, Start::Num(0.0)),
|
||||
],
|
||||
};
|
||||
|
||||
/// The custom paper sizes `file.print` takes, in points.
|
||||
const MIN_PAPER: f64 = 72.0;
|
||||
const MAX_PAPER: f64 = 14_400.0;
|
||||
|
||||
const POSTSCRIPT: Class = Class {
|
||||
name: "PrintPostScriptOptions",
|
||||
fields: &[
|
||||
@@ -440,6 +451,14 @@ fn checked(h: &Host, class: &Class, field: &Field, d: &Data) -> std::result::Res
|
||||
}
|
||||
_ => return Err(HostError::Type(format!("{what} must be a finite number"))),
|
||||
},
|
||||
Kind::PaperSize => match d {
|
||||
Data::Number(n) if n.is_finite() => {
|
||||
if *n != 0.0 && !(MIN_PAPER..=MAX_PAPER).contains(n) {
|
||||
return Err(HostError::Range(format!("{what} must be 0 or from {MIN_PAPER} to {MAX_PAPER}")));
|
||||
}
|
||||
}
|
||||
_ => return Err(HostError::Type(format!("{what} must be a finite number"))),
|
||||
},
|
||||
Kind::Whole(lo, hi) => match d {
|
||||
Data::Number(n) => {
|
||||
if !whole(*n).is_some_and(|n| (lo..=hi).contains(&n)) {
|
||||
@@ -529,6 +548,7 @@ fn property(link: &Link, class: usize, field: usize) -> HostMember {
|
||||
/// What a `PrintOptions` asks `file.print` for.
|
||||
#[derive(Default)]
|
||||
struct Job {
|
||||
clear_fit: bool,
|
||||
preset: Option<String>,
|
||||
file: Option<Data>,
|
||||
/// The assigned `printerName`.
|
||||
@@ -545,10 +565,12 @@ struct Job {
|
||||
paper_size: bool,
|
||||
/// `colorProfileMode` is `SOURCEPROFILE`: the colors print as they are, whatever `name` says.
|
||||
source: bool,
|
||||
/// `colorProfileMode` is assigned `CUSTOMPROFILE`: `name` must name the profile.
|
||||
/// `colorProfileMode` is assigned `CUSTOMPROFILE`: `name` or the base settings must name the profile.
|
||||
custom: bool,
|
||||
/// `printArea` is assigned: the artboards print even when the base settings ignore them.
|
||||
print_area: bool,
|
||||
/// `position` is assigned: an untiled job does not use the saved Print Tiling origin.
|
||||
position: bool,
|
||||
/// The groups of `settings`: the top level and each nested object by its key.
|
||||
top: Map<String, Value>,
|
||||
groups: Vec<(&'static str, Map<String, Value>)>,
|
||||
@@ -675,6 +697,9 @@ fn map_job(h: &Host, slot: usize, job: &mut Job) {
|
||||
"printAsBitmap" => {
|
||||
job.group("advanced").insert("printAsBitmap".into(), json!(flag(v)));
|
||||
}
|
||||
"bitmapResolution" => {
|
||||
job.group("advanced").insert("bitmapResolution".into(), json!(number_of(v)));
|
||||
}
|
||||
"file" => job.file = Some(v.clone()),
|
||||
"artboardRange" => {
|
||||
job.range = Some(string_of(v)).filter(|r| !r.trim().is_empty());
|
||||
@@ -683,6 +708,9 @@ fn map_job(h: &Host, slot: usize, job: &mut Job) {
|
||||
if let Some(range) = job.range.as_ref().filter(|_| value("printAllArtboards").is_none()) {
|
||||
s.insert("range".into(), json!(range));
|
||||
}
|
||||
if job.range.is_none() && value("printAllArtboards").is_none() {
|
||||
s.insert("artboards".into(), json!("all"));
|
||||
}
|
||||
}
|
||||
"printArea" => job.print_area = true,
|
||||
_ => {}
|
||||
@@ -756,11 +784,12 @@ fn map_coordinate(h: &Host, slot: usize, job: &mut Job) -> std::result::Result<(
|
||||
Some(t)
|
||||
} else if scaled {
|
||||
Some("custom")
|
||||
} else if fit.is_some() || tiling.is_some() {
|
||||
} else if tiling.is_some() {
|
||||
Some("none")
|
||||
} else {
|
||||
None
|
||||
};
|
||||
job.clear_fit = fit == Some(false) && scaling.is_none();
|
||||
if let Some(scaling) = scaling {
|
||||
job.top.insert("scaling".into(), json!(scaling));
|
||||
}
|
||||
@@ -809,6 +838,7 @@ fn map_coordinate(h: &Host, slot: usize, job: &mut Job) -> std::result::Result<(
|
||||
_ => "center",
|
||||
};
|
||||
job.group("placement").insert("origin".into(), json!(origin));
|
||||
job.position = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -874,6 +904,10 @@ fn map_postscript(h: &Host, slot: usize, job: &mut Job) {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn postscript_name(path: &str, windows: bool) -> bool {
|
||||
super::save_open::filename_for_suffix(path, windows).to_lowercase().ends_with(".ps")
|
||||
}
|
||||
|
||||
/// `document.print(options?)`: `file.print` of the document to the file `jobOptions.file` names,
|
||||
/// with the assigned options over the document's print settings, or without a file the job for a
|
||||
/// printer ([`prepare`]).
|
||||
@@ -890,11 +924,15 @@ fn doc_print(h: &Host, a: &[Data]) -> Answer {
|
||||
let Some(file) = job.file.take() else { return prepare(h, doc, job) };
|
||||
check_names(h, doc, &mut job)?;
|
||||
let path = file_path(&file, "print")?;
|
||||
// The format follows the name `jobOptions.file` gives, not the real path a link leads to.
|
||||
let postscript = job.level.is_some() || postscript_name(path, cfg!(windows));
|
||||
let real = h.disk.borrow().save_target(path).map_err(|m| refused(m, path))?;
|
||||
let mut p = print_params(&mut job);
|
||||
// The format follows the name `jobOptions.file` gives, not the real path a link leads to.
|
||||
let postscript = job.level.is_some() || crate::cmd::fileio::extension(path) == "ps";
|
||||
p.insert("format".into(), json!(if postscript { "postscript" } else { "pdf" }));
|
||||
// PostScript prints at the level the options read as: an unassigned `postScriptLevel` is `PSLEVEL2`.
|
||||
if postscript {
|
||||
p.insert("level".into(), json!(job.level.unwrap_or(2)));
|
||||
}
|
||||
p.insert("path".into(), json!(plain(real)?));
|
||||
let printed = exactly(h, || on_doc(h, doc.uid, false, |h| unfenced(h, PRINT, || command(h, PRINT, &Value::Object(p)))))?;
|
||||
// What the job lost or how its options apply: one Script Console line each.
|
||||
@@ -997,21 +1035,38 @@ fn prepare(h: &Host, doc: Doc, mut job: Job) -> Answer {
|
||||
/// name (any case) and a paper by its id or label. An empty name, or one with a path separator or
|
||||
/// a control character, throws, and so does `CUSTOMPROFILE` with no profile `name`.
|
||||
fn check_names(h: &Host, doc: Doc, job: &mut Job) -> std::result::Result<(), HostError> {
|
||||
let (count, saved_ignore) = with_doc(h, doc, |_, st| {
|
||||
let (count, saved_ignore, saved_fit, saved_tiled, mut base_profile) = with_doc(h, doc, |_, st| {
|
||||
let mode = st.doc.print_setup.as_ref().and_then(|v| v.get("artboards")).and_then(Value::as_str);
|
||||
(st.doc.artboards.len(), mode == Some("ignore"))
|
||||
let scaling = st.doc.print_setup.as_ref().and_then(|v| v.get("scaling")).and_then(Value::as_str);
|
||||
let profile = st.doc.print_setup.as_ref().and_then(|v| v.get("color")).and_then(|v| v.get("profile")).and_then(Value::as_str);
|
||||
let tiled = matches!(scaling, Some("tileFull" | "tileImageable"));
|
||||
(st.doc.artboards.len(), mode == Some("ignore"), scaling == Some("fit"), tiled, profile.unwrap_or("").to_string())
|
||||
});
|
||||
if let Some(range) = &job.range {
|
||||
vectorcraft_doc::range::parse_range(range, count).map_err(|e| HostError::Range(format!("PrintJobOptions.artboardRange: {e}")))?;
|
||||
}
|
||||
let s = h.session.borrow();
|
||||
let mut base_ignore = saved_ignore;
|
||||
let mut base_fit = saved_fit;
|
||||
let mut base_tiled = saved_tiled;
|
||||
if let Some(name) = job.preset.take() {
|
||||
let n = plain_name("PrintOptions.printPreset", "print preset", &name)?;
|
||||
let preset = s.print_preset_settings(n).ok_or_else(|| no_such("PrintOptions.printPreset", "print preset", &name))?;
|
||||
base_ignore = matches!(preset.artboards, vectorcraft_pdf::PrintArtboards::Ignore);
|
||||
base_fit = matches!(preset.scaling, vectorcraft_pdf::PrintScaling::Fit);
|
||||
base_tiled = preset.scaling.tiles();
|
||||
base_profile.clone_from(&preset.color.profile);
|
||||
job.preset = Some(n.to_string());
|
||||
}
|
||||
if job.clear_fit && base_fit {
|
||||
job.top.insert("scaling".into(), json!("none"));
|
||||
}
|
||||
// A placed Print Tiling origin replaces the placement, so an assigned `position` clears it
|
||||
// for this job when the job does not tile; the saved settings keep it.
|
||||
let tiled = job.top.get("scaling").and_then(Value::as_str).map_or(base_tiled, |s| matches!(s, "tileFull" | "tileImageable"));
|
||||
if job.position && !tiled {
|
||||
job.group("tileOrigin").insert("placed".into(), json!(false));
|
||||
}
|
||||
// An assigned `printArea` prints by artboard when the base settings ignore the artboards: the
|
||||
// assigned `artboardRange` when there is one, otherwise every artboard.
|
||||
if job.print_area && base_ignore && !job.top.contains_key("artboards") {
|
||||
@@ -1025,9 +1080,6 @@ fn check_names(h: &Host, doc: Doc, job: &mut Job) -> std::result::Result<(), Hos
|
||||
}
|
||||
job.group("advanced").insert("flattenerPreset".into(), json!(n));
|
||||
}
|
||||
if job.custom && job.profile.is_none() {
|
||||
return Err(HostError::Error("PrintColorManagementOptions.name must name a color profile for CUSTOMPROFILE".into()));
|
||||
}
|
||||
if let Some(name) = job.profile.take() {
|
||||
let what = "PrintColorManagementOptions.name";
|
||||
let n = plain_name(what, "color profile", &name)?;
|
||||
@@ -1039,6 +1091,8 @@ fn check_names(h: &Host, doc: Doc, job: &mut Job) -> std::result::Result<(), Hos
|
||||
if !job.source {
|
||||
job.group("color").insert("profile".into(), json!(profile.name));
|
||||
}
|
||||
} else if job.custom && base_profile.trim().is_empty() {
|
||||
return Err(HostError::Error("PrintColorManagementOptions.name must name a color profile for CUSTOMPROFILE".into()));
|
||||
}
|
||||
if let Some(name) = job.paper.take() {
|
||||
let n = plain_name("PrintPaperOptions.name", "paper", &name)?;
|
||||
@@ -1155,10 +1209,16 @@ pub(super) fn document_members(l: &Link) -> Vec<Described> {
|
||||
fn field_info(field: &Field) -> MemberInfo {
|
||||
match field.kind {
|
||||
Kind::Bool => typed("boolean"),
|
||||
// A field with no upper limit, such as `bitmapResolution`, reports no maximum.
|
||||
// A field with no upper limit reports no maximum.
|
||||
Kind::Number(min, max) => MemberInfo { min: Some(min), max: (max < f64::MAX).then_some(max), ..typed("number") },
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
Kind::Whole(min, max) => MemberInfo { min: Some(min as f64), max: Some(max as f64), ..typed("number") },
|
||||
Kind::PaperSize => MemberInfo {
|
||||
min: Some(0.0),
|
||||
max: Some(MAX_PAPER),
|
||||
description: Some(format!("0 (not assigned) or a custom size from {MIN_PAPER} to {MAX_PAPER} pt")),
|
||||
..typed("number")
|
||||
},
|
||||
Kind::Text => typed("string"),
|
||||
Kind::Choice(name, _, _) | Kind::Child(name) => typed(name),
|
||||
Kind::File => typed("File"),
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
//! Page and crop options require PDF content, including PDF-compatible `.ai` and `.ait` files.
|
||||
//! Built-in file reads by script commands reject files over 8 MiB and cap the read at 8 MiB plus one byte.
|
||||
//! - Optional arguments use defaults when omitted or `undefined`; explicit `null` throws a type error.
|
||||
//! - Each method sends command warnings to the Script Console with its name as the prefix.
|
||||
//! - `app.userInteractionLevel` starts at `UserInteractionLevel.DISPLAYALERTS` in each run. The
|
||||
//! commands a script runs never show a dialog, so the level does not change what they do, and it
|
||||
//! never allows a file the script's grants do not.
|
||||
@@ -919,7 +920,7 @@ pub(super) fn command_warnings(h: &Host, method: &str, result: &Data) {
|
||||
/// a linked image an open could not read. → the command's answer.
|
||||
fn warned(h: &Host, method: &str, id: &str, p: &Value) -> Answer {
|
||||
let (answer, value) = super::super::command_value(h, id, p)?;
|
||||
for w in value.get("warnings").and_then(Value::as_array).into_iter().flatten().filter_map(Value::as_str) {
|
||||
for w in value.get("warnings").and_then(Value::as_array).into_iter().flatten().take(super::MAX_LISTED).filter_map(Value::as_str) {
|
||||
super::super::each_line(&format!("{method}: {w}"), |line, cut| h.line(super::super::console::Entry::Log(line), cut));
|
||||
}
|
||||
Ok(answer)
|
||||
@@ -963,8 +964,8 @@ fn doc_save_as(h: &Host, a: &[Data]) -> Answer {
|
||||
let given_options = given(arg(a, 2));
|
||||
// Without options, a path ending in `.ai`, `.eps` or `.pdf` takes the defaults a new options
|
||||
// object of that format's class holds.
|
||||
let extension = path.rsplit(['/', '\\']).next().and_then(|n| n.rsplit_once('.')).map(|(_, e)| e.to_ascii_lowercase());
|
||||
let by_extension = SAVE_CLASSES.iter().find(|(_, f)| Some(*f) == extension.as_deref()).map(|(c, _)| fresh(c));
|
||||
let named_format = save_format_for_name(path, cfg!(windows)).map(|f| f.id);
|
||||
let by_extension = SAVE_CLASSES.iter().find(|(_, f)| Some(*f) == named_format).map(|(c, _)| fresh(c));
|
||||
if let Some(o) = given_options.or(by_extension.as_ref()) {
|
||||
let name = typename(o);
|
||||
let Some((class, format)) = SAVE_CLASSES.iter().find(|(c, _)| Some(c.name) == name) else {
|
||||
@@ -982,20 +983,38 @@ fn doc_save_as(h: &Host, a: &[Data]) -> Answer {
|
||||
} else if !q.is_empty() {
|
||||
p.insert("options".into(), Value::Object(q));
|
||||
}
|
||||
} else {
|
||||
let format = crate::cmd::fileio::format_for_name(path).map_or_else(|| super::with_doc(h, doc, |_, st| st.format), |f| f.id);
|
||||
}
|
||||
// Without options, the format of the file name as the platform reads it (on Windows, without
|
||||
// trailing dots and spaces), else the document's own.
|
||||
if !p.contains_key("format") {
|
||||
let format = named_format.unwrap_or_else(|| super::with_doc(h, doc, |_, st| st.format));
|
||||
p.insert("format".into(), json!(format));
|
||||
}
|
||||
let real = h.disk.borrow().save_target(path).map_err(|m| refused(m, path))?;
|
||||
p.insert("path".into(), json!(plain(real)?));
|
||||
exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "saveAs", "file.saveAs", &Value::Object(p))))?;
|
||||
exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "Document.saveAs", "file.saveAs", &Value::Object(p))))?;
|
||||
Ok(Data::Undefined)
|
||||
}
|
||||
|
||||
/// `path` with the extension of `kind` added, unless its name already ends with one of them.
|
||||
fn with_extension(path: &str, kind: &ExportKind, svgz: bool) -> String {
|
||||
let extensions: &[&str] = if svgz { &["svgz"] } else { kind.extensions };
|
||||
let name = path.rsplit(['/', '\\']).next().unwrap_or(path).to_lowercase();
|
||||
fn save_format_for_name(path: &str, windows: bool) -> Option<&'static crate::cmd::fileio::Format> {
|
||||
let name = filename_for_suffix(path, windows);
|
||||
// A name that is only a dot and an extension, such as `.pdf`, picks its format only for the
|
||||
// `.ai`, `.eps` and `.pdf` options classes; any other name takes the usual extension rule.
|
||||
match name.rsplit_once('.') {
|
||||
Some(("", extension)) if SAVE_CLASSES.iter().any(|(_, f)| extension.eq_ignore_ascii_case(f)) => {
|
||||
crate::cmd::fileio::format_for_name(&format!("x.{extension}"))
|
||||
}
|
||||
_ => crate::cmd::fileio::format_for_name(name),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn filename_for_suffix(path: &str, windows: bool) -> &str {
|
||||
let name = if windows { path.rsplit(['/', '\\']).next() } else { path.rsplit('/').next() }.unwrap_or(path);
|
||||
if windows { name.trim_end_matches(['.', ' ']) } else { name }
|
||||
}
|
||||
|
||||
pub(crate) fn with_extension(path: &str, extensions: &[&str], windows: bool) -> String {
|
||||
let name = filename_for_suffix(path, windows).to_lowercase();
|
||||
match extensions.first() {
|
||||
Some(first) if !extensions.iter().any(|e| name.ends_with(&format!(".{e}"))) => format!("{path}.{first}"),
|
||||
_ => path.to_string(),
|
||||
@@ -1058,10 +1077,10 @@ fn doc_export_file(h: &Host, a: &[Data]) -> Answer {
|
||||
} else {
|
||||
p.insert("useArtboards".into(), json!(false));
|
||||
}
|
||||
let named = with_extension(path, &kind, svgz);
|
||||
let named = with_extension(path, if svgz { &["svgz"] } else { kind.extensions }, cfg!(windows));
|
||||
let real = h.disk.borrow().save_target(&named).map_err(|m| refused(m, &named))?;
|
||||
p.insert("path".into(), json!(plain(real)?));
|
||||
exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "exportFile", "document.export", &Value::Object(p))))?;
|
||||
exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "Document.exportFile", "document.export", &Value::Object(p))))?;
|
||||
Ok(Data::Undefined)
|
||||
}
|
||||
|
||||
@@ -1110,9 +1129,19 @@ fn app_open(h: &Host, a: &[Data]) -> Answer {
|
||||
}
|
||||
// The command opens the given path; a real path that is not valid UTF-8 is still refused.
|
||||
let real = h.disk.borrow().open_target(path).map_err(|m| refused(m, path))?;
|
||||
// The document's size is read before any of it is; a placed image keeps its own limit and message.
|
||||
if std::fs::metadata(&real).is_ok_and(|m| m.len() > super::super::files::MAX_OPEN_BYTES) {
|
||||
return Err(refused(super::super::files::OPEN_TOO_LARGE, path));
|
||||
}
|
||||
plain(real)?;
|
||||
p.insert("path".into(), json!(plain(std::path::PathBuf::from(path))?));
|
||||
let r = exactly(h, || warned(h, "open", "document.open", &Value::Object(p)))?;
|
||||
let r = crate::cmd::fileio::with_read_limit(super::super::files::MAX_OPEN_BYTES as usize, || {
|
||||
exactly(h, || warned(h, "app.open", "document.open", &Value::Object(p)))
|
||||
})
|
||||
.map_err(|e| match e {
|
||||
HostError::Error(message) if message == crate::cmd::fileio::READ_TOO_LARGE => refused(super::super::files::OPEN_TOO_LARGE, path),
|
||||
e => e,
|
||||
})?;
|
||||
let index = match &r {
|
||||
Data::Object(items) => items.iter().find_map(|(k, v)| match (k.as_str(), v) {
|
||||
("index", Data::Number(n)) => whole(*n).and_then(|i| usize::try_from(i).ok()),
|
||||
@@ -1283,7 +1312,7 @@ fn doc_close(h: &Host, a: &[Data]) -> Answer {
|
||||
let name = super::with_doc(h, doc, |_, st| st.title());
|
||||
let real = h.disk.borrow().save_target(&path).map_err(|m| refused(m, &name))?;
|
||||
let p = json!({"path": plain(real)?, "format": format});
|
||||
exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "close", "file.saveAs", &p)))?;
|
||||
exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "Document.close", "file.saveAs", &p)))?;
|
||||
}
|
||||
_ => return Err(HostError::Error(UNSAVED_CHANGES.into())),
|
||||
}
|
||||
@@ -1340,3 +1369,37 @@ pub(super) fn classes(link: &Link) -> Vec<HostClass> {
|
||||
.chain(screens::classes(link))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod save_format_tests {
|
||||
use super::save_format_for_name;
|
||||
|
||||
#[test]
|
||||
fn save_as_selects_the_format_from_windows_filename_aliases() {
|
||||
for extension in ["svg", "svgz", "ai", "eps", "pdf"] {
|
||||
for suffix in [".", " ", ". . ", "..."] {
|
||||
for prefix in ["", "/exports/", "C:\\exports\\"] {
|
||||
let name = format!("{prefix}drawing.{}{suffix}", extension.to_ascii_uppercase());
|
||||
assert_eq!(save_format_for_name(&name, true).map(|f| f.id), Some(extension), "{name}");
|
||||
assert!(save_format_for_name(&name, false).is_none(), "{name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
for name in ["drawing", "drawing. . ", "drawing.svg\t", "drawing.svg\u{a0}", "folder.svg/drawing", "folder.svg\\drawing"] {
|
||||
assert!(save_format_for_name(name, true).is_none(), "{name}");
|
||||
}
|
||||
// Production passes `cfg!(windows)`; a Windows host still splits this name at the backslash.
|
||||
#[cfg(unix)]
|
||||
assert_eq!(save_format_for_name("proof\\.svg", false).map(|f| f.id), Some("svg"));
|
||||
#[cfg(windows)]
|
||||
assert!(save_format_for_name("proof\\.svg", false).is_none());
|
||||
for windows in [false, true] {
|
||||
assert_eq!(save_format_for_name(".pdf", windows).map(|f| f.id), Some("pdf"));
|
||||
assert!(save_format_for_name(".svg", windows).is_none());
|
||||
assert!(save_format_for_name("/exports/.png", windows).is_none());
|
||||
assert_eq!(save_format_for_name("/exports/.eps", windows).map(|f| f.id), Some("eps"));
|
||||
assert_eq!(save_format_for_name("drawing.svg", windows).map(|f| f.id), Some("svg"));
|
||||
assert_eq!(save_format_for_name("drawing.svgz", windows).map(|f| f.id), Some("svgz"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ fn doc_export_for_screens(h: &Host, a: &[Data]) -> Answer {
|
||||
for items in exports {
|
||||
let mut p = base.clone();
|
||||
p.extend(items);
|
||||
exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "exportForScreens", "document.exportForScreens", &Value::Object(p))))?;
|
||||
exactly(h, || on_doc(h, doc.uid, false, |h| warned(h, "Document.exportForScreens", "document.exportForScreens", &Value::Object(p))))?;
|
||||
}
|
||||
Ok(Data::Undefined)
|
||||
})
|
||||
|
||||
@@ -108,6 +108,9 @@ pub const MAX_MASK_STEPS: usize = 1 << 24;
|
||||
|
||||
pub(crate) const ACCESS_DENIED: &str = "Script file access denied";
|
||||
pub(crate) const TOO_LARGE: &str = "Script file exceeds 8 MiB";
|
||||
/// The largest document `app.open` reads, checked before the file is read.
|
||||
pub(crate) const MAX_OPEN_BYTES: u64 = 256 << 20;
|
||||
pub(crate) const OPEN_TOO_LARGE: &str = "Script document exceeds 256 MiB";
|
||||
pub(crate) const NOT_OPEN: &str = "Script file is not open";
|
||||
pub(crate) const UNDECODABLE: &str = "Script file cannot be decoded";
|
||||
pub(crate) const NOT_REGULAR: &str = "Script file is not a regular file";
|
||||
@@ -750,7 +753,7 @@ impl Disk {
|
||||
Err(ScriptRead::Refused | ScriptRead::TooLarge) => return Err(ACCESS_DENIED),
|
||||
Err(ScriptRead::Failed(_)) => return Err(READ_FAILED),
|
||||
};
|
||||
if !real.is_file() {
|
||||
if !std::fs::metadata(&real).map_err(|_| READ_FAILED)?.is_file() {
|
||||
return Err(NOT_REGULAR);
|
||||
}
|
||||
Ok(real)
|
||||
|
||||
@@ -152,6 +152,211 @@ fn print_as_bitmap_prints_all_of_a_long_artboard() {
|
||||
assert!(b.x0 <= 0.0 && b.x1 >= 9000.0, "the image covers the artboard: {b:?}");
|
||||
}
|
||||
|
||||
/// The images `file.print` prints with `settings`: their pixel sizes and their places on the page
|
||||
/// in the print-ready PDF (read back), their pixel sizes in the PostScript file (its image
|
||||
/// dictionaries, each size once), and the warnings of both.
|
||||
struct Printed {
|
||||
pdf: Vec<(u32, u32)>,
|
||||
placed: Vec<Rect>,
|
||||
ps: Vec<(u32, u32)>,
|
||||
warnings: Vec<String>,
|
||||
}
|
||||
|
||||
fn printed_images(s: &mut Session, settings: &Value) -> Printed {
|
||||
let warnings = |v: &Value| -> Vec<String> { v["warnings"].as_array().unwrap().iter().filter_map(Value::as_str).map(str::to_string).collect() };
|
||||
let v = s.execute("file.print", &json!({ "settings": settings })).unwrap();
|
||||
let back = vectorcraft_pdf::import(&vectorcraft_format::base64_decode(v["dataBase64"].as_str().unwrap()).unwrap()).unwrap();
|
||||
let (mut pdf, mut placed) = (vec![], vec![]);
|
||||
back.walk(|n| {
|
||||
if let NodeKind::Image(im) = &n.kind {
|
||||
pdf.push((im.width, im.height));
|
||||
placed.push(im.xf.transform_rect_bbox(Rect::new(0.0, 0.0, f64::from(im.width), f64::from(im.height))));
|
||||
}
|
||||
});
|
||||
let mut all = warnings(&v);
|
||||
let v = s.execute("file.print", &json!({ "settings": settings, "format": "postscript" })).unwrap();
|
||||
let ps = String::from_utf8_lossy(&vectorcraft_format::base64_decode(v["dataBase64"].as_str().unwrap()).unwrap()).into_owned();
|
||||
let mut sizes = vec![];
|
||||
for part in ps.split("<< /ImageType ").skip(1) {
|
||||
let after = |key: &str| part.split_once(key).and_then(|(_, r)| r.split_whitespace().next()).and_then(|n| n.parse::<u32>().ok());
|
||||
if let (Some(w), Some(h)) = (after("/Width "), after("/Height ")) {
|
||||
sizes.push((w, h));
|
||||
}
|
||||
}
|
||||
sizes.sort_unstable();
|
||||
sizes.dedup();
|
||||
all.extend(warnings(&v));
|
||||
Printed { pdf, placed, ps: sizes, warnings: all }
|
||||
}
|
||||
|
||||
const CAPPED: &str = "Print as Bitmap prints at";
|
||||
|
||||
/// `advanced.bitmapResolution` sets how many pixels Print as Bitmap prints the art with, in a
|
||||
/// print-ready PDF and in PostScript, on the same place of the page; 0 or none keeps the
|
||||
/// document's raster effects resolution.
|
||||
#[test]
|
||||
fn bitmap_resolution_sets_the_printed_image_size() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("document.rasterEffectsSettings", &json!({"resolution": 72})).unwrap();
|
||||
let mut places = vec![];
|
||||
for (ppi, size) in [(Value::Null, (200, 100)), (json!(0), (200, 100)), (json!(144), (400, 200)), (json!(36), (100, 50)), (json!(1), (3, 2))] {
|
||||
let mut advanced = json!({"printAsBitmap": true});
|
||||
if !ppi.is_null() {
|
||||
advanced["bitmapResolution"] = ppi.clone();
|
||||
}
|
||||
let p = printed_images(&mut s, &json!({ "advanced": advanced }));
|
||||
assert_eq!((p.pdf.as_slice(), p.ps.as_slice()), ([size].as_slice(), [size].as_slice()), "{ppi}");
|
||||
assert!(!p.warnings.iter().any(|w| w.starts_with(CAPPED)), "{ppi}: {:?}", p.warnings);
|
||||
// At 1 ppi the image is rounded up to whole pixels past the artboard.
|
||||
if ppi != json!(1) {
|
||||
places.extend(p.placed);
|
||||
}
|
||||
}
|
||||
let first = places[0];
|
||||
for r in &places {
|
||||
let apart = (r.x0 - first.x0).abs() + (r.y0 - first.y0).abs() + (r.width() - first.width()).abs() + (r.height() - first.height()).abs();
|
||||
assert!(apart < 1.0, "the image covers the same part of the page: {r:?} vs {first:?}");
|
||||
}
|
||||
// Art that does not print as a bitmap leaves it unused.
|
||||
let p = printed_images(&mut s, &json!({"advanced": {"bitmapResolution": 144}}));
|
||||
assert!(p.pdf.is_empty(), "{:?}", p.pdf);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_as_bitmap_keeps_its_resolution_at_unlinked_print_scales() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("document.rasterEffectsSettings", &json!({"resolution": 72})).unwrap();
|
||||
let set = json!({
|
||||
"advanced": {"printAsBitmap": true, "bitmapResolution": 144},
|
||||
"scaling": "custom", "scale": {"width": 200, "height": 100, "linked": false}
|
||||
});
|
||||
let p = printed_images(&mut s, &set);
|
||||
assert_eq!((p.pdf.as_slice(), p.ps.as_slice()), ([(800, 200)].as_slice(), [(800, 200)].as_slice()));
|
||||
assert!(!p.warnings.iter().any(|w| w.starts_with(CAPPED)), "{:?}", p.warnings);
|
||||
let [placed] = p.placed[..] else { panic!("one image: {:?}", p.placed) };
|
||||
assert!((placed.width() - 400.0).abs() < 0.01 && (placed.height() - 100.0).abs() < 0.01, "{placed:?}");
|
||||
}
|
||||
|
||||
/// Print as Bitmap prints at `bitmapResolution` on paper: a job printed at 200% renders twice the
|
||||
/// pixels, and so does one that Fit to Page enlarges, so the image keeps its resolution.
|
||||
#[test]
|
||||
fn print_as_bitmap_keeps_its_resolution_at_a_print_scale() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("document.rasterEffectsSettings", &json!({"resolution": 72})).unwrap();
|
||||
let advanced = json!({"printAsBitmap": true, "bitmapResolution": 144});
|
||||
let p = printed_images(&mut s, &json!({"advanced": advanced, "scaling": "custom", "scale": {"width": 200}}));
|
||||
assert_eq!((p.pdf.as_slice(), p.ps.as_slice()), ([(800, 400)].as_slice(), [(800, 400)].as_slice()));
|
||||
assert!(!p.warnings.iter().any(|w| w.starts_with(CAPPED)), "{:?}", p.warnings);
|
||||
let fit = printed_images(&mut s, &json!({"advanced": advanced, "scaling": "fit"}));
|
||||
let [(w, _)] = fit.pdf[..] else { panic!("one image: {:?}", fit.pdf) };
|
||||
let [placed] = fit.placed[..] else { panic!("one image: {:?}", fit.placed) };
|
||||
let ppi = f64::from(w) / placed.width() * 72.0;
|
||||
assert!((ppi - 144.0).abs() < 2.0, "{w} pixels across {} pt: {ppi} ppi", placed.width());
|
||||
}
|
||||
|
||||
/// A `bitmapResolution` given to `file.print` applies to that job alone; `print.setup` saves it.
|
||||
#[test]
|
||||
fn a_bitmap_resolution_given_to_file_print_applies_to_that_job() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("document.rasterEffectsSettings", &json!({"resolution": 72})).unwrap();
|
||||
let undo = s.active().unwrap().history.undo.len();
|
||||
let p = printed_images(&mut s, &json!({"advanced": {"printAsBitmap": true, "bitmapResolution": 144}}));
|
||||
assert_eq!(p.pdf, [(400, 200)]);
|
||||
assert!(doc(&s).print_setup.is_none(), "the saved settings stay as they are");
|
||||
assert_eq!(doc(&s).raster_effects_ppi, 72.0, "and so does the raster effects resolution");
|
||||
assert_eq!(s.active().unwrap().history.undo.len(), undo, "printing adds no undo step");
|
||||
let v = s.execute("print.setup", &json!({"settings": {"advanced": {"printAsBitmap": true, "bitmapResolution": 144}}})).unwrap();
|
||||
assert_eq!(v["settings"]["advanced"]["bitmapResolution"], 144.0);
|
||||
assert_eq!(printed_images(&mut s, &json!({})).pdf, [(400, 200)], "a job without settings prints at the saved one");
|
||||
assert_eq!(printed_images(&mut s, &json!({"advanced": {"bitmapResolution": 0}})).pdf, [(200, 100)], "0 over it: the document's");
|
||||
// A saved 0 is left out of the settings, which read it back as 0.
|
||||
let v = s.execute("print.setup", &json!({"settings": {"advanced": {"bitmapResolution": 0}}})).unwrap();
|
||||
assert!(v["settings"]["advanced"].get("bitmapResolution").is_none(), "{}", v["settings"]["advanced"]);
|
||||
}
|
||||
|
||||
/// A `bitmapResolution` outside 0 and 1–9600 ppi, or that is not a number, is refused by
|
||||
/// `print.setup`, `print.preview` and `file.print` alike, and nothing is saved.
|
||||
#[test]
|
||||
fn a_bitmap_resolution_out_of_range_is_refused() {
|
||||
let (mut s, _) = session();
|
||||
let undo = s.active().unwrap().history.undo.len();
|
||||
for bad in [json!(0.5), json!(-1), json!(-0.001), json!(9600.5), json!(1e300), json!("high"), json!(true), json!([300])] {
|
||||
let p = json!({"settings": {"advanced": {"printAsBitmap": true, "bitmapResolution": bad}}});
|
||||
for cmd in ["print.setup", "print.preview", "file.print"] {
|
||||
let e = s.execute(cmd, &p).map(|v| panic!("{cmd} {bad}: {v}")).unwrap_err().to_string();
|
||||
assert!(!bad.is_number() || e.contains("advanced.bitmapResolution must be 1–9600 ppi"), "{cmd} {bad}: {e}");
|
||||
}
|
||||
}
|
||||
assert!(doc(&s).print_setup.is_none());
|
||||
assert_eq!(s.active().unwrap().history.undo.len(), undo);
|
||||
for ok in [1.0, 9600.0] {
|
||||
s.execute("print.preview", &json!({"settings": {"advanced": {"printAsBitmap": true, "bitmapResolution": ok}}})).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
/// A page the pixel limits print below the `bitmapResolution` asked for gets a warning that names
|
||||
/// the resolution it prints at, in `file.print`'s PDF and PostScript replies and in
|
||||
/// `print.preview`.
|
||||
#[test]
|
||||
fn a_bitmap_resolution_the_pixel_limits_lower_is_named() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 9000, "height": 2})).unwrap();
|
||||
s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 9000, "height": 2})).unwrap();
|
||||
let set = json!({"advanced": {"printAsBitmap": true, "bitmapResolution": 600}});
|
||||
let p = printed_images(&mut s, &set);
|
||||
// 32,766 pixels across 9,000 pt: 262.1 ppi.
|
||||
let note = "Print as Bitmap prints at 262 ppi, not the 600 ppi bitmapResolution asks for";
|
||||
assert_eq!(p.warnings.iter().filter(|w| w.starts_with(note)).count(), 2, "{:?}", p.warnings);
|
||||
let [(w, _)] = p.pdf[..] else { panic!("one image: {:?}", p.pdf) };
|
||||
assert!((32_000..=vectorcraft_render::MAX_RASTER_SIDE).contains(&w), "{w} pixels");
|
||||
assert_eq!(p.ps, p.pdf);
|
||||
let pv = s.execute("print.preview", &json!({ "settings": set })).unwrap();
|
||||
assert!(pv["warnings"].as_array().unwrap().iter().any(|w| w.as_str().unwrap().starts_with(note)), "{}", pv["warnings"]);
|
||||
// A resolution that fits, the document's resolution, and output that is not a bitmap: no note.
|
||||
for set in [
|
||||
json!({"advanced": {"printAsBitmap": true, "bitmapResolution": 200}}),
|
||||
json!({"advanced": {"printAsBitmap": true}}),
|
||||
json!({"advanced": {"bitmapResolution": 600}}),
|
||||
json!({"advanced": {"printAsBitmap": true, "bitmapResolution": 600}, "output": {"mode": "separations"}}),
|
||||
] {
|
||||
let pv = s.execute("print.preview", &json!({ "settings": set })).unwrap();
|
||||
assert!(!pv["warnings"].as_array().unwrap().iter().any(|w| w.as_str().unwrap().starts_with(CAPPED)), "{set}: {}", pv["warnings"]);
|
||||
}
|
||||
}
|
||||
|
||||
/// An artboard with no art prints no image, so the pixel limits a bitmap of it would meet name no
|
||||
/// lower resolution, also with only art that draws nothing on it in `file.print`; once a background
|
||||
/// color or art that draws is on it, they do.
|
||||
#[test]
|
||||
fn an_empty_artboard_does_not_name_a_lower_bitmap_resolution() {
|
||||
let (mut s, _) = session();
|
||||
s.execute("artboard.new", &json!({"x": 0, "y": 500, "width": 9000, "height": 2})).unwrap();
|
||||
let set = json!({"advanced": {"printAsBitmap": true, "bitmapResolution": 600}});
|
||||
let p = printed_images(&mut s, &set);
|
||||
assert_eq!(p.pdf.len(), 1, "only the artboard with art prints an image: {:?}", p.pdf);
|
||||
assert!(!p.warnings.iter().any(|w| w.starts_with(CAPPED)), "{:?}", p.warnings);
|
||||
let pv = s.execute("print.preview", &json!({ "settings": set })).unwrap();
|
||||
assert!(!pv["warnings"].as_array().unwrap().iter().any(|w| w.as_str().unwrap().starts_with(CAPPED)), "{}", pv["warnings"]);
|
||||
// A background color prints, in file.print and in what print.preview says alike.
|
||||
s.execute("artboard.setProps", &json!({"index": 1, "color": "#336699"})).unwrap();
|
||||
let p = printed_images(&mut s, &set);
|
||||
assert_eq!(p.pdf.len(), 2, "{:?}", p.pdf);
|
||||
assert_eq!(p.warnings.iter().filter(|w| w.starts_with(CAPPED)).count(), 2, "{:?}", p.warnings);
|
||||
let pv = s.execute("print.preview", &json!({ "settings": set })).unwrap();
|
||||
assert!(pv["warnings"].as_array().unwrap().iter().any(|w| w.as_str().unwrap().starts_with(CAPPED)), "{}", pv["warnings"]);
|
||||
s.execute("artboard.setProps", &json!({"index": 1, "color": null})).unwrap();
|
||||
let id = s.execute("shape.rectangle", &json!({"x": 0, "y": 500, "width": 9000, "height": 2})).unwrap()["id"].clone();
|
||||
// Art that draws nothing prints no image either.
|
||||
s.execute("object.setProps", &json!({"ids": [id], "opacity": 0})).unwrap();
|
||||
let p = printed_images(&mut s, &set);
|
||||
assert_eq!(p.pdf.len(), 1, "{:?}", p.pdf);
|
||||
assert!(!p.warnings.iter().any(|w| w.starts_with(CAPPED)), "{:?}", p.warnings);
|
||||
s.execute("object.setProps", &json!({"ids": [id], "opacity": 100})).unwrap();
|
||||
let p = printed_images(&mut s, &set);
|
||||
assert_eq!(p.pdf.len(), 2, "{:?}", p.pdf);
|
||||
assert_eq!(p.warnings.iter().filter(|w| w.starts_with(CAPPED)).count(), 2, "{:?}", p.warnings);
|
||||
}
|
||||
|
||||
/// Appearance of Black › Printing / Exporting (#394): Print as Bitmap draws pure CMYK black as RGB
|
||||
/// black when `rich_black` is on.
|
||||
#[test]
|
||||
|
||||
@@ -133,6 +133,118 @@ fn pathless_save_rejection_hides_document_folder() {
|
||||
let _ = std::fs::remove_dir_all(d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multi_file_save_directory_errors_hide_paths_the_caller_did_not_give() {
|
||||
use crate::file_access::{AutomationRoots, confine};
|
||||
|
||||
let d = dir("multi-file-directory-error");
|
||||
let (inside, outside) = (d.join("in"), d.join("kept-out"));
|
||||
for folder in [&inside, &outside] {
|
||||
std::fs::create_dir_all(folder).unwrap();
|
||||
}
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 2})).unwrap();
|
||||
let own = path(&outside, "doc.vectorcraft");
|
||||
let saved = s.execute("document.save", &json!({"path": own, "separateArtboards": true})).unwrap();
|
||||
let files: Vec<String> = saved["files"].as_array().unwrap().iter().map(|f| f.as_str().unwrap().to_string()).collect();
|
||||
assert!(files.len() > 1, "{saved}");
|
||||
let primary = std::fs::read(&own).unwrap();
|
||||
rect(&mut s);
|
||||
let write_only = AutomationRoots::new(&[inside.as_path()], &[outside.as_path()]).unwrap();
|
||||
let both = AutomationRoots::new(&[inside.as_path(), outside.as_path()], &[outside.as_path()]).unwrap();
|
||||
for target in [&files[0], &files[1]] {
|
||||
let original = std::fs::read(target).unwrap();
|
||||
std::fs::remove_file(target).unwrap();
|
||||
std::fs::create_dir(target).unwrap();
|
||||
let name = std::path::Path::new(target).file_name().unwrap().to_string_lossy();
|
||||
for (roots, params, shown) in [
|
||||
(&write_only, json!({"separateArtboards": true}), name.as_ref()),
|
||||
(&write_only, json!({"path": null, "separateArtboards": true}), name.as_ref()),
|
||||
(&write_only, json!({"path": own, "separateArtboards": true}), target.as_str()),
|
||||
(&both, json!({"separateArtboards": true}), target.as_str()),
|
||||
] {
|
||||
let error = confine(roots.as_ref(), || s.execute("document.save", ¶ms)).unwrap_err().to_string();
|
||||
assert_eq!(error, format!("{shown}: not a file"), "{params}");
|
||||
assert!(std::path::Path::new(target).is_dir());
|
||||
if target != &own {
|
||||
assert_eq!(std::fs::read(&own).unwrap(), primary);
|
||||
}
|
||||
assert!(s.doc().unwrap().is_dirty());
|
||||
}
|
||||
std::fs::remove_dir(target).unwrap();
|
||||
std::fs::write(target, original).unwrap();
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refused_multi_file_save_never_calls_the_writer() {
|
||||
use crate::cmd::fileio::save_job;
|
||||
use crate::file_access::{AutomationRoots, confine};
|
||||
|
||||
let d = dir("refused-writer");
|
||||
let inside = d.join("in");
|
||||
let outside = d.join("out");
|
||||
std::fs::create_dir_all(&inside).unwrap();
|
||||
std::fs::create_dir_all(&outside).unwrap();
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 2})).unwrap();
|
||||
let own = path(&outside, "doc.vectorcraft");
|
||||
s.execute("document.save", &json!({"path": own})).unwrap();
|
||||
let original = std::fs::read(&own).unwrap();
|
||||
let roots = AutomationRoots::new(&[inside.as_path()], &[inside.as_path()]).unwrap();
|
||||
for explicit in [false, true] {
|
||||
let p = if explicit { json!({"path": own, "separateArtboards": true}) } else { json!({"separateArtboards": true}) };
|
||||
let plan = save_plan(&s, SaveMode::Save, &p).unwrap();
|
||||
let job = save_job(&mut s, plan).unwrap();
|
||||
let mut calls = 0;
|
||||
let error = confine(roots.as_ref(), || {
|
||||
job.write_unless(
|
||||
|_| None,
|
||||
|_, _| {
|
||||
calls += 1;
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
})
|
||||
.unwrap_err()
|
||||
.to_string();
|
||||
assert_eq!(calls, 0);
|
||||
assert!(error.contains("outside the write root"), "{error}");
|
||||
assert_eq!(error.contains(&outside.to_string_lossy().to_string()), explicit, "{error}");
|
||||
assert_eq!(std::fs::read(&own).unwrap(), original);
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(d);
|
||||
}
|
||||
|
||||
/// A save of several files into a folder that may not be read fails as a write there fails, with
|
||||
/// READ_ONLY_LOCATION, and not because the files' real paths could not be compared.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_multi_file_save_into_a_locked_folder_is_read_only() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
let d = dir("locked-multi");
|
||||
let locked = d.join("locked");
|
||||
std::fs::create_dir_all(&locked).unwrap();
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 200, "height": 100, "artboards": 2})).unwrap();
|
||||
let own = path(&locked, "doc.vectorcraft");
|
||||
std::fs::set_permissions(&locked, std::fs::Permissions::from_mode(0o000)).unwrap();
|
||||
// Where permissions don't hold (root), the folder reads as any other.
|
||||
let enforced = std::fs::read_dir(&locked).is_err();
|
||||
let r = s.execute("document.save", &json!({"path": own, "separateArtboards": true}));
|
||||
std::fs::set_permissions(&locked, std::fs::Permissions::from_mode(0o755)).unwrap();
|
||||
if enforced {
|
||||
let e = r.unwrap_err();
|
||||
assert!(matches!(e, EngineError::ReadOnlyLocation(_)), "{e}");
|
||||
assert!(std::fs::read_dir(&locked).unwrap().next().is_none());
|
||||
} else {
|
||||
assert!(r.is_ok(), "{r:?}");
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_svg_path_writes_svg_and_save_writes_it_back() {
|
||||
let d = dir("svg");
|
||||
|
||||
@@ -10,6 +10,23 @@ use crate::*;
|
||||
|
||||
const DENIED: &str = "Script file access denied";
|
||||
|
||||
#[test]
|
||||
fn postscript_suffix_recognizes_windows_filename_aliases() {
|
||||
use crate::script::dom::postscript_name;
|
||||
|
||||
for suffix in [".", " ", ". . ", "..."] {
|
||||
for prefix in ["", "/exports/", "C:\\exports\\"] {
|
||||
let name = format!("{prefix}proof.PS{suffix}");
|
||||
assert!(postscript_name(&name, true), "{name}");
|
||||
assert!(!postscript_name(&name, false), "{name}");
|
||||
}
|
||||
}
|
||||
for name in ["proof.pdf", "proof.ps\t", "proof.ps\u{a0}", "folder.ps/proof", "folder.ps\\proof"] {
|
||||
assert!(!postscript_name(name, true), "{name}");
|
||||
}
|
||||
assert!(postscript_name("proof.ps", false));
|
||||
}
|
||||
|
||||
/// A test's folder, removed when the test ends, a failed assertion included.
|
||||
struct Workspace(PathBuf);
|
||||
|
||||
@@ -42,6 +59,20 @@ fn folder(name: &str) -> Workspace {
|
||||
Workspace(std::fs::canonicalize(&base).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_workspace_is_removed_when_its_test_panics() {
|
||||
let base = folder("removed-on-panic");
|
||||
let path = base.to_path_buf();
|
||||
assert!(
|
||||
std::panic::catch_unwind(move || {
|
||||
let _held = base;
|
||||
panic!("a failed assertion");
|
||||
})
|
||||
.is_err()
|
||||
);
|
||||
assert!(!path.exists());
|
||||
}
|
||||
|
||||
/// A session whose scripts keep their data folders in `base/settings/Script Data`, with a
|
||||
/// 300 × 200 document of two artboards holding a rectangle.
|
||||
fn session(base: &Path) -> Session {
|
||||
@@ -81,6 +112,95 @@ fn pages(path: &Path) -> Vec<(f64, f64)> {
|
||||
info.pages.iter().map(|p| (p.width.round(), p.height.round())).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_blank_assigned_range_clears_the_saved_range() {
|
||||
let base = folder("blank-range");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
s.execute("print.setup", &json!({"settings": {"artboards": "range", "range": "1"}})).unwrap();
|
||||
for (name, range) in [("empty.pdf", ""), ("spaces.pdf", " ")] {
|
||||
logged(
|
||||
&mut s,
|
||||
&base,
|
||||
&format!(
|
||||
"Folder.userData; var o = new PrintOptions(); o.jobOptions.file = new File({});
|
||||
o.jobOptions.artboardRange = '{}'; app.activeDocument.print(o);",
|
||||
quoted(&dir.join(name)),
|
||||
range
|
||||
),
|
||||
);
|
||||
assert_eq!(pages(&dir.join(name)).len(), s.active().unwrap().doc.artboards.len());
|
||||
}
|
||||
assert_eq!(s.execute("print.setup", &json!({})).unwrap()["settings"]["range"], json!("1"));
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_uses_the_assigned_file_object_after_its_path_changes() {
|
||||
let base = folder("file-reference");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let out = logged(
|
||||
&mut s,
|
||||
&base,
|
||||
&format!(
|
||||
"Folder.userData; var o = new PrintOptions(), f = new File({}); o.jobOptions.file = f;
|
||||
vc.log(o.jobOptions.file === f); vc.log(f.changePath({}));
|
||||
app.activeDocument.print(o); vc.log(o.jobOptions.file === f);
|
||||
vc.log(f.rename('renamed.pdf')); app.activeDocument.print(o);
|
||||
o.jobOptions.file = null; vc.log(o.jobOptions.file == null);",
|
||||
quoted(&dir.join("old.pdf")),
|
||||
quoted(&dir.join("new.ps"))
|
||||
),
|
||||
);
|
||||
assert_eq!(out, json!([true, true, true, true, true]));
|
||||
assert!(!dir.join("old.pdf").exists());
|
||||
assert!(!dir.join("new.ps").exists());
|
||||
assert!(std::fs::read(dir.join("renamed.pdf")).unwrap().starts_with(b"%PDF"));
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_custom_profile_requires_an_assigned_or_base_profile() {
|
||||
let base = folder("custom-profile-required");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let path = dir.join("custom.pdf");
|
||||
std::fs::write(&path, "original").unwrap();
|
||||
let script = format!(
|
||||
"Folder.userData; var o = new PrintOptions(); o.jobOptions.file = new File({});
|
||||
o.colorManagementOptions.colorProfileMode = PrintColorProfile.CUSTOMPROFILE; app.activeDocument.print(o);",
|
||||
quoted(&path)
|
||||
);
|
||||
let error = failure(&mut s, &base, &script);
|
||||
assert!(error.contains("must name a color profile for CUSTOMPROFILE"), "{error}");
|
||||
assert_eq!(std::fs::read(&path).unwrap(), b"original");
|
||||
s.execute("print.setup", &json!({"settings": {"color": {"profile": "sRGB IEC61966-2.1"}}})).unwrap();
|
||||
logged(&mut s, &base, &script);
|
||||
assert!(std::fs::read(&path).unwrap().starts_with(b"%PDF"));
|
||||
let preset_script = script.replace("app.activeDocument.print(o);", "o.printPreset = '[Default]'; app.activeDocument.print(o);");
|
||||
let error = failure(&mut s, &base, &preset_script);
|
||||
assert!(error.contains("must name a color profile for CUSTOMPROFILE"), "{error}");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_dot_ps_file_names_write_postscript() {
|
||||
let base = folder("dot-ps");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
for name in [".ps", ".PS"] {
|
||||
let path = dir.join(name);
|
||||
logged(
|
||||
&mut s,
|
||||
&base,
|
||||
&format!("Folder.userData; var o = new PrintOptions(); o.jobOptions.file = new File({}); app.activeDocument.print(o);", quoted(&path)),
|
||||
);
|
||||
assert!(std::fs::read(&path).unwrap().starts_with(b"%!PS"));
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_writes_the_file_with_the_assigned_options_over_the_saved_settings() {
|
||||
let base = folder("happy");
|
||||
@@ -108,6 +228,8 @@ fn print_writes_the_file_with_the_assigned_options_over_the_saved_settings() {
|
||||
j.file = new File(dir + '/c.ps'); doc.print(o);\n\
|
||||
o.postScriptOptions.postScriptLevel = PrinterPostScriptLevelEnum.PSLEVEL2; j.file = new File(dir + '/level2.prn');\n\
|
||||
doc.print(o);\n\
|
||||
o.postScriptOptions.postScriptLevel = PrinterPostScriptLevelEnum.PSLEVEL3; j.file = new File(dir + '/level3.ps');\n\
|
||||
doc.print(o);\n\
|
||||
vc.log([app.printPresetsList[0], app.PPDFileList.length]);"
|
||||
),
|
||||
);
|
||||
@@ -120,9 +242,11 @@ fn print_writes_the_file_with_the_assigned_options_over_the_saved_settings() {
|
||||
assert_eq!(pages(&dir.join("a.pdf")).len(), 6, "two artboards, three copies");
|
||||
assert_eq!(pages(&dir.join("b.pdf")), vec![(595.0, 842.0)], "artboard 2 only, on upright A4");
|
||||
let ps = std::fs::read_to_string(dir.join("c.ps")).unwrap();
|
||||
assert!(ps.starts_with("%!PS") && !ps.contains("%%LanguageLevel: 2"), "a .ps name alone: {}", &ps[..ps.len().min(200)]);
|
||||
assert!(ps.starts_with("%!PS") && ps.contains("%%LanguageLevel: 2"), "a .ps name alone prints at PSLEVEL2: {}", &ps[..ps.len().min(200)]);
|
||||
let ps = std::fs::read_to_string(dir.join("level2.prn")).unwrap();
|
||||
assert!(ps.starts_with("%!PS") && ps.contains("%%LanguageLevel: 2"), "a level alone: {}", &ps[..ps.len().min(200)]);
|
||||
let ps = std::fs::read_to_string(dir.join("level3.ps")).unwrap();
|
||||
assert!(ps.starts_with("%!PS") && ps.contains("%%LanguageLevel: 3"), "an assigned PSLEVEL3: {}", &ps[..ps.len().min(200)]);
|
||||
assert_eq!(s.execute("print.setup", &json!({})).unwrap()["settings"], saved, "printing leaves the saved settings as they are");
|
||||
assert_eq!(s.active().unwrap().history.undo.len(), undo, "and adds no undo step");
|
||||
// The commands stay closed to vc.run, before and after a print.
|
||||
@@ -389,6 +513,92 @@ fn file_print_max_pages_composes_only_what_fits() {
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_print_job_file_can_be_read_and_assigned_to_another_job() {
|
||||
let base = folder("file-getter");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let path = dir.join("proof 100%.pdf");
|
||||
let out = logged(
|
||||
&mut s,
|
||||
&base,
|
||||
&format!(
|
||||
"Folder.userData; var first = new PrintJobOptions(), second = new PrintJobOptions();
|
||||
first.file = new File({}); second.file = first.file;
|
||||
vc.log([second.file instanceof File, second.file.fsName === first.file.fsName]);
|
||||
var o = new PrintOptions(); o.jobOptions = second; app.activeDocument.print(o);",
|
||||
quoted(&path)
|
||||
),
|
||||
);
|
||||
assert_eq!(out[0], json!([true, true]));
|
||||
assert!(!pages(&path).is_empty());
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_scale_assignment_and_reflection_share_the_supported_range() {
|
||||
let base = folder("scale-range");
|
||||
let mut s = session(&base);
|
||||
let out = logged(
|
||||
&mut s,
|
||||
&base,
|
||||
"var c = new PrintCoordinateOptions();
|
||||
var names = ['horizontalScale', 'verticalScale'];
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
var name = names[i], info = c.reflect.find(name);
|
||||
c[name] = info.max;
|
||||
try { c[name] = info.max + 0.01; vc.log('accepted'); }
|
||||
catch (e) { vc.log([e.name, c[name] === info.max, info.max === 10000]); }
|
||||
}",
|
||||
);
|
||||
assert_eq!(out, json!([["RangeError", true, true], ["RangeError", true, true]]));
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabling_fit_preserves_other_base_scaling_modes() {
|
||||
let base = folder("fit-false");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let boxes = |path: &Path| {
|
||||
let mut boxes = Vec::new();
|
||||
vectorcraft_pdf::import(&std::fs::read(path).unwrap()).unwrap().walk(|node| {
|
||||
if let Some(bounds) = node.path_data().and_then(|p| p.bounds()) {
|
||||
boxes.push(bounds);
|
||||
}
|
||||
});
|
||||
boxes
|
||||
};
|
||||
for mode in ["tileFull", "tileImageable", "custom", "fit"] {
|
||||
let settings = json!({"scaling": mode, "scale": {"width": 500, "height": 500}});
|
||||
s.execute("print.setup", &json!({"settings": settings})).unwrap();
|
||||
s.execute("print.presets.save", &json!({"name": "Base", "settings": settings})).unwrap();
|
||||
let override_settings = if mode == "fit" { json!({"scaling": "none"}) } else { json!({}) };
|
||||
let want = s.execute("file.print", &json!({"settings": override_settings, "path": dir.join("want.pdf").to_string_lossy()})).unwrap();
|
||||
for preset in [false, true] {
|
||||
if preset {
|
||||
s.execute("print.setup", &json!({"settings": {"scaling": "none"}})).unwrap();
|
||||
}
|
||||
let out = dir.join(format!("{mode}-{preset}.pdf"));
|
||||
let select = if preset { "o.printPreset = 'Base';" } else { "" };
|
||||
logged(
|
||||
&mut s,
|
||||
&base,
|
||||
&format!(
|
||||
"Folder.userData; var o = new PrintOptions(); o.jobOptions.file = new File({});
|
||||
{select} o.coordinateOptions.fitToPage = false; app.activeDocument.print(o);",
|
||||
quoted(&out)
|
||||
),
|
||||
);
|
||||
let expected = boxes(&dir.join("want.pdf"));
|
||||
assert!(!expected.is_empty());
|
||||
assert_eq!(boxes(&out), expected, "{mode}, preset: {preset}");
|
||||
assert_eq!(pages(&out).len() as u64, want["pages"].as_u64().unwrap());
|
||||
}
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// A job past `maxPages` is turned away before its raster effects are flattened.
|
||||
#[test]
|
||||
fn file_print_max_pages_turns_a_job_away_before_raster_effects_are_flattened() {
|
||||
@@ -439,6 +649,9 @@ fn print_options_refuse_bad_values() {
|
||||
("c.verticalScale = 20000;", "RangeError", "verticalScale must be from 1 to 10000"),
|
||||
("c.verticalScale = 0;", "RangeError", "verticalScale must be from 1 to 10000"),
|
||||
("m.trimMarksWeight = -1;", "RangeError", "trimMarksWeight must be from 0"),
|
||||
("o.paperOptions.width = 36;", "RangeError", "width must be 0 or from 72 to 14400"),
|
||||
("o.paperOptions.height = 71.9;", "RangeError", "height must be 0 or from 72 to 14400"),
|
||||
("o.paperOptions.width = 72; o.paperOptions.width = 0; o.paperOptions.width = 1;", "RangeError", "width must be 0 or from 72"),
|
||||
("c.orientation = 'PrintOrientation.SIDEWAYS';", "TypeError", "orientation must be a PrintOrientation value"),
|
||||
("c.orientation = 'PrintTiling.TILEFULLPAGES';", "TypeError", "orientation must be a PrintOrientation value"),
|
||||
("j.file = 'C:/out.pdf';", "TypeError", "file must be a File"),
|
||||
@@ -590,6 +803,68 @@ fn one_assigned_scale_factor_keeps_the_saved_other() {
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// The pixel sizes of the images in the PDF at `path`.
|
||||
fn image_sizes(path: &Path) -> Vec<(u32, u32)> {
|
||||
let back = vectorcraft_pdf::import(&std::fs::read(path).unwrap()).unwrap();
|
||||
let mut sizes = vec![];
|
||||
back.walk(|n| {
|
||||
if let vectorcraft_doc::NodeKind::Image(im) = &n.kind {
|
||||
sizes.push((im.width, im.height));
|
||||
}
|
||||
});
|
||||
sizes
|
||||
}
|
||||
|
||||
/// `PrintJobOptions.bitmapResolution` sets the resolution Print as Bitmap prints at, as
|
||||
/// `advanced.bitmapResolution` does; 0 keeps the document's raster effects resolution.
|
||||
#[test]
|
||||
fn bitmap_resolution_sets_the_printed_image_size() {
|
||||
let base = folder("bitmap");
|
||||
let mut s = session(&base);
|
||||
s.execute("document.rasterEffectsSettings", &json!({"resolution": 72})).unwrap();
|
||||
let saved = s.execute("print.setup", &json!({})).unwrap()["settings"].clone();
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let out = logged(
|
||||
&mut s,
|
||||
&base,
|
||||
&format!(
|
||||
"Folder.userData; var o = new PrintOptions(), j = o.jobOptions;\n\
|
||||
vc.log(j.bitmapResolution);\n\
|
||||
j.printAsBitmap = true; j.printAllArtboards = false; j.artboardRange = '1';\n\
|
||||
j.bitmapResolution = 144; j.file = new File({}); app.activeDocument.print(o);\n\
|
||||
j.bitmapResolution = 0; j.file = new File({}); app.activeDocument.print(o);\n\
|
||||
vc.log(j.bitmapResolution);",
|
||||
quoted(&dir.join("a.pdf")),
|
||||
quoted(&dir.join("b.pdf"))
|
||||
),
|
||||
);
|
||||
assert_eq!(out, json!([0, 0]));
|
||||
assert_eq!(image_sizes(&dir.join("a.pdf")), [(600, 400)], "a 300 by 200 pt artboard at 144 ppi");
|
||||
assert_eq!(image_sizes(&dir.join("b.pdf")), [(300, 200)], "at the raster effects resolution, 72 ppi");
|
||||
let settings = json!({"artboards": "range", "range": "1", "advanced": {"printAsBitmap": true, "bitmapResolution": 144}});
|
||||
s.execute("file.print", &json!({"settings": settings, "path": dir.join("want.pdf").to_string_lossy()})).unwrap();
|
||||
assert_eq!(image_sizes(&dir.join("want.pdf")), image_sizes(&dir.join("a.pdf")), "the same image as the command prints");
|
||||
assert_eq!(s.execute("print.setup", &json!({})).unwrap()["settings"], saved, "the saved settings stay as they are");
|
||||
let file = format!("j.file = new File({});", quoted(&dir.join("x.pdf")));
|
||||
for (case, kind, part) in [
|
||||
("j.bitmapResolution = 9601;", "RangeError", "bitmapResolution must be from 0 to 9600"),
|
||||
("j.bitmapResolution = -1;", "RangeError", "bitmapResolution must be from 0 to 9600"),
|
||||
("j.bitmapResolution = NaN;", "TypeError", "bitmapResolution"),
|
||||
("j.bitmapResolution = Infinity;", "TypeError", "bitmapResolution"),
|
||||
("j.bitmapResolution = '300';", "TypeError", "bitmapResolution must be a finite number"),
|
||||
(
|
||||
&format!("{file} j.printAsBitmap = true; j.bitmapResolution = 0.5; app.activeDocument.print(o);"),
|
||||
"",
|
||||
"advanced.bitmapResolution must be 1–9600 ppi",
|
||||
),
|
||||
] {
|
||||
let e = failure(&mut s, &base, &format!("Folder.userData; var o = new PrintOptions(), j = o.jobOptions; {case}"));
|
||||
assert!(e.contains(kind) && e.contains(part), "{case}: {e}");
|
||||
}
|
||||
assert!(!dir.join("x.pdf").exists(), "nothing printed");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// An assigned `artboardRange` replaces a saved range, an assigned `printArea` prints by artboard over
|
||||
/// saved settings that ignore the artboards, and two scale factors that differ by any amount print
|
||||
/// unlinked.
|
||||
@@ -614,14 +889,46 @@ fn assigned_job_and_scale_options_apply_over_the_saved_settings() {
|
||||
assert_eq!(print(&mut s, "ignore.pdf", ""), 1, "all the art as one page");
|
||||
assert_eq!(print(&mut s, "area.pdf", "o.jobOptions.printArea = PrintingBounds.ARTBOARDBOUNDS;"), 2, "each artboard prints");
|
||||
assert_eq!(print(&mut s, "range-ignored.pdf", "o.jobOptions.artboardRange = '2';"), 1, "a range alone keeps ignoring the artboards");
|
||||
s.execute("artboard.setProps", &json!({"index": 1, "width": 150})).unwrap();
|
||||
let area_range = "o.jobOptions.printArea = PrintingBounds.ARTBOARDBOUNDS; o.jobOptions.artboardRange = '2';";
|
||||
assert_eq!(print(&mut s, "area-range.pdf", area_range), 1, "printArea with a range prints the range");
|
||||
let info = vectorcraft_pdf::info(&std::fs::read(dir.join("area-range.pdf")).unwrap(), None).unwrap();
|
||||
let trim = info.pages[0].boxes.iter().find(|(k, _)| *k == vectorcraft_pdf::CropTo::Trim).map(|(_, r)| *r).unwrap();
|
||||
assert_eq!((trim.width().round(), trim.height().round()), (150.0, 200.0), "the page is artboard 2");
|
||||
let scaled = "o.coordinateOptions.horizontalScale = 100; o.coordinateOptions.verticalScale = 100.0000000005;";
|
||||
assert!(print(&mut s, "scale.pdf", scaled) >= 1, "factors that differ by a tiny amount print unlinked");
|
||||
assert_eq!(s.execute("print.setup", &json!({})).unwrap()["settings"]["artboards"], json!("ignore"), "the saved settings stay");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// An assigned `position` places an untiled print even when the saved Print Tiling origin is
|
||||
/// placed; the saved origin stays.
|
||||
#[test]
|
||||
fn an_assigned_position_replaces_a_placed_tile_origin() {
|
||||
let base = folder("position");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let trim = |s: &mut Session, name: &str, body: &str| {
|
||||
let file = quoted(&dir.join(name));
|
||||
logged(
|
||||
s,
|
||||
&base,
|
||||
&format!("Folder.userData; var o = new PrintOptions(); o.jobOptions.file = new File({file}); {body} app.activeDocument.print(o);"),
|
||||
);
|
||||
let info = vectorcraft_pdf::info(&std::fs::read(dir.join(name)).unwrap(), None).unwrap();
|
||||
let b = info.pages[0].boxes.iter().find(|(k, _)| *k == vectorcraft_pdf::CropTo::Trim).map(|(_, r)| *r).unwrap();
|
||||
[b.x0, b.y0, b.x1, b.y1].map(f64::round)
|
||||
};
|
||||
let top_left = "o.coordinateOptions.position = PrintPosition.TRANSLATETOPLEFT;";
|
||||
s.execute("print.setup", &json!({"settings": {"artboards": "range", "range": "1"}})).unwrap();
|
||||
let plain = trim(&mut s, "plain.pdf", top_left);
|
||||
s.execute("print.setup", &json!({"settings": {"tileOrigin": {"placed": true, "x": 100, "y": 0}}})).unwrap();
|
||||
assert_ne!(trim(&mut s, "placed.pdf", ""), plain, "the placed origin moves the art");
|
||||
assert_eq!(trim(&mut s, "assigned.pdf", top_left), plain, "the assigned position wins");
|
||||
assert_eq!(s.execute("print.setup", &json!({})).unwrap()["settings"]["tileOrigin"]["placed"], json!(true), "the saved origin stays");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// Each option group prints the PostScript `file.print` writes for the settings it maps to, and
|
||||
/// each of those settings changes the file.
|
||||
#[test]
|
||||
@@ -644,7 +951,8 @@ fn option_groups_print_what_their_settings_print() {
|
||||
assert!(text.starts_with("%!PS"), "{}: {}", path.display(), &text[..text.len().min(40)]);
|
||||
text.lines().filter(|l| !l.starts_with("%%CreationDate:")).collect::<Vec<_>>().join("\n")
|
||||
};
|
||||
s.execute("file.print", &json!({"format": "postscript", "path": dir.join("plain.ps").to_string_lossy()})).unwrap();
|
||||
// A script prints PostScript at level 2 unless `postScriptLevel` is assigned.
|
||||
s.execute("file.print", &json!({"format": "postscript", "level": 2, "path": dir.join("plain.ps").to_string_lossy()})).unwrap();
|
||||
let plain = undated(&dir.join("plain.ps"));
|
||||
let mut wrong = Vec::new();
|
||||
let cases = [
|
||||
@@ -667,7 +975,7 @@ fn option_groups_print_what_their_settings_print() {
|
||||
];
|
||||
for (i, (body, settings)) in cases.iter().enumerate() {
|
||||
let [want, got] = ["want", "got"].map(|name| dir.join(format!("{name}{i}.ps")));
|
||||
s.execute("file.print", &json!({"format": "postscript", "settings": settings, "path": want.to_string_lossy()})).unwrap();
|
||||
s.execute("file.print", &json!({"format": "postscript", "level": 2, "settings": settings, "path": want.to_string_lossy()})).unwrap();
|
||||
logged(
|
||||
&mut s,
|
||||
&base,
|
||||
|
||||
@@ -10,6 +10,41 @@ use crate::*;
|
||||
|
||||
const DENIED: &str = "Script file access denied";
|
||||
|
||||
#[test]
|
||||
fn export_extension_recognizes_windows_filename_aliases() {
|
||||
use crate::script::dom::with_extension;
|
||||
|
||||
for extension in ["svg", "svgz", "jpg", "jpeg", "png"] {
|
||||
for suffix in [".", " ", ". . ", "..."] {
|
||||
for prefix in ["", "/exports/", "C:\\exports\\"] {
|
||||
let name = format!("{prefix}drawing.{}{suffix}", extension.to_ascii_uppercase());
|
||||
assert_eq!(with_extension(&name, &[extension], true), name);
|
||||
assert_eq!(with_extension(&name, &[extension], false), format!("{name}.{extension}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!(with_extension("drawing.JPEG ", &["jpg", "jpeg"], true), "drawing.JPEG ");
|
||||
assert_eq!(with_extension("drawing.svg ", &["svgz"], true), "drawing.svg .svgz");
|
||||
for name in ["drawing", "drawing.png\t", "drawing.png\u{a0}", "folder.png/drawing", "folder.png\\drawing"] {
|
||||
assert_eq!(with_extension(name, &["png"], true), format!("{name}.png"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn app_open_refuses_an_oversized_document() {
|
||||
let base = folder("oversized-open");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let input = dir.join("huge.svg");
|
||||
std::fs::File::create(&input).unwrap().set_len(crate::script::files::MAX_OPEN_BYTES + 1).unwrap();
|
||||
let before = s.documents().len();
|
||||
let error = failure(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&input)));
|
||||
assert!(error.contains(crate::script::files::OPEN_TOO_LARGE), "{error}");
|
||||
assert_eq!(s.documents().len(), before);
|
||||
let out = logged(&mut s, &base, &format!("Folder.userData; var f = new File({}); vc.log([f.open('r'), f.error]);", quoted(&input)));
|
||||
assert_eq!(out, json!([[false, crate::script::files::TOO_LARGE]]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_wrappers_report_encoder_warnings_without_changing_their_return_values() {
|
||||
for method in ["exportFile", "saveAs", "exportForScreens"] {
|
||||
@@ -209,6 +244,76 @@ fn quoted(p: &Path) -> String {
|
||||
serde_json::to_string(&p.to_string_lossy()).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_description_limits_the_preflight_guarantee() {
|
||||
let params = crate::cmd::find_command("document.save").unwrap().params;
|
||||
assert!(params.contains("failure found before writing leaves every file unchanged"));
|
||||
assert!(params.contains("a later write failure can leave earlier files written"));
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn svg_save_and_export_refuse_resolved_destination_collisions() {
|
||||
let base = folder("svg-collision");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let pic = base.join("outside/pic.png");
|
||||
std::fs::write(&pic, super::links::png(2, 2, [10, 200, 30])).unwrap();
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
s.execute("file.place", &json!({"path": pic.to_string_lossy(), "link": false})).unwrap();
|
||||
let svg = dir.join("a.svg");
|
||||
let export = format!("app.activeDocument.exportFile(new File({}), ExportType.SVG);", quoted(&svg));
|
||||
logged(&mut s, &base, &format!("Folder.userData; {export}"));
|
||||
s.execute("file.saveAs", &json!({"path": svg.to_string_lossy(), "format": "svg", "images": "link"})).unwrap();
|
||||
let images: Vec<_> = std::fs::read_dir(&dir).unwrap().map(|e| e.unwrap().path()).filter(|p| *p != svg).collect();
|
||||
assert_eq!(images.len(), 1);
|
||||
std::fs::remove_file(&images[0]).unwrap();
|
||||
std::os::unix::fs::symlink(&svg, &images[0]).unwrap();
|
||||
for call in [export.clone(), format!("app.activeDocument.saveAs(new File({}));", quoted(&svg))] {
|
||||
std::fs::write(&svg, "original").unwrap();
|
||||
let error = failure(&mut s, &base, &format!("Folder.userData; {call}"));
|
||||
assert!(error.contains("resolve to the same file"), "{error}");
|
||||
assert_eq!(std::fs::read(&svg).unwrap(), b"original");
|
||||
assert!(std::fs::symlink_metadata(&images[0]).unwrap().file_type().is_symlink());
|
||||
}
|
||||
// With no primary file yet, the image's link leads nowhere but still names the primary.
|
||||
std::fs::remove_file(&svg).unwrap();
|
||||
let error = s.execute("file.saveAs", &json!({"path": svg.to_string_lossy(), "format": "svg", "images": "link"})).unwrap_err().to_string();
|
||||
assert!(error.contains("resolve to the same file"), "{error}");
|
||||
assert!(!svg.exists());
|
||||
// A script may not write through a link that leads nowhere at all.
|
||||
let error = failure(&mut s, &base, &format!("Folder.userData; {export}"));
|
||||
assert!(error.contains("resolve to the same file") || error.contains("access denied"), "{error}");
|
||||
assert!(!svg.exists());
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn open_template_link_creates_an_untitled_copy() {
|
||||
let base = folder("template-link");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
let target = dir.join("drawing.vectorcraft");
|
||||
s.execute("file.saveAs", &json!({"path": target.to_string_lossy()})).unwrap();
|
||||
let link = dir.join("drawing.vctemplate");
|
||||
std::os::unix::fs::symlink(&target, &link).unwrap();
|
||||
let count = s.documents().len();
|
||||
logged(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&link)));
|
||||
assert_eq!(s.documents().len(), count + 1);
|
||||
assert!(s.active().unwrap().path.is_none());
|
||||
assert_ne!(s.active().unwrap().title(), "drawing.vectorcraft");
|
||||
assert!(!s.active().unwrap().doc.template);
|
||||
let template = dir.join("source.vctemplate");
|
||||
std::fs::write(&template, std::fs::read(&target).unwrap()).unwrap();
|
||||
let document = dir.join("alias.vectorcraft");
|
||||
std::os::unix::fs::symlink(&template, &document).unwrap();
|
||||
logged(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&document)));
|
||||
assert!(s.active().unwrap().path.is_some());
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_as_export_file_and_open_write_and_read_where_the_script_may() {
|
||||
let base = folder("happy");
|
||||
@@ -251,6 +356,99 @@ fn save_as_export_file_and_open_write_and_read_where_the_script_may() {
|
||||
assert_eq!(s.documents().len(), 2);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn save_as_selects_the_format_before_resolving_a_link() {
|
||||
let base = folder("save-link-format");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
for extension in ["svg", "svgz"] {
|
||||
let target = dir.join(format!("{extension}.vectorcraft"));
|
||||
let link = dir.join(format!("drawing.{extension}"));
|
||||
std::fs::write(&target, "original").unwrap();
|
||||
std::os::unix::fs::symlink(&target, &link).unwrap();
|
||||
logged(&mut s, &base, &format!("Folder.userData; app.activeDocument.saveAs(new File({}));", quoted(&link)));
|
||||
let bytes = std::fs::read(&target).unwrap();
|
||||
if extension == "svgz" {
|
||||
assert!(bytes.starts_with(&[0x1f, 0x8b]));
|
||||
} else {
|
||||
assert!(String::from_utf8(bytes).unwrap().contains("<svg"));
|
||||
}
|
||||
}
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
let link = dir.join("drawing");
|
||||
std::fs::write(dir.join("target.svg"), "original").unwrap();
|
||||
std::os::unix::fs::symlink(dir.join("target.svg"), &link).unwrap();
|
||||
logged(&mut s, &base, &format!("Folder.userData; app.activeDocument.saveAs(new File({}));", quoted(&link)));
|
||||
assert_eq!(s.active().unwrap().format, "vectorcraft");
|
||||
assert!(dir.join("target.svg").is_file());
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn svg_sidecar_directories_are_refused_before_any_output_changes() {
|
||||
let base = folder("svg-directory");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
let pic = base.join("outside/pic.png");
|
||||
std::fs::write(&pic, super::links::png(2, 2, [10, 200, 30])).unwrap();
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
s.execute("file.place", &json!({"path": pic.to_string_lossy(), "link": false})).unwrap();
|
||||
let svg = dir.join("a.svg");
|
||||
let export = format!("app.activeDocument.exportFile(new File({}), ExportType.SVG);", quoted(&svg));
|
||||
logged(&mut s, &base, &format!("Folder.userData; {export}"));
|
||||
s.execute("file.saveAs", &json!({"path": svg.to_string_lossy(), "format": "svg", "images": "link"})).unwrap();
|
||||
let images: Vec<PathBuf> = std::fs::read_dir(&dir).unwrap().map(|e| e.unwrap().path()).filter(|p| *p != svg).collect();
|
||||
assert_eq!(images.len(), 1);
|
||||
let image = &images[0];
|
||||
std::fs::remove_file(image).unwrap();
|
||||
std::fs::create_dir(image).unwrap();
|
||||
for save in [false, true] {
|
||||
std::fs::write(&svg, "original SVG").unwrap();
|
||||
let call = if save { format!("app.activeDocument.saveAs(new File({}));", quoted(&svg)) } else { export.clone() };
|
||||
let error = failure(&mut s, &base, &format!("Folder.userData; {call}"));
|
||||
assert!(error.contains("not a file"), "{call}: {error}");
|
||||
assert_eq!(std::fs::read_to_string(&svg).unwrap(), "original SVG");
|
||||
assert!(image.is_dir());
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_export_and_open_report_command_warnings_in_the_console() {
|
||||
let base = folder("command-warnings");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
logged(
|
||||
&mut s,
|
||||
&base,
|
||||
"app.documents.add(DocumentColorSpace.RGB, 100, 100);
|
||||
vc.run('shape.rectangle', {x: 10, y: 10, width: 50, height: 50});
|
||||
vc.run('transparency.set', {opacity: 0.5}); app.activeDocument.pageItems[0].name = 'bad\\u0001name';",
|
||||
);
|
||||
for (command, format, method, call) in [
|
||||
("file.saveAs", "eps", "Document.saveAs", "app.activeDocument.saveAs(f);"),
|
||||
("document.export", "svg", "Document.exportFile", "app.activeDocument.exportFile(f, ExportType.SVG);"),
|
||||
] {
|
||||
let path = dir.join(format!("warnings.{format}"));
|
||||
let want = s.execute(command, &json!({"path": path.to_string_lossy(), "format": format})).unwrap();
|
||||
let warnings: Vec<String> = want["warnings"].as_array().unwrap().iter().map(|w| format!("{method}: {}", w.as_str().unwrap())).collect();
|
||||
assert!(!warnings.is_empty(), "{command}: {want}");
|
||||
let report = run(&mut s, &base, &format!("Folder.userData; var f = new File({}); {call}", quoted(&path))).unwrap();
|
||||
assert_eq!(report["console"]["lines"], json!(warnings));
|
||||
}
|
||||
let svg = dir.join("missing-image.svg");
|
||||
std::fs::write(&svg, "<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><image href='missing.png' width='50' height='50'/></svg>")
|
||||
.unwrap();
|
||||
let want = s.execute("document.open", &json!({"path": svg.to_string_lossy()})).unwrap();
|
||||
let warnings: Vec<String> = want["warnings"].as_array().unwrap().iter().map(|w| format!("app.open: {}", w.as_str().unwrap())).collect();
|
||||
assert!(!warnings.is_empty(), "{want}");
|
||||
let report = run(&mut s, &base, &format!("Folder.userData; app.open(new File({}));", quoted(&svg))).unwrap();
|
||||
assert_eq!(report["console"]["lines"], json!(warnings));
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scripted_file_writes_log_command_warnings() {
|
||||
for (method, extension, call) in [("saveAs", "pdf", "d.saveAs(file)"), ("exportFile", "png", "d.exportFile(file, ExportType.PNG24)")] {
|
||||
@@ -262,7 +460,7 @@ fn scripted_file_writes_log_command_warnings() {
|
||||
let path = dir.join(format!("output.{extension}"));
|
||||
let out = run(&mut s, &base, &format!("Folder.userData; var d = app.activeDocument, file = new File({}); {call};", quoted(&path))).unwrap();
|
||||
assert!(path.is_file(), "{method}");
|
||||
let prefix = format!("{method}: ");
|
||||
let prefix = format!("Document.{method}: ");
|
||||
let lines = out["console"]["lines"].as_array().unwrap();
|
||||
assert!(lines.iter().filter_map(Value::as_str).any(|s| s.starts_with(&prefix) && s.contains("couldn't be decoded")), "{method}: {out}");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
@@ -319,7 +517,7 @@ fn export_file_logs_encoder_warnings() {
|
||||
assert_eq!(r["log"], json!(["undefined"]));
|
||||
assert!(dir.join("warnings.svg").is_file());
|
||||
let lines = r["console"]["lines"].as_array().unwrap();
|
||||
let warning = "exportFile: Object names containing invalid XML characters were left out of SVG name attributes";
|
||||
let warning = "Document.exportFile: Object names containing invalid XML characters were left out of SVG name attributes";
|
||||
assert!(lines.iter().any(|line| line.as_str() == Some(warning)), "{lines:?}");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
@@ -338,7 +536,7 @@ fn save_as_logs_the_saves_warnings() {
|
||||
let r = run(&mut s, &base, &text).unwrap_or_else(|e| panic!("{text}: {e}"));
|
||||
assert_eq!(r["log"], json!(["undefined"]));
|
||||
let lines = r["console"]["lines"].as_array().cloned().unwrap_or_default();
|
||||
let warned = lines.iter().filter_map(Value::as_str).any(|l| l.starts_with("saveAs: ") && l.contains("keeps the artwork"));
|
||||
let warned = lines.iter().filter_map(Value::as_str).any(|l| l.starts_with("Document.saveAs: ") && l.contains("keeps the artwork"));
|
||||
assert!(warned, "{lines:?}");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
@@ -359,7 +557,7 @@ fn open_logs_warnings_for_an_unreadable_linked_image() {
|
||||
let r = run(&mut s, &base, &text).unwrap();
|
||||
assert_eq!(r["log"], json!(["Document"]));
|
||||
let lines = r["console"]["lines"].as_array().unwrap();
|
||||
assert!(lines.iter().filter_map(Value::as_str).any(|l| l.starts_with("open: ") && l.contains("missing.png")), "{lines:?}");
|
||||
assert!(lines.iter().filter_map(Value::as_str).any(|l| l.starts_with("app.open: ") && l.contains("missing.png")), "{lines:?}");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
@@ -410,6 +608,27 @@ fn save_as_uses_the_link_name_extension_for_the_encoder() {
|
||||
drop(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_multi_file_save_refuses_a_directory_before_replacing_the_primary_file() {
|
||||
let base = folder("save-directory");
|
||||
let mut s = session(&base);
|
||||
let dir = data_folder(&mut s, &base);
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100, "artboards": 2})).unwrap();
|
||||
let path = dir.join("drawing.vectorcraft");
|
||||
let saved = s.execute("file.saveAs", &json!({"path": path.to_string_lossy(), "format": "vectorcraft", "separateArtboards": true})).unwrap();
|
||||
let files = saved["files"].as_array().unwrap();
|
||||
assert!(files.len() > 1, "{saved}");
|
||||
let primary = std::fs::read(&path).unwrap();
|
||||
let sidecar = files.iter().map(|v| PathBuf::from(v.as_str().unwrap())).find(|p| *p != path).unwrap();
|
||||
std::fs::remove_file(&sidecar).unwrap();
|
||||
std::fs::create_dir(&sidecar).unwrap();
|
||||
let error = failure(&mut s, &base, &format!("Folder.userData; app.activeDocument.saveAs(new File({}));", quoted(&path)));
|
||||
assert!(error.contains("not a file"), "{error}");
|
||||
assert_eq!(std::fs::read(&path).unwrap(), primary);
|
||||
assert!(sidecar.is_dir());
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_as_template_preserves_the_document_file_and_saved_state() {
|
||||
let base = folder("templatecopy");
|
||||
@@ -1267,6 +1486,23 @@ fn bad_arguments_are_refused_with_an_error() {
|
||||
assert_eq!(s.active().unwrap().path, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logging_files_and_folders_reads_only_enumerable_own_properties() {
|
||||
let base = folder("log-file-folder");
|
||||
let mut s = session(&base);
|
||||
let text = "var f = new File('kept.svg'), d = new Folder('kept');\n\
|
||||
vc.log(f); vc.log(d); vc.log([f, {folder: d}]);\n\
|
||||
File.prototype.inherited = 'omit'; Folder.prototype.inherited = 'omit';\n\
|
||||
Object.defineProperty(f, 'hidden', {value: 'omit', enumerable: false});\n\
|
||||
Object.defineProperty(d, 'hidden', {value: 'omit', enumerable: false});\n\
|
||||
f.label = 'drawing'; d.count = 2;\n\
|
||||
vc.log(f); vc.log(d); vc.log([f, {folder: d}]);";
|
||||
let log = logged(&mut s, &base, text);
|
||||
let nested = json!([{"label": "drawing"}, {"folder": {"count": 2}}]);
|
||||
assert_eq!(log, json!([{}, {}, [{}, {"folder": {}}], {"label": "drawing"}, {"count": 2}, nested]));
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
/// Only a `File` the `File` class made names a file. An object made from `File.prototype` and a
|
||||
/// plain object throw a `TypeError`, and a `File` whose hidden path property a script set keeps its
|
||||
/// own path, so nothing is written or opened at the path the script put there.
|
||||
@@ -1649,7 +1885,7 @@ fn a_saves_warnings_go_to_the_console() {
|
||||
);
|
||||
let r = run(&mut s, &base, &save).unwrap();
|
||||
let lines = r["console"]["lines"].as_array().unwrap();
|
||||
assert!(lines.iter().any(|l| l.as_str().is_some_and(|l| l.starts_with("saveAs: "))), "{lines:?}");
|
||||
assert!(lines.iter().any(|l| l.as_str().is_some_and(|l| l.starts_with("Document.saveAs: "))), "{lines:?}");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
@@ -1989,7 +2225,7 @@ fn save_as_writes_its_warnings_to_the_console() {
|
||||
s.execute("file.new", &json!({"width": 100, "height": 50, "artboards": 2})).unwrap();
|
||||
let r = run(&mut s, &base, &format!("Folder.userData; app.activeDocument.saveAs(new File({}));", quoted(&dir.join("two.svg")))).unwrap();
|
||||
let lines = r["console"]["lines"].as_array().cloned().unwrap_or_default();
|
||||
assert!(lines.iter().filter_map(Value::as_str).any(|l| l.starts_with("saveAs: ")), "{lines:?}");
|
||||
assert!(lines.iter().filter_map(Value::as_str).any(|l| l.starts_with("Document.saveAs: ")), "{lines:?}");
|
||||
drop(base);
|
||||
}
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
// The print option classes and the enumerations of printing.
|
||||
(
|
||||
"",
|
||||
"FontSubstitutionPolicy PageMarksTypes PostScriptImageCompressionType PrintArtworkDesignation PrintColorIntent \
|
||||
"FontSubstitutionPolicy PostScriptImageCompressionType PrintArtworkDesignation PrintColorIntent \
|
||||
PrintColorManagementOptions PrintColorProfile PrintColorSeparationMode PrintColorSeparationOptions \
|
||||
PrintCoordinateOptions PrintFlattenerOptions PrintFontDownloadMode PrintFontOptions PrintJobOptions PrintOptions \
|
||||
PrintOrientation PrintPageMarksOptions PrintPaperOptions PrintPosition PrintPostScriptOptions PrintTiling \
|
||||
@@ -464,7 +464,6 @@ const INSIDE: &[(&str, &str)] = &[
|
||||
postScriptLevel= shadingResolution shadingResolution= typename",
|
||||
),
|
||||
("FontSubstitutionPolicy.", "SUBSTITUTEDEVICE SUBSTITUTEOBLIQUE SUBSTITUTETINT"),
|
||||
("PageMarksTypes.", "Japanese Roman"),
|
||||
("PostScriptImageCompressionType.", "IMAGECOMPRESSIONNONE JPEG RLE"),
|
||||
("PrintArtworkDesignation.", "ALLLAYERS VISIBLELAYERS VISIBLEPRINTABLELAYERS"),
|
||||
("PrintColorIntent.", "ABSOLUTECOLORIMETRIC PERCEPTUALINTENT RELATIVECOLORIMETRIC SATURATIONINTENT"),
|
||||
|
||||
@@ -103,7 +103,7 @@ pub(crate) fn install(interp: &mut Interp) -> JsResult<()> {
|
||||
/// The text of the localization object `id` for the current locale: the string value of the first
|
||||
/// of [`Localization::keys`] that the object has as its own data property. No getter runs.
|
||||
pub(crate) fn localized_text(interp: &mut Interp, id: ObjId) -> JsResult<Option<Value>> {
|
||||
if !matches!(interp.object(id)?.class, Class::Ordinary) {
|
||||
if !matches!(interp.object(id)?.class, Class::Ordinary | Class::FsEntry(..)) {
|
||||
return Ok(None);
|
||||
}
|
||||
for k in interp.localization.keys() {
|
||||
@@ -293,11 +293,13 @@ impl Source {
|
||||
Some(Err(*length))
|
||||
}
|
||||
Class::Array { .. } => return Err(interp.type_error(NOT_PLAIN_ARRAY)),
|
||||
Class::Ordinary if has_symbols => return Err(interp.type_error("toSource: an object with a Symbol property cannot be written as source")),
|
||||
Class::Ordinary if o.proto == Some(object_proto) && enumerable => {
|
||||
Class::Ordinary | Class::FsEntry(..) if has_symbols => {
|
||||
return Err(interp.type_error("toSource: an object with a Symbol property cannot be written as source"));
|
||||
}
|
||||
Class::Ordinary | Class::FsEntry(..) if o.proto == Some(object_proto) && enumerable => {
|
||||
Some(Ok(o.props.iter().map(|(k, p)| (k.clone(), p.clone())).collect::<Vec<_>>()))
|
||||
}
|
||||
Class::Ordinary => return Err(interp.type_error(NOT_PLAIN_OBJECT)),
|
||||
Class::Ordinary | Class::FsEntry(..) => return Err(interp.type_error(NOT_PLAIN_OBJECT)),
|
||||
_ => None,
|
||||
};
|
||||
let fixed = shape.as_ref().and(fixed_state(o));
|
||||
@@ -451,3 +453,53 @@ fn function_name(code: &Code) -> String {
|
||||
None => "[anonymous]".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::heap::{OPEN, PropMap};
|
||||
use crate::interp::Abrupt;
|
||||
|
||||
fn source_error(interp: &mut Interp, id: ObjId) -> String {
|
||||
let Err(Abrupt::Throw(error)) = write_source(interp, Value::Object(id)) else { panic!("expected a source error") };
|
||||
let Value::String(message) = interp.get_value(&error, &key("message")).unwrap() else { panic!("expected an error message") };
|
||||
message.to_rust_string()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_source_uses_ordinary_properties_and_guards_for_files() {
|
||||
for file in [false, true] {
|
||||
let mut interp = Interp::new(crate::Options { es2015: true, ..crate::Options::default() }, crate::Limits::default());
|
||||
let class = if file {
|
||||
let Value::String(path) = Value::str("native path") else { panic!("expected a string") };
|
||||
let mut slots = PropMap::default();
|
||||
slots.insert(key("__vcError"), Value::str(""));
|
||||
Class::FsEntry(path, Box::new(slots))
|
||||
} else {
|
||||
Class::Ordinary
|
||||
};
|
||||
let mut object = Object::new(class, Some(interp.intrinsics.object_proto));
|
||||
object.props.insert(key("label"), Prop::Data { value: Value::str("public"), flags: OPEN });
|
||||
let id = interp.heap.alloc_object(object);
|
||||
let Value::String(source) = write_source(&mut interp, Value::Object(id)).unwrap() else { panic!("expected source text") };
|
||||
assert_eq!(source.to_rust_string(), r#"({"label":"public"})"#);
|
||||
interp.object_mut(id).unwrap().props.insert(key("__vcPath"), Prop::Data { value: Value::str("own path"), flags: OPEN });
|
||||
let Value::String(source) = write_source(&mut interp, Value::Object(id)).unwrap() else { panic!("expected source text") };
|
||||
assert_eq!(source.to_rust_string(), r#"({"label":"public", "__vcPath":"own path"})"#);
|
||||
interp.object_mut(id).unwrap().proto = None;
|
||||
assert_eq!(source_error(&mut interp, id), NOT_PLAIN_OBJECT);
|
||||
interp.object_mut(id).unwrap().proto = Some(interp.intrinsics.object_proto);
|
||||
interp.object_mut(id).unwrap().props.insert(key("hidden"), Prop::Data { value: Value::Bool(true), flags: 0 });
|
||||
assert_eq!(source_error(&mut interp, id), NOT_PLAIN_OBJECT);
|
||||
interp.object_mut(id).unwrap().props.insert(key("hidden"), Prop::Data { value: Value::Bool(true), flags: crate::heap::ENUMERABLE });
|
||||
assert_eq!(source_error(&mut interp, id), FIXED_PROPERTY);
|
||||
interp.object_mut(id).unwrap().props.insert(key("hidden"), Prop::Data { value: Value::Bool(true), flags: OPEN });
|
||||
interp.object_mut(id).unwrap().extensible = false;
|
||||
assert_eq!(source_error(&mut interp, id), NOT_EXTENSIBLE);
|
||||
interp.object_mut(id).unwrap().extensible = true;
|
||||
let symbol = interp.well_known(|w| &w.iterator).unwrap();
|
||||
interp.define_sym(id, symbol, Prop::Data { value: Value::Bool(true), flags: OPEN }).unwrap();
|
||||
assert_eq!(source_error(&mut interp, id), "toSource: an object with a Symbol property cannot be written as source");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ impl Interp {
|
||||
return Err(self.type_error(&format!("the constructor {name} did not give an object")));
|
||||
}
|
||||
if let Value::Object(o) = &v
|
||||
&& matches!(self.object(*o)?.class, Class::Ordinary)
|
||||
&& matches!(self.object(*o)?.class, Class::Ordinary | Class::FsEntry(..))
|
||||
&& let Some(Prop::Data { value: Value::Object(proto), .. }) = self.find_property(callee, &key("prototype"))?
|
||||
{
|
||||
self.object_mut(*o)?.proto = Some(proto);
|
||||
|
||||
+117
-19
@@ -7,10 +7,10 @@
|
||||
//! `File` and `new Folder(path)` always a `Folder`, while `File(path)` gives a `Folder` when the
|
||||
//! host's `stat` says the path is a folder, and `Folder(path)` a `File` when it is a file. Two
|
||||
//! objects for one path are different objects. An object keeps its path in the host's platform
|
||||
//! form in an internal slot that only the classes' own methods set ([`Class::FsEntry`]), so an
|
||||
//! object a script makes with `Object.create(File.prototype)` is not a `File`. It keeps its `error`
|
||||
//! text, the id of the file it has open (or -1), the encoding set before `open` and its line feed
|
||||
//! in properties that are not enumerable; every name the getters give comes from
|
||||
//! form, its `error` text, the id of the file it has open (or -1), the encoding set before `open`
|
||||
//! and its line feed in native slots that only the classes' own methods set ([`Class::FsEntry`]),
|
||||
//! so an object a script makes with `Object.create(File.prototype)` is not a `File`; every name the
|
||||
//! getters give comes from
|
||||
//! the host's `parse` of that path. `Folder.current` is kept in the realm and starts at the host's
|
||||
//! `current`.
|
||||
//!
|
||||
@@ -97,7 +97,7 @@ impl Interp {
|
||||
return Ok(None);
|
||||
};
|
||||
Ok(match &o.class {
|
||||
Class::FsEntry(s) => Some(crate::Data::Object(vec![(key.to_string(), crate::Data::String(s.to_rust_string()))])),
|
||||
Class::FsEntry(s, _) => Some(crate::Data::Object(vec![(key.to_string(), crate::Data::String(s.to_rust_string()))])),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
@@ -106,7 +106,7 @@ impl Interp {
|
||||
/// The path of `o` when the `File` or `Folder` class made it.
|
||||
fn own_path(i: &Interp, o: ObjId) -> JsResult<Option<Value>> {
|
||||
Ok(match &i.object(o)?.class {
|
||||
Class::FsEntry(s) => Some(Value::String(s.clone())),
|
||||
Class::FsEntry(s, _) => Some(Value::String(s.clone())),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
@@ -116,7 +116,7 @@ fn set_path(i: &mut Interp, o: ObjId, fs: Value) -> JsResult<()> {
|
||||
let Value::String(s) = fs else { return Err(i.type_error("File: the host gave no path")) };
|
||||
i.rooted(&[Value::Object(o), Value::String(s.clone())], |i| i.reserve_heap(string_bytes(s.len())))?;
|
||||
if let Some(ob) = i.heap.object_mut(o)
|
||||
&& let Class::FsEntry(path) = &mut ob.class
|
||||
&& let Class::FsEntry(path, _) = &mut ob.class
|
||||
{
|
||||
*path = s;
|
||||
}
|
||||
@@ -151,28 +151,55 @@ fn message(i: &mut Interp, name: &str) -> JsResult<Value> {
|
||||
}
|
||||
|
||||
/// The field `name` of a record the host gave: its own data property, `undefined` when it has none,
|
||||
/// so that a property a script put on `Object.prototype` is not read as part of it.
|
||||
/// so that a property a script put on `Object.prototype` is not read as part of it. A proxy's traps
|
||||
/// do not run: a proxy has no such property.
|
||||
fn field(i: &mut Interp, v: &Value, name: &str) -> JsResult<Value> {
|
||||
match v.as_object() {
|
||||
Some(o) => slot(i, o, name),
|
||||
Some(o) => Ok(match i.ordinary_own_property(o, &key(name))? {
|
||||
Some(Prop::Data { value, .. }) => value,
|
||||
_ => Value::Undefined,
|
||||
}),
|
||||
None => Ok(Value::Undefined),
|
||||
}
|
||||
}
|
||||
|
||||
/// The value of the own data property `name` of `o`, `undefined` when it has none. A proxy's
|
||||
/// traps do not run: a proxy has no such property.
|
||||
/// The native slot `name` of `o`, or `undefined` when it has none.
|
||||
fn slot(i: &Interp, o: ObjId, name: &str) -> JsResult<Value> {
|
||||
Ok(match i.ordinary_own_property(o, &key(name))? {
|
||||
Some(Prop::Data { value, .. }) => value,
|
||||
Ok(match &i.object(o)?.class {
|
||||
Class::FsEntry(_, fields) => fields.get(&key(name)).cloned().unwrap_or(Value::Undefined),
|
||||
_ => Value::Undefined,
|
||||
})
|
||||
}
|
||||
|
||||
fn set_slot(i: &mut Interp, o: ObjId, name: &str, value: Value) -> JsResult<()> {
|
||||
if let Value::String(s) = &value {
|
||||
i.rooted(std::slice::from_ref(&value), |i| i.reserve_heap(PROP_BYTES + string_bytes(s.len())))?;
|
||||
/// The path of `id` when it is a `File` the `File` class made: its prototype is `File.prototype`
|
||||
/// and it holds its path in its [`Class::FsEntry`]. `None` for anything else, a `Folder` and an
|
||||
/// object made with `Object.create(File.prototype)` included.
|
||||
pub(crate) fn file_path(i: &Interp, id: ObjId) -> JsResult<Option<String>> {
|
||||
let Some(c) = &i.files else { return Ok(None) };
|
||||
let o = i.object(id)?;
|
||||
if o.proto != Some(c.file_proto) {
|
||||
return Ok(None);
|
||||
}
|
||||
i.define(o, key(name), Prop::Data { value, flags: HIDDEN })
|
||||
Ok(match own_path(i, id)? {
|
||||
Some(Value::String(s)) => Some(s.to_rust_string()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
fn set_slot(i: &mut Interp, o: ObjId, name: &str, value: Value) -> JsResult<()> {
|
||||
let Class::FsEntry(_, fields) = &i.object(o)?.class else {
|
||||
return Err(Abrupt::Internal("File slot on an object without native storage".into()));
|
||||
};
|
||||
let name = key(name);
|
||||
let added = if fields.contains(&name) { 0 } else { PROP_BYTES + string_bytes(name.len()) };
|
||||
i.rooted(&[Value::Object(o), value.clone()], |i| {
|
||||
i.reserve_heap(added)?;
|
||||
if let Class::FsEntry(_, fields) = &mut i.object_mut(o)?.class {
|
||||
fields.insert(name, value);
|
||||
i.heap.bytes = i.heap.bytes.saturating_add(added);
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
/// The object `this` and its path, or a `TypeError` naming `what` when it is not a `File` or
|
||||
@@ -245,8 +272,10 @@ fn instance(i: &mut Interp, proto: ObjId, fs: Value) -> JsResult<Value> {
|
||||
let Value::String(path) = fs.clone() else { return Err(i.type_error("File: the host gave no path")) };
|
||||
let line_feed = host_value(i, "lineFeed")?;
|
||||
i.rooted(&[fs, line_feed.clone()], |i| {
|
||||
i.reserve_heap(OBJECT_BYTES + 5 * PROP_BYTES + string_bytes(path.len()))?;
|
||||
let o = i.heap.alloc_object(Object::new(Class::FsEntry(path.clone()), Some(proto)));
|
||||
let storage = std::mem::size_of::<crate::heap::PropMap<Value>>();
|
||||
i.reserve_heap(OBJECT_BYTES + storage + string_bytes(path.len()))?;
|
||||
let o = i.heap.alloc_object(Object::new(Class::FsEntry(path.clone(), Box::default()), Some(proto)));
|
||||
i.heap.bytes = i.heap.bytes.saturating_add(storage);
|
||||
i.rooted(&[Value::Object(o)], |i| {
|
||||
set_slot(i, o, ERROR, Value::str(""))?;
|
||||
set_slot(i, o, HANDLE, Value::Number(-1.0))?;
|
||||
@@ -1426,6 +1455,75 @@ mod tests {
|
||||
assert_eq!(v.unwrap(), JsValue::String("x,/x,2,d/b,1".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn files_and_folders_localize_their_own_locale_properties() {
|
||||
let mut r = realm();
|
||||
r.add_script_extensions().unwrap();
|
||||
r.localization().set_locale("fr_FR");
|
||||
r.localization().set_enabled(true);
|
||||
let source = "var results = []; var constructors = [File, Folder];
|
||||
for (var n = 0; n < constructors.length; n++) {
|
||||
var C = constructors[n], f = new C('x'), hit = false;
|
||||
C.prototype.fr = 'inherited';
|
||||
results.push(localize(f) === f);
|
||||
f.en = 'English %1';
|
||||
Object.defineProperty(f, 'fr_FR', {get: function () { hit = true; return 'getter'; }, configurable: true});
|
||||
results.push(localize(f, 'text') === 'English text', !hit);
|
||||
f.fr = 'French %1';
|
||||
results.push(localize(f, 'text') === 'French text');
|
||||
results.push(Object.prototype.toString.call(f) === 'French %1');
|
||||
delete C.prototype.fr;
|
||||
}
|
||||
results.every(function (v) { return v; })";
|
||||
assert_eq!(r.run(source).unwrap(), JsValue::Bool(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn files_and_folders_copy_only_ordinary_own_properties() {
|
||||
let mut r = realm();
|
||||
let copy = HostItem::Function(Rc::new(|a: Vec<Data>| Ok(a.into_iter().next().unwrap_or(Data::Undefined))));
|
||||
r.define_host_object("host", vec![("copy".into(), copy)]).unwrap();
|
||||
let source = "var results = []; var constructors = [File, Folder];
|
||||
for (var n = 0; n < constructors.length; n++) {
|
||||
var C = constructors[n], f = new C('x');
|
||||
results.push(Object.getOwnPropertyNames(f).length === 0, Object.keys(f).length === 0);
|
||||
results.push(JSON.stringify(f) === '{}', typeof f === 'object', f instanceof C);
|
||||
results.push(Object.prototype.toString.call(f) === '[object Object]');
|
||||
f.label = 'public'; f.child = {values: [1, true]}; f.__vcPath = 'ordinary property';
|
||||
var plain = {label: 'public', child: {values: [1, true]}, __vcPath: 'ordinary property'};
|
||||
results.push(JSON.stringify(f) === JSON.stringify(plain));
|
||||
results.push(Object.keys(f).join() === Object.keys(plain).join());
|
||||
results.push(Object.getOwnPropertyNames(f).join() === Object.getOwnPropertyNames(plain).join());
|
||||
results.push(f.fsName === '/x', f.__vcPath === 'ordinary property', f.__vcHandle === undefined);
|
||||
var cloned = host.copy(f);
|
||||
results.push(JSON.stringify(cloned) === JSON.stringify(plain), cloned !== f, cloned.child !== f.child);
|
||||
results.push(Object.getPrototypeOf(cloned) === Object.prototype);
|
||||
}
|
||||
results.every(function (v) { return v; })";
|
||||
assert_eq!(r.run(source).unwrap(), JsValue::Bool(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_host_constructor_assigns_its_prototype_to_a_returned_file() {
|
||||
let mut r = realm();
|
||||
let make = Rc::new(|_: Vec<Data>| Ok(Data::Object(vec![(crate::FILE_REF_KEY.into(), Data::String("/x".into()))])));
|
||||
let copy = Rc::new(|a: Vec<Data>| Ok(a.get(1).cloned().unwrap_or(Data::Undefined)));
|
||||
let class = crate::HostClass {
|
||||
name: "ReturnedFile".into(),
|
||||
parent: None,
|
||||
members: vec![("copy".into(), crate::HostMember::Method(copy))],
|
||||
info: Vec::new(),
|
||||
index: None,
|
||||
construct: Some(make),
|
||||
};
|
||||
r.define_host_classes(vec![class], Vec::new()).unwrap();
|
||||
let source = "var f = new ReturnedFile(); f.own = 'kept'; var d = new Folder('x'); d.own = 'folder';
|
||||
f instanceof ReturnedFile && Object.getPrototypeOf(f) === ReturnedFile.prototype &&
|
||||
Object.keys(f).join() === 'own' && JSON.stringify(f) === '{\"own\":\"kept\"}' &&
|
||||
JSON.stringify(f.copy(f)) === '{\"own\":\"kept\"}' && f.copy(d) instanceof Folder && f.copy(d).fsName === d.fsName";
|
||||
assert_eq!(r.run(source).unwrap(), JsValue::Bool(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_constructor_picks_the_class_only_without_new() {
|
||||
let mut r = realm();
|
||||
|
||||
+20
-6
@@ -292,9 +292,9 @@ pub(crate) enum Class {
|
||||
ModuleNamespace(Box<ModuleExports>),
|
||||
/// An object of a class a host defined ([`crate::host_classes`]).
|
||||
Host(crate::host_classes::HostObj),
|
||||
/// A `File` or `Folder` ([`crate::file_classes`]) and its path in the host's platform form,
|
||||
/// which only the classes' own methods set.
|
||||
FsEntry(Str),
|
||||
/// A `File` or `Folder` ([`crate::file_classes`]): its path in the host's platform form and its
|
||||
/// other native slots, which only the classes' own methods set.
|
||||
FsEntry(Str, Box<PropMap<Value>>),
|
||||
/// A `UnitValue` object and its measurement ([`crate::unit_value`]).
|
||||
UnitValue(Box<crate::unit_value::Measure>),
|
||||
/// A promise (ECMA-262 11th edition, section 25.6) and its state.
|
||||
@@ -618,7 +618,7 @@ impl Class {
|
||||
Class::Ordinary
|
||||
| Class::ForIn(_)
|
||||
| Class::Host(_)
|
||||
| Class::FsEntry(_)
|
||||
| Class::FsEntry(..)
|
||||
| Class::Symbol(_)
|
||||
| Class::Iterator(_)
|
||||
| Class::IterRecord(_)
|
||||
@@ -1193,7 +1193,7 @@ fn trace_object(o: &Object, work: &mut Vec<u32>, strings: &mut StringSizes) -> u
|
||||
}
|
||||
extra = PROP_BYTES * exports.bindings.len();
|
||||
}
|
||||
Class::String(s) | Class::FsEntry(s) => strings.add(s),
|
||||
Class::String(s) => strings.add(s),
|
||||
Class::RegExp(re) => {
|
||||
if strings.seen.insert(Rc::as_ptr(re) as *const () as usize) {
|
||||
strings.bytes += re.heap_bytes();
|
||||
@@ -1291,8 +1291,22 @@ fn trace_object(o: &Object, work: &mut Vec<u32>, strings: &mut StringSizes) -> u
|
||||
}
|
||||
extra = std::mem::size_of::<PropMap<Value>>() + PROP_BYTES * fields.len();
|
||||
}
|
||||
Class::FsEntry(path, fields) => {
|
||||
strings.add(path);
|
||||
for (name, value) in fields.iter() {
|
||||
strings.add_key(name);
|
||||
mark_value(value, work, strings);
|
||||
}
|
||||
extra = std::mem::size_of::<PropMap<Value>>() + PROP_BYTES * fields.len();
|
||||
}
|
||||
Class::UnitValue(_) => extra = UNIT_VALUE_BYTES,
|
||||
Class::Host(h) => extra = crate::host_classes::handle_bytes(h.handle.len()),
|
||||
Class::Host(h) => {
|
||||
for (_, file, _) in &h.files {
|
||||
mark_value(file, work, strings);
|
||||
}
|
||||
extra = crate::host_classes::handle_bytes(h.handle.len())
|
||||
+ h.files.iter().map(|(name, _, path)| PROP_BYTES + name.len() + path.len()).sum::<usize>();
|
||||
}
|
||||
Class::Promise(p) => {
|
||||
for v in p.values() {
|
||||
mark_value(&v, work, strings);
|
||||
|
||||
+151
-7
@@ -119,6 +119,16 @@ pub(crate) enum ArgRead {
|
||||
/// [`Data`], objects of host classes in them as [`crate::host_ref`] gives them; the objects of
|
||||
/// host classes in the result are made from theirs.
|
||||
Hosted,
|
||||
/// A read of a host property whose reflected type is `File`.
|
||||
HostedFileGet,
|
||||
/// An assignment to a host property whose reflected type is `File`.
|
||||
HostedFileSet,
|
||||
}
|
||||
|
||||
impl ArgRead {
|
||||
fn hosted(&self) -> bool {
|
||||
matches!(self, Self::Hosted | Self::HostedFileGet | Self::HostedFileSet)
|
||||
}
|
||||
}
|
||||
|
||||
/// A member of an object the host adds to the global environment.
|
||||
@@ -291,7 +301,7 @@ impl Interp {
|
||||
Class::Host(_) if r.hosted => return self.read_host_ref(id, r),
|
||||
Class::Host(_) => return Err(self.data_error(r, ErrorType::Type, "is an object of a host class, not plain data")),
|
||||
Class::Array { length, .. } => Shape::Array(*length),
|
||||
Class::Ordinary | Class::FsEntry(_) => {
|
||||
Class::Ordinary | Class::FsEntry(..) => {
|
||||
let o = self.object(id)?;
|
||||
if o.props.len() > r.limits.entries {
|
||||
return Err(self.data_error(r, ErrorType::Range, "has too many entries"));
|
||||
@@ -447,9 +457,23 @@ impl Interp {
|
||||
/// Calls host function `f`: reads its arguments as `how` says, runs it, and gives its result to
|
||||
/// the script.
|
||||
pub(crate) fn call_data(&mut self, f: &crate::heap::DataFn, name: &Rc<str>, this: &Value, args: &[Value], how: &ArgRead) -> JsResult<Value> {
|
||||
// The receiver and the arguments may be held only here (an `apply` of an array-like): they
|
||||
// stay rooted while the files sync, the host runs and the assigned File is kept.
|
||||
let mark = self.temp_roots.len();
|
||||
self.temp_roots.push(this.clone());
|
||||
self.temp_roots.extend(args.iter().cloned());
|
||||
let r = self.call_data_rooted(f, name, this, args, how);
|
||||
self.temp_roots.truncate(mark);
|
||||
r
|
||||
}
|
||||
|
||||
fn call_data_rooted(&mut self, f: &crate::heap::DataFn, name: &Rc<str>, this: &Value, args: &[Value], how: &ArgRead) -> JsResult<Value> {
|
||||
if how.hosted() {
|
||||
self.sync_host_files()?;
|
||||
}
|
||||
let data = match how {
|
||||
ArgRead::Site => site_data(self.call_site()),
|
||||
ArgRead::Hosted => self.read_args(name, Some(this), args, how)?,
|
||||
how if how.hosted() => self.read_args(name, Some(this), args, how)?,
|
||||
_ => self.read_args(name, None, args, how)?,
|
||||
};
|
||||
// Only the script's own code, in a run that can pause, can wait for a result, and a host
|
||||
@@ -458,12 +482,37 @@ impl Interp {
|
||||
self.can_wait.set(can_wait);
|
||||
let result = f(data);
|
||||
self.can_wait.set(false);
|
||||
if result.is_ok()
|
||||
&& let Some(id) = this.as_object()
|
||||
{
|
||||
if matches!(how, ArgRead::HostedFileSet) {
|
||||
let file = args.first().cloned().unwrap_or(Value::Undefined);
|
||||
self.keep_host_file(id, name.clone(), file)?;
|
||||
} else if matches!(how, ArgRead::HostedFileGet)
|
||||
&& let Class::Host(h) = &self.object(id)?.class
|
||||
&& let Some((_, file, kept)) = h.files.iter().find(|(n, _, _)| n == name)
|
||||
&& let Ok(d) = &result
|
||||
{
|
||||
// The assigned File keeps its identity while the getter still names its file;
|
||||
// otherwise the host changed the property, and the getter's value is given.
|
||||
let (file, kept, d) = (file.clone(), kept.clone(), d.clone());
|
||||
let (same, got) = self.names_file(d, &kept)?;
|
||||
if same {
|
||||
return Ok(file);
|
||||
}
|
||||
self.keep_host_file(id, name.clone(), Value::Undefined)?;
|
||||
return match got {
|
||||
Some(got) => Ok(got),
|
||||
None => Ok(Value::Undefined),
|
||||
};
|
||||
}
|
||||
}
|
||||
match result {
|
||||
Ok(d) if matches!(how, ArgRead::Hosted) => self.write_hosted(d),
|
||||
Ok(d) if how.hosted() => self.write_hosted(d),
|
||||
Ok(d) => self.write_data(d, 0, matches!(how, ArgRead::Frozen)),
|
||||
Err(HostError::Wait) if can_wait => {
|
||||
self.waiting = true;
|
||||
self.waiting_hosted = matches!(how, ArgRead::Hosted);
|
||||
self.waiting_hosted = how.hosted();
|
||||
self.pause.set(true);
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
@@ -472,6 +521,95 @@ impl Interp {
|
||||
}
|
||||
}
|
||||
|
||||
fn keep_host_file(&mut self, id: ObjId, name: Rc<str>, file: Value) -> JsResult<()> {
|
||||
let path = match file.as_object() {
|
||||
Some(file) => crate::file_classes::file_path(self, file)?,
|
||||
None => None,
|
||||
};
|
||||
let Class::Host(h) = &self.object(id)?.class else { return Ok(()) };
|
||||
let before = h.files.iter().find(|(n, _, _)| n == &name).map_or(0, |(n, _, p)| PROP_BYTES + n.len() + p.len());
|
||||
let after = path.as_ref().map_or(0, |p| PROP_BYTES + name.len() + p.len());
|
||||
if after > before {
|
||||
self.reserve_heap(after - before)?;
|
||||
}
|
||||
self.heap.bytes = self.heap.bytes.saturating_sub(before).saturating_add(after);
|
||||
if let Class::Host(h) = &mut self.object_mut(id)?.class {
|
||||
h.files.retain(|(n, _, _)| n != &name);
|
||||
if let Some(path) = path {
|
||||
h.files.push((name, file, path));
|
||||
}
|
||||
}
|
||||
if after > 0 && !self.host_file_objects.contains(&id) {
|
||||
self.host_file_objects.push(id);
|
||||
} else if after == 0 && matches!(&self.object(id)?.class, Class::Host(h) if h.files.is_empty()) {
|
||||
self.host_file_objects.retain(|&kept| kept != id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Whether the host's value `d` is a File for `path`, compared as the File the script receives
|
||||
/// for it; with the File made to compare it, when one was made.
|
||||
fn names_file(&mut self, d: Data, path: &str) -> JsResult<(bool, Option<Value>)> {
|
||||
if crate::file_ref_path(&d) == Some(path) {
|
||||
return Ok((true, None));
|
||||
}
|
||||
let got = self.write_hosted(d)?;
|
||||
let same = match got.as_object() {
|
||||
Some(g) => crate::file_classes::file_path(self, g)?.as_deref() == Some(path),
|
||||
None => false,
|
||||
};
|
||||
Ok((same, Some(got)))
|
||||
}
|
||||
|
||||
pub(crate) fn sync_host_files(&mut self) -> JsResult<()> {
|
||||
let mut updates = Vec::new();
|
||||
for id in self.host_file_objects.clone() {
|
||||
self.use_fuel()?;
|
||||
let Some(object) = self.heap.object(id) else { continue };
|
||||
let Class::Host(h) = &object.class else { continue };
|
||||
let class = h.class;
|
||||
for (name, file, previous) in &h.files {
|
||||
let Some(file_id) = file.as_object() else { continue };
|
||||
if crate::file_classes::file_path(self, file_id)?.as_ref() != Some(previous)
|
||||
&& let Some((get, set)) = self.file_accessors(class, name)
|
||||
{
|
||||
updates.push((id, name.clone(), file.clone(), previous.clone(), get, set));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (id, name, file, previous, get, set) in updates {
|
||||
self.use_fuel()?;
|
||||
// A property the host changed since the assignment no longer holds this File: it is
|
||||
// not tracked any more, and the host's value stays.
|
||||
let this = self.read_args(&name, Some(&Value::Object(id)), &[], &ArgRead::Hosted)?;
|
||||
let same = match get(this) {
|
||||
Ok(d) => self.names_file(d, &previous).map(|(same, _)| same),
|
||||
Err(error) => Err(self.host_error(error).unwrap_or_else(|e| e)),
|
||||
};
|
||||
match same {
|
||||
Ok(true) => {}
|
||||
Ok(false) => {
|
||||
self.keep_host_file(id, name, Value::Undefined)?;
|
||||
continue;
|
||||
}
|
||||
Err(e) => {
|
||||
// A getter that fails stops tracking too, so the error is thrown once.
|
||||
self.keep_host_file(id, name, Value::Undefined)?;
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
let data = self.read_args(&name, Some(&Value::Object(id)), std::slice::from_ref(&file), &ArgRead::Hosted)?;
|
||||
if let Err(error) = set(data) {
|
||||
// The host refused the new path: the File is no longer tracked, so the error is
|
||||
// thrown once and a later assignment can replace it.
|
||||
self.keep_host_file(id, name, Value::Undefined)?;
|
||||
return Err(self.host_error(error)?);
|
||||
}
|
||||
self.keep_host_file(id, name, file)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Where the innermost frame of the script's code is: its source's tag and the line and column
|
||||
/// of the instruction it is running.
|
||||
fn call_site(&self) -> CallSite {
|
||||
@@ -559,7 +697,7 @@ impl Interp {
|
||||
ancestors: Vec::new(),
|
||||
path: Vec::new(),
|
||||
function: name.clone(),
|
||||
hosted: matches!(how, ArgRead::Hosted),
|
||||
hosted: how.hosted(),
|
||||
};
|
||||
let args = match how {
|
||||
ArgRead::Each(list) => args.get(..list.len().min(args.len())).unwrap_or(args),
|
||||
@@ -575,14 +713,20 @@ impl Interp {
|
||||
}
|
||||
// A conversion can run the script's own `toString`, which may collect garbage.
|
||||
let mark = self.temp_roots.len();
|
||||
if !matches!(how, ArgRead::Data | ArgRead::DataWithin(_) | ArgRead::Frozen | ArgRead::Hosted) {
|
||||
if !matches!(how, ArgRead::Data | ArgRead::DataWithin(_) | ArgRead::Frozen) && !how.hosted() {
|
||||
self.temp_roots.extend(args.iter().cloned());
|
||||
}
|
||||
let mut read = Ok(());
|
||||
for (i, a) in args.iter().enumerate() {
|
||||
reading.path.push(Step::Index(u32::try_from(i).unwrap_or(u32::MAX)));
|
||||
let d = match how {
|
||||
ArgRead::Data | ArgRead::DataWithin(_) | ArgRead::Frozen | ArgRead::Site | ArgRead::Hosted => self.read_data(a, &mut reading),
|
||||
ArgRead::Data
|
||||
| ArgRead::DataWithin(_)
|
||||
| ArgRead::Frozen
|
||||
| ArgRead::Site
|
||||
| ArgRead::Hosted
|
||||
| ArgRead::HostedFileGet
|
||||
| ArgRead::HostedFileSet => self.read_data(a, &mut reading),
|
||||
ArgRead::Text => self.read_text(a, &mut reading),
|
||||
ArgRead::Each(list) => match list.get(i) {
|
||||
Some(Arg::TextOrUndefined) if matches!(a, Value::Undefined) => Ok(Data::Undefined),
|
||||
|
||||
@@ -125,6 +125,8 @@ pub struct HostClass {
|
||||
pub(crate) struct HostObj {
|
||||
pub(crate) class: u32,
|
||||
pub(crate) handle: Rc<[f64]>,
|
||||
/// The assigned File objects and the paths last sent to their setters.
|
||||
pub(crate) files: Vec<(Rc<str>, Value, String)>,
|
||||
}
|
||||
|
||||
/// The estimated bytes an object of a host class holds beyond [`crate::heap::OBJECT_BYTES`] for a
|
||||
@@ -153,6 +155,8 @@ pub(crate) struct Entry {
|
||||
own: Rc<HashMap<Key, bool>>,
|
||||
/// The class's own members as `reflect` lists them.
|
||||
members: Rc<[Reflected]>,
|
||||
/// The getter and setter of each File property the class declares, by `Class.member`.
|
||||
pub(crate) file_setters: Vec<(Rc<str>, HostFunction, HostFunction)>,
|
||||
}
|
||||
|
||||
/// How a script may use a member of a host class.
|
||||
@@ -249,6 +253,20 @@ pub fn host_ref_parts(d: &Data) -> Option<(&str, Vec<f64>)> {
|
||||
}
|
||||
|
||||
impl Interp {
|
||||
/// The getter and setter of File property `name` (`Class.member`) of `class` or of a class it
|
||||
/// descends from.
|
||||
pub(crate) fn file_accessors(&self, class: u32, name: &str) -> Option<(HostFunction, HostFunction)> {
|
||||
let mut at = Some(class);
|
||||
for _ in 0..=self.host_classes.len() {
|
||||
let entry = self.host_classes.get(at? as usize)?;
|
||||
if let Some((_, get, set)) = entry.file_setters.iter().find(|(n, _, _)| &**n == name) {
|
||||
return Some((get.clone(), set.clone()));
|
||||
}
|
||||
at = entry.parent;
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Whether `k` is a member that `hasOwnProperty` reports on `id`: `id` is an object of a host
|
||||
/// class, and the closest of that class and the classes it descends from that declares `k`
|
||||
/// declares it as available.
|
||||
@@ -340,7 +358,7 @@ impl Interp {
|
||||
}
|
||||
let extra = handle_bytes(handle.len());
|
||||
self.reserve_heap(crate::heap::OBJECT_BYTES.saturating_add(extra))?;
|
||||
let mut o = Object::new(Class::Host(HostObj { class, handle: handle.into() }), Some(proto));
|
||||
let mut o = Object::new(Class::Host(HostObj { class, handle: handle.into(), files: Vec::new() }), Some(proto));
|
||||
o.extensible = false;
|
||||
let id = self.heap.alloc_object(o);
|
||||
self.heap.bytes = self.heap.bytes.saturating_add(extra);
|
||||
@@ -414,6 +432,13 @@ impl Interp {
|
||||
if self.host_ref_size(id)?.is_none() {
|
||||
return Ok(Value::Undefined);
|
||||
}
|
||||
// The host reads File properties as the script left them, as it does for a method call. The
|
||||
// receiver may be held only here, so it stays rooted while the files sync.
|
||||
let mark = self.temp_roots.len();
|
||||
self.temp_roots.push(Value::Object(id));
|
||||
let synced = self.sync_host_files();
|
||||
self.temp_roots.truncate(mark);
|
||||
synced?;
|
||||
let args = self.read_index_args(id, k, probe)?;
|
||||
match f(args) {
|
||||
Ok(d) => self.write_hosted(d),
|
||||
@@ -632,6 +657,17 @@ fn install_class(i: &mut Interp, class: HostClass, members: Rc<[Reflected]>, und
|
||||
parent: parent_class,
|
||||
own: Rc::new(own),
|
||||
members,
|
||||
file_setters: class
|
||||
.members
|
||||
.iter()
|
||||
.filter_map(|(name, member)| {
|
||||
let HostMember::Property { get, set } = member else { return None };
|
||||
if !class.info.iter().any(|(n, info)| n == name && info.data_type == "File") {
|
||||
return None;
|
||||
}
|
||||
Some((format!("{}.{name}", class.name).into(), get.clone(), set.clone()))
|
||||
})
|
||||
.collect(),
|
||||
});
|
||||
// The host class named `Symbol` keeps the built-in `Symbol` global. Its objects use the host prototype.
|
||||
let global = i.global;
|
||||
@@ -684,9 +720,11 @@ fn fill_class(i: &mut Interp, proto: ObjId, class: &HostClass) -> JsResult<ObjId
|
||||
let prop = match member {
|
||||
HostMember::Get(f) => Prop::Accessor { get: Some(hosted_function(i, f.clone(), &full)), set: None, flags: ENUMERABLE },
|
||||
HostMember::Property { get, set } => {
|
||||
let get = hosted_function(i, get.clone(), &full);
|
||||
let file = class.info.iter().any(|(n, info)| n == name && info.data_type == "File");
|
||||
let get = hosted_function_read(i, get.clone(), &full, if file { ArgRead::HostedFileGet } else { ArgRead::Hosted });
|
||||
i.temp_roots.push(Value::Object(get));
|
||||
Prop::Accessor { get: Some(get), set: Some(hosted_function(i, set.clone(), &full)), flags: ENUMERABLE }
|
||||
let set = hosted_function_read(i, set.clone(), &full, if file { ArgRead::HostedFileSet } else { ArgRead::Hosted });
|
||||
Prop::Accessor { get: Some(get), set: Some(set), flags: ENUMERABLE }
|
||||
}
|
||||
HostMember::Method(f) => Prop::Data { value: Value::Object(hosted_function(i, f.clone(), &full)), flags: 0 },
|
||||
HostMember::Unavailable(f) => {
|
||||
@@ -709,6 +747,10 @@ fn fill_class(i: &mut Interp, proto: ObjId, class: &HostClass) -> JsResult<ObjId
|
||||
}
|
||||
|
||||
fn hosted_function(i: &mut Interp, f: HostFunction, name: &str) -> ObjId {
|
||||
let proto = i.intrinsics.function_proto;
|
||||
i.heap.alloc_object(Object::new(Class::Function(Func::Data { f, name: name.into(), read: ArgRead::Hosted }), Some(proto)))
|
||||
hosted_function_read(i, f, name, ArgRead::Hosted)
|
||||
}
|
||||
|
||||
fn hosted_function_read(i: &mut Interp, f: HostFunction, name: &str, read: ArgRead) -> ObjId {
|
||||
let proto = i.intrinsics.function_proto;
|
||||
i.heap.alloc_object(Object::new(Class::Function(Func::Data { f, name: name.into(), read }), Some(proto)))
|
||||
}
|
||||
|
||||
@@ -1577,3 +1577,108 @@ proptest::proptest! {
|
||||
proptest::prop_assert!(matches!(out.as_str(), "ok" | "RangeError" | "TypeError"), "{}", out);
|
||||
}
|
||||
}
|
||||
|
||||
/// A realm whose global `it` is a `Child` that inherits the File property `file` from `Base`. The
|
||||
/// setter records each path it is given and refuses one containing `bad`; `clear()` sets the
|
||||
/// property to null and `touch()` does nothing.
|
||||
fn file_property_realm() -> (Realm, Rc<RefCell<Vec<String>>>) {
|
||||
file_property_realm_indexed(false)
|
||||
}
|
||||
|
||||
/// [`file_property_realm`], with an indexer on `Child` when `indexed` that gives the last path the
|
||||
/// setter was given when it is called.
|
||||
fn file_property_realm_indexed(indexed: bool) -> (Realm, Rc<RefCell<Vec<String>>>) {
|
||||
let mut r = realm(10_000_000);
|
||||
let parse: HostFunction = Rc::new(|a| {
|
||||
let fs = match a.first() {
|
||||
Some(Data::String(s)) => s.clone(),
|
||||
_ => String::new(),
|
||||
};
|
||||
let name = fs.trim_start_matches('/').to_string();
|
||||
let fields = [("fs", fs.clone()), ("uri", fs), ("name", name.clone()), ("display", name), ("path", "/".into()), ("parent", "/".into())];
|
||||
Ok(Data::Object(fields.into_iter().map(|(k, v)| (k.to_string(), Data::String(v))).collect()))
|
||||
});
|
||||
let messages = ["notOpen", "badMode"].map(|k| (k.to_string(), HostItem::Value(Data::String(k.into()))));
|
||||
r.define_file_classes(vec![
|
||||
("text".into(), HostItem::Object(messages.to_vec())),
|
||||
("current".into(), HostItem::Function(Rc::new(|_| Ok(Data::String("/".into()))))),
|
||||
("parse".into(), HostItem::Function(parse)),
|
||||
])
|
||||
.unwrap();
|
||||
let stored = Rc::new(RefCell::new(Data::Null));
|
||||
let seen = Rc::new(RefCell::new(Vec::new()));
|
||||
let (get_stored, set_stored, clear_stored) = (stored.clone(), stored.clone(), stored);
|
||||
let log = seen.clone();
|
||||
let get: HostFunction = Rc::new(move |_| Ok(get_stored.borrow().clone()));
|
||||
let set: HostFunction = Rc::new(move |args| {
|
||||
let path = args.last().and_then(file_ref_path).unwrap_or("?").to_string();
|
||||
if path.contains("bad") {
|
||||
return Err(HostError::Error(format!("{path} is refused")));
|
||||
}
|
||||
log.borrow_mut().push(path.clone());
|
||||
*set_stored.borrow_mut() = file_ref(&path);
|
||||
Ok(Data::Undefined)
|
||||
});
|
||||
let clear: HostFunction = Rc::new(move |_| {
|
||||
*clear_stored.borrow_mut() = Data::Null;
|
||||
Ok(Data::Undefined)
|
||||
});
|
||||
let info = MemberInfo { data_type: "File".into(), ..MemberInfo::default() };
|
||||
let base = HostClass {
|
||||
name: "Base".into(),
|
||||
parent: None,
|
||||
members: vec![
|
||||
("file".into(), HostMember::Property { get, set }),
|
||||
("clear".into(), HostMember::Method(clear)),
|
||||
("touch".into(), HostMember::Method(Rc::new(|_| Ok(Data::Undefined)))),
|
||||
],
|
||||
info: vec![("file".into(), info)],
|
||||
index: None,
|
||||
construct: None,
|
||||
};
|
||||
let last = seen.clone();
|
||||
let index: Option<HostFunction> =
|
||||
indexed.then(|| -> HostFunction { Rc::new(move |_| Ok(last.borrow().last().map_or(Data::Null, |p| Data::String(p.clone())))) });
|
||||
let child = HostClass { name: "Child".into(), parent: Some("Base".into()), members: vec![], info: Vec::new(), index, construct: None };
|
||||
r.define_host_classes(vec![base, child], vec![("it".into(), host_ref("Child", &[1.0]))]).unwrap();
|
||||
(r, seen)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_inherited_file_property_follows_its_files_new_path() {
|
||||
let (mut r, seen) = file_property_realm();
|
||||
r.run("var f = new File('/a'); it.file = f; f.changePath('/b'); it.touch();").unwrap();
|
||||
assert_eq!(*seen.borrow(), ["/a", "/b"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_indexed_read_follows_a_file_propertys_new_path() {
|
||||
let (mut r, seen) = file_property_realm_indexed(true);
|
||||
assert_eq!(r.run("var f = new File('/a'); it.file = f; f.changePath('/b'); it[0]").unwrap(), JsValue::String("/b".into()));
|
||||
assert_eq!(*seen.borrow(), ["/a", "/b"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_getter_gives_its_own_value_once_the_host_changes_a_file_property() {
|
||||
let (mut r, _) = file_property_realm();
|
||||
let source = "var f = new File('/a'); it.file = f; var same = it.file === f; it.clear(); [same, it.file === null].join('|')";
|
||||
assert_eq!(r.run(source).unwrap(), JsValue::String("true|true".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_path_change_does_not_restore_a_property_the_host_cleared() {
|
||||
let (mut r, seen) = file_property_realm();
|
||||
let source = "var f = new File('/a'); it.file = f; it.clear(); f.changePath('/b'); it.touch(); it.file === null";
|
||||
assert_eq!(r.run(source).unwrap(), JsValue::Bool(true));
|
||||
assert_eq!(*seen.borrow(), ["/a"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_refused_path_change_is_thrown_once() {
|
||||
let (mut r, seen) = file_property_realm();
|
||||
let source = "var f = new File('/a'); it.file = f; f.changePath('/bad'); var first = 'none'; try { it.touch(); } catch (e) { first = e.message; }\n\
|
||||
it.touch(); it.file = new File('/good'); first";
|
||||
let JsValue::String(first) = r.run(source).unwrap() else { panic!("not a string") };
|
||||
assert!(first.contains("refused"), "{first}");
|
||||
assert_eq!(*seen.borrow(), ["/a", "/good"]);
|
||||
}
|
||||
|
||||
@@ -399,6 +399,8 @@ pub(crate) struct Interp {
|
||||
/// the same one give the same object. It is not a root: an object that was collected is dropped
|
||||
/// after each collection.
|
||||
pub(crate) host_objects: crate::host_classes::Made,
|
||||
/// Host objects with assigned Files stay reachable until the next script run.
|
||||
pub(crate) host_file_objects: Vec<ObjId>,
|
||||
/// `UnitValue`, once a host has added it ([`crate::Realm::add_unit_values`]). Until then the
|
||||
/// operators take no object as a measurement.
|
||||
pub(crate) unit_values: Option<crate::unit_value::Classes>,
|
||||
@@ -822,6 +824,7 @@ impl Interp {
|
||||
host_classes: Vec::new(),
|
||||
write_hosted: false,
|
||||
host_objects: crate::host_classes::Made::default(),
|
||||
host_file_objects: Vec::new(),
|
||||
unit_values: None,
|
||||
date_host: crate::date_builtins::DateHost::default(),
|
||||
held: Rc::default(),
|
||||
@@ -1110,6 +1113,7 @@ impl Interp {
|
||||
roots.objects.extend(self.script_ui.iter().flat_map(crate::scriptui::Classes::objects));
|
||||
roots.objects.extend(self.xmp.iter().flat_map(crate::xmp_classes::Classes::objects));
|
||||
roots.objects.extend(self.host_classes.iter().flat_map(crate::host_classes::Entry::objects));
|
||||
roots.objects.extend(self.host_file_objects.iter().copied());
|
||||
roots.values.extend(self.symbols.root_values());
|
||||
roots.objects.extend(self.symbols.root_objects());
|
||||
roots.objects.extend(self.unit_values.iter().map(crate::unit_value::Classes::object));
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use crate::bytecode::CodeKind;
|
||||
use crate::heap::{Func, HIDDEN, Object, Prop, key};
|
||||
use crate::heap::{Class, Func, HIDDEN, Object, Prop, key};
|
||||
use crate::interp::{Abrupt, CompileError, Interp};
|
||||
use crate::module::{LinkFail, ModuleLimits, ModuleLoader};
|
||||
use crate::value::Value;
|
||||
@@ -865,6 +865,11 @@ impl Realm {
|
||||
pub fn reset_folder_current(&mut self) -> Result<(), RunError> {
|
||||
self.interp.last_thrown = Value::Undefined;
|
||||
self.interp.last_error = Value::Null;
|
||||
for id in std::mem::take(&mut self.interp.host_file_objects) {
|
||||
if let Class::Host(host) = &mut self.interp.object_mut(id).map_err(|_| internal_error("missing host file object"))?.class {
|
||||
host.files.clear();
|
||||
}
|
||||
}
|
||||
match crate::file_classes::reset_current(&mut self.interp) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(e) => self.outcome(Err(e)).map(drop),
|
||||
|
||||
@@ -443,6 +443,18 @@ pub fn print_regions(doc: &Document, set: &PrintSettings) -> Result<Vec<(Option<
|
||||
layout::regions(&printed_document(doc, set), set)
|
||||
}
|
||||
|
||||
/// The scale `set` prints the region `r` of `printed` (a document as [`printed_document`] gives
|
||||
/// it, `r` one of [`print_regions`]) at on paper (1 = 100%): its horizontal and vertical scales,
|
||||
/// with Fit to Page worked out for that region. `None` when it prints on no page.
|
||||
pub fn print_region_scale(printed: &Document, set: &PrintSettings, r: kurbo::Rect) -> Option<(f64, f64)> {
|
||||
layout::region_scale(printed, set, r)
|
||||
}
|
||||
|
||||
/// Is there art that prints in `r` of `printed`, a document as [`printed_document`] gives it?
|
||||
pub fn prints_art_in(printed: &Document, r: kurbo::Rect) -> bool {
|
||||
layout::has_art(printed, r)
|
||||
}
|
||||
|
||||
impl<'a> Job<'a> {
|
||||
fn new(doc: &'a Document, set: &PrintSettings, postscript: bool) -> Result<Self, PdfError> {
|
||||
set.check()?;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
use kurbo::{Affine, Rect, Vec2};
|
||||
use serde::Serialize;
|
||||
use vectorcraft_doc::marks::outset;
|
||||
use vectorcraft_doc::marks::{PrinterMarks, outset};
|
||||
use vectorcraft_doc::range::parse_range;
|
||||
use vectorcraft_doc::{Document, Node, NodeKind, SymbolBoxes};
|
||||
|
||||
@@ -96,7 +96,7 @@ fn printed(n: &Node, symbols: &SymbolBoxes, f: &mut impl FnMut(Rect)) {
|
||||
|
||||
/// Is there art that prints in `r`? The box of a symbol instance whose art holds brushed strokes
|
||||
/// grows by as far as their brush art can paint ([`SymbolBoxes::with_brush_art`]).
|
||||
fn has_art(doc: &Document, r: Rect) -> bool {
|
||||
pub(crate) fn has_art(doc: &Document, r: Rect) -> bool {
|
||||
let symbols = doc.symbol_boxes().with_brush_art();
|
||||
let mut any = false;
|
||||
for l in &doc.layers {
|
||||
@@ -183,6 +183,56 @@ fn turns(set: &PrintSettings, (w, h): (f64, f64), flipped: bool) -> (Affine, (f6
|
||||
(v, (w, h))
|
||||
}
|
||||
|
||||
/// The bleed at scale `s` and how far it and the marks reach around the artboard,
|
||||
/// `[top, bottom, left, right]` each.
|
||||
fn reach_around(marks: &PrinterMarks, bleed: [f64; 4], s: (f64, f64)) -> ([f64; 4], [f64; 4]) {
|
||||
let b = scaled(bleed, s);
|
||||
let reach = marks.reach(b);
|
||||
(b, std::array::from_fn::<f64, 4, _>(|i| b[i].max(reach[i])))
|
||||
}
|
||||
|
||||
/// The horizontal and vertical scale `set` prints the artboard `r` at on `imageable` (1 = 100%);
|
||||
/// `None` when Fit to Page finds no scale at which it fits with its bleed and marks.
|
||||
fn print_scale(set: &PrintSettings, marks: &PrinterMarks, bleed: [f64; 4], imageable: Rect, r: Rect) -> Option<(f64, f64)> {
|
||||
match set.scaling {
|
||||
PrintScaling::None => Some((1.0, 1.0)),
|
||||
PrintScaling::Fit => {
|
||||
// The largest scale whose artboard with its bleed and marks fits: the marks reach
|
||||
// further when a larger scale grows the bleed.
|
||||
let fit = |s: f64| {
|
||||
let (_, most) = reach_around(marks, bleed, (s, s));
|
||||
((imageable.width() - most[2] - most[3]) / r.width()).min((imageable.height() - most[0] - most[1]) / r.height())
|
||||
};
|
||||
let first = fit(1.0);
|
||||
let s = if first <= 1.0 { first } else { fit(first) };
|
||||
(s.is_finite() && s > 0.0).then_some((s, s))
|
||||
}
|
||||
_ => Some((set.scale.width / 100.0, set.scale.height / 100.0)),
|
||||
}
|
||||
}
|
||||
|
||||
/// The scale `set` prints the region `r` of `doc` at (1 = 100%), as [`layout`] works it out,
|
||||
/// without laying out its pages: the horizontal and vertical scales. `None` for a
|
||||
/// region with no area, a margin that leaves no imageable area, or art that doesn't fit.
|
||||
pub(crate) fn region_scale(doc: &Document, set: &PrintSettings, r: Rect) -> Option<(f64, f64)> {
|
||||
if !(r.width() > 0.0 && r.height() > 0.0) {
|
||||
return None;
|
||||
}
|
||||
let (pw, ph) = set.paper();
|
||||
let landscape = match set.auto_rotate {
|
||||
true => (r.width() > r.height()) != (pw > ph),
|
||||
false => set.orientation.landscape(),
|
||||
};
|
||||
let paper = if landscape { (ph, pw) } else { (pw, ph) };
|
||||
let m = set.margin;
|
||||
let imageable = Rect::new(m, m, paper.0 - m, paper.1 - m);
|
||||
if imageable.width() < 1.0 || imageable.height() < 1.0 {
|
||||
return None;
|
||||
}
|
||||
let marks = crate::printer_marks(&set.marks);
|
||||
print_scale(set, &marks, crate::page_bleed(&set.bleed, doc), imageable, r)
|
||||
}
|
||||
|
||||
fn too_many_pages() -> PdfError {
|
||||
PdfError::BadSetting(format!("the job would print more than {} pages", super::MAX_PAGES))
|
||||
}
|
||||
@@ -222,31 +272,10 @@ pub(crate) fn layout(
|
||||
if imageable.width() < 1.0 || imageable.height() < 1.0 {
|
||||
return Err(PdfError::BadSetting(format!("margin: a {m} pt margin leaves no imageable area on the paper")));
|
||||
}
|
||||
// How far the bleed and marks reach around the artboard at scale `s`, `[top, bottom, left, right]`.
|
||||
let around = |s: (f64, f64)| {
|
||||
let b = scaled(bleed, s);
|
||||
let reach = marks.reach(b);
|
||||
(b, std::array::from_fn::<f64, 4, _>(|i| b[i].max(reach[i])))
|
||||
let Some(scale) = print_scale(set, &marks, bleed, imageable, r) else {
|
||||
return Err(PdfError::BadSetting(format!("{what} doesn't fit the paper with its bleed and marks")));
|
||||
};
|
||||
let scale = match set.scaling {
|
||||
PrintScaling::None => (1.0, 1.0),
|
||||
PrintScaling::Fit => {
|
||||
// The largest scale whose artboard with its bleed and marks fits: the marks reach
|
||||
// further when a larger scale grows the bleed.
|
||||
let fit = |s: f64| {
|
||||
let (_, most) = around((s, s));
|
||||
((imageable.width() - most[2] - most[3]) / r.width()).min((imageable.height() - most[0] - most[1]) / r.height())
|
||||
};
|
||||
let first = fit(1.0);
|
||||
let s = if first <= 1.0 { first } else { fit(first) };
|
||||
if !(s.is_finite() && s > 0.0) {
|
||||
return Err(PdfError::BadSetting(format!("{what} doesn't fit the paper with its bleed and marks")));
|
||||
}
|
||||
(s, s)
|
||||
}
|
||||
_ => (set.scale.width / 100.0, set.scale.height / 100.0),
|
||||
};
|
||||
let (bleed_s, most) = around(scale);
|
||||
let (bleed_s, most) = reach_around(&marks, bleed, scale);
|
||||
let size = (r.width() * scale.0, r.height() * scale.1);
|
||||
let extent = (most[2] + size.0 + most[3], most[0] + size.1 + most[1]);
|
||||
let flipped = !set.auto_rotate && orientation.flipped();
|
||||
|
||||
@@ -560,9 +560,13 @@ choice! {
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
pub struct PrintAdvanced {
|
||||
/// Composite pages print as one image each of the art, at the document's raster effects
|
||||
/// resolution (the app renders them before printing).
|
||||
/// Composite pages print as one image each of the art, at [`Self::bitmap_resolution`] (the
|
||||
/// app renders them before printing).
|
||||
pub print_as_bitmap: bool,
|
||||
/// The resolution Print as Bitmap renders at (ppi, 1–[`MAX_BITMAP_RESOLUTION`]); 0: the
|
||||
/// document's raster effects resolution. Other output leaves it unused.
|
||||
#[serde(skip_serializing_if = "is_zero")]
|
||||
pub bitmap_resolution: f64,
|
||||
pub overprints: PrintOverprints,
|
||||
/// The transparency flattener preset transparency is flattened with (a built-in or saved
|
||||
/// one, by name; the app flattens before printing). Empty: transparency prints live.
|
||||
@@ -583,9 +587,17 @@ pub struct TileOrigin {
|
||||
pub y: f64,
|
||||
}
|
||||
|
||||
/// Whether `v` is 0 (a field left at its default is not written).
|
||||
fn is_zero(v: &f64) -> bool {
|
||||
*v == 0.0
|
||||
}
|
||||
|
||||
/// Most copies of a job.
|
||||
pub const MAX_COPIES: u32 = 999;
|
||||
|
||||
/// The highest [`PrintAdvanced::bitmap_resolution`] (ppi).
|
||||
pub const MAX_BITMAP_RESOLUTION: f64 = 9600.0;
|
||||
|
||||
impl PrintSettings {
|
||||
/// Refuse values out of range (ranges and tile overlap are checked against the document when
|
||||
/// it prints).
|
||||
@@ -613,6 +625,9 @@ impl PrintSettings {
|
||||
self.marks.check()?;
|
||||
self.bleed.check()?;
|
||||
within("graphics.flatness", self.graphics.flatness, 0.2, 100.0, "")?;
|
||||
if self.advanced.bitmap_resolution != 0.0 {
|
||||
within("advanced.bitmapResolution", self.advanced.bitmap_resolution, 1.0, MAX_BITMAP_RESOLUTION, " ppi")?;
|
||||
}
|
||||
let profile = self.color.profile.trim();
|
||||
if !profile.is_empty() && cms::profile(profile).is_none_or(|p| p.kind == ProfileKind::Gray) {
|
||||
return Err(PdfError::BadSetting(format!("color.profile: no RGB or CMYK profile is called “{profile}”")));
|
||||
|
||||
@@ -537,7 +537,9 @@ impl Chain {
|
||||
|
||||
/// The index that ends the chain is of the member `name`, which a string literal in brackets
|
||||
/// named: `[]` becomes `.name` when one of [`catalog::DOM_DOCUMENTS`] reads that member as a
|
||||
/// property (`app['activeDocument']`, `app['documents'][0]`). Any other name keeps the index.
|
||||
/// property (`app['activeDocument']`, `app['documents'][0]`), and when `name` is a member every
|
||||
/// collection inherits or one the collection lists (`app.documents['length']`), so the index is
|
||||
/// not read as a lookup by name. Any other name keeps the index.
|
||||
fn name_index(&mut self, name: &str, cap: usize) {
|
||||
let Some(base) = self.path.strip_suffix("[]").filter(|_| !self.cut) else { return };
|
||||
let property = |d: &&str| {
|
||||
@@ -546,8 +548,11 @@ impl Chain {
|
||||
.and_then(|m| m.strip_prefix(name))
|
||||
.is_some_and(|rest| rest.is_empty() || rest.starts_with('.') || rest.starts_with('['))
|
||||
};
|
||||
let collection = base.rsplit('.').next().unwrap_or(base);
|
||||
let member = catalog::OBJECT_PROTOTYPE_MEMBERS.contains(&name)
|
||||
|| catalog::DOM_COLLECTIONS.iter().any(|(c, members)| collection == *c && members.contains(&name));
|
||||
let ident = !name.is_empty() && name.chars().all(|c| c.is_alphanumeric() || c == '_' || c == '$');
|
||||
if !ident || !catalog::DOM_DOCUMENTS.iter().any(property) {
|
||||
if !ident || !(member || catalog::DOM_DOCUMENTS.iter().any(property)) {
|
||||
return;
|
||||
}
|
||||
self.path.truncate(self.path.len() - 2);
|
||||
|
||||
@@ -110,6 +110,34 @@ pub(crate) const DOM_DOCUMENTS: &[&str] = &[
|
||||
"app.open()",
|
||||
];
|
||||
|
||||
// Every collection inherits these Object.prototype members (ECMA-262 3rd edition, section 15.2.4).
|
||||
pub(crate) const OBJECT_PROTOTYPE_MEMBERS: &[&str] =
|
||||
&["constructor", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable"];
|
||||
|
||||
// Each collection lists the members a string key names instead of looking up an item.
|
||||
// https://ai-scripting.docsforadobe.dev/jsobjref/Documents/ and the corresponding collection
|
||||
// pages list these properties and methods.
|
||||
pub(crate) const DOM_COLLECTIONS: &[(&str, &[&str])] = &[
|
||||
("artboards", &["add", "getActiveArtboardIndex", "getByName", "insert", "length", "parent", "remove", "setActiveArtboardIndex", "typename"]),
|
||||
("characterStyles", &["add", "getByName", "index", "length", "parent", "removeAll", "typename"]),
|
||||
("documents", &["add", "addDocument", "addDocumentNoUI", "getByName", "index", "length", "parent", "typename"]),
|
||||
("groupItems", &["add", "createFromFile", "getByName", "index", "length", "parent", "removeAll", "typename"]),
|
||||
("layers", &["add", "getByName", "index", "length", "parent", "removeAll", "typename"]),
|
||||
("pageItems", &["getByName", "index", "length", "parent", "removeAll", "typename"]),
|
||||
("paragraphStyles", &["add", "getByName", "index", "length", "parent", "removeAll", "typename"]),
|
||||
(
|
||||
"pathItems",
|
||||
&["add", "ellipse", "getByName", "index", "length", "parent", "polygon", "rectangle", "removeAll", "roundedRectangle", "star", "typename"],
|
||||
),
|
||||
("pathPoints", &["add", "index", "length", "parent", "removeAll", "typename"]),
|
||||
("stories", &["index", "length", "parent", "typename"]),
|
||||
("swatches", &["add", "getByName", "getSelected", "index", "length", "parent", "removeAll", "typename"]),
|
||||
("symbols", &["add", "getByName", "index", "length", "parent", "removeAll", "typename"]),
|
||||
("tags", &["add", "getByName", "index", "length", "parent", "removeAll", "typename"]),
|
||||
("textFrames", &["add", "areaText", "getByName", "index", "length", "parent", "pathText", "pointText", "removeAll", "typename"]),
|
||||
("views", &["index", "length", "parent", "typename"]),
|
||||
];
|
||||
|
||||
// The save option of `Document.close` that saves the document to its own file:
|
||||
// https://ai-scripting.docsforadobe.dev/jsobjref/Document/ and
|
||||
// https://ai-scripting.docsforadobe.dev/jsobjref/scripting-constants/ (SaveOptions).
|
||||
|
||||
@@ -67,10 +67,17 @@ const FEATURE_CASES: &[(&str, &str, &str)] = &[
|
||||
("file.objects", "var f = new File(path);", "var f = new Filer(path);"),
|
||||
("file.places", "var t = Folder.temp;", "var t = cache.temp;"),
|
||||
("file.read", "var f = new File(p); f.open('r');", "var f = new File(p);"),
|
||||
("file.read", "app.open(f);", "var f = app.open;"),
|
||||
("file.read", "app.open(f);", "cache.app.open(f);"),
|
||||
("file.read", "app.open(f);", "var app = cache; app.open(f);"),
|
||||
("file.read", "app['open'](f);", "var f = app['open'];"),
|
||||
("file.read", "app['open'](f);", "cache.app['open'](f);"),
|
||||
("file.read", "app['open'](f);", "var app = cache; app['open'](f);"),
|
||||
("file.read", "var f = new File(p); var s = f.read();", "var s = cache.read();"),
|
||||
("file.read", "var all = folder.getFiles();", "var all = folder.files;"),
|
||||
("file.read", "var s = File(p).read();", "var s = Cache(p).read();"),
|
||||
("file.write", "var f = new File(p); f.open('w');", "var f = new File(p); f.open('r');"),
|
||||
("file.write", "var app = new File(p); app.open('w');", "var app = new File(p); app.open('r');"),
|
||||
("file.write", "var f = File.saveDialog(); f.write(s);", "var f = picker(); f.write(s);"),
|
||||
("file.write", "new File(p).remove();", "new Thing(p).remove();"),
|
||||
("file.write", "var a = new File(p); var b = a; b.remove();", "var a = new File(p); var b = a.parent; b.remove();"),
|
||||
@@ -560,6 +567,7 @@ fn save_as_and_export_file_write_a_file() {
|
||||
"d.saveAs(f);\n",
|
||||
"app.activeDocument.exportFile(f, ExportType.PNG24);\n",
|
||||
));
|
||||
assert_eq!(feature(&r, "file.read").map(|f| f.lines.as_slice()), Some(&[2][..]));
|
||||
assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3, 4][..]));
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", &[3, 4][..])]);
|
||||
}
|
||||
@@ -748,6 +756,74 @@ fn print_writes_a_file() {
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", lines)]);
|
||||
}
|
||||
|
||||
/// A document reached with its member names in brackets prints to a file as one reached with dots
|
||||
/// does, and so does one a collection looks up by its name; a bracketed name that is not a
|
||||
/// document's member, and a computed one, do not. The report shows a member named in brackets
|
||||
/// after a dot.
|
||||
#[test]
|
||||
fn print_on_bracketed_document_chains_writes_a_file() {
|
||||
let r = report(concat!(
|
||||
"var o = new PrintOptions(); o.jobOptions.file = new File(p);\n",
|
||||
"app['activeDocument'].print(o);\n",
|
||||
"app[\"activeDocument\"][\"print\"](o);\n",
|
||||
"app[\"documents\"][0].print(o);\n",
|
||||
"app.documents['Draft'].print(o);\n",
|
||||
"app['preferences'].print(o);\n",
|
||||
"app[key].print(o);\n",
|
||||
"app['open'](new File(p));\n",
|
||||
"var d = app['activeDocument']; d.print(o);\n",
|
||||
"app.documents['getByName']('Draft').print(o);\n",
|
||||
"app['documents']['length'].print(o);\n",
|
||||
"var grouped = (app['activeDocument']); grouped.print(o);\n",
|
||||
"var scoped = app['activeDocument']; function f(scoped) {} scoped.print(o);\n",
|
||||
"var caught = app['activeDocument']; try {} catch (caught) {} caught.print(o);\n",
|
||||
"function later() { future.print(o); } var future = app['activeDocument'];\n",
|
||||
"app.documents['removeAll'].print(o);\n",
|
||||
"app['documents']['remove'].print(o);\n",
|
||||
"app.documents['addDocumentNoUI']('Print').print(o);\n",
|
||||
"app.documents['index'](0).print(o);\n",
|
||||
"app.documents['parent'].print(o); app.documents['typename'].print(o);\n",
|
||||
"app['documents']['toString'].print(o);\n",
|
||||
));
|
||||
let lines = &[2, 3, 4, 5, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19][..];
|
||||
assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(lines));
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", lines)]);
|
||||
assert_eq!(feature(&r, "file.read").map(|f| f.lines.as_slice()), Some(&[8][..]));
|
||||
assert!(r.members.iter().any(|m| m.name == "app.activeDocument.print()"));
|
||||
}
|
||||
|
||||
/// The document `app.open` returns prints to a file when `open` is named in brackets too, and the
|
||||
/// call reads the opened file.
|
||||
#[test]
|
||||
fn print_on_a_document_app_open_returns_writes_a_file() {
|
||||
let r = report(concat!(
|
||||
"var o = new PrintOptions(); o.jobOptions.file = new File(p);\n",
|
||||
"app['open'](new File(p)).print(o);\n",
|
||||
"app.open(new File(p))['print'](o);\n",
|
||||
"app[\"open\"](new File(p))[\"print\"](o);\n",
|
||||
));
|
||||
let lines = &[2, 3, 4][..];
|
||||
assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(lines));
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", lines)]);
|
||||
assert_eq!(feature(&r, "file.read").map(|f| f.lines.as_slice()), Some(lines));
|
||||
}
|
||||
|
||||
/// A bracketed document chain keeps its member names across scans and included files.
|
||||
#[test]
|
||||
fn print_on_bracketed_document_chains_in_included_files_writes_a_file() {
|
||||
for order in [["doc.jsxinc", "alias.jsxinc"], ["alias.jsxinc", "doc.jsxinc"]] {
|
||||
let mut m = mem(&[("doc.jsxinc", "var doc = app['activeDocument'];\n"), ("alias.jsxinc", "var alias = doc;\n")]);
|
||||
let main = format!("#include '{}'\n#include '{}'\ndoc.print(o);\nalias.print(o);\n", order[0], order[1]);
|
||||
let r = check("main.jsx", main.as_bytes(), Some(&mut m), &Limits::default());
|
||||
let lines = &[3, 4][..];
|
||||
assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(lines), "{order:?}");
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", lines)], "{order:?}");
|
||||
let mut members: Vec<&str> = r.members.iter().map(|m| m.name.as_str()).collect();
|
||||
members.sort_unstable();
|
||||
assert_eq!(members, ["app.activeDocument", "app.activeDocument.print()"], "{order:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A string literal in brackets that names `activeDocument` or `documents` reads that property, so the
|
||||
/// `print` of the document it gives writes a file; any other name in the brackets, a name that is not
|
||||
/// a property's, and a computed name do not give a document.
|
||||
|
||||
@@ -11,6 +11,7 @@ use craft::ui::docking::IconGroupSeparator;
|
||||
use craft::ui::list::{CommandHighlight, ThumbRows};
|
||||
use craft::ui::menu::{MenuTitleLook, MenuTitlePad};
|
||||
use craft::ui::patterns::form_dialogs::PresetCardLook;
|
||||
use craft::ui::runtime::drag::{self, OsFiles};
|
||||
use craft::ui::runtime::env::{AltCodeKeys, RootEnv, Scale, ScrubDrags, WindowKey, WordsOverride, with_env};
|
||||
use craft::ui::runtime::frame::{FrameInput, FrameOutput};
|
||||
use craft::ui::runtime::toast::{self, Toast};
|
||||
@@ -149,7 +150,6 @@ impl VectorcraftApp {
|
||||
spelling: Default::default(),
|
||||
text_nodes: Default::default(),
|
||||
momentary: None,
|
||||
momentary_keys: vec![],
|
||||
hand: None,
|
||||
zoom_tool: None,
|
||||
selection_box: None,
|
||||
@@ -368,18 +368,26 @@ impl VectorcraftApp {
|
||||
}
|
||||
|
||||
/// The folders this pass may read and write: the automation roots while the pass carries
|
||||
/// input the control channel injected, or delivers files the OS dropped in such a pass;
|
||||
/// anywhere otherwise.
|
||||
/// input the control channel injected, or while the drag session still holds files the OS
|
||||
/// dropped in such a pass; anywhere otherwise.
|
||||
fn automation_scope(&self, ctx: &egui::Context) -> Option<Arc<AutomationRoots>> {
|
||||
let delivers = self.confined_drop.is_some_and(|last| ctx.cumulative_frame_nr_for(egui::ViewportId::ROOT) <= last);
|
||||
(WindowHost::of(ctx).injected_pass() || delivers).then(|| self.automation_roots.clone()).flatten()
|
||||
(WindowHost::of(ctx).injected_pass() || self.confined_drop.is_some()).then(|| self.automation_roots.clone()).flatten()
|
||||
}
|
||||
|
||||
/// Notes files the OS dropped in a pass that carries injected input: the drag session delivers
|
||||
/// them in the next root frame, which [`Self::automation_scope`] confines too.
|
||||
/// Keeps the files the OS dropped in a pass that carries injected input until the drag session
|
||||
/// lets them go: it delivers them in a later pass, after their target is resolved, and
|
||||
/// [`Self::automation_scope`] confines every pass until then.
|
||||
fn note_confined_drop(&mut self, ctx: &egui::Context) {
|
||||
if self.automation_roots.is_none() {
|
||||
return;
|
||||
}
|
||||
let held = || drag::active::<OsFiles>(ctx);
|
||||
if WindowHost::of(ctx).injected_pass() && ctx.input(|i| !i.raw.dropped_files.is_empty()) {
|
||||
self.confined_drop = Some(ctx.cumulative_frame_nr_for(egui::ViewportId::ROOT) + 1);
|
||||
self.confined_drop = held();
|
||||
} else if let Some(dropped) = &self.confined_drop
|
||||
&& !held().is_some_and(|now| Arc::ptr_eq(&now, dropped))
|
||||
{
|
||||
self.confined_drop = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +81,6 @@ pub struct CanvasCache {
|
||||
/// The Hand, Zoom and Rotate View tools the Space key and its chords lend the canvas, between
|
||||
/// passes; the tool adapter takes it out for its call and puts it back.
|
||||
pub momentary: Option<craft::ui::canvas::Momentary>,
|
||||
/// The keys down when the held momentary command started; empty while none is held or when none started it.
|
||||
/// Temporary, with `tool_adapter::end_missed_momentary` (craft-libs#5056).
|
||||
pub momentary_keys: Vec<craft::keymap::Key>,
|
||||
pub hand: Option<craft::ui::canvas::HandTool>,
|
||||
/// The selected Zoom tool keeps its press and drag rectangle between canvas passes.
|
||||
pub zoom_tool: Option<craft::ui::canvas::ZoomTool>,
|
||||
|
||||
@@ -146,6 +146,8 @@ struct Body {
|
||||
edited: Option<CanvasView>,
|
||||
/// The Quick Pen tool took this pass's wheel for its arc size ([`quick_pen_wheel::arc_size`]).
|
||||
arc_view: Option<CanvasView>,
|
||||
/// What this pass's pan by whole device pixels left ([`pan_on_device_pixels`]).
|
||||
pan: Option<PanRest>,
|
||||
}
|
||||
|
||||
/// Window `win`'s document in the framework canvas, filling the rest of `ui`. True when the canvas
|
||||
@@ -184,6 +186,8 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
if refit && queued.is_empty() {
|
||||
queued.push(ViewRequest::Place(ViewCommands::FitArtboard));
|
||||
}
|
||||
// A view the app asks for this pass (a fit, a zoom command) keeps its exact center.
|
||||
let requested = !queued.is_empty();
|
||||
let mut cv = view.canvas(scaling, area);
|
||||
let given = cv;
|
||||
// A zoom percentage (Actual Size) counts from the density of the display that shows this
|
||||
@@ -265,8 +269,16 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
pass.view = Some(arc_view);
|
||||
}
|
||||
}
|
||||
// The canvas's own pans (the wheel, a middle-button drag, keys) move the view by a step from where it was.
|
||||
let pan = (!measuring).then(|| {
|
||||
let rest = doc_windows::view(app, win)
|
||||
.filter(|_| !requested)
|
||||
.and_then(|v| v.pan_rest.filter(|rest| rest.kept == Some((v.center, v.zoom, v.rotation))));
|
||||
pan_on_device_pixels(rest, ui.ctx().input(|i| i.max_texture_side), &mut space, pass.as_mut())
|
||||
});
|
||||
body = with_canvas_space(ui, space, |ui| show_body(app, ui, &space, pass.as_ref(), win, kind, bar_shapes));
|
||||
body.arc_view = arc_turn.then_some(arc_view);
|
||||
body.pan = pan;
|
||||
}
|
||||
});
|
||||
let output = shown.output;
|
||||
@@ -279,7 +291,7 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
rulers::apply(app, ui, out);
|
||||
}
|
||||
let pressed = matches!(output.press.phase, PressPhase::Down { .. });
|
||||
let Body { reply, context_at, context_key, edited, arc_view } = body;
|
||||
let Body { reply, context_at, context_key, edited, arc_view, pan } = body;
|
||||
let request = reply
|
||||
.as_ref()
|
||||
.and_then(|r| r.context.as_ref())
|
||||
@@ -288,13 +300,17 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
let jumped = edited.is_some();
|
||||
// Presentation Mode keeps its view through a drag of the middle button, which the canvas pans on its own, and a
|
||||
// wheel turn the Quick Pen tool takes for its arc size leaves other view requests in place.
|
||||
let view_now = if presenting && ui.input(|i| i.pointer.middle_down()) {
|
||||
given
|
||||
} else {
|
||||
edited.or(reply.and_then(|r| r.view)).or(arc_view).or(output.view).unwrap_or(cv)
|
||||
};
|
||||
let keeps_given = presenting && ui.input(|i| i.pointer.middle_down());
|
||||
let pan = pan.filter(|_| !keeps_given);
|
||||
let view_now =
|
||||
if keeps_given { given } else { edited.or(reply.and_then(|r| r.view)).or(arc_view).or(pan.map(|p| p.view)).or(output.view).unwrap_or(cv) };
|
||||
// Pointer drags of the Hand, compass and scroll bars request absolute views without carrying a rounding remainder.
|
||||
let absolute_drag = (edited.is_some() || app.session.tool_id() == "hand" || tool_adapter::view_tool_held(app))
|
||||
&& ui.input(|i| i.pointer.any_down() || i.pointer.any_released());
|
||||
let (view_now, pan) = settled_on_device_pixels(pan, view_now, !absolute_drag);
|
||||
if let Some(view) = doc_windows::view_mut(app, win) {
|
||||
view.set_canvas(&view_now, scaling);
|
||||
view.pan_rest = pan.map(|rest| PanRest { kept: Some((view.center, view.zoom, view.rotation)), ..rest });
|
||||
// Fitted once, the view stays where it is moved.
|
||||
view.fitted |= refit;
|
||||
// An edit of the compass or a scroll bar reaches the next pass, which stops a running ease.
|
||||
@@ -318,6 +334,100 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
pressed
|
||||
}
|
||||
|
||||
/// What a canvas pan by whole device pixels ([`pan_step`]) left: the view the canvas settled on, the device pixels a
|
||||
/// point it was shown at, and the part of a device pixel along each screen axis the pan has not moved yet (at most half
|
||||
/// a pixel each way).
|
||||
///
|
||||
/// Temporary: storytold/craft-libs#5411 moves the canvas's pans and wheel steps by whole device pixels. Remove this,
|
||||
/// [`crate::state::View::pan_rest`] and their callers with the craft-libs pin bump that brings it in.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub(crate) struct PanRest {
|
||||
view: CanvasView,
|
||||
pixels_per_point: f32,
|
||||
owed: (f64, f64),
|
||||
/// The app's center, zoom and rotation after keeping the settled view.
|
||||
kept: Option<(vectorcraft_geom::Point, f64, f64)>,
|
||||
}
|
||||
|
||||
impl PanRest {
|
||||
/// A rest of nothing after `view`, shown at `pixels_per_point`.
|
||||
fn none(view: CanvasView, pixels_per_point: f32) -> Self {
|
||||
Self { view, pixels_per_point, owed: (0.0, 0.0), kept: None }
|
||||
}
|
||||
}
|
||||
|
||||
/// `view`, when it differs from `from` only in its center: the view that moves the document from where `from` draws it
|
||||
/// by a whole number of device pixels at `pixels_per_point` along each screen axis, the number nearest to how far
|
||||
/// `view` moves it plus `owed` device pixels, with what is left of a pixel. Exactly half a pixel left stays owed. None
|
||||
/// when `view` differs from `from` in more than its center, or `pixels_per_point` or the views are not usable.
|
||||
pub(crate) fn pan_step(from: CanvasView, view: CanvasView, owed: (f64, f64), pixels_per_point: f32) -> Option<(CanvasView, (f64, f64))> {
|
||||
let ppp = f64::from(pixels_per_point);
|
||||
let mut moved = from;
|
||||
moved.center = view.center;
|
||||
if moved != view || !(ppp.is_finite() && ppp > 0.0 && view.zoom.is_finite() && view.zoom > 0.0) {
|
||||
return None;
|
||||
}
|
||||
let (a, b) = (from.affine() * vectorcraft_geom::Point::ZERO, view.affine() * vectorcraft_geom::Point::ZERO);
|
||||
let total = ((b.x - a.x) * ppp + owed.0, (b.y - a.y) * ppp + owed.1);
|
||||
let nearest = |t: f64| t.signum() * (t.abs() - 0.5).ceil().max(0.0);
|
||||
let whole = (nearest(total.0), nearest(total.1));
|
||||
let shift = egui::vec2((a.x + whole.0 / ppp - b.x) as f32, (a.y + whole.1 / ppp - b.y) as f32);
|
||||
if !(shift.x.is_finite() && shift.y.is_finite()) {
|
||||
return None;
|
||||
}
|
||||
let mut shown = view;
|
||||
if shift != egui::Vec2::ZERO {
|
||||
shown.center = view.center - view.unmap_vec(shift);
|
||||
}
|
||||
(shown.center.x.is_finite() && shown.center.y.is_finite()).then_some((shown, (total.0 - whole.0, total.1 - whole.1)))
|
||||
}
|
||||
|
||||
/// Moves the view the canvas settled on in this pass (`space`'s target) from `rest.view` by whole pixels of the art's
|
||||
/// frame ([`pan_step`], [`raster::frame_ppp`] with the display's largest texture side `max_side`), adding the part of a
|
||||
/// pixel `rest` owes, and gives the tool host the same view in `pass`. The render worker then moves the frame it kept
|
||||
/// ([`raster::render_job`]) instead of rendering the whole canvas for a pan by part of a pixel. Nothing is rounded while
|
||||
/// a zoom eases, when the app changed the view since `rest`, or when the app asks for a view this pass (`rest` is None).
|
||||
/// Returns the rest to keep.
|
||||
fn pan_on_device_pixels(rest: Option<PanRest>, max_side: usize, space: &mut CanvasSpace, pass: Option<&mut ToolPass>) -> PanRest {
|
||||
let target = space.target();
|
||||
// The pixels of the art's frame, which are fewer than the device's when the frame would be wider than `max_side`.
|
||||
let ppp = raster::frame_ppp(target.rect.size(), space.pixels_per_point, max_side);
|
||||
let step = rest.filter(|rest| !space.easing() && rest.pixels_per_point == ppp).and_then(|rest| {
|
||||
let mut from = rest.view;
|
||||
// Match zooms separated only by the UI scaling round trip.
|
||||
if (from.zoom - target.zoom).abs() <= 1e-12 * from.zoom.abs().max(target.zoom.abs()) {
|
||||
from.zoom = target.zoom;
|
||||
}
|
||||
pan_step(from, target, rest.owed, ppp)
|
||||
});
|
||||
let Some((view, owed)) = step else {
|
||||
return PanRest::none(target, ppp);
|
||||
};
|
||||
if view != target {
|
||||
space.set_view(view);
|
||||
if let Some(pass) = pass {
|
||||
pass.space = Some(*space);
|
||||
pass.view = Some(view);
|
||||
}
|
||||
}
|
||||
PanRest { view, pixels_per_point: ppp, owed, kept: None }
|
||||
}
|
||||
|
||||
/// `view`, the view the app keeps after this pass, moved from the view of `rest` by whole device pixels when it differs
|
||||
/// from it in its center alone (a tool, a scroll bar or the compass panned it after [`pan_on_device_pixels`]), and the
|
||||
/// rest to keep. Without `carry` (an absolute drag) the rest neither adds nor keeps a part of a pixel.
|
||||
fn settled_on_device_pixels(rest: Option<PanRest>, view: CanvasView, carry: bool) -> (CanvasView, Option<PanRest>) {
|
||||
let Some(rest) = rest else { return (view, None) };
|
||||
if rest.view == view {
|
||||
return (view, Some(PanRest { owed: if carry { rest.owed } else { (0.0, 0.0) }, ..rest }));
|
||||
}
|
||||
let ppp = rest.pixels_per_point;
|
||||
match pan_step(rest.view, view, if carry { rest.owed } else { (0.0, 0.0) }, ppp) {
|
||||
Some((view, owed)) => (view, Some(PanRest { view, owed: if carry { owed } else { (0.0, 0.0) }, ..rest })),
|
||||
None => (view, Some(PanRest::none(view, ppp))),
|
||||
}
|
||||
}
|
||||
|
||||
/// The body of the canvas in order: controls that take presses first, the tool host, the selection's marks and the
|
||||
/// display-only widgets over it, the picture last.
|
||||
fn show_body(
|
||||
|
||||
@@ -6268,6 +6268,309 @@ fn a_whole_pixel_pan() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Wheel steps of part of a device pixel, at a zoom and center that put the document's origin between device pixels,
|
||||
/// move the frame the render worker kept: every frame that may copy from the last one does.
|
||||
#[test]
|
||||
fn wheel_steps_of_part_of_a_pixel_move_the_kept_frame() {
|
||||
keeping_color_settings(|| {
|
||||
for rulers in [false, true] {
|
||||
for scaling in [1.0, 1.75] {
|
||||
wheel_steps_of_part_of_a_pixel(rulers, scaling);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn wheel_steps_of_part_of_a_pixel(rulers: bool, scaling: f64) {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.prefs.ui_scaling = scaling;
|
||||
app.ui.view.rulers = rulers;
|
||||
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
for x in [20, 160, 300] {
|
||||
app.session.execute("shape.rectangle", &json!({"x": x, "y": 40, "width": 80, "height": 200})).unwrap();
|
||||
}
|
||||
app.canvas.worker_started = true;
|
||||
let ctx = crate::testing::ui_context();
|
||||
for _ in 0..3 {
|
||||
app_step(&mut app, &ctx, vec![]);
|
||||
}
|
||||
{
|
||||
let v = app.view_mut().unwrap();
|
||||
let zoom = 1.37;
|
||||
let scale = f64::from(scaling as f32);
|
||||
if scaling != 1.0 {
|
||||
assert_ne!((zoom * scale) / scale, zoom, "the UI scaling round trip changes the canvas zoom");
|
||||
}
|
||||
v.zoom = zoom * scale;
|
||||
v.center = Point::new(200.3, 150.7);
|
||||
}
|
||||
app_step(&mut app, &ctx, vec![]);
|
||||
let (worker, jobs, done) = crate::render_worker::Worker::test_channel();
|
||||
app.canvas.worker = Some(worker);
|
||||
app.canvas.last_ms = 50.0;
|
||||
let at = app.canvas_view().unwrap().rect.center();
|
||||
let wheel = egui::Event::MouseWheel {
|
||||
unit: egui::MouseWheelUnit::Point,
|
||||
delta: vec2(0.3, -0.4),
|
||||
phase: egui::TouchPhase::Move,
|
||||
modifiers: egui::Modifiers::default(),
|
||||
source: egui::MouseWheelSource::Unknown,
|
||||
};
|
||||
let start = app.canvas_view().unwrap().center;
|
||||
let mut r = vectorcraft_render::Renderer::new();
|
||||
let (mut kept, mut copying) = (None, 0);
|
||||
for _ in 0..10 {
|
||||
app_step(&mut app, &ctx, vec![egui::Event::PointerMoved(at), wheel.clone()]);
|
||||
while let Ok(job) = jobs.try_recv() {
|
||||
let may = job.may_copy && kept.is_some();
|
||||
let frame = render_job(&mut r, &mut kept, &job);
|
||||
copying += usize::from(may);
|
||||
if may {
|
||||
assert!(frame.reused, "each new frame of the pan copies the kept frame's pixels, rulers: {rulers}, UI scaling: {scaling}");
|
||||
}
|
||||
let (img, reused) = (frame.img, frame.reused);
|
||||
done.send(crate::render_worker::Done { key: job.key, doc: job.doc, opts: job.opts, img, ms: 50.0, moved: 0, reused, view_sized: false })
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
assert_ne!(app.canvas_view().unwrap().center, start, "the wheel pans the view");
|
||||
assert!(copying >= 3, "the pan asks for new frames: {copying}");
|
||||
}
|
||||
|
||||
/// Pans by part of a device pixel, each from the view the last one settled on, move the document by whole device pixels
|
||||
/// at the view's zoom and rotation, and the parts left over add up: after each step the document is within half a device
|
||||
/// pixel of where the pans together put it. A change of more than the center is not a pan.
|
||||
#[test]
|
||||
fn pans_by_part_of_a_pixel_move_by_whole_device_pixels_and_add_up() {
|
||||
let rect = egui::Rect::from_min_size(pos2(10.5, 7.25), vec2(640.0, 480.0));
|
||||
for (zoom, rotation, ppp) in [(1.37, 0.0, 1.0), (0.613, 30.0, 2.0), (7.9, -75.0, 1.25)] {
|
||||
let start = CanvasView::new(rect, Point::new(203.17, -48.6), zoom).rotation(rotation);
|
||||
let origin = |v: &CanvasView| v.affine() * Point::ZERO;
|
||||
let (mut view, mut owed) = (start, (0.0, 0.0));
|
||||
// Each step moves the document 0.3 points right and 0.45 points up on screen.
|
||||
let step = vec2(0.3, -0.45);
|
||||
for n in 1..=12 {
|
||||
let mut next = view;
|
||||
next.center = view.center - view.unmap_vec(step);
|
||||
let (shown, left) = super::pan_step(view, next, owed, ppp).expect("a pan");
|
||||
let ppp = f64::from(ppp);
|
||||
let (a, b) = (origin(&view), origin(&shown));
|
||||
let wanted = origin(&start) + vectorcraft_geom::Vec2::new(f64::from(step.x), f64::from(step.y)) * f64::from(n);
|
||||
for (from, to, want) in [(a.x, b.x, wanted.x), (a.y, b.y, wanted.y)] {
|
||||
let moved = (to - from) * ppp;
|
||||
assert!((moved - moved.round()).abs() < 1e-6, "{zoom} {rotation}° step {n}: moved {moved} device pixels");
|
||||
assert!(((to - want) * ppp).abs() <= 0.5 + 1e-6, "{zoom} {rotation}° step {n}: {} device pixels short", (want - to) * ppp);
|
||||
}
|
||||
assert_eq!((shown.zoom, shown.rotation, shown.rect), (start.zoom, start.rotation, start.rect));
|
||||
(view, owed) = (shown, left);
|
||||
}
|
||||
let mut zoomed = view;
|
||||
zoomed.zoom = zoom * 1.1;
|
||||
assert_eq!(super::pan_step(view, zoomed, owed, ppp), None, "a zoom is not a pan");
|
||||
}
|
||||
}
|
||||
|
||||
/// A drag (a button held) sets where the view goes: each pass's view stays within half a device pixel of the view the
|
||||
/// drag asked for, however many passes it lasts, and moves by whole device pixels from the last one.
|
||||
#[test]
|
||||
fn a_drag_s_views_stay_within_half_a_pixel_of_the_pointer() {
|
||||
let rect = egui::Rect::from_min_size(pos2(0.0, 0.0), vec2(640.0, 480.0));
|
||||
let start = CanvasView::new(rect, Point::new(100.0, 80.0), 1.37);
|
||||
let mut rest = Some(super::PanRest::none(start, 1.0));
|
||||
for n in 1..=20 {
|
||||
// The drag asks for the view at its press moved 0.35 points a pass.
|
||||
let mut asked = start;
|
||||
asked.center = start.center - start.unmap_vec(vec2(0.35, 0.35) * n as f32);
|
||||
let last = rest.unwrap().view;
|
||||
let (view, next) = super::settled_on_device_pixels(rest, asked, false);
|
||||
let [a, b, c] = [last, view, asked].map(|v| v.affine() * Point::ZERO);
|
||||
for (from, to, want) in [(a.x, b.x, c.x), (a.y, b.y, c.y)] {
|
||||
assert!(((to - from) - (to - from).round()).abs() < 1e-6, "pass {n}: whole pixels from the last view");
|
||||
assert!((to - want).abs() <= 0.5 + 1e-6, "pass {n}: {} device pixels from the drag", want - to);
|
||||
}
|
||||
rest = next;
|
||||
}
|
||||
}
|
||||
|
||||
/// A drag's rounding is not owed to the pans after it: a drag by 0.4 device pixels leaves the view where it was and
|
||||
/// nothing owed, so a later step of 0.2 device pixels does not move the view either.
|
||||
#[test]
|
||||
fn a_drag_leaves_nothing_owed_to_later_pans() {
|
||||
let rect = egui::Rect::from_min_size(pos2(0.0, 0.0), vec2(640.0, 480.0));
|
||||
let start = CanvasView::new(rect, Point::new(100.0, 80.0), 1.0);
|
||||
let mut asked = start;
|
||||
asked.center = start.center - start.unmap_vec(vec2(0.4, 0.0));
|
||||
let (view, rest) = super::settled_on_device_pixels(Some(super::PanRest::none(start, 1.0)), asked, false);
|
||||
assert_eq!(view.center, start.center, "a drag by 0.4 device pixels rounds to no move");
|
||||
assert_eq!(rest.map(|rest| rest.owed), Some((0.0, 0.0)), "the drag leaves nothing owed");
|
||||
let mut stepped = view;
|
||||
stepped.center = view.center - view.unmap_vec(vec2(0.2, 0.0));
|
||||
let (after, _) = super::settled_on_device_pixels(rest, stepped, true);
|
||||
assert_eq!(after.center, view.center, "a step of 0.2 device pixels alone does not move the view");
|
||||
}
|
||||
|
||||
/// A drag pass that leaves the view where it was clears what earlier pans left owed, so a later step of 0.2 device
|
||||
/// pixels after 0.4 owed does not move the view by a whole pixel.
|
||||
#[test]
|
||||
fn a_drag_that_leaves_the_view_in_place_clears_what_is_owed() {
|
||||
let rect = egui::Rect::from_min_size(pos2(0.0, 0.0), vec2(640.0, 480.0));
|
||||
let start = CanvasView::new(rect, Point::new(100.0, 80.0), 1.0);
|
||||
let owing = super::PanRest { owed: (0.4, 0.0), ..super::PanRest::none(start, 1.0) };
|
||||
let (view, rest) = super::settled_on_device_pixels(Some(owing), start, false);
|
||||
assert_eq!(view, start, "the drag keeps the view");
|
||||
assert_eq!(rest.map(|rest| rest.owed), Some((0.0, 0.0)), "the drag leaves nothing owed");
|
||||
let mut stepped = view;
|
||||
stepped.center = view.center - view.unmap_vec(vec2(0.2, 0.0));
|
||||
let (after, _) = super::settled_on_device_pixels(rest, stepped, true);
|
||||
assert_eq!(after.center, view.center, "a step of 0.2 device pixels alone does not move the view");
|
||||
// A pass that carries the rest keeps what is owed when the view stays where it was.
|
||||
let (_, kept) = super::settled_on_device_pixels(Some(owing), start, true);
|
||||
assert_eq!(kept.map(|rest| rest.owed), Some((0.4, 0.0)), "a carrying pass keeps what is owed");
|
||||
}
|
||||
|
||||
/// Steps a tool takes from where the view was (a drag's autoscroll, the Hand's glide) keep the parts of a pixel they
|
||||
/// leave: after each pass the view is within half a device pixel of all the steps together.
|
||||
#[test]
|
||||
fn a_tool_s_steps_keep_the_parts_of_a_pixel_they_leave() {
|
||||
let rect = egui::Rect::from_min_size(pos2(0.0, 0.0), vec2(640.0, 480.0));
|
||||
let start = CanvasView::new(rect, Point::new(100.0, 80.0), 1.37);
|
||||
let mut rest = Some(super::PanRest::none(start, 1.25));
|
||||
for n in 1..=12 {
|
||||
let last = rest.unwrap().view;
|
||||
// Each pass the tool moves the view it was given 2.4 device pixels left.
|
||||
let mut asked = last;
|
||||
asked.center = last.center - last.unmap_vec(vec2(-2.4 / 1.25, 0.0));
|
||||
let (view, next) = super::settled_on_device_pixels(rest, asked, true);
|
||||
let moved = (view.affine() * Point::ZERO).x - (start.affine() * Point::ZERO).x;
|
||||
assert!((moved * 1.25 + 2.4 * f64::from(n)).abs() <= 0.5 + 1e-5, "pass {n}: moved {} device pixels", moved * 1.25);
|
||||
rest = next;
|
||||
}
|
||||
}
|
||||
|
||||
/// A Hand drag by parts of a device pixel, at a zoom and center that put the document's origin between device pixels,
|
||||
/// ends where the pointer let go: the document is within half a device pixel of where the drag puts it, after the
|
||||
/// release too.
|
||||
#[test]
|
||||
fn a_hand_drag_by_parts_of_a_pixel_ends_where_the_pointer_lets_go() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
app.select_tool("hand");
|
||||
let ctx = crate::testing::ui_context();
|
||||
for _ in 0..3 {
|
||||
app_step(&mut app, &ctx, vec![]);
|
||||
}
|
||||
{
|
||||
let v = app.view_mut().unwrap();
|
||||
v.zoom = 1.37;
|
||||
v.center = Point::new(200.3, 150.7);
|
||||
}
|
||||
app_step(&mut app, &ctx, vec![]);
|
||||
let start = app.canvas_view().unwrap();
|
||||
let at = start.rect.center();
|
||||
let end = at + vec2(17.7, 12.35);
|
||||
app_step(&mut app, &ctx, vec![egui::Event::PointerMoved(at), press(at, true)]);
|
||||
for to in [at + vec2(13.7, 9.35), end] {
|
||||
app_step(&mut app, &ctx, vec![egui::Event::PointerMoved(to)]);
|
||||
}
|
||||
let origin = |v: &CanvasView| v.affine() * Point::ZERO;
|
||||
let wanted = origin(&start) + vectorcraft_geom::Vec2::new(f64::from(end.x - at.x), f64::from(end.y - at.y));
|
||||
let near = |app: &VectorcraftApp, when: &str| {
|
||||
let got = origin(&app.canvas_view().unwrap());
|
||||
assert!((got.x - wanted.x).abs() <= 0.5 + 1e-6 && (got.y - wanted.y).abs() <= 0.5 + 1e-6, "{when}: {got:?}, the drag puts it at {wanted:?}");
|
||||
};
|
||||
near(&app, "dragging");
|
||||
app_step(&mut app, &ctx, vec![press(end, false)]);
|
||||
app_step(&mut app, &ctx, vec![]);
|
||||
near(&app, "released");
|
||||
}
|
||||
|
||||
/// A middle-button drag at 1.25 device pixels a point moves the view by whole device pixels and keeps the parts of a
|
||||
/// pixel each move leaves: after moves of one point each the document is within half a device pixel of the pointer.
|
||||
#[test]
|
||||
fn a_middle_button_drag_keeps_the_parts_of_a_pixel_it_moves() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
let ctx = crate::testing::ui_context();
|
||||
let step = |app: &mut VectorcraftApp, events: Vec<egui::Event>| {
|
||||
let screen = egui::Rect::from_min_size(Pos2::ZERO, vec2(1600.0, 850.0));
|
||||
let mut raw = egui::RawInput { screen_rect: Some(screen), events, ..Default::default() };
|
||||
raw.viewports.entry(egui::ViewportId::ROOT).or_default().native_pixels_per_point = Some(1.25);
|
||||
crate::testing::app_frame(app, &ctx, raw);
|
||||
};
|
||||
for _ in 0..3 {
|
||||
step(&mut app, vec![]);
|
||||
}
|
||||
{
|
||||
let v = app.view_mut().unwrap();
|
||||
v.zoom = 1.37;
|
||||
v.center = Point::new(200.3, 150.7);
|
||||
}
|
||||
step(&mut app, vec![]);
|
||||
assert_eq!(ctx.pixels_per_point(), 1.25);
|
||||
let start = app.canvas_view().unwrap();
|
||||
let at = start.rect.center();
|
||||
let middle =
|
||||
|at: Pos2, pressed: bool| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Middle, pressed, modifiers: Default::default() };
|
||||
step(&mut app, vec![egui::Event::PointerMoved(at), middle(at, true)]);
|
||||
let mut to = at;
|
||||
for _ in 0..8 {
|
||||
to += vec2(1.0, 0.0);
|
||||
step(&mut app, vec![egui::Event::PointerMoved(to)]);
|
||||
}
|
||||
let origin = |v: &CanvasView| v.affine() * Point::ZERO;
|
||||
let (got, from) = (origin(&app.canvas_view().unwrap()), origin(&start));
|
||||
let moved = (got.x - from.x) * 1.25;
|
||||
assert!((moved - f64::from(to.x - at.x) * 1.25).abs() <= 0.5 + 1e-6, "moved {moved} device pixels for {} points", to.x - at.x);
|
||||
assert!(((got.y - from.y) * 1.25).abs() <= 0.5 + 1e-6, "no move down");
|
||||
step(&mut app, vec![middle(to, false)]);
|
||||
}
|
||||
|
||||
/// A fit the app asks for after a pan by parts of a device pixel, at the zoom the pan kept, puts the view at the fitted
|
||||
/// center exactly: the pan's leftover part of a pixel does not round it.
|
||||
#[test]
|
||||
fn a_fit_after_a_pan_by_part_of_a_pixel_keeps_its_exact_center() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
let ctx = crate::testing::ui_context();
|
||||
let step = |app: &mut VectorcraftApp, events: Vec<egui::Event>| {
|
||||
let screen = egui::Rect::from_min_size(Pos2::ZERO, vec2(1600.0, 850.0));
|
||||
let mut raw = egui::RawInput { screen_rect: Some(screen), events, ..Default::default() };
|
||||
raw.viewports.entry(egui::ViewportId::ROOT).or_default().native_pixels_per_point = Some(1.25);
|
||||
crate::testing::app_frame(app, &ctx, raw);
|
||||
};
|
||||
for _ in 0..3 {
|
||||
step(&mut app, vec![]);
|
||||
}
|
||||
let fitted = app.canvas_view().unwrap();
|
||||
let at = fitted.rect.center();
|
||||
// The pans start from a view whose document origin is between device pixels of the fitted one.
|
||||
{
|
||||
let v = app.view_mut().unwrap();
|
||||
v.center = Point::new(v.center.x + 0.37, v.center.y + 0.21);
|
||||
}
|
||||
step(&mut app, vec![]);
|
||||
let wheel = egui::Event::MouseWheel {
|
||||
unit: egui::MouseWheelUnit::Point,
|
||||
delta: vec2(0.3, -0.45),
|
||||
phase: egui::TouchPhase::Move,
|
||||
modifiers: egui::Modifiers::default(),
|
||||
source: egui::MouseWheelSource::Unknown,
|
||||
};
|
||||
for _ in 0..3 {
|
||||
step(&mut app, vec![egui::Event::PointerMoved(at), wheel.clone()]);
|
||||
}
|
||||
let panned = app.canvas_view().unwrap();
|
||||
assert_ne!(panned.center, fitted.center, "the wheel pans the view");
|
||||
assert_eq!(panned.zoom, fitted.zoom, "the pan keeps the zoom");
|
||||
assert!(app.view().unwrap().pan_rest.is_some(), "the pan keeps a rest");
|
||||
app.view_mut().unwrap().fitted = false;
|
||||
step(&mut app, vec![]);
|
||||
let refit = app.canvas_view().unwrap();
|
||||
assert_eq!(refit.zoom, fitted.zoom, "the fit gives the same zoom");
|
||||
let (got, want) = (refit.affine() * Point::ZERO, fitted.affine() * Point::ZERO);
|
||||
assert!((got.x - want.x).abs() < 1e-6 && (got.y - want.y).abs() < 1e-6, "the fit is not rounded: {got:?}, fitted at {want:?}");
|
||||
}
|
||||
|
||||
/// Installing, replacing or removing a plug-in draws a document with a plug-in effect again, and a
|
||||
/// pan from the frame drawn before the change renders whole instead of copying its pixels. The key
|
||||
/// of a document without a plug-in effect does not follow the plug-ins. The other tests share the
|
||||
|
||||
@@ -9,8 +9,8 @@ use craft::behavior::{CancelReason, CanvasView, Cursor, PointerKind as Device, P
|
||||
use craft::keymap::{Chord, Key};
|
||||
use craft::ui::canvas::ToolPath;
|
||||
use craft::ui::canvas::{
|
||||
Autoscroll, CanvasTool, Momentary, MomentaryCommands, MomentaryShift, ToolAction, ToolClaims, ToolContext, ToolHost, ToolHostResponse, ToolKey,
|
||||
ToolPass, ToolPointer,
|
||||
Autoscroll, CanvasTool, Momentary, MomentaryShift, ToolAction, ToolClaims, ToolContext, ToolHost, ToolHostResponse, ToolKey, ToolPass,
|
||||
ToolPointer,
|
||||
};
|
||||
use craft::ui::contract::DragPreview;
|
||||
use craft::ui::runtime::drag;
|
||||
@@ -47,6 +47,7 @@ const PLANES: &[Chord] =
|
||||
&[Chord::plain(Key::Num1), Chord::plain(Key::Num2), Chord::plain(Key::Num3), Chord::plain(Key::Num4), Chord::plain(Key::Num5)];
|
||||
const TAB: &[Chord] = &[Chord::plain(Key::Tab)];
|
||||
const HOME_END: &[Chord] = &[Chord::plain(Key::Home), Chord::plain(Key::End)];
|
||||
const LETTER_E: &[Chord] = &[Chord::plain(Key::E)];
|
||||
|
||||
/// The modifiers of an egui key event, as the engine's tools read them.
|
||||
pub fn mods(m: egui::Modifiers, space: bool) -> Mods {
|
||||
@@ -489,6 +490,8 @@ impl CanvasTool for SessionTool<'_> {
|
||||
_ if claim(&mut app, EngineKey::Digit(1)) => PLANES,
|
||||
_ if claim(&mut app, EngineKey::Tab) => TAB,
|
||||
_ if claim(&mut app, EngineKey::Home) => HOME_END,
|
||||
// The Extend Path tool's E cycles its shape with no drag running too.
|
||||
_ if claim(&mut app, EngineKey::Letter('e')) => LETTER_E,
|
||||
_ => &[],
|
||||
};
|
||||
let mut claims = ToolClaims::NONE.keys(keys);
|
||||
@@ -656,37 +659,6 @@ impl CanvasTool for SessionTool<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Ends the held momentary command (Space's Hand, Cmd+Space's Zoom...) once none of the keys that were down when it
|
||||
/// started is down, and returns the command still held. The shortcut board drops a queued release when the canvas
|
||||
/// does not run on the frame the key goes up (a dialog or another tab in front). A hold that started with no key down
|
||||
/// (automation) lasts until its release.
|
||||
///
|
||||
/// Temporary: craft-libs#5056 ends the hold inside the tool host. Remove this function, [`note_momentary_keys`],
|
||||
/// their calls and `CanvasCache::momentary_keys` once the craft-libs pin includes that change.
|
||||
fn end_missed_momentary(ctx: &egui::Context, momentary: &mut Momentary, keys: &mut Vec<Key>) -> Option<MomentaryCommands> {
|
||||
let held = momentary.held()?;
|
||||
if keys.is_empty() {
|
||||
return Some(held);
|
||||
}
|
||||
let down = craft::ui::runtime::keys::held(ctx);
|
||||
if keys.iter().any(|key| down.contains(key)) {
|
||||
return Some(held);
|
||||
}
|
||||
momentary.fired(held, craft::ui::runtime::commands::FirePhase::Release);
|
||||
keys.clear();
|
||||
None
|
||||
}
|
||||
|
||||
/// Notes the keys down when a momentary command starts (or changes), for [`end_missed_momentary`]; `before` is the
|
||||
/// command held before the tool host's pass.
|
||||
fn note_momentary_keys(ctx: &egui::Context, before: Option<MomentaryCommands>, momentary: &Momentary, keys: &mut Vec<Key>) {
|
||||
match momentary.held() {
|
||||
None => keys.clear(),
|
||||
Some(held) if before != Some(held) => *keys = craft::ui::runtime::keys::held(ctx),
|
||||
Some(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs the tool host on `tool` with the app's momentary set, which the app keeps across passes. A finger, once a pen
|
||||
/// has been seen, only navigates (palm rejection).
|
||||
fn host_run(app: &mut VectorcraftApp, ui: &Ui, pass: &ToolPass, tool: &mut dyn CanvasTool) -> ToolHostResponse {
|
||||
@@ -694,9 +666,7 @@ fn host_run(app: &mut VectorcraftApp, ui: &Ui, pass: &ToolPass, tool: &mut dyn C
|
||||
let mut momentary = app.canvas.momentary.take().unwrap_or_else(|| Momentary::new(options).shift(MomentaryShift::RotateView));
|
||||
momentary.set_options(options);
|
||||
momentary.hand_selected(app.session.tool_id() == "hand");
|
||||
let before = end_missed_momentary(ui.ctx(), &mut momentary, &mut app.canvas.momentary_keys);
|
||||
let response = ToolHost::new().momentary(&mut momentary).navigates(crate::touch::finger_navigates_only()).run(ui, pass, tool);
|
||||
note_momentary_keys(ui.ctx(), before, &momentary, &mut app.canvas.momentary_keys);
|
||||
app.canvas.momentary = Some(momentary);
|
||||
response
|
||||
}
|
||||
@@ -855,14 +825,9 @@ fn host_run_session(tool: &mut SessionTool<'_>, ui: &Ui, pass: &ToolPass) -> Too
|
||||
let mut momentary = app.canvas.momentary.take().unwrap_or_else(|| Momentary::new(options).shift(MomentaryShift::RotateView));
|
||||
momentary.set_options(options);
|
||||
momentary.hand_selected(app.session.tool_id() == "hand");
|
||||
let mut keys = std::mem::take(&mut app.canvas.momentary_keys);
|
||||
drop(app);
|
||||
let before = end_missed_momentary(ui.ctx(), &mut momentary, &mut keys);
|
||||
let response = ToolHost::new().momentary(&mut momentary).navigates(crate::touch::finger_navigates_only()).run(ui, pass, tool);
|
||||
note_momentary_keys(ui.ctx(), before, &momentary, &mut keys);
|
||||
let mut app = tool.app();
|
||||
app.canvas.momentary = Some(momentary);
|
||||
app.canvas.momentary_keys = keys;
|
||||
tool.app().canvas.momentary = Some(momentary);
|
||||
response
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,6 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
// An angle between the presets, from the Rotate View tool or `view.rotate`, shows in whole degrees; adding 0.0
|
||||
// turns the -0 of a small negative angle into 0.
|
||||
let degrees = rotation.round() + 0.0;
|
||||
let revision = st.map(|d| (d.uid, d.revision));
|
||||
let artboards = st.map_or(&[][..], |d| d.doc.artboards.as_slice());
|
||||
let mut picks = Vec::new();
|
||||
let shows: Vec<Entry<StatusBarShow>> =
|
||||
StatusBarShow::ALL.into_iter().map(|s| Entry::new(s, s.label()).checked(app.ui.status_bar_show == s)).collect();
|
||||
@@ -95,7 +93,8 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let zoom =
|
||||
ZoomControls { zoom: canvas_zoom, document, scaling, print, shown_zoom, has_view: view.is_some(), lang, picked: Outbox::new(&mut picks) };
|
||||
let _ = MemoView::new("status-bar-zoom", zoom, show_zoom).show(ui);
|
||||
let navigation = Navigation { has_view: view.is_some(), turned, degrees, cur, revision, artboards, lang, picked: Outbox::new(&mut picks) };
|
||||
let artboards = st.map_or_else(Vec::new, |d| d.doc.artboards.iter().map(|a| a.name.as_str()).collect());
|
||||
let navigation = Navigation { has_view: view.is_some(), turned, degrees, cur, artboards, lang, picked: Outbox::new(&mut picks) };
|
||||
let _ = MemoView::new("status-bar-navigation", navigation, show_navigation).show(ui);
|
||||
Divider::vertical().show(ui);
|
||||
// An empty readout shows a dash.
|
||||
@@ -237,10 +236,9 @@ struct Navigation<'a> {
|
||||
degrees: f64,
|
||||
/// The artboard the navigator shows.
|
||||
cur: usize,
|
||||
/// The active document's uid and revision.
|
||||
revision: Option<(u64, u64)>,
|
||||
#[memo_props(covered_by = "revision", reason = "a document's uid and revision change with every edit of it")]
|
||||
artboards: &'a [vectorcraft_doc::Artboard],
|
||||
/// The names of the active document's artboards, in order, which the navigator lists. Edits that leave them
|
||||
/// alone, such as the frames of a drag, replay the controls.
|
||||
artboards: Vec<&'a str>,
|
||||
#[memo_props(hash = "an interface language: an index into the languages offered")]
|
||||
lang: crate::i18n::Lang,
|
||||
/// What the controls chose in the pass.
|
||||
@@ -291,7 +289,7 @@ fn show_navigation(p: &mut Navigation<'_>, ui: &mut Ui) {
|
||||
p.picked.send(NavigationPick::Artboard(json!(to)));
|
||||
}
|
||||
}
|
||||
let boards: Vec<Entry<usize>> = p.artboards.iter().enumerate().map(|(i, a)| Entry::new(i, format!("{} {}", i + 1, a.name))).collect();
|
||||
let boards: Vec<Entry<usize>> = p.artboards.iter().enumerate().map(|(i, name)| Entry::new(i, format!("{} {}", i + 1, name))).collect();
|
||||
let mut go = None;
|
||||
Field::new(tl!("Artboard")).side(SideLabel::new().kind(LabelKind::Hidden)).show(ui, |ui, _| {
|
||||
// With no document the navigator shows a dash, as the info readout does.
|
||||
@@ -433,6 +431,33 @@ mod tests {
|
||||
assert!(panel.enabled("Next Artboard") || panel.enabled("Previous Artboard"), "the navigator counts the new artboard");
|
||||
}
|
||||
|
||||
/// Edits that leave the artboards' names alone, such as the steps of a drag, replay the Rotation menu and the
|
||||
/// artboard navigator; renaming an artboard runs them, and the navigator shows the new name.
|
||||
#[test]
|
||||
fn edits_that_keep_the_artboard_names_replay_the_navigation_controls() {
|
||||
let runs = || NAVIGATION_RUNS.with(std::cell::Cell::get);
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
|
||||
app.view_mut().unwrap().rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 400.0));
|
||||
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap();
|
||||
let mut panel = Panel::new(app, status_bar);
|
||||
panel.room(egui::vec2(1200.0, 300.0));
|
||||
panel.frame();
|
||||
panel.frame();
|
||||
let (before, revision) = (runs(), panel.app().session.active().unwrap().revision);
|
||||
for _ in 0..10 {
|
||||
panel.app().run("object.move", json!({"dx": 1, "dy": 0})).unwrap();
|
||||
panel.frame();
|
||||
}
|
||||
assert!(panel.app().session.active().unwrap().revision > revision, "each move is an edit of the document");
|
||||
assert_eq!(runs(), before, "moves do not run the navigation controls");
|
||||
panel.app().run("artboard.rename", json!({"indices": [0], "name": "Front"})).unwrap();
|
||||
panel.frame();
|
||||
panel.frame();
|
||||
assert!(runs() > before, "a rename runs them again");
|
||||
assert_eq!(panel.value("Artboard").as_deref(), Some("1 Front"), "and the navigator shows the new name");
|
||||
}
|
||||
|
||||
/// Scrolling the view moves its center and nothing the navigation controls show, so frames of a wheel pan replay
|
||||
/// them; a new zoom runs only the Zoom field and its presets, not the Rotation menu and the artboard navigator.
|
||||
#[test]
|
||||
|
||||
@@ -23,7 +23,6 @@ use serde_json::{Map, Value, json};
|
||||
use vectorcraft_doc::setup::DocSetup;
|
||||
use vectorcraft_engine::cmd::textstyles::NORMAL_CHAR;
|
||||
|
||||
use super::host::preview_canvas;
|
||||
use super::preview::LivePreview;
|
||||
use crate::VectorcraftApp;
|
||||
|
||||
@@ -1037,18 +1036,12 @@ pub(crate) fn tabs(fields: &DialogFields, opening: &Opening) -> Vec<PropertiesTa
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The dialog of style `name` over `opening`, which `title` heads, kept open by a held OK. A dialog that previews on
|
||||
/// the document passes its `canvas` (from [`preview_canvas`]): the modal layer leaves it undimmed, and the wheel still
|
||||
/// moves its view.
|
||||
pub(crate) fn hosted(key: &'static str, title: &'static str, opening: &Arc<Opening>, name: &str, canvas: Option<egui::Id>) -> HostedPropertiesDialog {
|
||||
/// The dialog of style `name` over `opening`, which `title` heads, kept open by a held OK.
|
||||
pub(crate) fn hosted(key: &'static str, title: &'static str, opening: &Arc<Opening>, name: &str) -> HostedPropertiesDialog {
|
||||
let rows_of = Arc::clone(opening);
|
||||
HostedPropertiesDialog::new(key, opening.fields(name), move |values| {
|
||||
let now = values.value().cloned().unwrap_or_else(DialogFields::new);
|
||||
let dialog = PropertiesDialog::new(key, title, tabs(&now, &rows_of), values).tab_layout(TabLayout::List);
|
||||
match canvas {
|
||||
Some(canvas) => dialog.canvas(canvas),
|
||||
None => dialog,
|
||||
}
|
||||
PropertiesDialog::new(key, title, tabs(&now, &rows_of), values).tab_layout(TabLayout::List)
|
||||
})
|
||||
.held_ok()
|
||||
}
|
||||
@@ -1203,7 +1196,6 @@ pub(crate) struct Preview {
|
||||
|
||||
pub fn open(app: &mut VectorcraftApp, name: &str) -> Result<Value, String> {
|
||||
crate::panels::character::end_typing(app);
|
||||
let canvas = preview_canvas(app);
|
||||
let state = app.session.active().ok_or("no document open")?;
|
||||
let (document, doc) = ((state.uid, state.reverts), &state.doc);
|
||||
// [Normal Character Style] has no definition until it is first redefined: it sets nothing.
|
||||
@@ -1213,7 +1205,7 @@ pub fn open(app: &mut VectorcraftApp, name: &str) -> Result<Value, String> {
|
||||
None => return Err(format!("no character style `{name}`")),
|
||||
};
|
||||
let opening = Arc::new(Opening::new(name, attrs, &doc.setup, swatch_choices(doc)));
|
||||
let dialog = CharStyleOptions { inner: hosted(KIND, tl!("Character Style Options"), &opening, name, canvas).previews(), opening, document };
|
||||
let dialog = CharStyleOptions { inner: hosted(KIND, tl!("Character Style Options"), &opening, name).previews(), opening, document };
|
||||
app.dialogs().ok_or("no window")?.with(|host| host.open(dialog));
|
||||
Ok(json!({"dialog": KIND}))
|
||||
}
|
||||
|
||||
@@ -65,11 +65,11 @@ pub fn open(app: &mut VectorcraftApp, para: bool, target: Value) -> Result<Value
|
||||
target["attrs"] = Value::Object(attrs.clone());
|
||||
let (opening, inner) = if para {
|
||||
let opening = Arc::new(para_style_options::Opening::new("", attrs, app.session.general_unit(), para_style_options::vertical_text(app)));
|
||||
let inner = para_style_options::hosted(KIND, tl!("New Paragraph Style"), &opening, &name, None);
|
||||
let inner = para_style_options::hosted(KIND, tl!("New Paragraph Style"), &opening, &name);
|
||||
(Opening::Para(opening), inner)
|
||||
} else {
|
||||
let opening = Arc::new(char_style_options::Opening::new("", attrs, &doc.setup, char_style_options::swatch_choices(doc)));
|
||||
let inner = char_style_options::hosted(KIND, tl!("New Character Style"), &opening, &name, None);
|
||||
let inner = char_style_options::hosted(KIND, tl!("New Character Style"), &opening, &name);
|
||||
(Opening::Char(opening), inner)
|
||||
};
|
||||
app.dialogs().ok_or("no window")?.with(|host| host.open(NewTextStyle { inner, opening, para, document, target }));
|
||||
|
||||
@@ -28,7 +28,6 @@ use vectorcraft_engine::cmd::textstyles::NORMAL_PARA;
|
||||
use super::char_style_options::{
|
||||
Refusals, Values, canonical_map, general_rows, pump_in_opening_document, rows, select, style_dialog, text, to_fields, tri_state, value_of,
|
||||
};
|
||||
use super::host::preview_canvas;
|
||||
use crate::VectorcraftApp;
|
||||
|
||||
pub const KIND: &str = "paraStyleOptions";
|
||||
@@ -810,19 +809,13 @@ pub(crate) fn tabs(fields: &DialogFields, opening: &Opening) -> Vec<PropertiesTa
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The dialog of style `name` over `opening`, which `title` heads, kept open by a held OK. A dialog that previews on
|
||||
/// the document passes its `canvas` (from [`preview_canvas`]): the modal layer leaves it undimmed, and the wheel still
|
||||
/// moves its view.
|
||||
pub(crate) fn hosted(key: &'static str, title: &'static str, opening: &Arc<Opening>, name: &str, canvas: Option<egui::Id>) -> HostedPropertiesDialog {
|
||||
/// The dialog of style `name` over `opening`, which `title` heads, kept open by a held OK.
|
||||
pub(crate) fn hosted(key: &'static str, title: &'static str, opening: &Arc<Opening>, name: &str) -> HostedPropertiesDialog {
|
||||
let rows_of = Arc::clone(opening);
|
||||
HostedPropertiesDialog::new(key, opening.fields(name), move |values| {
|
||||
let now = values.value().cloned().unwrap_or_else(DialogFields::new);
|
||||
let dialog = craft::ui::patterns::form_dialogs::PropertiesDialog::new(key, title, tabs(&now, &rows_of), values)
|
||||
.tab_layout(craft::ui::patterns::form_dialogs::TabLayout::List);
|
||||
match canvas {
|
||||
Some(canvas) => dialog.canvas(canvas),
|
||||
None => dialog,
|
||||
}
|
||||
craft::ui::patterns::form_dialogs::PropertiesDialog::new(key, title, tabs(&now, &rows_of), values)
|
||||
.tab_layout(craft::ui::patterns::form_dialogs::TabLayout::List)
|
||||
})
|
||||
.held_ok()
|
||||
}
|
||||
@@ -851,7 +844,6 @@ style_dialog!(ParaStyleOptions, KIND);
|
||||
pub fn open(app: &mut VectorcraftApp, name: &str) -> Result<Value, String> {
|
||||
crate::panels::character::end_typing(app);
|
||||
let unit = app.session.general_unit();
|
||||
let canvas = preview_canvas(app);
|
||||
let state = app.session.active().ok_or("no document open")?;
|
||||
let (document, doc) = ((state.uid, state.reverts), &state.doc);
|
||||
// [Normal Paragraph Style] has no definition until it is first redefined: it sets nothing.
|
||||
@@ -861,7 +853,7 @@ pub fn open(app: &mut VectorcraftApp, name: &str) -> Result<Value, String> {
|
||||
None => return Err(format!("no style `{name}`")),
|
||||
};
|
||||
let opening = Arc::new(Opening::new(name, attrs, unit, vertical_text(app)));
|
||||
let dialog = ParaStyleOptions { inner: hosted(KIND, tl!("Paragraph Style Options"), &opening, name, canvas).previews(), opening, document };
|
||||
let dialog = ParaStyleOptions { inner: hosted(KIND, tl!("Paragraph Style Options"), &opening, name).previews(), opening, document };
|
||||
app.dialogs().ok_or("no window")?.with(|host| host.open(dialog));
|
||||
Ok(json!({"dialog": KIND}))
|
||||
}
|
||||
|
||||
@@ -789,6 +789,9 @@ fn serve(app: &mut VectorcraftApp, ctx: &egui::Context, dialogs: &WindowDialogs,
|
||||
p.set_field("__summary.options", options.into());
|
||||
p.set_field("__summary.warnings", warnings.into());
|
||||
p.set_field("__inks", FieldValue::Json(inks));
|
||||
for (key, on) in bitmap_companions(&d.settings) {
|
||||
p.set_field(key, on.into());
|
||||
}
|
||||
});
|
||||
}
|
||||
// Physical printing waits until the dialog has applied the discovered list.
|
||||
@@ -1046,6 +1049,20 @@ fn scaling_ids(tiles: bool) -> Vec<&'static str> {
|
||||
PrintScaling::ALL.iter().filter(|s| s.tiles() == tiles).map(|s| s.id()).collect()
|
||||
}
|
||||
|
||||
/// Set by the pump while Print as Bitmap is on for composite output: Advanced › Resolution takes input.
|
||||
const BITMAP_ON: &str = "__bitmap.on";
|
||||
/// Set by the pump while `advanced.bitmapResolution` is 0: the note on the raster effects resolution shows.
|
||||
const BITMAP_AT_DOCUMENT: &str = "__bitmap.atDocument";
|
||||
|
||||
/// The values of [`BITMAP_ON`] and [`BITMAP_AT_DOCUMENT`] for the print settings `settings`.
|
||||
fn bitmap_companions(settings: &Value) -> [(&'static str, bool); 2] {
|
||||
let composite = settings["output"]["mode"].as_str() != Some(OutputMode::Separations.id());
|
||||
let on = composite && settings["advanced"]["printAsBitmap"].as_bool() == Some(true);
|
||||
// 0, the default, leaves the resolution to the document.
|
||||
let at_document = settings["advanced"]["bitmapResolution"].as_f64().is_none_or(|ppi| ppi == 0.0);
|
||||
[(BITMAP_ON, on), (BITMAP_AT_DOCUMENT, at_document)]
|
||||
}
|
||||
|
||||
/// A summary line that the pump fills (`key` is a `__` companion of the fields), selectable and named `label`.
|
||||
fn shown(key: &'static str, label: &'static str) -> Param {
|
||||
Param::custom(key, "", move |ui, fields, _| SelectableText::new(label, fields.text(key).unwrap_or_default()).multiline().show(ui))
|
||||
@@ -1195,7 +1212,11 @@ fn sections(lists: &Lists) -> Vec<PrintSection> {
|
||||
length("margin", tl!("Unprintable margin:")),
|
||||
note("marginNote", tl!("The edge of the paper the printer can't reach: the art goes inside it, and the preview shows it dashed.")),
|
||||
flag("advanced.printAsBitmap", tl!("Print as Bitmap")).enabled_when_in("output.mode", composite.clone()),
|
||||
note("bitmapNote", tl!("Each page prints as one image, at the document's raster effects resolution.")),
|
||||
Param::number("advanced.bitmapResolution", tl!("Resolution:"), 0.0, 1.0, 0)
|
||||
.bounds(Some(0.0), Some(vectorcraft_pdf::MAX_BITMAP_RESOLUTION))
|
||||
.unit(UnitKind::PixelsPerInch)
|
||||
.enabled_when(BITMAP_ON, true),
|
||||
note("bitmapNote", tl!("Each page prints as one image, at the document's raster effects resolution.")).visible_when(BITMAP_AT_DOCUMENT, true),
|
||||
Param::section(tl!("Overprint and Transparency Flattener Options")),
|
||||
pick::<PrintOverprints>("advanced.overprints", tl!("Overprints:")).enabled_when_in("output.mode", composite),
|
||||
Param::new("advanced.flattenerPreset", tl!("Preset:"), ParamKind::choice(flatteners, None)),
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
|
||||
use craft::print::ui::Printer;
|
||||
use egui::accesskit::Role;
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_engine::Session;
|
||||
|
||||
@@ -1439,6 +1440,56 @@ fn a_spot_inks_icon_converts_it_to_process_and_back() {
|
||||
assert_eq!(inks(&app), json!([{"name": "Gold", "print": true, "convertToProcess": false}]));
|
||||
}
|
||||
|
||||
/// What the Advanced section shows, read from the window's access tree after the pump has run: whether
|
||||
/// the Resolution field takes input (`None` without the field), and whether the note on the raster
|
||||
/// effects resolution shows.
|
||||
fn bitmap_rows(app: &mut VectorcraftApp) -> (Option<bool>, bool) {
|
||||
let ctx = ctx(app);
|
||||
ctx.enable_accesskit();
|
||||
pump(app);
|
||||
let out = crate::testing::app_frame(app, &ctx, Default::default());
|
||||
let nodes = out.platform_output.accesskit_update.map(|u| u.nodes).unwrap_or_default();
|
||||
let field = nodes
|
||||
.iter()
|
||||
.find(|(_, n)| n.label().is_some_and(|l| l.starts_with("Resolution")) && matches!(n.role(), Role::TextInput | Role::SpinButton))
|
||||
.map(|(_, n)| !n.is_disabled());
|
||||
// A label's text is its node's value.
|
||||
let note = nodes.iter().any(|(_, n)| n.label().or(n.value()).is_some_and(|t| t.starts_with("Each page prints as one image")));
|
||||
(field, note)
|
||||
}
|
||||
|
||||
/// Advanced › Resolution sets the resolution Print as Bitmap prints at: a field dimmed until Print as
|
||||
/// Bitmap is on for composite output, with the note on the raster effects resolution only while it is
|
||||
/// 0, printed and kept with the document by Print.
|
||||
#[test]
|
||||
fn the_advanced_section_sets_the_print_as_bitmap_resolution() {
|
||||
let (mut app, jobs) = app();
|
||||
app.run("file.print", json!({})).unwrap();
|
||||
pump(&mut app);
|
||||
press(&mut app, "Advanced");
|
||||
assert_eq!(bitmap_rows(&mut app), (Some(false), true), "dimmed with Print as Bitmap off");
|
||||
set(&mut app, "advanced.printAsBitmap", json!(true));
|
||||
assert_eq!(bitmap_rows(&mut app), (Some(true), true));
|
||||
set(&mut app, "output.mode", json!("separations"));
|
||||
assert_eq!(bitmap_rows(&mut app).0, Some(false), "dimmed for separations");
|
||||
set(&mut app, "output.mode", json!("composite"));
|
||||
pump(&mut app);
|
||||
set(&mut app, "advanced.bitmapResolution", json!(144));
|
||||
assert_eq!(bitmap_rows(&mut app), (Some(true), false), "the note shows only at 0");
|
||||
confirm(&mut app);
|
||||
assert!(!is_open(&app), "Print closes the dialog");
|
||||
let back = vectorcraft_pdf::import(&jobs.borrow()[0].2).unwrap();
|
||||
let mut sizes = vec![];
|
||||
back.walk(|n| {
|
||||
if let vectorcraft_doc::NodeKind::Image(im) = &n.kind {
|
||||
sizes.push((im.width, im.height));
|
||||
}
|
||||
});
|
||||
assert_eq!(sizes, [(240, 180)], "the artboard with art, 120 × 90 pt at 144 ppi");
|
||||
let saved = app.session.active().unwrap().doc.print_setup.as_ref().unwrap();
|
||||
assert_eq!(saved["advanced"]["bitmapResolution"], json!(144.0));
|
||||
}
|
||||
|
||||
/// The names screen readers give the number and text fields in `out`'s accessibility tree: a field's own
|
||||
/// name, else the text of a label it is labeled by, else "".
|
||||
pub(super) fn field_names(out: &egui::FullOutput) -> Vec<String> {
|
||||
|
||||
@@ -190,7 +190,7 @@ pub(crate) fn font_fields(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let sample = sample_text(app);
|
||||
let out = show_picker(app, ui, tl!("Font Family"), &s.font_family, sample.as_deref());
|
||||
// The preview ends before the pick that ends it is applied.
|
||||
apply_preview(app, out.edit.response.id, out.preview);
|
||||
apply_preview(app, out.edit.response.id, out.preview, out.preview_style.as_deref());
|
||||
let style = out.picked_style;
|
||||
let mut applied = false;
|
||||
for event in out.edit.events {
|
||||
@@ -227,8 +227,9 @@ pub(crate) fn apply_family(app: &mut VectorcraftApp, event: EditEvent<String>, s
|
||||
}
|
||||
|
||||
/// Shows or ends the live preview of the row under the pointer or the keyboard on the selected text, in
|
||||
/// one interaction that leaves nothing in the history. `owner` is the picker that shows it.
|
||||
pub(crate) fn apply_preview(app: &mut VectorcraftApp, owner: egui::Id, preview: Preview<String>) {
|
||||
/// one interaction that leaves nothing in the history. `owner` is the picker that shows it; `style` is the
|
||||
/// style of a style row, and without one the family takes the closest style it has.
|
||||
pub(crate) fn apply_preview(app: &mut VectorcraftApp, owner: egui::Id, preview: Preview<String>, style: Option<&str>) {
|
||||
match preview {
|
||||
Preview::Shows(family) => {
|
||||
if app.font_preview_owner.is_none() {
|
||||
@@ -239,7 +240,7 @@ pub(crate) fn apply_preview(app: &mut VectorcraftApp, owner: egui::Id, preview:
|
||||
}
|
||||
}
|
||||
app.font_preview_owner = Some(owner);
|
||||
let (cmd, params) = font_command(app, &family, None);
|
||||
let (cmd, params) = font_command(app, &family, style);
|
||||
if let Err(e) = app.session.preview(cmd, ¶ms) {
|
||||
app.ui.status = e.to_string();
|
||||
}
|
||||
|
||||
@@ -157,10 +157,10 @@ fn a_preview_keeps_the_document_filters_families() {
|
||||
let mut app = app_with_type(&["Source Serif 4", "Inter"]);
|
||||
assert_eq!(used(&mut app), ["inter", "source serif 4"]);
|
||||
// The selected text, the only type in Inter, previewed in Source Serif 4.
|
||||
super::apply_preview(&mut app, owner, Preview::Shows("Source Serif 4".into()));
|
||||
super::apply_preview(&mut app, owner, Preview::Shows("Source Serif 4".into()), None);
|
||||
assert!(app.session.active().unwrap().interaction.is_some(), "the preview is open");
|
||||
assert_eq!(used(&mut app), ["inter", "source serif 4"], "the preview leaves the set as it was");
|
||||
super::apply_preview(&mut app, owner, Preview::Shows("Inter".into()));
|
||||
super::apply_preview(&mut app, owner, Preview::Shows("Inter".into()), None);
|
||||
assert_eq!(used(&mut app), ["inter", "source serif 4"], "previewing back changes nothing");
|
||||
super::apply_family(&mut app, set("Inter", "Source Serif 4"), None);
|
||||
assert_eq!(used(&mut app), ["source serif 4"], "the pick is an edit: Inter is no longer used");
|
||||
@@ -281,7 +281,7 @@ fn a_preview_size_asked_for_sets_the_preference_and_keeps_the_preview() {
|
||||
vectorcraft_doc::NodeKind::Text(t) => t.first_style().font_family,
|
||||
_ => String::new(),
|
||||
};
|
||||
super::apply_preview(&mut app, owner, Preview::Shows("Source Serif 4".into()));
|
||||
super::apply_preview(&mut app, owner, Preview::Shows("Source Serif 4".into()), None);
|
||||
assert_eq!(font(&app), "Source Serif 4");
|
||||
assert!(!app.take_prefs_changed(), "nothing to write yet");
|
||||
let undo_depth = |app: &VectorcraftApp| app.session.doc().unwrap().history.undo.len();
|
||||
@@ -299,7 +299,7 @@ fn a_preview_size_asked_for_sets_the_preference_and_keeps_the_preview() {
|
||||
assert_eq!(app.ui.engine_prefs["fontPreviewSize"], "large");
|
||||
assert!(app.session.in_interaction(), "the preview is still open");
|
||||
assert_eq!(font(&app), "Source Serif 4", "the preview stays on the type");
|
||||
super::apply_preview(&mut app, owner, Preview::Ended);
|
||||
super::apply_preview(&mut app, owner, Preview::Ended, None);
|
||||
assert_eq!(font(&app), "Inter");
|
||||
app.run("edit.undo", serde_json::json!({})).unwrap();
|
||||
assert!(
|
||||
|
||||
@@ -356,9 +356,10 @@ pub struct VectorcraftApp {
|
||||
/// (`--automation-read-root`, `--automation-write-root`); `None`: anywhere. See
|
||||
/// [`Self::with_automation_roots`].
|
||||
automation_roots: Option<Arc<AutomationRoots>>,
|
||||
/// The last root frame of a drop of files the OS made in a pass that carried injected input: the drag session
|
||||
/// delivers that drop in the next frame, which [`Self::ui`] confines to the automation roots as well.
|
||||
confined_drop: Option<u64>,
|
||||
/// The files the OS dropped in a pass that carried injected input, while the drag session holds them: every pass
|
||||
/// until the session lets them go, the one that delivers them included, is confined to the automation roots as well
|
||||
/// ([`Self::ui`]).
|
||||
confined_drop: Option<Arc<craft::ui::runtime::drag::OsFiles>>,
|
||||
/// The agents link while the ArtCraft Launcher's switch may let agents in ([`Self::with_agents`]).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) agents: Option<Box<agents::Agents>>,
|
||||
|
||||
@@ -1253,9 +1253,9 @@ pub(crate) fn controls(app: &mut VectorcraftApp, ui: &mut Ui, rows: CharacterRow
|
||||
}
|
||||
let out = controls.show(ui);
|
||||
hold.store(app, &before);
|
||||
let CharacterControlsOutput { picker, preview_family, edits, .. } = out;
|
||||
let CharacterControlsOutput { picker, preview_family, preview_style, edits, .. } = out;
|
||||
if let Some(owner) = picker {
|
||||
font_menu::apply_preview(app, owner, preview_family);
|
||||
font_menu::apply_preview(app, owner, preview_family, preview_style.as_deref());
|
||||
}
|
||||
for event in edits {
|
||||
apply_character_event(app, event);
|
||||
|
||||
@@ -102,13 +102,6 @@ pub struct GradientUi {
|
||||
/// `paint.editGradient` sorts the stops, so the gradient shown mid-gesture is the last preview
|
||||
/// re-sorted: the editor's tags name stops of this one.
|
||||
pub(crate) begun: Option<Vec<GradientStop>>,
|
||||
/// The press of a double click that asked for a stop's color is still held. Until craft-libs#5131 reaches the
|
||||
/// pin, the slider also drags the stop when the pointer drifts during that press, and the moved stop closes the
|
||||
/// popover the double click opened: the panel drops that press's slider edits.
|
||||
pub(crate) color_press: bool,
|
||||
/// The slider's gesture that the press above began, dropped until its `Commit` or `Cancel`, which can arrive in a
|
||||
/// pass after the button is up.
|
||||
pub(crate) color_drag: bool,
|
||||
}
|
||||
|
||||
/// Select stop `i` (the session's selected stop, shared with the Gradient tool's annotator, the
|
||||
@@ -838,21 +831,6 @@ fn stops_editor(app: &mut VectorcraftApp, ui: &mut Ui, g: &GradientPaint, is_gra
|
||||
.shared_selection(Bind::bound(&mut shared))
|
||||
.drop_target::<PanelDrag>()
|
||||
.show(ui);
|
||||
let panel = &mut app.ui.gradient_panel;
|
||||
let color_press = panel.color_press || out.color_requested.is_some();
|
||||
let held = craft::ui::runtime::pointer::press_state(ui.ctx()).buttons.contains(craft::behavior::Buttons::PRIMARY);
|
||||
let dropping = panel.color_drag || (color_press && out.edit.events.began());
|
||||
let ended = matches!(out.edit.events.last(), Some(EditEvent::Commit { .. } | EditEvent::Cancel { .. } | EditEvent::Set { .. }));
|
||||
panel.color_press = color_press && held;
|
||||
panel.color_drag = dropping && !ended;
|
||||
if color_press || dropping {
|
||||
// The drift of the press that asked for the color moves no stop (craft-libs#5131).
|
||||
if is_grad && let Some(request) = &out.color_requested {
|
||||
let at = request.rect.map_or(out.edit.response.rect.left_bottom(), |r| r.left_bottom());
|
||||
open_popover(app, request.index, at);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let events = &out.edit.events;
|
||||
if !is_grad {
|
||||
// The slider shows the default gradient: an edit of it applies a gradient first.
|
||||
|
||||
@@ -406,6 +406,31 @@ fn tool_keys_choose_their_tools() {
|
||||
}
|
||||
}
|
||||
|
||||
/// E with the Extend Path tool and no drag cycles the tool's shape; with another tool E still chooses Free Transform.
|
||||
#[test]
|
||||
fn e_with_the_extend_path_tool_cycles_its_shape_without_a_drag() {
|
||||
let press_e = |tool: &str| {
|
||||
let mut app = new_app();
|
||||
let ctx = ready(&mut app);
|
||||
app.select_tool(tool);
|
||||
focus_canvas(&mut app, &ctx);
|
||||
assert!(!app.session.tool_busy());
|
||||
key_frame(&mut app, &ctx, typed(Key::E, Modifiers::NONE, "e"));
|
||||
app
|
||||
};
|
||||
let app = press_e("selection");
|
||||
assert_eq!(app.session.tool_id(), "freeTransform", "E's shortcut with a tool that does not use E");
|
||||
|
||||
let extend = vectorcraft_tools::addons::extend_path::ID;
|
||||
let mut app = press_e(extend);
|
||||
assert_eq!(app.session.tool_id(), extend, "E is the tool's key");
|
||||
assert_eq!(app.session.tool_options()["mode"], "bezier", "E cycles straight to bezier");
|
||||
let ctx = ready(&mut app);
|
||||
focus_canvas(&mut app, &ctx);
|
||||
key_frame(&mut app, &ctx, typed(Key::E, Modifiers::NONE, "e"));
|
||||
assert_eq!(app.session.tool_options()["mode"], "arc", "a second E cycles on");
|
||||
}
|
||||
|
||||
/// A tool bound to a key that types nothing, a panel and a command, and a held Cmd+= zooms on.
|
||||
#[test]
|
||||
fn shortcuts_run_tools_panels_and_commands() {
|
||||
|
||||
@@ -104,6 +104,10 @@ pub struct View {
|
||||
/// How the canvas reaches the view the app last set ([`Self::set_canvas`] callers).
|
||||
#[serde(skip)]
|
||||
pub moved: Option<ViewMove>,
|
||||
/// What the canvas's last pan left to move ([`crate::canvas::PanRest`]). Temporary, removed with the craft-libs pin
|
||||
/// bump that brings in storytold/craft-libs#5411.
|
||||
#[serde(skip)]
|
||||
pub(crate) pan_rest: Option<crate::canvas::PanRest>,
|
||||
}
|
||||
|
||||
impl Default for View {
|
||||
@@ -122,6 +126,7 @@ impl Default for View {
|
||||
rect: egui::Rect::NOTHING,
|
||||
request: None,
|
||||
moved: None,
|
||||
pan_rest: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,10 +619,24 @@ fn a_drop_in_a_pass_with_one_step_of_injected_input_is_confined_when_delivered()
|
||||
drop_in_an_injected_pass_is_confined("ui.text", json!({"text": "a"}));
|
||||
}
|
||||
|
||||
/// The OS held the file under the pointer and drops it in a pass with no pointer position: the drag
|
||||
/// session holds the drop until a later pass resolves its target, and the drop is still refused when
|
||||
/// it is delivered there.
|
||||
#[test]
|
||||
fn a_drop_that_waits_for_its_target_is_confined_when_delivered() {
|
||||
drop_is_confined("ui.text", json!({"text": "a"}), true);
|
||||
}
|
||||
|
||||
/// Injects `method` with `params`, has the person drop a file outside the automation roots in the
|
||||
/// same pass, and checks that the drop opens nothing, then that a later drop of the person's opens
|
||||
/// the file.
|
||||
fn drop_in_an_injected_pass_is_confined(method: &str, params: Value) {
|
||||
drop_is_confined(method, params, false);
|
||||
}
|
||||
|
||||
/// [`drop_in_an_injected_pass_is_confined`]; `pointer`: the pass that hovers the file carries a
|
||||
/// pointer position and the drop's pass none, so the drag session delivers the drop a pass later.
|
||||
fn drop_is_confined(method: &str, params: Value, pointer: bool) {
|
||||
#[derive(Debug)]
|
||||
struct Dropped(PathBuf);
|
||||
impl egui::DroppedFile for Dropped {
|
||||
@@ -633,7 +647,8 @@ fn drop_in_an_injected_pass_is_confined(method: &str, params: Value) {
|
||||
std::fs::read(&self.0).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
let (mut app, tx, base) = confined(&format!("synthetic-{method}"));
|
||||
// Each scenario has its own directory, so tests running in parallel do not remove each other's files.
|
||||
let (mut app, tx, base) = confined(&format!("synthetic-{method}-{}", if pointer { "pointer" } else { "nopointer" }));
|
||||
let ctx = crate::testing::ui_context();
|
||||
let outside = base.join("outside/b.svg");
|
||||
// The OS holds the file over the window in the pass before it drops it (`hovered`), as a desktop drag does.
|
||||
@@ -641,6 +656,12 @@ fn drop_in_an_injected_pass_is_confined(method: &str, params: Value) {
|
||||
let mut raw = egui::RawInput::default();
|
||||
if hovered {
|
||||
raw.hovered_files.push(egui::HoveredFile { path: Some(outside.clone()), mime: String::new() });
|
||||
if pointer {
|
||||
raw.events.push(egui::Event::PointerMoved(egui::pos2(300.0, 300.0)));
|
||||
}
|
||||
}
|
||||
if dropped && pointer {
|
||||
raw.events.push(egui::Event::PointerGone);
|
||||
}
|
||||
if dropped {
|
||||
raw.dropped_files.push(std::sync::Arc::new(Dropped(outside.clone())));
|
||||
@@ -653,13 +674,13 @@ fn drop_in_an_injected_pass_is_confined(method: &str, params: Value) {
|
||||
tx.send(req).unwrap();
|
||||
app.run_control(&ctx);
|
||||
pass(&mut app, false, true);
|
||||
// The drag session delivers a drop of files in the pass after the one the OS dropped them in.
|
||||
assert_eq!(pass(&mut app, false, false), 0, "{method}: the drop of the pass carrying the input is confined");
|
||||
for _ in 0..4 {
|
||||
pass(&mut app, false, false);
|
||||
// The drag session delivers a drop of files in a pass after the one the OS dropped them in.
|
||||
for _ in 0..5 {
|
||||
assert_eq!(pass(&mut app, false, false), 0, "{method}: the drop of the pass carrying the input is confined");
|
||||
}
|
||||
pass(&mut app, true, false);
|
||||
pass(&mut app, false, true);
|
||||
pass(&mut app, false, false);
|
||||
assert_eq!(pass(&mut app, false, false), 1, "{method}: the person's pass is not");
|
||||
let _ = std::fs::remove_dir_all(base);
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ fn recent_fonts_follow_committed_choices_and_the_count_preference() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({})).unwrap();
|
||||
let id = app.run("text.create", json!({"x": 20, "y": 50, "text": "Recent fonts", "font": "Inter"})).unwrap()["id"].clone();
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into()));
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into()), None);
|
||||
assert!(app.recent_fonts().is_empty());
|
||||
apply_preview(&mut app, owner(), Preview::Ended);
|
||||
apply_preview(&mut app, owner(), Preview::Ended, None);
|
||||
assert!(app.recent_fonts().is_empty());
|
||||
apply_family(&mut app, set("Inter", "Source Serif 4"), None);
|
||||
app.run("text.setStyle", json!({"font": "Inter"})).unwrap();
|
||||
@@ -161,24 +161,42 @@ fn preview_changes_the_text_live_and_only_a_choice_is_a_step() {
|
||||
let steps = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len();
|
||||
assert_eq!(sample_text(&app).as_deref(), Some("Gagaku"));
|
||||
let before = steps(&app);
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into()));
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into()), None);
|
||||
assert_eq!(font_of(&app, id), "Source Serif 4", "previewed on the text");
|
||||
assert_eq!(
|
||||
crate::panels::character::values(&mut app).family.as_deref(),
|
||||
Some("Inter"),
|
||||
"the picker must still be able to commit the previewed row"
|
||||
);
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Sans 3".into()));
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Sans 3".into()), None);
|
||||
assert_eq!(font_of(&app, id), "Source Sans 3");
|
||||
apply_preview(&mut app, owner(), Preview::Ended);
|
||||
apply_preview(&mut app, owner(), Preview::Ended, None);
|
||||
assert_eq!((font_of(&app, id), steps(&app)), ("Inter".to_string(), before), "the preview leaves nothing behind");
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into()));
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into()), None);
|
||||
apply_family(&mut app, set("Inter", "Source Serif 4"), None);
|
||||
assert_eq!((font_of(&app, id), steps(&app)), ("Source Serif 4".to_string(), before + 1), "one step");
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(font_of(&app, id), "Inter");
|
||||
}
|
||||
|
||||
/// #10798: a style row under the pointer previews the type in that style; the family row after it previews the family
|
||||
/// in its own style, and the end of the preview puts the type back.
|
||||
#[test]
|
||||
fn a_style_row_previews_its_style_on_the_text() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
let id = selected_inter(&mut app);
|
||||
let styles = FontDb::global().styles("Inter");
|
||||
let style = styles.iter().find(|s| *s != "Regular").unwrap_or_else(|| panic!("Inter has a style besides Regular: {styles:?}"));
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Inter".into()), Some(style));
|
||||
let s = first_style(&app, id);
|
||||
assert_eq!((s.font_family.as_str(), s.font_style.as_str()), ("Inter", style.as_str()), "the hovered style shows on the text");
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Inter".into()), None);
|
||||
assert_eq!(first_style(&app, id).font_style, "Regular", "the family row shows the type's own style");
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Inter".into()), Some(style));
|
||||
apply_preview(&mut app, owner(), Preview::Ended, None);
|
||||
assert_eq!(first_style(&app, id).font_style, "Regular", "the preview leaves nothing behind");
|
||||
}
|
||||
|
||||
/// A preview whose picker isn't shown any more (the text was deselected, the panel closed) is undone.
|
||||
#[test]
|
||||
fn a_preview_left_open_by_a_menu_that_is_gone_is_undone() {
|
||||
@@ -187,7 +205,7 @@ fn a_preview_left_open_by_a_menu_that_is_gone_is_undone() {
|
||||
let id = app.session.execute("text.create", &json!({"x": 20, "y": 50, "text": "Gagaku", "font": "Inter"})).unwrap()["id"].as_u64().unwrap();
|
||||
app.session.execute("select.set", &json!({"ids": [id]})).unwrap();
|
||||
let steps = app.session.active().unwrap().history.undo.len();
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into()));
|
||||
apply_preview(&mut app, owner(), Preview::Shows("Source Serif 4".into()), None);
|
||||
assert!(app.session.in_interaction());
|
||||
let previewer = app.font_preview_owner.expect("the app records who previews");
|
||||
end_previews(&mut app, &[previewer]);
|
||||
|
||||
@@ -125,6 +125,50 @@ fn home_screen(app: VectorcraftApp) -> Panel {
|
||||
home
|
||||
}
|
||||
|
||||
/// Where one frame of the whole window `size` big painted Home's title, after `events`.
|
||||
fn home_title_after(app: &mut VectorcraftApp, ctx: &egui::Context, size: egui::Vec2, events: Vec<egui::Event>) -> egui::Rect {
|
||||
let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)), events, ..Default::default() };
|
||||
let out = crate::testing::app_frame(app, ctx, raw);
|
||||
let titles: Vec<egui::Rect> = crate::tests_labels::painted_shapes(&out.shapes)
|
||||
.into_iter()
|
||||
.filter_map(|(shape, transform, _)| match shape {
|
||||
egui::Shape::Text(t) if t.galley.text() == "Welcome to VectorCraft" => Some(transform * t.visual_bounding_rect()),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(titles.len(), 1, "Home paints its title once: {titles:?}");
|
||||
titles[0]
|
||||
}
|
||||
|
||||
/// How far a wheel turned to the end over Home's title moves the title, with no recent files in a window `size` big.
|
||||
fn home_title_moved_by_a_wheel(size: egui::Vec2) -> f32 {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
|
||||
let ctx = crate::testing::ui_context();
|
||||
for _ in 0..3 {
|
||||
home_title_after(&mut app, &ctx, size, vec![]);
|
||||
}
|
||||
assert!(crate::menus::home_showing(&app), "Home with no document open");
|
||||
let before = home_title_after(&mut app, &ctx, size, vec![]);
|
||||
home_title_after(&mut app, &ctx, size, vec![egui::Event::PointerMoved(before.center())]);
|
||||
home_title_after(&mut app, &ctx, size, vec![craft::ui::testing::pointer::wheel(-2000.0)]);
|
||||
let mut after = before;
|
||||
for _ in 0..3 {
|
||||
after = home_title_after(&mut app, &ctx, size, vec![]);
|
||||
}
|
||||
after.top() - before.top()
|
||||
}
|
||||
|
||||
/// At the app's default window size, Home's column fits the canvas view, so the page has no room to scroll and shows no
|
||||
/// scroll bar beside the docks: a wheel leaves the title where it is. In a smaller window, where the Learn cards stand
|
||||
/// two by two and the column is taller than the view, the page scrolls.
|
||||
#[test]
|
||||
fn home_scrolls_only_when_its_column_is_taller_than_the_window() {
|
||||
let moved = home_title_moved_by_a_wheel(egui::vec2(1440.0, 900.0));
|
||||
assert!(moved.abs() < 0.5, "at 1440 by 900 the column fits, so the page does not scroll: moved {moved}");
|
||||
let moved = home_title_moved_by_a_wheel(egui::vec2(1280.0, 800.0));
|
||||
assert!(moved < -1.0, "at 1280 by 800 the column is taller than the view, so the page scrolls: moved {moved}");
|
||||
}
|
||||
|
||||
/// Home's Open while a file dialog is still open (a window the system may have placed out of sight)
|
||||
/// says so in the status bar and asks for no second picker; once the first answers, Open asks again
|
||||
/// (#6160).
|
||||
|
||||
@@ -420,7 +420,7 @@ fn the_font_menu_preview_reads_the_menus_when_it_ends() {
|
||||
m.app.run("select.none", json!({})).unwrap();
|
||||
m.app.run("text.create", json!({"x": 50, "y": 50, "text": "Hi"})).unwrap();
|
||||
m.frame(vec![]);
|
||||
let shows = |font: &'static str| move |app: &mut VectorcraftApp| apply_preview(app, owner, Preview::Shows(font.into()));
|
||||
let shows = |font: &'static str| move |app: &mut VectorcraftApp| apply_preview(app, owner, Preview::Shows(font.into()), None);
|
||||
assert_eq!(read(m, &shows("Source Serif 4")), 1, "the menus were read as the preview began");
|
||||
let between = read(m, &shows("Source Sans 3")) + read(m, &shows("Inter"));
|
||||
let ended = read(m, &|app| end_previews(app, &[owner]));
|
||||
|
||||
@@ -96,21 +96,7 @@ fn bullets_and_numbering_keeps_the_canvas_open() {
|
||||
assert!(wheel_scrolls_the_view(&mut app, &ctx), "the wheel over the canvas scrolls the view under Bullets and Numbering");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn character_style_options_keeps_the_canvas_open() {
|
||||
let (mut app, ctx) = app();
|
||||
app.run("ui.charStyleOptions", json!({"name": vectorcraft_engine::cmd::textstyles::NORMAL_CHAR})).unwrap();
|
||||
assert!(wheel_scrolls_the_view(&mut app, &ctx), "the wheel over the canvas scrolls the view under Character Style Options");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paragraph_style_options_keeps_the_canvas_open() {
|
||||
let (mut app, ctx) = app();
|
||||
app.run("ui.paraStyleOptions", json!({"name": vectorcraft_engine::cmd::textstyles::NORMAL_PARA})).unwrap();
|
||||
assert!(wheel_scrolls_the_view(&mut app, &ctx), "the wheel over the canvas scrolls the view under Paragraph Style Options");
|
||||
}
|
||||
|
||||
/// New Character Style shares the style dialog but does not preview, so the canvas stays covered.
|
||||
/// New Character Style does not preview, so the canvas stays covered.
|
||||
#[test]
|
||||
fn new_character_style_leaves_the_canvas_covered() {
|
||||
let (mut app, ctx) = app();
|
||||
|
||||
+46
-24
@@ -3503,7 +3503,11 @@ through `$`:
|
||||
When the format is selected by a `.vctemplate` path, `saveAs` writes a template copy and leaves the document's
|
||||
file and saved state unchanged.
|
||||
`Document.exportFile(file, exportType, options?)` runs `document.export` and leaves the document's file as it is.
|
||||
`app.open(file, documentColorSpace?, options?)` runs `document.open` and gives the new `Document`
|
||||
Each method sends command warnings to the Script Console with its name as the prefix: `Document.saveAs: `,
|
||||
`Document.exportFile: ` or `app.open: `. Without options, `saveAs` selects the format from the supplied name before following a link.
|
||||
`app.open(file, documentColorSpace?, options?)` runs `document.open` and gives the new `Document`; a file
|
||||
larger than 128 MiB, the most a script command reads, throws before it is read: above 256 MiB the error is
|
||||
`Script document exceeds 256 MiB`, and otherwise it ends `file exceeds 128 MiB`
|
||||
(https://ai-scripting.docsforadobe.dev/jsobjref/Document/, https://ai-scripting.docsforadobe.dev/jsobjref/Application/).
|
||||
`file` is a `File`. `new IllustratorSaveOptions()`, `new EPSSaveOptions()` and `new PDFSaveOptions()` pick the
|
||||
format (https://ai-scripting.docsforadobe.dev/jsobjref/IllustratorSaveOptions/,
|
||||
@@ -3555,7 +3559,9 @@ through `$`:
|
||||
path whose real file name is not valid UTF-8 throws `Script file path is not valid UTF-8` before anything is written
|
||||
or opened.
|
||||
VectorCraft's own rules: each path is checked as a `File` opened for reading or writing is checked, before the
|
||||
command runs. A path outside the script's folders throws `Script file access denied`, also when it is an open
|
||||
command runs. A resolved path that is not valid UTF-8 throws before the command runs. `app.open` keeps the
|
||||
supplied name for format detection, so a `.vctemplate` link to a native document opens an untitled copy.
|
||||
A path outside the script's folders throws `Script file access denied`, also when it is an open
|
||||
document's file, a link that leads outside them, or the settings folder; a read-only file throws `Script file is
|
||||
read-only`; a file a `File` object holds open for writing throws `Script file is open for writing` on `saveAs`
|
||||
and `exportFile`, and `Script file access denied` when a command would write it besides the file named; and the
|
||||
@@ -3567,8 +3573,9 @@ through `$`:
|
||||
visible art. An SVG with `embedRasterImages` false also writes the document's embedded images beside it, and a
|
||||
DXF of a drawing with placed raster images writes each image it exports beside it as a PNG file, or a JPEG
|
||||
file with `rasterFormat` `AutoCADRasterFormat.JPEG`; those files must travel with the DXF. When the script's
|
||||
folders refuse one of those files, or one is a folder or an existing read-only file, none of them is written; a
|
||||
write that fails once the
|
||||
folders refuse one of those files, or one is a folder or an existing read-only file, or a destination-collision
|
||||
check fails, none of them is written. Destinations that resolve to the same file are refused, including two names
|
||||
in one folder that differ only in letter case. A write that fails once the
|
||||
first file is in place leaves the files written before it. A listed option that is not mapped is accepted at its help page's default, and any other value throws
|
||||
an error that says it is not available yet, as does `ExportType.FLASH`. A property the help
|
||||
pages do not list throws an error that names it (`PDFFileOptions` also accepts its read-only `typename` and
|
||||
@@ -3603,7 +3610,7 @@ through `$`:
|
||||
`SaveOptions.PROMPTTOSAVECHANGES`, the default, throws an error and leaves the document open, since a script cannot
|
||||
show the prompt. A bad value throws an error before anything is written. The warnings of the save or export that
|
||||
`saveAs`, `exportFile`, `app.open` and `close` run go to the console, each after the method's name
|
||||
(`saveAs: …`).
|
||||
(`Document.saveAs: …`, `Document.exportFile: …`, `app.open: …`, `Document.close: …`).
|
||||
- `Document.exportForScreens(exportFolder, exportFormat, options?, itemToExport?, fileNamePrefix?)` runs
|
||||
`document.exportForScreens` with one format row into `exportFolder`, a `Folder` (or a `File`, read as the folder at
|
||||
its path) (https://www.indesignjs.de/indesignapi/illustrator/Document.html). `exportFormat` is an
|
||||
@@ -3647,7 +3654,7 @@ through `$`:
|
||||
another class throws. `null` in place of the options, `itemToExport` or `fileNamePrefix` throws a TypeError. A bad option value throws an error before anything is written. Each export checks the scale of
|
||||
each of its items before it writes, and an item too large to draw throws after the files before it are written. A
|
||||
size gives each region its own scale, so a size that only a later export's items make out of range throws after the
|
||||
earlier exports' files are written. The warnings of each export go to the console after `exportForScreens: `.
|
||||
earlier exports' files are written. The warnings of each export go to the console after `Document.exportForScreens: `.
|
||||
- `Document.placedItems` (https://ai-scripting.docsforadobe.dev/jsobjref/PlacedItems/) lists the document's linked
|
||||
images and `Document.rasterItems` (https://ai-scripting.docsforadobe.dev/jsobjref/RasterItems/) its embedded ones,
|
||||
topmost first as `pageItems` lists them, each with `length`, `[i]`, `index(key)`, `getByName(name)` and `removeAll()`. `placedItems.add()`
|
||||
@@ -3738,9 +3745,10 @@ through `$`:
|
||||
its help page's default until it is assigned, and a `PrintOptions` holds its option objects by reference, so a change
|
||||
made after the assignment is printed. `print` maps `printPreset` (a print preset's name) and `flattenerPreset`;
|
||||
`copies` (1 to 999), `collate`, `reversePages`, `designation`, `printAllArtboards`, `artboardRange`,
|
||||
`printAsBitmap` and `file` of the job; `colorProfileMode` (`SOURCEPROFILE` and `CUSTOMPROFILE`), `intent` and
|
||||
`name` (an RGB or CMYK profile) of color management; `colorSeparationMode` (`COMPOSITE` and
|
||||
`HOSTBASEDSEPARATION`), `convertSpotColors` and `overPrintBlack`; `emulsion`, `fitToPage`, `horizontalScale` and
|
||||
`printAsBitmap`, `bitmapResolution` (`advanced.bitmapResolution`: 0 for the document's raster effects resolution,
|
||||
or 1 to 9600 ppi; `print` throws for a value between 0 and 1) and `file` of the job; `colorProfileMode`
|
||||
(`SOURCEPROFILE` and `CUSTOMPROFILE`), `intent` and `name` (an RGB or CMYK profile) of color management;
|
||||
`colorSeparationMode` (`COMPOSITE` and `HOSTBASEDSEPARATION`), `convertSpotColors` and `overPrintBlack`; `emulsion`, `fitToPage`, `horizontalScale` and
|
||||
`verticalScale` (1 to 1000), `orientation`, `position` and `tiling`; `overprint` of the flattener; `colorBars`,
|
||||
`pageInfoMarks`, `registrationMarks`, `trimMarks`, `pageMarksType` and `trimMarksWeight`; `name`, `width`,
|
||||
`height` and `transverse` of the paper; and `negativePrinting` and `postScriptLevel` (`PSLEVEL2` and `PSLEVEL3`).
|
||||
@@ -3749,9 +3757,11 @@ through `$`:
|
||||
`PrintPosition`, `PrintTiling`, `PrintArtworkDesignation`, `PrintingBounds`, `PrintFontDownloadMode`,
|
||||
`FontSubstitutionPolicy`, `PageMarksTypes`, `PostScriptImageCompressionType` and `PrinterPostScriptLevelEnum` hold
|
||||
strings such as `"PrintTiling.TILEFULLPAGES"`. VectorCraft's own rules: `print` writes the file `jobOptions.file`
|
||||
names, checked as `saveAs` checks its file: PostScript when the name ends with `.ps` or `postScriptLevel` is
|
||||
names. `jobOptions.file` keeps the assigned File object and uses its current path when printing.
|
||||
The file is checked as `saveAs` checks its file: PostScript when the name ends with `.ps` (any case, including `.ps` alone) or `postScriptLevel` is
|
||||
assigned, a print-ready PDF otherwise, also when that name is a link to a file with another extension, and
|
||||
`printerName` does not apply. Without a file, `print` prints to the
|
||||
`printerName` does not apply. The PostScript is level 2 when `postScriptLevel` is not assigned, the default it
|
||||
reads as. Without a file, `print` prints to the
|
||||
printer `printerName` names, or to the system's default printer when it is `""` or not assigned
|
||||
(https://ai-scripting.docsforadobe.dev/jsobjref/PrintOptions/). The name must be exactly the name of a printer the
|
||||
app listed for the run, or `print` throws `PrintOptions.printerName names no installed printer`; with no default
|
||||
@@ -3780,19 +3790,24 @@ through `$`:
|
||||
is never read as a path, a URL or a command. `fitToPage` set to true wins over the scale factors and the tiling
|
||||
mode. With `printAllArtboards` false, `artboardRange` picks the artboards, and without a range every artboard
|
||||
prints. With `printAllArtboards` not assigned, an assigned `artboardRange` replaces the range of the settings
|
||||
`print` starts from, which prints when those settings print a range. `print` starts from the preset's settings
|
||||
`print` starts from, which prints when those settings print a range. An assigned empty or whitespace-only range
|
||||
prints every artboard. `print` starts from the preset's settings
|
||||
when `printPreset` is assigned, otherwise from the document's saved settings. When those settings ignore the
|
||||
artboards, an assigned `printArea` prints the artboards an assigned `artboardRange` names, or each artboard without
|
||||
a range. With one of `horizontalScale` and `verticalScale` assigned, the other keeps its value in the settings
|
||||
`print` starts from. `print` throws before anything is written when an assigned `artboardRange` names an
|
||||
`print` starts from. With no scale or tiling assigned, `fitToPage = false` clears a base fit mode and preserves
|
||||
other base scaling modes. An assigned `position` places an untiled job even when the base settings hold a placed
|
||||
Print Tiling origin; the saved settings keep that origin. `print` throws before anything is written when an assigned `artboardRange` names an
|
||||
artboard the document does not have, also with `printAllArtboards` true, when `printPreset` or `flattenerPreset`
|
||||
is not a preset's name (any case), when `colorManagementOptions.name` is not an RGB or CMYK profile's name (any
|
||||
case) or `colorProfileMode` is assigned `CUSTOMPROFILE` without a `name`, when `paperOptions.name` is not a paper `file.print` knows, or when it names a paper other than `custom`
|
||||
and `width` or `height` is assigned above 0. An assigned name that is empty or only spaces, or holds `/`, `\` or
|
||||
case), when `paperOptions.name` is not a paper `file.print` knows, or when it names a paper other than `custom`
|
||||
and `width` or `height` is assigned above 0. `CUSTOMPROFILE` requires an assigned profile name or a profile in
|
||||
the base settings; otherwise `print` throws before writing. An assigned name that is empty or only spaces, or holds `/`, `\` or
|
||||
a control character (also at either end), throws too, and each checked name is sent without the spaces around it.
|
||||
`PPDName` takes only `""`. A listed option that is not mapped, or a value that is not mapped such as
|
||||
`PrintingBounds.ARTWORKBOUNDS`, `INRIPSEPARATION`, `PSLEVEL1` or a scale above 1000 with `fitToPage` not true,
|
||||
throws an error that says it is not available yet. Each value is checked when it is assigned: a wrong type, a number that is not finite or is
|
||||
throws an error that says it is not available yet. Paper `width` and `height` take 0 (not assigned) or 72 to
|
||||
14,400 pt. Each value is checked when it is assigned: a wrong type, a number that is not finite or is
|
||||
out of range, a string longer than 4,096 bytes, an option object of the wrong class or from an earlier run, and a
|
||||
path given as a string all throw. A run makes at most 256 option objects. Each warning `file.print` gives goes to
|
||||
the Script Console as a line that starts with `Document.print: `. `vc.run` still cannot run `file.print` or
|
||||
@@ -14433,16 +14448,23 @@ the placement then shows as placed by the tool, with a Reset button; dragging th
|
||||
## Print advanced options
|
||||
|
||||
The Print dialog's Advanced section and the printer profile are print settings too (`print.setup`, `print.preview`,
|
||||
`file.print`): `advanced: {printAsBitmap, overprints: preserve|discard|simulate, flattenerPreset}` and `color:
|
||||
{profile}`. In composite output, `preserve` writes overprinting fills and strokes with an overprinting graphics state
|
||||
(`/OP`, as PDF export does), `discard` makes overprinting fills and strokes knock out and `simulate` prints them
|
||||
`file.print`): `advanced: {printAsBitmap, bitmapResolution, overprints: preserve|discard|simulate, flattenerPreset}`
|
||||
and `color: {profile}`. In composite output, `preserve` writes overprinting fills and strokes with an overprinting
|
||||
graphics state (`/OP`, as PDF export does), `discard` makes overprinting fills and strokes knock out and `simulate` prints them
|
||||
as Overprint Preview shows them (darkened); either way the file has no overprint left. Separations always keep
|
||||
overprints. `flattenerPreset` (High Resolution, Medium Resolution, Low Resolution or a saved preset,
|
||||
`flattener.presets.list`) flattens transparency before printing, as Object → Flatten Transparency does; empty, a
|
||||
PDF keeps it live (PostScript, which has none, uses `file.print`'s `flattenerPreset`, else this one, else medium).
|
||||
`printAsBitmap` prints each composite page as one image of the art at the document's raster effects resolution,
|
||||
or at the highest resolution that fits when the image would be larger than 64 million pixels or longer than 32,768
|
||||
pixels a side.
|
||||
`printAsBitmap` prints each composite page as one image of the art at `bitmapResolution`, or at the highest
|
||||
resolution that fits when the image would be larger than 64 million pixels or longer than 32,768 pixels a side.
|
||||
The resolution is measured on paper: a page printed at 200%, or enlarged by Fit to Page, renders that many more
|
||||
pixels. `bitmapResolution` is VectorCraft's own range, 1 to 9600 ppi, and 0 (the default) prints at the document's raster
|
||||
effects resolution; any other value is an error. When a page prints below a `bitmapResolution` that was given, the
|
||||
reply's `warnings` (and `print.preview`'s) say at what resolution; a page with no art that draws prints no image
|
||||
and gets no warning (`print.preview` goes by the bounds of the art, without drawing it). Separations and pages that
|
||||
do not print as a bitmap leave it unused. Given in `file.print`'s `settings`, it applies to that job only;
|
||||
`print.setup` saves it with the document. (https://ai-scripting.docsforadobe.dev/jsobjref/PrintJobOptions/ lists a
|
||||
job's bitmap resolution with a minimum of 0 and does not say what 0 does.)
|
||||
`color.profile` names an RGB or CMYK profile: composite PDF colours are converted to it with `color.intent` (CMYK
|
||||
colours keep their numbers with `preserveNumbers`), so a CMYK profile writes device CMYK; separations separate with a
|
||||
CMYK one. Settings saved before these options load with their defaults.
|
||||
@@ -17616,8 +17638,8 @@ spacing and orientation new blends start with. The Blend panel's Ramp and Shift
|
||||
a drag previews and its release records one undo step. Blend Options sends only the spacing or orientation set in the dialog.
|
||||
While Blend Options previews a selected blend, the canvas of the current window is not dimmed under the dialog, and the
|
||||
wheel over it still scrolls the view. Other dialogs that preview on the canvas (envelope, path, Flare Tool,
|
||||
Justification, Proof Setup, Swatch Options, Effect Gallery, Bullets and Numbering, Character Style Options, Paragraph
|
||||
Style Options, add-on and command dialogs) work the same way.
|
||||
Justification, Proof Setup, Swatch Options, Effect Gallery, Bullets and Numbering, add-on and
|
||||
command dialogs) work the same way.
|
||||
|
||||
`object.blend.setEasing {id?, easingType?, ramp?, colorShift?}` sets one blend's easing and color shift (the
|
||||
first selected blend without `id`) and returns `{id, easingType, ramp, colorShift, changed}`; omitted values are kept.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Scripts return usable File objects from print job options, select Save As formats before resolving links, and report save, export, and open warnings in the Script Console. Saves and exports reject generated targets that already name directories before writing any output. Print options preserve base tiling when fitToPage is false and print scale factors above 1000 percent only with fitToPage set to true. New message keys use English fallback text.
|
||||
@@ -2609,6 +2609,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- File Info has metadata templates: its menu saves the fields as an XMP file (Save Metadata Template…, into the Metadata Templates folder in the settings folder or anywhere), imports one with a choice of clearing the fields first, replacing the ones the template has, or appending to them (VectorCraft's own names for the three ways), lists the saved templates and opens Templates Folder; the import is one undo step (`file.info.saveTemplate`, `file.info.applyTemplate`, `file.info.templates`; `crates/engine/src/tests/fileinfo.rs`, `crates/pdf/src/tests/file_info.rs`, `crates/ui-egui/src/dialogs/file_info.rs`). A PDF or `.ai` also opens with the rating and author title its XMP packet gives.
|
||||
- `file.print`, `print.preview` and `print.setup` take a print preset by name (`preset`: `[Default]` or a saved preset, in any case): its settings are used instead of the document's, with `settings` over them, `print.setup` saves them with the document, and an unknown name is refused with the list of presets.
|
||||
- Print's Copies per Sheet (`copiesPerSheet`, `gutter`; off by default) prints as many copies of each artboard, with its bleed and marks, as fit the imageable area, across then down, as one grid placed like a single copy; the preview shows them, and an artboard that does not fit prints one copy per sheet with a warning (#1283).
|
||||
- Print as Bitmap renders at `advanced.bitmapResolution` (the Print dialog's Advanced › Resolution; VectorCraft's own range, 1 to 9600 ppi; 0, the default, keeps the document's raster effects resolution) measured on paper, so a print scale or Fit to Page that enlarges the page renders more pixels, in a print-ready PDF and in PostScript, for one job through `file.print`'s `settings` or saved by `print.setup`; a page that the pixel limits print at a lower resolution gets a warning that names it. A script's `PrintJobOptions.bitmapResolution` (https://ai-scripting.docsforadobe.dev/jsobjref/PrintJobOptions/) sets it (`crates/engine/src/tests/printadvanced.rs`, `crates/engine/src/tests/script_print.rs`).
|
||||
- Place and the Links panel, Package (placed `.vectorcraft` documents packaged with their own linked files and fonts, relinked to the copies: #777), File Info, Print with print presets, PostScript output and print tiling, slices and Save for Web, Export for Screens and Asset Export, CSS Properties, PNG/PDF/SVG/text clipboard flavours; files copied in a file manager paste as art (SVG, PDF, EMF/WMF, bitmaps) on every desktop platform, and Linux/Wayland reads the compositor's clipboard (#398); on Linux the Paste menu checks the clipboard off the UI thread, so an X11 owner that never answers can't freeze the window (#510); screenshots and other copied pictures paste as embedded images at the view centre everywhere, the web included (#457).
|
||||
- On X11, quitting while the Paste menu's background check waits on a clipboard owner that never answers waits up to 27 s for that check to drop its clipboard handle, so the app's own handle is the last one dropped when the check drops its handle within that wait, and the app quits after the wait when it has not; the window is hidden before that wait, so an X11 window closes at once (`crates/ui-egui/src/tests/sysclip_probe.rs`, `apps/vectorcraft/src/clipboard.rs`, `apps/vectorcraft/src/quit_windows.rs`).
|
||||
- On Linux, quitting takes every window off screen before that wait: a native Wayland main window is unmapped (its surface gets no buffer) and stays open with the connection the Wayland clipboard uses, and the X11 windows of floating panels and documents are unmapped with the hidden main window (`apps/vectorcraft/src/quit_windows.rs`).
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::process::Command;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
const REV: &str = "dfd876669dd3d64f0061ab510a94b866a1ae35ab";
|
||||
const REV: &str = "4f3e34d0dda2a6862f5ba5fc4cfe3e323602a2da";
|
||||
const PACKAGES: &[(&str, &str, &str)] = &[
|
||||
("craft-pdf", "0.1.0", REV),
|
||||
("krilla", "0.8.2", REV),
|
||||
|
||||
Reference in New Issue
Block a user