docx 9.7.1 → 9.7.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.
@@ -26,7 +26,7 @@
26
26
  enumerable: true
27
27
  }) : target, mod));
28
28
  //#endregion
29
- //#region \0@oxc-project+runtime@0.132.0/helpers/typeof.js
29
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
30
30
  function _typeof(o) {
31
31
  "@babel/helpers - typeof";
32
32
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -36,7 +36,7 @@
36
36
  }, _typeof(o);
37
37
  }
38
38
  //#endregion
39
- //#region \0@oxc-project+runtime@0.132.0/helpers/toPrimitive.js
39
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
40
40
  function toPrimitive(t, r) {
41
41
  if ("object" != _typeof(t) || !t) return t;
42
42
  var e = t[Symbol.toPrimitive];
@@ -48,13 +48,13 @@
48
48
  return ("string" === r ? String : Number)(t);
49
49
  }
50
50
  //#endregion
51
- //#region \0@oxc-project+runtime@0.132.0/helpers/toPropertyKey.js
51
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
52
52
  function toPropertyKey(t) {
53
53
  var i = toPrimitive(t, "string");
54
54
  return "symbol" == _typeof(i) ? i : i + "";
55
55
  }
56
56
  //#endregion
57
- //#region \0@oxc-project+runtime@0.132.0/helpers/defineProperty.js
57
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
58
58
  function _defineProperty(e, r, t) {
59
59
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
60
60
  value: t,
@@ -254,7 +254,7 @@
254
254
  }
255
255
  };
256
256
  //#endregion
257
- //#region \0@oxc-project+runtime@0.132.0/helpers/objectSpread2.js
257
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectSpread2.js
258
258
  function ownKeys(e, r) {
259
259
  var t = Object.keys(e);
260
260
  if (Object.getOwnPropertySymbols) {
@@ -888,7 +888,7 @@
888
888
  return 0;
889
889
  };
890
890
  browserExports = browser.exports;
891
- process$1 = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
891
+ process$1 = /*@__PURE__*/ getDefaultExportFromCjs(browserExports);
892
892
  }));
893
893
  //#endregion
894
894
  //#region node_modules/stream-browserify/node_modules/readable-stream/lib/internal/streams/stream-browser.js
@@ -3942,7 +3942,7 @@
3942
3942
  function copyBuffer(src, target, offset) {
3943
3943
  Buffer.prototype.copy.call(src, target, offset);
3944
3944
  }
3945
- module.exports = /* @__PURE__ */ function() {
3945
+ module.exports = /*#__PURE__*/ function() {
3946
3946
  function BufferList() {
3947
3947
  _classCallCheck(this, BufferList);
3948
3948
  this.head = null;
@@ -4199,7 +4199,7 @@
4199
4199
  if (typeof message === "string") return message;
4200
4200
  else return message(arg1, arg2, arg3);
4201
4201
  }
4202
- var NodeError = /* @__PURE__ */ function(_Base) {
4202
+ var NodeError = /*#__PURE__*/ function(_Base) {
4203
4203
  _inheritsLoose(NodeError, _Base);
4204
4204
  function NodeError(arg1, arg2, arg3) {
4205
4205
  return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
@@ -12276,7 +12276,7 @@ DOT: "dot" };
12276
12276
  };
12277
12277
  }));
12278
12278
  //#endregion
12279
- //#region node_modules/nanoid/non-secure/index.js
12279
+ //#region node_modules/nanoid/url-alphabet/index.js
12280
12280
  var import_hash = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports) => {
12281
12281
  var hash = exports;
12282
12282
  hash.utils = require_utils();
@@ -12292,18 +12292,20 @@ DOT: "dot" };
12292
12292
  hash.ripemd160 = hash.ripemd.ripemd160;
12293
12293
  })))(), 1);
12294
12294
  var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
12295
+ //#endregion
12296
+ //#region node_modules/nanoid/non-secure/index.js
12295
12297
  var customAlphabet = (alphabet, defaultSize = 21) => {
12296
12298
  return (size = defaultSize) => {
12297
12299
  let id = "";
12298
12300
  let i = size | 0;
12299
- while (i--) id += alphabet[Math.random() * alphabet.length | 0];
12301
+ while (i-- > 0) id += alphabet[Math.random() * alphabet.length | 0];
12300
12302
  return id;
12301
12303
  };
12302
12304
  };
12303
12305
  var nanoid = (size = 21) => {
12304
12306
  let id = "";
12305
12307
  let i = size | 0;
12306
- while (i--) id += urlAlphabet[Math.random() * 64 | 0];
12308
+ while (i-- > 0) id += urlAlphabet[Math.random() * 64 | 0];
12307
12309
  return id;
12308
12310
  };
12309
12311
  //#endregion
@@ -15738,6 +15740,7 @@ EXTERNAL: "External" };
15738
15740
  super("w:comments");
15739
15741
  _defineProperty(this, "relationships", void 0);
15740
15742
  _defineProperty(this, "threadData", void 0);
15743
+ _defineProperty(this, "commentIdsData", void 0);
15741
15744
  this.root.push(new RootCommentsAttributes({
15742
15745
  "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex",
15743
15746
  "xmlns:cx1": "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",
@@ -15771,14 +15774,23 @@ EXTERNAL: "External" };
15771
15774
  "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml",
15772
15775
  "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
15773
15776
  }));
15774
- if (children.some((child) => child.parentId !== void 0)) {
15777
+ const hasThreading = children.some((child) => child.parentId !== void 0);
15778
+ const hasDurableIds = children.some((child) => child.durableId !== void 0);
15779
+ if (hasThreading || hasDurableIds) {
15775
15780
  const idToParaId = new Map(children.map((child) => [child.id, commentIdToParaId(child.id)]));
15776
15781
  for (const child of children) this.root.push(new Comment(child, idToParaId.get(child.id)));
15777
- this.threadData = children.map((child) => ({
15782
+ if (hasThreading) this.threadData = children.map((child) => ({
15778
15783
  paraId: idToParaId.get(child.id),
15779
15784
  parentParaId: child.parentId !== void 0 ? idToParaId.get(child.parentId) : void 0,
15780
15785
  done: child.resolved
15781
15786
  }));
15787
+ if (hasDurableIds) this.commentIdsData = children.map((child) => {
15788
+ var _child$durableId;
15789
+ return {
15790
+ paraId: idToParaId.get(child.id),
15791
+ durableId: (_child$durableId = child.durableId) !== null && _child$durableId !== void 0 ? _child$durableId : idToParaId.get(child.id)
15792
+ };
15793
+ });
15782
15794
  } else for (const child of children) this.root.push(new Comment(child));
15783
15795
  this.relationships = new Relationships();
15784
15796
  }
@@ -15789,6 +15801,10 @@ EXTERNAL: "External" };
15789
15801
  get ThreadData() {
15790
15802
  return this.threadData;
15791
15803
  }
15804
+ /** Comment id data for commentsIds.xml, or undefined when no comments carry a durableId. */
15805
+ get CommentIdsData() {
15806
+ return this.commentIdsData;
15807
+ }
15792
15808
  };
15793
15809
  //#endregion
15794
15810
  //#region src/file/paragraph/run/comments-extended.ts
@@ -15869,6 +15885,69 @@ EXTERNAL: "External" };
15869
15885
  for (const data of threadData) this.root.push(new CommentEx(data));
15870
15886
  }
15871
15887
  };
15888
+ /**
15889
+ * @internal
15890
+ */
15891
+ var CommentIdAttributes = class extends XmlAttributeComponent {
15892
+ constructor(..._args3) {
15893
+ super(..._args3);
15894
+ _defineProperty(this, "xmlKeys", {
15895
+ paraId: "w16cid:paraId",
15896
+ durableId: "w16cid:durableId"
15897
+ });
15898
+ }
15899
+ };
15900
+ /**
15901
+ * @internal
15902
+ */
15903
+ var CommentId = class extends XmlComponent {
15904
+ constructor(options) {
15905
+ super("w16cid:commentId");
15906
+ this.root.push(new CommentIdAttributes({
15907
+ paraId: options.paraId,
15908
+ durableId: options.durableId
15909
+ }));
15910
+ }
15911
+ };
15912
+ /**
15913
+ * @internal
15914
+ */
15915
+ var CommentsIdsAttributes = class extends XmlAttributeComponent {
15916
+ constructor(..._args4) {
15917
+ super(..._args4);
15918
+ _defineProperty(this, "xmlKeys", {
15919
+ "xmlns:w16cid": "xmlns:w16cid",
15920
+ "xmlns:mc": "xmlns:mc",
15921
+ "mc:Ignorable": "mc:Ignorable"
15922
+ });
15923
+ }
15924
+ };
15925
+ /**
15926
+ * Represents the commentsIds part (word/commentsIds.xml).
15927
+ *
15928
+ * Contains w16cid:commentId elements that map each comment's volatile paraId
15929
+ * to a stable w16cid:durableId preserved by Word across edits.
15930
+ *
15931
+ * ## XSD Schema (wml-cid.xsd)
15932
+ * ```xml
15933
+ * <xsd:complexType name="CT_CommentsIds">
15934
+ * <xsd:sequence>
15935
+ * <xsd:element name="commentId" type="CT_CommentId" minOccurs="0" maxOccurs="unbounded"/>
15936
+ * </xsd:sequence>
15937
+ * </xsd:complexType>
15938
+ * ```
15939
+ */
15940
+ var CommentsIds = class extends XmlComponent {
15941
+ constructor(commentIdsData) {
15942
+ super("w16cid:commentsIds");
15943
+ this.root.push(new CommentsIdsAttributes({
15944
+ "xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid",
15945
+ "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
15946
+ "mc:Ignorable": "w16cid"
15947
+ }));
15948
+ for (const data of commentIdsData) this.root.push(new CommentId(data));
15949
+ }
15950
+ };
15872
15951
  //#endregion
15873
15952
  //#region src/file/paragraph/run/empty-children.ts
15874
15953
  /**
@@ -21879,6 +21958,12 @@ MAX: 9026 };
21879
21958
  this.root.push(createOverride("application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", "/word/commentsExtended.xml"));
21880
21959
  }
21881
21960
  /**
21961
+ * Registers the commentsIds part in the content types.
21962
+ */
21963
+ addCommentsIds() {
21964
+ this.root.push(createOverride("application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml", "/word/commentsIds.xml"));
21965
+ }
21966
+ /**
21882
21967
  * Registers a footer part in the content types.
21883
21968
  *
21884
21969
  * @param index - Footer index number (e.g., 1 for footer1.xml)
@@ -26802,6 +26887,12 @@ MAX: 9026 };
26802
26887
  "commentsExtended",
26803
26888
  void 0
26804
26889
  );
26890
+ _defineProperty(
26891
+ this,
26892
+ /** Durable comment id mapping (word/commentsIds.xml). */
26893
+ "commentsIds",
26894
+ void 0
26895
+ );
26805
26896
  _defineProperty(this, "fontWrapper", void 0);
26806
26897
  this.coreProperties = new CoreProperties(_objectSpread2(_objectSpread2({}, options), {}, {
26807
26898
  creator: (_options$creator = options.creator) !== null && _options$creator !== void 0 ? _options$creator : "Un-named",
@@ -26811,6 +26902,7 @@ MAX: 9026 };
26811
26902
  this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] });
26812
26903
  this.comments = new Comments((_options$comments = options.comments) !== null && _options$comments !== void 0 ? _options$comments : { children: [] });
26813
26904
  if (this.comments.ThreadData) this.commentsExtended = new CommentsExtended(this.comments.ThreadData);
26905
+ if (this.comments.CommentIdsData) this.commentsIds = new CommentsIds(this.comments.CommentIdsData);
26814
26906
  this.fileRelationships = new Relationships();
26815
26907
  this.customProperties = new CustomProperties((_options$customProper = options.customProperties) !== null && _options$customProper !== void 0 ? _options$customProper : []);
26816
26908
  this.appProperties = new AppProperties();
@@ -26909,6 +27001,10 @@ MAX: 9026 };
26909
27001
  this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++, "http://schemas.microsoft.com/office/2011/relationships/commentsExtended", "commentsExtended.xml");
26910
27002
  this.contentTypes.addCommentsExtended();
26911
27003
  }
27004
+ if (this.commentsIds) {
27005
+ this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++, "http://schemas.microsoft.com/office/2016/09/relationships/commentsIds", "commentsIds.xml");
27006
+ this.contentTypes.addCommentsIds();
27007
+ }
26912
27008
  }
26913
27009
  get Document() {
26914
27010
  return this.documentWrapper;
@@ -26959,6 +27055,10 @@ MAX: 9026 };
26959
27055
  get CommentsExtended() {
26960
27056
  return this.commentsExtended;
26961
27057
  }
27058
+ /** Durable comment id part. Undefined when no comment carries a durableId. */
27059
+ get CommentsIds() {
27060
+ return this.commentsIds;
27061
+ }
26962
27062
  get FontTable() {
26963
27063
  return this.fontWrapper;
26964
27064
  }
@@ -27128,7 +27228,7 @@ MAX: 9026 };
27128
27228
  }
27129
27229
  };
27130
27230
  //#endregion
27131
- //#region \0@oxc-project+runtime@0.132.0/helpers/objectWithoutPropertiesLoose.js
27231
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectWithoutPropertiesLoose.js
27132
27232
  function _objectWithoutPropertiesLoose(r, e) {
27133
27233
  if (null == r) return {};
27134
27234
  var t = {};
@@ -27139,7 +27239,7 @@ MAX: 9026 };
27139
27239
  return t;
27140
27240
  }
27141
27241
  //#endregion
27142
- //#region \0@oxc-project+runtime@0.132.0/helpers/objectWithoutProperties.js
27242
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectWithoutProperties.js
27143
27243
  function _objectWithoutProperties(e, t) {
27144
27244
  if (null == e) return {};
27145
27245
  var o, r, i = _objectWithoutPropertiesLoose(e, t);
@@ -31535,7 +31635,7 @@ while (n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[+
31535
31635
  const documentMediaDatas = this.imageReplacer.getMediaData(documentXmlData, file.Media);
31536
31636
  const commentMediaDatas = this.imageReplacer.getMediaData(commentXmlData, file.Media);
31537
31637
  const footnoteMediaDatas = this.imageReplacer.getMediaData(footnoteXmlData, file.Media);
31538
- return _objectSpread2(_objectSpread2({
31638
+ return _objectSpread2(_objectSpread2(_objectSpread2({
31539
31639
  Relationships: {
31540
31640
  data: (() => {
31541
31641
  documentMediaDatas.forEach((mediaData, i) => {
@@ -31836,6 +31936,22 @@ while (n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[+
31836
31936
  }
31837
31937
  }),
31838
31938
  path: "word/commentsExtended.xml"
31939
+ } } : {}), file.CommentsIds ? { CommentsIds: {
31940
+ data: (0, import_xml.default)(this.formatter.format(file.CommentsIds, {
31941
+ viewWrapper: {
31942
+ View: file.CommentsIds,
31943
+ Relationships: file.Comments.Relationships
31944
+ },
31945
+ file,
31946
+ stack: []
31947
+ }), {
31948
+ indent: prettify,
31949
+ declaration: {
31950
+ standalone: "yes",
31951
+ encoding: "UTF-8"
31952
+ }
31953
+ }),
31954
+ path: "word/commentsIds.xml"
31839
31955
  } } : {}), {}, {
31840
31956
  FontTable: {
31841
31957
  data: (0, import_xml.default)(this.formatter.format(file.FontTable.View, {
@@ -31852,21 +31968,21 @@ while (n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[+
31852
31968
  path: "word/fontTable.xml"
31853
31969
  },
31854
31970
  FontTableRelationships: {
31855
- data: (0, import_xml.default)(this.formatter.format(file.FontTable.Relationships, {
31971
+ data: (() => (0, import_xml.default)(this.formatter.format(file.FontTable.Relationships, {
31856
31972
  viewWrapper: file.Document,
31857
31973
  file,
31858
31974
  stack: []
31859
31975
  }), {
31860
31976
  indent: prettify,
31861
31977
  declaration: { encoding: "UTF-8" }
31862
- }),
31978
+ }))(),
31863
31979
  path: "word/_rels/fontTable.xml.rels"
31864
31980
  }
31865
31981
  });
31866
31982
  }
31867
31983
  };
31868
31984
  //#endregion
31869
- //#region \0@oxc-project+runtime@0.132.0/helpers/asyncToGenerator.js
31985
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/asyncToGenerator.js
31870
31986
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
31871
31987
  try {
31872
31988
  var i = n[a](c), u = i.value;
@@ -32892,6 +33008,7 @@ while (n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[+
32892
33008
  exports.CommentReference = CommentReference;
32893
33009
  exports.Comments = Comments;
32894
33010
  exports.CommentsExtended = CommentsExtended;
33011
+ exports.CommentsIds = CommentsIds;
32895
33012
  exports.ConcreteHyperlink = ConcreteHyperlink;
32896
33013
  exports.ConcreteNumbering = ConcreteNumbering;
32897
33014
  exports.ContinuationSeparator = ContinuationSeparator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx",
3
- "version": "9.7.1",
3
+ "version": "9.7.2",
4
4
  "description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
5
5
  "type": "module",
6
6
  "main": "dist/index.umd.cjs",
@@ -61,7 +61,7 @@
61
61
  "@types/node": "^25.2.3",
62
62
  "hash.js": "^1.1.7",
63
63
  "jszip": "^3.10.1",
64
- "nanoid": "^5.1.3",
64
+ "nanoid": "^6.0.1",
65
65
  "xml": "^1.0.1",
66
66
  "xml-js": "^1.6.8"
67
67
  },
@@ -72,6 +72,7 @@
72
72
  },
73
73
  "homepage": "https://docx.js.org",
74
74
  "devDependencies": {
75
+ "@eslint/js": "^10.0.1",
75
76
  "@microsoft/api-extractor": "^7.58.7",
76
77
  "@types/inquirer": "^9.0.3",
77
78
  "@types/unzipper": "^0.10.4",
@@ -81,17 +82,18 @@
81
82
  "@vitest/coverage-v8": "^4.1.7",
82
83
  "@vitest/ui": "^4.1.7",
83
84
  "cspell": "^10.0.0",
84
- "docsify-cli": "^4.3.0",
85
- "eslint": "^9.13.0",
85
+ "docsify-cli": "^5.0.0",
86
+ "eslint": "^10.11.0",
86
87
  "eslint-import-resolver-typescript": "^4.3.2",
87
88
  "eslint-plugin-functional": "^9.0.3",
88
- "eslint-plugin-import": "^2.26.0",
89
+ "eslint-plugin-import-x": "^4.17.1",
89
90
  "eslint-plugin-jsdoc": "^63.0.0",
90
91
  "eslint-plugin-no-null": "^1.0.2",
91
92
  "eslint-plugin-prefer-arrow": "^1.2.3",
92
93
  "eslint-plugin-unicorn": "^64.0.0",
93
94
  "execa": "^9.4.0",
94
95
  "glob": "^13.0.3",
96
+ "globals": "^17.12.0",
95
97
  "inquirer": "^14.0.0",
96
98
  "jiti": "^2.3.3",
97
99
  "jsdom": "^29.0.0",