Use shared ZIP codec for dotLottie imports

This commit is contained in:
Dylan M. Taylor
2026-11-13 15:07:00 +00:00
parent 69bce0ec66
commit 0627dd0e4b
5 changed files with 107 additions and 173 deletions
Generated
+62 -28
View File
@@ -1092,26 +1092,26 @@ dependencies = [
[[package]]
name = "craft-aep"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
[[package]]
name = "craft-audio"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9)",
"craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef)",
"thiserror 2.0.21",
]
[[package]]
name = "craft-docpath"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
[[package]]
name = "craft-dpx"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"thiserror 2.0.21",
]
@@ -1119,7 +1119,7 @@ dependencies = [
[[package]]
name = "craft-ecproj-format"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"serde",
"serde_json",
@@ -1129,12 +1129,12 @@ dependencies = [
[[package]]
name = "craft-eps"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
[[package]]
name = "craft-exr"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"serde_json",
]
@@ -1142,17 +1142,17 @@ dependencies = [
[[package]]
name = "craft-fonts-build"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
[[package]]
name = "craft-gif"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
[[package]]
name = "craft-i18n"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"fixed_decimal",
"icu_decimal",
@@ -1175,8 +1175,9 @@ dependencies = [
[[package]]
name = "craft-lottie"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"craft-zip",
"serde_json",
"thiserror 2.0.21",
]
@@ -1184,7 +1185,7 @@ dependencies = [
[[package]]
name = "craft-media"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"thiserror 2.0.21",
]
@@ -1200,7 +1201,7 @@ dependencies = [
[[package]]
name = "craft-mesh"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"miniz_oxide 0.9.1",
"serde_json",
@@ -1209,7 +1210,7 @@ dependencies = [
[[package]]
name = "craft-pdf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"hayro-syntax",
"thiserror 2.0.21",
@@ -1218,7 +1219,7 @@ dependencies = [
[[package]]
name = "craft-psd"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"encoding_rs",
"flate2",
@@ -1229,7 +1230,7 @@ dependencies = [
[[package]]
name = "craft-quit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"dispatch2",
"egui",
@@ -1240,19 +1241,21 @@ dependencies = [
[[package]]
name = "craft-svg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"craft-xml",
"flate2",
"kurbo",
"roxmltree",
"thiserror 2.0.21",
"vectorcraft-geom",
"vectorcraft-pathops",
]
[[package]]
name = "craft-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"craft-fonts-build",
"craft-i18n",
@@ -1273,7 +1276,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"chrono",
"dunce",
@@ -1300,9 +1303,9 @@ dependencies = [
[[package]]
name = "craft-video"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9)",
"craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef)",
"rayon",
"thiserror 2.0.21",
]
@@ -1310,7 +1313,7 @@ dependencies = [
[[package]]
name = "craft-webp"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"thiserror 2.0.21",
]
@@ -1318,12 +1321,22 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"quick-xml 0.41.0",
"thiserror 2.0.21",
]
[[package]]
name = "craft-zip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"flate2",
"thiserror 2.0.21",
"zip 9.1.3",
]
[[package]]
name = "crc32fast"
version = "1.5.2"
@@ -1683,7 +1696,7 @@ name = "effectcraft-export"
version = "0.24.1"
dependencies = [
"craft-audio",
"craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9)",
"craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef)",
"craft-video",
"effectcraft-color",
"effectcraft-effects",
@@ -1852,7 +1865,7 @@ dependencies = [
"craft-dpx",
"craft-exr",
"craft-gif",
"craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9)",
"craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef)",
"craft-webp",
"effectcraft-color",
"effectcraft-effects",
@@ -3422,7 +3435,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a"
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"hayro-ccitt",
]
@@ -3436,7 +3449,7 @@ checksum = "c75ab947623ef4ccaa7acf0579edf7cbb5a73838e3839a7be73335e522f433a1"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
source = "git+https://github.com/storytold/craft-libs?rev=47107f660191de2f0b425569506f4daa4faadac9#47107f660191de2f0b425569506f4daa4faadac9"
source = "git+https://github.com/storytold/craft-libs?rev=b7b9f8eb7c016cef2680cb65230eb7273723a7ef#b7b9f8eb7c016cef2680cb65230eb7273723a7ef"
dependencies = [
"hayro-jbig2",
"hayro-jpeg2000",
@@ -6683,6 +6696,27 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "vectorcraft-geom"
version = "0.18.0"
source = "git+https://github.com/storytold/vectorcraft.git?rev=6b3a6b8788ebcb420d69449199cbdf323888d27e#6b3a6b8788ebcb420d69449199cbdf323888d27e"
dependencies = [
"kurbo",
"serde",
"thiserror 2.0.21",
]
[[package]]
name = "vectorcraft-pathops"
version = "0.18.0"
source = "git+https://github.com/storytold/vectorcraft.git?rev=6b3a6b8788ebcb420d69449199cbdf323888d27e#6b3a6b8788ebcb420d69449199cbdf323888d27e"
dependencies = [
"kurbo",
"linesweeper",
"thiserror 2.0.21",
"vectorcraft-geom",
]
[[package]]
name = "vello_common"
version = "0.2.0"
+21 -21
View File
@@ -11,22 +11,22 @@ rust-version = "1.95"
repository = "https://github.com/storytold/effectcraft"
[workspace.dependencies]
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", version = "=0.1.0", default-features = false, features = ["read"] }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-eps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-webp = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-lottie = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", default-features = false, features = ["stl", "obj", "gltf", "fbx"] }
craft-aep = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", version = "=0.1.0", default-features = false, features = ["read"] }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-ecproj-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-eps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-webp = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-lottie = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", default-features = false, features = ["stl", "obj", "gltf", "fbx"] }
craft-aep = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef" }
# 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 = "47107f660191de2f0b425569506f4daa4faadac9", features = ["egui"] }
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", features = ["egui"] }
# internal
effectcraft-time = { path = "crates/time" }
effectcraft-geom = { path = "crates/geom" }
@@ -90,9 +90,9 @@ same-file = "1.0"
tempfile = "3.27"
# codecs + containers shared by the Craft apps (crates/media, crates/export); keep all three on one rev.
craft-media = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", default-features = false, features = ["isobmff", "matroska"] }
craft-audio = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", default-features = false, features = ["aac-decode", "aac-encode", "opus-decode"] }
craft-video = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", features = ["h264-encode", "prores", "hevc-encode", "vp9-encode", "av1", "threads"] }
craft-media = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", default-features = false, features = ["isobmff", "matroska"] }
craft-audio = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", default-features = false, features = ["aac-decode", "aac-encode", "opus-decode"] }
craft-video = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", features = ["h264-encode", "prores", "hevc-encode", "vp9-encode", "av1", "threads"] }
# footage decoding: FilmCraft's pure-Rust crates, pinned to a revision (plan/adr/0001).
# Only `crates/media`, `crates/export` and `crates/interchange` may depend on these.
@@ -122,7 +122,7 @@ half = "2.7"
# ui
# Shared frontend components; keep this dependency above the engine boundary.
# Shared UI and the complete egui family select reviewed immutable commits below.
craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", features = ["serde"] }
craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", features = ["serde"] }
# `default_fonts` and `monochrome_emoji_fonts` are explicit: the app's `FontDefinitions::default()`
# and its `✔`/`▣` chrome glyphs need both, and kittest's own dev-dependencies do not propagate.
egui = { version = "0.37", default-features = false, features = ["default_fonts", "monochrome_emoji_fonts"] }
@@ -231,8 +231,8 @@ lto = "thin"
codegen-units = 1
[patch.crates-io]
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", version = "=0.7.2" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "47107f660191de2f0b425569506f4daa4faadac9", version = "=0.3.0" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", version = "=0.7.2" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "b7b9f8eb7c016cef2680cb65230eb7273723a7ef", version = "=0.3.0" }
ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
emath = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
epaint = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" }
+4 -4
View File
@@ -41,7 +41,7 @@ pub struct ImportResult {
pub warnings: Vec<String>,
}
/// The Lottie document inside raw bytes (plain JSON, or a stored dotLottie archive), read into
/// The Lottie document inside raw bytes (plain JSON, or a dotLottie archive), read into
/// `craft-lottie`'s model within its default limits.
fn document(bytes: &[u8]) -> Result<Animation, LottieError> {
let read = |b: &[u8]| {
@@ -51,12 +51,12 @@ fn document(bytes: &[u8]) -> Result<Animation, LottieError> {
})
};
if bytes.starts_with(b"PK") {
let entries = crate::zip::read_stored(bytes);
let entries = crate::zip::read_entries(bytes).map_err(|e| LottieError::Parse(format!("dotLottie ZIP: {e}")))?;
let anim = entries
.iter()
.find(|(n, _)| n.starts_with("animations/") && n.ends_with(".json"))
.or_else(|| entries.iter().find(|(n, _)| n.ends_with(".json") && n != "manifest.json"))
.ok_or_else(|| LottieError::Parse("dotLottie archive without an uncompressed animation".into()))?;
.ok_or_else(|| LottieError::Parse("dotLottie archive without a JSON animation".into()))?;
return read(&anim.1);
}
read(bytes)
@@ -102,7 +102,7 @@ fn external_image(stored: &str, base_dir: &str) -> Result<String, String> {
}
}
/// Import a Lottie document (JSON or a stored `.lottie` archive) into `project` as a new
/// Import a Lottie document (JSON or a `.lottie` archive) into `project` as a new
/// composition. `store` saves embedded images and returns the file path to use;
/// `base_dir` resolves external image references.
pub fn import(
+18
View File
@@ -799,6 +799,24 @@ fn dotlottie_archive_roundtrip() {
assert_eq!(q.comp(imp.comp).unwrap().layers.len(), 1);
}
#[test]
fn deflated_dotlottie_archive_imports() {
let (mut p, cid) = setup();
let l = solid_layer(&mut p, cid, [0.0, 1.0, 0.0], 40, 40);
push(&mut p, cid, l);
let res = export_comp(&p, cid, &ExportOptions::default(), &no_read).unwrap();
let manifest = serde_json::to_vec(&serde_json::json!({"version":"1","animations":[{"id":"main"}]})).unwrap();
let animation = serde_json::to_vec(&res.json).unwrap();
let zip = craft_lottie::zip::try_store_with_compression(
&[("manifest.json".into(), manifest), ("animations/main.json".into(), animation)],
craft_lottie::zip::Compression::Deflated,
)
.unwrap();
let mut q = Project::default();
let imp = import(&mut q, &zip, "compressed", "", &mut |_| None).unwrap();
assert_eq!(q.comp(imp.comp).unwrap().layers.len(), 1);
}
// ---------------------------------------------------------------- hand-written fixtures
fn fixture(name: &str) -> (Project, ItemId, Vec<String>) {
+2 -120
View File
@@ -1,121 +1,3 @@
//! A minimal ZIP writer (stored entries, PKWARE APPNOTE 6.3 local headers + central directory)
//! for `.lottie` (dotLottie) archives.
//! Shared stored-entry ZIP functions used by dotLottie imports and exports.
fn crc32(data: &[u8]) -> u32 {
let mut crc = 0xFFFF_FFFFu32;
for &b in data {
crc ^= b as u32;
for _ in 0..8 {
crc = if crc & 1 != 0 { (crc >> 1) ^ 0xEDB8_8320 } else { crc >> 1 };
}
}
!crc
}
/// Build a ZIP archive with the given (name, bytes) entries, uncompressed.
pub fn store(entries: &[(String, Vec<u8>)]) -> Vec<u8> {
let mut out = Vec::new();
let mut central = Vec::new();
let put16 = |v: &mut Vec<u8>, x: u16| v.extend_from_slice(&x.to_le_bytes());
let put32 = |v: &mut Vec<u8>, x: u32| v.extend_from_slice(&x.to_le_bytes());
for (name, data) in entries {
let offset = out.len() as u32;
let crc = crc32(data);
let n = name.as_bytes();
// Local file header.
put32(&mut out, 0x0403_4b50);
put16(&mut out, 20); // version needed
put16(&mut out, 0x0800); // flags: UTF-8 names
put16(&mut out, 0); // stored
put16(&mut out, 0); // time
put16(&mut out, 0x21); // date (1980-01-01)
put32(&mut out, crc);
put32(&mut out, data.len() as u32);
put32(&mut out, data.len() as u32);
put16(&mut out, n.len() as u16);
put16(&mut out, 0);
out.extend_from_slice(n);
out.extend_from_slice(data);
// Central directory record.
put32(&mut central, 0x0201_4b50);
put16(&mut central, 20); // made by
put16(&mut central, 20);
put16(&mut central, 0x0800);
put16(&mut central, 0);
put16(&mut central, 0);
put16(&mut central, 0x21);
put32(&mut central, crc);
put32(&mut central, data.len() as u32);
put32(&mut central, data.len() as u32);
put16(&mut central, n.len() as u16);
put16(&mut central, 0); // extra
put16(&mut central, 0); // comment
put16(&mut central, 0); // disk
put16(&mut central, 0); // internal attrs
put32(&mut central, 0); // external attrs
put32(&mut central, offset);
central.extend_from_slice(n);
}
let cd_offset = out.len() as u32;
let cd_len = central.len() as u32;
out.extend_from_slice(&central);
put32(&mut out, 0x0605_4b50);
put16(&mut out, 0);
put16(&mut out, 0);
put16(&mut out, entries.len() as u16);
put16(&mut out, entries.len() as u16);
put32(&mut out, cd_len);
put32(&mut out, cd_offset);
put16(&mut out, 0);
out
}
/// Whether an entry name is a relative path inside the archive: not absolute (`/…`, `\…`), no
/// drive (`C:…`) and no `..` component.
fn is_relative_name(name: &str) -> bool {
let drive = name.as_bytes().get(1) == Some(&b':');
!name.starts_with(['/', '\\']) && !drive && !name.split(['/', '\\']).any(|c| c == "..")
}
/// Read the stored (uncompressed) entries of a ZIP archive written by [`store`] or any other
/// writer that did not compress. Compressed entries and entries whose names are not relative
/// paths inside the archive are skipped.
pub fn read_stored(data: &[u8]) -> Vec<(String, Vec<u8>)> {
let mut out = vec![];
let mut i = 0usize;
let u16_at = |p: usize| data.get(p..p + 2).map(|b| u16::from_le_bytes([b[0], b[1]]) as usize);
let u32_at = |p: usize| data.get(p..p + 4).map(|b| u32::from_le_bytes([b[0], b[1], b[2], b[3]]) as usize);
while u32_at(i) == Some(0x0403_4b50) {
let (Some(method), Some(size), Some(nlen), Some(xlen)) = (u16_at(i + 8), u32_at(i + 18), u16_at(i + 26), u16_at(i + 28)) else { break };
let name_start = i + 30;
let body = name_start + nlen + xlen;
let (Some(name), Some(bytes)) = (data.get(name_start..name_start + nlen), data.get(body..body + size)) else { break };
let name = String::from_utf8_lossy(name).to_string();
if method == 0 && is_relative_name(&name) {
out.push((name, bytes.to_vec()));
}
i = body + size;
}
out
}
#[cfg(test)]
mod tests {
#[test]
fn crc_and_roundtrip() {
assert_eq!(super::crc32(b"123456789"), 0xCBF4_3926);
let z = super::store(&[("a.json".into(), b"{}".to_vec()), ("b/c.txt".into(), b"hello".to_vec())]);
let back = super::read_stored(&z);
assert_eq!(back.len(), 2);
assert_eq!(back[1].0, "b/c.txt");
assert_eq!(back[1].1, b"hello");
}
#[test]
fn entries_outside_the_archive_root_are_skipped() {
let names = ["../up.txt", "a/../../up.txt", "/abs/x", "\\abs\\x", "C:\\x", "c:x", "a\\..\\x", "ok/x.txt", "ok/..x"];
let z = super::store(&names.iter().map(|n| (n.to_string(), b"x".to_vec())).collect::<Vec<_>>());
let back: Vec<String> = super::read_stored(&z).into_iter().map(|(n, _)| n).collect();
assert_eq!(back, ["ok/x.txt", "ok/..x"]);
}
}
pub use craft_lottie::zip::{Limits, read_entries, read_entries_with_limits, read_stored, store, try_store, try_store_with_compression};