diff --git a/Cargo.lock b/Cargo.lock index c0e3142ebd7..eff039f2845 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1323,7 +1323,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "crc32fast", "flate2", @@ -1344,7 +1344,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "rustix 1.1.5", ] @@ -1352,7 +1352,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "md-5", "rayon", @@ -1361,7 +1361,7 @@ dependencies = [ [[package]] name = "craft-crs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-metadata", "craft-xml", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "craft-crw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "thiserror 2.0.21", ] @@ -1379,17 +1379,17 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" [[package]] name = "craft-file-formats" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-eps", "craft-idml", @@ -1407,7 +1407,7 @@ dependencies = [ [[package]] name = "craft-flags" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-atomic", "dirs", @@ -1417,12 +1417,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" [[package]] name = "craft-heif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "heic-rs", "rayon", @@ -1431,7 +1431,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "fixed_decimal", "icu_decimal", @@ -1454,7 +1454,7 @@ dependencies = [ [[package]] name = "craft-idml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-xml", "craft-zip", @@ -1464,13 +1464,15 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-heif", "craft-jpeg", + "craft-metadata", "exr", "flate2", "half", + "hayro-jpeg2000", "image", "image-webp", "jpeg-encoder", @@ -1487,7 +1489,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "thiserror 2.0.21", ] @@ -1495,7 +1497,7 @@ dependencies = [ [[package]] name = "craft-kra" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-xml", "craft-zip", @@ -1505,7 +1507,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "brotli-decompressor 6.3.1", "chrono", @@ -1517,7 +1519,7 @@ dependencies = [ [[package]] name = "craft-ora" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-xml", "craft-zip", @@ -1527,7 +1529,7 @@ dependencies = [ [[package]] name = "craft-pcraft-bundle" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "blake3", "craft-atomic", @@ -1540,7 +1542,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "serde", "serde_json", @@ -1550,7 +1552,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "bytemuck", "flate2", @@ -1564,7 +1566,7 @@ dependencies = [ [[package]] name = "craft-pdn" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "flate2", "thiserror 2.0.21", @@ -1573,7 +1575,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-winprint-gdi", "log", @@ -1587,7 +1589,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "encoding_rs", "flate2", @@ -1598,7 +1600,7 @@ dependencies = [ [[package]] name = "craft-raw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "chrono", "craft-crw", @@ -1616,7 +1618,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-image-codecs", "craft-xml", @@ -1633,7 +1635,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "serde", "thiserror 2.0.21", @@ -1642,7 +1644,7 @@ dependencies = [ [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "craft-fonts-build", "craft-i18n", @@ -1663,7 +1665,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "chrono", "dunce", @@ -1698,7 +1700,7 @@ dependencies = [ [[package]] name = "craft-xcf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "flate2", "thiserror 2.0.21", @@ -1707,16 +1709,17 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "quick-xml 0.41.0", + "serde", "thiserror 2.0.21", ] [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "flate2", "thiserror 2.0.21", @@ -3143,7 +3146,7 @@ dependencies = [ [[package]] name = "hayro" version = "0.7.1" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "bytemuck", "hayro-interpret", @@ -3173,7 +3176,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3191,7 +3194,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3215,7 +3218,7 @@ checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=e2dc681a3#e2dc681a3ad8a47038da2f11ddd2c5e1c0454991" +source = "git+https://github.com/storytold/craft-libs?rev=29ff69b933bcad563035e97bdb38729ad6516290#29ff69b933bcad563035e97bdb38729ad6516290" dependencies = [ "flate2", "hayro-ccitt", @@ -9515,7 +9518,7 @@ dependencies = [ [[package]] name = "winprint" version = "0.2.1" -source = "git+https://github.com/storytold/winprint.rs?rev=72951d7455ebcab569fbd9386c513d3d9f53fb02#72951d7455ebcab569fbd9386c513d3d9f53fb02" +source = "git+https://github.com/storytold/winprint.rs?rev=8ae097ef941b432b0e7671b1ec3a506800e65e57#8ae097ef941b432b0e7671b1ec3a506800e65e57" dependencies = [ "flate2", "fmt-derive", diff --git a/Cargo.toml b/Cargo.toml index 1ec3fe6b374..b869c5c0327 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3", features = ["serde"] } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290", features = ["serde"] } # Feature flags shared with the launcher and the other Craft apps (craft-libs#1118, #1119). -craft-flags = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } +craft-flags = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } # The ArtCraft Launcher's agents switch and app list, shared with the launcher, the MCP gateway and # every Craft app (storytold/craft-ai-integrations#195). Pinned to the head of # storytold/craft-ai-integrations#197 until it merges. @@ -23,11 +23,11 @@ photocraft-color = { path = "crates/color" } photocraft-raster = { path = "crates/raster" } photocraft-doc = { path = "crates/doc" } photocraft-ops = { path = "crates/ops" } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] } photocraft-raw = { path = "crates/raw" } -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } photocraft-compose = { path = "crates/compose" } photocraft-gpu = { path = "crates/gpu" } photocraft-paint = { path = "crates/paint" } @@ -46,31 +46,31 @@ photocraft-ipp = { path = "crates/ipp" } # external # ICC colour management: the shared crate (replaces crates/cms; craft-libs#779). -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-print = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-print = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } # HEIC/HEIF: the shared decoder (replaces crates/heif; craft-libs#784). -craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3", features = ["raster", "write-raster"] } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3", features = ["tree-render", "tree-render-system-fonts"] } -craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } +craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290", features = ["raster", "write-raster"] } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290", features = ["tree-render", "tree-render-system-fonts"] } +craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } # Interface translations: lookup, fallback, CLDR plurals and language names over the craft-i18n # catalogs that `crates/ui-egui/build.rs` embeds from `CRAFT_I18N_DIR` (storytold/craft-i18n, at # the commit in `craft-i18n.rev`). Already in the tree through craft-ui. -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "e2dc681a3", features = ["egui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "29ff69b933bcad563035e97bdb38729ad6516290", features = ["egui"] } thiserror = "2" serde = { version = "1", features = ["derive", "rc"] } serde_json = "1" @@ -229,7 +229,7 @@ egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "6d518fc7 egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # craft-pdf's vendored Hayro trees: consumers patch the same craft-libs revision (crates/pdf README). -hayro = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "e2dc681a3" } +hayro = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "29ff69b933bcad563035e97bdb38729ad6516290" } diff --git a/crates/io/src/linked.rs b/crates/io/src/linked.rs index 13201ae1c1a..40136e30adf 100644 --- a/crates/io/src/linked.rs +++ b/crates/io/src/linked.rs @@ -9,7 +9,6 @@ //! Pascal uuid, Unicode file name, file type, creator, `u64` data length, open-descriptor flag (+ //! versioned descriptor), then for `liFD` the raw file bytes. -use craft_psd::descriptor::VersionedDescriptor; use photocraft_doc::Metadata; /// An embedded file found in a linked-layer block. @@ -20,102 +19,35 @@ pub struct LinkedFile { pub bytes: Vec, } -struct Rd<'a> { - d: &'a [u8], - p: usize, +/// A selected embedded item's decoded header and borrowed bytes. +fn item_data(item: &[u8]) -> Option<(String, String, &[u8])> { + let header = craft_psd::smart::embedded_file_header(item).ok()?; + let bytes = header.payload(item)?; + Some((header.uuid, header.name, bytes)) } -impl<'a> Rd<'a> { - fn take(&mut self, n: usize) -> Option<&'a [u8]> { - let s = self.d.get(self.p..self.p.checked_add(n)?)?; - self.p += n; - Some(s) - } - fn u8(&mut self) -> Option { - self.take(1).map(|b| b[0]) - } - fn u32(&mut self) -> Option { - self.take(4).map(|b| u32::from_be_bytes([b[0], b[1], b[2], b[3]])) - } - fn u64(&mut self) -> Option { - self.take(8).map(|b| u64::from_be_bytes(b.try_into().unwrap_or([0; 8]))) - } - /// Decode a bounded metadata filename without trusting its declared allocation size. - fn unicode(&mut self) -> Option { - let n = self.u32()? as usize; - if n > 32_768 { - return None; - } // A file name is metadata, never an unbounded allocation. - let raw = self.take(n.checked_mul(2)?)?; - let units: Vec = raw.as_chunks::<2>().0.iter().map(|c| u16::from_be_bytes([c[0], c[1]])).collect(); - Some(String::from_utf16_lossy(&units).trim_end_matches('\0').to_string()) - } -} - -/// Parses one item; `None` for malformed data or non-`liFD` items. -fn parse_item(item: &[u8]) -> Option { - let (uuid, file_name, start, len) = item_header(item)?; - let bytes = item.get(start..start.checked_add(len)?)?.to_vec(); - Some(LinkedFile { uuid, file_name, bytes }) -} - -/// The uuid and file name of an embedded (`liFD`) item, and where its file bytes start and how -/// many there are; `None` for malformed data or other items. -fn item_header(item: &[u8]) -> Option<(String, String, usize, usize)> { - let mut r = Rd { d: item, p: 0 }; - let kind = r.take(4)?; - let _version = r.u32()?; - let n = r.u8()? as usize; - let uuid = String::from_utf8_lossy(r.take(n)?).to_string(); - let file_name = r.unicode()?; - r.take(8)?; // file type + creator - let len = usize::try_from(r.u64()?).ok()?; - if r.u8()? != 0 { - let (_, used) = VersionedDescriptor::parse_prefix(item.get(r.p..)?).ok()?; - r.p += used; - } - if kind != b"liFD" { - return None; - } - Some((uuid, file_name, r.p, len)) -} - -/// The file name of the embedded file for smart-object `uuid` among the document's preserved PSD -/// global blocks, without copying its bytes: whether a placed layer's source is embedded. +/// Embedded filename without requiring the declared payload to be resident. pub fn embedded_file_name(meta: &Metadata, uuid: &str) -> Option { if uuid.is_empty() { return None; } - meta.psd_global_blocks.iter().filter(|(_, k, _)| matches!(k, b"lnk2" | b"lnk3" | b"lnkD")).find_map(|(_, _, d)| { - let mut r = Rd { d, p: 0 }; - while let Some(len) = r.u64() { - let item = r.take(usize::try_from(len).ok()?)?; - if let Some((_, name, ..)) = item_header(item).filter(|h| h.0 == uuid) { - return Some(name); - } - r.p = r.p.next_multiple_of(4); - } - None - }) + meta.psd_global_blocks + .iter() + .filter(|(_, k, _)| matches!(k, b"lnk2" | b"lnk3" | b"lnkD")) + .flat_map(|(_, _, data)| craft_psd::smart::iter_linked_records(data)) + .filter_map(|record| craft_psd::smart::embedded_file_header(record.item()?).ok()) + .find(|header| header.uuid == uuid) + .map(|header| header.name) } -/// Borrow the selected item payload without copying it. -fn item_data(item: &[u8]) -> Option<(String, String, &[u8])> { - let (uuid, name, start, len) = item_header(item)?; - Some((uuid, name, item.get(start..start.checked_add(len)?)?)) -} - -/// Every embedded (`liFD`) file in one linked-layer block's data. +/// Every complete embedded file; malformed inner headers do not hide later records. pub fn parse_linked_files(data: &[u8]) -> Vec { - let mut out = Vec::new(); - let mut r = Rd { d: data, p: 0 }; - while let Some(len) = r.u64() { - let Ok(len) = usize::try_from(len) else { break }; - let Some(item) = r.take(len) else { break }; - out.extend(parse_item(item)); - r.p = r.p.next_multiple_of(4); - } - out + craft_psd::smart::iter_linked_records(data) + .filter_map(|record| { + let (uuid, file_name, bytes) = item_data(record.item()?)?; + Some(LinkedFile { uuid, file_name, bytes: bytes.to_vec() }) + }) + .collect() } /// The embedded file for smart-object `uuid` among the document's preserved PSD global blocks. @@ -130,25 +62,8 @@ pub fn embedded_payload<'a>(meta: &'a Metadata, uuid: &str) -> Option<(String, & /// Borrow one selected payload from PSD global blocks without copying unrelated files. pub fn embedded_payload_in_blocks<'a>(blocks: impl IntoIterator, uuid: &str) -> Option<(String, &'a [u8])> { - if uuid.is_empty() { - return None; - } - for (key, data) in blocks { - if !matches!(key, b"lnk2" | b"lnk3" | b"lnkD") { - continue; - } - let mut r = Rd { d: data, p: 0 }; - while let Some(len) = r.u64().and_then(|n| usize::try_from(n).ok()) { - let Some(item) = r.take(len) else { break }; - if let Some((id, name, bytes)) = item_data(item) - && id == uuid - { - return Some((name, bytes)); - } - r.p = r.p.checked_add(3)? & !3; - } - } - None + let (_, name, bytes) = find_slice_in_blocks(blocks, uuid)?; + Some((name, bytes)) } /// The embedded file for smart-object `uuid` among PSD global blocks given as (key, data). @@ -167,19 +82,12 @@ fn find_slice_in_blocks<'a>(blocks: impl IntoIterator [u8; 4] { - match bytes { - [b'8', b'B', b'P', b'S', 0, 2, ..] => *b"8BPB", - [b'8', b'B', b'P', b'S', ..] => *b"8BPS", - [0x89, b'P', b'N', b'G', ..] => *b"PNGf", - [0xFF, 0xD8, ..] => *b"JPEG", - [b'I', b'I', 42, 0, ..] | [b'M', b'M', 0, 42, ..] => *b"TIFF", - [b'G', b'I', b'F', ..] => *b"GIFf", - _ => *b" ", - } + craft_psd::smart::file_type(bytes) } -/// Encodes one `liFD` item (version 7: no open descriptor, empty child document id, no -/// modification time, unlocked), length-prefixed and padded to 4 bytes. +/// Encode using the shared PSD record writer. pub fn encode_linked_file(f: &LinkedFile) -> Vec { - let mut item = Vec::new(); - item.extend_from_slice(b"liFD"); - item.extend_from_slice(&7u32.to_be_bytes()); - let id = f.uuid.as_bytes().get(..f.uuid.len().min(255)).unwrap_or_default(); - item.push(id.len() as u8); - item.extend_from_slice(id); - // NUL-terminated, the terminator counted (as Photoshop writes and reads it). - let units: Vec = f.file_name.encode_utf16().chain(std::iter::once(0)).collect(); - item.extend_from_slice(&(units.len() as u32).to_be_bytes()); - for u in units { - item.extend_from_slice(&u.to_be_bytes()); - } - item.extend_from_slice(&file_type(&f.bytes)); - item.extend_from_slice(b"8BIM"); - item.extend_from_slice(&(f.bytes.len() as u64).to_be_bytes()); - item.push(0); - item.extend_from_slice(&f.bytes); - item.extend_from_slice(&0u32.to_be_bytes()); // child document id (version 5) - item.extend_from_slice(&0f64.to_be_bytes()); // asset modification time (version 6) - item.push(0); // asset locked (version 7) - let mut out = (item.len() as u64).to_be_bytes().to_vec(); - out.extend_from_slice(&item); - while !out.len().is_multiple_of(4) { - out.push(0); - } - out + craft_psd::smart::encode_embedded_file(&f.uuid, &f.file_name, &f.bytes) } -/// The uuid of one linked-layer item (any type), if its header is readable. -fn item_uuid(item: &[u8]) -> Option { - let n = usize::from(*item.get(8)?); - Some(String::from_utf8_lossy(item.get(9..9 + n)?).into_owned()) -} - -/// The items of a linked-layer block: each item's uuid (when readable) and its bytes including -/// the length prefix and padding. A malformed tail is returned as one unnamed piece. -fn split_items(data: &[u8]) -> Vec<(Option, &[u8])> { - let mut out = Vec::new(); - let mut at = 0usize; - while let Some(rest) = data.get(at..).filter(|r| !r.is_empty()) { - let len = rest.get(..8).map(|b| u64::from_be_bytes(b.try_into().unwrap_or([0; 8]))); - let end = len.and_then(|l| usize::try_from(l).ok()).and_then(|l| l.checked_add(8)).filter(|&e| e <= rest.len()); - let (Some(end), Some(item)) = (end, end.and_then(|e| rest.get(8..e))) else { - out.push((None, rest)); - break; - }; - let padded = end.next_multiple_of(4).min(rest.len()); - out.push((item_uuid(item), rest.get(..padded).unwrap_or(rest))); - at += padded; - } - out -} - -/// Rewrites a linked-layer block: keeps the items `keep` accepts (and anything unreadable), then -/// appends `add`. `None` when nothing would change. +/// Preserve unreadable records, retaining or appending the selected embedded files. pub fn rebuild_block(data: &[u8], keep: &dyn Fn(&str) -> bool, add: &[LinkedFile]) -> Option> { - let items = split_items(data); - let dropped = items.iter().any(|(u, _)| u.as_deref().is_some_and(|u| !keep(u))); - if !dropped && add.is_empty() { - return None; + let kept = craft_psd::smart::rebuild_linked_block(data, keep, &[]); + if add.is_empty() { + return kept; } - let mut out = Vec::with_capacity(data.len()); - for (u, bytes) in items { - if u.as_deref().is_none_or(keep) { - out.extend_from_slice(bytes); - } - } - for f in add { - out.extend(encode_linked_file(f)); + // Encode one new payload at a time, preserving the app's peak-memory behavior. + let mut out = kept.unwrap_or_else(|| data.to_vec()); + for file in add { + out.extend(encode_linked_file(file)); } Some(out) } -/// The uuids of every item in a linked-layer block. +/// IDs retain the shared reader's lossy metadata decoding. pub fn block_uuids(data: &[u8]) -> Vec { - split_items(data).into_iter().filter_map(|(u, _)| u).collect() + craft_psd::smart::linked_uuids(data) } -/// Copies only records accepted by `keep` (UUID and complete raw record including padding). -/// Unlike [`rebuild_block`], unidentified records and malformed tails are discarded: clipboard -/// copies must not carry unrelated embedded files. Empty UUIDs cannot identify source bytes. -/// Selected identity must be provable without lossy UTF-8 decoding; an ambiguous or truncated -/// selected ID is an error instead. No payload decoding or filesystem access is performed. -/// `None` means the block already contains only selected complete records and can be shared. +/// Clipboard selection requires exact identity; ambiguous selected IDs are refused. pub fn select_items(data: &[u8], keep: &dyn Fn(&str, &[u8]) -> bool) -> Result>, crate::IoError> { - let error = || crate::IoError::Unsupported("can't copy a truncated selected PSD linked-layer record".into()); - let mut selected = None; - let mut at = 0usize; - while let Some(rest) = data.get(at..).filter(|r| !r.is_empty()) { - let Some((item, raw)) = framed_item(rest) else { - if let Some(item) = rest.get(8..) - && selection_uuid(item, rest, keep)?.is_some_and(|uuid| keep(uuid, rest)) - { - return Err(error()); - } - if selected.is_none() { - let mut prefix = Vec::new(); - append_selected(&mut prefix, data.get(..at).ok_or_else(error)?)?; - selected = Some(prefix); - } - break; + craft_psd::smart::select_linked_records(data, keep).map_err(|error| { + let message = match error { + craft_psd::PsdError::OutOfMemory(_) => "not enough memory to copy PSD linked-layer records", + _ if error.to_string().contains("not valid UTF-8") => "can't verify a PSD linked-layer source ID with invalid UTF-8", + _ => "can't copy a truncated selected PSD linked-layer record", }; - if selection_uuid(item, raw, keep)?.is_some_and(|uuid| keep(uuid, raw)) { - if let Some(out) = &mut selected { - append_selected(out, raw)?; - } - } else if selected.is_none() { - let mut prefix = Vec::new(); - append_selected(&mut prefix, data.get(..at).ok_or_else(error)?)?; - selected = Some(prefix); - } - at = at.checked_add(raw.len()).ok_or_else(error)?; - } - Ok(selected) + crate::IoError::Unsupported(message.into()) + }) } -// Legacy PSD readers retain lossy IDs for file fidelity. Selection needs exact identity; -// a lossy label is used only to refuse an ambiguous transfer, never to retain a record. -fn selection_uuid<'a>(item: &'a [u8], raw: &[u8], keep: &dyn Fn(&str, &[u8]) -> bool) -> Result, crate::IoError> { - let Some(n) = item.get(8).map(|n| usize::from(*n)) else { return Ok(None) }; - let Some(bytes) = 9usize.checked_add(n).and_then(|end| item.get(9..end)).filter(|bytes| !bytes.is_empty()) else { return Ok(None) }; - match std::str::from_utf8(bytes) { - Ok(uuid) => Ok(Some(uuid)), - Err(_) if keep(&String::from_utf8_lossy(bytes), raw) => { - Err(crate::IoError::Unsupported("can't verify a PSD linked-layer source ID with invalid UTF-8".into())) - } - Err(_) => Ok(None), - } -} - -/// Whether a complete raw record already occurs in a block, without decoding its file bytes. pub fn contains_item(data: &[u8], record: &[u8]) -> bool { - let mut remaining = data; - while let Some((_, raw)) = framed_item(remaining) { - if raw == record { - return true; - } - let Some(next) = remaining.get(raw.len()..) else { return false }; - remaining = next; - } - false + craft_psd::smart::contains_linked_record(data, record) } -fn framed_item(data: &[u8]) -> Option<(&[u8], &[u8])> { - let len = usize::try_from(u64::from_be_bytes(data.get(..8)?.try_into().ok()?)).ok()?; - let end = len.checked_add(8)?; - let item = data.get(8..end)?; - let padded = end.checked_add(3).map(|n| n & !3)?.min(data.len()); - Some((item, data.get(..padded)?)) -} - -fn append_selected(out: &mut Vec, bytes: &[u8]) -> Result<(), crate::IoError> { - out.try_reserve(bytes.len()).map_err(|_| crate::IoError::Unsupported("not enough memory to copy PSD linked-layer records".into()))?; - out.extend_from_slice(bytes); - Ok(()) -} - -/// Copies one linked item under a new UUID, preserving its embedded, external or alias payload. +/// Preserve the app's historical lossy-ID lookup; raw payload is never rewritten. pub(crate) fn copy_item(data: &[u8], uuid: &str, new_uuid: &str) -> Option> { - let (_, raw) = split_items(data).into_iter().find(|(u, _)| u.as_deref() == Some(uuid))?; - let len = usize::try_from(u64::from_be_bytes(raw.get(..8)?.try_into().ok()?)).ok()?; - let item = raw.get(8..8usize.checked_add(len)?)?; - let old_end = 9usize.checked_add(usize::from(*item.get(8)?))?; - let new_len = u8::try_from(new_uuid.len()).ok()?; - let mut copy = item.get(..8)?.to_vec(); - copy.push(new_len); - copy.extend_from_slice(new_uuid.as_bytes()); - copy.extend_from_slice(item.get(old_end..)?); - let mut out = (copy.len() as u64).to_be_bytes().to_vec(); - out.extend(copy); - out.resize(out.len().next_multiple_of(4), 0); - Some(out) + craft_psd::smart::iter_linked_records(data).find(|record| record.uuid.is_some_and(|id| String::from_utf8_lossy(id) == uuid))?.copy_with_uuid(new_uuid) } +#[cfg(test)] +#[path = "linked_legacy_tests.rs"] +mod legacy; + #[cfg(test)] mod tests { use super::*; @@ -658,3 +430,42 @@ mod bounded_payload_tests { assert!(embedded_payload(&meta, "/dev/zero").is_none()); } } + +#[cfg(test)] +mod shared_parity { + use super::*; + fn check(data: &[u8]) { + let old: Vec<_> = legacy::parse_linked_files(data).into_iter().map(|f| (f.uuid, f.file_name, f.bytes)).collect(); + let new: Vec<_> = parse_linked_files(data).into_iter().map(|f| (f.uuid, f.file_name, f.bytes)).collect(); + assert_eq!(new, old); + assert_eq!(block_uuids(data), legacy::block_uuids(data)); + for id in ["wanted", "other", "\u{fffd}", ""] { + let meta = Metadata { psd_global_blocks: vec![(*b"8BIM", *b"lnk2", std::sync::Arc::new(data.to_vec()))], ..Metadata::default() }; + assert_eq!(embedded_file_name(&meta, id), legacy::embedded_file_name(&meta, id)); + assert_eq!(embedded_payload(&meta, id), legacy::embedded_payload(&meta, id)); + assert_eq!(copy_item(data, id, "new"), legacy::copy_item(data, id, "new")); + assert_eq!(rebuild_block(data, &|x| x == id, &[]), legacy::rebuild_block(data, &|x| x == id, &[])); + assert_eq!(select_items(data, &|x, _| x == id).map_err(|e| e.to_string()), legacy::select_items(data, &|x, _| x == id).map_err(|e| e.to_string())); + } + } + #[test] + fn shared_linked_views_match_original_on_truncation_and_mutation() { + let file = LinkedFile { uuid: "wanted".into(), file_name: "source.psd".into(), bytes: b"8BPS payload".to_vec() }; + let encoded = encode_linked_file(&file); + assert_eq!( + encoded, + legacy::encode_linked_file(&legacy::LinkedFile { uuid: file.uuid.clone(), file_name: file.file_name.clone(), bytes: file.bytes.clone() }) + ); + let data = [vec![0; 8], encoded.clone(), encoded, vec![1, 2, 3]].concat(); + for n in 0..=data.len() { + check(&data[..n]); + } + for at in 0..data.len() { + for byte in [0, 0xff, 0x80] { + let mut changed = data.clone(); + changed[at] = byte; + check(&changed); + } + } + } +}