Skip to content

feat!: migrate --dump-package and from-package to documents.js 2.0.0's fused package shape - #216

Merged
Mearman merged 1 commit into
mainfrom
feat/documents-2-package-shape
Aug 17, 2026
Merged

feat!: migrate --dump-package and from-package to documents.js 2.0.0's fused package shape#216
Mearman merged 1 commit into
mainfrom
feat/documents-2-package-shape

Conversation

@Mearman

@Mearman Mearman commented Aug 17, 2026

Copy link
Copy Markdown
Member

documents.js 2.0.0 replaced the DocumentPackage JSON shape: { formatVersion: 1, content, layout } became { formatVersion: 2, content, pages } with per-node frames on content nodes. This migrates the CLI's two DocumentPackage surfaces onto it and bumps the dependency to ^2.0.0, superseding the automation's own red bump PR (#215).

What changed:

  • --dump-package output now carries the fused shape — content nodes stamped with their rendered frames, plus the pages geometry those frames index into; the separate layout half is gone. The pdf target of from-package rebuilds the layout from those recorded positions (documents.js's layoutDocumentFromPackagewritePdf) instead of writing a stored layout half, so the round trip still closes.
  • Old dumps are rejected loudly. A documents.js 1.x dump (formatVersion 1, content + separate layout) still identifies as a DocumentPackage by its version-agnostic ``, but under the new schema it failed DocumentPackageSchema.parse with a raw ZodError wall. `from-package` now intercepts that wrong-version case and names the shape change and the remedy (`re-run the source conversion with --dump-package`) instead — covered by a new test driving a hand-built 1.x-shape dump through the real command.
  • README package-shape documentation updated for both paragraphs (from-package and --dump-package), including a correction: odf-to-pdf has populated a dump since documents.js gained the formula ContentDocument variant (its dump carries the formula content and the one A4 page), so the old "every conversion populates one except odf-to-pdf" claim was stale and is now gone. The bridge paragraph's "layout always undefined" became "pages always absent".
  • The bridge-conversion test's expected error follows the library's new message (no pages), and the dump-shape assertions now pin formatVersion 2 / pages / frames / no layout; a new test exercises the pdf target's rebuild-from-frames path end to end.

No Ink TUI surface reads a DocumentPackage — the TUI's layout state is readPdf's own LayoutDocument, pdf-codec's unchanged contract — so no TUI change was needed.

BREAKING CHANGE: from-package no longer reads documents.js 1.x formatVersion 1 dump files; --dump-package output and the pdf target's rebuild follow documents.js 2.0.0.

Generated by Claude Code

…s fused package shape

DocumentPackage dropped its separate layout half for formatVersion 2:
content nodes carry their own rendered frames and the package carries the
page sizes those frames index into, so a dump written now holds
{$schema, formatVersion, content, pages} and from-package's pdf target
rebuilds the layout from those recorded positions (layoutDocumentFromPackage)
instead of reading a stored layout tree.

A dump from the documents.js 1.x formatVersion 1 shape still identifies
as a DocumentPackage by its version-agnostic $schema but failed
DocumentPackageSchema.parse with a raw ZodError; from-package now
intercepts that one wrong-version case and names the shape change and
the remedy (re-run the source conversion with --dump-package) instead.

README's --dump-package documentation also drops a stale claim: odf-to-pdf
has populated a package since the formula variant gained a ContentDocument,
its dump carrying the formula content and the one A4 page it renders.

BREAKING CHANGE: from-package no longer reads documents.js 1.x
formatVersion 1 dump files; --dump-package output and the pdf target's
rebuild follow documents.js 2.0.0.
@Mearman
Mearman merged commit 5629bf5 into main Aug 17, 2026
9 checks passed
@Mearman
Mearman deleted the feat/documents-2-package-shape branch August 17, 2026 16:42
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant