@adeu/core 1.7.1 → 1.7.4

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
@@ -49,7 +49,7 @@ __export(index_exports, {
49
49
  module.exports = __toCommonJS(index_exports);
50
50
 
51
51
  // src/docx/bridge.ts
52
- var import_jszip = __toESM(require("jszip"), 1);
52
+ var import_fflate = require("fflate");
53
53
 
54
54
  // src/docx/dom.ts
55
55
  var import_xmldom = require("@xmldom/xmldom");
@@ -158,10 +158,10 @@ var Part = class {
158
158
  }
159
159
  };
160
160
  var DocxPackage = class {
161
- constructor(zip) {
162
- this.zip = zip;
161
+ constructor(unzipped) {
162
+ this.unzipped = unzipped;
163
163
  }
164
- zip;
164
+ unzipped;
165
165
  parts = [];
166
166
  mainDocumentPart;
167
167
  getPartByPath(path) {
@@ -236,20 +236,21 @@ var DocumentObject = class _DocumentObject {
236
236
  * Main entrypoint for loading a DOCX buffer into the DOM wrapper.
237
237
  */
238
238
  static async load(buffer) {
239
- const zip = await import_jszip.default.loadAsync(buffer);
240
- const pkg = new DocxPackage(zip);
241
- const ctFile = zip.file("[Content_Types].xml");
239
+ const u8 = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
240
+ const unzipped = (0, import_fflate.unzipSync)(u8);
241
+ const pkg = new DocxPackage(unzipped);
242
+ const ctFile = unzipped["[Content_Types].xml"];
242
243
  let contentTypes = {};
243
244
  if (ctFile) {
244
- const ctXml = parseXml(await ctFile.async("text"));
245
+ const ctXml = parseXml((0, import_fflate.strFromU8)(ctFile));
245
246
  const overrides = findAllDescendants(ctXml.documentElement, "Override");
246
247
  for (const override of overrides) {
247
248
  contentTypes[override.getAttribute("PartName") || ""] = override.getAttribute("ContentType") || "";
248
249
  }
249
250
  }
250
- for (const [path, file] of Object.entries(zip.files)) {
251
- if (!file.dir && (path.endsWith(".xml") || path.endsWith(".rels"))) {
252
- const text = await file.async("text");
251
+ for (const [path, fileData] of Object.entries(unzipped)) {
252
+ if (path.endsWith(".xml") || path.endsWith(".rels")) {
253
+ const text = (0, import_fflate.strFromU8)(fileData);
253
254
  const doc = parseXml(text);
254
255
  const cType = contentTypes["/" + path] || "application/xml";
255
256
  const part = new Part("/" + path, text, doc.documentElement, cType);
@@ -302,9 +303,9 @@ var DocumentObject = class _DocumentObject {
302
303
  if (!xmlStr.startsWith("<?xml")) {
303
304
  xmlStr = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n' + xmlStr;
304
305
  }
305
- this.pkg.zip.file(part.partname.substring(1), xmlStr);
306
+ this.pkg.unzipped[part.partname.substring(1)] = (0, import_fflate.strToU8)(xmlStr);
306
307
  }
307
- return this.pkg.zip.generateAsync({ type: "nodebuffer" });
308
+ return Buffer.from((0, import_fflate.zipSync)(this.pkg.unzipped));
308
309
  }
309
310
  };
310
311