DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge #854: index duplicate asset candidates by content (#727)
aiongg5ff7c4f9569e
diff --cc crates/doc/src/assets.rsindex fec7cbab0,cff196fc0..0b1813103--- a/crates/doc/src/assets.rs+++ b/crates/doc/src/assets.rs@@@ -277,9 -287,59 +287,59 @@@ mod testsuse designcraft_geom::{Affine, Rect, shapes};fn asset(id: u64, data: &[u8]) -> Asset {- Asset { id: AssetId(id), name: "p.png".into(), mime: "image/png".into(), link: None, data: Arc::new(data.to_vec()), pixels: None, page: 0 }+ Asset { id: AssetId(id), name: "p.png".into(), mime: "image/png".into(), data: Arc::new(data.to_vec()), ..Default::default() }}+ #[test]+ fn equal_size_assets_keep_distinct_contents_and_merge_exact_copies() {+ let mut d = Document::new(&Default::default());+ for id in 1..=256u64 {+ let mut bytes = vec![42; 1024];+ bytes[1016..].copy_from_slice(&id.to_le_bytes());+ d.assets.insert(AssetId(id), Arc::new(asset(id, &bytes)));+ d.assets.insert(AssetId(id + 256), Arc::new(asset(id + 256, &bytes)));+ }+ assert_eq!(d.merge_duplicate_assets(), 256);+ assert_eq!(d.assets.len(), 256);+ for id in 1..=256u64 {+ assert_eq!(d.assets[&AssetId(id)].data[1016..], id.to_le_bytes());+ }+ }++ #[test]+ fn compaction_preserves_asset_identity_and_missing_data_rules() {+ let mut d = Document::new(&Default::default());+ let mut cases = vec![asset(1, b"same"), asset(2, b"same"), asset(3, b"same"), asset(4, b"same")];+ cases[1].mime = "application/pdf".into();+ cases[2].page = 1;+ cases[3].link = Some("/linked.png".into());+ cases.extend([asset(5, b""), asset(6, b""), asset(7, b""), asset(8, b"")]);+ cases[6].link = Some("/missing.png".into());+ cases[7].link = Some("/missing.png".into());+ for a in cases {+ d.assets.insert(a.id, Arc::new(a));+ }+ assert_eq!(d.merge_duplicate_assets(), 1);+ assert_eq!(d.assets.keys().copied().collect::<Vec<_>>(), (1..=7).map(AssetId).collect::<Vec<_>>());+ }++ #[test]+ #[cfg(not(target_arch = "wasm32"))]+ #[ignore = "manual bounded timing comparison; no timing assertion"]+ fn equal_size_assets_timing() {+ for count in [500, 1000, 2000] {+ let mut d = Document::new(&Default::default());+ for id in 1..=count as u64 {+ let mut bytes = vec![42; 8192];+ bytes[8184..].copy_from_slice(&id.to_le_bytes());+ d.assets.insert(AssetId(id), Arc::new(asset(id, &bytes)));+ }+ let start = std::time::Instant::now();+ assert_eq!(d.merge_duplicate_assets(), 0);+ eprintln!("{count} distinct 8 KiB assets: {:?}", start.elapsed());+ }+ }+fn graphic_item(id: u64, asset: u64, crop: f64) -> Item {let mut it = Item::new(ItemId(id), LayerId(1), Shape::Rectangle, shapes::rectangle(Rect::new(0.0, 0.0, 10.0, 10.0)));it.content = Content::Graphic(Graphic {diff --cc docs/file-format-parity.mdindex c19df6b5c,06f59de94..d32492602--- a/docs/file-format-parity.md+++ b/docs/file-format-parity.md@@@ -1,6 -1,6 +1,6 @@@# File format parity- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (.indd and .indt open through indd-utils; XLSX cached values preserve numeric precision and text; shared print spooler; Windows CI passes) · **Target:** Adobe InDesign 2026 (21.6)-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (content-indexed asset deduplication, #727) · **Target:** Adobe InDesign 2026 (21.6)++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (.indd and .indt open through indd-utils; XLSX cached values preserve numeric precision and text; shared print spooler; Windows CI passes; content-indexed asset deduplication, #727) · **Target:** Adobe InDesign 2026 (21.6)Every format InDesign 2026 reads or writes, with DesignCraft's support, fidelity and tests. TheInDesign list comes from its bundle's `Info.plist` (`CFBundleDocumentTypes`,@@@ -19,10 -19,10 +19,10 @@@ score below)| Format | Ext | InDesign | DesignCraft read | DesignCraft write | Fidelity / tests | Weight ||---|---|---|---|---|---|---|-| InDesign document | `.indd` | read/write (native) | ✗ (#21; converters proposed in #98, #114) | ✗ | — | 30% |-| InDesign template | `.indt` | read/write | ✗ | ✗ | — | 2% |-| InDesign Markup | `.idml` | read/write | ✓ | ✓ | Synthetic fixtures in `crates/idml/src/tests.rs` (49 tests); exported files verified by opening in InDesign 2026 by hand; indd-utils' 98-document run imports 811 spreads / 2,866 stories / 5,812 items. Open: #193, #338, #339, #340, #211. No real-file corpus test | 20% |-| DesignCraft native | `.designcraft` | — | ✓ | ✓ | zip + JSON, versioned; round-trip tests. Asset loading and compaction index by content hash, then confirm byte equality; equal-sized distinct files no longer all share one search bucket (#727). Separate links, MIME types and PDF pages retain their identity | — |+| InDesign document | `.indd` | read/write (native) | ✓ (converted to IDML in memory by [storytold/indd-utils](https://github.com/storytold/indd-utils), then the IDML importer; #21, #114) | ✗ | Converter warnings join the open result; unreadable files are open errors. Synthetic-bytes tests only; indd-utils reports 96.9% of IDML values reproduced on ~650 pairs. No real-file corpus test | 30% |+| InDesign template | `.indt` | read/write | ✓ (as `.indd`) | ✗ | As `.indd` | 2% |+| InDesign Markup | `.idml` | read/write | ✓ | ✓ | Synthetic fixtures in `crates/idml/src/tests.rs` (51 tests); exported files verified by opening in InDesign 2026 by hand; indd-utils' 98-document run imports 811 spreads / 2,866 stories / 5,812 items. Open: #193, #338, #339, #340, #211. No real-file corpus test | 20% |- | DesignCraft native | `.designcraft` | — | ✓ | ✓ | zip + JSON, versioned; round-trip tests | — |++| DesignCraft native | `.designcraft` | — | ✓ | ✓ | zip + JSON, versioned; round-trip tests. Asset loading and compaction index by content hash, then confirm byte equality; equal-sized distinct files fall into separate search buckets (#727). Separate links, MIME types and PDF pages retain their identity | — || InDesign book | `.indb` | read/write | ✗ (own `.dcbook`) | ✗ | Books are shallow (see gaps.md) | 2% || InDesign library | `.indl`, `.inlx` | read/write | ✗ (own `.dclib`) | ✗ | | 1% || Snippet | `.idms` | read/write | ✗ (own snippets) | ✗ | | 1% |@@@ -108,6 -107,5 +108,7 @@@ up to 30 points| Date | Change | Summary ||---|---|---|+ | 2026-10-13 | minor | Asset loading and compaction use content fingerprints with exact equality checks; tests cover equal-sized distinct buffers, shared copies, independent links and missing data (#727) |+| 2026-10-13 | minor | `.indd` and `.indt` read through storytold/indd-utils; INDD remaining work is a real-file corpus (10–30 h); score unchanged until it is measured |+| 2026-10-12 | minor | XLSX table placement and data merge preserve small numeric values and cached formula strings; synthetic regressions in `textimport::xlsx::tests`. Scores unchanged. || 2026-10-10 | major | Created from InDesign 2026's declared document types and filters, `plan/indesign/08-file-formats.md` and the code |