rocx-docx 0.0.0-stage → 0.5.0

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.
@@ -0,0 +1,316 @@
1
+ import type { ResolvedImage } from "./drawings.js";
2
+ import type { StyleDefinition, NumberingStyleDefinition, NumberingLevel, NumberingDefinition, TableSectionFormat } from "./styles.js";
3
+ import type { ControlAnchor, DefaultValues, HeaderAnchor, InlineAnchor, ParagraphAnchor, StoryParagraphAnchor, TableAnchor, ParagraphFlag, SectionFlag, ImportedSectionType } from "./inspection.js";
4
+ import type { ResolvedTable, TableLayout } from "./tables.js";
5
+ import type { Alignment, ResolvedInline, ResolvedParagraph, RunFormat } from "./text-layout.js";
6
+ import type { SectionAnchor, DirectParagraphLayout, DirectSectionLayout } from "./inspection.js";
7
+
8
+ export interface ParagraphAlignmentEdit {
9
+ readonly target: ParagraphAnchor;
10
+ readonly alignment: Alignment;
11
+ }
12
+
13
+ export interface TableInsertion {
14
+ /** Insert immediately after this original body paragraph. */
15
+ readonly target: ParagraphAnchor;
16
+ readonly table: ResolvedTable;
17
+ }
18
+
19
+ /** Physical row/cell indices include opaque children in the inspected view. */
20
+ export interface CellAlignmentEdit {
21
+ readonly target: TableAnchor;
22
+ readonly rowIndex: number;
23
+ readonly cellIndex: number;
24
+ readonly alignment: "top" | "center" | "bottom" | "both";
25
+ }
26
+ export interface CellAlignmentChange {
27
+ readonly bodyIndex: number;
28
+ readonly rowIndex: number;
29
+ readonly cellIndex: number;
30
+ readonly before?: string;
31
+ readonly after: CellAlignmentEdit["alignment"];
32
+ }
33
+
34
+ export interface ParagraphInsertion {
35
+ /** Insert immediately after this original body paragraph. */
36
+ readonly target: ParagraphAnchor;
37
+ readonly paragraph: ResolvedParagraph;
38
+ }
39
+
40
+ export type HeaderEditMode = "shared" | "sectionLocal";
41
+ type LayoutChange<A, T> = { [K in keyof T]-?: {
42
+ readonly target: A; readonly field: K; readonly value: NonNullable<T[K]> | null
43
+ } }[keyof T];
44
+ export type LayoutEdit = LayoutChange<ParagraphAnchor, DirectParagraphLayout>
45
+ | LayoutChange<SectionAnchor, Omit<DirectSectionLayout, "margins" | "lineNumbering">>
46
+ | { readonly target: SectionAnchor; readonly field: "margins" | "lineNumbering"; readonly value: null };
47
+
48
+ export type BlockEdit =
49
+ | { readonly kind: "splitSection"; readonly target: SectionAnchor; readonly offset: number }
50
+ | { readonly kind: "mergeSection"; readonly target: SectionAnchor }
51
+ | { readonly kind: "paragraphFlag"; readonly target: ParagraphAnchor; readonly flag: ParagraphFlag; readonly value: boolean | null }
52
+ | { readonly kind: "sectionFlag"; readonly target: ParagraphAnchor; readonly flag: SectionFlag; readonly value: boolean | null }
53
+ | { readonly kind: "sectionType"; readonly target: ParagraphAnchor; readonly value: ImportedSectionType | null }
54
+ | { readonly kind: "replace"; readonly target: ParagraphAnchor; readonly paragraph: ResolvedParagraph }
55
+ | { readonly kind: "remove"; readonly target: ParagraphAnchor }
56
+ | { readonly kind: "replaceSection"; readonly target: ParagraphAnchor; readonly blocks: readonly (ResolvedParagraph | ResolvedTable)[] }
57
+ | { readonly kind: "keepWithNext"; readonly target: ParagraphAnchor; readonly value: boolean };
58
+
59
+ export interface HeaderImageEdit {
60
+ readonly target: HeaderAnchor;
61
+ readonly mode: HeaderEditMode;
62
+ readonly image: ResolvedImage;
63
+ }
64
+
65
+ export type InlineEdit = { readonly target: InlineAnchor } & (
66
+ | { readonly kind: "removeObject" }
67
+ | { readonly kind: "patchDrawing"; readonly property: "size" | "placement" | "crop" | "transform" | "accessibility" | "shapeFill" | "shapeOutline" | "shapeText" | "shapeGeometry" | "chartSeries"; readonly inline: ResolvedInline }
68
+ | { readonly kind: "setImageAsset"; readonly image: ResolvedImage }
69
+ | { readonly kind: "setDrawingDescription"; readonly value: string | null }
70
+ | { readonly kind: "insertAfter" | "replace"; readonly inline: ResolvedInline }
71
+ | { readonly kind: "setBold"; readonly bold: boolean }
72
+ | { readonly kind: "setToggle"; readonly property: "bold" | "italic" | "strike" | "hidden"; readonly value: boolean | null }
73
+ | { readonly kind: "removeHyperlink" }
74
+ | { readonly kind: "hyperlinkTooltip"; readonly value?: string }
75
+ | { readonly kind: "hyperlinkHistory"; readonly value?: boolean }
76
+ | { readonly kind: "patchFormat"; readonly format?: RunFormat; readonly clear?: readonly
77
+ (Exclude<keyof RunFormat, "superscript" | "subscript" | "language"> |
78
+ "verticalAlignment" | "languageLatin" | "languageEastAsia" | "languageBidi" | "hidden")[] }
79
+ );
80
+
81
+ export interface EditBatch {
82
+ readonly fields?: readonly FieldEdit[];
83
+ readonly pairedRanges?: readonly PairedRangeEdit[];
84
+ readonly blockEdits?: readonly BlockEdit[];
85
+ readonly inlineEdits?: readonly InlineEdit[];
86
+ readonly tableStructure?: readonly TableStructureEdit[];
87
+ readonly styleEdits?: readonly StyleEdit[];
88
+ readonly resources?: readonly ResourceEdit[];
89
+ readonly controls?: readonly ControlEdit[];
90
+ readonly wrappers?: readonly WrapperEdit[];
91
+ readonly textRanges?: readonly TextRangeEdit[];
92
+ readonly textInsertions?: readonly TextInsertion[];
93
+ readonly runText?: readonly RunTextEdit[];
94
+ readonly runRemovals?: readonly InlineAnchor[];
95
+ readonly alignments?: readonly ParagraphAlignmentEdit[];
96
+ readonly tableInsertions?: readonly TableInsertion[];
97
+ readonly paragraphInsertions?: readonly ParagraphInsertion[];
98
+ readonly headerImages?: readonly HeaderImageEdit[];
99
+ readonly cellAlignments?: readonly CellAlignmentEdit[];
100
+ }
101
+
102
+ export type FieldEdit = {readonly target: ParagraphAnchor; readonly inlineIndex: number} & (
103
+ | { readonly op: "patch"; readonly property: "instruction"; readonly value: string }
104
+ | { readonly op: "patch"; readonly property: "dirty" | "locked"; readonly value?: boolean }
105
+ | { readonly op: "replace"; readonly field?: import("./structured.js").ResolvedField }
106
+ | { readonly op: "cache"; readonly children: readonly ResolvedInline[] }
107
+ );
108
+ export interface PairedRangeEdit {
109
+ readonly id: number;
110
+ readonly bookmark?: string;
111
+ readonly endpoints?: readonly [InlineAnchor, InlineAnchor];
112
+ }
113
+
114
+ export interface TextRangeEdit { readonly target: ParagraphAnchor; readonly start: number; readonly end: number; readonly text: string }
115
+ export interface TextInsertion { readonly target: ParagraphAnchor; readonly position: number; readonly text: string }
116
+ type TableCoordinate =
117
+ | { readonly row?: never; readonly cell?: never }
118
+ | { readonly row: number; readonly cell?: number };
119
+ type PropertyCoordinate =
120
+ | {readonly column: number; readonly row?: never; readonly cell?: never; readonly field: "width"}
121
+ | {readonly column?: never; readonly row?: never; readonly cell?: never; readonly field:
122
+ "style" | "alignment" | "layout" | `look.${"firstRow"|"lastRow"|"firstColumn"|"lastColumn"|"horizontalBanding"|"verticalBanding"}` |
123
+ `border.${"top"|"left"|"bottom"|"right"|"insideH"|"insideV"}`}
124
+ | {readonly column?: never; readonly row: number; readonly cell?: never; readonly field: "height"|"repeatHeader"|"cantSplit"}
125
+ | {readonly column?: never; readonly row: number; readonly cell: number; readonly field: "gridSpan"|"verticalMerge"|"backgroundColor"|"verticalAlignment"|"textDirection"|
126
+ `border.${"top"|"start"|"bottom"|"end"}` | `margin.${"top"|"start"|"bottom"|"end"}`};
127
+ export type TableStructureEdit =
128
+ | { readonly target: TableAnchor; readonly kind: "removeTable" }
129
+ | ({ readonly target: TableAnchor; readonly kind: "replaceNode"; readonly source: ResolvedTable } & TableCoordinate)
130
+ | ({ readonly target: TableAnchor; readonly kind: "patchProperty"; readonly source: ResolvedTable | null } & PropertyCoordinate)
131
+ | { readonly target: TableAnchor; readonly kind: "layout"; readonly value: TableLayout | null }
132
+ | { readonly target: TableAnchor; readonly kind: "insertRow" | "removeRow" | "insertColumn" | "removeColumn"; readonly index: number }
133
+ | { readonly target: TableAnchor; readonly kind: "insertCell" | "removeCell"; readonly row: number; readonly cell: number }
134
+ | { readonly target: TableAnchor; readonly kind: "replaceCell"; readonly row: number; readonly cell: number; readonly blocks: readonly (ResolvedParagraph | ResolvedTable)[] };
135
+
136
+ declare const styleAnchor: unique symbol;
137
+ export interface StyleAnchor { readonly [styleAnchor]: true }
138
+ type EditableDefinition = Exclude<StyleDefinition, NumberingStyleDefinition>;
139
+ export type StyleEdit =
140
+ | { readonly op: "retarget"; readonly target: StyleAnchor; readonly replacement: StyleAnchor }
141
+ | { readonly op: "field"; readonly target: StyleAnchor; readonly region?: StyleRegion; readonly field: StyleField; readonly value: string | null }
142
+ | { readonly op: "region"; readonly target: StyleAnchor; readonly region: StyleRegion; readonly format: TableSectionFormat | null }
143
+ | { readonly op: "add"; readonly definition: StyleDefinition }
144
+ | { readonly op: "patch"; readonly target: StyleAnchor; readonly bold?: boolean; readonly italic?: boolean }
145
+ | { readonly op: "replace"; readonly target: StyleAnchor; readonly definition: EditableDefinition }
146
+ | { readonly op: "remove"; readonly target: StyleAnchor };
147
+
148
+ type StyleRegion = "wholeTable" | "firstRow" | "lastRow" | "firstCol" | "lastCol" | "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert" | "nwCell" | "neCell" | "swCell" | "seCell";
149
+ type StyleField = "basedOn" | "next" | "link" | "b" | "i" | "bCs" | "iCs" | "rtl" | "cs" | "strike" | "caps" | "smallCaps" | "vanish" | "keepNext" | "keepLines" | "pageBreakBefore" | "widowControl" | "bidi" | "contextualSpacing" | "mirrorIndents" | "snapToGrid" | "jc" | "suppressLineNumbers"
150
+ | `rFonts.${"ascii" | "hAnsi" | "eastAsia" | "cs" | "asciiTheme" | "hAnsiTheme" | "eastAsiaTheme" | "cstheme"}`
151
+ | `lang.${"val" | "eastAsia" | "bidi"}` | `${"sz" | "szCs" | "vertAlign" | "runSnapToGrid"}.val`
152
+ | `${"color" | "u" | "shd"}.${"val" | "themeColor" | "themeTint" | "themeShade"}`
153
+ | "u.color" | `shd.${"fill" | "color" | "themeFill" | "themeFillTint" | "themeFillShade"}`
154
+ | `spacing.${"line" | "lineRule" | "before" | "after" | "beforeLines" | "afterLines" | "beforeAutospacing" | "afterAutospacing"}`
155
+ | `ind.${"left" | "right" | "start" | "end" | "leftChars" | "rightChars" | "startChars" | "endChars" | "firstLine" | "hanging" | "firstLineChars" | "hangingChars"}`
156
+ | `tab.${number}.${"val" | "leader"}`;
157
+
158
+ export type ResourceEdit =
159
+ | { [K in keyof DefaultValues]: {readonly kind: "documentDefault"; readonly field: K; readonly value: DefaultValues[K] | null} }[keyof DefaultValues]
160
+ | { readonly kind: "metadata"; readonly field: import("./inspection.js").MetadataField; readonly value: string | null }
161
+ | { readonly kind: "customProperty"; readonly name: string; readonly value: string | boolean | null }
162
+ | { readonly kind: "replaceInstance"; readonly definition: Omit<NumberingDefinition, "abstractId" | "inheritStyle" | "levels"> & {readonly abstractId: number} }
163
+ | { readonly kind: "replaceAbstract"; readonly abstractId: number; readonly levels: readonly NumberingLevel[] }
164
+ | { readonly kind: "abstractLevel"; readonly abstractId: number; readonly level: number; readonly value: NumberingLevel | null }
165
+ | { readonly kind: "relinkInstance"; readonly numId: number; readonly abstractId: number }
166
+ | { readonly kind: "storyParagraphNumbering"; readonly target: StoryParagraphAnchor; readonly value: { readonly id: number; readonly level: number } | null }
167
+ | { readonly kind: "addAbstract"; readonly abstractId: number; readonly levels: readonly NumberingLevel[] }
168
+ | { readonly kind: "instanceLevel"; readonly numId: number; readonly level: number; readonly value: NumberingLevel | null }
169
+ | { readonly kind: "removeAbstract"; readonly abstractId: number }
170
+ | { readonly kind: "addInstance"; readonly numId: number; readonly abstractId: number }
171
+ | { readonly kind: "removeInstance"; readonly numId: number }
172
+ | { readonly kind: "instanceStart"; readonly numId: number; readonly level: number; readonly value: number | null }
173
+ | { readonly kind: "paragraphNumbering"; readonly target: ParagraphAnchor; readonly value: { readonly id: number; readonly level: number } | null }
174
+ | { readonly kind: "coreTitle"; readonly value: string | null }
175
+ | { readonly kind: "coreSubject"; readonly value: string | null }
176
+ | { readonly kind: "defaultAlignment"; readonly value: Alignment | null }
177
+ | { readonly kind: "abstractStart"; readonly abstractId: number; readonly level: number; readonly value: number | null };
178
+
179
+ export interface ControlEdit {
180
+ readonly target: ControlAnchor;
181
+ readonly tag?: string;
182
+ readonly alias?: string;
183
+ readonly text?: string;
184
+ }
185
+ export type WrapperEdit =
186
+ | {readonly kind:"wrap"; readonly target:import("./inspection.js").ControlSiteAnchor; readonly last?:import("./inspection.js").ControlSiteAnchor; readonly tag:string}
187
+ | {readonly kind:"unwrap"; readonly target:ControlAnchor}
188
+ | {readonly kind:"define"; readonly target:ControlAnchor; readonly properties:import("./structured.js").ContentControlProperties}
189
+ | {readonly kind:"choice"; readonly target:ControlAnchor; readonly selected:string; readonly choices?:import("./inspection.js").ImportedControl["choices"]}
190
+ | {readonly kind:"replaceInlines"; readonly target:ControlAnchor; readonly inlines:readonly ResolvedInline[]}
191
+ | {readonly kind:"replaceBlocks"; readonly target:ControlAnchor; readonly blocks:readonly (ResolvedParagraph|ResolvedTable)[]};
192
+
193
+ export interface RunTextEdit { readonly target: InlineAnchor; readonly text: string }
194
+ export interface RunRemovalChange {
195
+ readonly bodyIndex: number;
196
+ readonly inlineIndex: number;
197
+ readonly before: string;
198
+ }
199
+ export interface RunTextChange {
200
+ readonly bodyIndex: number;
201
+ readonly inlineIndex: number;
202
+ readonly before: string;
203
+ readonly after: string;
204
+ }
205
+
206
+ export interface AlignmentChange {
207
+ readonly bodyIndex: number;
208
+ /** Original XML attribute value; absent if the alignment was unset. */
209
+ readonly before?: string;
210
+ readonly after: Alignment;
211
+ }
212
+
213
+ export interface TableInsertionChange {
214
+ readonly afterBodyIndex: number;
215
+ readonly rows: number;
216
+ readonly columns: number;
217
+ }
218
+
219
+ export interface HeaderImageChange {
220
+ readonly sourcePart: string;
221
+ readonly outputPart: string;
222
+ readonly affectedSections: readonly number[];
223
+ readonly restoredSection?: number;
224
+ readonly mode: HeaderEditMode;
225
+ }
226
+
227
+ declare const preview: unique symbol;
228
+ export interface EditPreview {
229
+ blockChanges(): readonly number[];
230
+ readonly [preview]: "edit";
231
+ /** Changes in original body order, excluding unchanged alignments. */
232
+ changes(): readonly AlignmentChange[];
233
+ cellAlignmentChanges(): readonly CellAlignmentChange[];
234
+ runTextChanges(): readonly RunTextChange[];
235
+ runRemovals(): readonly RunRemovalChange[];
236
+ /** Insertions in original body order. */
237
+ insertions(): readonly TableInsertionChange[];
238
+ inlineChanges(): readonly (readonly [number, number])[];
239
+ /** Original body indices after which paragraphs were inserted. */
240
+ paragraphInsertions(): readonly number[];
241
+ /** Changes in target section order. */
242
+ headerChanges(): readonly HeaderImageChange[];
243
+ /** Encode a fresh copy; does not consume the preview or alter its source. */
244
+ toDocx(): Uint8Array;
245
+ }
246
+
247
+ export interface HeaderImagePreview {
248
+ readonly [preview]: "headerImage";
249
+ change(): HeaderImageChange;
250
+ toDocx(): Uint8Array;
251
+ }
252
+
253
+ declare module "./inspection.js" {
254
+ interface ImportedDocument {
255
+ previewLayout(edits: readonly LayoutEdit[]): EditPreview;
256
+ styleAnchor(id: string): StyleAnchor;
257
+ previewWrapControl(edit: {readonly target: import("./inspection.js").ControlSiteAnchor; readonly tag: string}): EditPreview;
258
+ previewUnwrapControl(target: ControlAnchor): EditPreview;
259
+ previewReplaceControl(edit: {readonly target: ControlAnchor; readonly properties: import("./structured.js").ContentControlProperties}): EditPreview;
260
+ previewControlChoice(edit: {readonly target: ControlAnchor; readonly selected: string;
261
+ readonly choices?: import("./inspection.js").ImportedControl["choices"]}): EditPreview;
262
+ previewTrackedBold(edit: { readonly target: InlineAnchor; readonly bold: boolean; readonly author: string; readonly date?: string }): EditPreview;
263
+ previewTrackedParagraph(edit: { readonly target: ParagraphAnchor; readonly author: string; readonly date?: string } & (
264
+ | { readonly kind: "insertBefore"; readonly text: string }
265
+ | { readonly kind: "delete"; readonly text?: never }
266
+ )): EditPreview;
267
+ previewParagraphRevision(edit: { readonly target: ParagraphAnchor; readonly action: "accept" | "reject" }): EditPreview;
268
+ /** Explicitly track a single-text direct body run edit. */
269
+ previewTrackedText(edit: {
270
+ readonly target: InlineAnchor; readonly author: string; readonly date?: string;
271
+ } & (
272
+ | { readonly kind: "replace" | "insertAfter"; readonly text: string }
273
+ | { readonly kind: "delete"; readonly text?: never }
274
+ )): EditPreview;
275
+ /** Generate both move legs using a fresh name and a required UTC date. */
276
+ previewTrackedMove(edit: {
277
+ readonly target: InlineAnchor; readonly after: InlineAnchor;
278
+ readonly name: string; readonly author: string; readonly date: string;
279
+ }): EditPreview;
280
+ /** Review one insertion/deletion wrapper; moves require both wrappers. */
281
+ previewRevision(edit: {
282
+ readonly target: InlineAnchor; readonly action: "accept" | "reject"; readonly paired?: InlineAnchor;
283
+ }): EditPreview;
284
+ /** Change single-text runs in the named physical story part, including all aliases. */
285
+ editStoryText(batch: { readonly ownerPart: string; readonly runText: readonly RunTextEdit[] }): Uint8Array;
286
+ editStoryReference(edit: {readonly sectionIndex: number; readonly storyKind: "header" | "footer"; readonly variant: "default" | "first" | "even"} & (
287
+ | {readonly action: "create"; readonly blocks: readonly (ResolvedParagraph | ResolvedTable)[]}
288
+ | {readonly action: "link"; readonly partName: string}
289
+ | {readonly action: "remove"}
290
+ )): Uint8Array;
291
+ editStoryBlocks(edit: {readonly target: HeaderAnchor; readonly mode: HeaderEditMode; readonly index: number; readonly remove: number; readonly blocks: readonly (ResolvedParagraph | ResolvedTable)[]}): Uint8Array;
292
+ editEntryInlines(batch: { readonly ownerPart: string; readonly inlineEdits: readonly InlineEdit[] }): Uint8Array;
293
+ replaceField(batch: {readonly target: ParagraphAnchor; readonly inlineIndex: number; readonly field?: import("./structured.js").ResolvedField}): Uint8Array;
294
+ fieldAt(batch: {readonly target: ParagraphAnchor; readonly inlineIndex: number}): {readonly complex: boolean; readonly instruction: string; readonly inlineCount: number; readonly dirtyXml?: string; readonly lockedXml?: string};
295
+ patchField(batch: {readonly target: ParagraphAnchor; readonly inlineIndex: number} & ({readonly property: "instruction"; readonly value: string} | {readonly property: "dirty" | "locked"; readonly value?: boolean})): Uint8Array;
296
+ setPairedRange(batch: {readonly id: number; readonly bookmark?: string; readonly endpoints?: readonly [InlineAnchor, InlineAnchor]}): Uint8Array;
297
+ bodyRangeMarkers(): readonly {readonly bodyIndex: number; readonly inlineIndex: number; readonly kind: "bookmarkStart" | "bookmarkEnd" | "commentRangeStart" | "commentRangeEnd" | "commentReference"; readonly id?: string; readonly name?: string}[];
298
+ editRunFormat(batch: { readonly ownerPart?: string; readonly inlineEdits: readonly Extract<InlineEdit, { readonly kind: "setBold" | "setToggle" | "patchFormat" }>[] }): Uint8Array;
299
+ editNoteReference(edit: { readonly ownerPart: string; readonly target: InlineAnchor } & (
300
+ | { readonly kind: "create"; readonly id: number; readonly text: string }
301
+ | { readonly kind: "delete" | "detach" }
302
+ | { readonly kind: "attach" | "retarget" | "renumber"; readonly id: number }
303
+ )): Uint8Array;
304
+ editEntry(edit: { readonly ownerPart: string; readonly id: string } & (
305
+ | { readonly kind: "insertParagraph" | "replaceParagraph"; readonly index: number; readonly value: string }
306
+ | { readonly kind: "removeParagraph"; readonly index: number }
307
+ | { readonly kind: "author" | "date" | "initials"; readonly value: string }
308
+ | { readonly kind: "clearDate" | "clearInitials" | "deleteUnusedNote" }
309
+ )): Uint8Array;
310
+ editPartTables(batch: { readonly ownerPart: string; readonly tableStructure: readonly Exclude<TableStructureEdit, {readonly kind: "replaceNode" | "removeTable"}>[] }): Uint8Array;
311
+ /** Atomically stage edits against this snapshot's original anchors. */
312
+ preview(batch: EditBatch): EditPreview;
313
+ /** Append an inline image to a shared header/footer or a section-local fork. */
314
+ previewHeaderImage(edit: HeaderImageEdit): HeaderImagePreview;
315
+ }
316
+ }
@@ -0,0 +1,31 @@
1
+ import type { RenderOptions } from "./boundary.js";
2
+ import type { NamedImageData } from "./drawings.js";
3
+ import type { Value } from "./resolution.js";
4
+ import type { TemplateEdits, TemplateSource } from "./template.js";
5
+ import type { ResolvedDocument } from "./text-layout.js";
6
+
7
+ export * from "../index.js";
8
+
9
+ declare const templateFileSource: unique symbol;
10
+ export interface TemplateFileSource {
11
+ readonly [templateFileSource]: true;
12
+ }
13
+
14
+ /** Read a local DOCX or DOTX each time it is used for rendering or saving. */
15
+ export function templateFile(path: string, edits?: TemplateEdits): TemplateFileSource;
16
+
17
+ /** Read image bytes only when resolved and retain the path's basename. Single-use. */
18
+ export function imageFile(path: string): Value<NamedImageData>;
19
+
20
+ export interface SaveDocxOptions extends RenderOptions {
21
+ readonly template?: TemplateSource | TemplateFileSource;
22
+ }
23
+
24
+ /** Encode fully, then replace the local destination via a sibling temporary file. */
25
+ export function saveDocx(document: ResolvedDocument, path: string, options?: SaveDocxOptions): Promise<void>;
26
+
27
+ declare module "./text-layout.js" {
28
+ interface ResolvedDocument {
29
+ toDocxWithTemplate(source: TemplateFileSource, options?: RenderOptions): Promise<Uint8Array<ArrayBuffer>>;
30
+ }
31
+ }