Own the Layout item family, migrate to document-schema.js 4.0.0 - #68
Merged
Conversation
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.
Contributor
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #65.
document-schema.js 4.0.0 dropped
LayoutDocumentand the whole Layout item family whenDocumentPackagebecame 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'sPackage/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.tsports 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.tsand their tests import the family from./layout;pdfCodecvalidates against the now-localLayoutDocumentSchema; the barrel exports the family wholesale.readPdf/writePdfsignatures keep their codec-ownedLayoutDocumenttypes, so callers see the same names from a new home. documents.js's own re-exports of the family move source topdf-codecin its coordinated migration -- same names it exposes, new source.src/math-types.tscomment 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. Requiresdocument-schema.js ^4.0.0.Verification:
pnpm lint,typecheck(both tsconfigs),build,test(1119 tests),test:workers,test:smokeall green.Generated by Claude Code