feat(documents.js): wire wpd into the composition engine as a read-only source - #869
Merged
Conversation
Mearman
marked this pull request as ready for review
September 3, 2026 10:52
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Mearman
force-pushed
the
feat/wpd-composition-wiring
branch
from
September 3, 2026 11:06
98cec1a to
767c4f4
Compare
Mearman
force-pushed
the
feat/wpd-composition-wiring
branch
from
September 3, 2026 11:17
767c4f4 to
318148b
Compare
…ead-only source Adds a generic read-only-format concept to the composition engine (ReadOnlyContentFormat, READ_ONLY_FORMAT_NODES, directed-only graph edges) so a format with a reader and no writer is a real conversion source and can never be routed to as a target -- an asymmetry the graph's own shape now enforces rather than a per-call-site guard. wpd (WordPerfect 6.x-X6) is the first member, reading into the wordprocessing ContentDocument variant and riding that variant's layout engine straight to PDF, exactly as markdown does. The mechanism is generic: adding doc-codec, xls-codec, or ppt-codec later is one union member and one registry entry, not a new code path. executeToPdf gains the matching read-only branch (no source package to extract embedded fonts from, so it falls back to the caller-supplied- faces-only registry markdown already uses), and DocumentFormatSchema, DOCUMENT_FORMATS, FORMAT_CAPABILITIES, and READ_ONLY_FORMATS gain the wpd member.
…ource The composition engine now wires wpd-codec in as a real conversion source, so the package README's pair count, DocumentFormat member list, dependency graph, and Fidelity table were all describing a state that predates that wiring. Updates the pair count (129 -> 141), member list (thirteen -> fourteen), the mermaid dependency diagram, the "Seven external dependencies" count, and adds wpd's own row to the Fidelity table -- every cell a plain one-way arrow rather than a fidelity grade, since a read-only format has no reverse direction to measure loss against. The workspace root README's own documents.js summary row is updated to match: wpd-codec is no longer among the read-only codecs documents.js doesn't depend on.
buildFormatFixtures() drives readNativeDocumentTree for every DocumentFormat outline_document dispatches through; wpd joining that union (documents.js's own composition-engine wiring) left it as the one member with no fixture and no coverage. Adds a hand-authored minimal WordPerfect file (mirroring this package's own odf-formula fixture, and documents.js's internal test-support/wpd.ts, since wpd-codec ships no writer to build one through) and wires it into the existing per-format sweep.
wpd-codec's readWpdContent was reachable only through internal registry closures (CONTENT_READERS.wpd, READ_ONLY_FORMAT_NODES.wpd), mirroring every other read-only-format-shaped hole this package already closes for rtf via a direct re-export. A caller building a wordprocessing ContentDocument straight from wpd bytes -- without routing through convertDocument -- had no public entry point to do it with. There is no writeWpdContent to pair it with: wpd-codec ships no writer at all.
readContentForFormat's exhaustive dispatch (docx/pptx/xlsx/odt/odp/ ods/odg/odf via decodeDocumentPackage, markdown/csv/svg/rtf as plain text or bytes) had no wpd branch, so the web worker's own build failed once wpd joined DocumentFormat: the function fell through without returning for a format its own declared return type didn't allow. wpd reads through readWpdContent directly, the same shape rtf already takes -- a preview is a genuine, working use of a read-only source, unlike a conversion target.
EXTENSION_TO_FORMAT had no wpd entry, so a path-based DocumentInput naming a .wpd file failed format inference even though every tool built on readNativeDocumentTree/documents.js's DocumentConverter port already routes wpd correctly once its format is known.
Adds WpdOpenDocument, mirroring RtfOpenDocument exactly: no live-view
editor exists (wpd-codec ships no writer at all, so one never could),
but wpd's own genuine wpd -> pdf layout-engine edge opens it read-only
through the identical to-Pdf-then-readPdf shape the xlsx/csv/svg/rtf
preview family already uses, browsed through the shared pdf screen
group with no per-format branch needed. There is no wpdToPdf named
convenience function to call (wpd has no reverse direction to pair
one with), so this reaches the edge via convertDocument("wpd", "pdf",
...) directly.
format.ts's EXTENSION_TO_FORMAT/FORMAT_TO_EXTENSION gain a wpd entry
so a .wpd path is recognised and isDocumentFormat("wpd") answers
true. Every exhaustive DocumentFormat/OpenDocument switch this format
touches (documentWithPath, rootScreenForFormat, metadataFor) gains
its wpd case, and every read-only-format guard (saveDocumentTo, the
UNDO action, requirePdfDocument/isEditablePdfDocument) gains its wpd
branch alongside xlsx/csv/svg/rtf.
The package summary, metadata/outline/fonts command descriptions, and the TUI's read-only-preview paragraph all named the fixed set of formats this package covered before wpd joined DocumentFormat -- each now names wpd alongside its siblings and the format counts (thirteen -> fourteen) match what the commands actually support.
Mearman
force-pushed
the
feat/wpd-composition-wiring
branch
from
September 3, 2026 11:23
318148b to
c96f0b7
Compare
Contributor
|
🎉 This PR is included in version 5.3.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.
Stacked on #864 (WordPerfect read depth). Closes #819.
Wires
wpdinto the composition engine as the first read-onlyContentFormat: a real conversion source (bridges to docx/odt/markdown/rtf at cost 1, cross-variant transforms to pptx/odp, a direct layout-engine edge to pdf, and everything else composed through those) that can never be routed to as a target, since wpd-codec ships no writer at all. The mechanism is generic — adding doc-codec/xls-codec/ppt-codec later is one union member and one registry entry, not a new code path.Downstream consumers follow:
documents.js's own public barrel re-exportsreadWpdContent, the web UI's preview reader gains a wpd branch,document-mcprecognises.wpdpaths, anddocument-cli's TUI opens a.wpdfile read-only as a converted PDF preview (mirroring the existing xlsx/csv/svg/rtf treatment) alongside its own README updates.Test plan
pnpm lint/pnpm typecheck/pnpm typecheck:attwacross the whole workspacepnpm test/pnpm test:workers/pnpm test:smokeacross the whole workspacedocuments.js's roundtrip-matrix sweep exercises everywpd -> Xpair against a real, hand-authored minimal WordPerfect fixturedocument-mcp'soutline_documentsweep now covers wpd alongside every other DocumentFormat