@cj-tech-master/excelts 9.5.0 → 9.5.1

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.
Files changed (68) hide show
  1. package/dist/browser/modules/pdf/excel-bridge.js +27 -1
  2. package/dist/browser/modules/pdf/render/layout-engine.js +74 -9
  3. package/dist/browser/modules/pdf/render/style-converter.d.ts +1 -1
  4. package/dist/browser/modules/pdf/render/style-converter.js +98 -1
  5. package/dist/browser/modules/pdf/types.d.ts +1 -0
  6. package/dist/browser/modules/word/color-utils.d.ts +18 -0
  7. package/dist/browser/modules/word/color-utils.js +94 -0
  8. package/dist/browser/modules/word/content-types.d.ts +15 -15
  9. package/dist/browser/modules/word/content-types.js +39 -43
  10. package/dist/browser/modules/word/crypto.d.ts +17 -0
  11. package/dist/browser/modules/word/crypto.js +18 -0
  12. package/dist/browser/modules/word/document-io.d.ts +58 -0
  13. package/dist/browser/modules/word/document-io.js +239 -0
  14. package/dist/browser/modules/word/document.d.ts +64 -135
  15. package/dist/browser/modules/word/document.js +207 -469
  16. package/dist/browser/modules/word/docx-packager.js +90 -90
  17. package/dist/browser/modules/word/html-renderer.js +1 -1
  18. package/dist/browser/modules/word/html.d.ts +13 -0
  19. package/dist/browser/modules/word/html.js +12 -0
  20. package/dist/browser/modules/word/index.base.d.ts +6 -9
  21. package/dist/browser/modules/word/index.base.js +7 -10
  22. package/dist/browser/modules/word/namespaces.d.ts +159 -0
  23. package/dist/browser/modules/word/namespaces.js +189 -0
  24. package/dist/browser/modules/word/relationships.d.ts +15 -16
  25. package/dist/browser/modules/word/relationships.js +37 -45
  26. package/dist/cjs/modules/pdf/excel-bridge.js +27 -1
  27. package/dist/cjs/modules/pdf/render/layout-engine.js +74 -9
  28. package/dist/cjs/modules/pdf/render/style-converter.js +98 -1
  29. package/dist/cjs/modules/word/color-utils.js +97 -0
  30. package/dist/cjs/modules/word/content-types.js +44 -45
  31. package/dist/cjs/modules/word/crypto.js +34 -0
  32. package/dist/cjs/modules/word/document-io.js +244 -0
  33. package/dist/cjs/modules/word/document.js +209 -473
  34. package/dist/cjs/modules/word/docx-packager.js +88 -88
  35. package/dist/cjs/modules/word/html-renderer.js +2 -2
  36. package/dist/cjs/modules/word/html.js +16 -0
  37. package/dist/cjs/modules/word/index.base.js +17 -27
  38. package/dist/cjs/modules/word/namespaces.js +192 -0
  39. package/dist/cjs/modules/word/relationships.js +42 -47
  40. package/dist/esm/modules/pdf/excel-bridge.js +27 -1
  41. package/dist/esm/modules/pdf/render/layout-engine.js +74 -9
  42. package/dist/esm/modules/pdf/render/style-converter.js +98 -1
  43. package/dist/esm/modules/word/color-utils.js +94 -0
  44. package/dist/esm/modules/word/content-types.js +39 -43
  45. package/dist/esm/modules/word/crypto.js +18 -0
  46. package/dist/esm/modules/word/document-io.js +239 -0
  47. package/dist/esm/modules/word/document.js +207 -469
  48. package/dist/esm/modules/word/docx-packager.js +90 -90
  49. package/dist/esm/modules/word/html-renderer.js +1 -1
  50. package/dist/esm/modules/word/html.js +12 -0
  51. package/dist/esm/modules/word/index.base.js +7 -10
  52. package/dist/esm/modules/word/namespaces.js +189 -0
  53. package/dist/esm/modules/word/relationships.js +37 -45
  54. package/dist/iife/excelts.iife.js +153 -11
  55. package/dist/iife/excelts.iife.js.map +1 -1
  56. package/dist/iife/excelts.iife.min.js +4 -4
  57. package/dist/types/modules/pdf/render/style-converter.d.ts +1 -1
  58. package/dist/types/modules/pdf/types.d.ts +1 -0
  59. package/dist/types/modules/word/color-utils.d.ts +18 -0
  60. package/dist/types/modules/word/content-types.d.ts +15 -15
  61. package/dist/types/modules/word/crypto.d.ts +17 -0
  62. package/dist/types/modules/word/document-io.d.ts +58 -0
  63. package/dist/types/modules/word/document.d.ts +64 -135
  64. package/dist/types/modules/word/html.d.ts +13 -0
  65. package/dist/types/modules/word/index.base.d.ts +6 -9
  66. package/dist/types/modules/word/namespaces.d.ts +159 -0
  67. package/dist/types/modules/word/relationships.d.ts +15 -16
  68. package/package.json +1 -1
@@ -4,8 +4,11 @@
4
4
  * High-level fluent API for constructing DOCX documents programmatically.
5
5
  * Provides convenience methods for common operations including comments,
6
6
  * track changes, TOC, math, text boxes, checkboxes, and custom properties.
7
+ *
8
+ * This file has NO static imports from docx-packager or docx-reader,
9
+ * ensuring that importing builder helpers does not pull in archive/xml code.
7
10
  */
8
- import type { DocxDocument, BodyContent, Paragraph, ParagraphProperties, ParagraphChild, Run, RunProperties, Table, TableRow, TableCell, TableProperties, TableRowProperties, TableCellProperties, SectionProperties, StyleDef, DocDefaults, BookmarkStart, Hyperlink, HeaderFooterContent, ImageDef, ImageMediaType, CoreProperties, AppProperties, DocumentSettings, FontDef, Border, TableWidth, TableBorders, Emu, Twips, CommentDef, DocumentBackground, CustomPropertyValue, TableOfContents, MathBlock, MathContent, CheckBox, RevisionInfo, InsertedRun, DeletedRun, MovedFromRun, MovedToRun, MoveRangeMarker, Chart, ChartSeries, ChartAxis, ChartLegendPosition, ChartContent, CommentRangeStart, CommentRangeEnd, CommentReference, FloatingImage, StructuredDocumentTag, SdtProperties, Watermark, DocumentTheme, ColorSpec, HexColor, DrawingShape, PositionalTabAlignment, PositionalTabRelativeTo, PositionalTabLeader, RubyProperties } from "./types.js";
11
+ import type { DocxDocument, BodyContent, Paragraph, ParagraphProperties, ParagraphChild, Run, RunProperties, Table, TableRow, TableCell, TableProperties, TableRowProperties, TableCellProperties, SectionProperties, StyleDef, DocDefaults, BookmarkStart, Hyperlink, HeaderFooterContent, ImageDef, ImageMediaType, CoreProperties, AppProperties, DocumentSettings, FontDef, Border, TableWidth, TableBorders, Emu, Twips, CommentDef, DocumentBackground, CustomPropertyValue, TableOfContents, MathBlock, MathContent, CheckBox, RevisionInfo, InsertedRun, DeletedRun, MovedFromRun, MovedToRun, MoveRangeMarker, Chart, ChartSeries, ChartAxis, ChartLegendPosition, ChartContent, CommentRangeStart, CommentRangeEnd, CommentReference, FloatingImage, StructuredDocumentTag, SdtProperties, Watermark, HexColor, DrawingShape, PositionalTabAlignment, PositionalTabRelativeTo, PositionalTabLeader, RubyProperties } from "./types.js";
9
12
  /** Create a text run. */
10
13
  export declare function text(content: string, properties?: RunProperties): Run;
11
14
  /** Create a bold text run. */
@@ -411,71 +414,55 @@ export declare function simpleTable(data: string[][], options?: {
411
414
  width?: TableWidth;
412
415
  columnWidths?: Twips[];
413
416
  }): Table;
417
+ declare const _documentBrand: unique symbol;
418
+ /**
419
+ * Opaque handle representing a document being built.
420
+ * Created via `Document.create()`, passed to `Document.*` functions.
421
+ */
422
+ export type DocumentHandle = {
423
+ readonly [_documentBrand]: true;
424
+ };
414
425
  /**
415
- * Fluent builder for constructing DOCX documents.
426
+ * Namespace of free functions for building DOCX documents.
427
+ *
428
+ * Replaces the former `DocumentBuilder` class with tree-shakeable free functions.
429
+ * Each function operates on an opaque `DocumentHandle`.
416
430
  *
417
431
  * @example
418
432
  * ```ts
419
- * const doc = new DocumentBuilder()
420
- * .addHeading("Hello World", 1)
421
- * .addParagraph("This is a paragraph.")
422
- * .addTable([["Name", "Age"], ["Alice", "30"]])
423
- * .build();
424
- *
425
- * const bytes = await doc.toBuffer();
433
+ * const doc = Document.create();
434
+ * Document.addHeading(doc, "Hello World", 1);
435
+ * Document.addParagraph(doc, "This is a paragraph.");
436
+ * Document.addTable(doc, [["Name", "Age"], ["Alice", "30"]]);
437
+ * const bytes = await Document.toBuffer(doc);
426
438
  * ```
427
439
  */
428
- export declare class DocumentBuilder {
429
- private _body;
430
- private _sectionProperties?;
431
- private _styles;
432
- private _docDefaults?;
433
- private _abstractNumberings;
434
- private _numberingInstances;
435
- private _headers;
436
- private _footers;
437
- private _footnotes;
438
- private _endnotes;
439
- private _images;
440
- private _fonts;
441
- private _settings?;
442
- private _coreProperties?;
443
- private _appProperties?;
444
- private _comments;
445
- private _background?;
446
- private _customProperties;
447
- private _watermark?;
448
- private _nextImageId;
449
- private _nextFootnoteId;
450
- private _nextEndnoteId;
451
- private _nextBookmarkId;
452
- private _nextAbstractNumId;
453
- private _nextNumId;
454
- private _nextDrawingId;
455
- private _nextCommentId;
440
+ export declare const Document: {
441
+ /** Create a new document handle. */
442
+ create(): DocumentHandle;
456
443
  /** Add raw body content. */
457
- addContent(content: BodyContent): this;
444
+ addContent(doc: DocumentHandle, content: BodyContent): void;
458
445
  /** Add a paragraph with runs. */
459
- addParagraphElement(para: Paragraph): this;
446
+ addParagraphElement(doc: DocumentHandle, para: Paragraph): void;
460
447
  /** Add a simple text paragraph. */
461
- addParagraph(content: string, properties?: ParagraphProperties & {
448
+ addParagraph(doc: DocumentHandle, content: string, properties?: ParagraphProperties & {
462
449
  run?: RunProperties;
463
- }): this;
450
+ }): void;
464
451
  /** Add a heading. */
465
- addHeading(content: string, level?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9): this;
452
+ addHeading(doc: DocumentHandle, content: string, level?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9): void;
466
453
  /** Add a page break. */
467
- addPageBreak(): this;
454
+ addPageBreak(doc: DocumentHandle): void;
468
455
  /** Add a table from a 2D array. */
469
- addTable(data: string[][], options?: {
456
+ addTable(doc: DocumentHandle, data: string[][], options?: {
470
457
  headerRow?: boolean;
471
458
  borders?: boolean;
472
459
  width?: TableWidth;
473
460
  columnWidths?: Twips[];
474
- }): this;
461
+ }): void;
475
462
  /** Add a table element. */
476
- addTableElement(tbl: Table): this;
463
+ addTableElement(doc: DocumentHandle, tbl: Table): void;
477
464
  /** Add an inline image. Returns the image relationship ID and drawing ID. */
478
- addImage(data: Uint8Array, mediaType: ImageMediaType, width: Emu, height: Emu, options?: {
465
+ addImage(doc: DocumentHandle, data: Uint8Array, mediaType: ImageMediaType, width: Emu, height: Emu, options?: {
479
466
  altText?: string;
480
467
  name?: string;
481
468
  }): {
@@ -483,7 +470,7 @@ export declare class DocumentBuilder {
483
470
  drawingId: number;
484
471
  };
485
472
  /** Add a floating image. Returns the image relationship ID. */
486
- addFloatingImage(data: Uint8Array, mediaType: ImageMediaType, width: Emu, height: Emu, options?: {
473
+ addFloatingImage(doc: DocumentHandle, data: Uint8Array, mediaType: ImageMediaType, width: Emu, height: Emu, options?: {
487
474
  altText?: string;
488
475
  name?: string;
489
476
  horizontalPosition?: FloatingImage["horizontalPosition"];
@@ -502,76 +489,63 @@ export declare class DocumentBuilder {
502
489
  flipVertical?: boolean;
503
490
  }): string;
504
491
  /** Add a custom font definition. */
505
- addFont(font: FontDef): this;
492
+ addFont(doc: DocumentHandle, font: FontDef): void;
506
493
  /** Set a text watermark on the document. */
507
- setWatermark(watermark: Watermark): this;
494
+ setWatermark(doc: DocumentHandle, watermark: Watermark): void;
508
495
  /** Add a footnote. Returns the footnote ID. */
509
- addFootnote(content: string | Paragraph[]): number;
496
+ addFootnote(doc: DocumentHandle, content: string | Paragraph[]): number;
510
497
  /** Add an endnote. Returns the endnote ID. */
511
- addEndnote(content: string | Paragraph[]): number;
498
+ addEndnote(doc: DocumentHandle, content: string | Paragraph[]): number;
512
499
  /** Add a comment. Returns the comment ID. */
513
- addComment(author: string, content: string | Paragraph[], options?: {
500
+ addComment(doc: DocumentHandle, author: string, content: string | Paragraph[], options?: {
514
501
  date?: string;
515
502
  initials?: string;
516
503
  }): number;
517
504
  /** Add a Table of Contents. */
518
- addTableOfContents(options?: Partial<Omit<TableOfContents, "type">>): this;
505
+ addTableOfContents(doc: DocumentHandle, options?: Partial<Omit<TableOfContents, "type">>): void;
519
506
  /** Add a math equation block. */
520
- addMath(content: MathContent[]): this;
507
+ addMath(doc: DocumentHandle, content: MathContent[]): void;
521
508
  /** Add a text box. */
522
- addTextBox(content: string | Paragraph[], options?: {
509
+ addTextBox(doc: DocumentHandle, content: string | Paragraph[], options?: {
523
510
  width?: Twips;
524
511
  height?: Twips;
525
512
  stroke?: boolean;
526
513
  fill?: boolean;
527
- }): this;
514
+ }): void;
528
515
  /** Add a bullet list. */
529
- addBulletList(items: string[], level?: number): this;
516
+ addBulletList(doc: DocumentHandle, items: string[], level?: number): void;
530
517
  /** Add a numbered list. */
531
- addNumberedList(items: string[], level?: number): this;
518
+ addNumberedList(doc: DocumentHandle, items: string[], level?: number): void;
532
519
  /** Set section properties (page size, margins, etc.). */
533
- setSectionProperties(props: SectionProperties): this;
520
+ setSectionProperties(doc: DocumentHandle, props: SectionProperties): void;
534
521
  /** Set document defaults. */
535
- setDocDefaults(defaults: DocDefaults): this;
522
+ setDocDefaults(doc: DocumentHandle, defaults: DocDefaults): void;
536
523
  /** Add a style definition. */
537
- addStyle(style: StyleDef): this;
524
+ addStyle(doc: DocumentHandle, style: StyleDef): void;
538
525
  /** Set default styles (Normal, Heading1-6, Hyperlink, etc.). */
539
- useDefaultStyles(): this;
526
+ useDefaultStyles(doc: DocumentHandle): void;
540
527
  /** Set a header for the given type. */
541
- setHeader(type: string, content: HeaderFooterContent): this;
528
+ setHeader(doc: DocumentHandle, type: string, content: HeaderFooterContent): void;
542
529
  /** Set a footer for the given type. */
543
- setFooter(type: string, content: HeaderFooterContent): this;
530
+ setFooter(doc: DocumentHandle, type: string, content: HeaderFooterContent): void;
544
531
  /** Set document settings. */
545
- setSettings(settings: DocumentSettings): this;
532
+ setSettings(doc: DocumentHandle, settings: DocumentSettings): void;
546
533
  /** Set core properties (metadata). */
547
- setCoreProperties(props: CoreProperties): this;
534
+ setCoreProperties(doc: DocumentHandle, props: CoreProperties): void;
548
535
  /** Set application properties. */
549
- setAppProperties(props: AppProperties): this;
536
+ setAppProperties(doc: DocumentHandle, props: AppProperties): void;
550
537
  /** Set document background. */
551
- setBackground(background: DocumentBackground): this;
538
+ setBackground(doc: DocumentHandle, background: DocumentBackground): void;
552
539
  /** Add a custom document property. */
553
- addCustomProperty(name: string, value: CustomPropertyValue): this;
540
+ addCustomProperty(doc: DocumentHandle, name: string, value: CustomPropertyValue): void;
554
541
  /** Add a section break with properties. */
555
- addSectionBreak(props: SectionProperties): this;
542
+ addSectionBreak(doc: DocumentHandle, props: SectionProperties): void;
556
543
  /** Get next available bookmark ID. */
557
- nextBookmarkId(): number;
558
- /** Build the DocxDocument model. */
559
- build(): DocxDocument;
560
- /** Build and package to DOCX bytes. */
561
- toBuffer(compressionLevel?: number): Promise<Uint8Array>;
562
- /** Build and package to base64 string. */
563
- toBase64(compressionLevel?: number): Promise<string>;
564
- }
565
- /**
566
- * Resolve a ColorSpec to an actual hex RGB color using the document theme.
567
- *
568
- * Applies theme color lookup + tint/shade transformations per OOXML spec.
569
- *
570
- * @param color - The color value (HexColor string or ColorSpec).
571
- * @param theme - The document theme (from `doc.theme`).
572
- * @returns Resolved hex color string (6 chars, no #), or undefined if unresolvable.
573
- */
574
- export declare function resolveThemeColor(color: HexColor | ColorSpec | undefined, theme?: DocumentTheme): HexColor | undefined;
544
+ nextBookmarkId(doc: DocumentHandle): number;
545
+ /** Build the DocxDocument model from the handle. */
546
+ build(doc: DocumentHandle): DocxDocument;
547
+ };
548
+ export { resolveThemeColor } from "./color-utils.js";
575
549
  /** Result of a text search in a document. */
576
550
  export interface SearchResult {
577
551
  /** Paragraph index in body. */
@@ -680,49 +654,4 @@ export declare function mailMerge(doc: DocxDocument, data: Record<string, string
680
654
  /** If true, remove fields not found in data. Default: false (leave unchanged). */
681
655
  removeUnmatched?: boolean;
682
656
  }): number;
683
- /** Type of content to patch into a placeholder. */
684
- export type PatchContent = {
685
- readonly type: "text";
686
- readonly text: string;
687
- } | {
688
- readonly type: "paragraph";
689
- readonly children: readonly Paragraph[];
690
- } | {
691
- readonly type: "table";
692
- readonly table: Table;
693
- } | {
694
- readonly type: "image";
695
- readonly image: ImageDef;
696
- readonly width: number;
697
- readonly height: number;
698
- };
699
- /** A single patch operation mapping a placeholder to replacement content. */
700
- export interface PatchOperation {
701
- /** Placeholder string to find (e.g. "{{name}}"). */
702
- readonly placeholder: string;
703
- /** Content to replace the placeholder with. */
704
- readonly content: PatchContent;
705
- }
706
- /** Options for patchDocument. */
707
- export interface PatchOptions {
708
- /** Compression level (0-9). Default: 6. */
709
- readonly compressionLevel?: number;
710
- }
711
- /**
712
- * Read an existing DOCX file, replace placeholders with content, and produce a new DOCX.
713
- *
714
- * Placeholders are strings like `{{name}}` embedded in the document text.
715
- * They may span across multiple runs — the patcher handles cross-run matching.
716
- *
717
- * Supported patch content types:
718
- * - `text` — simple text replacement (preserves formatting of the first run)
719
- * - `paragraph` — replaces the entire paragraph containing the placeholder
720
- * - `table` — replaces the entire paragraph with a table
721
- * - `image` — replaces the placeholder with an inline image
722
- *
723
- * @param buffer - The source DOCX file as a Uint8Array.
724
- * @param patches - Array of patch operations to apply.
725
- * @param options - Optional compression settings.
726
- * @returns New DOCX file as a Uint8Array.
727
- */
728
- export declare function patchDocument(buffer: Uint8Array, patches: readonly PatchOperation[], options?: PatchOptions): Promise<Uint8Array>;
657
+ export type { PatchContent, PatchOperation, PatchOptions } from "./document-io.js";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * DOCX Module - HTML Renderer (Subpath Export)
3
+ *
4
+ * Import separately to avoid pulling html-renderer into the bundle
5
+ * when only core document building is needed.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { renderToHtml } from "excelts/word/html";
10
+ * ```
11
+ */
12
+ export { renderToHtml } from "./html-renderer.js";
13
+ export type { HtmlRenderOptions, HtmlRenderResult } from "./html-renderer.js";
@@ -6,14 +6,11 @@
6
6
  export type { HalfPoint, Twips, Emu, EighthPoint, HexColor, ShadingType, BorderStyle, PageOrientation, PageSize, PageMargins, ColumnDef, SectionColumns, SectionBreakType, PageNumberFormat, HeaderFooterType, HeaderFooterRef, PageVerticalAlign, DocumentGridType, PageTextDirection, Border, ArtBorderType, PageBorders, SectionProperties, UnderlineStyle, VerticalAlign, HighlightColor, FontSpec, Shading, UnderlineSpec, TextEffect, EmphasisMarkType, ColorSpec, RunProperties, RunContent, TextContent, BreakContent, TabContent, PositionalTabContent, RubyContent, RubyAlign, RubyProperties, SymbolContent, FootnoteRefContent, EndnoteRefContent, FieldContent, InlineImageContent, CarriageReturnContent, NoBreakHyphenContent, SoftHyphenContent, LastRenderedPageBreakContent, AnnotationReferenceContent, PageNumberType, DateFieldContent, Run, RevisionInfo, InsertedRun, DeletedRun, MovedFromRun, MovedToRun, MoveRangeMarker, CustomXmlTrackingMarker, ParagraphPropertyChange, RunPropertyChange, SectionPropertyChange, TableRowRevision, CommentDef, CommentRangeStart, CommentRangeEnd, CommentReference, Alignment, LineSpacingRule, LineSpacing, Indentation, TabStopType, TabStopLeader, TabStop, PositionalTabAlignment, PositionalTabRelativeTo, PositionalTabLeader, ParagraphBorders, NumberingRef, FrameAnchorType, DropCapType, ParagraphFrame, ParagraphProperties, Paragraph, Hyperlink, BookmarkStart, BookmarkEnd, ParagraphChild, TableWidth, TableBorders, TableCellMargins, TableLayout, TableLook, TableFloat, TableProperties, RowHeightRule, TableRowProperties, VerticalCellAlign, TextDirection, VerticalMerge, TableCellProperties, TableCell, TableRow, Table, HorizontalPositionRelative, VerticalPositionRelative, WrapStyle, WrapTextSide, WrapMargins, FloatingImage, DrawingShape, PresetShapeType, Chart, ChartType, ChartSeries, ChartLegendPosition, ChartAxis, ChartContent, AltChunk, WebSettings, PersonInfo, NoteType, TablePropertyChange, TableRowPropertyChange, TableCellPropertyChange, CellMergeRevision, OpaquePart, OpaqueRelationship, OpaqueDrawing, TableOfContents, MathRun, MathFraction, MathSuperScript, MathSubScript, MathSubSuperScript, MathPreSubSuperScript, MathPhantom, MathGroupChar, MathBorderBox, MathRadical, MathDelimiter, MathNary, MathFunction, MathLimit, MathMatrix, MathAccent, MathBar, MathBox, MathEquationArray, MathContent, MathBlock, TextBox, CheckBox, SdtListItem, SdtDateProperties, SdtProperties, SdtDataBinding, SdtCheckboxProperties, SdtRepeatingSectionProperties, StructuredDocumentTag, CustomXmlPart, BodyContent, StyleType, TableStyleConditionType, TableStyleConditionalFormat, StyleDef, DocDefaults, NumberFormat, LevelJustification, LevelSuffix, NumberingLevel, MultiLevelType, AbstractNumbering, LevelOverride, NumberingInstance, NumPicBullet, HeaderFooterContent, HeaderDef, FooterDef, FootnoteDef, EndnoteDef, ImageMediaType, ImageDef, FontFamily, FontPitch, FontDef, EmbeddedFont, ProtectionType, HyphenationSettings, DocumentSettings, CompatSetting, CompatFlag, DocumentBackground, DocumentTheme, ThemeColorScheme, ThemeFontScheme, ThemeFont, ThemeFormatScheme, ThemeColorName, CustomPropertyValue, CustomProperty, CoreProperties, AppProperties, DocxDocument, DocxOptions } from "./types.js";
7
7
  export { DocxError, DocxParseError, DocxWriteError, DocxMissingPartError, DocxInvalidStructureError, DocxUnsupportedFeatureError, isDocxError } from "./errors.js";
8
8
  export { inchesToTwips, twipsToInches, cmToTwips, twipsToCm, ptToTwips, twipsToPt, mmToTwips, inchesToEmu, emuToInches, cmToEmu, emuToCm, ptToEmu, pxToEmu, emuToPx, ptToHalfPoint, halfPointToPt, ptToEighthPoint, eighthPointToPt, lineMultiplierToSpacing, spacingToLineMultiplier, percentToTablePct, tablePctToPercent } from "./units.js";
9
- export { DocumentBuilder, text, bold, italic, pageBreak, lineBreak, columnBreak, tab, positionalTab, ruby, carriageReturn, noBreakHyphen, softHyphen, field, pageNumberField, totalPagesField, sectionPagesField, sectionField, dateField, sequenceField, timeField, authorField, titleField, subjectField, keywordsField, fileNameField, fileSizeField, styleRefField, refField, pageRefField, noteRefField, hyperlinkField, quoteField, tocField, tcField, indexEntryField, indexField, ifField, includeTextField, includePictureField, formTextField, formCheckboxField, formDropdownField, paragraph, textParagraph, heading, hyperlink, bookmarkStart, bookmarkEnd, commentRangeStart, commentRangeEnd, commentReference, insertedRun, deletedRun, movedFromRun, movedToRun, moveFromRangeStart, moveFromRangeEnd, moveToRangeStart, moveToRangeEnd, checkBox, mathBlock, mathRun, mathFraction, mathSqrt, mathRoot, mathSum, mathIntegral, mathProduct, mathSuperScript, mathSubScript, mathSubSuperScript, mathPreSubSuperScript, mathPhantom, mathGroupChar, mathBorderBox, mathDelimiter, mathNary, mathFunction, mathLimit, mathMatrix, mathAccent, mathBar, mathBox, mathEquationArray, symbol, floatingImage, drawingShape, chart, structuredDocumentTag, border, gridBorders, cell, row, table, simpleTable, searchText, replaceText, resolveThemeColor, patchDocument, mailMerge, paragraphCount, countWords, getHeadings, findBookmark, findComment, listImages, listTables, listHyperlinks, tableCount, extractText } from "./document.js";
10
- export type { SearchResult, PatchContent, PatchOperation, PatchOptions, DocumentHeading } from "./document.js";
9
+ export { Document, text, bold, italic, pageBreak, lineBreak, columnBreak, tab, positionalTab, ruby, carriageReturn, noBreakHyphen, softHyphen, field, pageNumberField, totalPagesField, sectionPagesField, sectionField, dateField, sequenceField, timeField, authorField, titleField, subjectField, keywordsField, fileNameField, fileSizeField, styleRefField, refField, pageRefField, noteRefField, hyperlinkField, quoteField, tocField, tcField, indexEntryField, indexField, ifField, includeTextField, includePictureField, formTextField, formCheckboxField, formDropdownField, paragraph, textParagraph, heading, hyperlink, bookmarkStart, bookmarkEnd, commentRangeStart, commentRangeEnd, commentReference, insertedRun, deletedRun, movedFromRun, movedToRun, moveFromRangeStart, moveFromRangeEnd, moveToRangeStart, moveToRangeEnd, checkBox, mathBlock, mathRun, mathFraction, mathSqrt, mathRoot, mathSum, mathIntegral, mathProduct, mathSuperScript, mathSubScript, mathSubSuperScript, mathPreSubSuperScript, mathPhantom, mathGroupChar, mathBorderBox, mathDelimiter, mathNary, mathFunction, mathLimit, mathMatrix, mathAccent, mathBar, mathBox, mathEquationArray, symbol, floatingImage, drawingShape, chart, structuredDocumentTag, border, gridBorders, cell, row, table, simpleTable, searchText, replaceText, resolveThemeColor, mailMerge, paragraphCount, countWords, getHeadings, findBookmark, findComment, listImages, listTables, listHyperlinks, tableCount, extractText } from "./document.js";
10
+ export type { DocumentHandle, SearchResult, DocumentHeading } from "./document.js";
11
+ export type { PatchContent, PatchOperation, PatchOptions } from "./document-io.js";
11
12
  export { packageDocx } from "./docx-packager.js";
12
13
  export { readDocx } from "./docx-reader.js";
13
- export { deobfuscateFont, obfuscateFont, generateFontKey } from "./font-obfuscation.js";
14
- export { isEncryptedDocx, verifyPassword, decryptPackage, parseEncryptionInfoXml, deriveEncryptionKey, AGILE_BLOCK_KEYS } from "./encryption.js";
15
- export type { AgileEncryptionInfo } from "./encryption.js";
16
- export { hasDigitalSignatures, parseSignatureXml, extractSignatures, isWellFormedSignature } from "./digital-signatures.js";
17
- export type { DigitalSignatureInfo } from "./digital-signatures.js";
18
- export { renderToHtml } from "./html-renderer.js";
19
- export type { HtmlRenderOptions, HtmlRenderResult } from "./html-renderer.js";
14
+ export { toBuffer, toBase64, patchDocument } from "./document-io.js";
15
+ export { Field, Drawing, TrackChanges, Sdt, Query } from "./namespaces.js";
16
+ export { Math as MathML } from "./namespaces.js";
@@ -0,0 +1,159 @@
1
+ /**
2
+ * DOCX Module — Sub-namespace objects
3
+ *
4
+ * Groups flat builder helpers into logical namespaces for better
5
+ * IDE discoverability. These are re-exports aggregated into objects;
6
+ * since they reference the same underlying functions, tree-shaking
7
+ * still applies at the individual function level for consumers who
8
+ * import the flat named exports instead.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { Run, Paragraph, Table, Math, Field } from "excelts/word";
13
+ *
14
+ * const doc = Document.create();
15
+ * Document.addParagraphElement(doc, Paragraph.create([
16
+ * Run.bold("Hello"),
17
+ * Run.text(" world")
18
+ * ]));
19
+ * ```
20
+ */
21
+ import { text, bold, italic, pageBreak, lineBreak, columnBreak, tab, positionalTab, ruby, carriageReturn, noBreakHyphen, softHyphen, symbol, field, pageNumberField, totalPagesField, sectionPagesField, sectionField, dateField, sequenceField, timeField, authorField, titleField, subjectField, keywordsField, fileNameField, fileSizeField, styleRefField, refField, pageRefField, noteRefField, hyperlinkField, quoteField, tocField, tcField, indexEntryField, indexField, ifField, includeTextField, includePictureField, formTextField, formCheckboxField, formDropdownField, paragraph, textParagraph, heading, hyperlink, bookmarkStart, bookmarkEnd, commentRangeStart, commentRangeEnd, commentReference, insertedRun, deletedRun, movedFromRun, movedToRun, moveFromRangeStart, moveFromRangeEnd, moveToRangeStart, moveToRangeEnd, checkBox, mathBlock, mathRun, mathFraction, mathSqrt, mathRoot, mathSum, mathIntegral, mathProduct, mathSuperScript, mathSubScript, mathSubSuperScript, mathPreSubSuperScript, mathPhantom, mathGroupChar, mathBorderBox, mathDelimiter, mathNary, mathFunction, mathLimit, mathMatrix, mathAccent, mathBar, mathBox, mathEquationArray, floatingImage, drawingShape, chart, structuredDocumentTag, border, gridBorders, cell, row, table, simpleTable, searchText, replaceText, mailMerge, paragraphCount, countWords, getHeadings, findBookmark, findComment, listImages, listTables, listHyperlinks, tableCount, extractText } from "./document.js";
22
+ /** Namespace for creating text runs (inline content). */
23
+ export declare const Run: {
24
+ text: typeof text;
25
+ bold: typeof bold;
26
+ italic: typeof italic;
27
+ pageBreak: typeof pageBreak;
28
+ lineBreak: typeof lineBreak;
29
+ columnBreak: typeof columnBreak;
30
+ tab: typeof tab;
31
+ positionalTab: typeof positionalTab;
32
+ ruby: typeof ruby;
33
+ carriageReturn: typeof carriageReturn;
34
+ noBreakHyphen: typeof noBreakHyphen;
35
+ softHyphen: typeof softHyphen;
36
+ symbol: typeof symbol;
37
+ };
38
+ /** Namespace for creating field codes. */
39
+ export declare const Field: {
40
+ create: typeof field;
41
+ pageNumber: typeof pageNumberField;
42
+ totalPages: typeof totalPagesField;
43
+ sectionPages: typeof sectionPagesField;
44
+ section: typeof sectionField;
45
+ date: typeof dateField;
46
+ sequence: typeof sequenceField;
47
+ time: typeof timeField;
48
+ author: typeof authorField;
49
+ title: typeof titleField;
50
+ subject: typeof subjectField;
51
+ keywords: typeof keywordsField;
52
+ fileName: typeof fileNameField;
53
+ fileSize: typeof fileSizeField;
54
+ styleRef: typeof styleRefField;
55
+ ref: typeof refField;
56
+ pageRef: typeof pageRefField;
57
+ noteRef: typeof noteRefField;
58
+ hyperlink: typeof hyperlinkField;
59
+ quote: typeof quoteField;
60
+ toc: typeof tocField;
61
+ tc: typeof tcField;
62
+ indexEntry: typeof indexEntryField;
63
+ index: typeof indexField;
64
+ condition: typeof ifField;
65
+ includeText: typeof includeTextField;
66
+ includePicture: typeof includePictureField;
67
+ formText: typeof formTextField;
68
+ formCheckbox: typeof formCheckboxField;
69
+ formDropdown: typeof formDropdownField;
70
+ };
71
+ /** Namespace for creating paragraphs. */
72
+ export declare const Paragraph: {
73
+ create: typeof paragraph;
74
+ text: typeof textParagraph;
75
+ heading: typeof heading;
76
+ hyperlink: typeof hyperlink;
77
+ bookmarkStart: typeof bookmarkStart;
78
+ bookmarkEnd: typeof bookmarkEnd;
79
+ };
80
+ /** Namespace for comment-related markers. */
81
+ export declare const Comment: {
82
+ rangeStart: typeof commentRangeStart;
83
+ rangeEnd: typeof commentRangeEnd;
84
+ reference: typeof commentReference;
85
+ };
86
+ /** Namespace for track-changes (revision) markers. */
87
+ export declare const TrackChanges: {
88
+ insertedRun: typeof insertedRun;
89
+ deletedRun: typeof deletedRun;
90
+ movedFromRun: typeof movedFromRun;
91
+ movedToRun: typeof movedToRun;
92
+ moveFromRangeStart: typeof moveFromRangeStart;
93
+ moveFromRangeEnd: typeof moveFromRangeEnd;
94
+ moveToRangeStart: typeof moveToRangeStart;
95
+ moveToRangeEnd: typeof moveToRangeEnd;
96
+ };
97
+ /** Namespace for OMML (Office Math) content. */
98
+ export declare const Math: {
99
+ block: typeof mathBlock;
100
+ run: typeof mathRun;
101
+ fraction: typeof mathFraction;
102
+ sqrt: typeof mathSqrt;
103
+ root: typeof mathRoot;
104
+ sum: typeof mathSum;
105
+ integral: typeof mathIntegral;
106
+ product: typeof mathProduct;
107
+ superScript: typeof mathSuperScript;
108
+ subScript: typeof mathSubScript;
109
+ subSuperScript: typeof mathSubSuperScript;
110
+ preSubSuperScript: typeof mathPreSubSuperScript;
111
+ phantom: typeof mathPhantom;
112
+ groupChar: typeof mathGroupChar;
113
+ borderBox: typeof mathBorderBox;
114
+ delimiter: typeof mathDelimiter;
115
+ nary: typeof mathNary;
116
+ func: typeof mathFunction;
117
+ limit: typeof mathLimit;
118
+ matrix: typeof mathMatrix;
119
+ accent: typeof mathAccent;
120
+ bar: typeof mathBar;
121
+ box: typeof mathBox;
122
+ equationArray: typeof mathEquationArray;
123
+ };
124
+ /** Namespace for creating tables. */
125
+ export declare const Table: {
126
+ create: typeof table;
127
+ simple: typeof simpleTable;
128
+ row: typeof row;
129
+ cell: typeof cell;
130
+ border: typeof border;
131
+ gridBorders: typeof gridBorders;
132
+ };
133
+ /** Namespace for drawings (images, shapes, charts). */
134
+ export declare const Drawing: {
135
+ floatingImage: typeof floatingImage;
136
+ shape: typeof drawingShape;
137
+ chart: typeof chart;
138
+ };
139
+ /** Namespace for structured document tags (content controls). */
140
+ export declare const Sdt: {
141
+ create: typeof structuredDocumentTag;
142
+ checkBox: typeof checkBox;
143
+ };
144
+ /** Namespace for querying/searching document content. */
145
+ export declare const Query: {
146
+ search: typeof searchText;
147
+ replace: typeof replaceText;
148
+ mailMerge: typeof mailMerge;
149
+ paragraphCount: typeof paragraphCount;
150
+ countWords: typeof countWords;
151
+ getHeadings: typeof getHeadings;
152
+ findBookmark: typeof findBookmark;
153
+ findComment: typeof findComment;
154
+ listImages: typeof listImages;
155
+ listTables: typeof listTables;
156
+ listHyperlinks: typeof listHyperlinks;
157
+ tableCount: typeof tableCount;
158
+ extractText: typeof extractText;
159
+ };
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Manages OPC relationships for the DOCX package.
5
5
  * Generates .rels files for package-level and part-level relationships.
6
+ * Uses a plain data record + free functions for tree-shakeability.
6
7
  */
7
8
  import type { XmlSink } from "../xml/types.js";
8
9
  /** A single OPC relationship. */
@@ -12,20 +13,18 @@ export interface Relationship {
12
13
  readonly target: string;
13
14
  readonly targetMode?: "External";
14
15
  }
15
- /**
16
- * Manages relationships and generates .rels XML.
17
- */
18
- export declare class RelationshipManager {
19
- private readonly _rels;
20
- private _nextId;
21
- /** Add a relationship and return its assigned rId. */
22
- add(type: string, target: string, targetMode?: "External"): string;
23
- /** Add a relationship with a specific ID. */
24
- addWithId(id: string, type: string, target: string, targetMode?: "External"): void;
25
- /** Get all relationships. */
26
- get relationships(): readonly Relationship[];
27
- /** Get the number of relationships. */
28
- get count(): number;
29
- /** Render the relationships XML to a sink. */
30
- render(xml: XmlSink): void;
16
+ /** Internal state for relationships (plain record, not a class). */
17
+ export interface RelationshipsState {
18
+ readonly rels: Relationship[];
19
+ nextId: number;
31
20
  }
21
+ /** Create a new empty RelationshipsState. */
22
+ export declare function createRelationships(): RelationshipsState;
23
+ /** Add a relationship and return its assigned rId. */
24
+ export declare function addRelationship(state: RelationshipsState, type: string, target: string, targetMode?: "External"): string;
25
+ /** Add a relationship with a specific ID. */
26
+ export declare function addRelationshipWithId(state: RelationshipsState, id: string, type: string, target: string, targetMode?: "External"): void;
27
+ /** Get the number of relationships. */
28
+ export declare function getRelationshipCount(state: RelationshipsState): number;
29
+ /** Render the relationships XML to a sink. */
30
+ export declare function renderRelationships(state: RelationshipsState, xml: XmlSink): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cj-tech-master/excelts",
3
- "version": "9.5.0",
3
+ "version": "9.5.1",
4
4
  "description": "Zero-dependency TypeScript toolkit — Excel (XLSX), PDF, CSV, Markdown, XML, ZIP/TAR, and streaming.",
5
5
  "keywords": [
6
6
  "archive",