js.documents 7.20.21 → 7.20.22

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 (69) hide show
  1. package/dist/bin-dispatch.cjs +4 -4
  2. package/dist/bin-dispatch.js +4 -4
  3. package/dist/csv/read.cjs +1 -1
  4. package/dist/csv/read.js +1 -1
  5. package/dist/edit/odg/svg-path.cjs +1 -3
  6. package/dist/edit/odg/svg-path.js +1 -3
  7. package/dist/edit/ods/print-settings.cjs +3 -3
  8. package/dist/edit/ods/print-settings.js +3 -3
  9. package/dist/edit/pptx/editor.cjs +7 -8
  10. package/dist/edit/pptx/editor.js +1 -2
  11. package/dist/edit/pptx/scaffold.cjs +1 -0
  12. package/dist/edit/pptx/scaffold.d.cts +2 -1
  13. package/dist/edit/pptx/scaffold.d.ts +2 -1
  14. package/dist/edit/pptx/scaffold.js +1 -1
  15. package/dist/edit/pptx/slide.cjs +15 -1
  16. package/dist/edit/pptx/slide.js +16 -2
  17. package/dist/firebird/backup.cjs +4 -6
  18. package/dist/firebird/backup.js +4 -6
  19. package/dist/markdown/read.cjs +1 -0
  20. package/dist/markdown/read.d.cts +3 -2
  21. package/dist/markdown/read.d.ts +3 -2
  22. package/dist/markdown/read.js +1 -1
  23. package/dist/mathml/compose.cjs +0 -1
  24. package/dist/mathml/compose.js +0 -1
  25. package/dist/mathml/nodes.cjs +1 -2
  26. package/dist/mathml/nodes.js +1 -2
  27. package/dist/metadata/core-patch.cjs +1 -0
  28. package/dist/metadata/core-patch.d.cts +2 -1
  29. package/dist/metadata/core-patch.d.ts +2 -1
  30. package/dist/metadata/core-patch.js +1 -1
  31. package/dist/model/embedded-drawing.cjs +2 -8
  32. package/dist/model/embedded-drawing.js +2 -8
  33. package/dist/odb/values.cjs +2 -2
  34. package/dist/odb/values.js +2 -2
  35. package/dist/odf/odp/read.cjs +0 -1
  36. package/dist/odf/odp/read.js +0 -1
  37. package/dist/odf/vector/detect.cjs +6 -3
  38. package/dist/odf/vector/detect.d.cts +2 -1
  39. package/dist/odf/vector/detect.d.ts +2 -1
  40. package/dist/odf/vector/detect.js +6 -4
  41. package/dist/odf-package/formula.cjs +2 -2
  42. package/dist/odf-package/formula.d.cts +2 -1
  43. package/dist/odf-package/formula.d.ts +2 -1
  44. package/dist/odf-package/formula.js +2 -3
  45. package/dist/odf-package/manifest.cjs +1 -1
  46. package/dist/odf-package/manifest.js +1 -1
  47. package/dist/odf-package/media.cjs +2 -2
  48. package/dist/odf-package/media.d.cts +2 -1
  49. package/dist/odf-package/media.d.ts +2 -1
  50. package/dist/odf-package/media.js +2 -3
  51. package/dist/ooxml/pptx/read.cjs +1 -0
  52. package/dist/ooxml/pptx/read.d.cts +2 -1
  53. package/dist/ooxml/pptx/read.d.ts +2 -1
  54. package/dist/ooxml/pptx/read.js +1 -1
  55. package/dist/opc/media.cjs +2 -2
  56. package/dist/opc/media.d.cts +2 -1
  57. package/dist/opc/media.d.ts +2 -1
  58. package/dist/opc/media.js +2 -3
  59. package/dist/opc/paths.cjs +2 -2
  60. package/dist/opc/paths.js +2 -2
  61. package/dist/opc/rels.cjs +2 -2
  62. package/dist/opc/rels.d.cts +3 -2
  63. package/dist/opc/rels.d.ts +3 -2
  64. package/dist/opc/rels.js +2 -3
  65. package/dist/xml/edit.cjs +1 -2
  66. package/dist/xml/edit.js +1 -2
  67. package/dist/xml/odf-text.cjs +2 -2
  68. package/dist/xml/odf-text.js +2 -2
  69. package/package.json +1 -1
@@ -19,10 +19,10 @@ const RUNNERS = {
19
19
  }
20
20
  };
21
21
  function detectPackageManager(userAgent) {
22
- const ua = userAgent ?? "";
23
- if (ua.startsWith("yarn/")) return ua.startsWith("yarn/1.") ? "npm" : "yarn";
24
- if (ua.startsWith("pnpm/")) return "pnpm";
25
- if (ua.startsWith("bun/")) return "bun";
22
+ if (userAgent === void 0) return "npm";
23
+ if (userAgent.startsWith("yarn/")) return userAgent.startsWith("yarn/1.") ? "npm" : "yarn";
24
+ if (userAgent.startsWith("pnpm/")) return "pnpm";
25
+ if (userAgent.startsWith("bun/")) return "bun";
26
26
  return "npm";
27
27
  }
28
28
  /**
@@ -18,10 +18,10 @@ const RUNNERS = {
18
18
  }
19
19
  };
20
20
  function detectPackageManager(userAgent) {
21
- const ua = userAgent ?? "";
22
- if (ua.startsWith("yarn/")) return ua.startsWith("yarn/1.") ? "npm" : "yarn";
23
- if (ua.startsWith("pnpm/")) return "pnpm";
24
- if (ua.startsWith("bun/")) return "bun";
21
+ if (userAgent === void 0) return "npm";
22
+ if (userAgent.startsWith("yarn/")) return userAgent.startsWith("yarn/1.") ? "npm" : "yarn";
23
+ if (userAgent.startsWith("pnpm/")) return "pnpm";
24
+ if (userAgent.startsWith("bun/")) return "bun";
25
25
  return "npm";
26
26
  }
27
27
  /**
package/dist/csv/read.cjs CHANGED
@@ -21,7 +21,7 @@ const DEFAULT_PRINT_SETTINGS = {
21
21
  pageOrder: "downThenOver"
22
22
  };
23
23
  function dataCell(rowIndex, columnIndex, field, onCellTypeInference) {
24
- const inference = field === "" ? void 0 : require_layout_cell_typing.inferCellValue(field);
24
+ const inference = require_layout_cell_typing.inferCellValue(field);
25
25
  if (inference !== void 0) onCellTypeInference?.({
26
26
  sheetIndex: 0,
27
27
  row: rowIndex,
package/dist/csv/read.js CHANGED
@@ -20,7 +20,7 @@ const DEFAULT_PRINT_SETTINGS = {
20
20
  pageOrder: "downThenOver"
21
21
  };
22
22
  function dataCell(rowIndex, columnIndex, field, onCellTypeInference) {
23
- const inference = field === "" ? void 0 : inferCellValue(field);
23
+ const inference = inferCellValue(field);
24
24
  if (inference !== void 0) onCellTypeInference?.({
25
25
  sheetIndex: 0,
26
26
  row: rowIndex,
@@ -4,9 +4,7 @@ const PATH_NUMBER_DECIMALS = 6;
4
4
  const PATH_NUMBER_SCALE = 10 ** PATH_NUMBER_DECIMALS;
5
5
  function formatPathNumber(value) {
6
6
  if (!Number.isFinite(value)) throw new Error(`cannot format a non-finite path coordinate: ${value}`);
7
- const rounded = Math.round(value * PATH_NUMBER_SCALE) / PATH_NUMBER_SCALE;
8
- if (rounded === 0) return "0";
9
- return rounded.toFixed(PATH_NUMBER_DECIMALS).replace(/0+$/, "").replace(/\.$/, "");
7
+ return (Math.round(value * PATH_NUMBER_SCALE) / PATH_NUMBER_SCALE).toFixed(PATH_NUMBER_DECIMALS).replace(/0+$/, "").replace(/\.$/, "");
10
8
  }
11
9
  function formatPathPoint(point) {
12
10
  return `${formatPathNumber(point.xPt)} ${formatPathNumber(point.yPt)}`;
@@ -3,9 +3,7 @@ const PATH_NUMBER_DECIMALS = 6;
3
3
  const PATH_NUMBER_SCALE = 10 ** PATH_NUMBER_DECIMALS;
4
4
  function formatPathNumber(value) {
5
5
  if (!Number.isFinite(value)) throw new Error(`cannot format a non-finite path coordinate: ${value}`);
6
- const rounded = Math.round(value * PATH_NUMBER_SCALE) / PATH_NUMBER_SCALE;
7
- if (rounded === 0) return "0";
8
- return rounded.toFixed(PATH_NUMBER_DECIMALS).replace(/0+$/, "").replace(/\.$/, "");
6
+ return (Math.round(value * PATH_NUMBER_SCALE) / PATH_NUMBER_SCALE).toFixed(PATH_NUMBER_DECIMALS).replace(/0+$/, "").replace(/\.$/, "");
9
7
  }
10
8
  function formatPathPoint(point) {
11
9
  return `${formatPathNumber(point.xPt)} ${formatPathNumber(point.yPt)}`;
@@ -131,7 +131,7 @@ function readSheetPrintSettings(pkg, tableElement) {
131
131
  const layoutProperties = (0, odf_js.resolvePageLayoutProperties)(pkg, masterPageName);
132
132
  const pageSize = layoutProperties === void 0 ? void 0 : (0, odf_js.parsePageSize)(layoutProperties);
133
133
  const margins = layoutProperties === void 0 ? void 0 : (0, odf_js.parseMargins)(layoutProperties);
134
- const printTokens = new Set((layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:print"))?.split(" ").filter((token) => token.length > 0) ?? []);
134
+ const printWords = (layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:print"))?.split(" ") ?? [];
135
135
  const pageOrder = (layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:print-page-order")) === "ltr" ? "overThenDown" : "downThenOver";
136
136
  const scaleToRaw = layoutProperties === void 0 ? void 0 : (0, ooxml_js.attr)(layoutProperties, "style:scale-to");
137
137
  const scalePercent = scaleToRaw === void 0 ? void 0 : parseScalePercentage(scaleToRaw);
@@ -151,8 +151,8 @@ function readSheetPrintSettings(pkg, tableElement) {
151
151
  return {
152
152
  pageSize: pageSize ?? document_schema_js.PAGE_SIZE_A4,
153
153
  margins: margins ?? DEFAULT_MARGINS,
154
- gridlines: printTokens.has("grid"),
155
- headers: printTokens.has("headers"),
154
+ gridlines: printWords.includes("grid"),
155
+ headers: printWords.includes("headers"),
156
156
  pageOrder,
157
157
  ...printRange !== void 0 ? { printRange } : {},
158
158
  ...scalePercent !== void 0 ? { scalePercent } : {},
@@ -130,7 +130,7 @@ function readSheetPrintSettings(pkg, tableElement) {
130
130
  const layoutProperties = resolvePageLayoutProperties(pkg, masterPageName);
131
131
  const pageSize = layoutProperties === void 0 ? void 0 : parsePageSize(layoutProperties);
132
132
  const margins = layoutProperties === void 0 ? void 0 : parseMargins(layoutProperties);
133
- const printTokens = new Set((layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:print"))?.split(" ").filter((token) => token.length > 0) ?? []);
133
+ const printWords = (layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:print"))?.split(" ") ?? [];
134
134
  const pageOrder = (layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:print-page-order")) === "ltr" ? "overThenDown" : "downThenOver";
135
135
  const scaleToRaw = layoutProperties === void 0 ? void 0 : attr(layoutProperties, "style:scale-to");
136
136
  const scalePercent = scaleToRaw === void 0 ? void 0 : parseScalePercentage(scaleToRaw);
@@ -150,8 +150,8 @@ function readSheetPrintSettings(pkg, tableElement) {
150
150
  return {
151
151
  pageSize: pageSize ?? PAGE_SIZE_A4,
152
152
  margins: margins ?? DEFAULT_MARGINS,
153
- gridlines: printTokens.has("grid"),
154
- headers: printTokens.has("headers"),
153
+ gridlines: printWords.includes("grid"),
154
+ headers: printWords.includes("headers"),
155
155
  pageOrder,
156
156
  ...printRange !== void 0 ? { printRange } : {},
157
157
  ...scalePercent !== void 0 ? { scalePercent } : {},
@@ -11,7 +11,6 @@ const require_edit_pptx_scaffold = require("./scaffold.cjs");
11
11
  const require_edit_pptx_slide = require("./slide.cjs");
12
12
  let ooxml_js = require("ooxml.js");
13
13
  //#region src/edit/pptx/editor.ts
14
- const PRESENTATION_PART_PATH = "ppt/presentation.xml";
15
14
  const MEDIA_DIR = "ppt/media";
16
15
  const SLIDE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
17
16
  const SLIDE_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
@@ -22,18 +21,18 @@ function attrValue(element, name) {
22
21
  for (const a of element.attributes) if (a.name === name) return a.value;
23
22
  }
24
23
  function findPresentationRoot(pkg) {
25
- const root = (0, ooxml_js.rootElement)(pkg.parts[PRESENTATION_PART_PATH]);
26
- if (root === void 0) throw new Error(`package has no root element at ${PRESENTATION_PART_PATH}`);
24
+ const root = (0, ooxml_js.rootElement)(pkg.parts[require_edit_pptx_scaffold.PRESENTATION_PART_PATH]);
25
+ if (root === void 0) throw new Error(`package has no root element at ${require_edit_pptx_scaffold.PRESENTATION_PART_PATH}`);
27
26
  return root;
28
27
  }
29
28
  function findSldIdLst(presentationRoot) {
30
29
  const sldIdLst = directChild(presentationRoot, "p:sldIdLst");
31
- if (sldIdLst === void 0) throw new Error(`${PRESENTATION_PART_PATH} has no p:sldIdLst element`);
30
+ if (sldIdLst === void 0) throw new Error(`${require_edit_pptx_scaffold.PRESENTATION_PART_PATH} has no p:sldIdLst element`);
32
31
  return sldIdLst;
33
32
  }
34
33
  function findSldSz(presentationRoot) {
35
34
  const sldSz = directChild(presentationRoot, "p:sldSz");
36
- if (sldSz === void 0) throw new Error(`${PRESENTATION_PART_PATH} has no p:sldSz element`);
35
+ if (sldSz === void 0) throw new Error(`${require_edit_pptx_scaffold.PRESENTATION_PART_PATH} has no p:sldSz element`);
37
36
  return sldSz;
38
37
  }
39
38
  function nextSlideId(sldIdLst) {
@@ -80,7 +79,7 @@ var PptxEditor = class {
80
79
  }
81
80
  slides() {
82
81
  const sldIdLst = findSldIdLst(findPresentationRoot(this.pkg));
83
- const presentationRels = (0, ooxml_js.resolveRelationships)(this.pkg, PRESENTATION_PART_PATH);
82
+ const presentationRels = (0, ooxml_js.resolveRelationships)(this.pkg, require_edit_pptx_scaffold.PRESENTATION_PART_PATH);
84
83
  const out = [];
85
84
  for (const child of sldIdLst.children) {
86
85
  if (child.type !== "element" || child.tag !== "p:sldId") continue;
@@ -109,7 +108,7 @@ var PptxEditor = class {
109
108
  nodes: [slideRoot]
110
109
  };
111
110
  require_opc_content_types.ensureContentTypeOverride(this.pkg, slidePartPath, SLIDE_CONTENT_TYPE);
112
- const relationshipId = require_opc_rels.addRelationship(this.pkg, PRESENTATION_PART_PATH, {
111
+ const relationshipId = require_opc_rels.addRelationship(this.pkg, require_edit_pptx_scaffold.PRESENTATION_PART_PATH, {
113
112
  type: SLIDE_RELATIONSHIP_TYPE,
114
113
  target: `slides/slide${partIndex}.xml`
115
114
  });
@@ -137,7 +136,7 @@ var PptxEditor = class {
137
136
  const listIndex = sldIdLst.children.indexOf(target);
138
137
  sldIdLst.children.splice(listIndex, 1);
139
138
  if (rId !== void 0) {
140
- const rel = (0, ooxml_js.resolveRelationships)(this.pkg, PRESENTATION_PART_PATH).get(rId);
139
+ const rel = (0, ooxml_js.resolveRelationships)(this.pkg, require_edit_pptx_scaffold.PRESENTATION_PART_PATH).get(rId);
141
140
  if (rel !== void 0) Reflect.deleteProperty(this.pkg.parts, rel.target);
142
141
  }
143
142
  }
@@ -6,11 +6,10 @@ import { patchOoxmlCorePropertiesOnPackage } from "../../metadata/core-patch.js"
6
6
  import { resolveMetadataTimestamps } from "../../model/metadata.js";
7
7
  import { systemClock } from "../../ports/clock.js";
8
8
  import { emuToPt, ptToEmu } from "../../model/units.js";
9
- import { DML_NS, PML_NS, R_NS, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_REL_TYPE, buildEmptyGroupSpTree, createEmptyPptxPackage } from "./scaffold.js";
9
+ import { DML_NS, PML_NS, PRESENTATION_PART_PATH, R_NS, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_REL_TYPE, buildEmptyGroupSpTree, createEmptyPptxPackage } from "./scaffold.js";
10
10
  import { PptxSlide } from "./slide.js";
11
11
  import { decodePackage, encodePackage, readCoreProperties, resolveRelationships, rootElement } from "ooxml.js";
12
12
  //#region src/edit/pptx/editor.ts
13
- const PRESENTATION_PART_PATH = "ppt/presentation.xml";
14
13
  const MEDIA_DIR = "ppt/media";
15
14
  const SLIDE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
16
15
  const SLIDE_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
@@ -286,6 +286,7 @@ function createEmptyPptxPackage(options) {
286
286
  exports.DML_NS = DML_NS;
287
287
  exports.NOTES_MASTER_REL_TYPE = NOTES_MASTER_REL_TYPE;
288
288
  exports.PML_NS = PML_NS;
289
+ exports.PRESENTATION_PART_PATH = PRESENTATION_PART_PATH;
289
290
  exports.R_NS = R_NS;
290
291
  exports.SLIDE_LAYOUT_PART_PATH = SLIDE_LAYOUT_PART_PATH;
291
292
  exports.SLIDE_LAYOUT_REL_TYPE = SLIDE_LAYOUT_REL_TYPE;
@@ -5,6 +5,7 @@ declare const PML_NS = "http://schemas.openxmlformats.org/presentationml/2006/ma
5
5
  declare const DML_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
6
6
  declare const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
7
7
  declare const SLIDE_LAYOUT_PART_PATH = "ppt/slideLayouts/slideLayout1.xml";
8
+ declare const PRESENTATION_PART_PATH = "ppt/presentation.xml";
8
9
  declare const SLIDE_LAYOUT_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
9
10
  declare const NOTES_MASTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster";
10
11
  declare function buildEmptyGroupSpTree(): XmlElement;
@@ -14,4 +15,4 @@ interface CreateEmptyPptxPackageOptions {
14
15
  }
15
16
  declare function createEmptyPptxPackage(options?: CreateEmptyPptxPackageOptions): Package;
16
17
  //#endregion
17
- export { CreateEmptyPptxPackageOptions, DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, R_NS, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_REL_TYPE, buildEmptyGroupSpTree, createEmptyPptxPackage, ensureNotesMaster };
18
+ export { CreateEmptyPptxPackageOptions, DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, PRESENTATION_PART_PATH, R_NS, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_REL_TYPE, buildEmptyGroupSpTree, createEmptyPptxPackage, ensureNotesMaster };
@@ -5,6 +5,7 @@ declare const PML_NS = "http://schemas.openxmlformats.org/presentationml/2006/ma
5
5
  declare const DML_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
6
6
  declare const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
7
7
  declare const SLIDE_LAYOUT_PART_PATH = "ppt/slideLayouts/slideLayout1.xml";
8
+ declare const PRESENTATION_PART_PATH = "ppt/presentation.xml";
8
9
  declare const SLIDE_LAYOUT_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
9
10
  declare const NOTES_MASTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster";
10
11
  declare function buildEmptyGroupSpTree(): XmlElement;
@@ -14,4 +15,4 @@ interface CreateEmptyPptxPackageOptions {
14
15
  }
15
16
  declare function createEmptyPptxPackage(options?: CreateEmptyPptxPackageOptions): Package;
16
17
  //#endregion
17
- export { CreateEmptyPptxPackageOptions, DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, R_NS, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_REL_TYPE, buildEmptyGroupSpTree, createEmptyPptxPackage, ensureNotesMaster };
18
+ export { CreateEmptyPptxPackageOptions, DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, PRESENTATION_PART_PATH, R_NS, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_REL_TYPE, buildEmptyGroupSpTree, createEmptyPptxPackage, ensureNotesMaster };
@@ -282,4 +282,4 @@ function createEmptyPptxPackage(options) {
282
282
  return pkg;
283
283
  }
284
284
  //#endregion
285
- export { DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, R_NS, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_REL_TYPE, buildEmptyGroupSpTree, createEmptyPptxPackage, ensureNotesMaster };
285
+ export { DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, PRESENTATION_PART_PATH, R_NS, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_REL_TYPE, buildEmptyGroupSpTree, createEmptyPptxPackage, ensureNotesMaster };
@@ -12,6 +12,9 @@ const require_edit_pptx_table = require("./table.cjs");
12
12
  const require_edit_pptx_vector = require("./vector.cjs");
13
13
  let ooxml_js = require("ooxml.js");
14
14
  //#region src/edit/pptx/slide.ts
15
+ function attrValue(element, name) {
16
+ for (const a of element.attributes) if (a.name === name) return a.value;
17
+ }
15
18
  function directChild(parent, tag) {
16
19
  for (const child of parent.children) if (child.type === "element" && child.tag === tag) return child;
17
20
  }
@@ -171,7 +174,18 @@ var PptxSlide = class {
171
174
  });
172
175
  }
173
176
  remove() {
174
- require_xml_edit.removeChild(this.container, this.live());
177
+ const { pkg, slidePartPath } = this.context;
178
+ const presentationRels = (0, ooxml_js.resolveRelationships)(pkg, require_edit_pptx_scaffold.PRESENTATION_PART_PATH);
179
+ for (const child of this.container) {
180
+ if (child.type !== "element" || child.tag !== "p:sldId") continue;
181
+ const rId = attrValue(child, "r:id");
182
+ if (rId === void 0) continue;
183
+ if (presentationRels.get(rId)?.target === slidePartPath) {
184
+ require_xml_edit.removeChild(this.container, child);
185
+ break;
186
+ }
187
+ }
188
+ Reflect.deleteProperty(pkg.parts, slidePartPath);
175
189
  this.removed = true;
176
190
  }
177
191
  };
@@ -4,13 +4,16 @@ import { ensureContentTypeOverride } from "../../opc/content-types.js";
4
4
  import { buildRelativeTarget } from "../../opc/paths.js";
5
5
  import { addRelationship } from "../../opc/rels.js";
6
6
  import { removeChild } from "../../xml/edit.js";
7
- import { DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, buildEmptyGroupSpTree, ensureNotesMaster } from "./scaffold.js";
7
+ import { DML_NS, NOTES_MASTER_REL_TYPE, PML_NS, PRESENTATION_PART_PATH, buildEmptyGroupSpTree, ensureNotesMaster } from "./scaffold.js";
8
8
  import { PptxShape, buildTextBoxShape } from "./shape.js";
9
9
  import { insertPictureShapeMedia } from "./image.js";
10
10
  import { PptxTable, buildDrawingTable, buildTableGraphicFrame, findGraphicFrameTable } from "./table.js";
11
11
  import { buildVectorShape } from "./vector.js";
12
12
  import { resolveRelationships, rootElement, textContent } from "ooxml.js";
13
13
  //#region src/edit/pptx/slide.ts
14
+ function attrValue(element, name) {
15
+ for (const a of element.attributes) if (a.name === name) return a.value;
16
+ }
14
17
  function directChild(parent, tag) {
15
18
  for (const child of parent.children) if (child.type === "element" && child.tag === tag) return child;
16
19
  }
@@ -170,7 +173,18 @@ var PptxSlide = class {
170
173
  });
171
174
  }
172
175
  remove() {
173
- removeChild(this.container, this.live());
176
+ const { pkg, slidePartPath } = this.context;
177
+ const presentationRels = resolveRelationships(pkg, PRESENTATION_PART_PATH);
178
+ for (const child of this.container) {
179
+ if (child.type !== "element" || child.tag !== "p:sldId") continue;
180
+ const rId = attrValue(child, "r:id");
181
+ if (rId === void 0) continue;
182
+ if (presentationRels.get(rId)?.target === slidePartPath) {
183
+ removeChild(this.container, child);
184
+ break;
185
+ }
186
+ }
187
+ Reflect.deleteProperty(pkg.parts, slidePartPath);
174
188
  this.removed = true;
175
189
  }
176
190
  };
@@ -94,7 +94,7 @@ function readFirebirdBackup(bytes) {
94
94
  if (!transportable) throw new FirebirdBackupFormatError("backup is in non-transportable (native binary) row format (att_backup_transportable=false) -- this reader only decodes the transportable/XDR row encoding, the one every real fixture it was built against actually uses (gbak's own default).");
95
95
  let pageSizeBytes;
96
96
  const schema = /* @__PURE__ */ new Map();
97
- const tablesInOrder = [];
97
+ const relationsInOrder = [];
98
98
  const rowsByRelation = /* @__PURE__ */ new Map();
99
99
  for (;;) {
100
100
  const recordType = reader.readTag();
@@ -108,7 +108,7 @@ function readFirebirdBackup(bytes) {
108
108
  throw new require_firebird_data.FirebirdCompositeRecordUnsupportedError(nestedRecordType, "reading a relation's own schema (a rec_view child, most likely)");
109
109
  });
110
110
  schema.set(relation.name, relation);
111
- tablesInOrder.push(relation.name);
111
+ relationsInOrder.push(relation);
112
112
  continue;
113
113
  }
114
114
  if (recordType === REC_RELATION_DATA) {
@@ -122,10 +122,8 @@ function readFirebirdBackup(bytes) {
122
122
  }
123
123
  throw new require_firebird_data.FirebirdCompositeRecordUnsupportedError(recordType, "walking the backup stream's own top-level record sequence");
124
124
  }
125
- const tables = tablesInOrder.map((name) => {
126
- const relation = schema.get(name);
127
- if (relation === void 0) throw new FirebirdBackupFormatError(`internal error: relation "${name}" missing from its own schema map`);
128
- const rows = rowsByRelation.get(name) ?? [];
125
+ const tables = relationsInOrder.map((relation) => {
126
+ const rows = rowsByRelation.get(relation.name) ?? [];
129
127
  return {
130
128
  tableName: relation.name,
131
129
  columns: relationToColumns(relation),
@@ -93,7 +93,7 @@ function readFirebirdBackup(bytes) {
93
93
  if (!transportable) throw new FirebirdBackupFormatError("backup is in non-transportable (native binary) row format (att_backup_transportable=false) -- this reader only decodes the transportable/XDR row encoding, the one every real fixture it was built against actually uses (gbak's own default).");
94
94
  let pageSizeBytes;
95
95
  const schema = /* @__PURE__ */ new Map();
96
- const tablesInOrder = [];
96
+ const relationsInOrder = [];
97
97
  const rowsByRelation = /* @__PURE__ */ new Map();
98
98
  for (;;) {
99
99
  const recordType = reader.readTag();
@@ -107,7 +107,7 @@ function readFirebirdBackup(bytes) {
107
107
  throw new FirebirdCompositeRecordUnsupportedError(nestedRecordType, "reading a relation's own schema (a rec_view child, most likely)");
108
108
  });
109
109
  schema.set(relation.name, relation);
110
- tablesInOrder.push(relation.name);
110
+ relationsInOrder.push(relation);
111
111
  continue;
112
112
  }
113
113
  if (recordType === REC_RELATION_DATA) {
@@ -121,10 +121,8 @@ function readFirebirdBackup(bytes) {
121
121
  }
122
122
  throw new FirebirdCompositeRecordUnsupportedError(recordType, "walking the backup stream's own top-level record sequence");
123
123
  }
124
- const tables = tablesInOrder.map((name) => {
125
- const relation = schema.get(name);
126
- if (relation === void 0) throw new FirebirdBackupFormatError(`internal error: relation "${name}" missing from its own schema map`);
127
- const rows = rowsByRelation.get(name) ?? [];
124
+ const tables = relationsInOrder.map((relation) => {
125
+ const rows = rowsByRelation.get(relation.name) ?? [];
128
126
  return {
129
127
  tableName: relation.name,
130
128
  columns: relationToColumns(relation),
@@ -25,4 +25,5 @@ function promoteBlock(block) {
25
25
  return block.runs.map((run) => run.text).join("") === "<!-- page break -->" ? { kind: "pageBreak" } : block;
26
26
  }
27
27
  //#endregion
28
+ exports.promoteBlock = promoteBlock;
28
29
  exports.readMarkdownContent = readMarkdownContent;
@@ -1,7 +1,8 @@
1
1
  import { MarkdownMathLoweringOptions } from "./math.cjs";
2
- import { ContentDocument } from "document-schema.js";
2
+ import { ContentBlock, ContentDocument } from "document-schema.js";
3
3
  import { ReadMarkdownOptions } from "markdown-codec";
4
4
  //#region src/markdown/read.d.ts
5
5
  declare function readMarkdownContent(text: string, options?: ReadMarkdownOptions, math?: MarkdownMathLoweringOptions): ContentDocument;
6
+ declare function promoteBlock(block: ContentBlock): ContentBlock;
6
7
  //#endregion
7
- export { readMarkdownContent };
8
+ export { promoteBlock, readMarkdownContent };
@@ -1,7 +1,8 @@
1
1
  import { MarkdownMathLoweringOptions } from "./math.js";
2
- import { ContentDocument } from "document-schema.js";
2
+ import { ContentBlock, ContentDocument } from "document-schema.js";
3
3
  import { ReadMarkdownOptions } from "markdown-codec";
4
4
  //#region src/markdown/read.d.ts
5
5
  declare function readMarkdownContent(text: string, options?: ReadMarkdownOptions, math?: MarkdownMathLoweringOptions): ContentDocument;
6
+ declare function promoteBlock(block: ContentBlock): ContentBlock;
6
7
  //#endregion
7
- export { readMarkdownContent };
8
+ export { promoteBlock, readMarkdownContent };
@@ -24,4 +24,4 @@ function promoteBlock(block) {
24
24
  return block.runs.map((run) => run.text).join("") === "<!-- page break -->" ? { kind: "pageBreak" } : block;
25
25
  }
26
26
  //#endregion
27
- export { readMarkdownContent };
27
+ export { promoteBlock, readMarkdownContent };
@@ -8,7 +8,6 @@ const EMPTY_BOX = {
8
8
  items: []
9
9
  };
10
10
  function shiftItems(items, dxPt, dyPt) {
11
- if (dxPt === 0 && dyPt === 0) return [...items];
12
11
  return items.map((item) => {
13
12
  if (item.kind === "stroke") return {
14
13
  ...item,
@@ -7,7 +7,6 @@ const EMPTY_BOX = {
7
7
  items: []
8
8
  };
9
9
  function shiftItems(items, dxPt, dyPt) {
10
- if (dxPt === 0 && dyPt === 0) return [...items];
11
10
  return items.map((item) => {
12
11
  if (item.kind === "stroke") return {
13
12
  ...item,
@@ -7,8 +7,7 @@ function isMathMlText(node) {
7
7
  return node.type === "text";
8
8
  }
9
9
  function localName(tag) {
10
- const colonIndex = tag.indexOf(":");
11
- return colonIndex === -1 ? tag : tag.slice(colonIndex + 1);
10
+ return tag.slice(tag.indexOf(":") + 1);
12
11
  }
13
12
  function elementLocalName(element) {
14
13
  return localName(element.tag);
@@ -6,8 +6,7 @@ function isMathMlText(node) {
6
6
  return node.type === "text";
7
7
  }
8
8
  function localName(tag) {
9
- const colonIndex = tag.indexOf(":");
10
- return colonIndex === -1 ? tag : tag.slice(colonIndex + 1);
9
+ return tag.slice(tag.indexOf(":") + 1);
11
10
  }
12
11
  function elementLocalName(element) {
13
12
  return localName(element.tag);
@@ -24,6 +24,7 @@ function patchOdfMetadataOnPackage(pkg, overrides, version) {
24
24
  else if (hasWritableMetadataOverride(overrides)) (0, odf_js.writeOdfMetadata)(pkg, mergeMetadata({}, overrides), version);
25
25
  }
26
26
  //#endregion
27
+ exports.hasWritableMetadataOverride = hasWritableMetadataOverride;
27
28
  exports.mergeMetadata = mergeMetadata;
28
29
  exports.patchOdfMetadataOnPackage = patchOdfMetadataOnPackage;
29
30
  exports.patchOoxmlCorePropertiesOnPackage = patchOoxmlCorePropertiesOnPackage;
@@ -9,7 +9,8 @@ interface MetadataOverrides {
9
9
  readonly keywords?: string[];
10
10
  }
11
11
  declare function mergeMetadata(current: LayoutMetadata, overrides: MetadataOverrides): LayoutMetadata;
12
+ declare function hasWritableMetadataOverride(overrides: MetadataOverrides): boolean;
12
13
  declare function patchOoxmlCorePropertiesOnPackage(pkg: Package, overrides: MetadataOverrides): void;
13
14
  declare function patchOdfMetadataOnPackage(pkg: Package$1, overrides: MetadataOverrides, version: string): void;
14
15
  //#endregion
15
- export { MetadataOverrides, mergeMetadata, patchOdfMetadataOnPackage, patchOoxmlCorePropertiesOnPackage };
16
+ export { MetadataOverrides, hasWritableMetadataOverride, mergeMetadata, patchOdfMetadataOnPackage, patchOoxmlCorePropertiesOnPackage };
@@ -9,7 +9,8 @@ interface MetadataOverrides {
9
9
  readonly keywords?: string[];
10
10
  }
11
11
  declare function mergeMetadata(current: LayoutMetadata, overrides: MetadataOverrides): LayoutMetadata;
12
+ declare function hasWritableMetadataOverride(overrides: MetadataOverrides): boolean;
12
13
  declare function patchOoxmlCorePropertiesOnPackage(pkg: Package, overrides: MetadataOverrides): void;
13
14
  declare function patchOdfMetadataOnPackage(pkg: Package$1, overrides: MetadataOverrides, version: string): void;
14
15
  //#endregion
15
- export { MetadataOverrides, mergeMetadata, patchOdfMetadataOnPackage, patchOoxmlCorePropertiesOnPackage };
16
+ export { MetadataOverrides, hasWritableMetadataOverride, mergeMetadata, patchOdfMetadataOnPackage, patchOoxmlCorePropertiesOnPackage };
@@ -23,4 +23,4 @@ function patchOdfMetadataOnPackage(pkg, overrides, version) {
23
23
  else if (hasWritableMetadataOverride(overrides)) writeOdfMetadata(pkg, mergeMetadata({}, overrides), version);
24
24
  }
25
25
  //#endregion
26
- export { mergeMetadata, patchOdfMetadataOnPackage, patchOoxmlCorePropertiesOnPackage };
26
+ export { hasWritableMetadataOverride, mergeMetadata, patchOdfMetadataOnPackage, patchOoxmlCorePropertiesOnPackage };
@@ -44,14 +44,8 @@ function translateVector(vector, dxPt, dyPt) {
44
44
  from: shiftPoint(vector.from, dxPt, dyPt),
45
45
  to: shiftPoint(vector.to, dxPt, dyPt)
46
46
  };
47
- case "rect": return {
48
- ...vector,
49
- frame: shiftBox(vector.frame, dxPt, dyPt)
50
- };
51
- case "ellipse": return {
52
- ...vector,
53
- frame: shiftBox(vector.frame, dxPt, dyPt)
54
- };
47
+ case "rect":
48
+ case "ellipse":
55
49
  case "path": return {
56
50
  ...vector,
57
51
  frame: shiftBox(vector.frame, dxPt, dyPt)
@@ -43,14 +43,8 @@ function translateVector(vector, dxPt, dyPt) {
43
43
  from: shiftPoint(vector.from, dxPt, dyPt),
44
44
  to: shiftPoint(vector.to, dxPt, dyPt)
45
45
  };
46
- case "rect": return {
47
- ...vector,
48
- frame: shiftBox(vector.frame, dxPt, dyPt)
49
- };
50
- case "ellipse": return {
51
- ...vector,
52
- frame: shiftBox(vector.frame, dxPt, dyPt)
53
- };
46
+ case "rect":
47
+ case "ellipse":
54
48
  case "path": return {
55
49
  ...vector,
56
50
  frame: shiftBox(vector.frame, dxPt, dyPt)
@@ -25,9 +25,9 @@ function cellComparisonKey(value) {
25
25
  }
26
26
  }
27
27
  function compareCellKeys(left, right, fail) {
28
- if (left.valueClass === "numeric" && right.valueClass === "numeric") return left.numeric === right.numeric ? 0 : left.numeric < right.numeric ? -1 : 1;
28
+ if (left.valueClass === "numeric" && right.valueClass === "numeric") return left.numeric < right.numeric ? -1 : left.numeric > right.numeric ? 1 : 0;
29
29
  if (left.valueClass === "boolean" && right.valueClass === "boolean") return left.boolean === right.boolean ? 0 : left.boolean ? 1 : -1;
30
- if (left.valueClass === "text" && right.valueClass === "text") return left.text === right.text ? 0 : left.text < right.text ? -1 : 1;
30
+ if (left.valueClass === "text" && right.valueClass === "text") return left.text < right.text ? -1 : left.text > right.text ? 1 : 0;
31
31
  throw fail(`cannot compare a ${left.valueClass} value with a ${right.valueClass} value`);
32
32
  }
33
33
  function compareCellValues(left, right, fail) {
@@ -24,9 +24,9 @@ function cellComparisonKey(value) {
24
24
  }
25
25
  }
26
26
  function compareCellKeys(left, right, fail) {
27
- if (left.valueClass === "numeric" && right.valueClass === "numeric") return left.numeric === right.numeric ? 0 : left.numeric < right.numeric ? -1 : 1;
27
+ if (left.valueClass === "numeric" && right.valueClass === "numeric") return left.numeric < right.numeric ? -1 : left.numeric > right.numeric ? 1 : 0;
28
28
  if (left.valueClass === "boolean" && right.valueClass === "boolean") return left.boolean === right.boolean ? 0 : left.boolean ? 1 : -1;
29
- if (left.valueClass === "text" && right.valueClass === "text") return left.text === right.text ? 0 : left.text < right.text ? -1 : 1;
29
+ if (left.valueClass === "text" && right.valueClass === "text") return left.text < right.text ? -1 : left.text > right.text ? 1 : 0;
30
30
  throw fail(`cannot compare a ${left.valueClass} value with a ${right.valueClass} value`);
31
31
  }
32
32
  function compareCellValues(left, right, fail) {
@@ -24,7 +24,6 @@ function readOdpContent(pkg) {
24
24
  };
25
25
  }
26
26
  const groups = require_odf_vector_detect.collectSlideVectorGroups(pageElement.children, pkg);
27
- if (groups.length === 0) return;
28
27
  const shapes = [];
29
28
  let shapeIndex = 0;
30
29
  let groupIndex = 0;
@@ -23,7 +23,6 @@ function readOdpContent(pkg) {
23
23
  };
24
24
  }
25
25
  const groups = collectSlideVectorGroups(pageElement.children, pkg);
26
- if (groups.length === 0) return;
27
26
  const shapes = [];
28
27
  let shapeIndex = 0;
29
28
  let groupIndex = 0;
@@ -21,9 +21,7 @@ function paintOrderOf(item) {
21
21
  if (item.paintOrder === void 0) throw new Error("expected odf.js's own readDrawPageContent to stamp every shape/vector with a paintOrder");
22
22
  return item.paintOrder;
23
23
  }
24
- function collectSlideVectorGroups(pageChildren, pkg) {
25
- const { shapes, vectors } = (0, odf_js.readDrawPageContent)(pageChildren, pkg);
26
- const shapePaintOrders = shapes.map(paintOrderOf);
24
+ function groupVectorsByShapePosition(shapePaintOrders, vectors) {
27
25
  const groups = [];
28
26
  for (const vector of vectors) {
29
27
  const vectorOrder = paintOrderOf(vector);
@@ -46,7 +44,12 @@ function collectSlideVectorGroups(pageChildren, pkg) {
46
44
  }))
47
45
  }));
48
46
  }
47
+ function collectSlideVectorGroups(pageChildren, pkg) {
48
+ const { shapes, vectors } = (0, odf_js.readDrawPageContent)(pageChildren, pkg);
49
+ return groupVectorsByShapePosition(shapes.map(paintOrderOf), vectors);
50
+ }
49
51
  //#endregion
50
52
  exports.collectContainerVectors = collectContainerVectors;
51
53
  exports.collectSlideVectorGroups = collectSlideVectorGroups;
54
+ exports.groupVectorsByShapePosition = groupVectorsByShapePosition;
52
55
  exports.isVectorElementTag = isVectorElementTag;
@@ -7,6 +7,7 @@ interface DetectedSlideVectorGroup {
7
7
  readonly insertBeforeShapeIndex: number;
8
8
  readonly vectors: readonly ContentVector[];
9
9
  }
10
+ declare function groupVectorsByShapePosition(shapePaintOrders: readonly number[], vectors: readonly ContentVector[]): readonly DetectedSlideVectorGroup[];
10
11
  declare function collectSlideVectorGroups(pageChildren: readonly XmlNode[], pkg: Package): readonly DetectedSlideVectorGroup[];
11
12
  //#endregion
12
- export { DetectedSlideVectorGroup, collectContainerVectors, collectSlideVectorGroups, isVectorElementTag };
13
+ export { DetectedSlideVectorGroup, collectContainerVectors, collectSlideVectorGroups, groupVectorsByShapePosition, isVectorElementTag };
@@ -7,6 +7,7 @@ interface DetectedSlideVectorGroup {
7
7
  readonly insertBeforeShapeIndex: number;
8
8
  readonly vectors: readonly ContentVector[];
9
9
  }
10
+ declare function groupVectorsByShapePosition(shapePaintOrders: readonly number[], vectors: readonly ContentVector[]): readonly DetectedSlideVectorGroup[];
10
11
  declare function collectSlideVectorGroups(pageChildren: readonly XmlNode[], pkg: Package): readonly DetectedSlideVectorGroup[];
11
12
  //#endregion
12
- export { DetectedSlideVectorGroup, collectContainerVectors, collectSlideVectorGroups, isVectorElementTag };
13
+ export { DetectedSlideVectorGroup, collectContainerVectors, collectSlideVectorGroups, groupVectorsByShapePosition, isVectorElementTag };
@@ -20,9 +20,7 @@ function paintOrderOf(item) {
20
20
  if (item.paintOrder === void 0) throw new Error("expected odf.js's own readDrawPageContent to stamp every shape/vector with a paintOrder");
21
21
  return item.paintOrder;
22
22
  }
23
- function collectSlideVectorGroups(pageChildren, pkg) {
24
- const { shapes, vectors } = readDrawPageContent(pageChildren, pkg);
25
- const shapePaintOrders = shapes.map(paintOrderOf);
23
+ function groupVectorsByShapePosition(shapePaintOrders, vectors) {
26
24
  const groups = [];
27
25
  for (const vector of vectors) {
28
26
  const vectorOrder = paintOrderOf(vector);
@@ -45,5 +43,9 @@ function collectSlideVectorGroups(pageChildren, pkg) {
45
43
  }))
46
44
  }));
47
45
  }
46
+ function collectSlideVectorGroups(pageChildren, pkg) {
47
+ const { shapes, vectors } = readDrawPageContent(pageChildren, pkg);
48
+ return groupVectorsByShapePosition(shapes.map(paintOrderOf), vectors);
49
+ }
48
50
  //#endregion
49
- export { collectContainerVectors, collectSlideVectorGroups, isVectorElementTag };
51
+ export { collectContainerVectors, collectSlideVectorGroups, groupVectorsByShapePosition, isVectorElementTag };
@@ -15,8 +15,7 @@ function nextObjectIndex(pkg) {
15
15
  for (const path of Object.keys(pkg.parts)) {
16
16
  const digits = pattern.exec(path)?.[1];
17
17
  if (digits === void 0) continue;
18
- const index = Number.parseInt(digits, 10);
19
- if (index > max) max = index;
18
+ max = Math.max(max, Number.parseInt(digits, 10));
20
19
  }
21
20
  return max + 1;
22
21
  }
@@ -57,3 +56,4 @@ function addFormulaObject(pkg, formula) {
57
56
  }
58
57
  //#endregion
59
58
  exports.addFormulaObject = addFormulaObject;
59
+ exports.nextObjectIndex = nextObjectIndex;
@@ -6,6 +6,7 @@ interface AddedOdfFormula {
6
6
  readonly href: string;
7
7
  readonly partPath: string;
8
8
  }
9
+ declare function nextObjectIndex(pkg: Package): number;
9
10
  declare function addFormulaObject(pkg: Package, formula: ContentFormula): AddedOdfFormula;
10
11
  //#endregion
11
- export { AddedOdfFormula, addFormulaObject };
12
+ export { AddedOdfFormula, addFormulaObject, nextObjectIndex };
@@ -6,6 +6,7 @@ interface AddedOdfFormula {
6
6
  readonly href: string;
7
7
  readonly partPath: string;
8
8
  }
9
+ declare function nextObjectIndex(pkg: Package): number;
9
10
  declare function addFormulaObject(pkg: Package, formula: ContentFormula): AddedOdfFormula;
10
11
  //#endregion
11
- export { AddedOdfFormula, addFormulaObject };
12
+ export { AddedOdfFormula, addFormulaObject, nextObjectIndex };
@@ -14,8 +14,7 @@ function nextObjectIndex(pkg) {
14
14
  for (const path of Object.keys(pkg.parts)) {
15
15
  const digits = pattern.exec(path)?.[1];
16
16
  if (digits === void 0) continue;
17
- const index = Number.parseInt(digits, 10);
18
- if (index > max) max = index;
17
+ max = Math.max(max, Number.parseInt(digits, 10));
19
18
  }
20
19
  return max + 1;
21
20
  }
@@ -55,4 +54,4 @@ function addFormulaObject(pkg, formula) {
55
54
  };
56
55
  }
57
56
  //#endregion
58
- export { addFormulaObject };
57
+ export { addFormulaObject, nextObjectIndex };
@@ -20,7 +20,7 @@ function subDocumentMediaType(pkg, directory) {
20
20
  function syncOdfManifest(pkg) {
21
21
  const mediaTypeOverrides = {};
22
22
  for (const path of Object.keys(pkg.parts)) {
23
- if (!path.endsWith(CONTENT_PART_SUFFIX) || path === ROOT_CONTENT_PART) continue;
23
+ if (!path.endsWith(CONTENT_PART_SUFFIX)) continue;
24
24
  const directory = path.slice(0, path.length - 11);
25
25
  const mediaType = subDocumentMediaType(pkg, directory);
26
26
  if (mediaType !== void 0) mediaTypeOverrides[directory] = mediaType;
@@ -19,7 +19,7 @@ function subDocumentMediaType(pkg, directory) {
19
19
  function syncOdfManifest(pkg) {
20
20
  const mediaTypeOverrides = {};
21
21
  for (const path of Object.keys(pkg.parts)) {
22
- if (!path.endsWith(CONTENT_PART_SUFFIX) || path === ROOT_CONTENT_PART) continue;
22
+ if (!path.endsWith(CONTENT_PART_SUFFIX)) continue;
23
23
  const directory = path.slice(0, path.length - 11);
24
24
  const mediaType = subDocumentMediaType(pkg, directory);
25
25
  if (mediaType !== void 0) mediaTypeOverrides[directory] = mediaType;
@@ -16,8 +16,7 @@ function nextPictureIndex(pkg, extension) {
16
16
  if (match === null) continue;
17
17
  const digits = match[1];
18
18
  if (digits === void 0) continue;
19
- const n = Number.parseInt(digits, 10);
20
- if (n > max) max = n;
19
+ max = Math.max(max, Number.parseInt(digits, 10));
21
20
  }
22
21
  return max + 1;
23
22
  }
@@ -33,3 +32,4 @@ function addImageMedia(pkg, imageBytes, format) {
33
32
  }
34
33
  //#endregion
35
34
  exports.addImageMedia = addImageMedia;
35
+ exports.nextPictureIndex = nextPictureIndex;
@@ -3,6 +3,7 @@ import { Package } from "odf.js";
3
3
  interface AddedOdfMedia {
4
4
  readonly partPath: string;
5
5
  }
6
+ declare function nextPictureIndex(pkg: Package, extension: string): number;
6
7
  declare function addImageMedia(pkg: Package, imageBytes: Uint8Array<ArrayBuffer>, format: "png" | "jpeg" | "svg" | "gif"): AddedOdfMedia;
7
8
  //#endregion
8
- export { AddedOdfMedia, addImageMedia };
9
+ export { AddedOdfMedia, addImageMedia, nextPictureIndex };
@@ -3,6 +3,7 @@ import { Package } from "odf.js";
3
3
  interface AddedOdfMedia {
4
4
  readonly partPath: string;
5
5
  }
6
+ declare function nextPictureIndex(pkg: Package, extension: string): number;
6
7
  declare function addImageMedia(pkg: Package, imageBytes: Uint8Array<ArrayBuffer>, format: "png" | "jpeg" | "svg" | "gif"): AddedOdfMedia;
7
8
  //#endregion
8
- export { AddedOdfMedia, addImageMedia };
9
+ export { AddedOdfMedia, addImageMedia, nextPictureIndex };
@@ -15,8 +15,7 @@ function nextPictureIndex(pkg, extension) {
15
15
  if (match === null) continue;
16
16
  const digits = match[1];
17
17
  if (digits === void 0) continue;
18
- const n = Number.parseInt(digits, 10);
19
- if (n > max) max = n;
18
+ max = Math.max(max, Number.parseInt(digits, 10));
20
19
  }
21
20
  return max + 1;
22
21
  }
@@ -31,4 +30,4 @@ function addImageMedia(pkg, imageBytes, format) {
31
30
  return { partPath };
32
31
  }
33
32
  //#endregion
34
- export { addImageMedia };
33
+ export { addImageMedia, nextPictureIndex };
@@ -41,3 +41,4 @@ function readPptxContent(pkg, options) {
41
41
  }
42
42
  //#endregion
43
43
  exports.readPptxContent = readPptxContent;
44
+ exports.slidePathsInOrder = slidePathsInOrder;
@@ -5,6 +5,7 @@ import { Package } from "ooxml.js";
5
5
  interface ReadPptxContentOptions {
6
6
  readonly onMathDiagnostic?: OmmlDiagnosticSink;
7
7
  }
8
+ declare function slidePathsInOrder(pkg: Package): readonly string[];
8
9
  declare function readPptxContent(pkg: Package, options?: ReadPptxContentOptions): ContentDocument;
9
10
  //#endregion
10
- export { ReadPptxContentOptions, readPptxContent };
11
+ export { ReadPptxContentOptions, readPptxContent, slidePathsInOrder };
@@ -5,6 +5,7 @@ import { ContentDocument } from "document-schema.js";
5
5
  interface ReadPptxContentOptions {
6
6
  readonly onMathDiagnostic?: OmmlDiagnosticSink;
7
7
  }
8
+ declare function slidePathsInOrder(pkg: Package): readonly string[];
8
9
  declare function readPptxContent(pkg: Package, options?: ReadPptxContentOptions): ContentDocument;
9
10
  //#endregion
10
- export { ReadPptxContentOptions, readPptxContent };
11
+ export { ReadPptxContentOptions, readPptxContent, slidePathsInOrder };
@@ -39,4 +39,4 @@ function readPptxContent(pkg, options) {
39
39
  };
40
40
  }
41
41
  //#endregion
42
- export { readPptxContent };
42
+ export { readPptxContent, slidePathsInOrder };
@@ -18,8 +18,7 @@ function nextMediaIndex(pkg, mediaDir, fileNamePrefix, extension) {
18
18
  if (match === null) continue;
19
19
  const digits = match[1];
20
20
  if (digits === void 0) continue;
21
- const n = Number.parseInt(digits, 10);
22
- if (n > max) max = n;
21
+ max = Math.max(max, Number.parseInt(digits, 10));
23
22
  }
24
23
  return max + 1;
25
24
  }
@@ -42,3 +41,4 @@ function addImageMedia(pkg, fromPartPath, mediaDir, format, bytes) {
42
41
  }
43
42
  //#endregion
44
43
  exports.addImageMedia = addImageMedia;
44
+ exports.nextMediaIndex = nextMediaIndex;
@@ -4,7 +4,8 @@ interface AddedMedia {
4
4
  readonly partPath: string;
5
5
  readonly relationshipId: string;
6
6
  }
7
+ declare function nextMediaIndex(pkg: Package, mediaDir: string, fileNamePrefix: string, extension: string): number;
7
8
  declare function addImageMedia(pkg: Package, fromPartPath: string, mediaDir: string // e.g. 'word/media' or 'ppt/media'
8
9
  , format: "png" | "jpeg" | "gif", bytes: Uint8Array<ArrayBuffer>): AddedMedia;
9
10
  //#endregion
10
- export { AddedMedia, addImageMedia };
11
+ export { AddedMedia, addImageMedia, nextMediaIndex };
@@ -4,7 +4,8 @@ interface AddedMedia {
4
4
  readonly partPath: string;
5
5
  readonly relationshipId: string;
6
6
  }
7
+ declare function nextMediaIndex(pkg: Package, mediaDir: string, fileNamePrefix: string, extension: string): number;
7
8
  declare function addImageMedia(pkg: Package, fromPartPath: string, mediaDir: string // e.g. 'word/media' or 'ppt/media'
8
9
  , format: "png" | "jpeg" | "gif", bytes: Uint8Array<ArrayBuffer>): AddedMedia;
9
10
  //#endregion
10
- export { AddedMedia, addImageMedia };
11
+ export { AddedMedia, addImageMedia, nextMediaIndex };
package/dist/opc/media.js CHANGED
@@ -17,8 +17,7 @@ function nextMediaIndex(pkg, mediaDir, fileNamePrefix, extension) {
17
17
  if (match === null) continue;
18
18
  const digits = match[1];
19
19
  if (digits === void 0) continue;
20
- const n = Number.parseInt(digits, 10);
21
- if (n > max) max = n;
20
+ max = Math.max(max, Number.parseInt(digits, 10));
22
21
  }
23
22
  return max + 1;
24
23
  }
@@ -40,4 +39,4 @@ function addImageMedia(pkg, fromPartPath, mediaDir, format, bytes) {
40
39
  };
41
40
  }
42
41
  //#endregion
43
- export { addImageMedia };
42
+ export { addImageMedia, nextMediaIndex };
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region src/opc/paths.ts
3
3
  function relsPathFor(partPath) {
4
4
  const lastSlash = partPath.lastIndexOf("/");
5
- return `${lastSlash === -1 ? "" : partPath.slice(0, lastSlash)}/_rels/${lastSlash === -1 ? partPath : partPath.slice(lastSlash + 1)}.rels`;
5
+ return `${lastSlash === -1 ? "" : partPath.slice(0, lastSlash)}/_rels/${partPath.slice(lastSlash + 1)}.rels`;
6
6
  }
7
7
  function dirSegments(partPath) {
8
8
  const lastSlash = partPath.lastIndexOf("/");
@@ -14,7 +14,7 @@ function buildRelativeTarget(fromPartPath, toPartPath) {
14
14
  const toDirs = dirSegments(toPartPath);
15
15
  const toFileName = toPartPath.slice(toPartPath.lastIndexOf("/") + 1);
16
16
  let common = 0;
17
- while (common < fromDirs.length && common < toDirs.length && fromDirs[common] === toDirs[common]) common++;
17
+ while (fromDirs[common] !== void 0 && fromDirs[common] === toDirs[common]) common++;
18
18
  const ups = Array(fromDirs.length - common).fill("..");
19
19
  const downs = toDirs.slice(common);
20
20
  return [
package/dist/opc/paths.js CHANGED
@@ -1,7 +1,7 @@
1
1
  //#region src/opc/paths.ts
2
2
  function relsPathFor(partPath) {
3
3
  const lastSlash = partPath.lastIndexOf("/");
4
- return `${lastSlash === -1 ? "" : partPath.slice(0, lastSlash)}/_rels/${lastSlash === -1 ? partPath : partPath.slice(lastSlash + 1)}.rels`;
4
+ return `${lastSlash === -1 ? "" : partPath.slice(0, lastSlash)}/_rels/${partPath.slice(lastSlash + 1)}.rels`;
5
5
  }
6
6
  function dirSegments(partPath) {
7
7
  const lastSlash = partPath.lastIndexOf("/");
@@ -13,7 +13,7 @@ function buildRelativeTarget(fromPartPath, toPartPath) {
13
13
  const toDirs = dirSegments(toPartPath);
14
14
  const toFileName = toPartPath.slice(toPartPath.lastIndexOf("/") + 1);
15
15
  let common = 0;
16
- while (common < fromDirs.length && common < toDirs.length && fromDirs[common] === toDirs[common]) common++;
16
+ while (fromDirs[common] !== void 0 && fromDirs[common] === toDirs[common]) common++;
17
17
  const ups = Array(fromDirs.length - common).fill("..");
18
18
  const downs = toDirs.slice(common);
19
19
  return [
package/dist/opc/rels.cjs CHANGED
@@ -26,8 +26,7 @@ function allocateRelationshipId(relationshipsRoot) {
26
26
  if (match === null) continue;
27
27
  const digits = match[1];
28
28
  if (digits === void 0) continue;
29
- const n = Number.parseInt(digits, 10);
30
- if (n > max) max = n;
29
+ max = Math.max(max, Number.parseInt(digits, 10));
31
30
  }
32
31
  return `rId${max + 1}`;
33
32
  }
@@ -52,3 +51,4 @@ function addRootRelationship(pkg, rel) {
52
51
  //#endregion
53
52
  exports.addRelationship = addRelationship;
54
53
  exports.addRootRelationship = addRootRelationship;
54
+ exports.allocateRelationshipId = allocateRelationshipId;
@@ -1,11 +1,12 @@
1
- import { Package } from "ooxml.js";
1
+ import { Package, XmlElement } from "ooxml.js";
2
2
  //#region src/opc/rels.d.ts
3
3
  interface NewRelationship {
4
4
  readonly type: string;
5
5
  readonly target: string;
6
6
  readonly targetMode?: "External";
7
7
  }
8
+ declare function allocateRelationshipId(relationshipsRoot: XmlElement): string;
8
9
  declare function addRelationship(pkg: Package, partPath: string, rel: NewRelationship): string;
9
10
  declare function addRootRelationship(pkg: Package, rel: NewRelationship): string;
10
11
  //#endregion
11
- export { NewRelationship, addRelationship, addRootRelationship };
12
+ export { NewRelationship, addRelationship, addRootRelationship, allocateRelationshipId };
@@ -1,11 +1,12 @@
1
- import { Package } from "ooxml.js";
1
+ import { Package, XmlElement } from "ooxml.js";
2
2
  //#region src/opc/rels.d.ts
3
3
  interface NewRelationship {
4
4
  readonly type: string;
5
5
  readonly target: string;
6
6
  readonly targetMode?: "External";
7
7
  }
8
+ declare function allocateRelationshipId(relationshipsRoot: XmlElement): string;
8
9
  declare function addRelationship(pkg: Package, partPath: string, rel: NewRelationship): string;
9
10
  declare function addRootRelationship(pkg: Package, rel: NewRelationship): string;
10
11
  //#endregion
11
- export { NewRelationship, addRelationship, addRootRelationship };
12
+ export { NewRelationship, addRelationship, addRootRelationship, allocateRelationshipId };
package/dist/opc/rels.js CHANGED
@@ -25,8 +25,7 @@ function allocateRelationshipId(relationshipsRoot) {
25
25
  if (match === null) continue;
26
26
  const digits = match[1];
27
27
  if (digits === void 0) continue;
28
- const n = Number.parseInt(digits, 10);
29
- if (n > max) max = n;
28
+ max = Math.max(max, Number.parseInt(digits, 10));
30
29
  }
31
30
  return `rId${max + 1}`;
32
31
  }
@@ -49,4 +48,4 @@ function addRootRelationship(pkg, rel) {
49
48
  return addRelationshipAtPath(pkg, ROOT_RELS_PART_PATH, rel);
50
49
  }
51
50
  //#endregion
52
- export { addRelationship, addRootRelationship };
51
+ export { addRelationship, addRootRelationship, allocateRelationshipId };
package/dist/xml/edit.cjs CHANGED
@@ -36,8 +36,7 @@ function insertInSchemaOrder(parent, child, order) {
36
36
  }
37
37
  for (const sibling of parent.children) {
38
38
  if (sibling.type !== "element") continue;
39
- const siblingRank = order.indexOf(sibling.tag);
40
- if (siblingRank !== -1 && siblingRank > childRank) {
39
+ if (order.indexOf(sibling.tag) > childRank) {
41
40
  insertBefore(parent.children, sibling, child);
42
41
  return;
43
42
  }
package/dist/xml/edit.js CHANGED
@@ -35,8 +35,7 @@ function insertInSchemaOrder(parent, child, order) {
35
35
  }
36
36
  for (const sibling of parent.children) {
37
37
  if (sibling.type !== "element") continue;
38
- const siblingRank = order.indexOf(sibling.tag);
39
- if (siblingRank !== -1 && siblingRank > childRank) {
38
+ if (order.indexOf(sibling.tag) > childRank) {
40
39
  insertBefore(parent.children, sibling, child);
41
40
  return;
42
41
  }
@@ -14,11 +14,11 @@ function encodeOdfText(text) {
14
14
  }
15
15
  };
16
16
  let i = 0;
17
- while (i < text.length) {
17
+ while (i !== text.length) {
18
18
  const ch = text.charAt(i);
19
19
  if (ch === " ") {
20
20
  let runLength = 1;
21
- while (i + runLength < text.length && text[i + runLength] === " ") runLength += 1;
21
+ while (text[i + runLength] === " ") runLength += 1;
22
22
  if (runLength >= MIN_SPACE_RUN_FOR_TEXT_S) {
23
23
  flushLiteral();
24
24
  nodes.push(require_xml_fragment.el("text:s", { "text:c": String(runLength) }));
@@ -13,11 +13,11 @@ function encodeOdfText(text) {
13
13
  }
14
14
  };
15
15
  let i = 0;
16
- while (i < text.length) {
16
+ while (i !== text.length) {
17
17
  const ch = text.charAt(i);
18
18
  if (ch === " ") {
19
19
  let runLength = 1;
20
- while (i + runLength < text.length && text[i + runLength] === " ") runLength += 1;
20
+ while (text[i + runLength] === " ") runLength += 1;
21
21
  if (runLength >= MIN_SPACE_RUN_FOR_TEXT_S) {
22
22
  flushLiteral();
23
23
  nodes.push(el("text:s", { "text:c": String(runLength) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js.documents",
3
- "version": "7.20.21",
3
+ "version": "7.20.22",
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": {