Skip to content

Releases: plutext/docx4j-generated-objects-ts

0.3.1

Choose a tag to compare

@plutext plutext released this 04 Oct 02:39

A patch: one fix and one new export. ^0.3.0 picks it up.

A marshalled part now declares the Office extension namespaces it uses as ignorable Now each part root whose type allows mc:Ignorable adds the prefix for each extension namespace its content uses. Those roots are w:document, headers, footers, footnotes, endnotes, comments, styles, numbering, settings, fonts, worksheets, the workbook, tables, pivot parts and the comments-extension parts. This includes content the model holds as DOM. A list the part already has, as in any document Word wrote, is kept whole and in order; new prefixes are appended. Following Office's own practice, a namespace doesn't count if it's the root's own namespace, if it's used only inside an mc:Choice that requires it, or if it's used only inside an extension list's ext. Other roots are left alone.

New export IGNORABLE_EXTENSION_NAMESPACES: the namespaces the rule applies to. These are the twenty that Office itself lists in mc:Ignorable across the test corpus: Word's w14 w15 w16se w16cid w16 w16cex w16sdtdh w16sdtfl cr w16du wp14 and Excel's x14ac x15 x16r2 xr xr2 xr3 xr6 xr10 xr16. It lists namespaces only; each prefix comes from the prefix table in effect for the call.

0.3.0

Choose a tag to compare

@plutext plutext released this 26 Sep 23:56

A minor version: new API, a docx4j regeneration closing every loss the fidelity test had found, and a runtime upgrade. ^0.2.x will not pick this up.

Excel's revision identifiers and Word's bibliography version survive a round trip (docx4j 17.2.1, its CR-027). xr:uid, xr2:uid, xr3:uid and xr16:uid are bound on the elements Office writes them on — autoFilter, hyperlink, table, tableColumn, cellStyle, dataValidation, tableStyle, connection, workbookView, pivotCacheDefinition, pivotTableDefinition, comment — and Version on b:Sources. Measured over the fidelity corpus: 69 uid attributes in, 69 out, where 43 were lost before. xcalcf:calcFeatures is typed rather than DOM, so 104 modules, and NAMESPACE_PREFIXES has 136 entries.

Per-call options on the facade (CR-007, needs @docx4j/jsonix 3.4.0). unmarshalString, unmarshalNode, marshalString and marshalNode each take an optional second argument for that call alone: onUnexpectedElement and onUnexpectedAttribute to be told what the model dropped and where, onElement to record what a marshal wrote, namespacePrefixes for one call's table. Nothing touches the shared context. No callback is set by default and none should be — for some callers a drop is the mechanism rather than a fault.

mc:Ignorable keeps a prefix the table cannot produce (CR-006): Excel's mc:Ignorable="x xr10" on slicer, slicer cache and timeline parts survives, with x declared beside the default. New export IGNORABLE_PREFIX_ALIASES.

The package bundles with no bundler configuration (CR-005, in 0.2.0) now also gets @docx4j/jsonix 3.4.0, whose entry points fork on the node condition — so a Node bundle no longer needs globalThis.DOMParser set, and a browser bundle carries no @xmldom/xmldom.

Testing: the round-trip fidelity test (CR-004) now covers 256 parts of thirteen documents Office 365 wrote, 253 checks, five of them with an mc:Choice resolved. Seventeen attributes the model still drops are recorded against docx4j — w:stylePaneFormatFilter's fifteen booleans, and a14:legacySpreadsheetColorIndex with the mc:Ignorable beside it. @docx4j/core-ts, using jsonix 3.4.0's callbacks over a different corpus, independently reports the same seventeen.

0.2.0

Choose a tag to compare

@plutext plutext released this 23 Sep 21:37

New API, no breaking change, and two docx4j regenerations closing three silent losses. A minor version because the API grew: ^0.1.x will not pick this up.

The package bundles with no bundler configuration (CR-005). The mappings now load from a registry of literal imports (MODULES) rather than a computed import(), which Vite could not resolve without dynamicImportVarsOptions and esbuild expanded to a glob over every .mjs in modules/ — siblings included, a 3.5MB esbuild bundle against 2.0MB now. New: MODULES, modulesFor(root) for a root's module closure, a modules option on getContext for a smaller context, and the ContextOptions type. MODULE_NAMES is unchanged but now derives from the registry. One obstacle remains and is the runtime's: bundled for Node, @docx4j/jsonix loses the @xmldom/xmldom it injects through its UMD wrapper, so a Node bundle needs globalThis.DOMParser and globalThis.XMLSerializer set (jsonix-CR-005; browsers are unaffected).

Three losses closed, each found by round-tripping parts Office wrote:

  • A vmlDrawing part — the legacy drawing behind a comment, form control or OLE picture — could never be unmarshalled: its root is <xml> in no namespace, and the schema declared it in an invented one (docx4j CR-026).
  • A graphic the model does not bind (a slicer, a timeline) was fatal rather than DOM, as was an unknown child of a vmlDrawing root; both wildcards are now lax (docx4j CR-024 §10).
  • mc:Ignorable lost a prefix the table cannot produce because its namespace is written as the default — Excel's mc:Ignorable="x xr10" on slicer, slicer cache and timeline parts (CR-006, new export IGNORABLE_PREFIX_ALIASES).

Also: a re-marshalled settings.xml keeps Word's order for w14:docId and w15:chartTrackingRefBased.

A round-trip fidelity test (CR-004 phase A): 18 parts Office 365 wrote, unmarshalled, marshalled and compared canonically, with two also checked with their mc:Choice taken. Run against 0.1.5 it reports all five losses that release carried. One known difference remains, an xr2:uid docx4j has logged for xlsx4j.

Note for anyone on ^0.1.x: do not use 0.1.5, which cannot load a pptx or xlsx with an equation in a text body; 0.1.6 or this release.

0.1.6

Choose a tag to compare

@plutext plutext released this 20 Sep 03:31

Fixes a regression in 0.1.5, and a chart option loss present since 0.1.0. Regenerated from docx4j (for 17.2.0), 103 modules.

  • A pptx or xlsx with an equation in a text body unmarshals again. 0.1.5 admitted a14:m in DrawingML paragraphs, so m:oMath unmarshalled typed, and OMML's CT_R / CT_CtrlPr rejected the a:rPr DrawingML text carries (Element a:rPr could not be unmarshalled ...) once the a14 mc:Choice was taken. docx4j CR-025 admits a:rPr there: CTR's content holds it as org_docx4j_dml.CTTextCharacterProperties, CTCtrlPr gains rPrDml, and org_docx4j_math depends on org_docx4j_dml. The equation round-trips as PowerPoint and Excel wrote it. 0.1.5 should not be used.
  • c16r3:dispNaAsBlank keeps its val. The 2017/03 chart schema's attributes are bound unqualified, as Office writes them; before, a typed round trip wrote the element bare, silently flipping the option to false. Its prefix in NAMESPACE_PREFIXES is now Office's c16r3 (was c173).

0.1.5

Choose a tag to compare

@plutext plutext released this 20 Sep 02:24

Schema regenerations from docx4j 17.1.1 (CR-021 to CR-024), 103 modules:

  • mc:AlternateContent admitted where Word and Excel write it: WordprocessingML and SpreadsheetML hosts (CR-021), and the DrawingML anchors, group shapes and c:chartSpace (CR-024). Before this, an Excel drawing part whose only child was an mc:AlternateContent came back empty.
  • Excel 2010/2013 extension schemas as six new modules: x14, x15, x15ac, x12ac, x16, xr (CR-022); x14ac attributes and xr:revisionPtr typed on their hosts.
  • Word extension attributes, org_docx4j_cei (CR-023).
  • NAMESPACE_PREFIXES at 135 entries, level with docx4j's NamespacePrefixMappings (adds x12ac, x16, x16r2, xr16, oel, sle, sle15, tsle).

Marshalling:

  • Every prefix an mc:Ignorable names is declared on the root (Excel repaired a workbook without it).
  • sdtProperty accepts several namespaces (Word writes w15:dataBinding).

builders/wml (CR-003 phase A): sdt / sdtPr / sdtProperty / sdtKindOf, inlinePicture, tr / tc, runItemsOf, rPrToElements / rPrFromElements, walkAll, mcBranchOf; textOf follows docx4j's McSelection. deepCopyAs / deepCopyAsSync in the facade.

0.1.4

Choose a tag to compare

@plutext plutext released this 16 Sep 03:26

CR-003 phase A: the helpers @docx4j/core-ts needed from the object model, each replacing a private copy there.

builders/wml

  • Content controls: sdt(content, options) builds all four w:sdt forms, with the form inferred
    from the content (w:tr a row, w:tc a cell, runs a run, else block) or forced with { form }.
    sdtPr writes w:alias, w:tag, w:id and the kind element in that order, with Office JS's
    ContentControlType names as the kinds. nextSdtId(root) gives an id free in a tree, and
    sdtProperty / sdtKindOf read a control's properties and its kind back.
  • Rows and cells: tr(cells, { widths }) and tc(blocks, { width }). tbl is now built over
    them, with its output unchanged.
  • Inline pictures: inlinePicture(relId, { cx, cy, id, name, descr, title }), docx4j's
    BinaryPartAbstractImage.createImageInline, including the wp:docPr/@title that docx4j CR-018
    added (Office JS altTextTitle).
  • Run properties as an element list: rPrToElements / rPrFromElements convert between
    w:rPr's named properties and the EG_RPrBase list that w:rPrChange/w:rPr keeps, in schema
    order and covering every member, the w14 effects included.
  • walkAll: walk plus the DOM elements an xs:any property holds, so a caller can rewrite
    r:embed wherever it appears.
  • runItemsOf (added in 0.1.3) is documented here for the first time.

Facade

  • deepCopyAs(value, typeName, parent?) copies and types the copy as one of the value's base
    types, dropping the properties that type does not declare: a w:pPrChange holds a PPrBase, and a
    copy that stays a PPr marshals as <w:pPr xsi:type="w:CT_PPr">, which is valid but not what Word
    writes.
  • deepCopyAsSync and getContextSync() are the same for a caller that cannot await and
    knows the context is built; getContextSync throws otherwise.

Notes

All additive, so this is a patch release. @docx4j/core-ts reviewed every signature against its call
sites before publication; deepCopyAsSync exists because of that review.

Requires @docx4j/jsonix ^3.2.1.

0.1.3

Choose a tag to compare

@plutext plutext released this 16 Sep 01:39
Version 0.1.3

0.1.2

Choose a tag to compare

@plutext plutext released this 15 Sep 20:35
Version 0.1.2

0.1.1

Choose a tag to compare

@plutext plutext released this 14 Sep 07:24

Fixes the TypeScript declarations of helpers/wml and builders/wml for Node ES module consumers (moduleResolution: node16/nodenext): they imported modules/org_docx4j_wml without its .mjs extension, which failed to compile (TS2835) or, with skipLibCheck, silently typed those APIs as any. Runtime behaviour is unchanged.