docx 9.4.0 → 9.4.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.
package/dist/index.cjs CHANGED
@@ -21116,8 +21116,19 @@ const PatchType = {
21116
21116
  PARAGRAPH: "paragraph"
21117
21117
  };
21118
21118
  const imageReplacer = new ImageReplacer();
21119
- const UTF16LE = Buffer.from([255, 254]);
21120
- const UTF16BE = Buffer.from([254, 255]);
21119
+ const UTF16LE = new Uint8Array([255, 254]);
21120
+ const UTF16BE = new Uint8Array([254, 255]);
21121
+ const compareByteArrays = (a, b) => {
21122
+ if (a.length !== b.length) {
21123
+ return false;
21124
+ }
21125
+ for (let i = 0; i < a.length; i++) {
21126
+ if (a[i] !== b[i]) {
21127
+ return false;
21128
+ }
21129
+ }
21130
+ return true;
21131
+ };
21121
21132
  const patchDocument = (_0) => __async(exports, [_0], function* ({
21122
21133
  outputType,
21123
21134
  data,
@@ -21143,7 +21154,7 @@ const patchDocument = (_0) => __async(exports, [_0], function* ({
21143
21154
  for (const [key, value] of Object.entries(zipContent.files)) {
21144
21155
  const binaryValue = yield value.async("uint8array");
21145
21156
  const startBytes = binaryValue.slice(0, 2);
21146
- if (UTF16LE.equals(startBytes) || UTF16BE.equals(startBytes)) {
21157
+ if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
21147
21158
  binaryContentMap.set(key, binaryValue);
21148
21159
  continue;
21149
21160
  }
@@ -21116,8 +21116,19 @@ var __async = (__this, __arguments, generator) => {
21116
21116
  PARAGRAPH: "paragraph"
21117
21117
  };
21118
21118
  const imageReplacer = new ImageReplacer();
21119
- const UTF16LE = Buffer.from([255, 254]);
21120
- const UTF16BE = Buffer.from([254, 255]);
21119
+ const UTF16LE = new Uint8Array([255, 254]);
21120
+ const UTF16BE = new Uint8Array([254, 255]);
21121
+ const compareByteArrays = (a, b) => {
21122
+ if (a.length !== b.length) {
21123
+ return false;
21124
+ }
21125
+ for (let i = 0; i < a.length; i++) {
21126
+ if (a[i] !== b[i]) {
21127
+ return false;
21128
+ }
21129
+ }
21130
+ return true;
21131
+ };
21121
21132
  const patchDocument = (_0) => __async(this, [_0], function* ({
21122
21133
  outputType,
21123
21134
  data,
@@ -21143,7 +21154,7 @@ var __async = (__this, __arguments, generator) => {
21143
21154
  for (const [key, value] of Object.entries(zipContent.files)) {
21144
21155
  const binaryValue = yield value.async("uint8array");
21145
21156
  const startBytes = binaryValue.slice(0, 2);
21146
- if (UTF16LE.equals(startBytes) || UTF16BE.equals(startBytes)) {
21157
+ if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
21147
21158
  binaryContentMap.set(key, binaryValue);
21148
21159
  continue;
21149
21160
  }
package/dist/index.mjs CHANGED
@@ -21114,8 +21114,19 @@ const PatchType = {
21114
21114
  PARAGRAPH: "paragraph"
21115
21115
  };
21116
21116
  const imageReplacer = new ImageReplacer();
21117
- const UTF16LE = Buffer.from([255, 254]);
21118
- const UTF16BE = Buffer.from([254, 255]);
21117
+ const UTF16LE = new Uint8Array([255, 254]);
21118
+ const UTF16BE = new Uint8Array([254, 255]);
21119
+ const compareByteArrays = (a, b) => {
21120
+ if (a.length !== b.length) {
21121
+ return false;
21122
+ }
21123
+ for (let i = 0; i < a.length; i++) {
21124
+ if (a[i] !== b[i]) {
21125
+ return false;
21126
+ }
21127
+ }
21128
+ return true;
21129
+ };
21119
21130
  const patchDocument = (_0) => __async(void 0, [_0], function* ({
21120
21131
  outputType,
21121
21132
  data,
@@ -21141,7 +21152,7 @@ const patchDocument = (_0) => __async(void 0, [_0], function* ({
21141
21152
  for (const [key, value] of Object.entries(zipContent.files)) {
21142
21153
  const binaryValue = yield value.async("uint8array");
21143
21154
  const startBytes = binaryValue.slice(0, 2);
21144
- if (UTF16LE.equals(startBytes) || UTF16BE.equals(startBytes)) {
21155
+ if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
21145
21156
  binaryContentMap.set(key, binaryValue);
21146
21157
  continue;
21147
21158
  }
@@ -21118,8 +21118,19 @@ var __async = (__this, __arguments, generator) => {
21118
21118
  PARAGRAPH: "paragraph"
21119
21119
  };
21120
21120
  const imageReplacer = new ImageReplacer();
21121
- const UTF16LE = Buffer.from([255, 254]);
21122
- const UTF16BE = Buffer.from([254, 255]);
21121
+ const UTF16LE = new Uint8Array([255, 254]);
21122
+ const UTF16BE = new Uint8Array([254, 255]);
21123
+ const compareByteArrays = (a, b) => {
21124
+ if (a.length !== b.length) {
21125
+ return false;
21126
+ }
21127
+ for (let i = 0; i < a.length; i++) {
21128
+ if (a[i] !== b[i]) {
21129
+ return false;
21130
+ }
21131
+ }
21132
+ return true;
21133
+ };
21123
21134
  const patchDocument = (_0) => __async(this, [_0], function* ({
21124
21135
  outputType,
21125
21136
  data,
@@ -21145,7 +21156,7 @@ var __async = (__this, __arguments, generator) => {
21145
21156
  for (const [key, value] of Object.entries(zipContent.files)) {
21146
21157
  const binaryValue = yield value.async("uint8array");
21147
21158
  const startBytes = binaryValue.slice(0, 2);
21148
- if (UTF16LE.equals(startBytes) || UTF16BE.equals(startBytes)) {
21159
+ if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
21149
21160
  binaryContentMap.set(key, binaryValue);
21150
21161
  continue;
21151
21162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docx",
3
- "version": "9.4.0",
3
+ "version": "9.4.1",
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",