Files
.CooCooandCodex 209c8ab919 Dependencies: unify craft-libs at 30a568b97 for shared cutovers (#2889)
* Dependencies: take craft-libs main at 3af718585c

Every craft-libs dependency and patch in Cargo.toml now uses one
revision, craft-libs main at 3af718585c60d8e9bab05c241d7a28282c61f85c.
Cargo.lock changes only craft-libs packages.

The newer crates need these changes:

- craft-xml is at one revision, so the craft-xml-dtd alias is removed
  and the DTD adapter uses craft_xml::dtd.
- craft-svg's gradient paint carries its stops and its pattern paint
  carries its tile. Paste uses the first stop's color as before, and
  skips embedded image nodes, which the scene still counts for the
  paste warning.
- craft_svg::sniff::viewbox_size came from a craft-libs commit that is
  not in main. The IDML importer keeps the same bounded viewBox sizing
  as a local function and no longer depends on craft-svg.
- craft-svg's Limits has tree_depth, the depth after references such as
  <use> are followed. Images set it to MAX_SVG_DEPTH, and a test checks
  that a long <use> chain is refused.
- craft-ui adds the flyout width and top layout actions, which the
  iconic dock sends when a flyout's side or top edge is dragged.
  window.panel.layout rejected every action it did not list, so both
  are now checked like the other per-panel actions. A test checks that
  they are kept for a registered panel and refused for an unknown one.

* Panels: a group docked back keeps its flyout's width and top

craft-ui at 3af718585c saves a dock group's flyout width and top when the
group floats and restores them in its own restore path. Dock Panel for a
group that floated as a whole goes through DesignCraft's own path, which
replayed the height, minimized state and column but not the two flyout
values, so a widened or moved flyout came back at its default size and
place. The path now replays ResizeFlyoutWidth and MoveFlyoutTop with the
other saved state.

The images test's doc comment gives the nesting depth of its `<use>`
chain as four levels, counting the root as one.

* PDF: pdf-deps expects craft-libs 3af718585c

`cargo xtask pdf-deps` checks that craft-pdf, Krilla and the Hayro
crates resolve to one craft-libs revision named in xtask. The workspace
now takes them at 3af718585c, so the check expects that revision, and
docs/pdf-backend.md names it.

* IDML: a placed SVG with a byte order mark keeps its viewBox size

The importer's viewBox sizing looked for `<` as the first byte, so a
linked viewBox-only SVG that starts with a UTF-8 byte order mark was
placed at its GraphicBounds instead of its viewBox size. The mark is now
skipped first.

* Tests: the discarded-pass input test clears its texture changes

discarded_pass_does_not_acknowledge_injected_input dropped its frame
output without clearing textures_delta, so epaint panicked on drop
whenever the frame carried a texture change. With craft-ui at
3af718585c it failed in 2 of 3 full ui-egui test runs. The test now
clears it, as the tests around it do.

* Dependencies: take craft-libs crates from craft-libs main at 453b0da782

Every craft-libs git dependency and [patch.crates-io] entry moves from
3af718585c to 453b0da782, and xtask pdf-deps and docs/pdf-backend.md
name the new commit.
Cargo.lock changes only the source revision of the 50 craft-libs
packages; no package is added or removed and no registry package
changes version.

craft-update now inspects a release the app offers on a thread of its
own (storytold/craft-libs#1149), so the prompt opens at a later tick
instead of inside offer. updates_ui's startup_prompt_shows_and_closes
waits for that answer: it ticks on each immediate repaint request the
offer's thread makes until the prompt is open.

* Updates: the startup prompt test fails instead of waiting forever

offer_and_wait waits for the one immediate repaint the offer's thread
requests after it answers, ticks once, and then asserts that the prompt
is open. Before, it waited for a repaint after every tick, so an offer
that ended without a prompt (the launcher pinning the app while the
files were read) blocked the test instead of failing it.

NOTICE names craft-libs 453b0da782 as the source of the patched Hayro
crates, the revision Cargo.toml fetches them at, adds hayro-postscript,
which is patched from the same revision, and names the PdfCraft
revision the snapshots were re-synced to.

* IDML: a placed SVG's viewBox size comes from its root tag alone

svg_viewbox_size reads only the root's start tag instead of parsing the
whole file, so placing the same large linked SVG many times no longer
parses it each time. Files over 16 MiB still give no size. A viewBox
with a value that is not a number, such as "0 0 junk 200 100", now
gives no size, so the frame's GraphicBounds size the graphic; before,
the bad value was dropped and the other numbers were read as the
viewBox.

* IDML: a placed SVG's root tag is read with craft-xml's first_start

svg_viewbox_size reads the root's start tag with Options::first_start and a
pattern that matches any name, in place of its own event loop. A file whose
root is not an svg element still gives no viewBox size; the placement test has
a case for it.

* Cargo: drop the unused craft-xml-dtd alias again

The merge of main kept the craft-xml-dtd alias at craft-libs a5ac3aa05c, which this branch had removed. No crate uses it, and Cargo.lock does not change.

* chore: resolve shared BMP dependency pin with Cargo [skip ci]

* test(color): align FOGRA39 references and isolate no-BPC accuracy [skip ci]

---------

Co-authored-by: Codex <[email protected]>
2026-11-19 22:45:28 +07:00

4.8 KiB

Shared PDF backend

DesignCraft pins craft-pdf, patched Krilla 0.8.2 and the six Hayro reader crates (with hayro-cmap and hayro-postscript) to craft-libs revision 30a568b97fa2927d2217f98ba9c799bc76102144. craft-ui, craft-print and the other craft-libs crates are pinned to the same revision. The reader migration is reviewed on top of the separate writer change.

Writing

The write-pdf capability is required for placed PDF pages and book merging.

The shared library supplies fallible font copying/preparation, metadata setup, version and archival configuration, final serialization and a native unwind guard. DesignCraft retains layout, shaping, font choice/licensing, fallback warnings, image caches, links, tagging, bleed/marks, PDF/X postprocessing and export presets. A shared writer does not improve the format-conformance or product-parity claims by itself.

export_pdf_with_report, export_booklet and merge_pdfs guard the whole export, including painting and postprocessing. A native drawing panic becomes PdfError::Write. A failed page or surface cleanup permanently poisons the backend writer, preventing successful serialization of an incomplete document after a narrow catch. Discard other captured app state after an internal failure. These guards do not catch WASM aborts, allocation aborts, or errors in preceding application operations such as print preparation.

Cargo applies patches only from the consuming workspace root. Keep the Krilla patch and facade at the same full immutable commit, including Krilla reached through krilla-svg. cargo xtask pdf-deps verifies their resolved versions, source and uniqueness, and runs in cargo xtask ci. Publish the dependency revision before publishing this consumer branch. Local path replacements are suitable only for development and should not be committed.

The vendored Krilla patch ledger, per-file hashes, licence texts and four unchanged CC0 Compact ICC profiles live in craft-libs (vendor/krilla, licenses/pdf-writer, and ATTRIBUTION.md). No fonts or binary PDF fixtures are added to DesignCraft by this migration.

Tests cover metadata key presence, hostile page selection, successful PDF export and native subprocess recovery for all three export entry points. Native/WASM export comparisons and independent PDF parsing/rendering supplement the repository gates. Physical printer output, Windows/Linux runtime and PDF/A/PDF/X certification remain separate acceptance work.

Reading

Placed-PDF geometry, layers and raster output use craft-pdf with its explicit raster feature. The facade and four patched Hayro crates are pinned to one immutable craft-libs revision. The backend source was transferred from PdfCraft revision 7437bde378f43856eada40af25b983812e615e8a; the per-crate vendor/SOURCE.json manifests and vendor/README.craft-reader.md record the transfer and subsequent craft-libs patches. Asset provenance and hashes are recorded separately in ASSETS.md. cargo xtask pdf-deps checks unique resolved packages, exact versions and sources.

DesignCraft retains placement, layer-name policy, document state and the application render cache. Render output is premultiplied RGBA8. Page boxes use the same crop, rotation and UserUnit transform as raster output, including fractional placed-PDF dimensions. Layer choices are validated for every selected PDF before any document/undo state changes; a selection containing an unsupported or layerless PDF is refused rather than partially edited. Stale persisted/relinked choices that cannot be honored suppress the graphic on canvas rather than reveal hidden source content; resetting to file defaults remains available. All-content cropping keeps the whole page when real optional-content state cannot be rewritten, while layerless files and empty/null optional-content properties retain measured bounds. Layered-PDF export stops on failed layer rewriting, missing pages or reported incomplete content rather than saving an unchanged or incomplete placed page. Shared diagnostics only report known backend warnings; they do not certify all PDF fidelity.

DesignCraft uses a 512 MiB reader input bound, checked before parsing or copying. Raster output has shared geometry/allocation bounds. Native unwind guards turn escaped backend panics into errors; WASM aborts and process-wide allocation failures are not recoverable. Application fonts, image assets, editing and export presets remain app-owned. craft-ui and craft-print are pinned separately. The reader migration builds on the independently qualified writer change.

The shared commit must be published before a fresh public checkout can resolve these pins. No sibling checkout is required. Licences and existing backend asset notices are recorded in NOTICE, ASSETS.md and licenses/pdf-backend. The backend's removed LAB.icc is not restored.