Skip to content

feat(documents.js): wire wpd into the composition engine as a read-only source - #869

Merged
Mearman merged 8 commits into
mainfrom
feat/wpd-composition-wiring
Sep 3, 2026
Merged

feat(documents.js): wire wpd into the composition engine as a read-only source#869
Mearman merged 8 commits into
mainfrom
feat/wpd-composition-wiring

Conversation

@Mearman

@Mearman Mearman commented Sep 3, 2026

Copy link
Copy Markdown
Member

Stacked on #864 (WordPerfect read depth). Closes #819.

Wires wpd into the composition engine as the first read-only ContentFormat: 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-exports readWpdContent, the web UI's preview reader gains a wpd branch, document-mcp recognises .wpd paths, and document-cli's TUI opens a .wpd file 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:attw across the whole workspace
  • pnpm test / pnpm test:workers / pnpm test:smoke across the whole workspace
  • documents.js's roundtrip-matrix sweep exercises every wpd -> X pair against a real, hand-authored minimal WordPerfect fixture
  • document-mcp's outline_document sweep now covers wpd alongside every other DocumentFormat

@Mearman
Mearman marked this pull request as ready for review September 3, 2026 10:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-03T11:03:32.146487Z 98cec1a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman force-pushed the feat/wpd-composition-wiring branch from 98cec1a to 767c4f4 Compare September 3, 2026 11:06
Base automatically changed from feat/wpd-read-depth to main September 3, 2026 11:14
@Mearman
Mearman force-pushed the feat/wpd-composition-wiring branch from 767c4f4 to 318148b Compare September 3, 2026 11:17
…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
Mearman force-pushed the feat/wpd-composition-wiring branch from 318148b to c96f0b7 Compare September 3, 2026 11:23
@Mearman
Mearman merged commit 42719d5 into main Sep 3, 2026
16 checks passed
@Mearman
Mearman deleted the feat/wpd-composition-wiring branch September 3, 2026 11:26
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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

Add read-only .wpd (WordPerfect 6.x-X6) support

1 participant