Releases: plutext/docx4j-generated-objects-ts
Release list
0.3.1
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
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
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:Ignorablelost a prefix the table cannot produce because its namespace is written as the default — Excel'smc:Ignorable="x xr10"on slicer, slicer cache and timeline parts (CR-006, new exportIGNORABLE_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
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:min DrawingML paragraphs, som:oMathunmarshalled typed, and OMML'sCT_R/CT_CtrlPrrejected thea:rPrDrawingML text carries (Element a:rPr could not be unmarshalled ...) once thea14mc:Choicewas taken. docx4j CR-025 admitsa:rPrthere:CTR's content holds it asorg_docx4j_dml.CTTextCharacterProperties,CTCtrlPrgainsrPrDml, andorg_docx4j_mathdepends onorg_docx4j_dml. The equation round-trips as PowerPoint and Excel wrote it. 0.1.5 should not be used. c16r3:dispNaAsBlankkeeps itsval. 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 inNAMESPACE_PREFIXESis now Office'sc16r3(wasc173).
0.1.5
Schema regenerations from docx4j 17.1.1 (CR-021 to CR-024), 103 modules:
mc:AlternateContentadmitted where Word and Excel write it: WordprocessingML and SpreadsheetML hosts (CR-021), and the DrawingML anchors, group shapes andc:chartSpace(CR-024). Before this, an Excel drawing part whose only child was anmc:AlternateContentcame back empty.- Excel 2010/2013 extension schemas as six new modules: x14, x15, x15ac, x12ac, x16, xr (CR-022);
x14acattributes andxr:revisionPtrtyped on their hosts. - Word extension attributes,
org_docx4j_cei(CR-023). NAMESPACE_PREFIXESat 135 entries, level with docx4j'sNamespacePrefixMappings(adds x12ac, x16, x16r2, xr16, oel, sle, sle15, tsle).
Marshalling:
- Every prefix an
mc:Ignorablenames is declared on the root (Excel repaired a workbook without it). sdtPropertyaccepts several namespaces (Word writesw15: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
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 fourw:sdtforms, with the form inferred
from the content (w:tra row,w:tca cell, runs a run, else block) or forced with{ form }.
sdtPrwritesw:alias,w:tag,w:idand the kind element in that order, with Office JS's
ContentControlTypenames as the kinds.nextSdtId(root)gives an id free in a tree, and
sdtProperty/sdtKindOfread a control's properties and its kind back. - Rows and cells:
tr(cells, { widths })andtc(blocks, { width }).tblis now built over
them, with its output unchanged. - Inline pictures:
inlinePicture(relId, { cx, cy, id, name, descr, title }), docx4j's
BinaryPartAbstractImage.createImageInline, including thewp:docPr/@titlethat docx4j CR-018
added (Office JSaltTextTitle). - Run properties as an element list:
rPrToElements/rPrFromElementsconvert between
w:rPr's named properties and theEG_RPrBaselist thatw:rPrChange/w:rPrkeeps, in schema
order and covering every member, the w14 effects included. walkAll:walkplus the DOM elements anxs:anyproperty holds, so a caller can rewrite
r:embedwherever 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: aw:pPrChangeholds aPPrBase, and a
copy that stays aPPrmarshals as<w:pPr xsi:type="w:CT_PPr">, which is valid but not what Word
writes.deepCopyAsSyncandgetContextSync()are the same for a caller that cannot await and
knows the context is built;getContextSyncthrows 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
0.1.2
0.1.1
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.