odf.js 4.0.3 → 5.0.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.
Files changed (56) hide show
  1. package/README.md +76 -11
  2. package/dist/{codec-FXnmhe15.d.ts → codec-DqldvlN5.d.ts} +8 -8
  3. package/dist/{codec-m4zK5kxz.d.cts → codec-jKlS0rWl.d.cts} +8 -8
  4. package/dist/codec.d.cts +1 -1
  5. package/dist/codec.d.ts +1 -1
  6. package/dist/{form-DcGOX5RW.d.ts → form-BsAAx5-p.d.ts} +1 -1
  7. package/dist/{form-BC-wb1M2.d.cts → form-DSIbHxog.d.cts} +1 -1
  8. package/dist/index.cjs +6 -1
  9. package/dist/index.d.cts +8 -8
  10. package/dist/index.d.ts +8 -8
  11. package/dist/index.js +6 -6
  12. package/dist/read-B4zS8bGb.d.ts +11 -0
  13. package/dist/read-B9zz_ax1.d.ts +11 -0
  14. package/dist/read-BHpPvhzR.d.cts +11 -0
  15. package/dist/read-BM8KaFQS.d.cts +11 -0
  16. package/dist/read-C6MhadqG.d.ts +11 -0
  17. package/dist/read-CszvDMMt.d.cts +11 -0
  18. package/dist/read-DOuXgPhP.d.ts +15 -0
  19. package/dist/read-KpU38maT.d.cts +11 -0
  20. package/dist/read-YSIwlhrk.d.ts +11 -0
  21. package/dist/read-xCmo7cec.d.cts +15 -0
  22. package/dist/typed/formula/read.cjs +11 -6
  23. package/dist/typed/formula/read.d.cts +2 -2
  24. package/dist/typed/formula/read.d.ts +2 -2
  25. package/dist/typed/formula/read.js +10 -6
  26. package/dist/typed/odb/form.cjs +1 -1
  27. package/dist/typed/odb/form.d.cts +1 -1
  28. package/dist/typed/odb/form.d.ts +1 -1
  29. package/dist/typed/odb/form.js +2 -2
  30. package/dist/typed/odg/read.cjs +10 -1
  31. package/dist/typed/odg/read.d.cts +2 -2
  32. package/dist/typed/odg/read.d.ts +2 -2
  33. package/dist/typed/odg/read.js +11 -3
  34. package/dist/typed/odp/read.cjs +10 -1
  35. package/dist/typed/odp/read.d.cts +2 -2
  36. package/dist/typed/odp/read.d.ts +2 -2
  37. package/dist/typed/odp/read.js +11 -3
  38. package/dist/typed/ods/read.cjs +16 -7
  39. package/dist/typed/ods/read.d.cts +2 -2
  40. package/dist/typed/ods/read.d.ts +2 -2
  41. package/dist/typed/ods/read.js +21 -13
  42. package/dist/typed/odt/read.cjs +13 -4
  43. package/dist/typed/odt/read.d.cts +2 -2
  44. package/dist/typed/odt/read.d.ts +2 -2
  45. package/dist/typed/odt/read.js +14 -6
  46. package/package.json +2 -2
  47. package/dist/read-B0aBfNRf.d.ts +0 -10
  48. package/dist/read-BKS_zlGG.d.cts +0 -10
  49. package/dist/read-Bd16x8VD.d.cts +0 -10
  50. package/dist/read-Bleh4LfR.d.ts +0 -14
  51. package/dist/read-C7gT8wtc.d.ts +0 -10
  52. package/dist/read-CxdHrV1m.d.ts +0 -10
  53. package/dist/read-D4DKvOY7.d.cts +0 -10
  54. package/dist/read-DapcRIZV.d.cts +0 -10
  55. package/dist/read-Dn9qyBBs.d.ts +0 -10
  56. package/dist/read-DyR9HfLT.d.cts +0 -14
@@ -1,6 +1,7 @@
1
1
  import { decodeXmlText } from "../../xml/entities.js";
2
2
  import { attrValue, elementsWithTag, rootElement } from "../../xml/query.js";
3
3
  import { readOdfMetadata } from "../shared/metadata.js";
4
+ import { assemblePackage } from "document-schema.js";
4
5
  //#region src/typed/formula/read.ts
5
6
  const CONTENT_PART = "content.xml";
6
7
  const MATH_ROOT_TAGS = ["math", "math:math"];
@@ -27,11 +28,11 @@ function findStarMathAnnotation(mathRoot) {
27
28
  if (text.length > 0) return text;
28
29
  }
29
30
  }
30
- function readOdfFormula(pkg) {
31
+ function readOdfFormulaMathMl(pkg) {
31
32
  const contentPart = pkg.parts[CONTENT_PART];
32
- if (contentPart?.kind !== "xml") throw new Error(`readOdfFormula: package has no ${CONTENT_PART} part`);
33
+ if (contentPart?.kind !== "xml") throw new Error(`readOdfFormulaMathMl: package has no ${CONTENT_PART} part`);
33
34
  const mathRoot = findMathRoot(contentPart.nodes);
34
- if (mathRoot === void 0) throw new Error(`readOdfFormula: ${CONTENT_PART} has no MathML root element`);
35
+ if (mathRoot === void 0) throw new Error(`readOdfFormulaMathMl: ${CONTENT_PART} has no MathML root element`);
35
36
  const metadata = readOdfMetadata(pkg);
36
37
  const starMath = findStarMathAnnotation(mathRoot);
37
38
  return starMath === void 0 ? {
@@ -43,8 +44,8 @@ function readOdfFormula(pkg) {
43
44
  metadata
44
45
  };
45
46
  }
46
- function readOdfFormulaDocument(pkg) {
47
- const { mathml, starMath, metadata } = readOdfFormula(pkg);
47
+ function readOdfFormulaContent(pkg) {
48
+ const { mathml, starMath, metadata } = readOdfFormulaMathMl(pkg);
48
49
  return {
49
50
  kind: "formula",
50
51
  metadata,
@@ -54,5 +55,8 @@ function readOdfFormulaDocument(pkg) {
54
55
  }
55
56
  };
56
57
  }
58
+ function readOdfFormula(pkg) {
59
+ return assemblePackage(readOdfFormulaContent(pkg));
60
+ }
57
61
  //#endregion
58
- export { findMathRoot, readOdfFormula, readOdfFormulaDocument };
62
+ export { findMathRoot, readOdfFormula, readOdfFormulaContent, readOdfFormulaMathMl };
@@ -77,7 +77,7 @@ function readOdbForm(pkg, formName) {
77
77
  return {
78
78
  name: component.name,
79
79
  href: component.href,
80
- document: require_typed_odt_read.readOdt(subPackage),
80
+ document: require_typed_odt_read.readOdtContent(subPackage),
81
81
  forms: readFormDefinitions(require_xml_query.rootElement(contentPart.nodes))
82
82
  };
83
83
  }
@@ -1,2 +1,2 @@
1
- import { i as readOdbForm, n as OdbFormControl, r as OdbFormDefinition, t as OdbForm } from "../../form-BC-wb1M2.cjs";
1
+ import { i as readOdbForm, n as OdbFormControl, r as OdbFormDefinition, t as OdbForm } from "../../form-DSIbHxog.cjs";
2
2
  export { OdbForm, OdbFormControl, OdbFormDefinition, readOdbForm };
@@ -1,2 +1,2 @@
1
- import { i as readOdbForm, n as OdbFormControl, r as OdbFormDefinition, t as OdbForm } from "../../form-DcGOX5RW.js";
1
+ import { i as readOdbForm, n as OdbFormControl, r as OdbFormDefinition, t as OdbForm } from "../../form-BsAAx5-p.js";
2
2
  export { OdbForm, OdbFormControl, OdbFormDefinition, readOdbForm };
@@ -1,7 +1,7 @@
1
1
  import { decodeXmlText } from "../../xml/entities.js";
2
2
  import { attrValue, findChildElement, rootElement } from "../../xml/query.js";
3
3
  import { subDocumentPackage } from "./subdocument.js";
4
- import { readOdt } from "../odt/read.js";
4
+ import { readOdtContent } from "../odt/read.js";
5
5
  import { resolveOdbComponent } from "./read.js";
6
6
  //#region src/typed/odb/form.ts
7
7
  const CONTENT_PART = "content.xml";
@@ -76,7 +76,7 @@ function readOdbForm(pkg, formName) {
76
76
  return {
77
77
  name: component.name,
78
78
  href: component.href,
79
- document: readOdt(subPackage),
79
+ document: readOdtContent(subPackage),
80
80
  forms: readFormDefinitions(rootElement(contentPart.nodes))
81
81
  };
82
82
  }
@@ -15,7 +15,7 @@ function readPage(page, pkg) {
15
15
  vectors
16
16
  };
17
17
  }
18
- function readOdg(pkg) {
18
+ function readOdgContent(pkg) {
19
19
  const contentPart = pkg.parts[CONTENT_PART];
20
20
  const root = contentPart?.kind === "xml" ? require_xml_query.rootElement(contentPart.nodes) : void 0;
21
21
  const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
@@ -26,5 +26,14 @@ function readOdg(pkg) {
26
26
  pages: pages.map((page) => readPage(page, pkg))
27
27
  };
28
28
  }
29
+ function readOdg(pkg) {
30
+ const { metadata, pages } = readOdgContent(pkg);
31
+ return (0, document_schema_js.assemblePackage)({
32
+ kind: "drawing",
33
+ metadata,
34
+ pages
35
+ });
36
+ }
29
37
  //#endregion
30
38
  exports.readOdg = readOdg;
39
+ exports.readOdgContent = readOdgContent;
@@ -1,2 +1,2 @@
1
- import { n as readOdg, t as OdgDocument } from "../../read-DapcRIZV.cjs";
2
- export { OdgDocument, readOdg };
1
+ import { n as readOdg, r as readOdgContent, t as OdgDocument } from "../../read-BM8KaFQS.cjs";
2
+ export { OdgDocument, readOdg, readOdgContent };
@@ -1,2 +1,2 @@
1
- import { n as readOdg, t as OdgDocument } from "../../read-C7gT8wtc.js";
2
- export { OdgDocument, readOdg };
1
+ import { n as readOdg, r as readOdgContent, t as OdgDocument } from "../../read-B9zz_ax1.js";
2
+ export { OdgDocument, readOdg, readOdgContent };
@@ -2,7 +2,7 @@ import { childrenWithTag, findChildElement, rootElement } from "../../xml/query.
2
2
  import { readOdfMetadata } from "../shared/metadata.js";
3
3
  import { resolveDrawPageSize } from "../shared/masterpage.js";
4
4
  import { readDrawPageContent } from "../draw/shapes.js";
5
- import { PAGE_SIZE_A4 } from "document-schema.js";
5
+ import { PAGE_SIZE_A4, assemblePackage } from "document-schema.js";
6
6
  //#region src/typed/odg/read.ts
7
7
  const CONTENT_PART = "content.xml";
8
8
  function readPage(page, pkg) {
@@ -14,7 +14,7 @@ function readPage(page, pkg) {
14
14
  vectors
15
15
  };
16
16
  }
17
- function readOdg(pkg) {
17
+ function readOdgContent(pkg) {
18
18
  const contentPart = pkg.parts[CONTENT_PART];
19
19
  const root = contentPart?.kind === "xml" ? rootElement(contentPart.nodes) : void 0;
20
20
  const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
@@ -25,5 +25,13 @@ function readOdg(pkg) {
25
25
  pages: pages.map((page) => readPage(page, pkg))
26
26
  };
27
27
  }
28
+ function readOdg(pkg) {
29
+ const { metadata, pages } = readOdgContent(pkg);
30
+ return assemblePackage({
31
+ kind: "drawing",
32
+ metadata,
33
+ pages
34
+ });
35
+ }
28
36
  //#endregion
29
- export { readOdg };
37
+ export { readOdg, readOdgContent };
@@ -24,7 +24,7 @@ function readSlide(page, pkg, listIdState) {
24
24
  notes: readSlideNotes(page)
25
25
  };
26
26
  }
27
- function readOdp(pkg) {
27
+ function readOdpContent(pkg) {
28
28
  const contentPart = pkg.parts[CONTENT_PART];
29
29
  const root = contentPart?.kind === "xml" ? require_xml_query.rootElement(contentPart.nodes) : void 0;
30
30
  const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
@@ -36,5 +36,14 @@ function readOdp(pkg) {
36
36
  slides: pages.map((page) => readSlide(page, pkg, listIdState))
37
37
  };
38
38
  }
39
+ function readOdp(pkg) {
40
+ const { metadata, slides } = readOdpContent(pkg);
41
+ return (0, document_schema_js.assemblePackage)({
42
+ kind: "presentation",
43
+ metadata,
44
+ slides
45
+ });
46
+ }
39
47
  //#endregion
40
48
  exports.readOdp = readOdp;
49
+ exports.readOdpContent = readOdpContent;
@@ -1,2 +1,2 @@
1
- import { n as readOdp, t as OdpDocument } from "../../read-Bd16x8VD.cjs";
2
- export { OdpDocument, readOdp };
1
+ import { n as readOdp, r as readOdpContent, t as OdpDocument } from "../../read-KpU38maT.cjs";
2
+ export { OdpDocument, readOdp, readOdpContent };
@@ -1,2 +1,2 @@
1
- import { n as readOdp, t as OdpDocument } from "../../read-CxdHrV1m.js";
2
- export { OdpDocument, readOdp };
1
+ import { n as readOdp, r as readOdpContent, t as OdpDocument } from "../../read-YSIwlhrk.js";
2
+ export { OdpDocument, readOdp, readOdpContent };
@@ -3,7 +3,7 @@ import { decodeOdfText } from "../shared/text.js";
3
3
  import { readOdfMetadata } from "../shared/metadata.js";
4
4
  import { resolveDrawPageSize } from "../shared/masterpage.js";
5
5
  import { walkDrawShapes } from "../draw/shapes.js";
6
- import { SLIDE_SIZE_WIDESCREEN } from "document-schema.js";
6
+ import { SLIDE_SIZE_WIDESCREEN, assemblePackage } from "document-schema.js";
7
7
  //#region src/typed/odp/read.ts
8
8
  const CONTENT_PART = "content.xml";
9
9
  function readSlideSize(page, pkg) {
@@ -23,7 +23,7 @@ function readSlide(page, pkg, listIdState) {
23
23
  notes: readSlideNotes(page)
24
24
  };
25
25
  }
26
- function readOdp(pkg) {
26
+ function readOdpContent(pkg) {
27
27
  const contentPart = pkg.parts[CONTENT_PART];
28
28
  const root = contentPart?.kind === "xml" ? rootElement(contentPart.nodes) : void 0;
29
29
  const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
@@ -35,5 +35,13 @@ function readOdp(pkg) {
35
35
  slides: pages.map((page) => readSlide(page, pkg, listIdState))
36
36
  };
37
37
  }
38
+ function readOdp(pkg) {
39
+ const { metadata, slides } = readOdpContent(pkg);
40
+ return assemblePackage({
41
+ kind: "presentation",
42
+ metadata,
43
+ slides
44
+ });
45
+ }
38
46
  //#endregion
39
- export { readOdp };
47
+ export { readOdp, readOdpContent };
@@ -20,7 +20,7 @@ let document_schema_js = require("document-schema.js");
20
20
  const CONTENT_PART = "content.xml";
21
21
  function parseKnownOdfLength(value) {
22
22
  const parsed = require_typed_shared_units.parseOdfLength(value);
23
- if (parsed === void 0) throw new Error(`readOds: internal error -- "${value}" is not a valid ODF length literal`);
23
+ if (parsed === void 0) throw new Error(`readOdsContent: internal error -- "${value}" is not a valid ODF length literal`);
24
24
  return parsed;
25
25
  }
26
26
  const DEFAULT_MARGIN_PT = parseKnownOdfLength("2cm");
@@ -168,7 +168,7 @@ function parseNonNegativeInteger(value) {
168
168
  function readEmbeddedObjectDocument(reference) {
169
169
  switch (reference.objectKind) {
170
170
  case "wordprocessing": {
171
- const { metadata, sections } = require_typed_odt_read.readOdt(reference.package);
171
+ const { metadata, sections } = require_typed_odt_read.readOdtContent(reference.package);
172
172
  return {
173
173
  kind: "wordprocessing",
174
174
  metadata,
@@ -176,7 +176,7 @@ function readEmbeddedObjectDocument(reference) {
176
176
  };
177
177
  }
178
178
  case "presentation": {
179
- const { metadata, slides } = require_typed_odp_read.readOdp(reference.package);
179
+ const { metadata, slides } = require_typed_odp_read.readOdpContent(reference.package);
180
180
  return {
181
181
  kind: "presentation",
182
182
  metadata,
@@ -184,7 +184,7 @@ function readEmbeddedObjectDocument(reference) {
184
184
  };
185
185
  }
186
186
  case "drawing": {
187
- const { metadata, pages } = require_typed_odg_read.readOdg(reference.package);
187
+ const { metadata, pages } = require_typed_odg_read.readOdgContent(reference.package);
188
188
  return {
189
189
  kind: "drawing",
190
190
  metadata,
@@ -192,14 +192,14 @@ function readEmbeddedObjectDocument(reference) {
192
192
  };
193
193
  }
194
194
  case "spreadsheet": {
195
- const { metadata, sheets } = readOds(reference.package);
195
+ const { metadata, sheets } = readOdsContent(reference.package);
196
196
  return {
197
197
  kind: "spreadsheet",
198
198
  metadata,
199
199
  sheets
200
200
  };
201
201
  }
202
- case "formula": return require_typed_formula_read.readOdfFormulaDocument(reference.package);
202
+ case "formula": return require_typed_formula_read.readOdfFormulaContent(reference.package);
203
203
  }
204
204
  }
205
205
  function collectAnchoredFrame(frameElement, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
@@ -396,7 +396,7 @@ function readSheet(tableElement, pkg) {
396
396
  if (embeddedObjects.length > 0) sheet.embeddedObjects = embeddedObjects;
397
397
  return sheet;
398
398
  }
399
- function readOds(pkg) {
399
+ function readOdsContent(pkg) {
400
400
  const contentPart = pkg.parts[CONTENT_PART];
401
401
  const root = contentPart?.kind === "xml" ? require_xml_query.rootElement(contentPart.nodes) : void 0;
402
402
  const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
@@ -412,5 +412,14 @@ function readOds(pkg) {
412
412
  sheets
413
413
  };
414
414
  }
415
+ function readOds(pkg) {
416
+ const { metadata, sheets } = readOdsContent(pkg);
417
+ return (0, document_schema_js.assemblePackage)({
418
+ kind: "spreadsheet",
419
+ metadata,
420
+ sheets
421
+ });
422
+ }
415
423
  //#endregion
416
424
  exports.readOds = readOds;
425
+ exports.readOdsContent = readOdsContent;
@@ -1,2 +1,2 @@
1
- import { n as readOds, t as OdsDocument } from "../../read-D4DKvOY7.cjs";
2
- export { OdsDocument, readOds };
1
+ import { n as readOds, r as readOdsContent, t as OdsDocument } from "../../read-BHpPvhzR.cjs";
2
+ export { OdsDocument, readOds, readOdsContent };
@@ -1,2 +1,2 @@
1
- import { n as readOds, t as OdsDocument } from "../../read-B0aBfNRf.js";
2
- export { OdsDocument, readOds };
1
+ import { n as readOds, r as readOdsContent, t as OdsDocument } from "../../read-B4zS8bGb.js";
2
+ export { OdsDocument, readOds, readOdsContent };
@@ -9,17 +9,17 @@ import { readCellStyleDecoration } from "../shared/table.js";
9
9
  import { parseOdfTransform } from "../shared/transform.js";
10
10
  import { resolvePageLayoutProperties } from "../shared/masterpage.js";
11
11
  import { readDrawFrame } from "../draw/shapes.js";
12
- import { readOdfFormulaDocument } from "../formula/read.js";
12
+ import { readOdfFormulaContent } from "../formula/read.js";
13
13
  import { readDrawObjectReference } from "../draw/embedded.js";
14
- import { readOdp } from "../odp/read.js";
15
- import { readOdt } from "../odt/read.js";
16
- import { readOdg } from "../odg/read.js";
17
- import { PAGE_SIZE_A4 } from "document-schema.js";
14
+ import { readOdpContent } from "../odp/read.js";
15
+ import { readOdtContent } from "../odt/read.js";
16
+ import { readOdgContent } from "../odg/read.js";
17
+ import { PAGE_SIZE_A4, assemblePackage } from "document-schema.js";
18
18
  //#region src/typed/ods/read.ts
19
19
  const CONTENT_PART = "content.xml";
20
20
  function parseKnownOdfLength(value) {
21
21
  const parsed = parseOdfLength(value);
22
- if (parsed === void 0) throw new Error(`readOds: internal error -- "${value}" is not a valid ODF length literal`);
22
+ if (parsed === void 0) throw new Error(`readOdsContent: internal error -- "${value}" is not a valid ODF length literal`);
23
23
  return parsed;
24
24
  }
25
25
  const DEFAULT_MARGIN_PT = parseKnownOdfLength("2cm");
@@ -167,7 +167,7 @@ function parseNonNegativeInteger(value) {
167
167
  function readEmbeddedObjectDocument(reference) {
168
168
  switch (reference.objectKind) {
169
169
  case "wordprocessing": {
170
- const { metadata, sections } = readOdt(reference.package);
170
+ const { metadata, sections } = readOdtContent(reference.package);
171
171
  return {
172
172
  kind: "wordprocessing",
173
173
  metadata,
@@ -175,7 +175,7 @@ function readEmbeddedObjectDocument(reference) {
175
175
  };
176
176
  }
177
177
  case "presentation": {
178
- const { metadata, slides } = readOdp(reference.package);
178
+ const { metadata, slides } = readOdpContent(reference.package);
179
179
  return {
180
180
  kind: "presentation",
181
181
  metadata,
@@ -183,7 +183,7 @@ function readEmbeddedObjectDocument(reference) {
183
183
  };
184
184
  }
185
185
  case "drawing": {
186
- const { metadata, pages } = readOdg(reference.package);
186
+ const { metadata, pages } = readOdgContent(reference.package);
187
187
  return {
188
188
  kind: "drawing",
189
189
  metadata,
@@ -191,14 +191,14 @@ function readEmbeddedObjectDocument(reference) {
191
191
  };
192
192
  }
193
193
  case "spreadsheet": {
194
- const { metadata, sheets } = readOds(reference.package);
194
+ const { metadata, sheets } = readOdsContent(reference.package);
195
195
  return {
196
196
  kind: "spreadsheet",
197
197
  metadata,
198
198
  sheets
199
199
  };
200
200
  }
201
- case "formula": return readOdfFormulaDocument(reference.package);
201
+ case "formula": return readOdfFormulaContent(reference.package);
202
202
  }
203
203
  }
204
204
  function collectAnchoredFrame(frameElement, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
@@ -395,7 +395,7 @@ function readSheet(tableElement, pkg) {
395
395
  if (embeddedObjects.length > 0) sheet.embeddedObjects = embeddedObjects;
396
396
  return sheet;
397
397
  }
398
- function readOds(pkg) {
398
+ function readOdsContent(pkg) {
399
399
  const contentPart = pkg.parts[CONTENT_PART];
400
400
  const root = contentPart?.kind === "xml" ? rootElement(contentPart.nodes) : void 0;
401
401
  const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
@@ -411,5 +411,13 @@ function readOds(pkg) {
411
411
  sheets
412
412
  };
413
413
  }
414
+ function readOds(pkg) {
415
+ const { metadata, sheets } = readOdsContent(pkg);
416
+ return assemblePackage({
417
+ kind: "spreadsheet",
418
+ metadata,
419
+ sheets
420
+ });
421
+ }
414
422
  //#endregion
415
- export { readOds };
423
+ export { readOds, readOdsContent };
@@ -44,7 +44,7 @@ function readBlocks(nodes, pkg, listIdState) {
44
44
  }
45
45
  function parseKnownOdfLength(value) {
46
46
  const parsed = require_typed_shared_units.parseOdfLength(value);
47
- if (parsed === void 0) throw new Error(`readOdt: internal error -- "${value}" is not a valid ODF length literal`);
47
+ if (parsed === void 0) throw new Error(`readOdtContent: internal error -- "${value}" is not a valid ODF length literal`);
48
48
  return parsed;
49
49
  }
50
50
  const DEFAULT_MARGIN_PT = parseKnownOdfLength("2cm");
@@ -80,13 +80,13 @@ function readFirstMasterPageGeometry(pkg) {
80
80
  margins: margins ?? DEFAULT_MARGINS
81
81
  };
82
82
  }
83
- function readOdt(pkg) {
83
+ function readOdtContent(pkg) {
84
84
  const contentPart = pkg.parts[CONTENT_PART];
85
- if (contentPart?.kind !== "xml") throw new Error(`readOdt: package has no ${CONTENT_PART} part`);
85
+ if (contentPart?.kind !== "xml") throw new Error(`readOdtContent: package has no ${CONTENT_PART} part`);
86
86
  const contentRoot = require_xml_query.rootElement(contentPart.nodes);
87
87
  const body = contentRoot === void 0 ? void 0 : require_xml_query.findChildElement(contentRoot.children, "office:body");
88
88
  const textElement = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:text");
89
- if (textElement === void 0) throw new Error(`readOdt: ${CONTENT_PART} has no office:body/office:text element`);
89
+ if (textElement === void 0) throw new Error(`readOdtContent: ${CONTENT_PART} has no office:body/office:text element`);
90
90
  const metadata = require_typed_shared_metadata.readOdfMetadata(pkg);
91
91
  const { pageSize, margins } = readFirstMasterPageGeometry(pkg);
92
92
  return {
@@ -98,5 +98,14 @@ function readOdt(pkg) {
98
98
  }]
99
99
  };
100
100
  }
101
+ function readOdt(pkg) {
102
+ const { metadata, sections } = readOdtContent(pkg);
103
+ return (0, document_schema_js.assemblePackage)({
104
+ kind: "wordprocessing",
105
+ metadata,
106
+ sections
107
+ });
108
+ }
101
109
  //#endregion
102
110
  exports.readOdt = readOdt;
111
+ exports.readOdtContent = readOdtContent;
@@ -1,2 +1,2 @@
1
- import { n as readOdt, t as OdtDocument } from "../../read-BKS_zlGG.cjs";
2
- export { OdtDocument, readOdt };
1
+ import { n as readOdt, r as readOdtContent, t as OdtDocument } from "../../read-CszvDMMt.cjs";
2
+ export { OdtDocument, readOdt, readOdtContent };
@@ -1,2 +1,2 @@
1
- import { n as readOdt, t as OdtDocument } from "../../read-Dn9qyBBs.js";
2
- export { OdtDocument, readOdt };
1
+ import { n as readOdt, r as readOdtContent, t as OdtDocument } from "../../read-C6MhadqG.js";
2
+ export { OdtDocument, readOdt, readOdtContent };
@@ -5,7 +5,7 @@ import { readOdfMetadata } from "../shared/metadata.js";
5
5
  import { readOdfParagraph } from "../shared/paragraph.js";
6
6
  import { mintOdfListNumId, readOdfListParagraphs } from "../shared/list.js";
7
7
  import { readOdfTable } from "../shared/table.js";
8
- import { PAGE_SIZE_A4 } from "document-schema.js";
8
+ import { PAGE_SIZE_A4, assemblePackage } from "document-schema.js";
9
9
  //#region src/typed/odt/read.ts
10
10
  const CONTENT_PART = "content.xml";
11
11
  const STYLES_PART = "styles.xml";
@@ -43,7 +43,7 @@ function readBlocks(nodes, pkg, listIdState) {
43
43
  }
44
44
  function parseKnownOdfLength(value) {
45
45
  const parsed = parseOdfLength(value);
46
- if (parsed === void 0) throw new Error(`readOdt: internal error -- "${value}" is not a valid ODF length literal`);
46
+ if (parsed === void 0) throw new Error(`readOdtContent: internal error -- "${value}" is not a valid ODF length literal`);
47
47
  return parsed;
48
48
  }
49
49
  const DEFAULT_MARGIN_PT = parseKnownOdfLength("2cm");
@@ -79,13 +79,13 @@ function readFirstMasterPageGeometry(pkg) {
79
79
  margins: margins ?? DEFAULT_MARGINS
80
80
  };
81
81
  }
82
- function readOdt(pkg) {
82
+ function readOdtContent(pkg) {
83
83
  const contentPart = pkg.parts[CONTENT_PART];
84
- if (contentPart?.kind !== "xml") throw new Error(`readOdt: package has no ${CONTENT_PART} part`);
84
+ if (contentPart?.kind !== "xml") throw new Error(`readOdtContent: package has no ${CONTENT_PART} part`);
85
85
  const contentRoot = rootElement(contentPart.nodes);
86
86
  const body = contentRoot === void 0 ? void 0 : findChildElement(contentRoot.children, "office:body");
87
87
  const textElement = body === void 0 ? void 0 : findChildElement(body.children, "office:text");
88
- if (textElement === void 0) throw new Error(`readOdt: ${CONTENT_PART} has no office:body/office:text element`);
88
+ if (textElement === void 0) throw new Error(`readOdtContent: ${CONTENT_PART} has no office:body/office:text element`);
89
89
  const metadata = readOdfMetadata(pkg);
90
90
  const { pageSize, margins } = readFirstMasterPageGeometry(pkg);
91
91
  return {
@@ -97,5 +97,13 @@ function readOdt(pkg) {
97
97
  }]
98
98
  };
99
99
  }
100
+ function readOdt(pkg) {
101
+ const { metadata, sections } = readOdtContent(pkg);
102
+ return assemblePackage({
103
+ kind: "wordprocessing",
104
+ metadata,
105
+ sections
106
+ });
107
+ }
100
108
  //#endregion
101
- export { readOdt };
109
+ export { readOdt, readOdtContent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odf.js",
3
- "version": "4.0.3",
3
+ "version": "5.0.1",
4
4
  "description": "Type-safe, lossless round-trip conversion between OpenDocument Format packages (odt, ods, odp) and JSON, hand-written and dependency-minimal, built on Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -77,7 +77,7 @@
77
77
  "license": "MIT",
78
78
  "packageManager": "pnpm@11.6.0",
79
79
  "dependencies": {
80
- "document-schema.js": "^4.3.0",
80
+ "document-schema.js": "^4.3.1",
81
81
  "fast-xml-parser": "^5.10.1",
82
82
  "fflate": "^0.8.3",
83
83
  "zod": "^4.4.3"
@@ -1,10 +0,0 @@
1
- import { Package } from "./model/package.js";
2
- import { ContentSheet, LayoutMetadata } from "document-schema.js";
3
- //#region src/typed/ods/read.d.ts
4
- interface OdsDocument {
5
- metadata: LayoutMetadata;
6
- sheets: ContentSheet[];
7
- }
8
- declare function readOds(pkg: Package): OdsDocument;
9
- //#endregion
10
- export { readOds as n, OdsDocument as t };
@@ -1,10 +0,0 @@
1
- import { Package } from "./model/package.cjs";
2
- import { ContentSection, LayoutMetadata } from "document-schema.js";
3
- //#region src/typed/odt/read.d.ts
4
- interface OdtDocument {
5
- metadata: LayoutMetadata;
6
- sections: ContentSection[];
7
- }
8
- declare function readOdt(pkg: Package): OdtDocument;
9
- //#endregion
10
- export { readOdt as n, OdtDocument as t };
@@ -1,10 +0,0 @@
1
- import { Package } from "./model/package.cjs";
2
- import { ContentSlide, LayoutMetadata } from "document-schema.js";
3
- //#region src/typed/odp/read.d.ts
4
- interface OdpDocument {
5
- metadata: LayoutMetadata;
6
- slides: ContentSlide[];
7
- }
8
- declare function readOdp(pkg: Package): OdpDocument;
9
- //#endregion
10
- export { readOdp as n, OdpDocument as t };
@@ -1,14 +0,0 @@
1
- import { d as XmlNode, l as XmlElement } from "./node-CkBWRjNR.js";
2
- import { Package } from "./model/package.js";
3
- import { ContentDocument, LayoutMetadata } from "document-schema.js";
4
- //#region src/typed/formula/read.d.ts
5
- interface OdfFormulaDocument {
6
- starMath?: string;
7
- mathml: XmlNode[];
8
- metadata: LayoutMetadata;
9
- }
10
- declare function findMathRoot(nodes: readonly XmlNode[]): XmlElement | undefined;
11
- declare function readOdfFormula(pkg: Package): OdfFormulaDocument;
12
- declare function readOdfFormulaDocument(pkg: Package): ContentDocument;
13
- //#endregion
14
- export { readOdfFormulaDocument as i, findMathRoot as n, readOdfFormula as r, OdfFormulaDocument as t };
@@ -1,10 +0,0 @@
1
- import { Package } from "./model/package.js";
2
- import { ContentDrawPage, LayoutMetadata } from "document-schema.js";
3
- //#region src/typed/odg/read.d.ts
4
- interface OdgDocument {
5
- metadata: LayoutMetadata;
6
- pages: ContentDrawPage[];
7
- }
8
- declare function readOdg(pkg: Package): OdgDocument;
9
- //#endregion
10
- export { readOdg as n, OdgDocument as t };
@@ -1,10 +0,0 @@
1
- import { Package } from "./model/package.js";
2
- import { ContentSlide, LayoutMetadata } from "document-schema.js";
3
- //#region src/typed/odp/read.d.ts
4
- interface OdpDocument {
5
- metadata: LayoutMetadata;
6
- slides: ContentSlide[];
7
- }
8
- declare function readOdp(pkg: Package): OdpDocument;
9
- //#endregion
10
- export { readOdp as n, OdpDocument as t };
@@ -1,10 +0,0 @@
1
- import { Package } from "./model/package.cjs";
2
- import { ContentSheet, LayoutMetadata } from "document-schema.js";
3
- //#region src/typed/ods/read.d.ts
4
- interface OdsDocument {
5
- metadata: LayoutMetadata;
6
- sheets: ContentSheet[];
7
- }
8
- declare function readOds(pkg: Package): OdsDocument;
9
- //#endregion
10
- export { readOds as n, OdsDocument as t };
@@ -1,10 +0,0 @@
1
- import { Package } from "./model/package.cjs";
2
- import { ContentDrawPage, LayoutMetadata } from "document-schema.js";
3
- //#region src/typed/odg/read.d.ts
4
- interface OdgDocument {
5
- metadata: LayoutMetadata;
6
- pages: ContentDrawPage[];
7
- }
8
- declare function readOdg(pkg: Package): OdgDocument;
9
- //#endregion
10
- export { readOdg as n, OdgDocument as t };
@@ -1,10 +0,0 @@
1
- import { Package } from "./model/package.js";
2
- import { ContentSection, LayoutMetadata } from "document-schema.js";
3
- //#region src/typed/odt/read.d.ts
4
- interface OdtDocument {
5
- metadata: LayoutMetadata;
6
- sections: ContentSection[];
7
- }
8
- declare function readOdt(pkg: Package): OdtDocument;
9
- //#endregion
10
- export { readOdt as n, OdtDocument as t };
@@ -1,14 +0,0 @@
1
- import { d as XmlNode, l as XmlElement } from "./node-CkBWRjNR.cjs";
2
- import { Package } from "./model/package.cjs";
3
- import { ContentDocument, LayoutMetadata } from "document-schema.js";
4
- //#region src/typed/formula/read.d.ts
5
- interface OdfFormulaDocument {
6
- starMath?: string;
7
- mathml: XmlNode[];
8
- metadata: LayoutMetadata;
9
- }
10
- declare function findMathRoot(nodes: readonly XmlNode[]): XmlElement | undefined;
11
- declare function readOdfFormula(pkg: Package): OdfFormulaDocument;
12
- declare function readOdfFormulaDocument(pkg: Package): ContentDocument;
13
- //#endregion
14
- export { readOdfFormulaDocument as i, findMathRoot as n, readOdfFormula as r, OdfFormulaDocument as t };