@usejunior/docx-core 0.19.1 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli/conformance-adapter.d.ts.map +1 -1
- package/dist/cli/conformance-adapter.js +0 -27
- package/dist/cli/conformance-adapter.js.map +1 -1
- package/dist/core-types.d.ts +1 -139
- package/dist/core-types.d.ts.map +1 -1
- package/dist/core-types.js +1 -3
- package/dist/core-types.js.map +1 -1
- package/dist/generation/compile.d.ts.map +1 -1
- package/dist/generation/compile.js +1 -3
- package/dist/generation/compile.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/integration/generation-probes.d.ts +36 -2
- package/dist/integration/generation-probes.d.ts.map +1 -1
- package/dist/integration/generation-probes.js +137 -15
- package/dist/integration/generation-probes.js.map +1 -1
- package/dist/integration/libreoffice-oracle.d.ts +3 -1
- package/dist/integration/libreoffice-oracle.d.ts.map +1 -1
- package/dist/integration/libreoffice-oracle.js +10 -4
- package/dist/integration/libreoffice-oracle.js.map +1 -1
- package/dist/integration/synthetic-docx-fixture.d.ts.map +1 -1
- package/dist/integration/synthetic-docx-fixture.js +8 -0
- package/dist/integration/synthetic-docx-fixture.js.map +1 -1
- package/dist/primitives/accept_ai_edits.js +14 -2
- package/dist/primitives/accept_ai_edits.js.map +1 -1
- package/dist/primitives/accept_changes.d.ts +6 -0
- package/dist/primitives/accept_changes.d.ts.map +1 -1
- package/dist/primitives/accept_changes.js +236 -62
- package/dist/primitives/accept_changes.js.map +1 -1
- package/dist/primitives/bookmarks.d.ts +8 -2
- package/dist/primitives/bookmarks.d.ts.map +1 -1
- package/dist/primitives/bookmarks.js +31 -7
- package/dist/primitives/bookmarks.js.map +1 -1
- package/dist/primitives/comments.d.ts +101 -5
- package/dist/primitives/comments.d.ts.map +1 -1
- package/dist/primitives/comments.js +356 -156
- package/dist/primitives/comments.js.map +1 -1
- package/dist/primitives/conformance.d.ts +42 -0
- package/dist/primitives/conformance.d.ts.map +1 -0
- package/dist/primitives/conformance.js +61 -0
- package/dist/primitives/conformance.js.map +1 -0
- package/dist/primitives/document.d.ts +145 -2
- package/dist/primitives/document.d.ts.map +1 -1
- package/dist/primitives/document.js +505 -27
- package/dist/primitives/document.js.map +1 -1
- package/dist/primitives/document_view-headings.d.ts +3 -1
- package/dist/primitives/document_view-headings.d.ts.map +1 -1
- package/dist/primitives/document_view-headings.js +5 -5
- package/dist/primitives/document_view-headings.js.map +1 -1
- package/dist/primitives/document_view.d.ts +2 -0
- package/dist/primitives/document_view.d.ts.map +1 -1
- package/dist/primitives/document_view.js +18 -4
- package/dist/primitives/document_view.js.map +1 -1
- package/dist/primitives/errors.d.ts +3 -2
- package/dist/primitives/errors.d.ts.map +1 -1
- package/dist/primitives/errors.js +3 -1
- package/dist/primitives/errors.js.map +1 -1
- package/dist/primitives/extract_revisions.d.ts +23 -6
- package/dist/primitives/extract_revisions.d.ts.map +1 -1
- package/dist/primitives/extract_revisions.js +208 -38
- package/dist/primitives/extract_revisions.js.map +1 -1
- package/dist/primitives/field_evaluation.d.ts +70 -0
- package/dist/primitives/field_evaluation.d.ts.map +1 -0
- package/dist/primitives/field_evaluation.js +462 -0
- package/dist/primitives/field_evaluation.js.map +1 -0
- package/dist/primitives/footnotes.d.ts +53 -3
- package/dist/primitives/footnotes.d.ts.map +1 -1
- package/dist/primitives/footnotes.js +228 -83
- package/dist/primitives/footnotes.js.map +1 -1
- package/dist/primitives/index.d.ts +12 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +12 -1
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/merge_runs.d.ts +3 -1
- package/dist/primitives/merge_runs.d.ts.map +1 -1
- package/dist/primitives/merge_runs.js +12 -2
- package/dist/primitives/merge_runs.js.map +1 -1
- package/dist/primitives/namespaces.d.ts +10 -2
- package/dist/primitives/namespaces.d.ts.map +1 -1
- package/dist/primitives/namespaces.js +11 -2
- package/dist/primitives/namespaces.js.map +1 -1
- package/dist/primitives/note_conversion.d.ts +11 -0
- package/dist/primitives/note_conversion.d.ts.map +1 -0
- package/dist/primitives/note_conversion.js +12 -0
- package/dist/primitives/note_conversion.js.map +1 -0
- package/dist/primitives/paragraph-index.d.ts +31 -0
- package/dist/primitives/paragraph-index.d.ts.map +1 -0
- package/dist/primitives/paragraph-index.js +140 -0
- package/dist/primitives/paragraph-index.js.map +1 -0
- package/dist/primitives/paragraph_merge_formatting.d.ts +24 -0
- package/dist/primitives/paragraph_merge_formatting.d.ts.map +1 -0
- package/dist/primitives/paragraph_merge_formatting.js +86 -0
- package/dist/primitives/paragraph_merge_formatting.js.map +1 -0
- package/dist/primitives/paragraph_numbering.d.ts +40 -0
- package/dist/primitives/paragraph_numbering.d.ts.map +1 -0
- package/dist/primitives/paragraph_numbering.js +198 -0
- package/dist/primitives/paragraph_numbering.js.map +1 -0
- package/dist/primitives/paragraph_structure.d.ts +19 -0
- package/dist/primitives/paragraph_structure.d.ts.map +1 -0
- package/dist/primitives/paragraph_structure.js +66 -0
- package/dist/primitives/paragraph_structure.js.map +1 -0
- package/dist/primitives/reject_changes.d.ts +6 -0
- package/dist/primitives/reject_changes.d.ts.map +1 -1
- package/dist/primitives/reject_changes.js +278 -68
- package/dist/primitives/reject_changes.js.map +1 -1
- package/dist/primitives/relationships.d.ts +22 -0
- package/dist/primitives/relationships.d.ts.map +1 -1
- package/dist/primitives/relationships.js +87 -0
- package/dist/primitives/relationships.js.map +1 -1
- package/dist/primitives/revision-parts.d.ts +15 -0
- package/dist/primitives/revision-parts.d.ts.map +1 -1
- package/dist/primitives/revision-parts.js +33 -1
- package/dist/primitives/revision-parts.js.map +1 -1
- package/dist/primitives/sectPrAudit.d.ts.map +1 -1
- package/dist/primitives/sectPrAudit.js +10 -1
- package/dist/primitives/sectPrAudit.js.map +1 -1
- package/dist/primitives/sections.d.ts +135 -0
- package/dist/primitives/sections.d.ts.map +1 -0
- package/dist/primitives/sections.js +644 -0
- package/dist/primitives/sections.js.map +1 -0
- package/dist/primitives/styles.d.ts +61 -0
- package/dist/primitives/styles.d.ts.map +1 -1
- package/dist/primitives/styles.js +207 -25
- package/dist/primitives/styles.js.map +1 -1
- package/dist/primitives/symbol_run_content.d.ts +42 -0
- package/dist/primitives/symbol_run_content.d.ts.map +1 -0
- package/dist/primitives/symbol_run_content.js +79 -0
- package/dist/primitives/symbol_run_content.js.map +1 -0
- package/dist/primitives/table_cells.d.ts +49 -0
- package/dist/primitives/table_cells.d.ts.map +1 -0
- package/dist/primitives/table_cells.js +149 -0
- package/dist/primitives/table_cells.js.map +1 -0
- package/dist/primitives/table_columns.d.ts +50 -0
- package/dist/primitives/table_columns.d.ts.map +1 -0
- package/dist/primitives/table_columns.js +138 -0
- package/dist/primitives/table_columns.js.map +1 -0
- package/dist/primitives/table_edit_common.d.ts +39 -0
- package/dist/primitives/table_edit_common.d.ts.map +1 -0
- package/dist/primitives/table_edit_common.js +163 -0
- package/dist/primitives/table_edit_common.js.map +1 -0
- package/dist/primitives/table_occupancy.d.ts +39 -0
- package/dist/primitives/table_occupancy.d.ts.map +1 -0
- package/dist/primitives/table_occupancy.js +145 -0
- package/dist/primitives/table_occupancy.js.map +1 -0
- package/dist/primitives/table_rows.d.ts +56 -0
- package/dist/primitives/table_rows.d.ts.map +1 -0
- package/dist/primitives/table_rows.js +390 -0
- package/dist/primitives/table_rows.js.map +1 -0
- package/dist/primitives/text.d.ts +69 -1
- package/dist/primitives/text.d.ts.map +1 -1
- package/dist/primitives/text.js +592 -102
- package/dist/primitives/text.js.map +1 -1
- package/dist/primitives/track-changes-emitter.d.ts +23 -0
- package/dist/primitives/track-changes-emitter.d.ts.map +1 -1
- package/dist/primitives/track-changes-emitter.js +64 -1
- package/dist/primitives/track-changes-emitter.js.map +1 -1
- package/dist/primitives/validate_document.d.ts.map +1 -1
- package/dist/primitives/validate_document.js +22 -1
- package/dist/primitives/validate_document.js.map +1 -1
- package/dist/primitives/zip.d.ts +22 -1
- package/dist/primitives/zip.d.ts.map +1 -1
- package/dist/primitives/zip.js +47 -8
- package/dist/primitives/zip.js.map +1 -1
- package/dist/shared/docx/DocxArchive.d.ts +6 -2
- package/dist/shared/docx/DocxArchive.d.ts.map +1 -1
- package/dist/shared/docx/DocxArchive.js +17 -4
- package/dist/shared/docx/DocxArchive.js.map +1 -1
- package/dist/shared/field-semantics.d.ts +26 -0
- package/dist/shared/field-semantics.d.ts.map +1 -0
- package/dist/shared/field-semantics.js +232 -0
- package/dist/shared/field-semantics.js.map +1 -0
- package/dist/shared/field-structure.d.ts +10 -1
- package/dist/shared/field-structure.d.ts.map +1 -1
- package/dist/shared/field-structure.js +31 -12
- package/dist/shared/field-structure.js.map +1 -1
- package/package.json +4 -5
package/dist/core-types.d.ts
CHANGED
|
@@ -53,127 +53,6 @@ export interface OpcPart {
|
|
|
53
53
|
* This alias will be removed once all imports are updated to use `Element` directly.
|
|
54
54
|
*/
|
|
55
55
|
export type WmlElement = Element;
|
|
56
|
-
/**
|
|
57
|
-
* Base interface for any comparison unit (atom or group).
|
|
58
|
-
*
|
|
59
|
-
* Represents a unit of content that can be compared between documents.
|
|
60
|
-
*
|
|
61
|
-
* @see ComparisonUnit abstract class in WmlComparer.cs lines 2230-2270
|
|
62
|
-
*/
|
|
63
|
-
export interface ComparisonUnit {
|
|
64
|
-
/** SHA1 hash of the unit's content for quick equality check */
|
|
65
|
-
sha1Hash: string;
|
|
66
|
-
/** Current correlation status after comparison */
|
|
67
|
-
correlationStatus: CorrelationStatus;
|
|
68
|
-
/** Child comparison units (for groups) */
|
|
69
|
-
contents?: ComparisonUnit[];
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Format change information for atoms where text matches but formatting differs.
|
|
73
|
-
*
|
|
74
|
-
* Stores the old and new run properties along with the specific property names
|
|
75
|
-
* that changed (e.g., "bold", "italic").
|
|
76
|
-
*/
|
|
77
|
-
export interface FormatChangeInfo {
|
|
78
|
-
/** Run properties from the original document (before changes) */
|
|
79
|
-
oldRunProperties: WmlElement | null;
|
|
80
|
-
/** Run properties from the modified document (after changes) */
|
|
81
|
-
newRunProperties: WmlElement | null;
|
|
82
|
-
/** List of property names that changed (e.g., "bold", "italic", "fontSize") */
|
|
83
|
-
changedProperties: string[];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Process-local payload for a comparison atom owned by an opaque XML boundary.
|
|
87
|
-
*
|
|
88
|
-
* The comparison model is already DOM-backed; this descriptor intentionally
|
|
89
|
-
* retains a cloned element rather than exposing a serialized public contract.
|
|
90
|
-
* `documentOrdinal` identifies the boundary among other captured boundaries in
|
|
91
|
-
* source order. The reconstructor validates original/revised counterparts before
|
|
92
|
-
* assigning `emissionElements` from the original side.
|
|
93
|
-
*/
|
|
94
|
-
export interface OpaquePassthroughNode {
|
|
95
|
-
/** Determines whether paragraph-run emission or the body scaffold owns output. */
|
|
96
|
-
placementKind: 'inline-run' | 'inline-range' | 'body-block';
|
|
97
|
-
namespaceUri: string;
|
|
98
|
-
localName: string;
|
|
99
|
-
documentOrdinal: number;
|
|
100
|
-
/** Source-order paragraph identity; movement is outside the bounded contract and fails closed. */
|
|
101
|
-
paragraphOrdinal: number;
|
|
102
|
-
/** Structural parent path (body or table/cell position) owning the paragraph. */
|
|
103
|
-
containerIdentity: string;
|
|
104
|
-
/** Direct body-child position for a scaffold-owned block boundary. */
|
|
105
|
-
bodyChildOrdinal?: number;
|
|
106
|
-
/** Inclusive direct paragraph-child range for an ordered inline payload. */
|
|
107
|
-
inlineChildStartOrdinal?: number;
|
|
108
|
-
inlineChildEndOrdinal?: number;
|
|
109
|
-
/** Stable sequence position among captured field ranges in this paragraph. */
|
|
110
|
-
inlineRangeOrdinal?: number;
|
|
111
|
-
/** Number of contiguous source-order paragraph slots owned by a block boundary. */
|
|
112
|
-
ownedParagraphCount?: number;
|
|
113
|
-
semanticFingerprint: string;
|
|
114
|
-
/** First retained XML element; kept for source compatibility with single-node owners. */
|
|
115
|
-
sourceElement: WmlElement;
|
|
116
|
-
/** Ordered XML payload retained by this boundary. */
|
|
117
|
-
sourceElements?: WmlElement[];
|
|
118
|
-
effectiveNamespaces: Readonly<Record<string, string>>;
|
|
119
|
-
effectiveMceDeclarations: Readonly<Record<string, string>>;
|
|
120
|
-
/** Package relationship closure rooted at relationship attributes in a block subtree. */
|
|
121
|
-
relationshipClosureFingerprint?: string;
|
|
122
|
-
/** Revised-side canonical owner for an equal original empty-paragraph atom. */
|
|
123
|
-
correlatedNode?: OpaquePassthroughNode;
|
|
124
|
-
emissionElement?: WmlElement;
|
|
125
|
-
emissionElements?: WmlElement[];
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Atomic leaf-node unit used in LCS comparison.
|
|
129
|
-
*
|
|
130
|
-
* Represents the smallest comparable unit of content. Created by atomizing
|
|
131
|
-
* the document tree into individual text nodes, breaks, and other leaf elements.
|
|
132
|
-
*
|
|
133
|
-
* @see ComparisonUnitAtom class in WmlComparer.cs lines 2305-2350
|
|
134
|
-
*/
|
|
135
|
-
export interface ComparisonUnitAtom extends ComparisonUnit {
|
|
136
|
-
/** The leaf element (w:t, w:br, w:cr, etc.) */
|
|
137
|
-
contentElement: WmlElement;
|
|
138
|
-
/**
|
|
139
|
-
* Convenience references used by some reconstruction paths (e.g. in-place mode).
|
|
140
|
-
* These are optional because they can be derived from `ancestorElements`.
|
|
141
|
-
*/
|
|
142
|
-
sourceRunElement?: WmlElement;
|
|
143
|
-
sourceParagraphElement?: WmlElement;
|
|
144
|
-
/** Ancestor elements from root to parent of contentElement */
|
|
145
|
-
ancestorElements: WmlElement[];
|
|
146
|
-
/** Unique identifiers extracted from ancestors (w:Unid attributes) */
|
|
147
|
-
ancestorUnids: string[];
|
|
148
|
-
/** The OPC part this atom belongs to */
|
|
149
|
-
part: OpcPart;
|
|
150
|
-
/** Revision tracking element if this atom is inside w:ins or w:del */
|
|
151
|
-
revTrackElement?: WmlElement;
|
|
152
|
-
/** Sequential index of the paragraph this atom belongs to (0-indexed) */
|
|
153
|
-
paragraphIndex?: number;
|
|
154
|
-
/** Group ID for atoms that are part of a move operation */
|
|
155
|
-
moveGroupId?: number;
|
|
156
|
-
/** Move name for linking source and destination (e.g., "move1") */
|
|
157
|
-
moveName?: string;
|
|
158
|
-
/** Format change details when text is equal but formatting differs */
|
|
159
|
-
formatChange?: FormatChangeInfo;
|
|
160
|
-
/** Reference to the corresponding atom in the other document (for Equal atoms) */
|
|
161
|
-
comparisonUnitAtomBefore?: ComparisonUnitAtom;
|
|
162
|
-
/** True if this atom represents an empty paragraph (paragraph with only w:pPr, no content) */
|
|
163
|
-
isEmptyParagraph?: boolean;
|
|
164
|
-
/** Original atoms when this atom represents a collapsed field sequence */
|
|
165
|
-
collapsedFieldAtoms?: ComparisonUnitAtom[];
|
|
166
|
-
/** Reference to the parent atom when this atom was created by word-level splitting */
|
|
167
|
-
splitFromAtom?: ComparisonUnitAtom;
|
|
168
|
-
/** Which document this atom originated from (for correct formatting application) */
|
|
169
|
-
sourceDocument?: 'original' | 'revised';
|
|
170
|
-
/** Cloned run properties (w:rPr) captured at atomization time, or null if no formatting */
|
|
171
|
-
rPr?: Element | null;
|
|
172
|
-
/** Opaque XML boundary that owns this atom, when bounded passthrough is enabled. */
|
|
173
|
-
opaquePassthrough?: OpaquePassthroughNode;
|
|
174
|
-
/** Zero-based paragraph position inside a scaffold-owned opaque block. */
|
|
175
|
-
opaquePassthroughRelativeParagraphOrdinal?: number;
|
|
176
|
-
}
|
|
177
56
|
/**
|
|
178
57
|
* Settings for move detection algorithm.
|
|
179
58
|
*
|
|
@@ -193,21 +72,6 @@ export interface MoveDetectionSettings {
|
|
|
193
72
|
* Default settings for move detection.
|
|
194
73
|
*/
|
|
195
74
|
export declare const DEFAULT_MOVE_DETECTION_SETTINGS: MoveDetectionSettings;
|
|
196
|
-
/**
|
|
197
|
-
* Block of consecutive atoms with the same status.
|
|
198
|
-
*
|
|
199
|
-
* Used during move detection to group atoms into comparable blocks.
|
|
200
|
-
*/
|
|
201
|
-
export interface AtomBlock {
|
|
202
|
-
/** Status of all atoms in this block (Deleted or Inserted) */
|
|
203
|
-
status: CorrelationStatus;
|
|
204
|
-
/** The atoms in this block */
|
|
205
|
-
atoms: ComparisonUnitAtom[];
|
|
206
|
-
/** Joined text content from all atoms */
|
|
207
|
-
text: string;
|
|
208
|
-
/** Number of words in the text */
|
|
209
|
-
wordCount: number;
|
|
210
|
-
}
|
|
211
75
|
/**
|
|
212
76
|
* Settings for format change detection.
|
|
213
77
|
*/
|
|
@@ -298,9 +162,7 @@ export interface FootnoteReference {
|
|
|
298
162
|
/** Display number (sequential order in document) */
|
|
299
163
|
displayNumber?: number;
|
|
300
164
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Types of revisions that can be detected.
|
|
303
|
-
*/
|
|
165
|
+
/** Types of revisions that can be detected. */
|
|
304
166
|
export declare enum WmlComparerRevisionType {
|
|
305
167
|
/** Text was inserted */
|
|
306
168
|
Insertion = "Insertion",
|
package/dist/core-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-types.d.ts","sourceRoot":"","sources":["../src/core-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;GAMG;AACH,oBAAY,iBAAiB;IAC3B,gDAAgD;IAChD,OAAO,YAAY;IACnB,wCAAwC;IACxC,KAAK,UAAU;IACf,yDAAyD;IACzD,OAAO,YAAY;IACnB,sDAAsD;IACtD,QAAQ,aAAa;IACrB,4DAA4D;IAC5D,WAAW,gBAAgB;IAC3B,+DAA+D;IAC/D,gBAAgB,qBAAqB;IACrC,kDAAkD;IAClD,aAAa,kBAAkB;CAChC;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,yHAAyH;IACzH,W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,WAAW;IACjB,6BAA6B;IAC7B,aAAa,kBAAkB;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,oCAAoC;IACpC,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,uBAAuB;IACvB,IAAI,EAAE,uBAAuB,CAAC;IAC9B,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,IAAI,EAAE,IAAI,CAAC;IACX,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C"}
|
package/dist/core-types.js
CHANGED
|
@@ -107,9 +107,7 @@ export const RESERVED_FOOTNOTE_IDS = {
|
|
|
107
107
|
// =============================================================================
|
|
108
108
|
// Revision Reporting Types
|
|
109
109
|
// =============================================================================
|
|
110
|
-
/**
|
|
111
|
-
* Types of revisions that can be detected.
|
|
112
|
-
*/
|
|
110
|
+
/** Types of revisions that can be detected. */
|
|
113
111
|
export var WmlComparerRevisionType;
|
|
114
112
|
(function (WmlComparerRevisionType) {
|
|
115
113
|
/** Text was inserted */
|
package/dist/core-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-types.js","sourceRoot":"","sources":["../src/core-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gFAAgF;AAChF,0BAA0B;AAC1B,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,iBAeX;AAfD,WAAY,iBAAiB;IAC3B,gDAAgD;IAChD,wCA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":"compile.d.ts","sourceRoot":"","sources":["../../src/generation/compile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiBH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/generation/compile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiBH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,MAAM,MAAM,mBAAmB,GAAG;IAChC,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,2DAA2D;AAC3D,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBlG"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* plumbing, which runs last because [Content_Types].xml is assembled from the
|
|
13
13
|
* part registry.
|
|
14
14
|
*/
|
|
15
|
-
import { createZipBuffer } from '../primitives/zip.js';
|
|
15
|
+
import { createZipBuffer, ZIP_EPOCH } from '../primitives/zip.js';
|
|
16
16
|
import { maybeCaptureEmittedDocumentXml } from '../primitives/schema-corpus-capture.js';
|
|
17
17
|
import { CompileContext } from './context.js';
|
|
18
18
|
import { emitCommentsPartsIfNeeded } from './emit/comments-part.js';
|
|
@@ -28,8 +28,6 @@ import { emitThemePart } from './emit/theme-part.js';
|
|
|
28
28
|
import { emitWebSettingsPart } from './emit/web-settings-part.js';
|
|
29
29
|
import { resolveThemeColorValues } from './theme-colors.js';
|
|
30
30
|
import { validateSpec } from './validate-spec.js';
|
|
31
|
-
/** Fixed zip-entry timestamp (2006-01-01T00:00:00Z, the OOXML vintage). */
|
|
32
|
-
const ZIP_EPOCH = new Date(Date.UTC(2006, 0, 1));
|
|
33
31
|
/** Compile a DocumentSpec into a complete DOCX package. */
|
|
34
32
|
export async function generateDocx(spec, opts) {
|
|
35
33
|
validateSpec(spec);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/generation/compile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/generation/compile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOlD,2DAA2D;AAC3D,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAkB,EAAE,I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AAC,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './shared/ooxml/namespaces.js';
|
|
2
2
|
export * from './generated/ecma-376-vocabulary.js';
|
|
3
|
+
export { inventoryTableOccupancy, TableOccupancyError } from './primitives/table_occupancy.js';
|
|
3
4
|
export * from './shared/ooxml/types.js';
|
|
4
5
|
export * from './shared/docx/DocxArchive.js';
|
|
5
6
|
export * from './shared/field-structure.js';
|
|
7
|
+
export * from './shared/field-semantics.js';
|
|
6
8
|
export * from './shared/validators/structural.js';
|
|
7
9
|
export * from './core-types.js';
|
|
8
10
|
export * from './numbering.js';
|
|
@@ -10,10 +12,12 @@ export * from './footnotes.js';
|
|
|
10
12
|
export * from './primitives/index.js';
|
|
11
13
|
export * from './primitives/schema-corpus-capture.js';
|
|
12
14
|
export * from './primitives/xml-helpers.js';
|
|
13
|
-
export { allocateRevisionId, buildPPrChangeElement, buildTcPrChangeElement, buildTrPrChangeElement, buildRPrChangeElement, createRevisionContainer, createRevisionContext, createRevisionIdState, escapeXmlAttr, formatDate, prepareElementForDeletion, convertSerializedDeletionContent, wrapSerializedContentWithDel, wrapSerializedContentWithIns, wrapElementWithDel, wrapElementWithIns, } from './primitives/track-changes-emitter.js';
|
|
15
|
+
export { allocateRevisionId, buildPPrChangeElement, buildSectPrBaseSnapshot, buildTcPrChangeElement, buildTrPrChangeElement, buildRPrChangeElement, createRevisionContainer, createRevisionContext, createRevisionIdState, escapeXmlAttr, formatDate, prepareElementForDeletion, convertSerializedDeletionContent, wrapSerializedContentWithDel, wrapSerializedContentWithIns, wrapElementWithDel, wrapElementWithIns, } from './primitives/track-changes-emitter.js';
|
|
14
16
|
export type { RevisionContext, RevisionContextOptions, RevisionIdState, } from './primitives/track-changes-emitter.js';
|
|
17
|
+
export { parseStylesXml, parseThemeXml, extractEffectiveRunFormatting, type StylesModel, type ThemeModel, type StyleDef, type RunFormatting, } from './primitives/styles.js';
|
|
15
18
|
export { resolveSoffice, probeSofficeUsable, runLibreOfficeOracle, type OracleJob } from './integration/libreoffice-oracle.js';
|
|
16
19
|
export { buildSyntheticDocx, buildDocxFromParts, type SyntheticDocxOptions, type DocxPartsOptions, } from './integration/synthetic-docx-fixture.js';
|
|
17
20
|
export { generateDocx, type GenerateDocxOptions, GenerationSpecError, GenerationInternalError, type GenerationSpecErrorCode, checkGeneratedPackage, type StructuralCheckResult, type StructuralIssue, } from './generation/index.js';
|
|
21
|
+
export { REVISION_ID_ELEMENT_NAMES, REVISION_ID_ELEMENT_NAME_SET, } from './primitives/revision-vocabulary.js';
|
|
18
22
|
export type { BlockSpec, BorderSpec, BreakSpec, DocumentMetaSpec, DocumentSpec, DraftingNoteSpec, FieldSpec, HeaderFooterSet, HeaderFooterSpec, InlineSpec, NumberingSpec, ParagraphSpec, RunProps, RunSpec, SectionSpec, StyleSpec, TableBorders, TableCellSpec, TableRowSpec, TableSpec, TabSpec, } from './generation/index.js';
|
|
19
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAGlD,cAAc,iBAAiB,CAAC;AAGhC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,uB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AAwB,CAAC;AAKhC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAK/H,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,yCAAyC,CAAC;AAKjD,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,aAAa,EACb,QAAQ,EACR,OAAO,EACP,WAAW,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,SAAS,EACT,OAAO,GACR,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Re-export shared utilities
|
|
2
2
|
export * from './shared/ooxml/namespaces.js';
|
|
3
3
|
export * from './generated/ecma-376-vocabulary.js';
|
|
4
|
+
export { inventoryTableOccupancy, TableOccupancyError } from './primitives/table_occupancy.js';
|
|
4
5
|
export * from './shared/ooxml/types.js';
|
|
5
6
|
export * from './shared/docx/DocxArchive.js';
|
|
6
7
|
export * from './shared/field-structure.js';
|
|
8
|
+
export * from './shared/field-semantics.js';
|
|
7
9
|
export * from './shared/validators/structural.js';
|
|
8
10
|
// Re-export core WmlComparer types
|
|
9
11
|
export * from './core-types.js';
|
|
@@ -15,7 +17,16 @@ export * from './footnotes.js';
|
|
|
15
17
|
export * from './primitives/index.js';
|
|
16
18
|
export * from './primitives/schema-corpus-capture.js';
|
|
17
19
|
export * from './primitives/xml-helpers.js';
|
|
18
|
-
export { allocateRevisionId, buildPPrChangeElement, buildTcPrChangeElement, buildTrPrChangeElement, buildRPrChangeElement, createRevisionContainer, createRevisionContext, createRevisionIdState, escapeXmlAttr, formatDate, prepareElementForDeletion, convertSerializedDeletionContent, wrapSerializedContentWithDel, wrapSerializedContentWithIns, wrapElementWithDel, wrapElementWithIns, } from './primitives/track-changes-emitter.js';
|
|
20
|
+
export { allocateRevisionId, buildPPrChangeElement, buildSectPrBaseSnapshot, buildTcPrChangeElement, buildTrPrChangeElement, buildRPrChangeElement, createRevisionContainer, createRevisionContext, createRevisionIdState, escapeXmlAttr, formatDate, prepareElementForDeletion, convertSerializedDeletionContent, wrapSerializedContentWithDel, wrapSerializedContentWithIns, wrapElementWithDel, wrapElementWithIns, } from './primitives/track-changes-emitter.js';
|
|
21
|
+
// Effective run-formatting resolution (issue #684). These names already reach
|
|
22
|
+
// the entry point through the star exports above; they are restated explicitly
|
|
23
|
+
// because they are a deliberate public surface, not incidental barrel spillage:
|
|
24
|
+
// external consumers — scripts/check_docx_formatting_loss.mjs today, the
|
|
25
|
+
// formatting-convention detector planned in #687 — resolve formatting through
|
|
26
|
+
// this one implementation instead of re-reading declared w:rPr and drifting.
|
|
27
|
+
// The set is the minimum coherent surface: the resolver, the parsers that
|
|
28
|
+
// build its styles/theme inputs, and the types its signature references.
|
|
29
|
+
export { parseStylesXml, parseThemeXml, extractEffectiveRunFormatting, } from './primitives/styles.js';
|
|
19
30
|
// Re-export the LibreOffice accept/reject oracle (gated reference voter; callers skip when
|
|
20
31
|
// `resolveSoffice()` is null or `probeSofficeUsable()` is false — the binary can exist yet
|
|
21
32
|
// abort on launch under a restricted shell). odf-core's round-trip tests drive it with `.odt` jobs.
|
|
@@ -28,4 +39,5 @@ export { buildSyntheticDocx, buildDocxFromParts, } from './integration/synthetic
|
|
|
28
39
|
// the final phase of add-docx-generation: compatibility matrix recorded, all
|
|
29
40
|
// scenario coverage enforced strictly in CI.
|
|
30
41
|
export { generateDocx, GenerationSpecError, GenerationInternalError, checkGeneratedPackage, } from './generation/index.js';
|
|
42
|
+
export { REVISION_ID_ELEMENT_NAMES, REVISION_ID_ELEMENT_NAME_SET, } from './primitives/revision-vocabulary.js';
|
|
31
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAElD,mCAAmC;AACnC,cAAc,iBAAiB,CAAC;AAEhC,gCAAgC;AAChC,cAAc,gBAAgB,CAAC;AAE/B,+BAA+B;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,mEAAmE;AACnE,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,yBAAyB,EACzB,gCAAgC,EAChC,4BAA4B,EAC5B,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,uCAAuC,CAAC;AAO/C,2FAA2F;AAC3F,2FAA2F;AAC3F,oGAAoG;AACpG,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,oBAAoB,EAAkB,MAAM,qCAAqC,CAAC;AAE/H,mFAAmF;AACnF,wFAAwF;AACxF,8EAA8E;AAC9E,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAG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F,2FAA2F;AAC3F,oGAAoG;AACpG,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,oBAAoB,EAAkB,MAAM,qCAAqC,CAAC;AAE/H,mFAAmF;AACnF,wFAAwF;AACxF,8EAA8E;AAC9E,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAGnB,MAAM,yCAAyC,CAAC;AAEjD,+EAA+E;AAC/E,6EAA6E;AAC7E,6CAA6C;AAC7C,OAAO,EACL,YAAY,EAEZ,mBAAmB,EACnB,uBAAuB,EAEvB,qBAAqB,GAGtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,qCAAqC,CAAC"}
|
|
@@ -1,15 +1,49 @@
|
|
|
1
|
+
export type ConvertDiagnostics = {
|
|
2
|
+
/** Process exit code, or null when the run was terminated by a signal. */
|
|
3
|
+
readonly exitCode: number | null;
|
|
4
|
+
/** Terminating signal, when the run was killed (the 45s timeout ⇒ SIGKILL). */
|
|
5
|
+
readonly signal: string | null;
|
|
6
|
+
/** Captured soffice stderr (falling back to stdout), kept on every path. */
|
|
7
|
+
readonly output: string;
|
|
8
|
+
};
|
|
1
9
|
export type DocxIdentityProbeResult = {
|
|
2
10
|
/** The package as re-saved by LibreOffice's DOCX export filter. */
|
|
3
11
|
savedPackage: Buffer;
|
|
12
|
+
/** Exit status and captured output of the converting run. */
|
|
13
|
+
diagnostics: ConvertDiagnostics;
|
|
4
14
|
};
|
|
5
15
|
export type DocxPdfProbeResult = {
|
|
6
16
|
pdf: Buffer;
|
|
17
|
+
/** Exit status and captured output of the converting run. */
|
|
18
|
+
diagnostics: ConvertDiagnostics;
|
|
7
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Raised when the converter did not produce a usable artifact.
|
|
22
|
+
*
|
|
23
|
+
* Carries the exit status and the captured output on *every* rejection path —
|
|
24
|
+
* including the path where an output file exists despite a failed run, which
|
|
25
|
+
* `runConvert` previously reported as a success.
|
|
26
|
+
*
|
|
27
|
+
* @see https://github.com/UseJunior/safe-docx/issues/796
|
|
28
|
+
*/
|
|
29
|
+
export declare class ConvertProbeError extends Error {
|
|
30
|
+
readonly diagnostics: ConvertDiagnostics;
|
|
31
|
+
constructor(message: string, diagnostics: ConvertDiagnostics);
|
|
32
|
+
}
|
|
8
33
|
/**
|
|
9
34
|
* Load→save a complete generated package through LibreOffice's DOCX filter.
|
|
10
|
-
*
|
|
35
|
+
*
|
|
36
|
+
* Throws when the converter fails, when it produces no output, or when what it
|
|
37
|
+
* produced is not a readable OPC package — the probe's pass condition is that
|
|
38
|
+
* the re-saved artifact IS a package, not that a file appeared at a path.
|
|
11
39
|
*/
|
|
12
40
|
export declare function probeDocxIdentity(generated: Buffer, soffice?: string | null): Promise<DocxIdentityProbeResult>;
|
|
13
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Render a generated package to PDF headlessly — the headless-renderer probe.
|
|
43
|
+
*
|
|
44
|
+
* Throws when the converter fails or when the rendered bytes are not a
|
|
45
|
+
* complete PDF. The `%PDF-` header alone is a magic-byte check that a
|
|
46
|
+
* truncated render passes, so the trailing `%%EOF` marker is checked too.
|
|
47
|
+
*/
|
|
14
48
|
export declare function probeDocxToPdf(generated: Buffer, soffice?: string | null): Promise<DocxPdfProbeResult>;
|
|
15
49
|
//# sourceMappingURL=generation-probes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generation-probes.d.ts","sourceRoot":"","sources":["../../src/integration/generation-probes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generation-probes.d.ts","sourceRoot":"","sources":["../../src/integration/generation-probes.ts"],"names":[],"mappings":"AAwCA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,mEAAmE;IACnE,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,WAAW,EAAE,kBAAkB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,WAAW,EAAE,kBAAkB,CAAC;CACjC,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;gBAE7B,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,kBAAkB;CAY7D;AAiHD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAM,GAAG,IAAuB,GACxC,OAAO,CAAC,uBAAuB,CAAC,CA6ClC;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAM,GAAG,IAAuB,GACxC,OAAO,CAAC,kBAAkB,CAAC,CAiB7B"}
|
|
@@ -7,12 +7,24 @@
|
|
|
7
7
|
* are dispatch-only. These probes have a different contract — a complete
|
|
8
8
|
* generated package goes in, and the *saved package* (or rendered PDF) comes
|
|
9
9
|
* back out — and need no macro: `--convert-to` performs exactly the
|
|
10
|
-
* load→save (or load→render) cycle that exposes recovery-dialog failures
|
|
11
|
-
*
|
|
10
|
+
* load→save (or load→render) cycle that exposes recovery-dialog failures.
|
|
11
|
+
*
|
|
12
|
+
* A probe's pass condition is a statement about the artifact, never about a
|
|
13
|
+
* file existing at a path: the run must not have failed, and what it produced
|
|
14
|
+
* must be readable as the thing it claims to be. Do not weaken these back to
|
|
15
|
+
* `existsSync` — a converter that fails *after* writing a partial file
|
|
16
|
+
* satisfies that and nothing else (issue #796).
|
|
17
|
+
*
|
|
18
|
+
* The exit status is necessary but not sufficient, and neither is the output
|
|
19
|
+
* check. Measured on LibreOffice 25.8 (2026-08): an unloadable source exits
|
|
20
|
+
* **0**, writes `Error: source file could not be loaded` to stderr, and
|
|
21
|
+
* produces no output file — so the status check added for #796 does not
|
|
22
|
+
* subsume the file checks, and the file checks do not subsume it.
|
|
12
23
|
*
|
|
13
24
|
* Local-only, like the oracle: callers skip when `resolveSoffice()` is null
|
|
14
25
|
* (CI does not install LibreOffice; the structural checks are the
|
|
15
|
-
* CI-enforceable proxy).
|
|
26
|
+
* CI-enforceable proxy). `generation-probes.test.ts` drives the probes against
|
|
27
|
+
* a stub converter instead, so the failure paths are covered in CI.
|
|
16
28
|
*/
|
|
17
29
|
import { execFile } from 'node:child_process';
|
|
18
30
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
@@ -20,8 +32,31 @@ import os from 'node:os';
|
|
|
20
32
|
import path from 'node:path';
|
|
21
33
|
import { pathToFileURL } from 'node:url';
|
|
22
34
|
import { promisify } from 'node:util';
|
|
35
|
+
import { parseXml } from '../primitives/xml.js';
|
|
36
|
+
import { readZipText } from '../primitives/zip.js';
|
|
23
37
|
import { resolveSoffice } from './libreoffice-oracle.js';
|
|
24
38
|
const execFileAsync = promisify(execFile);
|
|
39
|
+
/**
|
|
40
|
+
* Raised when the converter did not produce a usable artifact.
|
|
41
|
+
*
|
|
42
|
+
* Carries the exit status and the captured output on *every* rejection path —
|
|
43
|
+
* including the path where an output file exists despite a failed run, which
|
|
44
|
+
* `runConvert` previously reported as a success.
|
|
45
|
+
*
|
|
46
|
+
* @see https://github.com/UseJunior/safe-docx/issues/796
|
|
47
|
+
*/
|
|
48
|
+
export class ConvertProbeError extends Error {
|
|
49
|
+
diagnostics;
|
|
50
|
+
constructor(message, diagnostics) {
|
|
51
|
+
const status = diagnostics.signal !== null
|
|
52
|
+
? `killed by ${diagnostics.signal}`
|
|
53
|
+
: `exit ${diagnostics.exitCode ?? 'unknown'}`;
|
|
54
|
+
super(`${message}\nsoffice status: ${status}\nsoffice output:\n` +
|
|
55
|
+
`${diagnostics.output.trim() || '(no output)'}`);
|
|
56
|
+
this.name = 'ConvertProbeError';
|
|
57
|
+
this.diagnostics = diagnostics;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
25
60
|
async function runConvert(input, convertTo, outExt, soffice) {
|
|
26
61
|
const work = mkdtempSync(path.join(os.tmpdir(), 'sdx-gen-probe-'));
|
|
27
62
|
try {
|
|
@@ -44,41 +79,128 @@ async function runConvert(input, convertTo, outExt, soffice) {
|
|
|
44
79
|
outDir,
|
|
45
80
|
inPath,
|
|
46
81
|
];
|
|
47
|
-
let
|
|
82
|
+
let diagnostics;
|
|
48
83
|
try {
|
|
49
84
|
const r = await execFileAsync(soffice, args, { timeout: 45_000, killSignal: 'SIGKILL', maxBuffer: 8 * 1024 * 1024 });
|
|
50
|
-
|
|
85
|
+
diagnostics = {
|
|
86
|
+
exitCode: 0,
|
|
87
|
+
signal: null,
|
|
88
|
+
output: String(r.stderr ?? '') || String(r.stdout ?? ''),
|
|
89
|
+
};
|
|
51
90
|
}
|
|
52
91
|
catch (err) {
|
|
53
92
|
const e = err;
|
|
54
|
-
|
|
93
|
+
diagnostics = {
|
|
94
|
+
// execFile surfaces a signal death with no numeric code, and a
|
|
95
|
+
// spawn failure (ENOENT) with a string code — neither is an exit
|
|
96
|
+
// status, so both land as null and the signal/status check below
|
|
97
|
+
// still rejects because exitCode !== 0.
|
|
98
|
+
exitCode: typeof e.code === 'number' ? e.code : null,
|
|
99
|
+
signal: typeof e.signal === 'string' ? e.signal : null,
|
|
100
|
+
output: String(e.stderr ?? e.stdout ?? e.message ?? ''),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// Fail on the converter's own verdict FIRST, so a failed run that still
|
|
104
|
+
// dropped a partial file at the output path cannot be read back as a
|
|
105
|
+
// success. Note that LibreOffice does NOT always signal a load failure
|
|
106
|
+
// this way (observed: exit 0 with "Error: source file could not be
|
|
107
|
+
// loaded" on stderr and no output at all), which is why the file checks
|
|
108
|
+
// below remain and are not replaced by the status check.
|
|
109
|
+
if (diagnostics.exitCode !== 0 || diagnostics.signal !== null) {
|
|
110
|
+
throw new ConvertProbeError(`LibreOffice failed while converting the generated package to ${outExt}.`, diagnostics);
|
|
55
111
|
}
|
|
56
112
|
const outPath = path.join(outDir, `probe.${outExt}`);
|
|
57
113
|
if (!existsSync(outPath)) {
|
|
58
|
-
throw new
|
|
59
|
-
`(the recovery-dialog class of bug)
|
|
114
|
+
throw new ConvertProbeError(`LibreOffice could not convert the generated package to ${outExt} — likely a load failure ` +
|
|
115
|
+
`(the recovery-dialog class of bug).`, diagnostics);
|
|
60
116
|
}
|
|
61
|
-
|
|
117
|
+
const output = readFileSync(outPath);
|
|
118
|
+
if (output.length === 0) {
|
|
119
|
+
throw new ConvertProbeError(`LibreOffice produced an empty ${outExt} at the output path.`, diagnostics);
|
|
120
|
+
}
|
|
121
|
+
return { output, diagnostics };
|
|
62
122
|
}
|
|
63
123
|
finally {
|
|
64
124
|
rmSync(work, { recursive: true, force: true });
|
|
65
125
|
}
|
|
66
126
|
}
|
|
127
|
+
const OFFICE_DOCUMENT_RELATIONSHIP = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument';
|
|
128
|
+
/**
|
|
129
|
+
* The main-document part named by the package-level officeDocument
|
|
130
|
+
* relationship, normalized to a zip entry name.
|
|
131
|
+
*
|
|
132
|
+
* OPC selects the main part by relationship, not by a fixed path, so this
|
|
133
|
+
* resolves `_rels/.rels` rather than assuming `word/document.xml`.
|
|
134
|
+
*/
|
|
135
|
+
function mainDocumentPartPath(packageRelsXml) {
|
|
136
|
+
const relationships = parseXml(packageRelsXml).getElementsByTagName('Relationship');
|
|
137
|
+
for (const relationship of Array.from(relationships)) {
|
|
138
|
+
if (relationship.getAttribute('Type') !== OFFICE_DOCUMENT_RELATIONSHIP)
|
|
139
|
+
continue;
|
|
140
|
+
const target = relationship.getAttribute('Target');
|
|
141
|
+
if (!target)
|
|
142
|
+
continue;
|
|
143
|
+
// Package-relative targets may be written with a leading slash.
|
|
144
|
+
return target.replace(/^\/+/, '');
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
67
148
|
/**
|
|
68
149
|
* Load→save a complete generated package through LibreOffice's DOCX filter.
|
|
69
|
-
*
|
|
150
|
+
*
|
|
151
|
+
* Throws when the converter fails, when it produces no output, or when what it
|
|
152
|
+
* produced is not a readable OPC package — the probe's pass condition is that
|
|
153
|
+
* the re-saved artifact IS a package, not that a file appeared at a path.
|
|
70
154
|
*/
|
|
71
155
|
export async function probeDocxIdentity(generated, soffice = resolveSoffice()) {
|
|
72
156
|
if (!soffice)
|
|
73
157
|
throw new Error('probeDocxIdentity: no soffice binary (call resolveSoffice() and skip)');
|
|
74
|
-
const savedPackage = await runConvert(generated, 'docx:MS Word 2007 XML', 'docx', soffice);
|
|
75
|
-
|
|
158
|
+
const { output: savedPackage, diagnostics } = await runConvert(generated, 'docx:MS Word 2007 XML', 'docx', soffice);
|
|
159
|
+
let packageRels;
|
|
160
|
+
try {
|
|
161
|
+
packageRels = await readZipText(savedPackage, '_rels/.rels');
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
throw new ConvertProbeError(`LibreOffice wrote a ${savedPackage.length}-byte .docx that is not a readable ZIP ` +
|
|
165
|
+
`(${err.message}).`, diagnostics);
|
|
166
|
+
}
|
|
167
|
+
if (packageRels === null) {
|
|
168
|
+
throw new ConvertProbeError(`LibreOffice wrote a ${savedPackage.length}-byte .docx with no _rels/.rels part.`, diagnostics);
|
|
169
|
+
}
|
|
170
|
+
// The main part is whatever the package-level officeDocument relationship
|
|
171
|
+
// points at. `word/document.xml` is only a convention — resolving the
|
|
172
|
+
// relationship is what makes this a package check rather than a guess about
|
|
173
|
+
// one producer's layout.
|
|
174
|
+
const mainPartPath = mainDocumentPartPath(packageRels);
|
|
175
|
+
if (mainPartPath === undefined) {
|
|
176
|
+
throw new ConvertProbeError(`LibreOffice wrote a ${savedPackage.length}-byte .docx whose _rels/.rels declares no ` +
|
|
177
|
+
`officeDocument relationship.`, diagnostics);
|
|
178
|
+
}
|
|
179
|
+
const mainPart = await readZipText(savedPackage, mainPartPath);
|
|
180
|
+
if (mainPart === null) {
|
|
181
|
+
throw new ConvertProbeError(`LibreOffice wrote a ${savedPackage.length}-byte .docx whose officeDocument relationship ` +
|
|
182
|
+
`targets ${mainPartPath}, which is not in the package.`, diagnostics);
|
|
183
|
+
}
|
|
184
|
+
return { savedPackage, diagnostics };
|
|
76
185
|
}
|
|
77
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* Render a generated package to PDF headlessly — the headless-renderer probe.
|
|
188
|
+
*
|
|
189
|
+
* Throws when the converter fails or when the rendered bytes are not a
|
|
190
|
+
* complete PDF. The `%PDF-` header alone is a magic-byte check that a
|
|
191
|
+
* truncated render passes, so the trailing `%%EOF` marker is checked too.
|
|
192
|
+
*/
|
|
78
193
|
export async function probeDocxToPdf(generated, soffice = resolveSoffice()) {
|
|
79
194
|
if (!soffice)
|
|
80
195
|
throw new Error('probeDocxToPdf: no soffice binary (call resolveSoffice() and skip)');
|
|
81
|
-
const pdf = await runConvert(generated, 'pdf', 'pdf', soffice);
|
|
82
|
-
|
|
196
|
+
const { output: pdf, diagnostics } = await runConvert(generated, 'pdf', 'pdf', soffice);
|
|
197
|
+
if (pdf.subarray(0, 5).toString('latin1') !== '%PDF-') {
|
|
198
|
+
throw new ConvertProbeError(`LibreOffice wrote a ${pdf.length}-byte .pdf without a %PDF- header.`, diagnostics);
|
|
199
|
+
}
|
|
200
|
+
// The trailer lives at the end of the file, possibly followed by whitespace.
|
|
201
|
+
if (!pdf.subarray(-1024).toString('latin1').includes('%%EOF')) {
|
|
202
|
+
throw new ConvertProbeError(`LibreOffice wrote a ${pdf.length}-byte .pdf with no %%EOF trailer — the render is truncated.`, diagnostics);
|
|
203
|
+
}
|
|
204
|
+
return { pdf, diagnostics };
|
|
83
205
|
}
|
|
84
206
|
//# sourceMappingURL=generation-probes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generation-probes.js","sourceRoot":"","sources":["../../src/integration/generation-probes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generation-probes.js","sourceRoot":"","sources":["../../src/integration/generation-probes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClG,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAwB1C;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,WAAW,CAAqB;IAEzC,YAAY,OAAe,EAAE,WAA+B;QAC1D,MAAM,MAAM,GACV,WAAW,CAAC,MAAM,KAAK,IAAI;YACzB,CAAC,CAAC,aAAa,WAAW,CAAC,MAAM,EAAE;YACnC,CAAC,CAAC,QAAQ,WAAW,CAAC,QAAQ,IAAI,SAAS,EAAE,CAAC;QAClD,KAAK,CACH,GAAG,OAAO,qBAAqB,MAAM,qBAAqB;YACxD,GAAG,WAAW,CAAC,MAAM,C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c,CAClC,SAAiB,EACjB,UAAyB,cAAc,EAAE;IAEzC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACpG,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,MAAM,UAAU,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACxF,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,OAAO,EAAE,CAAC;QACtD,MAAM,IAAI,iBAAiB,CACzB,uBAAuB,GAAG,CAAC,MAAM,oCAAoC,EACrE,WAAW,CACZ,CAAC;IACJ,CAAC;IACD,6EAA6E;IAC7E,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,iBAAiB,CACzB,uBAAuB,GAAG,CAAC,MAAM,6DAA6D,EAC9F,WAAW,CACZ,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -48,8 +48,10 @@ export type OracleJob = {
|
|
|
48
48
|
* Run LibreOffice over a batch of jobs in ONE headless launch and return each job's resulting
|
|
49
49
|
* main XML part — `word/document.xml` for DOCX jobs, `content.xml` for ODT jobs. Throws if the
|
|
50
50
|
* binary is missing or the macro did not run.
|
|
51
|
+
* Optional evidence capture receives an isolated copy of that same saved
|
|
52
|
+
* package, allowing tests to inspect styles without changing the returned XML.
|
|
51
53
|
*/
|
|
52
|
-
export declare function runLibreOfficeOracle(jobs: OracleJob[], soffice?: string | null): Promise<string[]>;
|
|
54
|
+
export declare function runLibreOfficeOracle(jobs: OracleJob[], soffice?: string | null, captureOutput?: (index: number, packageBytes: Buffer) => void | Promise<void>): Promise<string[]>;
|
|
53
55
|
/**
|
|
54
56
|
* Structural projection of a `word/document.xml`: one entry per top-level body paragraph,
|
|
55
57
|
* recording whether it carries visible text (a non-whitespace `w:t` descendant). This captures
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libreoffice-oracle.d.ts","sourceRoot":"","sources":["../../src/integration/libreoffice-oracle.ts"],"names":[],"mappings":"AAoEA,4FAA4F;AAC5F,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAU9C;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgCpE;AAeD,iFAAiF;AACjF,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO1E;AAED,4DAA4D;AAC5D,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAItE;AA+DD;;;;;;;;;;;;;;GAcG;AACH,KAAK,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AACjD,MAAM,MAAM,SAAS,GACjB;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,CAAA;CAAE,CAAC;AAUlD
|
|
1
|
+
{"version":3,"file":"libreoffice-oracle.d.ts","sourceRoot":"","sources":["../../src/integration/libreoffice-oracle.ts"],"names":[],"mappings":"AAoEA,4FAA4F;AAC5F,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAU9C;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,G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