Skip to content

Own the Layout item family, migrate to document-schema.js 4.0.0 - #68

Merged
Mearman merged 2 commits into
mainfrom
feat/own-item-model
Aug 18, 2026
Merged

Own the Layout item family, migrate to document-schema.js 4.0.0#68
Mearman merged 2 commits into
mainfrom
feat/own-item-model

Conversation

@Mearman

@Mearman Mearman commented Aug 18, 2026

Copy link
Copy Markdown
Member

Closes #65.

document-schema.js 4.0.0 dropped LayoutDocument and the whole Layout item family when DocumentPackage became that package's single hierarchical artefact, so this package takes ownership of the family outright. That matches the family pattern everywhere else: a codec's native model lives in the codec (ooxml.js's Package/XmlElement, markdown-codec's AST). Only PDF's native model was ever a public shared-schema export -- an accident of this package predating the content pivot, as #65 puts it.

What landed:

  • src/layout.ts ports the family verbatim from document-schema.js 3.3.0 (the last version carrying it): every item/page/image-asset schema, the inferred types, LAYOUT_FORMAT_VERSION, and its test file. The shared leaf shapes the family composes from (Color/COLOR_BLACK, ContentStrokeStyleSchema, LayoutFont/DEFAULT_LAYOUT_FONT, LayoutMetadata) stay in document-schema.js and are imported, so content and layout keep one definition of each. The ported schemas are structurally identical to the 3.3.0 originals -- diffed against v4.0.0's colour/style/metadata/content modules, only comments changed there.
  • read.ts, write.ts, content-write.ts, codec.ts and their tests import the family from ./layout; pdfCodec validates against the now-local LayoutDocumentSchema; the barrel exports the family wholesale.
  • readPdf/writePdf signatures keep their codec-owned LayoutDocument types, so callers see the same names from a new home. documents.js's own re-exports of the family move source to pdf-codec in its coordinated migration -- same names it exposes, new source.
  • Two stale src/math-types.ts comment references (that module moved upstream into document-schema.js's math layout port a while back) are refreshed to point at the real source.

Supersedes #67 -- this PR carries the schema 4.0.0 bump together with the migration it requires, so that bump PR can't merge green on its own.

Breaking: the Layout item family is no longer exported by document-schema.js; import the same names from pdf-codec. Requires document-schema.js ^4.0.0.

Verification: pnpm lint, typecheck (both tsconfigs), build, test (1119 tests), test:workers, test:smoke all green.

Generated by Claude Code

document-schema.js 4.0.0 dropped its LayoutDocument model when
DocumentPackage became that package's single hierarchical artefact,
so the item family moves here, matching the family pattern where a
codec's native model lives in the codec (ooxml.js's
Package/XmlElement, markdown-codec's AST) -- only PDF's native model
was ever a public shared-schema export, an accident of this package
predating the content pivot.

src/layout.ts is ported verbatim from document-schema.js 3.3.0
(schemas, LAYOUT_FORMAT_VERSION, inferred types, and the test file);
the shared leaf shapes it composes from (Color,
ContentStrokeStyleSchema, LayoutFont, LayoutMetadata) stay in
document-schema.js and are imported, keeping one definition of each
across content and layout. read.ts, write.ts, content-write.ts, and
codec.ts (plus their tests) import the family locally, pdfCodec
validates against the local LayoutDocumentSchema, and the barrel
exports the family wholesale so documents.js's re-exports and any
direct consumer keep the same names from a new home.
readPdf/writePdf signatures are unchanged -- their LayoutDocument
types simply resolve to this package's own now.

Also refreshes the README's math-port bullet, whose src/math-types.ts
reference had been stale since those port types moved upstream into
document-schema.js.

BREAKING CHANGE: the Layout item family (LayoutDocument, LayoutItem,
every item/page/image-asset schema and type, LAYOUT_FORMAT_VERSION)
is no longer exported by document-schema.js and now lives in
pdf-codec; import the same names from pdf-codec. This requires
document-schema.js ^4.0.0, whose own major also reshaped
ContentDocument and DocumentPackage.
src/math-types.ts no longer exists -- the math port types moved into
document-schema.js when the shared contracts began being sourced from
there. The two remaining comment references now name the actual home
of MathAssembledGlyphs and the MathFontMetrics.stretch() contract.
@Mearman
Mearman merged commit f287f04 into main Aug 18, 2026
11 checks passed
@Mearman
Mearman deleted the feat/own-item-model branch August 18, 2026 11:01
@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.

Demote LayoutDocument to codec-private; map to and from frames at the edge

1 participant