ooxml-core 1.43.0 → 1.45.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 (69) hide show
  1. package/dist/{PptxHandler-V23RDNEX.cjs → PptxHandler-3RDVJFQV.cjs} +2 -2
  2. package/dist/{PptxHandler-WB3KL2WH.mjs → PptxHandler-EI6DMHPM.mjs} +1 -1
  3. package/dist/{PptxHandler-3VAVJDFB.mjs → PptxHandler-FXLXIOLT.mjs} +2 -2
  4. package/dist/{PresentationBuilder-7LJMTRJ6.mjs → PresentationBuilder-3FKFRSSV.mjs} +2 -2
  5. package/dist/{PresentationBuilder-KHL6GONR.cjs → PresentationBuilder-CSKLG64K.cjs} +4 -4
  6. package/dist/{PresentationBuilder-PY2GB4IG.mjs → PresentationBuilder-DDYHRV26.mjs} +1 -1
  7. package/dist/automation/index.cjs +10 -1
  8. package/dist/automation/index.mjs +10 -1
  9. package/dist/chart/edit/fill.d.ts +6 -2
  10. package/dist/chart/edit/fill.d.ts.map +1 -1
  11. package/dist/chart/index.cjs +12 -3
  12. package/dist/chart/index.mjs +12 -3
  13. package/dist/{chunk-HLYOHD2Z.mjs → chunk-CVJX6NNO.mjs} +438 -108
  14. package/dist/{chunk-243ZYX2B.mjs → chunk-GGJUWJXB.mjs} +1 -1
  15. package/dist/{chunk-KCDLTVUI.mjs → chunk-GXYK3H4O.mjs} +1 -1
  16. package/dist/{chunk-WEAWSXUX.mjs → chunk-LCXBTJXE.mjs} +4 -4
  17. package/dist/{chunk-JHYU7HGG.mjs → chunk-RVYGAYCP.mjs} +1 -1
  18. package/dist/{chunk-4LEVL6ZW.mjs → chunk-U5BXJQZG.mjs} +457 -105
  19. package/dist/{chunk-RNZQ2OU4.cjs → chunk-YBSNMVSN.cjs} +437 -107
  20. package/dist/index.cjs +164 -71
  21. package/dist/index.mjs +165 -72
  22. package/dist/opc/declared-fonts.d.ts +9 -0
  23. package/dist/opc/declared-fonts.d.ts.map +1 -0
  24. package/dist/opc/index.cjs +84 -0
  25. package/dist/opc/index.d.ts +1 -0
  26. package/dist/opc/index.d.ts.map +1 -1
  27. package/dist/opc/index.mjs +85 -2
  28. package/dist/pptx/automation/index.cjs +529 -167
  29. package/dist/pptx/automation/index.d.ts +6 -6
  30. package/dist/pptx/automation/index.mjs +5 -5
  31. package/dist/pptx/chunks/{elements-PBugbKtv.d.ts → elements-B4Z6N-Gz.d.ts} +4 -477
  32. package/dist/pptx/chunks/elements-B4Z6N-Gz.d.ts.map +1 -0
  33. package/dist/pptx/chunks/{index-CCJiD-Bm.d.ts → index-6Ot1b-4U.d.ts} +6 -6
  34. package/dist/pptx/chunks/{index-CCJiD-Bm.d.ts.map → index-6Ot1b-4U.d.ts.map} +1 -1
  35. package/dist/pptx/chunks/{index-CGNb1TV9.d.ts → index-DGKI80Hj.d.ts} +61 -6
  36. package/dist/pptx/chunks/{index-CGNb1TV9.d.ts.map → index-DGKI80Hj.d.ts.map} +1 -1
  37. package/dist/pptx/chunks/{index-Bj-hur0D.d.ts → index-jdZUtLGB.d.ts} +4 -4
  38. package/dist/pptx/chunks/{index-Bj-hur0D.d.ts.map → index-jdZUtLGB.d.ts.map} +1 -1
  39. package/dist/pptx/chunks/{table-C7ITXL3Y.d.ts → table-BfgZfw5R.d.ts} +488 -4
  40. package/dist/pptx/chunks/table-BfgZfw5R.d.ts.map +1 -0
  41. package/dist/pptx/chunks/{text-operations-BNJr7aGa.d.ts → text-operations-Mek86RBL.d.ts} +3 -3
  42. package/dist/pptx/chunks/{text-operations-BNJr7aGa.d.ts.map → text-operations-Mek86RBL.d.ts.map} +1 -1
  43. package/dist/pptx/cli/index.cjs +525 -163
  44. package/dist/pptx/cli/index.d.ts +1 -1
  45. package/dist/pptx/cli/index.mjs +4 -4
  46. package/dist/pptx/converter/index.d.ts +1 -1
  47. package/dist/pptx/converter/index.mjs +2 -2
  48. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  49. package/dist/pptx/editor/render/slide-operations.cjs +1 -1
  50. package/dist/pptx/editor/render/slide-operations.mjs +1 -1
  51. package/dist/pptx/editor/render/table-layout.d.ts +1 -1
  52. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
  53. package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
  54. package/dist/pptx/index.cjs +558 -168
  55. package/dist/pptx/index.d.ts +7 -7
  56. package/dist/pptx/index.mjs +5 -5
  57. package/dist/pptx/node/index.d.ts +1 -1
  58. package/dist/xlsx/index.cjs +10 -1
  59. package/dist/xlsx/index.mjs +10 -1
  60. package/dist/xlsx/ui/index.cjs +50 -6
  61. package/dist/xlsx/ui/index.mjs +50 -6
  62. package/dist/xlsx/ui/locales/de/options.d.ts.map +1 -1
  63. package/dist/xlsx/ui/locales/en/options.d.ts.map +1 -1
  64. package/dist/xlsx/ui/locales/es/options.d.ts.map +1 -1
  65. package/dist/xlsx/ui/locales/fr/options.d.ts.map +1 -1
  66. package/dist/xlsx/ui/locales/zh-CN/options.d.ts.map +1 -1
  67. package/package.json +1 -1
  68. package/dist/pptx/chunks/elements-PBugbKtv.d.ts.map +0 -1
  69. package/dist/pptx/chunks/table-C7ITXL3Y.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
2
2
  import * as xpath from 'xpath';
3
3
  import JSZip3 from 'jszip';
4
- import { zlibSync, Inflate } from 'fflate';
4
+ import { zlibSync, unzipSync, strFromU8, Inflate } from 'fflate';
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __export = (target, all) => {
@@ -14786,28 +14786,28 @@ function fillChild(doc, fill) {
14786
14786
  }
14787
14787
  function modelledChildren(doc, value) {
14788
14788
  const out = [];
14789
- const add2 = (name2, node) => out.push({ name: name2, node });
14789
+ const add3 = (name2, node) => out.push({ name: name2, node });
14790
14790
  if (value.line || value.lineSourceXml) {
14791
14791
  const ln = value.lineSourceXml ? importDrawingXml(doc, value.lineSourceXml) : drawingElement(doc, "ln");
14792
14792
  if (value.line) patchDrawingLine(ln, value.line);
14793
- add2("ln", ln);
14793
+ add3("ln", ln);
14794
14794
  }
14795
14795
  const fill = fillChild(doc, value.fill);
14796
14796
  if (fill) out.push(fill);
14797
14797
  if (value.highlight) {
14798
14798
  const highlight = drawingElement(doc, "highlight");
14799
14799
  highlight.appendChild(importDrawingXml(doc, drawingColorXml(value.highlight)));
14800
- add2("highlight", highlight);
14800
+ add3("highlight", highlight);
14801
14801
  }
14802
- if (value.underlineLineFollowsText) add2("uLnTx", drawingElement(doc, "uLnTx"));
14803
- else if (value.underlineLineXml) add2("uLn", importDrawingXml(doc, value.underlineLineXml));
14804
- if (value.underlineFillFollowsText) add2("uFillTx", drawingElement(doc, "uFillTx"));
14802
+ if (value.underlineLineFollowsText) add3("uLnTx", drawingElement(doc, "uLnTx"));
14803
+ else if (value.underlineLineXml) add3("uLn", importDrawingXml(doc, value.underlineLineXml));
14804
+ if (value.underlineFillFollowsText) add3("uFillTx", drawingElement(doc, "uFillTx"));
14805
14805
  else {
14806
14806
  const underline = fillChild(doc, value.underlineFill);
14807
14807
  if (underline) {
14808
14808
  const uFill = drawingElement(doc, "uFill");
14809
14809
  uFill.appendChild(underline.node);
14810
- add2("uFill", uFill);
14810
+ add3("uFill", uFill);
14811
14811
  }
14812
14812
  }
14813
14813
  for (const [local, key] of [
@@ -14817,16 +14817,16 @@ function modelledChildren(doc, value) {
14817
14817
  ["sym", "symbol"]
14818
14818
  ]) {
14819
14819
  const font = value[key];
14820
- if (font) add2(local, writeDrawingFont(doc, local, font));
14820
+ if (font) add3(local, writeDrawingFont(doc, local, font));
14821
14821
  }
14822
14822
  if (value.hyperlinkClick)
14823
- add2("hlinkClick", writeHyperlink(doc, "hlinkClick", value.hyperlinkClick));
14823
+ add3("hlinkClick", writeHyperlink(doc, "hlinkClick", value.hyperlinkClick));
14824
14824
  if (value.hyperlinkMouseOver)
14825
- add2("hlinkMouseOver", writeHyperlink(doc, "hlinkMouseOver", value.hyperlinkMouseOver));
14825
+ add3("hlinkMouseOver", writeHyperlink(doc, "hlinkMouseOver", value.hyperlinkMouseOver));
14826
14826
  if (value.rightToLeft !== void 0) {
14827
14827
  const rtl = drawingElement(doc, "rtl");
14828
14828
  if (!value.rightToLeft) rtl.setAttribute("val", "0");
14829
- add2("rtl", rtl);
14829
+ add3("rtl", rtl);
14830
14830
  }
14831
14831
  return out;
14832
14832
  }
@@ -14888,35 +14888,35 @@ function setAttributes2(element4, value) {
14888
14888
  }
14889
14889
  function bulletChildren(doc, value) {
14890
14890
  const out = [];
14891
- const add2 = (name2, node) => out.push({ name: name2, node });
14892
- if (value.bulletColor === "text") add2("buClrTx", drawingElement(doc, "buClrTx"));
14891
+ const add3 = (name2, node) => out.push({ name: name2, node });
14892
+ if (value.bulletColor === "text") add3("buClrTx", drawingElement(doc, "buClrTx"));
14893
14893
  else if (value.bulletColor) {
14894
14894
  const color2 = drawingElement(doc, "buClr");
14895
14895
  color2.appendChild(importDrawingXml(doc, drawingColorXml(value.bulletColor)));
14896
- add2("buClr", color2);
14896
+ add3("buClr", color2);
14897
14897
  }
14898
14898
  const size = value.bulletSize;
14899
- if (size === "text") add2("buSzTx", drawingElement(doc, "buSzTx"));
14899
+ if (size === "text") add3("buSzTx", drawingElement(doc, "buSzTx"));
14900
14900
  else if (size) {
14901
14901
  const local = size.unit === "percent" ? "buSzPct" : "buSzPts";
14902
14902
  const element4 = drawingElement(doc, local);
14903
14903
  setScaled(element4, "val", size.value, size.unit === "percent" ? 1e5 : 100);
14904
- add2(local, element4);
14904
+ add3(local, element4);
14905
14905
  }
14906
- if (value.bulletFont === "text") add2("buFontTx", drawingElement(doc, "buFontTx"));
14907
- else if (value.bulletFont) add2("buFont", writeDrawingFont(doc, "buFont", value.bulletFont));
14906
+ if (value.bulletFont === "text") add3("buFontTx", drawingElement(doc, "buFontTx"));
14907
+ else if (value.bulletFont) add3("buFont", writeDrawingFont(doc, "buFont", value.bulletFont));
14908
14908
  const bullet = value.bullet;
14909
- if (bullet?.kind === "none") add2("buNone", drawingElement(doc, "buNone"));
14909
+ if (bullet?.kind === "none") add3("buNone", drawingElement(doc, "buNone"));
14910
14910
  else if (bullet?.kind === "char") {
14911
14911
  const element4 = drawingElement(doc, "buChar");
14912
14912
  element4.setAttribute("char", bullet.char);
14913
- add2("buChar", element4);
14913
+ add3("buChar", element4);
14914
14914
  } else if (bullet?.kind === "autoNumber") {
14915
14915
  const element4 = drawingElement(doc, "buAutoNum");
14916
14916
  element4.setAttribute("type", bullet.scheme);
14917
14917
  setValue(element4, "startAt", bullet.startAt);
14918
- add2("buAutoNum", element4);
14919
- } else if (bullet?.kind === "picture") add2("buBlip", importDrawingXml(doc, bullet.xml));
14918
+ add3("buAutoNum", element4);
14919
+ } else if (bullet?.kind === "picture") add3("buBlip", importDrawingXml(doc, bullet.xml));
14920
14920
  return out;
14921
14921
  }
14922
14922
  function writeDrawingParagraphProperties(doc, value, local = "pPr") {
@@ -19301,7 +19301,16 @@ function repaintSeriesForFamily(series2, toLine) {
19301
19301
  shape.fill = structuredClone(shape.line.fill);
19302
19302
  }
19303
19303
  function clearPointPaint(series2, key) {
19304
- for (const point of series2.dataPoints) if (point.spPr) delete point.spPr[key];
19304
+ const emptied = (part) => Object.keys(part).every((name2) => name2 === "sourceXml");
19305
+ for (const point of series2.dataPoints) {
19306
+ if (!point.spPr) continue;
19307
+ delete point.spPr[key];
19308
+ if (point.spPr.line && emptied(point.spPr.line)) delete point.spPr.line;
19309
+ if (emptied(point.spPr)) delete point.spPr;
19310
+ }
19311
+ series2.dataPoints = series2.dataPoints.filter(
19312
+ (point) => Object.keys(point).some((name2) => name2 !== "index")
19313
+ );
19305
19314
  }
19306
19315
  function setChartSeriesFill(space3, index, fill) {
19307
19316
  return editChartSpace(space3, (draft) => {
@@ -19320,7 +19329,7 @@ function setChartSeriesLine(space3, index, line4) {
19320
19329
  );
19321
19330
  });
19322
19331
  }
19323
- function setChartSeriesColor(space3, index, color2) {
19332
+ function setChartSeriesColor(space3, index, color2, options2 = {}) {
19324
19333
  return editChartSpace(space3, (draft) => {
19325
19334
  const { series: series2 } = chartSeriesEntryAt(draft, index);
19326
19335
  const shape = series2.spPr ??= {};
@@ -19330,7 +19339,7 @@ function setChartSeriesColor(space3, index, color2) {
19330
19339
  const fill = color2 ? { kind: "solid", color: withAlphaOf(color2, previous) } : void 0;
19331
19340
  if (line4) assignOrDelete(shape.line ??= {}, "fill", fill);
19332
19341
  else assignOrDelete(shape, "fill", fill);
19333
- clearPointPaint(series2, line4 ? "line" : "fill");
19342
+ if (!options2.keepPointColors) clearPointPaint(series2, line4 ? "line" : "fill");
19334
19343
  });
19335
19344
  }
19336
19345
  function setChartSeriesTransparency(space3, index, percent) {
@@ -20314,22 +20323,22 @@ function patchRange(labels2, range2, show) {
20314
20323
  for (const child6 of elements(ext))
20315
20324
  if (child6.namespaceURI === C15 && ["datalabelsRange", "showDataLabelsRange"].includes(child6.localName))
20316
20325
  ext.removeChild(child6);
20317
- const add2 = (parent, ns, name2, text3) => {
20326
+ const add3 = (parent, ns, name2, text3) => {
20318
20327
  const node = root.ownerDocument.createElementNS(ns, name2);
20319
20328
  if (text3 !== void 0) node.textContent = text3;
20320
20329
  parent.appendChild(node);
20321
20330
  return node;
20322
20331
  };
20323
20332
  if (range2) {
20324
- add2(ext, C15, "c15:showDataLabelsRange").setAttribute("val", show ? "1" : "0");
20325
- const node = add2(ext, C15, "c15:datalabelsRange");
20326
- add2(node, C15, "c15:f", range2.formula);
20327
- const cache = add2(node, C15, "c15:dlblRangeCache");
20328
- add2(cache, NS.c, "c:ptCount").setAttribute("val", String(range2.cache.length));
20333
+ add3(ext, C15, "c15:showDataLabelsRange").setAttribute("val", show ? "1" : "0");
20334
+ const node = add3(ext, C15, "c15:datalabelsRange");
20335
+ add3(node, C15, "c15:f", range2.formula);
20336
+ const cache = add3(node, C15, "c15:dlblRangeCache");
20337
+ add3(cache, NS.c, "c:ptCount").setAttribute("val", String(range2.cache.length));
20329
20338
  range2.cache.forEach((text3, index) => {
20330
- const pt2 = add2(cache, NS.c, "c:pt");
20339
+ const pt2 = add3(cache, NS.c, "c:pt");
20331
20340
  pt2.setAttribute("idx", String(index));
20332
- add2(pt2, NS.c, "c:v", text3);
20341
+ add3(pt2, NS.c, "c:v", text3);
20333
20342
  });
20334
20343
  }
20335
20344
  if (!elements(ext).length) root.removeChild(ext);
@@ -24269,14 +24278,14 @@ function components(outline2) {
24269
24278
  function subsetTrueType(font, used) {
24270
24279
  const glyphs = [0];
24271
24280
  const mapped = /* @__PURE__ */ new Map([[0, 0]]);
24272
- const add2 = (glyph2) => {
24281
+ const add3 = (glyph2) => {
24273
24282
  if (mapped.has(glyph2) || glyph2 >= font.glyphCount) return;
24274
24283
  mapped.set(glyph2, glyphs.length);
24275
24284
  glyphs.push(glyph2);
24276
24285
  };
24277
- for (const glyph2 of used) add2(glyph2);
24286
+ for (const glyph2 of used) add3(glyph2);
24278
24287
  for (let index = 1; index < glyphs.length; index++)
24279
- for (const part of components(font.outline(glyphs[index]))) add2(part.glyph);
24288
+ for (const part of components(font.outline(glyphs[index]))) add3(part.glyph);
24280
24289
  const outlines = glyphs.map((glyph2) => {
24281
24290
  const source2 = font.outline(glyph2);
24282
24291
  if (!source2.length) return source2;
@@ -43836,7 +43845,7 @@ function siblingGroupOf(node, parentOf, childrenOf, roots2) {
43836
43845
  function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
43837
43846
  const out = [];
43838
43847
  const seen = /* @__PURE__ */ new Set();
43839
- const add2 = (node) => {
43848
+ const add3 = (node) => {
43840
43849
  if (!seen.has(node.id)) {
43841
43850
  seen.add(node.id);
43842
43851
  out.push(node);
@@ -43844,13 +43853,13 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
43844
43853
  };
43845
43854
  const addAll = (list2) => {
43846
43855
  for (const node of list2) {
43847
- add2(node);
43856
+ add3(node);
43848
43857
  }
43849
43858
  };
43850
43859
  for (const node of current) {
43851
43860
  switch (axis) {
43852
43861
  case "self":
43853
- add2(node);
43862
+ add3(node);
43854
43863
  break;
43855
43864
  case "ch":
43856
43865
  addAll(childrenOf.get(node.id) ?? []);
@@ -43859,13 +43868,13 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
43859
43868
  addAll(descendantsOf(node, childrenOf));
43860
43869
  break;
43861
43870
  case "desOrSelf":
43862
- add2(node);
43871
+ add3(node);
43863
43872
  addAll(descendantsOf(node, childrenOf));
43864
43873
  break;
43865
43874
  case "par": {
43866
43875
  const parent = parentOf.get(node.id);
43867
43876
  if (parent) {
43868
- add2(parent);
43877
+ add3(parent);
43869
43878
  }
43870
43879
  break;
43871
43880
  }
@@ -43873,7 +43882,7 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
43873
43882
  addAll(ancestorsOf(node, parentOf));
43874
43883
  break;
43875
43884
  case "ancstOrSelf":
43876
- add2(node);
43885
+ add3(node);
43877
43886
  addAll(ancestorsOf(node, parentOf));
43878
43887
  break;
43879
43888
  case "followSib":
@@ -43900,7 +43909,7 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
43900
43909
  }
43901
43910
  case "root": {
43902
43911
  const ancestors = ancestorsOf(node, parentOf);
43903
- add2(ancestors.length > 0 ? ancestors[ancestors.length - 1] : node);
43912
+ add3(ancestors.length > 0 ? ancestors[ancestors.length - 1] : node);
43904
43913
  break;
43905
43914
  }
43906
43915
  }
@@ -53079,8 +53088,8 @@ function applyOperation(data, edit, options2) {
53079
53088
  if (edit.position === "below") return addDiagramNodeBelow(data, edit.nodeId, text3, options2);
53080
53089
  if (edit.position === "above")
53081
53090
  return edit.nodeId ? addDiagramNodeAbove(data, edit.nodeId, text3, options2) : data;
53082
- const add2 = edit.position === "after" ? addDiagramNodeAfter : addDiagramNodeBefore;
53083
- return add2(data, text3, edit.nodeId, options2);
53091
+ const add3 = edit.position === "after" ? addDiagramNodeAfter : addDiagramNodeBefore;
53092
+ return add3(data, text3, edit.nodeId, options2);
53084
53093
  }
53085
53094
  case "remove":
53086
53095
  return removeDiagramNode(data, edit.nodeId);
@@ -54272,8 +54281,8 @@ function parseDefinitionHeader(root) {
54272
54281
  uniqueId: stringAttribute(root, "uniqueId") ?? "",
54273
54282
  categories: children(first(root, "catLst", NS.dgm) ?? root, "cat", NS.dgm).flatMap((cat) => {
54274
54283
  const type = stringAttribute(cat, "type");
54275
- const priority = Number.parseInt(cat.getAttribute("pri") ?? "", 10);
54276
- return type ? [{ type, ...Number.isFinite(priority) ? { priority } : {} }] : [];
54284
+ const priority2 = Number.parseInt(cat.getAttribute("pri") ?? "", 10);
54285
+ return type ? [{ type, ...Number.isFinite(priority2) ? { priority: priority2 } : {} }] : [];
54277
54286
  })
54278
54287
  };
54279
54288
  const title = stringAttribute(first(root, "title", NS.dgm), "val");
@@ -54524,6 +54533,7 @@ __export(opc_exports, {
54524
54533
  parseCustomProperties: () => parseCustomProperties,
54525
54534
  parseCustomPropertyTexts: () => parseCustomPropertyTexts,
54526
54535
  parseRelationships: () => parseRelationships,
54536
+ readDeclaredFonts: () => readDeclaredFonts,
54527
54537
  relationshipsPartFor: () => relationshipsPartFor,
54528
54538
  relativePartTarget: () => relativePartTarget,
54529
54539
  removeContentTypeOverride: () => removeContentTypeOverride,
@@ -55911,6 +55921,89 @@ async function stripPackageSignatures(zip) {
55911
55921
  function zlibCompress(data) {
55912
55922
  return zlibSync(data);
55913
55923
  }
55924
+ var PARTS = [
55925
+ /^word\/(fontTable|styles)\.xml$/u,
55926
+ /^xl\/styles\.xml$/u,
55927
+ /^ppt\/presentation\.xml$/u,
55928
+ /^ppt\/slideMasters\/slideMaster\d+\.xml$/u,
55929
+ /^ppt\/slides\/slide([1-9]|1[0-9]|20)\.xml$/u,
55930
+ /^visio\/document\.xml$/u,
55931
+ /^(word|xl|ppt|visio)\/theme\/theme\d+\.xml$/u
55932
+ ];
55933
+ var MAX_PART_BYTES = 2 * 1024 * 1024;
55934
+ var MAX_TOTAL_BYTES = 8 * 1024 * 1024;
55935
+ var FAMILY_PATTERNS = [
55936
+ /\btypeface="([^"]+)"/gu,
55937
+ /<w:font\s+w:name="([^"]+)"/gu,
55938
+ /\bw:(?:ascii|hAnsi|eastAsia|cs)="([^"]+)"/gu,
55939
+ /<name\s+val="([^"]+)"/gu,
55940
+ /<FaceName\b[^>]*?\bNameU="([^"]+)"/gu
55941
+ ];
55942
+ var decodeXml = (value) => value.replace(/&quot;/gu, '"').replace(/&apos;/gu, "'").replace(/&lt;/gu, "<").replace(/&gt;/gu, ">").replace(/&amp;/gu, "&");
55943
+ function add(into, raw2) {
55944
+ const family = decodeXml(raw2).trim();
55945
+ if (!family || family.startsWith("+") || family.length > 64) return;
55946
+ const key = family.toLowerCase();
55947
+ if (!into.has(key)) into.set(key, family);
55948
+ }
55949
+ function collectEmbedded(name2, xml2, into) {
55950
+ if (name2 === "ppt/presentation.xml") {
55951
+ for (const match of xml2.matchAll(/<p:embeddedFont>\s*<p:font\b[^>]*?\btypeface="([^"]+)"/gu)) {
55952
+ if (match[1]) add(into, match[1]);
55953
+ }
55954
+ }
55955
+ if (name2 === "word/fontTable.xml") {
55956
+ for (const match of xml2.matchAll(/<w:font\s+w:name="([^"]+)"[^>]*>([\s\S]*?)<\/w:font>/gu)) {
55957
+ if (match[1] && /<w:embed(Regular|Bold|Italic|BoldItalic)\b/u.test(match[2] ?? "")) {
55958
+ add(into, match[1]);
55959
+ }
55960
+ }
55961
+ }
55962
+ }
55963
+ function readDeclaredFonts(bytes) {
55964
+ const data = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
55965
+ let total = 0;
55966
+ let parts;
55967
+ try {
55968
+ parts = unzipSync(data, {
55969
+ filter: (file) => {
55970
+ if (!PARTS.some((pattern) => pattern.test(file.name))) return false;
55971
+ if (file.originalSize > MAX_PART_BYTES || total + file.originalSize > MAX_TOTAL_BYTES) {
55972
+ return false;
55973
+ }
55974
+ total += file.originalSize;
55975
+ return true;
55976
+ }
55977
+ });
55978
+ } catch {
55979
+ return { families: [], embedded: [] };
55980
+ }
55981
+ const families = /* @__PURE__ */ new Map();
55982
+ const embedded = /* @__PURE__ */ new Map();
55983
+ for (const name2 of Object.keys(parts).sort(byPriority)) {
55984
+ const part = parts[name2];
55985
+ if (!part) continue;
55986
+ const xml2 = strFromU8(part);
55987
+ for (const pattern of FAMILY_PATTERNS) {
55988
+ for (const match of xml2.matchAll(pattern)) if (match[1]) add(families, match[1]);
55989
+ }
55990
+ collectEmbedded(name2, xml2, embedded);
55991
+ }
55992
+ const embeddedKeys = new Set(embedded.keys());
55993
+ return {
55994
+ families: [...families].filter(([key]) => !embeddedKeys.has(key)).map(([, name2]) => name2),
55995
+ embedded: [...embedded.values()]
55996
+ };
55997
+ }
55998
+ function priority(name2) {
55999
+ if (name2.includes("/theme/")) return 0;
56000
+ if (/styles\.xml$|fontTable\.xml$|presentation\.xml$|document\.xml$/u.test(name2)) return 1;
56001
+ if (name2.includes("slideMaster")) return 2;
56002
+ return 3;
56003
+ }
56004
+ function byPriority(a2, b) {
56005
+ return priority(a2) - priority(b) || a2.localeCompare(b, "en", { numeric: true });
56006
+ }
55914
56007
 
55915
56008
  // diagram/picture-layout.ts
55916
56009
  var DIAGRAM_PICTURE_SOURCE_NS = "urn:ooxml-core:diagram-picture-sources:1";
@@ -55927,7 +56020,7 @@ function remapFill(fill, id) {
55927
56020
  function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
55928
56021
  const pictures = [];
55929
56022
  const parts = { ...dataParts };
55930
- const add2 = (source2, owner) => {
56023
+ const add3 = (source2, owner) => {
55931
56024
  const part = source2.fill.relId ? owner[source2.fill.relId] : void 0;
55932
56025
  if (!part) return;
55933
56026
  let id = Object.keys(parts).find((key) => parts[key] === part);
@@ -55950,7 +56043,7 @@ function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
55950
56043
  const nodeId = element4.getAttribute("nodeId");
55951
56044
  const fill = first(element4, "blipFill", NS.a);
55952
56045
  if (nodeId && fill && model.nodes.some((node) => node.modelId === nodeId))
55953
- add2(
56046
+ add3(
55954
56047
  {
55955
56048
  nodeId,
55956
56049
  fill: parseDrawingPictureFill(fill),
@@ -55964,7 +56057,7 @@ function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
55964
56057
  if (point.fill?.kind !== "picture") continue;
55965
56058
  const nodeId = point.type === "pres" ? point.presAssocId : point.modelId;
55966
56059
  if (nodeId && model.nodes.some((node) => node.modelId === nodeId) && !pictures.some((item2) => item2.nodeId === nodeId))
55967
- add2(
56060
+ add3(
55968
56061
  {
55969
56062
  nodeId,
55970
56063
  fill: point.fill,
@@ -55984,7 +56077,7 @@ function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
55984
56077
  ))
55985
56078
  continue;
55986
56079
  if (nodeId && model.nodes.some((node) => node.modelId === nodeId))
55987
- add2(
56080
+ add3(
55988
56081
  {
55989
56082
  nodeId,
55990
56083
  fill: shape.fill,
@@ -56351,7 +56444,7 @@ function resolveDiagramDrawingStyles(drawing, scheme2) {
56351
56444
 
56352
56445
  // diagram/write/cache.ts
56353
56446
  var DSP2 = "http://schemas.microsoft.com/office/drawing/2008/diagram";
56354
- function add(parent, namespace, name2, attrs2 = {}) {
56447
+ function add2(parent, namespace, name2, attrs2 = {}) {
56355
56448
  const child6 = parent.ownerDocument.createElementNS(namespace, name2);
56356
56449
  for (const [key, value] of Object.entries(attrs2)) child6.setAttribute(key, value);
56357
56450
  parent.appendChild(child6);
@@ -56362,8 +56455,8 @@ function withDiagramDrawingRelationship(xml2, relationshipId) {
56362
56455
  const model = doc.documentElement;
56363
56456
  let extension = descendants(model, "dataModelExt").find((node) => node.namespaceURI === DSP2);
56364
56457
  if (!extension) {
56365
- const extLst = first(model, "extLst", NS.dgm) ?? add(model, NS.dgm, "dgm:extLst");
56366
- extension = add(add(extLst, NS.a, "a:ext", { uri: DSP2 }), DSP2, "dsp:dataModelExt", {
56458
+ const extLst = first(model, "extLst", NS.dgm) ?? add2(model, NS.dgm, "dgm:extLst");
56459
+ extension = add2(add2(extLst, NS.a, "a:ext", { uri: DSP2 }), DSP2, "dsp:dataModelExt", {
56367
56460
  minVer: NS.dgm
56368
56461
  });
56369
56462
  }
@@ -56492,9 +56585,9 @@ function buildGeneratedDiagramCache(dataXml2, input) {
56492
56585
  parent.parentNode?.removeChild(parent);
56493
56586
  else parent?.removeChild(marker2);
56494
56587
  }
56495
- const extLst = first(root, "extLst", NS.dgm) ?? add(root, NS.dgm, "dgm:extLst");
56496
- const marker = add(
56497
- add(extLst, NS.a, "a:ext", { uri: GENERATED_DIAGRAM_CACHE_NS }),
56588
+ const extLst = first(root, "extLst", NS.dgm) ?? add2(root, NS.dgm, "dgm:extLst");
56589
+ const marker = add2(
56590
+ add2(extLst, NS.a, "a:ext", { uri: GENERATED_DIAGRAM_CACHE_NS }),
56498
56591
  GENERATED_DIAGRAM_CACHE_NS,
56499
56592
  "oc:generatedCache",
56500
56593
  {
@@ -56505,20 +56598,20 @@ function buildGeneratedDiagramCache(dataXml2, input) {
56505
56598
  );
56506
56599
  drawing.shapes.forEach((shape, index) => {
56507
56600
  const id = serialized.modelIds.get(shape.modelId);
56508
- const point = add(points2, NS.dgm, "dgm:pt", { modelId: id, type: "pres" });
56509
- add(point, NS.dgm, "dgm:prSet", {
56601
+ const point = add2(points2, NS.dgm, "dgm:pt", { modelId: id, type: "pres" });
56602
+ add2(point, NS.dgm, "dgm:prSet", {
56510
56603
  ...shape.sourceNodeId ? { presAssocID: shape.sourceNodeId } : {},
56511
56604
  presName: shape.sourceLayoutRole ?? "node",
56512
56605
  presStyleLbl: shape.sourceStyleLabel ?? "node1",
56513
56606
  presStyleIdx: String(index),
56514
56607
  presStyleCnt: String(drawing.shapes.length)
56515
56608
  });
56516
- const properties = add(point, NS.dgm, "dgm:spPr");
56609
+ const properties = add2(point, NS.dgm, "dgm:spPr");
56517
56610
  if (shape.fill?.kind === "picture" && shape.fill.sourceXml) {
56518
56611
  properties.appendChild(doc.importNode(parseXml(shape.fill.sourceXml).documentElement, true));
56519
56612
  }
56520
56613
  if (shape.sourceNodeId)
56521
- add(connections, NS.dgm, "dgm:cxn", {
56614
+ add2(connections, NS.dgm, "dgm:cxn", {
56522
56615
  modelId: createOfficeGuid(),
56523
56616
  type: "presOf",
56524
56617
  srcId: shape.sourceNodeId,
@@ -56527,7 +56620,7 @@ function buildGeneratedDiagramCache(dataXml2, input) {
56527
56620
  destOrd: "0",
56528
56621
  presId: input.layoutId ?? ""
56529
56622
  });
56530
- add(marker, GENERATED_DIAGRAM_CACHE_NS, "oc:shape", { id });
56623
+ add2(marker, GENERATED_DIAGRAM_CACHE_NS, "oc:shape", { id });
56531
56624
  });
56532
56625
  return {
56533
56626
  dataXml: buildXml(doc),
@@ -58673,19 +58766,19 @@ function compress3(h2, data, offset) {
58673
58766
  ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
58674
58767
  al = nl >>> 0;
58675
58768
  }
58676
- const add2 = (i2, xh, xl) => {
58769
+ const add3 = (i2, xh, xl) => {
58677
58770
  const lo = (h2[i2 + 1] >>> 0) + (xl >>> 0);
58678
58771
  h2[i2] = h2[i2] + xh + Math.floor(lo / 4294967296) >>> 0;
58679
58772
  h2[i2 + 1] = lo >>> 0;
58680
58773
  };
58681
- add2(0, ah, al);
58682
- add2(2, bh, bl);
58683
- add2(4, ch, cl);
58684
- add2(6, dh, dl);
58685
- add2(8, eh, el);
58686
- add2(10, fh, fl);
58687
- add2(12, gh, gl);
58688
- add2(14, hh, hl);
58774
+ add3(0, ah, al);
58775
+ add3(2, bh, bl);
58776
+ add3(4, ch, cl);
58777
+ add3(6, dh, dl);
58778
+ add3(8, eh, el);
58779
+ add3(10, fh, fl);
58780
+ add3(12, gh, gl);
58781
+ add3(14, hh, hl);
58689
58782
  }
58690
58783
  function digest64(data, iv, bytes) {
58691
58784
  const h2 = new Uint32Array(iv);
@@ -0,0 +1,9 @@
1
+ export interface DeclaredFonts {
2
+ /** Families the package names, in first-seen order, theme references (`+mn-lt`) excluded. */
3
+ families: string[];
4
+ /** Families the package embeds (PowerPoint `p:embeddedFont`, Word `w:embed*`). */
5
+ embedded: string[];
6
+ }
7
+ /** The families `bytes` (a .docx, .xlsx, .pptx or .vsdx and their template variants) declares. */
8
+ export declare function readDeclaredFonts(bytes: Uint8Array | ArrayBuffer): DeclaredFonts;
9
+ //# sourceMappingURL=declared-fonts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declared-fonts.d.ts","sourceRoot":"","sources":["../../opc/declared-fonts.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,aAAa;IAC7B,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,kFAAkF;IAClF,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AA2DD,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,CAmChF"}
@@ -2286,6 +2286,89 @@ async function stripPackageSignatures(zip) {
2286
2286
  function zlibCompress(data) {
2287
2287
  return fflate.zlibSync(data);
2288
2288
  }
2289
+ var PARTS = [
2290
+ /^word\/(fontTable|styles)\.xml$/u,
2291
+ /^xl\/styles\.xml$/u,
2292
+ /^ppt\/presentation\.xml$/u,
2293
+ /^ppt\/slideMasters\/slideMaster\d+\.xml$/u,
2294
+ /^ppt\/slides\/slide([1-9]|1[0-9]|20)\.xml$/u,
2295
+ /^visio\/document\.xml$/u,
2296
+ /^(word|xl|ppt|visio)\/theme\/theme\d+\.xml$/u
2297
+ ];
2298
+ var MAX_PART_BYTES = 2 * 1024 * 1024;
2299
+ var MAX_TOTAL_BYTES = 8 * 1024 * 1024;
2300
+ var FAMILY_PATTERNS = [
2301
+ /\btypeface="([^"]+)"/gu,
2302
+ /<w:font\s+w:name="([^"]+)"/gu,
2303
+ /\bw:(?:ascii|hAnsi|eastAsia|cs)="([^"]+)"/gu,
2304
+ /<name\s+val="([^"]+)"/gu,
2305
+ /<FaceName\b[^>]*?\bNameU="([^"]+)"/gu
2306
+ ];
2307
+ var decodeXml = (value) => value.replace(/&quot;/gu, '"').replace(/&apos;/gu, "'").replace(/&lt;/gu, "<").replace(/&gt;/gu, ">").replace(/&amp;/gu, "&");
2308
+ function add(into, raw) {
2309
+ const family = decodeXml(raw).trim();
2310
+ if (!family || family.startsWith("+") || family.length > 64) return;
2311
+ const key = family.toLowerCase();
2312
+ if (!into.has(key)) into.set(key, family);
2313
+ }
2314
+ function collectEmbedded(name, xml2, into) {
2315
+ if (name === "ppt/presentation.xml") {
2316
+ for (const match of xml2.matchAll(/<p:embeddedFont>\s*<p:font\b[^>]*?\btypeface="([^"]+)"/gu)) {
2317
+ if (match[1]) add(into, match[1]);
2318
+ }
2319
+ }
2320
+ if (name === "word/fontTable.xml") {
2321
+ for (const match of xml2.matchAll(/<w:font\s+w:name="([^"]+)"[^>]*>([\s\S]*?)<\/w:font>/gu)) {
2322
+ if (match[1] && /<w:embed(Regular|Bold|Italic|BoldItalic)\b/u.test(match[2] ?? "")) {
2323
+ add(into, match[1]);
2324
+ }
2325
+ }
2326
+ }
2327
+ }
2328
+ function readDeclaredFonts(bytes) {
2329
+ const data = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
2330
+ let total = 0;
2331
+ let parts;
2332
+ try {
2333
+ parts = fflate.unzipSync(data, {
2334
+ filter: (file) => {
2335
+ if (!PARTS.some((pattern) => pattern.test(file.name))) return false;
2336
+ if (file.originalSize > MAX_PART_BYTES || total + file.originalSize > MAX_TOTAL_BYTES) {
2337
+ return false;
2338
+ }
2339
+ total += file.originalSize;
2340
+ return true;
2341
+ }
2342
+ });
2343
+ } catch {
2344
+ return { families: [], embedded: [] };
2345
+ }
2346
+ const families = /* @__PURE__ */ new Map();
2347
+ const embedded = /* @__PURE__ */ new Map();
2348
+ for (const name of Object.keys(parts).sort(byPriority)) {
2349
+ const part = parts[name];
2350
+ if (!part) continue;
2351
+ const xml2 = fflate.strFromU8(part);
2352
+ for (const pattern of FAMILY_PATTERNS) {
2353
+ for (const match of xml2.matchAll(pattern)) if (match[1]) add(families, match[1]);
2354
+ }
2355
+ collectEmbedded(name, xml2, embedded);
2356
+ }
2357
+ const embeddedKeys = new Set(embedded.keys());
2358
+ return {
2359
+ families: [...families].filter(([key]) => !embeddedKeys.has(key)).map(([, name]) => name),
2360
+ embedded: [...embedded.values()]
2361
+ };
2362
+ }
2363
+ function priority(name) {
2364
+ if (name.includes("/theme/")) return 0;
2365
+ if (/styles\.xml$|fontTable\.xml$|presentation\.xml$|document\.xml$/u.test(name)) return 1;
2366
+ if (name.includes("slideMaster")) return 2;
2367
+ return 3;
2368
+ }
2369
+ function byPriority(a, b) {
2370
+ return priority(a) - priority(b) || a.localeCompare(b, "en", { numeric: true });
2371
+ }
2289
2372
 
2290
2373
  exports.CORE_PROPERTY_FIELDS = CORE_PROPERTY_FIELDS;
2291
2374
  exports.CUSTOM_PROPERTIES_FMTID = CUSTOM_PROPERTIES_FMTID;
@@ -2327,6 +2410,7 @@ exports.parseCoreProperties = parseCoreProperties;
2327
2410
  exports.parseCustomProperties = parseCustomProperties;
2328
2411
  exports.parseCustomPropertyTexts = parseCustomPropertyTexts;
2329
2412
  exports.parseRelationships = parseRelationships;
2413
+ exports.readDeclaredFonts = readDeclaredFonts;
2330
2414
  exports.relationshipsPartFor = relationshipsPartFor;
2331
2415
  exports.relativePartTarget = relativePartTarget;
2332
2416
  exports.removeContentTypeOverride = removeContentTypeOverride;
@@ -11,4 +11,5 @@ export * from './properties/index.js';
11
11
  export * as signature from './signature/index.js';
12
12
  export * from './zip-limits.js';
13
13
  export { zlibCompress } from './zlib.js';
14
+ export { readDeclaredFonts, type DeclaredFonts } from './declared-fonts.js';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../opc/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../opc/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAC/C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC"}