docx-plus 0.0.9 → 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.
package/dist/index.cjs CHANGED
@@ -7447,23 +7447,97 @@ var Drawing = class extends XmlComponent {
7447
7447
  }
7448
7448
  };
7449
7449
  //#endregion
7450
- //#region src/file/paragraph/run/image-run.ts
7451
- const createImageData = (data, transformation, key, srcRect) => ({
7452
- data,
7453
- fileName: key,
7454
- srcRect,
7455
- transformation: {
7450
+ //#region src/file/media/media.ts
7451
+ /**
7452
+ * Converts user-facing transformation options (pixels) to internal
7453
+ * transformation data (pixels + EMUs).
7454
+ *
7455
+ * @param options - User-facing transformation in pixels
7456
+ * @returns Internal transformation data with both pixel and EMU values
7457
+ */
7458
+ const createTransformation = (options) => {
7459
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7460
+ return {
7456
7461
  emus: {
7457
- x: Math.round(transformation.width * 9525),
7458
- y: Math.round(transformation.height * 9525)
7462
+ x: Math.round(options.width * 9525),
7463
+ y: Math.round(options.height * 9525)
7464
+ },
7465
+ flip: options.flip,
7466
+ offset: {
7467
+ emus: {
7468
+ 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),
7469
+ 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)
7470
+ },
7471
+ pixels: {
7472
+ 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),
7473
+ 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)
7474
+ }
7459
7475
  },
7460
- flip: transformation.flip,
7461
7476
  pixels: {
7462
- x: Math.round(transformation.width),
7463
- y: Math.round(transformation.height)
7477
+ x: Math.round(options.width),
7478
+ y: Math.round(options.height)
7464
7479
  },
7465
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7480
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7481
+ };
7482
+ };
7483
+ /**
7484
+ * Manages embedded media (images) in a document.
7485
+ *
7486
+ * Media stores all images referenced in the document and provides
7487
+ * access to their data for packaging into the DOCX file. Each image
7488
+ * is stored with a unique key for retrieval.
7489
+ *
7490
+ * @example
7491
+ * ```typescript
7492
+ * const media = new Media();
7493
+ * media.addImage("image1", {
7494
+ * type: "png",
7495
+ * fileName: "image1.png",
7496
+ * transformation: {
7497
+ * pixels: { x: 200, y: 100 },
7498
+ * emus: { x: 1828800, y: 914400 }
7499
+ * },
7500
+ * data: imageBuffer
7501
+ * });
7502
+ * const allImages = media.Array;
7503
+ * ```
7504
+ */
7505
+ var Media = class {
7506
+ constructor() {
7507
+ _defineProperty(this, "map", void 0);
7508
+ this.map = /* @__PURE__ */ new Map();
7466
7509
  }
7510
+ /**
7511
+ * Adds an image to the media collection.
7512
+ *
7513
+ * @param key - Unique identifier for this image
7514
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7515
+ */
7516
+ addImage(key, mediaData) {
7517
+ this.map.set(key, mediaData);
7518
+ }
7519
+ /**
7520
+ * Gets all images as an array.
7521
+ *
7522
+ * @returns Read-only array of all media data in the collection
7523
+ */
7524
+ get Array() {
7525
+ return [...this.map.values()];
7526
+ }
7527
+ };
7528
+ //#endregion
7529
+ //#region src/file/media/data.ts
7530
+ /**
7531
+ * @ignore
7532
+ */
7533
+ const WORKAROUND2 = "";
7534
+ //#endregion
7535
+ //#region src/file/paragraph/run/image-run.ts
7536
+ const createImageData = (data, transformation, key, srcRect) => ({
7537
+ data,
7538
+ fileName: key,
7539
+ srcRect,
7540
+ transformation: createTransformation(transformation)
7467
7541
  });
7468
7542
  /**
7469
7543
  * Represents an image in a WordprocessingML document.
@@ -7522,31 +7596,6 @@ var ImageRun = class extends Run {
7522
7596
  };
7523
7597
  //#endregion
7524
7598
  //#region src/file/paragraph/run/wps-shape-run.ts
7525
- const createTransformation = (options) => {
7526
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7527
- return {
7528
- emus: {
7529
- x: Math.round(options.width * 9525),
7530
- y: Math.round(options.height * 9525)
7531
- },
7532
- flip: options.flip,
7533
- offset: {
7534
- emus: {
7535
- 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),
7536
- 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)
7537
- },
7538
- pixels: {
7539
- 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),
7540
- 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)
7541
- }
7542
- },
7543
- pixels: {
7544
- x: Math.round(options.width),
7545
- y: Math.round(options.height)
7546
- },
7547
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7548
- };
7549
- };
7550
7599
  /**
7551
7600
  * @publicApi
7552
7601
  */
@@ -16861,59 +16910,6 @@ var HeaderWrapper = class {
16861
16910
  }
16862
16911
  };
16863
16912
  //#endregion
16864
- //#region src/file/media/media.ts
16865
- /**
16866
- * Manages embedded media (images) in a document.
16867
- *
16868
- * Media stores all images referenced in the document and provides
16869
- * access to their data for packaging into the DOCX file. Each image
16870
- * is stored with a unique key for retrieval.
16871
- *
16872
- * @example
16873
- * ```typescript
16874
- * const media = new Media();
16875
- * media.addImage("image1", {
16876
- * type: "png",
16877
- * fileName: "image1.png",
16878
- * transformation: {
16879
- * pixels: { x: 200, y: 100 },
16880
- * emus: { x: 1828800, y: 914400 }
16881
- * },
16882
- * data: imageBuffer
16883
- * });
16884
- * const allImages = media.Array;
16885
- * ```
16886
- */
16887
- var Media = class {
16888
- constructor() {
16889
- _defineProperty(this, "map", void 0);
16890
- this.map = /* @__PURE__ */ new Map();
16891
- }
16892
- /**
16893
- * Adds an image to the media collection.
16894
- *
16895
- * @param key - Unique identifier for this image
16896
- * @param mediaData - Complete image data including file name, transformation, and raw data
16897
- */
16898
- addImage(key, mediaData) {
16899
- this.map.set(key, mediaData);
16900
- }
16901
- /**
16902
- * Gets all images as an array.
16903
- *
16904
- * @returns Read-only array of all media data in the collection
16905
- */
16906
- get Array() {
16907
- return [...this.map.values()];
16908
- }
16909
- };
16910
- //#endregion
16911
- //#region src/file/media/data.ts
16912
- /**
16913
- * @ignore
16914
- */
16915
- const WORKAROUND2 = "";
16916
- //#endregion
16917
16913
  //#region src/file/numbering/level.ts
16918
16914
  /**
16919
16915
  * Numbering level definitions module for WordprocessingML documents.
package/dist/index.d.cts CHANGED
@@ -1287,6 +1287,7 @@ interface IMediaTransformation {
1287
1287
  };
1288
1288
  readonly rotation?: number;
1289
1289
  }
1290
+ declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1290
1291
  declare class Media {
1291
1292
  private readonly map;
1292
1293
  constructor();
@@ -1345,7 +1346,6 @@ interface CoreShapeOptions {
1345
1346
  type IWpsShapeOptions = WpsShapeCoreOptions & {
1346
1347
  readonly type: "wps";
1347
1348
  } & CoreShapeOptions;
1348
- declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1349
1349
  declare class WpsShapeRun extends Run {
1350
1350
  private readonly wpsShapeData;
1351
1351
  constructor(options: IWpsShapeOptions);
package/dist/index.d.mts CHANGED
@@ -1289,6 +1289,7 @@ interface IMediaTransformation {
1289
1289
  };
1290
1290
  readonly rotation?: number;
1291
1291
  }
1292
+ declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1292
1293
  declare class Media {
1293
1294
  private readonly map;
1294
1295
  constructor();
@@ -1347,7 +1348,6 @@ interface CoreShapeOptions {
1347
1348
  type IWpsShapeOptions = WpsShapeCoreOptions & {
1348
1349
  readonly type: "wps";
1349
1350
  } & CoreShapeOptions;
1350
- declare const createTransformation: (options: IMediaTransformation) => IMediaDataTransformation;
1351
1351
  declare class WpsShapeRun extends Run {
1352
1352
  private readonly wpsShapeData;
1353
1353
  constructor(options: IWpsShapeOptions);
@@ -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.
package/dist/index.mjs CHANGED
@@ -7422,23 +7422,97 @@ var Drawing = class extends XmlComponent {
7422
7422
  }
7423
7423
  };
7424
7424
  //#endregion
7425
- //#region src/file/paragraph/run/image-run.ts
7426
- const createImageData = (data, transformation, key, srcRect) => ({
7427
- data,
7428
- fileName: key,
7429
- srcRect,
7430
- transformation: {
7425
+ //#region src/file/media/media.ts
7426
+ /**
7427
+ * Converts user-facing transformation options (pixels) to internal
7428
+ * transformation data (pixels + EMUs).
7429
+ *
7430
+ * @param options - User-facing transformation in pixels
7431
+ * @returns Internal transformation data with both pixel and EMU values
7432
+ */
7433
+ const createTransformation = (options) => {
7434
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7435
+ return {
7431
7436
  emus: {
7432
- x: Math.round(transformation.width * 9525),
7433
- y: Math.round(transformation.height * 9525)
7437
+ x: Math.round(options.width * 9525),
7438
+ y: Math.round(options.height * 9525)
7439
+ },
7440
+ flip: options.flip,
7441
+ offset: {
7442
+ emus: {
7443
+ 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),
7444
+ 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)
7445
+ },
7446
+ pixels: {
7447
+ 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),
7448
+ 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)
7449
+ }
7434
7450
  },
7435
- flip: transformation.flip,
7436
7451
  pixels: {
7437
- x: Math.round(transformation.width),
7438
- y: Math.round(transformation.height)
7452
+ x: Math.round(options.width),
7453
+ y: Math.round(options.height)
7439
7454
  },
7440
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7455
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7456
+ };
7457
+ };
7458
+ /**
7459
+ * Manages embedded media (images) in a document.
7460
+ *
7461
+ * Media stores all images referenced in the document and provides
7462
+ * access to their data for packaging into the DOCX file. Each image
7463
+ * is stored with a unique key for retrieval.
7464
+ *
7465
+ * @example
7466
+ * ```typescript
7467
+ * const media = new Media();
7468
+ * media.addImage("image1", {
7469
+ * type: "png",
7470
+ * fileName: "image1.png",
7471
+ * transformation: {
7472
+ * pixels: { x: 200, y: 100 },
7473
+ * emus: { x: 1828800, y: 914400 }
7474
+ * },
7475
+ * data: imageBuffer
7476
+ * });
7477
+ * const allImages = media.Array;
7478
+ * ```
7479
+ */
7480
+ var Media = class {
7481
+ constructor() {
7482
+ _defineProperty(this, "map", void 0);
7483
+ this.map = /* @__PURE__ */ new Map();
7441
7484
  }
7485
+ /**
7486
+ * Adds an image to the media collection.
7487
+ *
7488
+ * @param key - Unique identifier for this image
7489
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7490
+ */
7491
+ addImage(key, mediaData) {
7492
+ this.map.set(key, mediaData);
7493
+ }
7494
+ /**
7495
+ * Gets all images as an array.
7496
+ *
7497
+ * @returns Read-only array of all media data in the collection
7498
+ */
7499
+ get Array() {
7500
+ return [...this.map.values()];
7501
+ }
7502
+ };
7503
+ //#endregion
7504
+ //#region src/file/media/data.ts
7505
+ /**
7506
+ * @ignore
7507
+ */
7508
+ const WORKAROUND2 = "";
7509
+ //#endregion
7510
+ //#region src/file/paragraph/run/image-run.ts
7511
+ const createImageData = (data, transformation, key, srcRect) => ({
7512
+ data,
7513
+ fileName: key,
7514
+ srcRect,
7515
+ transformation: createTransformation(transformation)
7442
7516
  });
7443
7517
  /**
7444
7518
  * Represents an image in a WordprocessingML document.
@@ -7497,31 +7571,6 @@ var ImageRun = class extends Run {
7497
7571
  };
7498
7572
  //#endregion
7499
7573
  //#region src/file/paragraph/run/wps-shape-run.ts
7500
- const createTransformation = (options) => {
7501
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7502
- return {
7503
- emus: {
7504
- x: Math.round(options.width * 9525),
7505
- y: Math.round(options.height * 9525)
7506
- },
7507
- flip: options.flip,
7508
- offset: {
7509
- emus: {
7510
- 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),
7511
- 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)
7512
- },
7513
- pixels: {
7514
- 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),
7515
- 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)
7516
- }
7517
- },
7518
- pixels: {
7519
- x: Math.round(options.width),
7520
- y: Math.round(options.height)
7521
- },
7522
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7523
- };
7524
- };
7525
7574
  /**
7526
7575
  * @publicApi
7527
7576
  */
@@ -16836,59 +16885,6 @@ var HeaderWrapper = class {
16836
16885
  }
16837
16886
  };
16838
16887
  //#endregion
16839
- //#region src/file/media/media.ts
16840
- /**
16841
- * Manages embedded media (images) in a document.
16842
- *
16843
- * Media stores all images referenced in the document and provides
16844
- * access to their data for packaging into the DOCX file. Each image
16845
- * is stored with a unique key for retrieval.
16846
- *
16847
- * @example
16848
- * ```typescript
16849
- * const media = new Media();
16850
- * media.addImage("image1", {
16851
- * type: "png",
16852
- * fileName: "image1.png",
16853
- * transformation: {
16854
- * pixels: { x: 200, y: 100 },
16855
- * emus: { x: 1828800, y: 914400 }
16856
- * },
16857
- * data: imageBuffer
16858
- * });
16859
- * const allImages = media.Array;
16860
- * ```
16861
- */
16862
- var Media = class {
16863
- constructor() {
16864
- _defineProperty(this, "map", void 0);
16865
- this.map = /* @__PURE__ */ new Map();
16866
- }
16867
- /**
16868
- * Adds an image to the media collection.
16869
- *
16870
- * @param key - Unique identifier for this image
16871
- * @param mediaData - Complete image data including file name, transformation, and raw data
16872
- */
16873
- addImage(key, mediaData) {
16874
- this.map.set(key, mediaData);
16875
- }
16876
- /**
16877
- * Gets all images as an array.
16878
- *
16879
- * @returns Read-only array of all media data in the collection
16880
- */
16881
- get Array() {
16882
- return [...this.map.values()];
16883
- }
16884
- };
16885
- //#endregion
16886
- //#region src/file/media/data.ts
16887
- /**
16888
- * @ignore
16889
- */
16890
- const WORKAROUND2 = "";
16891
- //#endregion
16892
16888
  //#region src/file/numbering/level.ts
16893
16889
  /**
16894
16890
  * Numbering level definitions module for WordprocessingML documents.
package/dist/index.umd.js CHANGED
@@ -7452,23 +7452,97 @@
7452
7452
  }
7453
7453
  };
7454
7454
  //#endregion
7455
- //#region src/file/paragraph/run/image-run.ts
7456
- const createImageData = (data, transformation, key, srcRect) => ({
7457
- data,
7458
- fileName: key,
7459
- srcRect,
7460
- transformation: {
7455
+ //#region src/file/media/media.ts
7456
+ /**
7457
+ * Converts user-facing transformation options (pixels) to internal
7458
+ * transformation data (pixels + EMUs).
7459
+ *
7460
+ * @param options - User-facing transformation in pixels
7461
+ * @returns Internal transformation data with both pixel and EMU values
7462
+ */
7463
+ const createTransformation = (options) => {
7464
+ var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7465
+ return {
7461
7466
  emus: {
7462
- x: Math.round(transformation.width * 9525),
7463
- y: Math.round(transformation.height * 9525)
7467
+ x: Math.round(options.width * 9525),
7468
+ y: Math.round(options.height * 9525)
7469
+ },
7470
+ flip: options.flip,
7471
+ offset: {
7472
+ emus: {
7473
+ 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),
7474
+ 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)
7475
+ },
7476
+ pixels: {
7477
+ 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),
7478
+ 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)
7479
+ }
7464
7480
  },
7465
- flip: transformation.flip,
7466
7481
  pixels: {
7467
- x: Math.round(transformation.width),
7468
- y: Math.round(transformation.height)
7482
+ x: Math.round(options.width),
7483
+ y: Math.round(options.height)
7469
7484
  },
7470
- rotation: transformation.rotation ? transformation.rotation * 6e4 : void 0
7485
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
7486
+ };
7487
+ };
7488
+ /**
7489
+ * Manages embedded media (images) in a document.
7490
+ *
7491
+ * Media stores all images referenced in the document and provides
7492
+ * access to their data for packaging into the DOCX file. Each image
7493
+ * is stored with a unique key for retrieval.
7494
+ *
7495
+ * @example
7496
+ * ```typescript
7497
+ * const media = new Media();
7498
+ * media.addImage("image1", {
7499
+ * type: "png",
7500
+ * fileName: "image1.png",
7501
+ * transformation: {
7502
+ * pixels: { x: 200, y: 100 },
7503
+ * emus: { x: 1828800, y: 914400 }
7504
+ * },
7505
+ * data: imageBuffer
7506
+ * });
7507
+ * const allImages = media.Array;
7508
+ * ```
7509
+ */
7510
+ var Media = class {
7511
+ constructor() {
7512
+ _defineProperty(this, "map", void 0);
7513
+ this.map = /* @__PURE__ */ new Map();
7471
7514
  }
7515
+ /**
7516
+ * Adds an image to the media collection.
7517
+ *
7518
+ * @param key - Unique identifier for this image
7519
+ * @param mediaData - Complete image data including file name, transformation, and raw data
7520
+ */
7521
+ addImage(key, mediaData) {
7522
+ this.map.set(key, mediaData);
7523
+ }
7524
+ /**
7525
+ * Gets all images as an array.
7526
+ *
7527
+ * @returns Read-only array of all media data in the collection
7528
+ */
7529
+ get Array() {
7530
+ return [...this.map.values()];
7531
+ }
7532
+ };
7533
+ //#endregion
7534
+ //#region src/file/media/data.ts
7535
+ /**
7536
+ * @ignore
7537
+ */
7538
+ const WORKAROUND2 = "";
7539
+ //#endregion
7540
+ //#region src/file/paragraph/run/image-run.ts
7541
+ const createImageData = (data, transformation, key, srcRect) => ({
7542
+ data,
7543
+ fileName: key,
7544
+ srcRect,
7545
+ transformation: createTransformation(transformation)
7472
7546
  });
7473
7547
  /**
7474
7548
  * Represents an image in a WordprocessingML document.
@@ -7527,31 +7601,6 @@
7527
7601
  };
7528
7602
  //#endregion
7529
7603
  //#region src/file/paragraph/run/wps-shape-run.ts
7530
- const createTransformation = (options) => {
7531
- var _options$offset$left, _options$offset, _options$offset$top, _options$offset2, _options$offset$left2, _options$offset3, _options$offset$top2, _options$offset4;
7532
- return {
7533
- emus: {
7534
- x: Math.round(options.width * 9525),
7535
- y: Math.round(options.height * 9525)
7536
- },
7537
- flip: options.flip,
7538
- offset: {
7539
- emus: {
7540
- 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),
7541
- 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)
7542
- },
7543
- pixels: {
7544
- 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),
7545
- 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)
7546
- }
7547
- },
7548
- pixels: {
7549
- x: Math.round(options.width),
7550
- y: Math.round(options.height)
7551
- },
7552
- rotation: options.rotation ? options.rotation * 6e4 : void 0
7553
- };
7554
- };
7555
7604
  /**
7556
7605
  * @publicApi
7557
7606
  */
@@ -16866,59 +16915,6 @@
16866
16915
  }
16867
16916
  };
16868
16917
  //#endregion
16869
- //#region src/file/media/media.ts
16870
- /**
16871
- * Manages embedded media (images) in a document.
16872
- *
16873
- * Media stores all images referenced in the document and provides
16874
- * access to their data for packaging into the DOCX file. Each image
16875
- * is stored with a unique key for retrieval.
16876
- *
16877
- * @example
16878
- * ```typescript
16879
- * const media = new Media();
16880
- * media.addImage("image1", {
16881
- * type: "png",
16882
- * fileName: "image1.png",
16883
- * transformation: {
16884
- * pixels: { x: 200, y: 100 },
16885
- * emus: { x: 1828800, y: 914400 }
16886
- * },
16887
- * data: imageBuffer
16888
- * });
16889
- * const allImages = media.Array;
16890
- * ```
16891
- */
16892
- var Media = class {
16893
- constructor() {
16894
- _defineProperty(this, "map", void 0);
16895
- this.map = /* @__PURE__ */ new Map();
16896
- }
16897
- /**
16898
- * Adds an image to the media collection.
16899
- *
16900
- * @param key - Unique identifier for this image
16901
- * @param mediaData - Complete image data including file name, transformation, and raw data
16902
- */
16903
- addImage(key, mediaData) {
16904
- this.map.set(key, mediaData);
16905
- }
16906
- /**
16907
- * Gets all images as an array.
16908
- *
16909
- * @returns Read-only array of all media data in the collection
16910
- */
16911
- get Array() {
16912
- return [...this.map.values()];
16913
- }
16914
- };
16915
- //#endregion
16916
- //#region src/file/media/data.ts
16917
- /**
16918
- * @ignore
16919
- */
16920
- const WORKAROUND2 = "";
16921
- //#endregion
16922
16918
  //#region src/file/numbering/level.ts
16923
16919
  /**
16924
16920
  * Numbering level definitions module for WordprocessingML documents.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx-plus",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
5
5
  "keywords": [
6
6
  "clippy",