docx-plus 0.0.8 → 0.0.10

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.
@@ -7442,23 +7442,97 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
7442
7442
  }
7443
7443
  };
7444
7444
  //#endregion
7445
- //#region src/file/paragraph/run/image-run.ts
7446
- const createImageData = (data, transformation, key, srcRect) => ({
7447
- data,
7448
- fileName: key,
7449
- srcRect,
7450
- transformation: {
7445
+ //#region src/file/media/media.ts
7446
+ /**
7447
+ * Converts user-facing transformation options (pixels) to internal
7448
+ * transformation data (pixels + EMUs).
7449
+ *
7450
+ * @param options - User-facing transformation in pixels
7451
+ * @returns Internal transformation data with both pixel and EMU values
7452
+ */
7453
+ const createTransformation = (options) => {
7454
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7455
+ return {
7451
7456
  emus: {
7452
- x: Math.round(transformation.width * 9525),
7453
- y: Math.round(transformation.height * 9525)
7457
+ x: Math.round(options.width * 9525),
7458
+ y: Math.round(options.height * 9525)
7459
+ },
7460
+ flip: options.flip,
7461
+ offset: {
7462
+ emus: {
7463
+ x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7464
+ y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7465
+ },
7466
+ pixels: {
7467
+ x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7468
+ y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7469
+ }
7454
7470
  },
7455
- flip: transformation.flip,
7456
7471
  pixels: {
7457
- x: Math.round(transformation.width),
7458
- y: Math.round(transformation.height)
7472
+ x: Math.round(options.width),
7473
+ y: Math.round(options.height)
7459
7474
  },
7460
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7475
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7476
+ };
7477
+ };
7478
+ /**
7479
+ * Manages embedded media (images) in a document.
7480
+ *
7481
+ * Media stores all images referenced in the document and provides
7482
+ * access to their data for packaging into the DOCX file. Each image
7483
+ * is stored with a unique key for retrieval.
7484
+ *
7485
+ * @example
7486
+ * ```typescript
7487
+ * const media = new Media();
7488
+ * media.addImage("image1", {
7489
+ * type: "png",
7490
+ * fileName: "image1.png",
7491
+ * transformation: {
7492
+ * pixels: { x: 200, y: 100 },
7493
+ * emus: { x: 1828800, y: 914400 }
7494
+ * },
7495
+ * data: imageBuffer
7496
+ * });
7497
+ * const allImages = media.Array;
7498
+ * ```
7499
+ */
7500
+ var Media = class {
7501
+ constructor() {
7502
+ _defineProperty(this, "map", void 0);
7503
+ this.map = /* @__PURE__ */ new Map();
7461
7504
  }
7505
+ /**
7506
+ * Adds an image to the media collection.
7507
+ *
7508
+ * @param key - Unique identifier for this image
7509
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7510
+ */
7511
+ addImage(key, mediaData) {
7512
+ this.map.set(key, mediaData);
7513
+ }
7514
+ /**
7515
+ * Gets all images as an array.
7516
+ *
7517
+ * @returns Read-only array of all media data in the collection
7518
+ */
7519
+ get Array() {
7520
+ return [...this.map.values()];
7521
+ }
7522
+ };
7523
+ //#endregion
7524
+ //#region src/file/media/data.ts
7525
+ /**
7526
+ * @ignore
7527
+ */
7528
+ const WORKAROUND2 = "";
7529
+ //#endregion
7530
+ //#region src/file/paragraph/run/image-run.ts
7531
+ const createImageData = (data, transformation, key, srcRect) => ({
7532
+ data,
7533
+ fileName: key,
7534
+ srcRect,
7535
+ transformation: createTransformation(transformation)
7462
7536
  });
7463
7537
  /**
7464
7538
  * Represents an image in a WordprocessingML document.
@@ -7517,31 +7591,6 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
7517
7591
  };
7518
7592
  //#endregion
7519
7593
  //#region src/file/paragraph/run/wps-shape-run.ts
7520
- const createTransformation = (options) => {
7521
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7522
- return {
7523
- emus: {
7524
- x: Math.round(options.width * 9525),
7525
- y: Math.round(options.height * 9525)
7526
- },
7527
- flip: options.flip,
7528
- offset: {
7529
- emus: {
7530
- x: Math.round(((_options$offset$left = (_options$offset = options.offset) === null || _options$offset === void 0 ? void 0 : _options$offset.left) !== null && _options$offset$left !== void 0 ? _options$offset$left : 0) * 9525),
7531
- y: Math.round(((_options$offset$top = (_options$offset2 = options.offset) === null || _options$offset2 === void 0 ? void 0 : _options$offset2.top) !== null && _options$offset$top !== void 0 ? _options$offset$top : 0) * 9525)
7532
- },
7533
- pixels: {
7534
- x: Math.round((_options$offset$left2 = (_options$offset3 = options.offset) === null || _options$offset3 === void 0 ? void 0 : _options$offset3.left) !== null && _options$offset$left2 !== void 0 ? _options$offset$left2 : 0),
7535
- y: Math.round((_options$offset$top2 = (_options$offset4 = options.offset) === null || _options$offset4 === void 0 ? void 0 : _options$offset4.top) !== null && _options$offset$top2 !== void 0 ? _options$offset$top2 : 0)
7536
- }
7537
- },
7538
- pixels: {
7539
- x: Math.round(options.width),
7540
- y: Math.round(options.height)
7541
- },
7542
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7543
- };
7544
- };
7545
7594
  /**
7546
7595
  * @publicApi
7547
7596
  */
@@ -16856,59 +16905,6 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
16856
16905
  }
16857
16906
  };
16858
16907
  //#endregion
16859
- //#region src/file/media/media.ts
16860
- /**
16861
- * Manages embedded media (images) in a document.
16862
- *
16863
- * Media stores all images referenced in the document and provides
16864
- * access to their data for packaging into the DOCX file. Each image
16865
- * is stored with a unique key for retrieval.
16866
- *
16867
- * @example
16868
- * ```typescript
16869
- * const media = new Media();
16870
- * media.addImage("image1", {
16871
- * type: "png",
16872
- * fileName: "image1.png",
16873
- * transformation: {
16874
- * pixels: { x: 200, y: 100 },
16875
- * emus: { x: 1828800, y: 914400 }
16876
- * },
16877
- * data: imageBuffer
16878
- * });
16879
- * const allImages = media.Array;
16880
- * ```
16881
- */
16882
- var Media = class {
16883
- constructor() {
16884
- _defineProperty(this, "map", void 0);
16885
- this.map = /* @__PURE__ */ new Map();
16886
- }
16887
- /**
16888
- * Adds an image to the media collection.
16889
- *
16890
- * @param key - Unique identifier for this image
16891
- * @param mediaData - Complete image data including file name, transformation, and raw data
16892
- */
16893
- addImage(key, mediaData) {
16894
- this.map.set(key, mediaData);
16895
- }
16896
- /**
16897
- * Gets all images as an array.
16898
- *
16899
- * @returns Read-only array of all media data in the collection
16900
- */
16901
- get Array() {
16902
- return [...this.map.values()];
16903
- }
16904
- };
16905
- //#endregion
16906
- //#region src/file/media/data.ts
16907
- /**
16908
- * @ignore
16909
- */
16910
- const WORKAROUND2 = "";
16911
- //#endregion
16912
16908
  //#region src/file/numbering/level.ts
16913
16909
  /**
16914
16910
  * Numbering level definitions module for WordprocessingML documents.
@@ -23620,7 +23616,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23620
23616
  viewWrapper: file.Document
23621
23617
  }), {
23622
23618
  declaration: {
23623
- encoding: "utf8",
23619
+ encoding: "UTF-8",
23624
23620
  standalone: "yes"
23625
23621
  },
23626
23622
  indent: prettify
@@ -23635,7 +23631,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23635
23631
  }
23636
23632
  }), {
23637
23633
  declaration: {
23638
- encoding: "utf8",
23634
+ encoding: "UTF-8",
23639
23635
  standalone: "yes"
23640
23636
  },
23641
23637
  indent: prettify
@@ -23647,7 +23643,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23647
23643
  viewWrapper: file.FootNotes
23648
23644
  }), {
23649
23645
  declaration: {
23650
- encoding: "utf8",
23646
+ encoding: "UTF-8",
23651
23647
  standalone: "yes"
23652
23648
  },
23653
23649
  indent: prettify
@@ -23663,7 +23659,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23663
23659
  viewWrapper: file.Document
23664
23660
  }), {
23665
23661
  declaration: {
23666
- encoding: "utf8",
23662
+ encoding: "UTF-8",
23667
23663
  standalone: "yes"
23668
23664
  },
23669
23665
  indent: prettify
@@ -23690,7 +23686,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23690
23686
  View: file.Comments
23691
23687
  }
23692
23688
  }), {
23693
- declaration: { encoding: "utf8" },
23689
+ declaration: { encoding: "UTF-8" },
23694
23690
  indent: prettify
23695
23691
  });
23696
23692
  })(),
@@ -23702,7 +23698,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23702
23698
  stack: [],
23703
23699
  viewWrapper: file.Document
23704
23700
  }), {
23705
- declaration: { encoding: "utf8" },
23701
+ declaration: { encoding: "UTF-8" },
23706
23702
  indent: prettify
23707
23703
  }),
23708
23704
  path: "[Content_Types].xml"
@@ -23714,7 +23710,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23714
23710
  viewWrapper: file.Document
23715
23711
  }), {
23716
23712
  declaration: {
23717
- encoding: "utf8",
23713
+ encoding: "UTF-8",
23718
23714
  standalone: "yes"
23719
23715
  },
23720
23716
  indent: prettify
@@ -23734,7 +23730,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23734
23730
  stack: [],
23735
23731
  viewWrapper: file.Endnotes
23736
23732
  }), {
23737
- declaration: { encoding: "utf8" },
23733
+ declaration: { encoding: "UTF-8" },
23738
23734
  indent: prettify
23739
23735
  }),
23740
23736
  path: "word/endnotes.xml"
@@ -23745,7 +23741,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23745
23741
  stack: [],
23746
23742
  viewWrapper: file.Endnotes
23747
23743
  }), {
23748
- declaration: { encoding: "utf8" },
23744
+ declaration: { encoding: "UTF-8" },
23749
23745
  indent: prettify
23750
23746
  }),
23751
23747
  path: "word/_rels/endnotes.xml.rels"
@@ -23756,7 +23752,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23756
23752
  stack: [],
23757
23753
  viewWrapper: file.Document
23758
23754
  }), {
23759
- declaration: { encoding: "utf8" },
23755
+ declaration: { encoding: "UTF-8" },
23760
23756
  indent: prettify
23761
23757
  }),
23762
23758
  path: "_rels/.rels"
@@ -23768,7 +23764,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23768
23764
  viewWrapper: file.Document
23769
23765
  }), {
23770
23766
  declaration: {
23771
- encoding: "utf8",
23767
+ encoding: "UTF-8",
23772
23768
  standalone: "yes"
23773
23769
  },
23774
23770
  indent: prettify
@@ -23781,7 +23777,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23781
23777
  stack: [],
23782
23778
  viewWrapper: file.Document
23783
23779
  }), {
23784
- declaration: { encoding: "utf8" },
23780
+ declaration: { encoding: "UTF-8" },
23785
23781
  indent: prettify
23786
23782
  }),
23787
23783
  path: "word/_rels/fontTable.xml.rels"
@@ -23803,7 +23799,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23803
23799
  stack: [],
23804
23800
  viewWrapper: file.FootNotes
23805
23801
  }), {
23806
- declaration: { encoding: "utf8" },
23802
+ declaration: { encoding: "UTF-8" },
23807
23803
  indent: prettify
23808
23804
  });
23809
23805
  })(),
@@ -23815,7 +23811,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23815
23811
  stack: [],
23816
23812
  viewWrapper: footerWrapper
23817
23813
  }), {
23818
- declaration: { encoding: "utf8" },
23814
+ declaration: { encoding: "UTF-8" },
23819
23815
  indent: prettify
23820
23816
  });
23821
23817
  footerFormattedViews.set(index, xmlData);
@@ -23828,7 +23824,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23828
23824
  stack: [],
23829
23825
  viewWrapper: footerWrapper
23830
23826
  }), {
23831
- declaration: { encoding: "utf8" },
23827
+ declaration: { encoding: "UTF-8" },
23832
23828
  indent: prettify
23833
23829
  }),
23834
23830
  path: `word/_rels/footer${index + 1}.xml.rels`
@@ -23849,7 +23845,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23849
23845
  stack: [],
23850
23846
  viewWrapper: headerWrapper
23851
23847
  }), {
23852
- declaration: { encoding: "utf8" },
23848
+ declaration: { encoding: "UTF-8" },
23853
23849
  indent: prettify
23854
23850
  });
23855
23851
  headerFormattedViews.set(index, xmlData);
@@ -23862,7 +23858,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23862
23858
  stack: [],
23863
23859
  viewWrapper: headerWrapper
23864
23860
  }), {
23865
- declaration: { encoding: "utf8" },
23861
+ declaration: { encoding: "UTF-8" },
23866
23862
  indent: prettify
23867
23863
  }),
23868
23864
  path: `word/_rels/header${index + 1}.xml.rels`
@@ -23884,7 +23880,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23884
23880
  viewWrapper: file.Document
23885
23881
  }), {
23886
23882
  declaration: {
23887
- encoding: "utf8",
23883
+ encoding: "UTF-8",
23888
23884
  standalone: "yes"
23889
23885
  },
23890
23886
  indent: prettify
@@ -23898,7 +23894,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23898
23894
  viewWrapper: file.Document
23899
23895
  }), {
23900
23896
  declaration: {
23901
- encoding: "utf8",
23897
+ encoding: "UTF-8",
23902
23898
  standalone: "yes"
23903
23899
  },
23904
23900
  indent: prettify
@@ -23916,7 +23912,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23916
23912
  stack: [],
23917
23913
  viewWrapper: file.Document
23918
23914
  }), {
23919
- declaration: { encoding: "utf8" },
23915
+ declaration: { encoding: "UTF-8" },
23920
23916
  indent: prettify
23921
23917
  });
23922
23918
  })(),
@@ -23929,7 +23925,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23929
23925
  viewWrapper: file.Document
23930
23926
  }), {
23931
23927
  declaration: {
23932
- encoding: "utf8",
23928
+ encoding: "UTF-8",
23933
23929
  standalone: "yes"
23934
23930
  },
23935
23931
  indent: prettify
@@ -23944,7 +23940,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
23944
23940
  viewWrapper: file.Document
23945
23941
  }), {
23946
23942
  declaration: {
23947
- encoding: "utf8",
23943
+ encoding: "UTF-8",
23948
23944
  standalone: "yes"
23949
23945
  },
23950
23946
  indent: prettify
@@ -24882,7 +24878,7 @@ var docx = (function(exports, xml_js, hash_js, nanoid_non_secure, undio, fflate,
24882
24878
  };
24883
24879
  const createRelationshipFile = () => ({
24884
24880
  declaration: { attributes: {
24885
- encoding: "utf8",
24881
+ encoding: "UTF-8",
24886
24882
  standalone: "yes",
24887
24883
  version: "1.0"
24888
24884
  } },