documents.js 2.3.2 → 3.0.0

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 (106) hide show
  1. package/README.md +27 -14
  2. package/dist/codecs/registry.d.cts +8 -3
  3. package/dist/codecs/registry.d.ts +8 -3
  4. package/dist/convert/canonicalise.cjs +20 -0
  5. package/dist/convert/canonicalise.d.cts +5 -0
  6. package/dist/convert/canonicalise.d.ts +5 -0
  7. package/dist/convert/canonicalise.js +18 -0
  8. package/dist/convert/composition.cjs +29 -28
  9. package/dist/convert/composition.d.cts +1 -1
  10. package/dist/convert/composition.d.ts +1 -1
  11. package/dist/convert/composition.js +29 -28
  12. package/dist/convert/convert.cjs +14 -26
  13. package/dist/convert/convert.d.cts +1 -1
  14. package/dist/convert/convert.d.ts +1 -1
  15. package/dist/convert/convert.js +14 -26
  16. package/dist/convert/decompose.cjs +134 -0
  17. package/dist/convert/decompose.d.cts +13 -0
  18. package/dist/convert/decompose.d.ts +13 -0
  19. package/dist/convert/decompose.js +126 -0
  20. package/dist/convert/factor-styles.cjs +364 -0
  21. package/dist/convert/factor-styles.d.cts +6 -0
  22. package/dist/convert/factor-styles.d.ts +6 -0
  23. package/dist/convert/factor-styles.js +362 -0
  24. package/dist/convert/flatten.cjs +137 -0
  25. package/dist/convert/flatten.d.cts +5 -0
  26. package/dist/convert/flatten.d.ts +5 -0
  27. package/dist/convert/flatten.js +136 -0
  28. package/dist/convert/from-package.cjs +4 -3
  29. package/dist/convert/from-package.d.cts +2 -1
  30. package/dist/convert/from-package.d.ts +2 -1
  31. package/dist/convert/from-package.js +5 -4
  32. package/dist/convert/local.cjs +1 -1
  33. package/dist/convert/local.js +1 -1
  34. package/dist/convert/variant-bridges.cjs +0 -4
  35. package/dist/convert/variant-bridges.js +1 -5
  36. package/dist/csv/read.cjs +0 -1
  37. package/dist/csv/read.js +1 -2
  38. package/dist/edit/docx/numbering.d.cts +1 -1
  39. package/dist/edit/docx/numbering.d.ts +1 -1
  40. package/dist/edit/docx/paragraph.cjs +1 -0
  41. package/dist/edit/docx/paragraph.js +1 -0
  42. package/dist/edit/pdf/editor.cjs +1 -2
  43. package/dist/edit/pdf/editor.d.cts +2 -2
  44. package/dist/edit/pdf/editor.d.ts +2 -2
  45. package/dist/edit/pdf/editor.js +1 -2
  46. package/dist/edit/pdf/item.d.cts +1 -1
  47. package/dist/edit/pdf/item.d.ts +1 -1
  48. package/dist/edit/pdf/page.d.cts +2 -2
  49. package/dist/edit/pdf/page.d.ts +2 -2
  50. package/dist/edit/pdf/util.d.cts +1 -1
  51. package/dist/edit/pdf/util.d.ts +1 -1
  52. package/dist/fonts/registry.d.cts +1 -1
  53. package/dist/fonts/registry.d.ts +1 -1
  54. package/dist/index.cjs +10 -15
  55. package/dist/index.d.cts +7 -4
  56. package/dist/index.d.ts +7 -4
  57. package/dist/index.js +6 -3
  58. package/dist/{item-Dj6f1VTE.d.cts → item-D9vQKT0T.d.cts} +2 -1
  59. package/dist/{item-Dj6f1VTE.d.ts → item-D9vQKT0T.d.ts} +2 -1
  60. package/dist/latex/lint.cjs +3 -2
  61. package/dist/latex/lint.js +3 -2
  62. package/dist/layout/drawing.d.cts +2 -1
  63. package/dist/layout/drawing.d.ts +2 -1
  64. package/dist/layout/engine.cjs +8 -5
  65. package/dist/layout/engine.d.cts +2 -1
  66. package/dist/layout/engine.d.ts +2 -1
  67. package/dist/layout/engine.js +8 -5
  68. package/dist/layout/lattice.d.cts +1 -1
  69. package/dist/layout/lattice.d.ts +1 -1
  70. package/dist/layout/reconstruct.cjs +0 -5
  71. package/dist/layout/reconstruct.d.cts +2 -1
  72. package/dist/layout/reconstruct.d.ts +2 -1
  73. package/dist/layout/reconstruct.js +0 -5
  74. package/dist/layout/shared.cjs +2 -1
  75. package/dist/layout/shared.d.cts +2 -1
  76. package/dist/layout/shared.d.ts +2 -1
  77. package/dist/layout/shared.js +2 -1
  78. package/dist/layout/sheets.d.cts +2 -1
  79. package/dist/layout/sheets.d.ts +2 -1
  80. package/dist/layout/slides.d.cts +2 -1
  81. package/dist/layout/slides.d.ts +2 -1
  82. package/dist/markdown/render.cjs +0 -1
  83. package/dist/markdown/render.js +1 -2
  84. package/dist/model/embedded-drawing.cjs +5 -8
  85. package/dist/model/embedded-drawing.js +5 -8
  86. package/dist/model/formula.cjs +0 -2
  87. package/dist/model/formula.js +0 -2
  88. package/dist/odb/report/render.cjs +0 -1
  89. package/dist/odb/report/render.js +1 -2
  90. package/dist/odb/spreadsheet.cjs +0 -1
  91. package/dist/odb/spreadsheet.js +1 -2
  92. package/dist/odf/odg/read.cjs +0 -2
  93. package/dist/odf/odg/read.js +0 -2
  94. package/dist/odf/odp/read.cjs +0 -2
  95. package/dist/odf/odp/read.js +0 -2
  96. package/dist/odf/ods/read.cjs +0 -2
  97. package/dist/odf/ods/read.js +0 -2
  98. package/dist/odf/odt/read.cjs +0 -2
  99. package/dist/odf/odt/read.js +0 -2
  100. package/dist/ooxml/docx/read.cjs +0 -2
  101. package/dist/ooxml/docx/read.js +0 -2
  102. package/dist/ooxml/pptx/read.cjs +0 -2
  103. package/dist/ooxml/pptx/read.js +0 -2
  104. package/dist/svg/read.cjs +8 -11
  105. package/dist/svg/read.js +8 -11
  106. package/package.json +6 -6
@@ -1,7 +1,7 @@
1
1
  import { displayTextFor } from "../../hsqldb/script.js";
2
2
  import { evaluateRptBandOutsideData, runRptReport } from "../formula/evaluate.js";
3
3
  import { odbReportGroupChain, rptBandDefinition, rptDefinitionFromReport } from "../formula/definition.js";
4
- import { CONTENT_FORMAT_VERSION, PAGE_SIZE_A4 } from "document-schema.js";
4
+ import { PAGE_SIZE_A4 } from "document-schema.js";
5
5
  //#region src/odb/report/render.ts
6
6
  const MARGIN_PT = 56.69291338582677;
7
7
  const CONTENT_WIDTH_PT = PAGE_SIZE_A4.widthPt - 2 * MARGIN_PT;
@@ -96,7 +96,6 @@ function renderOdbReportContent(report, resultSet) {
96
96
  };
97
97
  return {
98
98
  kind: "wordprocessing",
99
- formatVersion: CONTENT_FORMAT_VERSION,
100
99
  metadata: { title: report.caption ?? report.name },
101
100
  sections: [section]
102
101
  };
@@ -58,7 +58,6 @@ function tableToSheet(table) {
58
58
  function odbTablesToSpreadsheetDocument(tables) {
59
59
  return {
60
60
  kind: "spreadsheet",
61
- formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
62
61
  metadata: {},
63
62
  sheets: tables.map(tableToSheet)
64
63
  };
@@ -1,5 +1,5 @@
1
1
  import { displayTextFor } from "../hsqldb/script.js";
2
- import { CONTENT_FORMAT_VERSION, PAGE_SIZE_A4 } from "document-schema.js";
2
+ import { PAGE_SIZE_A4 } from "document-schema.js";
3
3
  //#region src/odb/spreadsheet.ts
4
4
  const HEADER_ROW_INDEX = 0;
5
5
  const COLUMN_WIDTH_PT = 64;
@@ -57,7 +57,6 @@ function tableToSheet(table) {
57
57
  function odbTablesToSpreadsheetDocument(tables) {
58
58
  return {
59
59
  kind: "spreadsheet",
60
- formatVersion: CONTENT_FORMAT_VERSION,
61
60
  metadata: {},
62
61
  sheets: tables.map(tableToSheet)
63
62
  };
@@ -1,12 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let document_schema_js = require("document-schema.js");
3
2
  let odf_js = require("odf.js");
4
3
  //#region src/odf/odg/read.ts
5
4
  function readOdgContent(pkg) {
6
5
  const odgDoc = (0, odf_js.readOdg)(pkg);
7
6
  return {
8
7
  kind: "drawing",
9
- formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
10
8
  metadata: { ...odgDoc.metadata },
11
9
  pages: odgDoc.pages
12
10
  };
@@ -1,11 +1,9 @@
1
- import { CONTENT_FORMAT_VERSION } from "document-schema.js";
2
1
  import { readOdg } from "odf.js";
3
2
  //#region src/odf/odg/read.ts
4
3
  function readOdgContent(pkg) {
5
4
  const odgDoc = readOdg(pkg);
6
5
  return {
7
6
  kind: "drawing",
8
- formatVersion: CONTENT_FORMAT_VERSION,
9
7
  metadata: { ...odgDoc.metadata },
10
8
  pages: odgDoc.pages
11
9
  };
@@ -3,7 +3,6 @@ const require_model_embedded_drawing = require("../../model/embedded-drawing.cjs
3
3
  const require_model_formula = require("../../model/formula.cjs");
4
4
  const require_odf_formula_detect = require("../formula/detect.cjs");
5
5
  const require_odf_vector_detect = require("../vector/detect.cjs");
6
- let document_schema_js = require("document-schema.js");
7
6
  let odf_js = require("odf.js");
8
7
  //#region src/odf/odp/read.ts
9
8
  function readOdpContent(pkg) {
@@ -64,7 +63,6 @@ function readOdpContent(pkg) {
64
63
  }
65
64
  return {
66
65
  kind: "presentation",
67
- formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
68
66
  metadata: { ...odpDoc.metadata },
69
67
  slides: odpDoc.slides
70
68
  };
@@ -2,7 +2,6 @@ import { buildDrawingBlock } from "../../model/embedded-drawing.js";
2
2
  import { buildFormulaBlock } from "../../model/formula.js";
3
3
  import { collectSlideFormulaFrames } from "../formula/detect.js";
4
4
  import { collectSlideVectorGroups } from "../vector/detect.js";
5
- import { CONTENT_FORMAT_VERSION } from "document-schema.js";
6
5
  import { childrenWithTag, findChildElement, readOdp, rootElement } from "odf.js";
7
6
  //#region src/odf/odp/read.ts
8
7
  function readOdpContent(pkg) {
@@ -63,7 +62,6 @@ function readOdpContent(pkg) {
63
62
  }
64
63
  return {
65
64
  kind: "presentation",
66
- formatVersion: CONTENT_FORMAT_VERSION,
67
65
  metadata: { ...odpDoc.metadata },
68
66
  slides: odpDoc.slides
69
67
  };
@@ -1,12 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let document_schema_js = require("document-schema.js");
3
2
  let odf_js = require("odf.js");
4
3
  //#region src/odf/ods/read.ts
5
4
  function readOdsContent(pkg) {
6
5
  const odsDoc = (0, odf_js.readOds)(pkg);
7
6
  return {
8
7
  kind: "spreadsheet",
9
- formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
10
8
  metadata: { ...odsDoc.metadata },
11
9
  sheets: odsDoc.sheets
12
10
  };
@@ -1,11 +1,9 @@
1
- import { CONTENT_FORMAT_VERSION } from "document-schema.js";
2
1
  import { readOds } from "odf.js";
3
2
  //#region src/odf/ods/read.ts
4
3
  function readOdsContent(pkg) {
5
4
  const odsDoc = readOds(pkg);
6
5
  return {
7
6
  kind: "spreadsheet",
8
- formatVersion: CONTENT_FORMAT_VERSION,
9
7
  metadata: { ...odsDoc.metadata },
10
8
  sheets: odsDoc.sheets
11
9
  };
@@ -5,7 +5,6 @@ const require_model_block_splice = require("../../model/block-splice.cjs");
5
5
  const require_odf_formula_detect = require("../formula/detect.cjs");
6
6
  const require_odf_image_detect = require("../image/detect.cjs");
7
7
  const require_odf_vector_detect = require("../vector/detect.cjs");
8
- let document_schema_js = require("document-schema.js");
9
8
  let odf_js = require("odf.js");
10
9
  //#region src/odf/odt/read.ts
11
10
  function readOdtContent(pkg) {
@@ -51,7 +50,6 @@ function readOdtContent(pkg) {
51
50
  }
52
51
  return {
53
52
  kind: "wordprocessing",
54
- formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
55
53
  metadata: { ...odtDoc.metadata },
56
54
  sections: odtDoc.sections
57
55
  };
@@ -4,7 +4,6 @@ import { spliceBlocks } from "../../model/block-splice.js";
4
4
  import { collectFormulaFrames } from "../formula/detect.js";
5
5
  import { collectImageFrames } from "../image/detect.js";
6
6
  import { collectContainerVectors, isVectorElementTag } from "../vector/detect.js";
7
- import { CONTENT_FORMAT_VERSION } from "document-schema.js";
8
7
  import { findChildElement, readOdt, rootElement } from "odf.js";
9
8
  //#region src/odf/odt/read.ts
10
9
  function readOdtContent(pkg) {
@@ -50,7 +49,6 @@ function readOdtContent(pkg) {
50
49
  }
51
50
  return {
52
51
  kind: "wordprocessing",
53
- formatVersion: CONTENT_FORMAT_VERSION,
54
52
  metadata: { ...odtDoc.metadata },
55
53
  sections: odtDoc.sections
56
54
  };
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_ooxml_docx_embedded_objects = require("./embedded-objects.cjs");
3
3
  let ooxml_js = require("ooxml.js");
4
- let document_schema_js = require("document-schema.js");
5
4
  //#region src/ooxml/docx/read.ts
6
5
  const DOCUMENT_PART_PATH = "word/document.xml";
7
6
  function documentBody(pkg) {
@@ -14,7 +13,6 @@ function readDocxContent(pkg, options) {
14
13
  const sections = body === void 0 ? docxDoc.sections : require_ooxml_docx_embedded_objects.spliceDocxEmbeddedObjects(docxDoc.sections, body.children, options?.onMathDiagnostic);
15
14
  return {
16
15
  kind: "wordprocessing",
17
- formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
18
16
  metadata: { ...docxDoc.metadata },
19
17
  sections
20
18
  };
@@ -1,6 +1,5 @@
1
1
  import { spliceDocxEmbeddedObjects } from "./embedded-objects.js";
2
2
  import { childrenWithTag, readDocx, rootElement } from "ooxml.js";
3
- import { CONTENT_FORMAT_VERSION } from "document-schema.js";
4
3
  //#region src/ooxml/docx/read.ts
5
4
  const DOCUMENT_PART_PATH = "word/document.xml";
6
5
  function documentBody(pkg) {
@@ -13,7 +12,6 @@ function readDocxContent(pkg, options) {
13
12
  const sections = body === void 0 ? docxDoc.sections : spliceDocxEmbeddedObjects(docxDoc.sections, body.children, options?.onMathDiagnostic);
14
13
  return {
15
14
  kind: "wordprocessing",
16
- formatVersion: CONTENT_FORMAT_VERSION,
17
15
  metadata: { ...docxDoc.metadata },
18
16
  sections
19
17
  };
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_ooxml_pptx_formula = require("./formula.cjs");
3
3
  const require_ooxml_pptx_vector = require("./vector.cjs");
4
4
  let ooxml_js = require("ooxml.js");
5
- let document_schema_js = require("document-schema.js");
6
5
  //#region src/ooxml/pptx/read.ts
7
6
  const PRESENTATION_PART = "ppt/presentation.xml";
8
7
  function slidePathsInOrder(pkg) {
@@ -33,7 +32,6 @@ function readPptxContent(pkg, options) {
33
32
  });
34
33
  return {
35
34
  kind: "presentation",
36
- formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
37
35
  metadata: { ...pptxDoc.metadata },
38
36
  slides
39
37
  };
@@ -1,7 +1,6 @@
1
1
  import { spliceSlideFormulas } from "./formula.js";
2
2
  import { collapseVectorShapeRuns } from "./vector.js";
3
3
  import { attr, childrenWithTag, readPptx, resolveRelationships, rootElement } from "ooxml.js";
4
- import { CONTENT_FORMAT_VERSION } from "document-schema.js";
5
4
  //#region src/ooxml/pptx/read.ts
6
5
  const PRESENTATION_PART = "ppt/presentation.xml";
7
6
  function slidePathsInOrder(pkg) {
@@ -32,7 +31,6 @@ function readPptxContent(pkg, options) {
32
31
  });
33
32
  return {
34
33
  kind: "presentation",
35
- formatVersion: CONTENT_FORMAT_VERSION,
36
34
  metadata: { ...pptxDoc.metadata },
37
35
  slides
38
36
  };
package/dist/svg/read.cjs CHANGED
@@ -4,7 +4,6 @@ const require_svg_path = require("./path.cjs");
4
4
  const require_svg_units = require("./units.cjs");
5
5
  const require_svg_transform = require("./transform.cjs");
6
6
  let ooxml_js = require("ooxml.js");
7
- let document_schema_js = require("document-schema.js");
8
7
  let odf_js = require("odf.js");
9
8
  //#region src/svg/read.ts
10
9
  var SvgMissingRootElementError = class extends Error {
@@ -657,19 +656,17 @@ function readSvgContent(text, options) {
657
656
  const title = titleElement === void 0 ? void 0 : textOf(titleElement).trim();
658
657
  const metadata = title === void 0 || title === "" ? {} : { title };
659
658
  walkChildren(state, root, rootGeometry.map, childPaintState(root, {}));
660
- const page = {
661
- size: {
662
- widthPt: rootGeometry.widthPt,
663
- heightPt: rootGeometry.heightPt
664
- },
665
- shapes: [],
666
- vectors: state.vectors
667
- };
668
659
  return {
669
660
  kind: "drawing",
670
- formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
671
661
  metadata,
672
- pages: [page]
662
+ pages: [{
663
+ size: {
664
+ widthPt: rootGeometry.widthPt,
665
+ heightPt: rootGeometry.heightPt
666
+ },
667
+ shapes: [],
668
+ vectors: state.vectors
669
+ }]
673
670
  };
674
671
  }
675
672
  //#endregion
package/dist/svg/read.js CHANGED
@@ -3,7 +3,6 @@ import { parseSvgPathData } from "./path.js";
3
3
  import { parseSvgLengthPt, parseSvgUserUnits, parseSvgViewBox } from "./units.js";
4
4
  import { applyMatrix, composeMatrices, isAxisAligned, isNonReflectingSimilarity, meanScaleFactor, parseSvgTransform, similarityRotationDeg } from "./transform.js";
5
5
  import { decodeEntities } from "ooxml.js";
6
- import { CONTENT_FORMAT_VERSION } from "document-schema.js";
7
6
  import { parseXml } from "odf.js";
8
7
  //#region src/svg/read.ts
9
8
  var SvgMissingRootElementError = class extends Error {
@@ -656,19 +655,17 @@ function readSvgContent(text, options) {
656
655
  const title = titleElement === void 0 ? void 0 : textOf(titleElement).trim();
657
656
  const metadata = title === void 0 || title === "" ? {} : { title };
658
657
  walkChildren(state, root, rootGeometry.map, childPaintState(root, {}));
659
- const page = {
660
- size: {
661
- widthPt: rootGeometry.widthPt,
662
- heightPt: rootGeometry.heightPt
663
- },
664
- shapes: [],
665
- vectors: state.vectors
666
- };
667
658
  return {
668
659
  kind: "drawing",
669
- formatVersion: CONTENT_FORMAT_VERSION,
670
660
  metadata,
671
- pages: [page]
661
+ pages: [{
662
+ size: {
663
+ widthPt: rootGeometry.widthPt,
664
+ heightPt: rootGeometry.heightPt
665
+ },
666
+ shapes: [],
667
+ vectors: state.vectors
668
+ }]
672
669
  };
673
670
  }
674
671
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "documents.js",
3
- "version": "2.3.2",
3
+ "version": "3.0.0",
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": {
@@ -84,12 +84,12 @@
84
84
  "packageManager": "pnpm@11.6.0",
85
85
  "dependencies": {
86
86
  "byte-codec": "^1.1.9",
87
- "document-schema.js": "^3.2.0",
87
+ "document-schema.js": "^4.0.0",
88
88
  "fflate": "^0.8.3",
89
- "markdown-codec": "^2.0.0",
90
- "odf.js": "^3.0.1",
91
- "ooxml.js": "^2.16.0",
92
- "pdf-codec": "^2.2.36",
89
+ "markdown-codec": "^3.0.0",
90
+ "odf.js": "^4.0.0",
91
+ "ooxml.js": "^3.0.0",
92
+ "pdf-codec": "^3.0.0",
93
93
  "temml": "0.13.4",
94
94
  "zod": "^4.4.3"
95
95
  },