Skip to content

feat!: migrate --dump-package and from-package to documents.js 3.0.0's tree-form package - #229

Merged
Mearman merged 3 commits into
mainfrom
feat/documents-3-tree
Aug 18, 2026
Merged

feat!: migrate --dump-package and from-package to documents.js 3.0.0's tree-form package#229
Mearman merged 3 commits into
mainfrom
feat/documents-3-tree

Conversation

@Mearman

@Mearman Mearman commented Aug 18, 2026

Copy link
Copy Markdown
Member

Part of the DocumentPackage tree promotion tracked on ExaDev/document-schema.js#20, following the documents.js 3.0.0 / document-schema.js 4.0.0 / pdf-codec 3.0.0 majors.

What changed

  • documents.js ^3.0.1 (+ pdf-codec devDep ^3.0.0, one coherent set with the major odf.js ^4.0.0 already carries): ConversionResult.package is now the tree-form DocumentPackage — content grouped one group per container (section, slide, sheet, draw page) under children, content nodes carrying their own rendered frames, pages geometry at the root, minted styles table beside it.
  • --dump-package writes the tree package, self-describing through the version-pinned $schema URI documentPackageWithSchema stamps (the URI is the package's version — the formatVersion integer is gone from schema 4).
  • from-package reads tree dumps through documentFromJson's dispatch and flattens once at its boundary (flattenPackage): the flat ContentDocument goes to buildCsvText/buildSvgText (signatures unchanged), the tree itself to buildDocumentBytes. Pre-4.0.0 dumps — the flat { formatVersion, content, pages } envelope documents.js 1.x/2.x wrote — are refused by documentFromJson's version gate with SchemaVersionMismatchError, surfaced as a readable line naming the pinned release, the flat-to-tree change, and the remedy (extending the formatVersion-1 intercept precedent; the CLI-level intercept is gone because the dispatch itself now gates versions). A layout-document dump (an old pdf-inspect --full output) gets the demotion pointer instead.
  • pdf-inspect --full dumps the plain LayoutDocumentlayoutDocumentWithSchema retired with the demotion (a LayoutDocument is a pdf-codec value with no schema-stamped envelope any more), and the Layout* names this CLI uses still import from documents.js, which re-exports them from pdf-codec unchanged.

Follow-up held on an external blocker: a --outline mode rendering the TOC projection over the tree via buildOutline from document-outline.js (that package's first real consumer, the retention criterion on document-outline.js#2) is prepared as a second PR and held until document-outline.js publishes a real npm release — its CI release job is currently blocked on the npmjs trusted-publisher registration for the package, which only the maintainer can add in the npm web UI.

Refs ExaDev/document-schema.js#20, ExaDev/document-outline.js#2.

Generated by Claude Code

…s tree-form package

DocumentPackage is the single hierarchical tree since document-schema.js 4:
content grouped one group per container (section, slide, sheet, draw page)
under children, with the content nodes carrying their own rendered frames,
the pages geometry at the root, and the minted styles table beside it -- so
a dump written now holds {$schema, kind, metadata, children, pages} and no
formatVersion integer at all: the version-pinned $schema URI the dumper
stamps IS the package's version.

from-package reads the tree through documentFromJson's dispatch and
flattens once at its boundary (flattenPackage), handing the flat
ContentDocument to buildCsvText/buildSvgText (whose signatures never
changed) and the tree itself to buildDocumentBytes. Pre-4.0.0 dumps --
the flat { formatVersion, content, pages } envelope documents.js 1.x/2.x
wrote, whatever its formatVersion -- are refused by documentFromJson's
own version gate with SchemaVersionMismatchError, surfaced as a readable
line naming the pinned release, the flat-to-tree change, and the remedy;
the CLI-level formatVersion-1 intercept this command carried existed only
because the old dispatch had no gate and died in DocumentPackageSchema.parse
with a raw ZodError wall. A layout-document dump (a document-schema.js 3.x
layout artefact, e.g. an old pdf-inspect --full output) gets the demotion
pointer: that schema moved to pdf-codec.

pdf-inspect --full dumps the plain LayoutDocument: layoutDocumentWithSchema
retired with the demotion (a LayoutDocument is a pdf-codec value with no
schema-stamped envelope any more), so there is nothing to tag the dump with.

BREAKING CHANGE: from-package no longer reads documents.js 1.x/2.x dump
files; --dump-package output follows documents.js 3.0.0 and pdf-inspect
--full output no longer carries a $schema key.
Nothing in this tree imports document-outline.js, and its file:
specifier resolved against a local checkout path -- the lockfile
entries it produced (file:../outline-pinned) point at a directory
that exists only on the machine that generated them, so a clean
frozen-lockfile install dies with ENOENT before any job runs. A
registry specifier is the only kind a published lockfile can carry.
The command stopped stamping a $schema key when layoutDocumentWithSchema
retired with the pdf-codec demotion -- the README passage still described
the old schema-tagged dump without saying so.
@Mearman
Mearman merged commit aa497a5 into main Aug 18, 2026
9 checks passed
@Mearman
Mearman deleted the feat/documents-3-tree branch August 18, 2026 14:16
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.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