ooxml-core 1.43.0 → 1.44.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.
- package/dist/index.cjs +152 -68
- package/dist/index.mjs +153 -69
- package/dist/opc/declared-fonts.d.ts +9 -0
- package/dist/opc/declared-fonts.d.ts.map +1 -0
- package/dist/opc/index.cjs +84 -0
- package/dist/opc/index.d.ts +1 -0
- package/dist/opc/index.d.ts.map +1 -1
- package/dist/opc/index.mjs +85 -2
- package/dist/xlsx/ui/index.cjs +40 -5
- package/dist/xlsx/ui/index.mjs +40 -5
- package/dist/xlsx/ui/locales/de/options.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/en/options.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/es/options.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/fr/options.d.ts.map +1 -1
- package/dist/xlsx/ui/locales/zh-CN/options.d.ts.map +1 -1
- package/package.json +1 -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
|
|
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
|
-
|
|
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
|
-
|
|
14800
|
+
add3("highlight", highlight);
|
|
14801
14801
|
}
|
|
14802
|
-
if (value.underlineLineFollowsText)
|
|
14803
|
-
else if (value.underlineLineXml)
|
|
14804
|
-
if (value.underlineFillFollowsText)
|
|
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
|
-
|
|
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)
|
|
14820
|
+
if (font) add3(local, writeDrawingFont(doc, local, font));
|
|
14821
14821
|
}
|
|
14822
14822
|
if (value.hyperlinkClick)
|
|
14823
|
-
|
|
14823
|
+
add3("hlinkClick", writeHyperlink(doc, "hlinkClick", value.hyperlinkClick));
|
|
14824
14824
|
if (value.hyperlinkMouseOver)
|
|
14825
|
-
|
|
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
|
-
|
|
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
|
|
14892
|
-
if (value.bulletColor === "text")
|
|
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
|
-
|
|
14896
|
+
add3("buClr", color2);
|
|
14897
14897
|
}
|
|
14898
14898
|
const size = value.bulletSize;
|
|
14899
|
-
if (size === "text")
|
|
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
|
-
|
|
14904
|
+
add3(local, element4);
|
|
14905
14905
|
}
|
|
14906
|
-
if (value.bulletFont === "text")
|
|
14907
|
-
else if (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")
|
|
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
|
-
|
|
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
|
-
|
|
14919
|
-
} else if (bullet?.kind === "picture")
|
|
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") {
|
|
@@ -20314,22 +20314,22 @@ function patchRange(labels2, range2, show) {
|
|
|
20314
20314
|
for (const child6 of elements(ext))
|
|
20315
20315
|
if (child6.namespaceURI === C15 && ["datalabelsRange", "showDataLabelsRange"].includes(child6.localName))
|
|
20316
20316
|
ext.removeChild(child6);
|
|
20317
|
-
const
|
|
20317
|
+
const add3 = (parent, ns, name2, text3) => {
|
|
20318
20318
|
const node = root.ownerDocument.createElementNS(ns, name2);
|
|
20319
20319
|
if (text3 !== void 0) node.textContent = text3;
|
|
20320
20320
|
parent.appendChild(node);
|
|
20321
20321
|
return node;
|
|
20322
20322
|
};
|
|
20323
20323
|
if (range2) {
|
|
20324
|
-
|
|
20325
|
-
const node =
|
|
20326
|
-
|
|
20327
|
-
const cache =
|
|
20328
|
-
|
|
20324
|
+
add3(ext, C15, "c15:showDataLabelsRange").setAttribute("val", show ? "1" : "0");
|
|
20325
|
+
const node = add3(ext, C15, "c15:datalabelsRange");
|
|
20326
|
+
add3(node, C15, "c15:f", range2.formula);
|
|
20327
|
+
const cache = add3(node, C15, "c15:dlblRangeCache");
|
|
20328
|
+
add3(cache, NS.c, "c:ptCount").setAttribute("val", String(range2.cache.length));
|
|
20329
20329
|
range2.cache.forEach((text3, index) => {
|
|
20330
|
-
const pt2 =
|
|
20330
|
+
const pt2 = add3(cache, NS.c, "c:pt");
|
|
20331
20331
|
pt2.setAttribute("idx", String(index));
|
|
20332
|
-
|
|
20332
|
+
add3(pt2, NS.c, "c:v", text3);
|
|
20333
20333
|
});
|
|
20334
20334
|
}
|
|
20335
20335
|
if (!elements(ext).length) root.removeChild(ext);
|
|
@@ -24269,14 +24269,14 @@ function components(outline2) {
|
|
|
24269
24269
|
function subsetTrueType(font, used) {
|
|
24270
24270
|
const glyphs = [0];
|
|
24271
24271
|
const mapped = /* @__PURE__ */ new Map([[0, 0]]);
|
|
24272
|
-
const
|
|
24272
|
+
const add3 = (glyph2) => {
|
|
24273
24273
|
if (mapped.has(glyph2) || glyph2 >= font.glyphCount) return;
|
|
24274
24274
|
mapped.set(glyph2, glyphs.length);
|
|
24275
24275
|
glyphs.push(glyph2);
|
|
24276
24276
|
};
|
|
24277
|
-
for (const glyph2 of used)
|
|
24277
|
+
for (const glyph2 of used) add3(glyph2);
|
|
24278
24278
|
for (let index = 1; index < glyphs.length; index++)
|
|
24279
|
-
for (const part of components(font.outline(glyphs[index])))
|
|
24279
|
+
for (const part of components(font.outline(glyphs[index]))) add3(part.glyph);
|
|
24280
24280
|
const outlines = glyphs.map((glyph2) => {
|
|
24281
24281
|
const source2 = font.outline(glyph2);
|
|
24282
24282
|
if (!source2.length) return source2;
|
|
@@ -43836,7 +43836,7 @@ function siblingGroupOf(node, parentOf, childrenOf, roots2) {
|
|
|
43836
43836
|
function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
|
|
43837
43837
|
const out = [];
|
|
43838
43838
|
const seen = /* @__PURE__ */ new Set();
|
|
43839
|
-
const
|
|
43839
|
+
const add3 = (node) => {
|
|
43840
43840
|
if (!seen.has(node.id)) {
|
|
43841
43841
|
seen.add(node.id);
|
|
43842
43842
|
out.push(node);
|
|
@@ -43844,13 +43844,13 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
|
|
|
43844
43844
|
};
|
|
43845
43845
|
const addAll = (list2) => {
|
|
43846
43846
|
for (const node of list2) {
|
|
43847
|
-
|
|
43847
|
+
add3(node);
|
|
43848
43848
|
}
|
|
43849
43849
|
};
|
|
43850
43850
|
for (const node of current) {
|
|
43851
43851
|
switch (axis) {
|
|
43852
43852
|
case "self":
|
|
43853
|
-
|
|
43853
|
+
add3(node);
|
|
43854
43854
|
break;
|
|
43855
43855
|
case "ch":
|
|
43856
43856
|
addAll(childrenOf.get(node.id) ?? []);
|
|
@@ -43859,13 +43859,13 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
|
|
|
43859
43859
|
addAll(descendantsOf(node, childrenOf));
|
|
43860
43860
|
break;
|
|
43861
43861
|
case "desOrSelf":
|
|
43862
|
-
|
|
43862
|
+
add3(node);
|
|
43863
43863
|
addAll(descendantsOf(node, childrenOf));
|
|
43864
43864
|
break;
|
|
43865
43865
|
case "par": {
|
|
43866
43866
|
const parent = parentOf.get(node.id);
|
|
43867
43867
|
if (parent) {
|
|
43868
|
-
|
|
43868
|
+
add3(parent);
|
|
43869
43869
|
}
|
|
43870
43870
|
break;
|
|
43871
43871
|
}
|
|
@@ -43873,7 +43873,7 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
|
|
|
43873
43873
|
addAll(ancestorsOf(node, parentOf));
|
|
43874
43874
|
break;
|
|
43875
43875
|
case "ancstOrSelf":
|
|
43876
|
-
|
|
43876
|
+
add3(node);
|
|
43877
43877
|
addAll(ancestorsOf(node, parentOf));
|
|
43878
43878
|
break;
|
|
43879
43879
|
case "followSib":
|
|
@@ -43900,7 +43900,7 @@ function navigateAxisHop(current, axis, nodes, childrenOf, parentOf, roots2) {
|
|
|
43900
43900
|
}
|
|
43901
43901
|
case "root": {
|
|
43902
43902
|
const ancestors = ancestorsOf(node, parentOf);
|
|
43903
|
-
|
|
43903
|
+
add3(ancestors.length > 0 ? ancestors[ancestors.length - 1] : node);
|
|
43904
43904
|
break;
|
|
43905
43905
|
}
|
|
43906
43906
|
}
|
|
@@ -53079,8 +53079,8 @@ function applyOperation(data, edit, options2) {
|
|
|
53079
53079
|
if (edit.position === "below") return addDiagramNodeBelow(data, edit.nodeId, text3, options2);
|
|
53080
53080
|
if (edit.position === "above")
|
|
53081
53081
|
return edit.nodeId ? addDiagramNodeAbove(data, edit.nodeId, text3, options2) : data;
|
|
53082
|
-
const
|
|
53083
|
-
return
|
|
53082
|
+
const add3 = edit.position === "after" ? addDiagramNodeAfter : addDiagramNodeBefore;
|
|
53083
|
+
return add3(data, text3, edit.nodeId, options2);
|
|
53084
53084
|
}
|
|
53085
53085
|
case "remove":
|
|
53086
53086
|
return removeDiagramNode(data, edit.nodeId);
|
|
@@ -54272,8 +54272,8 @@ function parseDefinitionHeader(root) {
|
|
|
54272
54272
|
uniqueId: stringAttribute(root, "uniqueId") ?? "",
|
|
54273
54273
|
categories: children(first(root, "catLst", NS.dgm) ?? root, "cat", NS.dgm).flatMap((cat) => {
|
|
54274
54274
|
const type = stringAttribute(cat, "type");
|
|
54275
|
-
const
|
|
54276
|
-
return type ? [{ type, ...Number.isFinite(
|
|
54275
|
+
const priority2 = Number.parseInt(cat.getAttribute("pri") ?? "", 10);
|
|
54276
|
+
return type ? [{ type, ...Number.isFinite(priority2) ? { priority: priority2 } : {} }] : [];
|
|
54277
54277
|
})
|
|
54278
54278
|
};
|
|
54279
54279
|
const title = stringAttribute(first(root, "title", NS.dgm), "val");
|
|
@@ -54524,6 +54524,7 @@ __export(opc_exports, {
|
|
|
54524
54524
|
parseCustomProperties: () => parseCustomProperties,
|
|
54525
54525
|
parseCustomPropertyTexts: () => parseCustomPropertyTexts,
|
|
54526
54526
|
parseRelationships: () => parseRelationships,
|
|
54527
|
+
readDeclaredFonts: () => readDeclaredFonts,
|
|
54527
54528
|
relationshipsPartFor: () => relationshipsPartFor,
|
|
54528
54529
|
relativePartTarget: () => relativePartTarget,
|
|
54529
54530
|
removeContentTypeOverride: () => removeContentTypeOverride,
|
|
@@ -55911,6 +55912,89 @@ async function stripPackageSignatures(zip) {
|
|
|
55911
55912
|
function zlibCompress(data) {
|
|
55912
55913
|
return zlibSync(data);
|
|
55913
55914
|
}
|
|
55915
|
+
var PARTS = [
|
|
55916
|
+
/^word\/(fontTable|styles)\.xml$/u,
|
|
55917
|
+
/^xl\/styles\.xml$/u,
|
|
55918
|
+
/^ppt\/presentation\.xml$/u,
|
|
55919
|
+
/^ppt\/slideMasters\/slideMaster\d+\.xml$/u,
|
|
55920
|
+
/^ppt\/slides\/slide([1-9]|1[0-9]|20)\.xml$/u,
|
|
55921
|
+
/^visio\/document\.xml$/u,
|
|
55922
|
+
/^(word|xl|ppt|visio)\/theme\/theme\d+\.xml$/u
|
|
55923
|
+
];
|
|
55924
|
+
var MAX_PART_BYTES = 2 * 1024 * 1024;
|
|
55925
|
+
var MAX_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
55926
|
+
var FAMILY_PATTERNS = [
|
|
55927
|
+
/\btypeface="([^"]+)"/gu,
|
|
55928
|
+
/<w:font\s+w:name="([^"]+)"/gu,
|
|
55929
|
+
/\bw:(?:ascii|hAnsi|eastAsia|cs)="([^"]+)"/gu,
|
|
55930
|
+
/<name\s+val="([^"]+)"/gu,
|
|
55931
|
+
/<FaceName\b[^>]*?\bNameU="([^"]+)"/gu
|
|
55932
|
+
];
|
|
55933
|
+
var decodeXml = (value) => value.replace(/"/gu, '"').replace(/'/gu, "'").replace(/</gu, "<").replace(/>/gu, ">").replace(/&/gu, "&");
|
|
55934
|
+
function add(into, raw2) {
|
|
55935
|
+
const family = decodeXml(raw2).trim();
|
|
55936
|
+
if (!family || family.startsWith("+") || family.length > 64) return;
|
|
55937
|
+
const key = family.toLowerCase();
|
|
55938
|
+
if (!into.has(key)) into.set(key, family);
|
|
55939
|
+
}
|
|
55940
|
+
function collectEmbedded(name2, xml2, into) {
|
|
55941
|
+
if (name2 === "ppt/presentation.xml") {
|
|
55942
|
+
for (const match of xml2.matchAll(/<p:embeddedFont>\s*<p:font\b[^>]*?\btypeface="([^"]+)"/gu)) {
|
|
55943
|
+
if (match[1]) add(into, match[1]);
|
|
55944
|
+
}
|
|
55945
|
+
}
|
|
55946
|
+
if (name2 === "word/fontTable.xml") {
|
|
55947
|
+
for (const match of xml2.matchAll(/<w:font\s+w:name="([^"]+)"[^>]*>([\s\S]*?)<\/w:font>/gu)) {
|
|
55948
|
+
if (match[1] && /<w:embed(Regular|Bold|Italic|BoldItalic)\b/u.test(match[2] ?? "")) {
|
|
55949
|
+
add(into, match[1]);
|
|
55950
|
+
}
|
|
55951
|
+
}
|
|
55952
|
+
}
|
|
55953
|
+
}
|
|
55954
|
+
function readDeclaredFonts(bytes) {
|
|
55955
|
+
const data = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
55956
|
+
let total = 0;
|
|
55957
|
+
let parts;
|
|
55958
|
+
try {
|
|
55959
|
+
parts = unzipSync(data, {
|
|
55960
|
+
filter: (file) => {
|
|
55961
|
+
if (!PARTS.some((pattern) => pattern.test(file.name))) return false;
|
|
55962
|
+
if (file.originalSize > MAX_PART_BYTES || total + file.originalSize > MAX_TOTAL_BYTES) {
|
|
55963
|
+
return false;
|
|
55964
|
+
}
|
|
55965
|
+
total += file.originalSize;
|
|
55966
|
+
return true;
|
|
55967
|
+
}
|
|
55968
|
+
});
|
|
55969
|
+
} catch {
|
|
55970
|
+
return { families: [], embedded: [] };
|
|
55971
|
+
}
|
|
55972
|
+
const families = /* @__PURE__ */ new Map();
|
|
55973
|
+
const embedded = /* @__PURE__ */ new Map();
|
|
55974
|
+
for (const name2 of Object.keys(parts).sort(byPriority)) {
|
|
55975
|
+
const part = parts[name2];
|
|
55976
|
+
if (!part) continue;
|
|
55977
|
+
const xml2 = strFromU8(part);
|
|
55978
|
+
for (const pattern of FAMILY_PATTERNS) {
|
|
55979
|
+
for (const match of xml2.matchAll(pattern)) if (match[1]) add(families, match[1]);
|
|
55980
|
+
}
|
|
55981
|
+
collectEmbedded(name2, xml2, embedded);
|
|
55982
|
+
}
|
|
55983
|
+
const embeddedKeys = new Set(embedded.keys());
|
|
55984
|
+
return {
|
|
55985
|
+
families: [...families].filter(([key]) => !embeddedKeys.has(key)).map(([, name2]) => name2),
|
|
55986
|
+
embedded: [...embedded.values()]
|
|
55987
|
+
};
|
|
55988
|
+
}
|
|
55989
|
+
function priority(name2) {
|
|
55990
|
+
if (name2.includes("/theme/")) return 0;
|
|
55991
|
+
if (/styles\.xml$|fontTable\.xml$|presentation\.xml$|document\.xml$/u.test(name2)) return 1;
|
|
55992
|
+
if (name2.includes("slideMaster")) return 2;
|
|
55993
|
+
return 3;
|
|
55994
|
+
}
|
|
55995
|
+
function byPriority(a2, b) {
|
|
55996
|
+
return priority(a2) - priority(b) || a2.localeCompare(b, "en", { numeric: true });
|
|
55997
|
+
}
|
|
55914
55998
|
|
|
55915
55999
|
// diagram/picture-layout.ts
|
|
55916
56000
|
var DIAGRAM_PICTURE_SOURCE_NS = "urn:ooxml-core:diagram-picture-sources:1";
|
|
@@ -55927,7 +56011,7 @@ function remapFill(fill, id) {
|
|
|
55927
56011
|
function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
|
|
55928
56012
|
const pictures = [];
|
|
55929
56013
|
const parts = { ...dataParts };
|
|
55930
|
-
const
|
|
56014
|
+
const add3 = (source2, owner) => {
|
|
55931
56015
|
const part = source2.fill.relId ? owner[source2.fill.relId] : void 0;
|
|
55932
56016
|
if (!part) return;
|
|
55933
56017
|
let id = Object.keys(parts).find((key) => parts[key] === part);
|
|
@@ -55950,7 +56034,7 @@ function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
|
|
|
55950
56034
|
const nodeId = element4.getAttribute("nodeId");
|
|
55951
56035
|
const fill = first(element4, "blipFill", NS.a);
|
|
55952
56036
|
if (nodeId && fill && model.nodes.some((node) => node.modelId === nodeId))
|
|
55953
|
-
|
|
56037
|
+
add3(
|
|
55954
56038
|
{
|
|
55955
56039
|
nodeId,
|
|
55956
56040
|
fill: parseDrawingPictureFill(fill),
|
|
@@ -55964,7 +56048,7 @@ function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
|
|
|
55964
56048
|
if (point.fill?.kind !== "picture") continue;
|
|
55965
56049
|
const nodeId = point.type === "pres" ? point.presAssocId : point.modelId;
|
|
55966
56050
|
if (nodeId && model.nodes.some((node) => node.modelId === nodeId) && !pictures.some((item2) => item2.nodeId === nodeId))
|
|
55967
|
-
|
|
56051
|
+
add3(
|
|
55968
56052
|
{
|
|
55969
56053
|
nodeId,
|
|
55970
56054
|
fill: point.fill,
|
|
@@ -55984,7 +56068,7 @@ function captureDiagramPictures(model, dataXml2, dataParts, drawing) {
|
|
|
55984
56068
|
))
|
|
55985
56069
|
continue;
|
|
55986
56070
|
if (nodeId && model.nodes.some((node) => node.modelId === nodeId))
|
|
55987
|
-
|
|
56071
|
+
add3(
|
|
55988
56072
|
{
|
|
55989
56073
|
nodeId,
|
|
55990
56074
|
fill: shape.fill,
|
|
@@ -56351,7 +56435,7 @@ function resolveDiagramDrawingStyles(drawing, scheme2) {
|
|
|
56351
56435
|
|
|
56352
56436
|
// diagram/write/cache.ts
|
|
56353
56437
|
var DSP2 = "http://schemas.microsoft.com/office/drawing/2008/diagram";
|
|
56354
|
-
function
|
|
56438
|
+
function add2(parent, namespace, name2, attrs2 = {}) {
|
|
56355
56439
|
const child6 = parent.ownerDocument.createElementNS(namespace, name2);
|
|
56356
56440
|
for (const [key, value] of Object.entries(attrs2)) child6.setAttribute(key, value);
|
|
56357
56441
|
parent.appendChild(child6);
|
|
@@ -56362,8 +56446,8 @@ function withDiagramDrawingRelationship(xml2, relationshipId) {
|
|
|
56362
56446
|
const model = doc.documentElement;
|
|
56363
56447
|
let extension = descendants(model, "dataModelExt").find((node) => node.namespaceURI === DSP2);
|
|
56364
56448
|
if (!extension) {
|
|
56365
|
-
const extLst = first(model, "extLst", NS.dgm) ??
|
|
56366
|
-
extension =
|
|
56449
|
+
const extLst = first(model, "extLst", NS.dgm) ?? add2(model, NS.dgm, "dgm:extLst");
|
|
56450
|
+
extension = add2(add2(extLst, NS.a, "a:ext", { uri: DSP2 }), DSP2, "dsp:dataModelExt", {
|
|
56367
56451
|
minVer: NS.dgm
|
|
56368
56452
|
});
|
|
56369
56453
|
}
|
|
@@ -56492,9 +56576,9 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
56492
56576
|
parent.parentNode?.removeChild(parent);
|
|
56493
56577
|
else parent?.removeChild(marker2);
|
|
56494
56578
|
}
|
|
56495
|
-
const extLst = first(root, "extLst", NS.dgm) ??
|
|
56496
|
-
const marker =
|
|
56497
|
-
|
|
56579
|
+
const extLst = first(root, "extLst", NS.dgm) ?? add2(root, NS.dgm, "dgm:extLst");
|
|
56580
|
+
const marker = add2(
|
|
56581
|
+
add2(extLst, NS.a, "a:ext", { uri: GENERATED_DIAGRAM_CACHE_NS }),
|
|
56498
56582
|
GENERATED_DIAGRAM_CACHE_NS,
|
|
56499
56583
|
"oc:generatedCache",
|
|
56500
56584
|
{
|
|
@@ -56505,20 +56589,20 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
56505
56589
|
);
|
|
56506
56590
|
drawing.shapes.forEach((shape, index) => {
|
|
56507
56591
|
const id = serialized.modelIds.get(shape.modelId);
|
|
56508
|
-
const point =
|
|
56509
|
-
|
|
56592
|
+
const point = add2(points2, NS.dgm, "dgm:pt", { modelId: id, type: "pres" });
|
|
56593
|
+
add2(point, NS.dgm, "dgm:prSet", {
|
|
56510
56594
|
...shape.sourceNodeId ? { presAssocID: shape.sourceNodeId } : {},
|
|
56511
56595
|
presName: shape.sourceLayoutRole ?? "node",
|
|
56512
56596
|
presStyleLbl: shape.sourceStyleLabel ?? "node1",
|
|
56513
56597
|
presStyleIdx: String(index),
|
|
56514
56598
|
presStyleCnt: String(drawing.shapes.length)
|
|
56515
56599
|
});
|
|
56516
|
-
const properties =
|
|
56600
|
+
const properties = add2(point, NS.dgm, "dgm:spPr");
|
|
56517
56601
|
if (shape.fill?.kind === "picture" && shape.fill.sourceXml) {
|
|
56518
56602
|
properties.appendChild(doc.importNode(parseXml(shape.fill.sourceXml).documentElement, true));
|
|
56519
56603
|
}
|
|
56520
56604
|
if (shape.sourceNodeId)
|
|
56521
|
-
|
|
56605
|
+
add2(connections, NS.dgm, "dgm:cxn", {
|
|
56522
56606
|
modelId: createOfficeGuid(),
|
|
56523
56607
|
type: "presOf",
|
|
56524
56608
|
srcId: shape.sourceNodeId,
|
|
@@ -56527,7 +56611,7 @@ function buildGeneratedDiagramCache(dataXml2, input) {
|
|
|
56527
56611
|
destOrd: "0",
|
|
56528
56612
|
presId: input.layoutId ?? ""
|
|
56529
56613
|
});
|
|
56530
|
-
|
|
56614
|
+
add2(marker, GENERATED_DIAGRAM_CACHE_NS, "oc:shape", { id });
|
|
56531
56615
|
});
|
|
56532
56616
|
return {
|
|
56533
56617
|
dataXml: buildXml(doc),
|
|
@@ -58673,19 +58757,19 @@ function compress3(h2, data, offset) {
|
|
|
58673
58757
|
ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
|
|
58674
58758
|
al = nl >>> 0;
|
|
58675
58759
|
}
|
|
58676
|
-
const
|
|
58760
|
+
const add3 = (i2, xh, xl) => {
|
|
58677
58761
|
const lo = (h2[i2 + 1] >>> 0) + (xl >>> 0);
|
|
58678
58762
|
h2[i2] = h2[i2] + xh + Math.floor(lo / 4294967296) >>> 0;
|
|
58679
58763
|
h2[i2 + 1] = lo >>> 0;
|
|
58680
58764
|
};
|
|
58681
|
-
|
|
58682
|
-
|
|
58683
|
-
|
|
58684
|
-
|
|
58685
|
-
|
|
58686
|
-
|
|
58687
|
-
|
|
58688
|
-
|
|
58765
|
+
add3(0, ah, al);
|
|
58766
|
+
add3(2, bh, bl);
|
|
58767
|
+
add3(4, ch, cl);
|
|
58768
|
+
add3(6, dh, dl);
|
|
58769
|
+
add3(8, eh, el);
|
|
58770
|
+
add3(10, fh, fl);
|
|
58771
|
+
add3(12, gh, gl);
|
|
58772
|
+
add3(14, hh, hl);
|
|
58689
58773
|
}
|
|
58690
58774
|
function digest64(data, iv, bytes) {
|
|
58691
58775
|
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"}
|
package/dist/opc/index.cjs
CHANGED
|
@@ -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(/"/gu, '"').replace(/'/gu, "'").replace(/</gu, "<").replace(/>/gu, ">").replace(/&/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;
|
package/dist/opc/index.d.ts
CHANGED
|
@@ -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
|
package/dist/opc/index.d.ts.map
CHANGED
|
@@ -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"}
|