js.documents 7.20.30 → 7.20.32

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.
@@ -2,8 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_fonts_obfuscation = require("./obfuscation.cjs");
3
3
  let ooxml_js = require("ooxml.js");
4
4
  //#region src/fonts/ooxml.ts
5
- const OFFICE_DOCUMENT_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
6
- const FONT_TABLE_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable";
5
+ const FONT_TABLE_REL_SUFFIX = "/fontTable";
7
6
  const ROOT_RELS_PART = "_rels/.rels";
8
7
  const DOCX_EMBED_ELEMENTS = [
9
8
  [
@@ -55,17 +54,10 @@ var OoxmlEmbeddedFontError = class extends Error {
55
54
  this.name = "OoxmlEmbeddedFontError";
56
55
  }
57
56
  };
58
- function relatedPartPath(pkg, fromPartPath, relationshipType) {
59
- for (const relationship of (0, ooxml_js.resolveRelationships)(pkg, fromPartPath).values()) if (relationship.type === relationshipType && relationship.targetMode === void 0) return relationship.target;
60
- }
61
57
  function officeDocumentPartPath(pkg) {
62
- const rels = (0, ooxml_js.rootElement)(pkg.parts[ROOT_RELS_PART]);
63
- if (rels !== void 0) for (const relationship of (0, ooxml_js.childrenWithTag)(rels, "Relationship")) {
64
- if ((0, ooxml_js.attr)(relationship, "Type") !== OFFICE_DOCUMENT_RELATIONSHIP || (0, ooxml_js.attr)(relationship, "TargetMode") !== void 0) continue;
65
- const target = (0, ooxml_js.attr)(relationship, "Target");
66
- if (target !== void 0) return target.startsWith("/") ? target.slice(1) : target;
67
- }
68
- throw new OoxmlEmbeddedFontError(`the package declares no officeDocument relationship in ${ROOT_RELS_PART}`);
58
+ const mainPartPath = (0, ooxml_js.findMainPartPath)(pkg);
59
+ if (mainPartPath === void 0) throw new OoxmlEmbeddedFontError(`the package declares no officeDocument relationship in ${ROOT_RELS_PART}`);
60
+ return mainPartPath;
69
61
  }
70
62
  function fontPartBytes(pkg, fromPartPath, relationships, relationshipId) {
71
63
  const relationship = relationships.get(relationshipId);
@@ -89,7 +81,8 @@ function collectFaces(pkg, declaringPartPath, relationships, fontElementChildren
89
81
  }
90
82
  }
91
83
  function extractDocxFonts(pkg) {
92
- const fontTablePath = relatedPartPath(pkg, officeDocumentPartPath(pkg), FONT_TABLE_RELATIONSHIP);
84
+ const documentPartPath = officeDocumentPartPath(pkg);
85
+ const fontTablePath = (0, ooxml_js.findRelatedPartPath)(pkg, documentPartPath, FONT_TABLE_REL_SUFFIX);
93
86
  if (fontTablePath === void 0) return [];
94
87
  const fontTablePart = pkg.parts[fontTablePath];
95
88
  if (fontTablePart?.kind !== "xml") throw new OoxmlEmbeddedFontError(`font table part ${JSON.stringify(fontTablePath)} is missing or is not an XML part`);
@@ -1,8 +1,7 @@
1
1
  import { deobfuscateEmbeddedFont } from "./obfuscation.js";
2
- import { attr, base64ToBytes, childrenWithTag, decodeEntities, resolveRelationships, rootElement } from "ooxml.js";
2
+ import { attr, base64ToBytes, childrenWithTag, decodeEntities, findMainPartPath, findRelatedPartPath, resolveRelationships, rootElement } from "ooxml.js";
3
3
  //#region src/fonts/ooxml.ts
4
- const OFFICE_DOCUMENT_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
5
- const FONT_TABLE_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable";
4
+ const FONT_TABLE_REL_SUFFIX = "/fontTable";
6
5
  const ROOT_RELS_PART = "_rels/.rels";
7
6
  const DOCX_EMBED_ELEMENTS = [
8
7
  [
@@ -54,17 +53,10 @@ var OoxmlEmbeddedFontError = class extends Error {
54
53
  this.name = "OoxmlEmbeddedFontError";
55
54
  }
56
55
  };
57
- function relatedPartPath(pkg, fromPartPath, relationshipType) {
58
- for (const relationship of resolveRelationships(pkg, fromPartPath).values()) if (relationship.type === relationshipType && relationship.targetMode === void 0) return relationship.target;
59
- }
60
56
  function officeDocumentPartPath(pkg) {
61
- const rels = rootElement(pkg.parts[ROOT_RELS_PART]);
62
- if (rels !== void 0) for (const relationship of childrenWithTag(rels, "Relationship")) {
63
- if (attr(relationship, "Type") !== OFFICE_DOCUMENT_RELATIONSHIP || attr(relationship, "TargetMode") !== void 0) continue;
64
- const target = attr(relationship, "Target");
65
- if (target !== void 0) return target.startsWith("/") ? target.slice(1) : target;
66
- }
67
- throw new OoxmlEmbeddedFontError(`the package declares no officeDocument relationship in ${ROOT_RELS_PART}`);
57
+ const mainPartPath = findMainPartPath(pkg);
58
+ if (mainPartPath === void 0) throw new OoxmlEmbeddedFontError(`the package declares no officeDocument relationship in ${ROOT_RELS_PART}`);
59
+ return mainPartPath;
68
60
  }
69
61
  function fontPartBytes(pkg, fromPartPath, relationships, relationshipId) {
70
62
  const relationship = relationships.get(relationshipId);
@@ -88,7 +80,8 @@ function collectFaces(pkg, declaringPartPath, relationships, fontElementChildren
88
80
  }
89
81
  }
90
82
  function extractDocxFonts(pkg) {
91
- const fontTablePath = relatedPartPath(pkg, officeDocumentPartPath(pkg), FONT_TABLE_RELATIONSHIP);
83
+ const documentPartPath = officeDocumentPartPath(pkg);
84
+ const fontTablePath = findRelatedPartPath(pkg, documentPartPath, FONT_TABLE_REL_SUFFIX);
92
85
  if (fontTablePath === void 0) return [];
93
86
  const fontTablePart = pkg.parts[fontTablePath];
94
87
  if (fontTablePart?.kind !== "xml") throw new OoxmlEmbeddedFontError(`font table part ${JSON.stringify(fontTablePath)} is missing or is not an XML part`);
@@ -4,12 +4,12 @@ const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs
4
4
  const require_model_formula = require("../../model/formula.cjs");
5
5
  const require_read = require("../../read-pPa9I8MO.cjs");
6
6
  const require_omml_read = require("../../omml/read.cjs");
7
+ const require_ooxml_docx_parts = require("./parts.cjs");
7
8
  const require_model_block_splice = require("../../model/block-splice.cjs");
8
9
  const require_ooxml_docx_vector = require("./vector.cjs");
9
10
  const require_ooxml_docx_formula = require("./formula.cjs");
10
11
  let ooxml_js = require("ooxml.js");
11
12
  //#region src/ooxml/docx/embedded-objects.ts
12
- const DOCUMENT_PART_PATH = "word/document.xml";
13
13
  function isVectorOnlyRun(run, vectors) {
14
14
  const elementChildren = run.children.filter((child) => child.type === "element");
15
15
  if (elementChildren.length !== 1) return false;
@@ -197,7 +197,7 @@ function spliceDocxEmbeddedObjects(sections, bodyChildren, pkg, onMathDiagnostic
197
197
  require_ooxml_docx_formula.collectBodyParagraphs(bodyChildren, paragraphElements);
198
198
  const tableElements = [];
199
199
  require_ooxml_docx_formula.collectBodyTables(bodyChildren, tableElements);
200
- const rels = (0, ooxml_js.resolveRelationships)(pkg, DOCUMENT_PART_PATH);
200
+ const rels = (0, ooxml_js.resolveRelationships)(pkg, require_ooxml_docx_parts.docxMainPartPath(pkg));
201
201
  let paragraphOrdinal = 0;
202
202
  let tableOrdinal = 0;
203
203
  const out = [];
@@ -3,12 +3,12 @@ import { buildDrawingBlock } from "../../model/embedded-drawing.js";
3
3
  import { buildFormulaBlock } from "../../model/formula.js";
4
4
  import { n as decodeLegacyEmbeddedObject } from "../../read--7mUJ4w7.js";
5
5
  import { collectOfficeMathElements, readOfficeMath } from "../../omml/read.js";
6
+ import { docxMainPartPath } from "./parts.js";
6
7
  import { spliceBlocks } from "../../model/block-splice.js";
7
8
  import { collectParagraphVectors } from "./vector.js";
8
9
  import { PARAGRAPH_NON_CONTENT_TAGS, collectBodyParagraphs, collectBodyTables, equationFrame } from "./formula.js";
9
10
  import { attr, base64ToBytes, childrenWithTag, elementsWithTag, resolveRelationships } from "ooxml.js";
10
11
  //#region src/ooxml/docx/embedded-objects.ts
11
- const DOCUMENT_PART_PATH = "word/document.xml";
12
12
  function isVectorOnlyRun(run, vectors) {
13
13
  const elementChildren = run.children.filter((child) => child.type === "element");
14
14
  if (elementChildren.length !== 1) return false;
@@ -196,7 +196,7 @@ function spliceDocxEmbeddedObjects(sections, bodyChildren, pkg, onMathDiagnostic
196
196
  collectBodyParagraphs(bodyChildren, paragraphElements);
197
197
  const tableElements = [];
198
198
  collectBodyTables(bodyChildren, tableElements);
199
- const rels = resolveRelationships(pkg, DOCUMENT_PART_PATH);
199
+ const rels = resolveRelationships(pkg, docxMainPartPath(pkg));
200
200
  let paragraphOrdinal = 0;
201
201
  let tableOrdinal = 0;
202
202
  const out = [];
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let ooxml_js = require("ooxml.js");
3
+ //#region src/ooxml/docx/parts.ts
4
+ const CONVENTIONAL_DOCUMENT_PART_PATH = "word/document.xml";
5
+ function docxMainPartPath(pkg) {
6
+ return (0, ooxml_js.findMainPartPath)(pkg) ?? CONVENTIONAL_DOCUMENT_PART_PATH;
7
+ }
8
+ //#endregion
9
+ exports.docxMainPartPath = docxMainPartPath;
@@ -0,0 +1,5 @@
1
+ import { Package } from "ooxml.js";
2
+ //#region src/ooxml/docx/parts.d.ts
3
+ declare function docxMainPartPath(pkg: Package): string;
4
+ //#endregion
5
+ export { docxMainPartPath };
@@ -0,0 +1,5 @@
1
+ import { Package } from "ooxml.js";
2
+ //#region src/ooxml/docx/parts.d.ts
3
+ declare function docxMainPartPath(pkg: Package): string;
4
+ //#endregion
5
+ export { docxMainPartPath };
@@ -0,0 +1,8 @@
1
+ import { findMainPartPath } from "ooxml.js";
2
+ //#region src/ooxml/docx/parts.ts
3
+ const CONVENTIONAL_DOCUMENT_PART_PATH = "word/document.xml";
4
+ function docxMainPartPath(pkg) {
5
+ return findMainPartPath(pkg) ?? CONVENTIONAL_DOCUMENT_PART_PATH;
6
+ }
7
+ //#endregion
8
+ export { docxMainPartPath };
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_ooxml_docx_parts = require("./parts.cjs");
2
3
  const require_ooxml_docx_embedded_objects = require("./embedded-objects.cjs");
3
4
  let ooxml_js = require("ooxml.js");
4
5
  //#region src/ooxml/docx/read.ts
5
- const DOCUMENT_PART_PATH = "word/document.xml";
6
6
  function documentBody(pkg) {
7
- const root = (0, ooxml_js.rootElement)(pkg.parts[DOCUMENT_PART_PATH]);
7
+ const root = (0, ooxml_js.rootElement)(pkg.parts[require_ooxml_docx_parts.docxMainPartPath(pkg)]);
8
8
  return root === void 0 ? void 0 : (0, ooxml_js.childrenWithTag)(root, "w:body")[0];
9
9
  }
10
10
  function readDocxContent(pkg, options) {
@@ -1,9 +1,9 @@
1
+ import { docxMainPartPath } from "./parts.js";
1
2
  import { spliceDocxEmbeddedObjects } from "./embedded-objects.js";
2
3
  import { childrenWithTag, readDocxContent as readDocxContent$1, rootElement } from "ooxml.js";
3
4
  //#region src/ooxml/docx/read.ts
4
- const DOCUMENT_PART_PATH = "word/document.xml";
5
5
  function documentBody(pkg) {
6
- const root = rootElement(pkg.parts[DOCUMENT_PART_PATH]);
6
+ const root = rootElement(pkg.parts[docxMainPartPath(pkg)]);
7
7
  return root === void 0 ? void 0 : childrenWithTag(root, "w:body")[0];
8
8
  }
9
9
  function readDocxContent(pkg, options) {
@@ -4,13 +4,14 @@ const require_ooxml_pptx_vector = require("./vector.cjs");
4
4
  const require_ooxml_pptx_legacy_embedded = require("./legacy-embedded.cjs");
5
5
  let ooxml_js = require("ooxml.js");
6
6
  //#region src/ooxml/pptx/read.ts
7
- const PRESENTATION_PART = "ppt/presentation.xml";
7
+ const CONVENTIONAL_PRESENTATION_PART = "ppt/presentation.xml";
8
8
  function slidePathsInOrder(pkg) {
9
- const presentationRoot = (0, ooxml_js.rootElement)(pkg.parts[PRESENTATION_PART]);
9
+ const presentationPath = (0, ooxml_js.findMainPartPath)(pkg) ?? CONVENTIONAL_PRESENTATION_PART;
10
+ const presentationRoot = (0, ooxml_js.rootElement)(pkg.parts[presentationPath]);
10
11
  if (presentationRoot === void 0) return [];
11
12
  const sldIdLst = (0, ooxml_js.childrenWithTag)(presentationRoot, "p:sldIdLst")[0];
12
13
  if (sldIdLst === void 0) return [];
13
- const rels = (0, ooxml_js.resolveRelationships)(pkg, PRESENTATION_PART);
14
+ const rels = (0, ooxml_js.resolveRelationships)(pkg, presentationPath);
14
15
  const paths = [];
15
16
  for (const sldId of (0, ooxml_js.childrenWithTag)(sldIdLst, "p:sldId")) {
16
17
  const rId = (0, ooxml_js.attr)(sldId, "r:id");
@@ -1,15 +1,16 @@
1
1
  import { spliceSlideFormulas } from "./formula.js";
2
2
  import { collapseVectorShapeRuns } from "./vector.js";
3
3
  import { spliceSlideLegacyEmbeddedObjects } from "./legacy-embedded.js";
4
- import { attr, childrenWithTag, readPptxContent as readPptxContent$1, resolveRelationships, rootElement } from "ooxml.js";
4
+ import { attr, childrenWithTag, findMainPartPath, readPptxContent as readPptxContent$1, resolveRelationships, rootElement } from "ooxml.js";
5
5
  //#region src/ooxml/pptx/read.ts
6
- const PRESENTATION_PART = "ppt/presentation.xml";
6
+ const CONVENTIONAL_PRESENTATION_PART = "ppt/presentation.xml";
7
7
  function slidePathsInOrder(pkg) {
8
- const presentationRoot = rootElement(pkg.parts[PRESENTATION_PART]);
8
+ const presentationPath = findMainPartPath(pkg) ?? CONVENTIONAL_PRESENTATION_PART;
9
+ const presentationRoot = rootElement(pkg.parts[presentationPath]);
9
10
  if (presentationRoot === void 0) return [];
10
11
  const sldIdLst = childrenWithTag(presentationRoot, "p:sldIdLst")[0];
11
12
  if (sldIdLst === void 0) return [];
12
- const rels = resolveRelationships(pkg, PRESENTATION_PART);
13
+ const rels = resolveRelationships(pkg, presentationPath);
13
14
  const paths = [];
14
15
  for (const sldId of childrenWithTag(sldIdLst, "p:sldId")) {
15
16
  const rId = attr(sldId, "r:id");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "7.20.30",
3
+ "version": "7.20.32",
4
4
  "description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -78,20 +78,20 @@
78
78
  "license": "MIT",
79
79
  "dependencies": {
80
80
  "archive-codec": "1.11.6",
81
- "byte-codec": "1.6.1",
82
- "doc-codec": "2.12.4",
81
+ "byte-codec": "1.6.2",
82
+ "doc-codec": "3.0.0",
83
83
  "document-schema.js": "7.11.4",
84
- "epub-codec": "1.5.8",
84
+ "epub-codec": "2.0.0",
85
85
  "fflate": "0.8.3",
86
- "markdown-codec": "6.7.6",
87
- "odf.js": "7.25.7",
88
- "ooxml.js": "8.14.11",
89
- "pdf-codec": "4.8.17",
90
- "ppt-codec": "1.7.13",
91
- "rtf-codec": "4.4.7",
86
+ "markdown-codec": "7.0.0",
87
+ "odf.js": "8.0.0",
88
+ "ooxml.js": "9.1.0",
89
+ "pdf-codec": "5.0.0",
90
+ "ppt-codec": "2.0.0",
91
+ "rtf-codec": "5.0.0",
92
92
  "temml": "0.13.4",
93
- "wpd-codec": "3.5.8",
94
- "xls-codec": "4.15.10",
93
+ "wpd-codec": "4.0.0",
94
+ "xls-codec": "4.15.11",
95
95
  "zod": "4.4.3"
96
96
  },
97
97
  "devDependencies": {