docx 9.5.1 → 9.5.2

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.mjs CHANGED
@@ -3232,58 +3232,61 @@ function requireSetFunctionLength() {
3232
3232
  };
3233
3233
  return setFunctionLength;
3234
3234
  }
3235
+ var applyBind;
3236
+ var hasRequiredApplyBind;
3237
+ function requireApplyBind() {
3238
+ if (hasRequiredApplyBind) return applyBind;
3239
+ hasRequiredApplyBind = 1;
3240
+ var bind = requireFunctionBind();
3241
+ var $apply = requireFunctionApply();
3242
+ var actualApply2 = requireActualApply();
3243
+ applyBind = function applyBind2() {
3244
+ return actualApply2(bind, $apply, arguments);
3245
+ };
3246
+ return applyBind;
3247
+ }
3235
3248
  var hasRequiredCallBind;
3236
3249
  function requireCallBind() {
3237
3250
  if (hasRequiredCallBind) return callBind.exports;
3238
3251
  hasRequiredCallBind = 1;
3239
3252
  (function(module) {
3240
- var bind = requireFunctionBind();
3241
- var GetIntrinsic = /* @__PURE__ */ requireGetIntrinsic();
3242
3253
  var setFunctionLength2 = /* @__PURE__ */ requireSetFunctionLength();
3243
- var $TypeError = /* @__PURE__ */ requireType();
3244
- var $apply = GetIntrinsic("%Function.prototype.apply%");
3245
- var $call = GetIntrinsic("%Function.prototype.call%");
3246
- var $reflectApply = GetIntrinsic("%Reflect.apply%", true) || bind.call($call, $apply);
3247
3254
  var $defineProperty = /* @__PURE__ */ requireEsDefineProperty();
3248
- var $max = GetIntrinsic("%Math.max%");
3255
+ var callBindBasic = requireCallBindApplyHelpers();
3256
+ var applyBind2 = requireApplyBind();
3249
3257
  module.exports = function callBind2(originalFunction) {
3250
- if (typeof originalFunction !== "function") {
3251
- throw new $TypeError("a function is required");
3252
- }
3253
- var func = $reflectApply(bind, $call, arguments);
3258
+ var func = callBindBasic(arguments);
3259
+ var adjustedLength = originalFunction.length - (arguments.length - 1);
3254
3260
  return setFunctionLength2(
3255
3261
  func,
3256
- 1 + $max(0, originalFunction.length - (arguments.length - 1)),
3262
+ 1 + (adjustedLength > 0 ? adjustedLength : 0),
3257
3263
  true
3258
3264
  );
3259
3265
  };
3260
- var applyBind = function applyBind2() {
3261
- return $reflectApply(bind, $apply, arguments);
3262
- };
3263
3266
  if ($defineProperty) {
3264
- $defineProperty(module.exports, "apply", { value: applyBind });
3267
+ $defineProperty(module.exports, "apply", { value: applyBind2 });
3265
3268
  } else {
3266
- module.exports.apply = applyBind;
3269
+ module.exports.apply = applyBind2;
3267
3270
  }
3268
3271
  })(callBind);
3269
3272
  return callBind.exports;
3270
3273
  }
3271
- var callBound;
3272
- var hasRequiredCallBound;
3273
- function requireCallBound() {
3274
- if (hasRequiredCallBound) return callBound;
3275
- hasRequiredCallBound = 1;
3274
+ var callBound$1;
3275
+ var hasRequiredCallBound$1;
3276
+ function requireCallBound$1() {
3277
+ if (hasRequiredCallBound$1) return callBound$1;
3278
+ hasRequiredCallBound$1 = 1;
3276
3279
  var GetIntrinsic = /* @__PURE__ */ requireGetIntrinsic();
3277
3280
  var callBind2 = requireCallBind();
3278
3281
  var $indexOf = callBind2(GetIntrinsic("String.prototype.indexOf"));
3279
- callBound = function callBoundIntrinsic(name, allowMissing) {
3282
+ callBound$1 = function callBoundIntrinsic(name, allowMissing) {
3280
3283
  var intrinsic = GetIntrinsic(name, !!allowMissing);
3281
3284
  if (typeof intrinsic === "function" && $indexOf(name, ".prototype.") > -1) {
3282
3285
  return callBind2(intrinsic);
3283
3286
  }
3284
3287
  return intrinsic;
3285
3288
  };
3286
- return callBound;
3289
+ return callBound$1;
3287
3290
  }
3288
3291
  var isArguments;
3289
3292
  var hasRequiredIsArguments;
@@ -3291,7 +3294,7 @@ function requireIsArguments() {
3291
3294
  if (hasRequiredIsArguments) return isArguments;
3292
3295
  hasRequiredIsArguments = 1;
3293
3296
  var hasToStringTag = requireShams()();
3294
- var callBound2 = requireCallBound();
3297
+ var callBound2 = requireCallBound$1();
3295
3298
  var $toString = callBound2("Object.prototype.toString");
3296
3299
  var isStandardArguments = function isArguments2(value) {
3297
3300
  if (hasToStringTag && value && typeof value === "object" && Symbol.toStringTag in value) {
@@ -3471,10 +3474,10 @@ function requireIsCallable() {
3471
3474
  };
3472
3475
  return isCallable;
3473
3476
  }
3474
- var forEach_1;
3477
+ var forEach;
3475
3478
  var hasRequiredForEach;
3476
3479
  function requireForEach() {
3477
- if (hasRequiredForEach) return forEach_1;
3480
+ if (hasRequiredForEach) return forEach;
3478
3481
  hasRequiredForEach = 1;
3479
3482
  var isCallable2 = requireIsCallable();
3480
3483
  var toStr = Object.prototype.toString;
@@ -3510,7 +3513,10 @@ function requireForEach() {
3510
3513
  }
3511
3514
  }
3512
3515
  };
3513
- var forEach = function forEach2(list, iterator, thisArg) {
3516
+ function isArray(x) {
3517
+ return toStr.call(x) === "[object Array]";
3518
+ }
3519
+ forEach = function forEach2(list, iterator, thisArg) {
3514
3520
  if (!isCallable2(iterator)) {
3515
3521
  throw new TypeError("iterator must be a function");
3516
3522
  }
@@ -3518,7 +3524,7 @@ function requireForEach() {
3518
3524
  if (arguments.length >= 3) {
3519
3525
  receiver = thisArg;
3520
3526
  }
3521
- if (toStr.call(list) === "[object Array]") {
3527
+ if (isArray(list)) {
3522
3528
  forEachArray(list, iterator, receiver);
3523
3529
  } else if (typeof list === "string") {
3524
3530
  forEachString(list, iterator, receiver);
@@ -3526,8 +3532,7 @@ function requireForEach() {
3526
3532
  forEachObject(list, iterator, receiver);
3527
3533
  }
3528
3534
  };
3529
- forEach_1 = forEach;
3530
- return forEach_1;
3535
+ return forEach;
3531
3536
  }
3532
3537
  var possibleTypedArrayNames;
3533
3538
  var hasRequiredPossibleTypedArrayNames;
@@ -3567,22 +3572,45 @@ function requireAvailableTypedArrays() {
3567
3572
  };
3568
3573
  return availableTypedArrays;
3569
3574
  }
3575
+ var callBound;
3576
+ var hasRequiredCallBound;
3577
+ function requireCallBound() {
3578
+ if (hasRequiredCallBound) return callBound;
3579
+ hasRequiredCallBound = 1;
3580
+ var GetIntrinsic = /* @__PURE__ */ requireGetIntrinsic();
3581
+ var callBindBasic = requireCallBindApplyHelpers();
3582
+ var $indexOf = callBindBasic([GetIntrinsic("%String.prototype.indexOf%")]);
3583
+ callBound = function callBoundIntrinsic(name, allowMissing) {
3584
+ var intrinsic = (
3585
+ /** @type {(this: unknown, ...args: unknown[]) => unknown} */
3586
+ GetIntrinsic(name, !!allowMissing)
3587
+ );
3588
+ if (typeof intrinsic === "function" && $indexOf(name, ".prototype.") > -1) {
3589
+ return callBindBasic(
3590
+ /** @type {const} */
3591
+ [intrinsic]
3592
+ );
3593
+ }
3594
+ return intrinsic;
3595
+ };
3596
+ return callBound;
3597
+ }
3570
3598
  var whichTypedArray;
3571
3599
  var hasRequiredWhichTypedArray;
3572
3600
  function requireWhichTypedArray() {
3573
3601
  if (hasRequiredWhichTypedArray) return whichTypedArray;
3574
3602
  hasRequiredWhichTypedArray = 1;
3575
- var forEach = requireForEach();
3603
+ var forEach2 = requireForEach();
3576
3604
  var availableTypedArrays2 = /* @__PURE__ */ requireAvailableTypedArrays();
3577
3605
  var callBind2 = requireCallBind();
3578
- var callBound2 = requireCallBound();
3606
+ var callBound2 = /* @__PURE__ */ requireCallBound();
3579
3607
  var gOPD2 = /* @__PURE__ */ requireGopd();
3608
+ var getProto2 = requireGetProto();
3580
3609
  var $toString = callBound2("Object.prototype.toString");
3581
3610
  var hasToStringTag = requireShams()();
3582
3611
  var g = typeof globalThis === "undefined" ? commonjsGlobal : globalThis;
3583
3612
  var typedArrays = availableTypedArrays2();
3584
3613
  var $slice = callBound2("String.prototype.slice");
3585
- var getPrototypeOf = Object.getPrototypeOf;
3586
3614
  var $indexOf = callBound2("Array.prototype.indexOf", true) || function indexOf(array, value) {
3587
3615
  for (var i = 0; i < array.length; i += 1) {
3588
3616
  if (array[i] === value) {
@@ -3592,41 +3620,45 @@ function requireWhichTypedArray() {
3592
3620
  return -1;
3593
3621
  };
3594
3622
  var cache = { __proto__: null };
3595
- if (hasToStringTag && gOPD2 && getPrototypeOf) {
3596
- forEach(typedArrays, function(typedArray) {
3623
+ if (hasToStringTag && gOPD2 && getProto2) {
3624
+ forEach2(typedArrays, function(typedArray) {
3597
3625
  var arr = new g[typedArray]();
3598
- if (Symbol.toStringTag in arr) {
3599
- var proto = getPrototypeOf(arr);
3626
+ if (Symbol.toStringTag in arr && getProto2) {
3627
+ var proto = getProto2(arr);
3600
3628
  var descriptor = gOPD2(proto, Symbol.toStringTag);
3601
- if (!descriptor) {
3602
- var superProto = getPrototypeOf(proto);
3629
+ if (!descriptor && proto) {
3630
+ var superProto = getProto2(proto);
3603
3631
  descriptor = gOPD2(superProto, Symbol.toStringTag);
3604
3632
  }
3605
3633
  cache["$" + typedArray] = callBind2(descriptor.get);
3606
3634
  }
3607
3635
  });
3608
3636
  } else {
3609
- forEach(typedArrays, function(typedArray) {
3637
+ forEach2(typedArrays, function(typedArray) {
3610
3638
  var arr = new g[typedArray]();
3611
3639
  var fn = arr.slice || arr.set;
3612
3640
  if (fn) {
3613
- cache["$" + typedArray] = callBind2(fn);
3641
+ cache[
3642
+ /** @type {`$${import('.').TypedArrayName}`} */
3643
+ "$" + typedArray
3644
+ ] = /** @type {import('./types').BoundSlice | import('./types').BoundSet} */
3645
+ // @ts-expect-error TODO FIXME
3646
+ callBind2(fn);
3614
3647
  }
3615
3648
  });
3616
3649
  }
3617
3650
  var tryTypedArrays = function tryAllTypedArrays(value) {
3618
3651
  var found = false;
3619
- forEach(
3620
- // eslint-disable-next-line no-extra-parens
3621
- /** @type {Record<`\$${TypedArrayName}`, Getter>} */
3622
- /** @type {any} */
3652
+ forEach2(
3653
+ /** @type {Record<`\$${import('.').TypedArrayName}`, Getter>} */
3623
3654
  cache,
3624
3655
  /** @type {(getter: Getter, name: `\$${import('.').TypedArrayName}`) => void} */
3625
3656
  function(getter, typedArray) {
3626
3657
  if (!found) {
3627
3658
  try {
3628
3659
  if ("$" + getter(value) === typedArray) {
3629
- found = $slice(typedArray, 1);
3660
+ found = /** @type {import('.').TypedArrayName} */
3661
+ $slice(typedArray, 1);
3630
3662
  }
3631
3663
  } catch (e) {
3632
3664
  }
@@ -3637,17 +3669,16 @@ function requireWhichTypedArray() {
3637
3669
  };
3638
3670
  var trySlices = function tryAllSlices(value) {
3639
3671
  var found = false;
3640
- forEach(
3641
- // eslint-disable-next-line no-extra-parens
3642
- /** @type {Record<`\$${TypedArrayName}`, Getter>} */
3643
- /** @type {any} */
3672
+ forEach2(
3673
+ /** @type {Record<`\$${import('.').TypedArrayName}`, Getter>} */
3644
3674
  cache,
3645
- /** @type {(getter: typeof cache, name: `\$${import('.').TypedArrayName}`) => void} */
3675
+ /** @type {(getter: Getter, name: `\$${import('.').TypedArrayName}`) => void} */
3646
3676
  function(getter, name) {
3647
3677
  if (!found) {
3648
3678
  try {
3649
3679
  getter(value);
3650
- found = $slice(name, 1);
3680
+ found = /** @type {import('.').TypedArrayName} */
3681
+ $slice(name, 1);
3651
3682
  } catch (e) {
3652
3683
  }
3653
3684
  }
@@ -9362,9 +9393,10 @@ class ImportedXmlComponent extends XmlComponent {
9362
9393
  return convertToXmlComponent(xmlObj);
9363
9394
  }
9364
9395
  /**
9365
- * Converts the xml string to a XmlComponent tree.
9396
+ * Creates an ImportedXmlComponent.
9366
9397
  *
9367
- * @param importedContent xml content of the imported component
9398
+ * @param rootKey the root element name
9399
+ * @param _attr optional attributes for the root element
9368
9400
  */
9369
9401
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9370
9402
  constructor(rootKey, _attr) {
@@ -9656,6 +9688,9 @@ class Border extends IgnoreIfEmptyXmlComponent {
9656
9688
  if (options.right) {
9657
9689
  this.root.push(new BorderElement("w:right", options.right));
9658
9690
  }
9691
+ if (options.between) {
9692
+ this.root.push(new BorderElement("w:between", options.between));
9693
+ }
9659
9694
  }
9660
9695
  }
9661
9696
  class ThematicBreak extends XmlComponent {
@@ -12896,17 +12931,12 @@ class Drawing extends XmlComponent {
12896
12931
  }
12897
12932
  }
12898
12933
  const convertDataURIToBinary = (dataURI) => {
12899
- if (typeof atob === "function") {
12900
- const BASE64_MARKER = ";base64,";
12901
- const base64Index = dataURI.indexOf(BASE64_MARKER);
12902
- const base64IndexWithOffset = base64Index === -1 ? 0 : base64Index + BASE64_MARKER.length;
12903
- return new Uint8Array(
12904
- atob(dataURI.substring(base64IndexWithOffset)).split("").map((c) => c.charCodeAt(0))
12905
- );
12906
- } else {
12907
- const b = require("buffer");
12908
- return new b.Buffer(dataURI, "base64");
12909
- }
12934
+ const BASE64_MARKER = ";base64,";
12935
+ const base64Index = dataURI.indexOf(BASE64_MARKER);
12936
+ const base64IndexWithOffset = base64Index === -1 ? 0 : base64Index + BASE64_MARKER.length;
12937
+ return new Uint8Array(
12938
+ atob(dataURI.substring(base64IndexWithOffset)).split("").map((c) => c.charCodeAt(0))
12939
+ );
12910
12940
  };
12911
12941
  const standardizeData = (data) => typeof data === "string" ? convertDataURIToBinary(data) : data;
12912
12942
  const createImageData = (options, key) => ({
@@ -13554,6 +13584,44 @@ class BookmarkEnd extends XmlComponent {
13554
13584
  this.root.push(attributes);
13555
13585
  }
13556
13586
  }
13587
+ var NumberedItemReferenceFormat = /* @__PURE__ */ ((NumberedItemReferenceFormat2) => {
13588
+ NumberedItemReferenceFormat2["NONE"] = "none";
13589
+ NumberedItemReferenceFormat2["RELATIVE"] = "relative";
13590
+ NumberedItemReferenceFormat2["NO_CONTEXT"] = "no_context";
13591
+ NumberedItemReferenceFormat2["FULL_CONTEXT"] = "full_context";
13592
+ return NumberedItemReferenceFormat2;
13593
+ })(NumberedItemReferenceFormat || {});
13594
+ const SWITCH_MAP = {
13595
+ [
13596
+ "relative"
13597
+ /* RELATIVE */
13598
+ ]: "\\r",
13599
+ [
13600
+ "no_context"
13601
+ /* NO_CONTEXT */
13602
+ ]: "\\n",
13603
+ [
13604
+ "full_context"
13605
+ /* FULL_CONTEXT */
13606
+ ]: "\\w",
13607
+ [
13608
+ "none"
13609
+ /* NONE */
13610
+ ]: void 0
13611
+ };
13612
+ class NumberedItemReference extends SimpleField {
13613
+ constructor(bookmarkId, cachedValue, options = {}) {
13614
+ const {
13615
+ hyperlink = true,
13616
+ referenceFormat = "full_context"
13617
+ /* FULL_CONTEXT */
13618
+ } = options;
13619
+ const baseInstruction = `REF ${bookmarkId}`;
13620
+ const switches = [...hyperlink ? ["\\h"] : [], ...[SWITCH_MAP[referenceFormat]].filter((a) => !!a)];
13621
+ const instruction = `${baseInstruction} ${switches.join(" ")}`;
13622
+ super(instruction, cachedValue);
13623
+ }
13624
+ }
13557
13625
  class OutlineLevel extends XmlComponent {
13558
13626
  constructor(level) {
13559
13627
  super("w:outlineLvl");
@@ -21684,6 +21752,8 @@ export {
21684
21752
  NumberFormat$1 as NumberFormat,
21685
21753
  NumberProperties,
21686
21754
  NumberValueElement,
21755
+ NumberedItemReference,
21756
+ NumberedItemReferenceFormat,
21687
21757
  Numbering,
21688
21758
  OnOffElement,
21689
21759
  OutlineLevel,