docx-kit 0.0.0 → 0.2.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,1817 @@
1
+ import { AlignmentType, Document } from "docx";
2
+ import { EChartsOption } from "echarts";
3
+
4
+ //#region src/types/utility.d.ts
5
+ /** Hexadecimal CSS color string, e.g. `"#ff0000"`. */
6
+ type HexColor = `#${string}`;
7
+ /**
8
+ * A literal union type that still allows arbitrary string values.
9
+ * Useful for autocomplete-friendly APIs with extensible values.
10
+ *
11
+ * @template T — The literal subtype (e.g. `'Arial' | 'Calibri'`)
12
+ * @template U — The base type, defaults to `string`
13
+ */
14
+ type LiteralUnion<T extends U, U = string> = T | (U & {});
15
+ /**
16
+ * A value that might be synchronous or wrapped in a Promise.
17
+ *
18
+ * @template T — The inner value type
19
+ */
20
+ type MaybePromise<T> = Promise<T> | T;
21
+ /**
22
+ * CSS-like length value.
23
+ *
24
+ * Supports bare numbers, and explicit unit strings:
25
+ * `%`, `cm`, `in`, `mm`, `pt`, `px`.
26
+ *
27
+ * Bare-number conventions vary by context:
28
+ * - `fontSize` → interpreted as `pt`
29
+ * - spacing / indent → interpreted as `pt`
30
+ * - image size → interpreted as `px`
31
+ */
32
+ type UnitValue = `${number}%` | `${number}cm` | `${number}in` | `${number}mm` | `${number}pt` | `${number}px` | number;
33
+ //#endregion
34
+ //#region src/types/style.d.ts
35
+ /**
36
+ * A single border side descriptor.
37
+ *
38
+ * Follows the CSS `border` shorthand convention (style, width, color).
39
+ */
40
+ interface BorderRule {
41
+ /** Border color (e.g. `"#333"` or named color). */
42
+ color?: string | HexColor;
43
+ /** Line style. */
44
+ style?: BorderStyle;
45
+ /** Line width (bare number treated as pt). */
46
+ width?: UnitValue;
47
+ }
48
+ /** Available border line styles. */
49
+ type BorderStyle = 'dashed' | 'dotted' | 'double' | 'none' | 'single';
50
+ /**
51
+ * CSS-like style descriptor for a run, paragraph, cell, or table.
52
+ *
53
+ * Keys mirror familiar CSS property names. Unknown properties that don't
54
+ * map to Word XML are silently ignored.
55
+ */
56
+ interface DocxStyleRule {
57
+ /** Force text to uppercase (small caps-like). */
58
+ allCaps?: boolean;
59
+ /** Background / shading color. */
60
+ backgroundColor?: string | HexColor;
61
+ /** Shorthand border for all four sides. */
62
+ border?: BorderRule;
63
+ /** Bottom border override. */
64
+ borderBottom?: BorderRule;
65
+ /** Left border override. */
66
+ borderLeft?: BorderRule;
67
+ /** Right border override. */
68
+ borderRight?: BorderRule;
69
+ /** Top border override. */
70
+ borderTop?: BorderRule;
71
+ /** Character spacing (letter-spacing). */
72
+ characterSpacing?: number;
73
+ /** Text / foreground color. */
74
+ color?: string | HexColor;
75
+ /**
76
+ * Direct passthrough to the underlying `docx` library constructor options.
77
+ * Use for properties not yet covered by the CSS-like mapping.
78
+ */
79
+ docx?: Record<string, unknown>;
80
+ /** Font family name. */
81
+ fontFamily?: LiteralUnion<'Arial' | 'Calibri' | 'Times New Roman'>;
82
+ /** Font size (bare number = pt). */
83
+ fontSize?: UnitValue;
84
+ /** Italic toggle. */
85
+ fontStyle?: 'italic' | 'normal';
86
+ /** Font weight: keyword `"bold"` / `"normal"` or numeric 100–900. */
87
+ fontWeight?: FontWeight;
88
+ /** Element height. */
89
+ height?: UnitValue;
90
+ /** Text highlight color (background marker). */
91
+ highlight?: HighlightColor;
92
+ /** Keep lines together on same page. */
93
+ keepLines?: boolean;
94
+ /** Keep this paragraph with the next one. */
95
+ keepNext?: boolean;
96
+ /** Character spacing. */
97
+ letterSpacing?: UnitValue;
98
+ /** Line height multiplier or explicit unit value. */
99
+ lineHeight?: number | UnitValue;
100
+ /** Bottom margin. */
101
+ marginBottom?: UnitValue;
102
+ /** Left margin. */
103
+ marginLeft?: UnitValue;
104
+ /** Right margin. */
105
+ marginRight?: UnitValue;
106
+ /** Top margin. */
107
+ marginTop?: UnitValue;
108
+ /** Force page break before this paragraph. */
109
+ pageBreakBefore?: boolean;
110
+ /** Small caps text variant. */
111
+ smallCaps?: boolean;
112
+ /** Strikethrough toggle. */
113
+ strike?: boolean;
114
+ /** Sub-script text. */
115
+ subScript?: boolean;
116
+ /** Super-script text. */
117
+ superScript?: boolean;
118
+ /** Horizontal text alignment. */
119
+ textAlign?: TextAlign;
120
+ /** First-line indent. */
121
+ textIndent?: UnitValue;
122
+ /** Underline style. */
123
+ underline?: 'double' | 'single' | boolean;
124
+ /** Vertical alignment (mostly for table cells). */
125
+ verticalAlign?: VerticalAlign;
126
+ /** Element width. */
127
+ width?: UnitValue;
128
+ /**
129
+ * CSS-like margin shorthand.
130
+ *
131
+ * Supports 1-value, 2-value, and 4-value string syntax
132
+ * (e.g. `"10pt"`, `"10pt 20pt"`, `"10pt 20pt 30pt 40pt"`).
133
+ */
134
+ margin?: `${string} ${string}` | `${string} ${string} ${string} ${string}` | UnitValue;
135
+ /**
136
+ * CSS-like padding shorthand (same syntax as margin).
137
+ */
138
+ padding?: `${string} ${string}` | `${string} ${string} ${string} ${string}` | UnitValue;
139
+ }
140
+ /**
141
+ * Font weight: keyword `"bold"` / `"normal"`, or numeric 100–900
142
+ * following the CSS `font-weight` spec.
143
+ */
144
+ type FontWeight = 'bold' | 'normal' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
145
+ /** Text highlight / marker colors (matches Word highlight palette). */
146
+ type HighlightColor = 'black' | 'blue' | 'cyan' | 'darkBlue' | 'darkCyan' | 'darkGray' | 'darkGreen' | 'darkMagenta' | 'darkRed' | 'darkYellow' | 'green' | 'lightGray' | 'magenta' | 'none' | 'red' | 'white' | 'yellow';
147
+ /**
148
+ * A map of class name → style rule.
149
+ *
150
+ * Used to define reusable named styles referenced via `className` on nodes.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * const styles = defineStyles({
155
+ * red: { color: '#ff0000' },
156
+ * big: { fontSize: 20 },
157
+ * })
158
+ * ```
159
+ */
160
+ type StyleSheet = Record<string, DocxStyleRule>;
161
+ /** Horizontal text alignment. */
162
+ type TextAlign = 'center' | 'justify' | 'left' | 'right';
163
+ /** Vertical alignment (for table cells). */
164
+ type VerticalAlign = 'bottom' | 'middle' | 'top';
165
+ /**
166
+ * Define a type-safe stylesheet.
167
+ *
168
+ * `fontSize` defaults to pt when passed as a bare number.
169
+ *
170
+ * @param styles - — The stylesheet object
171
+ * @returns The same stylesheet with `const` type inference
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * const styles = defineStyles({
176
+ * title: { fontSize: 28, fontWeight: 'bold' },
177
+ * body: { fontSize: 12, lineHeight: 1.5 },
178
+ * })
179
+ * ```
180
+ */
181
+ declare function defineStyles<const T extends StyleSheet>(styles: T): T;
182
+ //#endregion
183
+ //#region src/types/document.d.ts
184
+ /**
185
+ * Top-level configuration passed to `createDocx()`.
186
+ *
187
+ * Covers page setup, stylesheet, theme tokens, element defaults,
188
+ * and document metadata.
189
+ *
190
+ * @template TStyles — The user's stylesheet type (inferred from `styles`).
191
+ */
192
+ interface DocxKitConfig<TStyles extends StyleSheet = StyleSheet> {
193
+ /** Page dimensions and margins. */
194
+ page?: PageConfig;
195
+ /** Named style classes (class → style rule map). */
196
+ styles?: TStyles;
197
+ /** Semantic design tokens for theming. */
198
+ theme?: DocxTheme;
199
+ /** Default styles applied as base for each element type. */
200
+ defaults?: {
201
+ /** Default table cell style. */cell?: DocxStyleRule; /** Default image style (applied to the paragraph wrapping the image). */
202
+ image?: DocxStyleRule; /** Default paragraph style. */
203
+ paragraph?: DocxStyleRule; /** Default table style. */
204
+ table?: DocxStyleRule; /** Default text run style. */
205
+ text?: DocxStyleRule;
206
+ };
207
+ /** OOXML core properties (appear in File → Info). */
208
+ metadata?: {
209
+ /** Document author. */creator?: string; /** Document description / summary. */
210
+ description?: string; /** Keywords / tags. */
211
+ keywords?: string[]; /** Last editor. */
212
+ lastModifiedBy?: string; /** Document subject. */
213
+ subject?: string; /** Document title. */
214
+ title?: string;
215
+ };
216
+ }
217
+ /**
218
+ * Theme tokens that can be referenced in styles.
219
+ *
220
+ * Allows defining a single source of truth for colors, fonts,
221
+ * font sizes, and spacing values.
222
+ */
223
+ interface DocxTheme {
224
+ /** Color palette (name → hex). */
225
+ colors?: Record<string, string>;
226
+ /** Font family tokens (name → font family). */
227
+ fontFamily?: Record<string, string>;
228
+ /** Font size tokens (name → value). */
229
+ fontSize?: Record<string, UnitValue>;
230
+ /** Spacing tokens (name → value). */
231
+ spacing?: Record<string, UnitValue>;
232
+ }
233
+ /**
234
+ * Header/footer configuration for a section.
235
+ *
236
+ * Supports standard, first-page, and even-page variants.
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * {
241
+ * default: { children: ['Chapter 1'] },
242
+ * first: { children: ['Title Page'] },
243
+ * }
244
+ * ```
245
+ */
246
+ interface HeaderFooterConfig {
247
+ /** Default header/footer (appears on all pages). */
248
+ default?: HeaderFooterContent;
249
+ /** Even-page header/footer (overrides default on even pages). */
250
+ even?: HeaderFooterContent;
251
+ /** First-page-only header/footer (overrides default on page 1). */
252
+ first?: HeaderFooterContent;
253
+ }
254
+ /**
255
+ * Content for a header or footer — a list of text strings.
256
+ *
257
+ * Each string maps to a `Paragraph` in the compiled .docx output.
258
+ * Future versions may support richer content (tables, images, page numbers).
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * { default: ['Company Name', 'Confidential'] }
263
+ * ```
264
+ */
265
+ interface HeaderFooterContent {
266
+ /** Paragraph text lines. */
267
+ children: string[];
268
+ }
269
+ /** Page orientation. */
270
+ type Orientation = 'landscape' | 'portrait';
271
+ /**
272
+ * Page configuration (size, orientation, margin).
273
+ */
274
+ interface PageConfig {
275
+ /** Page orientation (`"portrait"` default). */
276
+ orientation?: Orientation;
277
+ /** Page size: preset name or explicit dimensions. */
278
+ size?: PageSize | {
279
+ height: UnitValue;
280
+ width: UnitValue;
281
+ };
282
+ /**
283
+ * Page margin.
284
+ *
285
+ * Supports 1-value, 2-value, and 4-value shorthand
286
+ * (e.g. `"20mm"`, `"20mm 15mm"`, `"20mm 15mm 25mm 15mm"`).
287
+ */
288
+ margin?: `${string} ${string}` | `${string} ${string} ${string} ${string}` | UnitValue;
289
+ }
290
+ /** Available page size presets. */
291
+ type PageSize = 'A3' | 'A4' | 'Legal' | 'Letter';
292
+ /**
293
+ * Per-section configuration.
294
+ *
295
+ * Each call to `.section(config)` starts a new document section, which
296
+ * can have its own page setup, headers, and footers independent of other
297
+ * sections.
298
+ *
299
+ * @example
300
+ * ```ts
301
+ * doc.section({
302
+ * page: { size: 'A3', orientation: 'landscape' },
303
+ * header: { default: { children: ['Wide Page'] } },
304
+ * })
305
+ * ```
306
+ */
307
+ interface SectionConfig {
308
+ /** Section footer(s). */
309
+ footer?: HeaderFooterConfig;
310
+ /** Section header(s). */
311
+ header?: HeaderFooterConfig;
312
+ /** Section-specific page dimensions (overrides document-level `page`). */
313
+ page?: PageConfig;
314
+ }
315
+ //#endregion
316
+ //#region src/dsl/nodes.d.ts
317
+ /**
318
+ * Common properties shared by all nodes.
319
+ *
320
+ * @template TStyles — The user's stylesheet type
321
+ */
322
+ interface BaseNode<TStyles extends StyleSheet = StyleSheet> {
323
+ /**
324
+ * CSS-like class name(s) referencing stylesheet entries.
325
+ *
326
+ * Can be a single string, an array, or a space-separated string.
327
+ */
328
+ className?: string | ClassName<TStyles> | ClassName<TStyles>[];
329
+ /** Optional unique identifier (for templating / references). */
330
+ id?: string;
331
+ /** Inline style override for this specific node. */
332
+ style?: DocxStyleRule;
333
+ }
334
+ /**
335
+ * Union of all top-level content node types.
336
+ *
337
+ * @template TStyles — The user's stylesheet type
338
+ */
339
+ type BlockNode<TStyles extends StyleSheet = StyleSheet> = BulletListNode<TStyles> | HeadingNode<TStyles> | HyperlinkNode<TStyles> | ImageNode<TStyles> | NumberedListNode<TStyles> | PageBreakNode | ParagraphNode<TStyles> | PluginNode<string, unknown, TStyles> | SectionBreakNode | TableNode<Record<string, unknown>, TStyles>;
340
+ /**
341
+ * A structured list item (for rich bullet/numbered items).
342
+ *
343
+ * @template TStyles — The user's stylesheet type
344
+ */
345
+ interface BulletItem<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
346
+ /** Item text content. */
347
+ text: string;
348
+ /** Optional inline children override (instead of text). */
349
+ children?: InlineNode<TStyles>[];
350
+ }
351
+ /**
352
+ * A bullet list node.
353
+ *
354
+ * Supports plain string items or structured items with children.
355
+ *
356
+ * @template TStyles — The user's stylesheet type
357
+ */
358
+ interface BulletListNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
359
+ /** List items — strings or structured items. */
360
+ items: (string | BulletItem<TStyles>)[];
361
+ type: 'bulletList';
362
+ /** Bullet character / style. Default: `'•'`. */
363
+ bullet?: string;
364
+ /** Nested list level (0 = top-level). */
365
+ level?: number;
366
+ }
367
+ /**
368
+ * Extract valid class name keys from a stylesheet type.
369
+ *
370
+ * @template TStyles — The user's stylesheet type
371
+ */
372
+ type ClassName<TStyles extends StyleSheet> = Extract<keyof TStyles, string>;
373
+ /**
374
+ * A heading node (h1–h6).
375
+ *
376
+ * @template TStyles — The user's stylesheet type
377
+ */
378
+ interface HeadingNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
379
+ /** Heading level (1 = largest, 6 = smallest). */
380
+ level: 1 | 2 | 3 | 4 | 5 | 6;
381
+ /** Heading text content. */
382
+ text: string;
383
+ type: 'heading';
384
+ }
385
+ /**
386
+ * A hyperlink node (inline content that creates a clickable link).
387
+ *
388
+ * @template TStyles — The user's stylesheet type
389
+ */
390
+ interface HyperlinkNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
391
+ /** Display text or inline children. */
392
+ children: (string | TextNode<TStyles>)[];
393
+ type: 'hyperlink';
394
+ /** Link target URL. */
395
+ url: string;
396
+ }
397
+ /**
398
+ * An image node.
399
+ *
400
+ * Supports raw bytes (`Uint8Array`, `ArrayBuffer`, `Blob`) or a file path string.
401
+ *
402
+ * @template TStyles — The user's stylesheet type
403
+ */
404
+ interface ImageNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
405
+ /** Image data as bytes, blob, or file path. */
406
+ data: string | ArrayBuffer | Blob | Uint8Array;
407
+ type: 'image';
408
+ /** Alt text for accessibility. */
409
+ alt?: string;
410
+ /** Display height. */
411
+ height?: UnitValue;
412
+ /** Image format hint. Auto-detected if omitted. */
413
+ imageType?: 'bmp' | 'gif' | 'jpeg' | 'jpg' | 'png';
414
+ /** Display width. */
415
+ width?: UnitValue;
416
+ /**
417
+ * Floating layout configuration.
418
+ *
419
+ * - `true` enables default floating
420
+ * - Object allows wrap mode and position offsets
421
+ */
422
+ floating?: boolean | {
423
+ /** Text wrap mode. */wrap?: 'square' | 'tight' | 'topAndBottom'; /** Horizontal offset. */
424
+ x?: UnitValue; /** Vertical offset. */
425
+ y?: UnitValue;
426
+ };
427
+ }
428
+ /**
429
+ * Union of inline content node types (appear inside paragraphs).
430
+ *
431
+ * @template TStyles — The user's stylesheet type
432
+ */
433
+ type InlineNode<TStyles extends StyleSheet = StyleSheet> = HyperlinkNode<TStyles> | ImageNode<TStyles> | TextNode<TStyles>;
434
+ /**
435
+ * A numbered / ordered list node.
436
+ *
437
+ * @template TStyles — The user's stylesheet type
438
+ */
439
+ interface NumberedListNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
440
+ /** List items. */
441
+ items: (string | BulletItem<TStyles>)[];
442
+ type: 'numberedList';
443
+ /** Nested list level (0 = top-level). */
444
+ level?: number;
445
+ /** Starting number (default: 1). */
446
+ start?: number;
447
+ /**
448
+ * Numbering format.
449
+ *
450
+ * {@link `LevelFormat.DECIMAL`} by default.
451
+ * e.g. `'decimal'`, `'upperRoman'`, `'lowerLetter'`
452
+ */
453
+ numberingFormat?: 'decimal' | 'lowerLetter' | 'lowerRoman' | 'upperLetter' | 'upperRoman';
454
+ }
455
+ /**
456
+ * A forced page break.
457
+ */
458
+ interface PageBreakNode {
459
+ type: 'pageBreak';
460
+ }
461
+ /**
462
+ * A paragraph containing text and/or inline children.
463
+ *
464
+ * @template TStyles — The user's stylesheet type
465
+ */
466
+ interface ParagraphNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
467
+ type: 'paragraph';
468
+ /** Inline children (text runs, inline images, etc.). */
469
+ children?: InlineNode<TStyles>[];
470
+ /** Plain-text content (used when `children` is not provided). */
471
+ text?: string;
472
+ }
473
+ /**
474
+ * A plugin-invocation node.
475
+ *
476
+ * Plugins extend the DSL with arbitrary content types.
477
+ *
478
+ * @template TName — Plugin name (string literal)
479
+ * @template TOptions — Plugin-specific options shape
480
+ * @template TStyles — The user's stylesheet type
481
+ */
482
+ interface PluginNode<TName extends string = string, TOptions = unknown, TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
483
+ /** Registered plugin name. */
484
+ name: TName;
485
+ /** Plugin-specific options. */
486
+ options: TOptions;
487
+ type: 'plugin';
488
+ }
489
+ /**
490
+ * Internal marker node that represents a section boundary.
491
+ *
492
+ * Created automatically by {@link DocxBuilder.section} — users should
493
+ * not create this node directly.
494
+ *
495
+ * When the compiler encounters this marker, it starts a new section
496
+ * with the provided configuration.
497
+ */
498
+ interface SectionBreakNode {
499
+ type: 'sectionBreak';
500
+ /** Optional per-section page/header/footer overrides. */
501
+ config?: SectionConfig;
502
+ }
503
+ /**
504
+ * A column definition for a table.
505
+ *
506
+ * @template TData — The row data type
507
+ */
508
+ interface TableColumn<TData extends Record<string, unknown> = Record<string, unknown>> {
509
+ /** Key in the data object this column maps to. */
510
+ key: Extract<keyof TData, string>;
511
+ /** Column header text. */
512
+ title: string;
513
+ /** Cell text alignment. */
514
+ align?: 'center' | 'left' | 'right';
515
+ /**
516
+ * Span multiple columns horizontally.
517
+ *
518
+ * Applied to all cells in this column.
519
+ */
520
+ colSpan?: number;
521
+ /**
522
+ * Span multiple rows vertically (per-cell via data hints).
523
+ *
524
+ * Set `rowSpan` on individual data objects using `_rowSpan: N` or keep it
525
+ * as a static column default.
526
+ */
527
+ rowSpan?: number;
528
+ /** Column width. Supports percentage strings (e.g. `"30%"`). */
529
+ width?: UnitValue;
530
+ /**
531
+ * Custom cell renderer.
532
+ *
533
+ * Receives the raw value, full row data, and row index.
534
+ * Returns a string or inline nodes.
535
+ */
536
+ render?: (value: TData[keyof TData], row: TData, index: number) => string | InlineNode[];
537
+ }
538
+ /**
539
+ * A table node with column definitions and data rows.
540
+ *
541
+ * @template TData — The row data type
542
+ * @template TStyles — The user's stylesheet type
543
+ */
544
+ interface TableNode<TData extends Record<string, unknown> = Record<string, unknown>, TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
545
+ /** Column definitions. */
546
+ columns: TableColumn<TData>[];
547
+ /** Row data objects. */
548
+ data: TData[];
549
+ type: 'table';
550
+ /** Show table borders. */
551
+ bordered?: boolean;
552
+ /** Default cell style for data rows. */
553
+ cellStyle?: DocxStyleRule;
554
+ /** Show header row (default: `true`). */
555
+ header?: boolean;
556
+ /** Style for header cells. */
557
+ headerCellStyle?: DocxStyleRule;
558
+ /** Alternate row shading. */
559
+ striped?: boolean;
560
+ }
561
+ /**
562
+ * A text run node (inline content).
563
+ *
564
+ * @template TStyles — The user's stylesheet type
565
+ */
566
+ interface TextNode<TStyles extends StyleSheet = StyleSheet> extends BaseNode<TStyles> {
567
+ /** Text content. */
568
+ text: string;
569
+ type: 'text';
570
+ }
571
+ //#endregion
572
+ //#region src/types/plugin.d.ts
573
+ /**
574
+ * A docx-kit plugin.
575
+ *
576
+ * Plugins have a unique `name`, an optional `setup` hook,
577
+ * and a required `render` function that receives user options
578
+ * and a rendering context.
579
+ *
580
+ * @template TName — The plugin name (string literal type)
581
+ * @template TOptions — The shape of the user-provided options
582
+ */
583
+ interface DocxPlugin<TName extends string = string, TOptions = unknown> {
584
+ /** Unique plugin name, used as the node discriminator. */
585
+ name: TName;
586
+ /** One-time setup called when the plugin is registered. */
587
+ setup?: () => MaybePromise<void>;
588
+ /**
589
+ * Render plugin content into one or more `docx` objects
590
+ * (Paragraph, Table, etc.).
591
+ *
592
+ * @param options - — User-provided plugin options
593
+ * @param context - — Rendering context with helper utilities
594
+ */
595
+ render: (options: TOptions, context: PluginRenderContext) => MaybePromise<unknown>;
596
+ }
597
+ /**
598
+ * Type-level map of plugin name → options type.
599
+ *
600
+ * Constructed via `Builder.use()` chaining.
601
+ */
602
+ type PluginRegistry = Record<string, unknown>;
603
+ /**
604
+ * Rendering context passed to a plugin's `render()` function.
605
+ *
606
+ * Provides access to the document config, image utilities,
607
+ * and the ability to compile child nodes.
608
+ */
609
+ interface PluginRenderContext {
610
+ /** The full document config. */
611
+ config: DocxKitConfig;
612
+ /** Compile a child node (useful for nesting). */
613
+ compileNode: (node: BlockNode) => Promise<unknown>;
614
+ /** Utility helpers. */
615
+ utils: {
616
+ image: {
617
+ /** Convert a Blob to raw image bytes. */fromBlob: (blob: Blob) => Promise<Uint8Array>;
618
+ /**
619
+ * Decode a base64 data-URL to raw image bytes.
620
+ * Works in both browser and Node.js environments.
621
+ */
622
+ fromDataUrl: (dataUrl: string) => MaybePromise<Uint8Array>;
623
+ };
624
+ };
625
+ }
626
+ /**
627
+ * Define a type-safe plugin with full inference.
628
+ *
629
+ * @param plugin - — The plugin definition object
630
+ * @returns The same plugin with `const` type inference
631
+ *
632
+ * @example
633
+ * ```ts
634
+ * const myPlugin = definePlugin<'badge', { text: string }>({
635
+ * name: 'badge',
636
+ * render: async (opts, ctx) => {
637
+ * // ... render logic
638
+ * return new Paragraph({ text: opts.text })
639
+ * },
640
+ * })
641
+ * ```
642
+ */
643
+ declare function definePlugin<const TName extends string, TOptions>(plugin: DocxPlugin<TName, TOptions>): DocxPlugin<TName, TOptions>;
644
+ //#endregion
645
+ //#region src/plugins/qrcode/index.d.ts
646
+ /**
647
+ * QR Code plugin — embeds a QR code image in the document.
648
+ *
649
+ * Uses the `qrcode` package (peer dependency) to generate
650
+ * a QR code PNG and renders it as an inline `ImageRun`.
651
+ *
652
+ * @module plugins/qrcode
653
+ *
654
+ * @example
655
+ * ```ts
656
+ * const doc = createDocx()
657
+ * .use(qrcodePlugin())
658
+ * .h1('Scan Me')
659
+ * .plugin('qrcode', { text: 'https://example.com', caption: 'Visit us' })
660
+ * .save('qrcode.docx')
661
+ * ```
662
+ */
663
+ /**
664
+ * Options for the QRCode plugin.
665
+ */
666
+ interface QRCodePluginOptions {
667
+ /** The text / URL to encode. */
668
+ text: string;
669
+ /** Optional caption text displayed below the QR code. */
670
+ caption?: string;
671
+ /**
672
+ * QR error correction level.
673
+ *
674
+ * - `"L"` — ~7% recovery
675
+ * - `"M"` — ~15% recovery
676
+ * - `"Q"` — ~25% recovery
677
+ * - `"H"` — ~30% recovery
678
+ *
679
+ * @default "M"
680
+ */
681
+ errorCorrectionLevel?: 'H' | 'L' | 'M' | 'Q';
682
+ /** QR code margin (in modules). @default 1 */
683
+ margin?: number;
684
+ /** QR code image size in pixels. @default 128 */
685
+ size?: number;
686
+ }
687
+ /**
688
+ * Create a QRCode plugin instance.
689
+ *
690
+ * The plugin dynamically imports the `qrcode` package at render time,
691
+ * keeping it an optional peer dependency of docx-kit core.
692
+ *
693
+ * @returns A configured DocxPlugin for `'qrcode'`
694
+ *
695
+ * @example
696
+ * ```ts
697
+ * import { createDocx, qrcodePlugin } from 'docx-kit'
698
+ *
699
+ * const doc = createDocx()
700
+ * .use(qrcodePlugin())
701
+ * .plugin('qrcode', {
702
+ * text: 'https://example.com',
703
+ * size: 256,
704
+ * errorCorrectionLevel: 'H',
705
+ * caption: 'Scan to visit',
706
+ * })
707
+ * ```
708
+ */
709
+ declare function qrcodePlugin(): DocxPlugin<"qrcode", QRCodePluginOptions>;
710
+ //#endregion
711
+ //#region src/plugins/callout/index.d.ts
712
+ /**
713
+ * Callout plugin — colored info / warning / success / danger boxes.
714
+ *
715
+ * Renders a single `Paragraph` with a prominent left border, a tinted
716
+ * background, an emoji icon, an optional bold title, and body text.
717
+ *
718
+ * @module plugins/callout
719
+ *
720
+ * @example
721
+ * ```ts
722
+ * const doc = createDocx()
723
+ * .use(calloutPlugin())
724
+ * .plugin('callout', {
725
+ * type: 'warning',
726
+ * title: '注意',
727
+ * content: '此操作不可撤销,请确认后再提交。',
728
+ * })
729
+ * .save('callout.docx')
730
+ * ```
731
+ */
732
+ /** Options for the Callout plugin. */
733
+ interface CalloutOptions {
734
+ /** Body text of the callout. */
735
+ content: string;
736
+ /** Callout style — controls icon, color, and tone. */
737
+ type: 'danger' | 'info' | 'success' | 'warning';
738
+ /** Optional bold title line placed before the content. */
739
+ title?: string;
740
+ }
741
+ /**
742
+ * Create a Callout plugin instance.
743
+ *
744
+ * @returns A configured DocxPlugin for `'callout'`
745
+ *
746
+ * @example
747
+ * ```ts
748
+ * import { createDocx, calloutPlugin } from 'docx-kit'
749
+ *
750
+ * const doc = createDocx()
751
+ * .use(calloutPlugin())
752
+ * .plugin('callout', { type: 'info', content: '系统将在今晚 22:00 升级。' })
753
+ * ```
754
+ */
755
+ declare function calloutPlugin(): DocxPlugin<"callout", CalloutOptions>;
756
+ //#endregion
757
+ //#region src/plugins/echarts/index.d.ts
758
+ /**
759
+ * Options for the ECharts plugin.
760
+ */
761
+ interface EChartsPluginOptions {
762
+ /** Full ECharts option object (series, axes, title, etc.). */
763
+ option: EChartsOption;
764
+ /** Optional caption text displayed below the chart. */
765
+ caption?: string;
766
+ /** Chart height in pixels. @default 360 */
767
+ height?: number;
768
+ /** Output image format. @default "png" */
769
+ imageType?: 'png' | 'svg';
770
+ /** ECharts rendering engine. @default "canvas" */
771
+ renderer?: 'canvas' | 'svg';
772
+ /** Chart width in pixels. @default 640 */
773
+ width?: number;
774
+ }
775
+ //#endregion
776
+ //#region src/builder/DocxBuilder.d.ts
777
+ /**
778
+ * Fluent document builder.
779
+ *
780
+ * Use `createDocx()` to instantiate, then chain `.h1()`, `.p()`, `.table()`,
781
+ * etc. to build content. Call `.save()`, `.toBlob()`, `.toBuffer()`, or
782
+ * `.toBase64()` to export the document.
783
+ *
784
+ * @template TStyles — Inferred stylesheet type from `config.styles`
785
+ * @template TPlugins — Accumulated plugin registry (built via `.use()`)
786
+ */
787
+ declare class DocxBuilder<TStyles extends StyleSheet = StyleSheet, TPlugins extends PluginRegistry = Record<never, never>> {
788
+ private readonly config;
789
+ private readonly nodes;
790
+ private readonly pendingSetups;
791
+ private readonly pluginMap;
792
+ constructor(config?: DocxKitConfig<TStyles>);
793
+ /**
794
+ * Add a raw DSL node to the document.
795
+ *
796
+ * @param node - — Any block-level node
797
+ * @returns The builder (for chaining)
798
+ *
799
+ * @example
800
+ * ```ts
801
+ * doc.add({ type: 'heading', level: 2, text: 'Section' })
802
+ * doc.add({ type: 'pageBreak' })
803
+ * ```
804
+ */
805
+ add(node: BlockNode<TStyles>): this;
806
+ /**
807
+ * Add a bullet (unordered) list.
808
+ *
809
+ * @param items - — List items (strings or structured items)
810
+ * @param options - — Optional bullet character, className, style, level
811
+ * @returns The builder (for chaining)
812
+ *
813
+ * @example
814
+ * ```ts
815
+ * doc.bulletList(['Item 1', 'Item 2', 'Item 3'])
816
+ * doc.bulletList([
817
+ * 'Simple item',
818
+ * { text: 'Rich item', className: 'highlight' },
819
+ * ], { bullet: '\u25CB' })
820
+ * ```
821
+ */
822
+ bulletList(items: (string | BulletItem<TStyles>)[], options?: Omit<Partial<BulletListNode<TStyles>>, 'items' | 'type'>): this;
823
+ /**
824
+ * Add a level-1 heading.
825
+ *
826
+ * @param text - — Heading text
827
+ * @param options - — Optional style overrides (className, id, style)
828
+ * @returns The builder (for chaining)
829
+ *
830
+ * @example
831
+ * ```ts
832
+ * doc.h1('Introduction', { className: 'title' })
833
+ * ```
834
+ */
835
+ h1(text: string, options?: Omit<Partial<HeadingNode<TStyles>>, 'level' | 'text' | 'type'>): this;
836
+ /**
837
+ * Add a level-2 heading.
838
+ *
839
+ * @param text - — Heading text
840
+ * @param options - — Optional style overrides
841
+ * @returns The builder (for chaining)
842
+ */
843
+ h2(text: string, options?: Omit<Partial<HeadingNode<TStyles>>, 'level' | 'text' | 'type'>): this;
844
+ /**
845
+ * Add a level-3 heading.
846
+ *
847
+ * @param text - — Heading text
848
+ * @param options - — Optional style overrides
849
+ * @returns The builder (for chaining)
850
+ */
851
+ h3(text: string, options?: Omit<Partial<HeadingNode<TStyles>>, 'level' | 'text' | 'type'>): this;
852
+ /**
853
+ * Add a level-4 heading.
854
+ *
855
+ * @param text - — Heading text
856
+ * @param options - — Optional style overrides
857
+ * @returns The builder (for chaining)
858
+ */
859
+ h4(text: string, options?: Omit<Partial<HeadingNode<TStyles>>, 'level' | 'text' | 'type'>): this;
860
+ /**
861
+ * Add a level-5 heading.
862
+ *
863
+ * @param text - — Heading text
864
+ * @param options - — Optional style overrides
865
+ * @returns The builder (for chaining)
866
+ */
867
+ h5(text: string, options?: Omit<Partial<HeadingNode<TStyles>>, 'level' | 'text' | 'type'>): this;
868
+ /**
869
+ * Add a level-6 heading.
870
+ *
871
+ * @param text - — Heading text
872
+ * @param options - — Optional style overrides
873
+ * @returns The builder (for chaining)
874
+ */
875
+ h6(text: string, options?: Omit<Partial<HeadingNode<TStyles>>, 'level' | 'text' | 'type'>): this;
876
+ /**
877
+ * Add a hyperlink.
878
+ *
879
+ * @param url - — Target URL
880
+ * @param text - — Display text
881
+ * @param options - — Optional style overrides
882
+ * @returns The builder (for chaining)
883
+ *
884
+ * @example
885
+ * ```ts
886
+ * doc.hyperlink('https://example.com', 'Click here')
887
+ * ```
888
+ */
889
+ hyperlink(url: string, text: string, options?: Omit<Partial<HyperlinkNode<TStyles>>, 'children' | 'type' | 'url'>): this;
890
+ /**
891
+ * Add an image node.
892
+ *
893
+ * @param options - — Image node options (data, width, height, etc.)
894
+ * @returns The builder (for chaining)
895
+ *
896
+ * @example
897
+ * ```ts
898
+ * doc.image({ data: imageBytes, width: 400, height: 300 })
899
+ * ```
900
+ */
901
+ image(options: Omit<ImageNode<TStyles>, 'type'>): this;
902
+ /**
903
+ * Add a numbered (ordered) list.
904
+ *
905
+ * @param items - — List items
906
+ * @param options - — Optional numbering format, start, className, style, level
907
+ * @returns The builder (for chaining)
908
+ *
909
+ * @example
910
+ * ```ts
911
+ * doc.numberedList(['First', 'Second', 'Third'])
912
+ * doc.numberedList(
913
+ * [{ text: 'Intro' }, { text: 'Body' }],
914
+ * { numberingFormat: 'upperRoman', start: 1 },
915
+ * )
916
+ * ```
917
+ */
918
+ numberedList(items: (string | BulletItem<TStyles>)[], options?: Omit<Partial<NumberedListNode<TStyles>>, 'items' | 'type'>): this;
919
+ /**
920
+ * Add a paragraph.
921
+ *
922
+ * @param text - — Paragraph text content
923
+ * @param options - — Optional style overrides (className, id, style)
924
+ * @returns The builder (for chaining)
925
+ *
926
+ * @example
927
+ * ```ts
928
+ * doc.p('Hello world', { className: 'body', style: { textAlign: 'center' } })
929
+ * ```
930
+ */
931
+ p(text: string, options?: Omit<Partial<ParagraphNode<TStyles>>, 'text' | 'type'>): this;
932
+ /**
933
+ * Add a forced page break.
934
+ *
935
+ * @returns The builder (for chaining)
936
+ *
937
+ * @example
938
+ * ```ts
939
+ * doc.h1('Chapter 1').pageBreak().h1('Chapter 2')
940
+ * ```
941
+ */
942
+ pageBreak(): this;
943
+ /**
944
+ * Invoke a registered plugin.
945
+ *
946
+ * @param name - — Plugin name (must match a previously registered plugin)
947
+ * @param options - — Plugin-specific options
948
+ * @param style - — Optional inline style for the plugin's container
949
+ * @returns The builder (for chaining)
950
+ *
951
+ * @example
952
+ * ```ts
953
+ * doc.use(qrcodePlugin()).plugin('qrcode', { text: 'https://example.com' })
954
+ * ```
955
+ */
956
+ plugin<TName extends string & keyof TPlugins>(name: TName, options: TPlugins[TName], style?: DocxStyleRule): this;
957
+ /**
958
+ * Save the document to a file (Node.js only).
959
+ *
960
+ * **⚠️ Not available in browser environments.**
961
+ * Use {@link toBlob} and trigger a download instead.
962
+ *
963
+ * @param filename - — Output file path (e.g. `"report.docx"`)
964
+ *
965
+ * @example
966
+ * ```ts
967
+ * await doc.save('output.docx')
968
+ * ```
969
+ */
970
+ save(filename: string): Promise<void>;
971
+ /**
972
+ * Start a new document section.
973
+ *
974
+ * Each section can have its own page size, orientation, margins,
975
+ * headers, and footers. Content added after this call belongs to
976
+ * the new section.
977
+ *
978
+ * @param config - — Optional section-level page/header/footer overrides
979
+ * @returns The builder (for chaining)
980
+ *
981
+ * @example
982
+ * ```ts
983
+ * // Simple section break
984
+ * doc.p('Section 1 content').section().p('Section 2 content')
985
+ *
986
+ * // Section with custom page setup
987
+ * doc.section({ page: { size: 'A3', orientation: 'landscape' } })
988
+ * .h1('Wide table')
989
+ * .table({ columns: [...], data: [...] })
990
+ *
991
+ * // Section with header and footer
992
+ * doc.section({
993
+ * header: { default: { children: ['Chapter 2', 'Confidential'] } },
994
+ * footer: { default: { children: ['Page 2'] } },
995
+ * })
996
+ * ```
997
+ */
998
+ section(config?: SectionConfig): this;
999
+ /**
1000
+ * Add a table.
1001
+ *
1002
+ * @param options - — Table node options (columns, data, style, etc.)
1003
+ * @returns The builder (for chaining)
1004
+ *
1005
+ * @example
1006
+ * ```ts
1007
+ * doc.table({
1008
+ * columns: [
1009
+ * { key: 'name', title: 'Name' },
1010
+ * { key: 'value', title: 'Value', align: 'right' },
1011
+ * ],
1012
+ * data: [{ name: 'Revenue', value: '$1.2M' }],
1013
+ * headerCellStyle: { fontWeight: 'bold' },
1014
+ * })
1015
+ * ```
1016
+ */
1017
+ table<TData extends Record<string, unknown>>(options: Omit<TableNode<TData, TStyles>, 'type'>): this;
1018
+ /**
1019
+ * Export the document as a base64-encoded string.
1020
+ *
1021
+ * @returns Base64-encoded .docx data
1022
+ *
1023
+ * @example
1024
+ * ```ts
1025
+ * const b64 = await doc.toBase64()
1026
+ * // Send b64 over HTTP or store in a database
1027
+ * ```
1028
+ */
1029
+ toBase64(): Promise<string>;
1030
+ /**
1031
+ * Export the document as a `Blob` (browser-friendly).
1032
+ *
1033
+ * @returns A `Blob` containing the .docx binary
1034
+ *
1035
+ * @example
1036
+ * ```ts
1037
+ * const blob = await doc.toBlob()
1038
+ * const url = URL.createObjectURL(blob)
1039
+ * ```
1040
+ */
1041
+ toBlob(): Promise<Blob>;
1042
+ /**
1043
+ * Export the document as a `Uint8Array` (alias for {@link toUint8Array}).
1044
+ *
1045
+ * **Note:** Despite the name, this returns a standard `Uint8Array`,
1046
+ * not a Node.js `Buffer`. Prefer using {@link toUint8Array} for clarity.
1047
+ *
1048
+ * @returns Raw .docx bytes
1049
+ *
1050
+ * @example
1051
+ * ```ts
1052
+ * const bytes = await doc.toBuffer()
1053
+ * fs.writeFileSync('output.docx', bytes)
1054
+ * ```
1055
+ */
1056
+ toBuffer(): Promise<Uint8Array>;
1057
+ /**
1058
+ * Compile and return the internal `docx` {@link Document} instance.
1059
+ *
1060
+ * Useful if you need to further manipulate the document with the
1061
+ * raw `docx` library before packaging.
1062
+ *
1063
+ * @returns A `docx` `Document` object
1064
+ */
1065
+ toDocument(): Promise<import("docx").Document>;
1066
+ /**
1067
+ * Serialize the builder state to a JSON-friendly object.
1068
+ *
1069
+ * Useful for debugging, serialization, or AI-driven document generation.
1070
+ *
1071
+ * @returns The config + content node array as a plain object
1072
+ */
1073
+ toJSON(): {
1074
+ content: BlockNode<TStyles>[];
1075
+ page?: PageConfig;
1076
+ styles?: TStyles | undefined;
1077
+ theme?: DocxTheme;
1078
+ defaults?: {
1079
+ cell?: DocxStyleRule;
1080
+ image?: DocxStyleRule;
1081
+ paragraph?: DocxStyleRule;
1082
+ table?: DocxStyleRule;
1083
+ text?: DocxStyleRule;
1084
+ };
1085
+ metadata?: {
1086
+ creator?: string;
1087
+ description?: string;
1088
+ keywords?: string[];
1089
+ lastModifiedBy?: string;
1090
+ subject?: string;
1091
+ title?: string;
1092
+ };
1093
+ };
1094
+ /**
1095
+ * Export the document as a `Uint8Array` (browser & Node.js).
1096
+ *
1097
+ * This is the preferred cross-platform export method.
1098
+ *
1099
+ * @returns Raw .docx bytes
1100
+ *
1101
+ * @example
1102
+ * ```ts
1103
+ * const bytes = await doc.toUint8Array()
1104
+ * // In Node.js: import { writeFileSync } from 'node:fs'
1105
+ * // In browser: trigger a download
1106
+ * ```
1107
+ */
1108
+ toUint8Array(): Promise<Uint8Array>;
1109
+ /**
1110
+ * Register a plugin.
1111
+ *
1112
+ * The plugin's name and options type are accumulated into the builder's
1113
+ * type-level plugin registry, enabling type-safe `.plugin()` calls.
1114
+ *
1115
+ * @param plugin - — The plugin definition returned by `definePlugin()`
1116
+ * @returns The builder with the plugin type merged into `TPlugins`
1117
+ *
1118
+ * @example
1119
+ * ```ts
1120
+ * const doc = createDocx()
1121
+ * .use(qrcodePlugin())
1122
+ * .plugin('qrcode', { text: 'https://example.com' })
1123
+ * ```
1124
+ */
1125
+ use<TName extends string, TOptions>(plugin: DocxPlugin<TName, TOptions>): DocxBuilder<TStyles, Record<TName, TOptions> & TPlugins>;
1126
+ }
1127
+ //#endregion
1128
+ //#region src/plugins/timeline/index.d.ts
1129
+ /**
1130
+ * Timeline plugin — renders a chronological timeline as a styled table.
1131
+ *
1132
+ * Each event occupies one table row: a date cell, a visual connector
1133
+ * cell, and a content cell (title + optional description).
1134
+ *
1135
+ * @module plugins/timeline
1136
+ *
1137
+ * @example
1138
+ * ```ts
1139
+ * const doc = createDocx()
1140
+ * .use(timelinePlugin())
1141
+ * .plugin('timeline', {
1142
+ * events: [
1143
+ * { date: '2026-01', title: '项目立项', description: '完成需求评审' },
1144
+ * { date: '2026-03', title: 'MVP 发布', description: '核心功能上线' },
1145
+ * ],
1146
+ * })
1147
+ * .save('timeline.docx')
1148
+ * ```
1149
+ */
1150
+ /** A single timeline event. */
1151
+ interface TimelineEvent {
1152
+ /** Date / time label (e.g. "2026-06" or "Q3"). */
1153
+ date: string;
1154
+ /** Short event title. */
1155
+ title: string;
1156
+ /** Optional longer description. */
1157
+ description?: string;
1158
+ }
1159
+ /** Options for the Timeline plugin. */
1160
+ interface TimelineOptions {
1161
+ /** Array of timeline events in chronological order. */
1162
+ events: TimelineEvent[];
1163
+ /**
1164
+ * Accent color for the connector line and date highlight.
1165
+ * @default '4472C4'
1166
+ */
1167
+ accentColor?: string;
1168
+ /**
1169
+ * Layout style.
1170
+ *
1171
+ * - `'alternating'` — dates alternate left / right (default)
1172
+ * - `'left'` — all dates on the left, content on the right
1173
+ * - `'right'` — all content on the left, dates on the right
1174
+ *
1175
+ * @default 'alternating'
1176
+ */
1177
+ layout?: 'alternating' | 'left' | 'right';
1178
+ }
1179
+ /**
1180
+ * Create a Timeline plugin instance.
1181
+ *
1182
+ * @returns A configured DocxPlugin for `'timeline'`
1183
+ *
1184
+ * @example
1185
+ * ```ts
1186
+ * import { createDocx, timelinePlugin } from 'docx-kit'
1187
+ *
1188
+ * const doc = createDocx()
1189
+ * .use(timelinePlugin())
1190
+ * .plugin('timeline', {
1191
+ * events: [
1192
+ * { date: '2026-01', title: '项目启动', description: '团队组建完成' },
1193
+ * { date: '2026-04', title: 'Beta 测试', description: '收集用户反馈' },
1194
+ * { date: '2026-06', title: '正式发布' },
1195
+ * ],
1196
+ * })
1197
+ * ```
1198
+ */
1199
+ declare function timelinePlugin(): DocxPlugin<"timeline", TimelineOptions>;
1200
+ //#endregion
1201
+ //#region src/errors.d.ts
1202
+ /**
1203
+ * Error handling types and classes for docx-kit.
1204
+ *
1205
+ * @module errors
1206
+ */
1207
+ /**
1208
+ * Well-known error codes used throughout the library.
1209
+ *
1210
+ * Consumers can match against these codes for structured error handling.
1211
+ */
1212
+ declare const ERROR_CODES: {
1213
+ /** Document export failed. */readonly EXPORT_FAILED: "EXPORT_FAILED"; /** Image data is empty, corrupt, or unsupported. */
1214
+ readonly IMAGE_INVALID_DATA: "IMAGE_INVALID_DATA"; /** A plugin node referenced an unregistered plugin. */
1215
+ readonly PLUGIN_NOT_REGISTERED: "PLUGIN_NOT_REGISTERED"; /** A plugin's `render()` method threw an error. */
1216
+ readonly PLUGIN_RENDER_FAILED: "PLUGIN_RENDER_FAILED"; /** A `className` referenced a stylesheet key that doesn't exist. */
1217
+ readonly STYLE_UNKNOWN_CLASS: "STYLE_UNKNOWN_CLASS"; /** Table was created with no columns. */
1218
+ readonly TABLE_INVALID_COLUMNS: "TABLE_INVALID_COLUMNS"; /** Encountered a node type that has no registered compiler. */
1219
+ readonly UNKNOWN_NODE_TYPE: "UNKNOWN_NODE_TYPE";
1220
+ };
1221
+ /** Union type of all known error codes. */
1222
+ type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
1223
+ /**
1224
+ * Structured error class for docx-kit.
1225
+ *
1226
+ * Carries a machine-readable `code`, a human-readable `message`,
1227
+ * and optionally the underlying `cause`.
1228
+ *
1229
+ * @example
1230
+ * ```ts
1231
+ * try {
1232
+ * await doc.save('output.docx')
1233
+ * } catch (err) {
1234
+ * if (err instanceof DocxKitError && err.code === ERROR_CODES.EXPORT_FAILED) {
1235
+ * console.error('Export failed:', err.message)
1236
+ * }
1237
+ * }
1238
+ * ```
1239
+ */
1240
+ declare class DocxKitError extends Error {
1241
+ /** The underlying error that caused this failure (if any). */
1242
+ readonly cause: unknown;
1243
+ /** Machine-readable error code. */
1244
+ readonly code: string | ErrorCode;
1245
+ /**
1246
+ * @param code - — Known error code from {@link ERROR_CODES}
1247
+ * @param message - — Human-readable description
1248
+ * @param cause - — Optional underlying error
1249
+ */
1250
+ constructor(code: string | ErrorCode, message: string, cause?: unknown);
1251
+ }
1252
+ //#endregion
1253
+ //#region src/plugins/watermark/index.d.ts
1254
+ /** Options for the Watermark plugin. */
1255
+ interface WatermarkOptions {
1256
+ /** Watermark text. */
1257
+ text: string;
1258
+ /**
1259
+ * Horizontal alignment.
1260
+ * @default 'center'
1261
+ */
1262
+ alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];
1263
+ /**
1264
+ * Text color in hex RRGGBB.
1265
+ * @default 'BFBFBF'
1266
+ */
1267
+ color?: string;
1268
+ /**
1269
+ * Font size in half-points (20 = 10pt).
1270
+ * @default 48
1271
+ */
1272
+ fontSize?: number;
1273
+ }
1274
+ /**
1275
+ * Create a Watermark plugin instance.
1276
+ *
1277
+ * @returns A configured DocxPlugin for `'watermark'`
1278
+ *
1279
+ * @example
1280
+ * ```ts
1281
+ * import { createDocx, watermarkPlugin } from 'docx-kit'
1282
+ *
1283
+ * const doc = createDocx()
1284
+ * .use(watermarkPlugin())
1285
+ * .plugin('watermark', { text: 'DRAFT', color: 'FF0000' })
1286
+ * ```
1287
+ */
1288
+ declare function watermarkPlugin(): DocxPlugin<"watermark", WatermarkOptions>;
1289
+ //#endregion
1290
+ //#region src/plugins/code-block/index.d.ts
1291
+ /**
1292
+ * Code Block plugin — renders source code with monospaced font and
1293
+ * optional line numbers and syntax highlighting.
1294
+ *
1295
+ * Syntax highlighting requires `highlight.js` as an optional peer dependency.
1296
+ * When unavailable (or when `language` is not provided), the plugin falls
1297
+ * back to plain monospaced rendering.
1298
+ *
1299
+ * @module plugins/code-block
1300
+ *
1301
+ * @example
1302
+ * ```ts
1303
+ * const doc = createDocx()
1304
+ * .use(codeBlockPlugin())
1305
+ * .plugin('codeBlock', {
1306
+ * code: `export function hello() {\n return "world"\n}`,
1307
+ * language: 'typescript',
1308
+ * showLineNumbers: true,
1309
+ * })
1310
+ * .save('code.docx')
1311
+ * ```
1312
+ */
1313
+ /** Options for the CodeBlock plugin. */
1314
+ interface CodeBlockOptions {
1315
+ /** Source code string. */
1316
+ code: string;
1317
+ /**
1318
+ * Language identifier for syntax highlighting (optional).
1319
+ *
1320
+ * Requires `highlight.js` as a peer dependency. Falls back
1321
+ * to monospaced rendering when the package is not installed.
1322
+ */
1323
+ language?: string;
1324
+ /** Prepend line numbers. @default false */
1325
+ showLineNumbers?: boolean;
1326
+ }
1327
+ /**
1328
+ * Create a CodeBlock plugin instance.
1329
+ *
1330
+ * @returns A configured DocxPlugin for `'codeBlock'`
1331
+ */
1332
+ declare function codeBlockPlugin(): DocxPlugin<"codeBlock", CodeBlockOptions>;
1333
+ //#endregion
1334
+ //#region src/plugins/cover-page/index.d.ts
1335
+ /** Options for the Cover Page plugin. */
1336
+ interface CoverPageOptions {
1337
+ /** Main title text (required). */
1338
+ title: string;
1339
+ /** Horizontal text alignment. @default CENTER */
1340
+ alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];
1341
+ /** Author or department name. */
1342
+ author?: string;
1343
+ /** Background color of the cover page in hex RRGGBB. */
1344
+ backgroundColor?: string;
1345
+ /** Date string (e.g. "2026-06-11"). */
1346
+ date?: string;
1347
+ /** Organization / company name. */
1348
+ organization?: string;
1349
+ /**
1350
+ * Show a decorative horizontal rule between title and author.
1351
+ * @default true
1352
+ */
1353
+ showRule?: boolean;
1354
+ /** Sub-title text displayed below the title. */
1355
+ subtitle?: string;
1356
+ }
1357
+ /**
1358
+ * Create a Cover Page plugin instance.
1359
+ *
1360
+ * @returns A configured DocxPlugin for `'coverPage'`
1361
+ *
1362
+ * @example
1363
+ * ```ts
1364
+ * import { coverPagePlugin, createDocx } from 'docx-kit'
1365
+ *
1366
+ * const doc = createDocx()
1367
+ * .use(coverPagePlugin())
1368
+ * .plugin('coverPage', {
1369
+ * title: '年度报告',
1370
+ * subtitle: '2026',
1371
+ * author: '战略发展部',
1372
+ * organization: 'XX 科技集团',
1373
+ * })
1374
+ * ```
1375
+ */
1376
+ declare function coverPagePlugin(): DocxPlugin<"coverPage", CoverPageOptions>;
1377
+ //#endregion
1378
+ //#region src/plugins/data-table/index.d.ts
1379
+ /**
1380
+ * Data Table plugin — renders an array of objects as a styled table.
1381
+ *
1382
+ * Columns are auto-inferred from the first object’s keys. Column headers
1383
+ * can be localised via `labels`, value formatting is controlled by `format`,
1384
+ * and per-column alignment is controlled by `align`.
1385
+ *
1386
+ * @module plugins/data-table
1387
+ *
1388
+ * @example
1389
+ * ```ts
1390
+ * const doc = createDocx()
1391
+ * .use(dataTablePlugin())
1392
+ * .plugin('dataTable', {
1393
+ * data: [
1394
+ * { name: 'Alice', age: 30, salary: 85000 },
1395
+ * { name: 'Bob', age: 25, salary: 62000 },
1396
+ * ],
1397
+ * labels: { name: '姓名', age: '年龄', salary: '薪资' },
1398
+ * format: { salary: 'currency' },
1399
+ * striped: true,
1400
+ * })
1401
+ * .save('table.docx')
1402
+ * ```
1403
+ */
1404
+ /** Per-column alignment hint. */
1405
+ type ColAlign = 'center' | 'left' | 'right';
1406
+ /** Value formatter identifier. */
1407
+ type ColFormat = 'currency' | 'date' | 'number' | 'percent';
1408
+ /** Options for the DataTable plugin. */
1409
+ interface DataTableOptions {
1410
+ /**
1411
+ * The data to render — each object is one row.
1412
+ *
1413
+ * Column keys are taken from the first object in the array.
1414
+ */
1415
+ data: Record<string, unknown>[];
1416
+ /** Per-column alignment. Auto-detected from value types when omitted. */
1417
+ align?: Record<string, ColAlign>;
1418
+ /** Render visible table borders. @default true */
1419
+ bordered?: boolean;
1420
+ /** Per-column value formatter. */
1421
+ format?: Record<string, ColFormat>;
1422
+ /** Human-readable column labels (e.g. `{ salary: '薪资' }`). */
1423
+ labels?: Record<string, string>;
1424
+ /** Alternate row background shading. @default false */
1425
+ striped?: boolean;
1426
+ }
1427
+ /**
1428
+ * Create a DataTable plugin instance.
1429
+ *
1430
+ * @returns A configured DocxPlugin for `'dataTable'`
1431
+ */
1432
+ declare function dataTablePlugin(): DocxPlugin<"dataTable", DataTableOptions>;
1433
+ //#endregion
1434
+ //#region src/plugins/page-number/index.d.ts
1435
+ /** Options for the Page Number plugin. */
1436
+ interface PageNumberOptions {
1437
+ /**
1438
+ * Horizontal alignment of the page number.
1439
+ * @default 'center'
1440
+ */
1441
+ alignment?: (typeof AlignmentType)[keyof typeof AlignmentType];
1442
+ /**
1443
+ * Font size in half-points.
1444
+ * @default 20
1445
+ */
1446
+ fontSize?: number;
1447
+ /**
1448
+ * Show "Page X of Y" instead of just "X".
1449
+ * @default false
1450
+ */
1451
+ showTotal?: boolean;
1452
+ }
1453
+ /**
1454
+ * Create a Page Number plugin instance.
1455
+ *
1456
+ * @returns A configured DocxPlugin for `'pageNumber'`
1457
+ *
1458
+ * @example
1459
+ * ```ts
1460
+ * import { createDocx, pageNumberPlugin } from 'docx-kit'
1461
+ *
1462
+ * const doc = createDocx()
1463
+ * .use(pageNumberPlugin())
1464
+ * // Use the page number content in a footer
1465
+ * const pn = doc.plugin('pageNumber', { alignment: 'center' })
1466
+ * ```
1467
+ */
1468
+ declare function pageNumberPlugin(): DocxPlugin<"pageNumber", PageNumberOptions>;
1469
+ //#endregion
1470
+ //#region src/builder/createDocx.d.ts
1471
+ /**
1472
+ * JSON schema for `renderDocx()`.
1473
+ *
1474
+ * The schema is deliberately simple — a flat config object plus an
1475
+ * ordered array of block nodes. This makes it easy to generate from
1476
+ * AI / LLMs or store as JSON.
1477
+ *
1478
+ * @template TStyles — The user's stylesheet type
1479
+ */
1480
+ interface DocxSchema<TStyles extends StyleSheet = StyleSheet> {
1481
+ /** Ordered array of block nodes. */
1482
+ content: BlockNode<TStyles>[];
1483
+ /** Optional page configuration. */
1484
+ page?: DocxKitConfig<TStyles>['page'];
1485
+ /** Named stylesheet entries. */
1486
+ styles?: TStyles;
1487
+ }
1488
+ /**
1489
+ * Create a new DocxBuilder with optional configuration.
1490
+ *
1491
+ * This is the primary entry point for the fluent builder API.
1492
+ * Chain `.h1()`, `.p()`, `.table()`, etc. and call `.save()`
1493
+ * or `.toBlob()` to export.
1494
+ *
1495
+ * @param config - — Document configuration (page, styles, metadata, theme, defaults)
1496
+ * @returns A new `DocxBuilder` instance
1497
+ *
1498
+ * @example
1499
+ * ```ts
1500
+ * const styles = defineStyles({
1501
+ * title: { fontSize: 28, fontWeight: 'bold' },
1502
+ * body: { fontSize: 12, lineHeight: 1.5 },
1503
+ * })
1504
+ *
1505
+ * const doc = createDocx({
1506
+ * styles,
1507
+ * page: { size: 'A4', margin: '20mm' },
1508
+ * metadata: { title: 'Report', creator: 'docx-kit' },
1509
+ * })
1510
+ *
1511
+ * await doc
1512
+ * .h1('Annual Report', { className: 'title' })
1513
+ * .p('Lorem ipsum...', { className: 'body' })
1514
+ * .save('report.docx')
1515
+ * ```
1516
+ */
1517
+ declare function createDocx<const TStyles extends StyleSheet = StyleSheet>(config?: DocxKitConfig<TStyles>): DocxBuilder<TStyles, Record<never, never>>;
1518
+ /**
1519
+ * Render a document from a JSON schema (AI-friendly / serializable DSL).
1520
+ *
1521
+ * Unlike `createDocx()`, this accepts a single JSON-serializable object
1522
+ * with `content` (node array), optional `styles`, and optional `page` config.
1523
+ * Ideal for AI-driven document generation or API integrations.
1524
+ *
1525
+ * @param schema - — The `DocxSchema` object
1526
+ * @returns A `DocxBuilder` instance (ready to export)
1527
+ *
1528
+ * @example
1529
+ * ```ts
1530
+ * const blob = await renderDocx({
1531
+ * page: { size: 'A4', margin: '20mm' },
1532
+ * styles: {
1533
+ * h1: { fontSize: 24, fontWeight: 'bold' },
1534
+ * p: { fontSize: 12 },
1535
+ * },
1536
+ * content: [
1537
+ * { type: 'heading', level: 1, text: 'Report', className: 'h1' },
1538
+ * { type: 'paragraph', text: 'This is a report generated via JSON DSL.', className: 'p' },
1539
+ * { type: 'pageBreak' },
1540
+ * {
1541
+ * type: 'table',
1542
+ * columns: [{ key: 'name', title: 'Name' }, { key: 'value', title: 'Value' }],
1543
+ * data: [{ name: 'Revenue', value: '$1.2M' }],
1544
+ * },
1545
+ * ],
1546
+ * }).toBlob()
1547
+ * ```
1548
+ */
1549
+ declare function renderDocx<const TStyles extends StyleSheet = StyleSheet>(schema: DocxSchema<TStyles>): DocxBuilder<TStyles>;
1550
+ //#endregion
1551
+ //#region src/plugins/property-table/index.d.ts
1552
+ /**
1553
+ * Property Table plugin — renders key-value pairs as a styled 2-column table.
1554
+ *
1555
+ * The key column is right-aligned with gray background; the value column
1556
+ * is left-aligned. Ideal for config tables, parameter docs, and spec sheets.
1557
+ *
1558
+ * @module plugins/property-table
1559
+ *
1560
+ * @example
1561
+ * ```ts
1562
+ * const doc = createDocx()
1563
+ * .use(propertyTablePlugin())
1564
+ * .plugin('propertyTable', {
1565
+ * items: [
1566
+ * { key: '项目名称', value: 'XX管理系统' },
1567
+ * { key: '技术栈', value: 'React + Node.js + PostgreSQL' },
1568
+ * ],
1569
+ * keyBold: true,
1570
+ * })
1571
+ * .save('props.docx')
1572
+ * ```
1573
+ */
1574
+ /** A single key-value pair. */
1575
+ interface PropertyItem {
1576
+ key: string;
1577
+ value: string;
1578
+ }
1579
+ /** Options for the PropertyTable plugin. */
1580
+ interface PropertyTableOptions {
1581
+ /** Key-value items to display. */
1582
+ items: PropertyItem[];
1583
+ /**
1584
+ * Whether the key column text is bold. @default true
1585
+ */
1586
+ keyBold?: boolean;
1587
+ /** Alternate row background shading. @default true */
1588
+ striped?: boolean;
1589
+ }
1590
+ /**
1591
+ * Create a PropertyTable plugin instance.
1592
+ *
1593
+ * @returns A configured DocxPlugin for `'propertyTable'`
1594
+ */
1595
+ declare function propertyTablePlugin(): DocxPlugin<"propertyTable", PropertyTableOptions>;
1596
+ //#endregion
1597
+ //#region src/plugins/meeting-minutes/index.d.ts
1598
+ /**
1599
+ * Meeting Minutes plugin — structured meeting notes with header, meta info,
1600
+ * and an agenda table.
1601
+ *
1602
+ * Renders a title paragraph, a date/attendees summary line, and a 4-column
1603
+ * agenda table (Topic | Discussion | Decision | Owner).
1604
+ *
1605
+ * @module plugins/meeting-minutes
1606
+ *
1607
+ * @example
1608
+ * ```ts
1609
+ * const doc = createDocx()
1610
+ * .use(meetingMinutesPlugin())
1611
+ * .plugin('meetingMinutes', {
1612
+ * title: '项目周会纪要',
1613
+ * date: '2026-06-11',
1614
+ * attendees: ['张三', '李四', '王五'],
1615
+ * agenda: [
1616
+ * { topic: '项目进度', discussion: '模块A已完成80%', decision: '下周一上线', owner: '张三' },
1617
+ * { topic: '风险项', discussion: '第三方API不稳定', decision: '增加重试机制', owner: '李四' },
1618
+ * ],
1619
+ * })
1620
+ * .save('minutes.docx')
1621
+ * ```
1622
+ */
1623
+ /** A single agenda item. */
1624
+ interface AgendaItem {
1625
+ /** Discussion notes. */
1626
+ discussion: string;
1627
+ /** Meeting topic. */
1628
+ topic: string;
1629
+ /** Decision made. */
1630
+ decision?: string;
1631
+ /** Responsible person. */
1632
+ owner?: string;
1633
+ }
1634
+ /** Options for the MeetingMinutes plugin. */
1635
+ interface MeetingMinutesOptions {
1636
+ /** Agenda items to render in the table. */
1637
+ agenda: AgendaItem[];
1638
+ /** Attendee names. */
1639
+ attendees: string[];
1640
+ /** Meeting date (e.g. "2026-06-11"). */
1641
+ date: string;
1642
+ /** Meeting title (rendered as Heading 1). */
1643
+ title: string;
1644
+ }
1645
+ /**
1646
+ * Create a MeetingMinutes plugin instance.
1647
+ *
1648
+ * @returns A configured DocxPlugin for `'meetingMinutes'`
1649
+ */
1650
+ declare function meetingMinutesPlugin(): DocxPlugin<"meetingMinutes", MeetingMinutesOptions>;
1651
+ //#endregion
1652
+ //#region src/plugins/signature-block/index.d.ts
1653
+ /**
1654
+ * Signature Block plugin — renders signature lines for contracts and approvals.
1655
+ *
1656
+ * Each party gets a cell in a borderless table with a bold label,
1657
+ * a signature line (underlined placeholder), and an optional date.
1658
+ *
1659
+ * @module plugins/signature-block
1660
+ *
1661
+ * @example
1662
+ * ```ts
1663
+ * const doc = createDocx()
1664
+ * .use(signatureBlockPlugin())
1665
+ * .plugin('signatureBlock', {
1666
+ * parties: [
1667
+ * { label: '甲方(盖章)', date: '2026年 月 日' },
1668
+ * { label: '乙方(盖章)', date: '2026年 月 日' },
1669
+ * ],
1670
+ * columns: 2,
1671
+ * })
1672
+ * .save('signature.docx')
1673
+ * ```
1674
+ */
1675
+ /** Options for the SignatureBlock plugin. */
1676
+ interface SignatureBlockOptions {
1677
+ /** The signing parties. */
1678
+ parties: SignatureParty[];
1679
+ /** Number of columns in the signature grid. @default 2 */
1680
+ columns?: number;
1681
+ }
1682
+ /** A single party in a signature block. */
1683
+ interface SignatureParty {
1684
+ /** Party label (e.g. "甲方(盖章)"). */
1685
+ label: string;
1686
+ /** Pre-filled date (e.g. "2026年 月 日"). */
1687
+ date?: string;
1688
+ /** Pre-filled name (shown underlined when provided). */
1689
+ name?: string;
1690
+ }
1691
+ /**
1692
+ * Create a SignatureBlock plugin instance.
1693
+ *
1694
+ * @returns A configured DocxPlugin for `'signatureBlock'`
1695
+ */
1696
+ declare function signatureBlockPlugin(): DocxPlugin<"signatureBlock", SignatureBlockOptions>;
1697
+ //#endregion
1698
+ //#region src/presets/types.d.ts
1699
+ /**
1700
+ * A named, reusable style preset.
1701
+ *
1702
+ * Each preset provides a `config` object compatible with `DocxKitConfig`.
1703
+ * Spread the config into `createDocx()` to apply the preset, or use the
1704
+ * `usePreset()` helper for lookup by ID.
1705
+ */
1706
+ interface DocxPreset {
1707
+ /** The config fragment to merge into `createDocx()`. */
1708
+ readonly config: DocxKitConfig;
1709
+ /** Short description of the preset's visual character. */
1710
+ readonly description: string;
1711
+ /** Machine-readable identifier (e.g. `"classic"`). */
1712
+ readonly id: string;
1713
+ /** Human-readable display name (e.g. `"Classic"`). */
1714
+ readonly name: string;
1715
+ }
1716
+ //#endregion
1717
+ //#region src/presets/academic.d.ts
1718
+ declare const academicPreset: DocxPreset;
1719
+ //#endregion
1720
+ //#region src/presets/classic.d.ts
1721
+ declare const classicPreset: DocxPreset;
1722
+ //#endregion
1723
+ //#region src/presets/modern.d.ts
1724
+ declare const modernPreset: DocxPreset;
1725
+ //#endregion
1726
+ //#region src/presets/index.d.ts
1727
+ /** Ordered list of built-in presets (for UI selectors). */
1728
+ declare const PRESET_LIST: readonly DocxPreset[];
1729
+ /**
1730
+ * Look up a built-in preset by ID.
1731
+ *
1732
+ * @param id - — Preset identifier (`"classic"`, `"modern"`, or `"academic"`)
1733
+ * @returns The matching preset, or `undefined` if not found
1734
+ *
1735
+ * @example
1736
+ * ```ts
1737
+ * const preset = usePreset('modern')
1738
+ * const doc = createDocx(preset!.config)
1739
+ * ```
1740
+ */
1741
+ declare function usePreset(id: string): DocxPreset | undefined;
1742
+ //#endregion
1743
+ //#region src/node/fs.d.ts
1744
+ /**
1745
+ * Save a compiled document to a file on disk.
1746
+ *
1747
+ * Uses `Packer.toBuffer()` to produce the .docx binary, then
1748
+ * writes via `node:fs/promises`. This function is **Node.js only**.
1749
+ *
1750
+ * @param doc - — A compiled `docx` `Document` instance
1751
+ * @param filename - — Output file path (e.g. `"report.docx"`)
1752
+ *
1753
+ * @example
1754
+ * ```ts
1755
+ * import { saveDocument } from 'docx-kit/node'
1756
+ *
1757
+ * const doc = await compileDocument({ ... })
1758
+ * await saveDocument(doc, 'report.docx')
1759
+ * ```
1760
+ */
1761
+ declare function saveDocument(doc: Document, filename: string): Promise<void>;
1762
+ //#endregion
1763
+ //#region src/node/dataUrl.d.ts
1764
+ /**
1765
+ * Node.js base64 data-URL decoder (uses `Buffer` from `node:buffer`).
1766
+ *
1767
+ * @module node/dataUrl
1768
+ */
1769
+ /**
1770
+ * Decode a base64 data-URL to raw bytes using Node.js `Buffer`.
1771
+ *
1772
+ * Strips the `"data:*;base64,"` prefix and decodes via
1773
+ * `Buffer.from(base64, 'base64')`.
1774
+ *
1775
+ * @param dataUrl - — A base64 data-URI string (e.g. `"data:image/png;base64,iVBO..."`)
1776
+ * @returns Raw bytes as `Uint8Array`
1777
+ *
1778
+ * @example
1779
+ * ```ts
1780
+ * import { dataUrlToUint8Array } from 'docx-kit/node'
1781
+ *
1782
+ * const bytes = await dataUrlToUint8Array('data:image/png;base64,iVBORw...')
1783
+ * ```
1784
+ */
1785
+ declare function dataUrlToUint8Array(dataUrl: string): Promise<Uint8Array>;
1786
+ //#endregion
1787
+ //#region src/node.d.ts
1788
+ /**
1789
+ * ### ❌ `echartsPlugin()` — Not available in Node.js
1790
+ *
1791
+ * The ECharts plugin requires a browser `window` and `document` to
1792
+ * render charts into a DOM container. Node.js has no native DOM.
1793
+ *
1794
+ * **Workarounds:**
1795
+ * - Use a server-side canvas library (e.g. `node-canvas` + `echarts`)
1796
+ * - Pre-render charts on the client and pass the image data to docx-kit
1797
+ *
1798
+ * @deprecated This API is not available in Node.js. See workarounds above.
1799
+ */
1800
+ declare const echartsPlugin: never;
1801
+ /**
1802
+ * ### ❌ `normalizeImageData()` — Not built-in for Node.js
1803
+ *
1804
+ * This utility converts `Blob` instances to `Uint8Array`. While `Blob`
1805
+ * is available in Node.js ≥ 18, it is rarely the carrier for image data
1806
+ * in Node workflows (most users work with `Buffer` or file paths directly).
1807
+ *
1808
+ * If you need Blob→Uint8Array in Node.js, use:
1809
+ * ```ts
1810
+ * const bytes = new Uint8Array(await blob.arrayBuffer())
1811
+ * ```
1812
+ *
1813
+ * @deprecated Use inline `new Uint8Array(await blob.arrayBuffer())` instead.
1814
+ */
1815
+ declare const normalizeImageData: never;
1816
+ //#endregion
1817
+ export { type AgendaItem, type BaseNode, type BlockNode, type BorderRule, type BorderStyle, type BulletItem, type BulletListNode, type CalloutOptions, type ClassName, type CodeBlockOptions, type ColAlign, type ColFormat, type CoverPageOptions, type DataTableOptions, DocxBuilder, type DocxKitConfig, DocxKitError, type DocxPlugin, type DocxPreset, type DocxSchema, type DocxStyleRule, type DocxTheme, type EChartsPluginOptions, ERROR_CODES, type ErrorCode, type FontWeight, type HeaderFooterConfig, type HeaderFooterContent, type HeadingNode, type HighlightColor, type HyperlinkNode, type ImageNode, type InlineNode, type MeetingMinutesOptions, type NumberedListNode, type Orientation, PRESET_LIST, type PageBreakNode, type PageConfig, type PageNumberOptions, type PageSize, type ParagraphNode, type PluginNode, type PluginRegistry, type PluginRenderContext, type PropertyItem, type PropertyTableOptions, type QRCodePluginOptions, type SectionBreakNode, type SectionConfig, type SignatureBlockOptions, type SignatureParty, type StyleSheet, type TableColumn, type TableNode, type TextAlign, type TextNode, type TimelineEvent, type TimelineOptions, type VerticalAlign, type WatermarkOptions, academicPreset, calloutPlugin, classicPreset, codeBlockPlugin, coverPagePlugin, createDocx, dataTablePlugin, dataUrlToUint8Array, definePlugin, defineStyles, echartsPlugin, meetingMinutesPlugin, modernPreset, normalizeImageData, pageNumberPlugin, propertyTablePlugin, qrcodePlugin, renderDocx, saveDocument, signatureBlockPlugin, timelinePlugin, usePreset, watermarkPlugin };