@office-open/core 0.9.7 → 0.10.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/chart/index.d.mts +1 -1
- package/dist/descriptor/index.d.mts +2 -2
- package/dist/descriptor/index.mjs +2 -2
- package/dist/descriptor-BdWTH1vv.mjs +444 -0
- package/dist/drawingml/index.d.mts +2 -2
- package/dist/drawingml/index.mjs +2 -2
- package/dist/{index-DMw7eid7.d.mts → index-BEQ12eyX.d.mts} +42 -42
- package/dist/{index-eu1aFQCm.d.mts → index-CsQP7Cl4.d.mts} +36 -36
- package/dist/index-DEeO4sOq.d.mts +239 -0
- package/dist/index-L82O3q6V.d.mts +170 -0
- package/dist/{index-CDYC3mxJ.d.mts → index-pvj6gDsT.d.mts} +832 -179
- package/dist/{index-4hjRdzMU.d.mts → index-vEeWkbm5.d.mts} +20 -20
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +4 -4
- package/dist/patch/index.d.mts +2 -2
- package/dist/patch/index.mjs +2 -2
- package/dist/{patch-ilNZTQmG.mjs → patch-DocIv0Sn.mjs} +125 -3
- package/dist/smartart/index.d.mts +1 -1
- package/dist/{src-DlZssiRY.mjs → src-CXdJt0WZ.mjs} +1214 -263
- package/dist/theme/index.d.mts +1 -1
- package/package.json +2 -2
- package/dist/descriptor-DcQm32dg.mjs +0 -71
- package/dist/index-C4r2WLEy.d.mts +0 -73
- package/dist/index-DmPBJwSk.d.mts +0 -127
|
@@ -1,17 +1,13 @@
|
|
|
1
|
+
import "./patch-DocIv0Sn.mjs";
|
|
1
2
|
import "./smartart-DCY-Vdv7.mjs";
|
|
2
3
|
import "./chart-DwE8FCFk.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import "./patch-ilNZTQmG.mjs";
|
|
4
|
+
import { d as parse$1, f as stringify$1 } from "./descriptor-BdWTH1vv.mjs";
|
|
5
5
|
import "./theme-CiNzdl-9.mjs";
|
|
6
6
|
import { attr, attrNum, element, escapeXml, findChild, js2xml, stringify, textOf, xml2js } from "@office-open/xml";
|
|
7
7
|
import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, strToU8, unzipSync, unzipSync as unzipSync$1, zip, zipSync } from "fflate";
|
|
8
8
|
import { sha1 } from "@noble/hashes/legacy.js";
|
|
9
9
|
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
10
10
|
import { sha512 } from "@noble/hashes/sha2.js";
|
|
11
|
-
//#region src/opc/app-properties.ts
|
|
12
|
-
/** Static app properties XML constant. */
|
|
13
|
-
const APP_PROPS_XML = "<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\"><Application>Microsoft Office Word</Application></Properties>";
|
|
14
|
-
//#endregion
|
|
15
11
|
//#region src/opc/relationships.ts
|
|
16
12
|
const TargetModeType = { EXTERNAL: "External" };
|
|
17
13
|
/**
|
|
@@ -55,103 +51,162 @@ const createDefault = (contentType, extension) => extension !== void 0 ? `<Defau
|
|
|
55
51
|
*/
|
|
56
52
|
const createOverride = (contentType, partName) => partName !== void 0 ? `<Override ContentType="${contentType}" PartName="${partName}"/>` : `<Override ContentType="${contentType}"/>`;
|
|
57
53
|
//#endregion
|
|
58
|
-
//#region src/opc/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
54
|
+
//#region src/opc/app-properties.ts
|
|
55
|
+
/**
|
|
56
|
+
* Extended (App) Properties module — shared OPC part (docProps/app.xml).
|
|
57
|
+
*
|
|
58
|
+
* Format-agnostic: CT_Properties (ISO-IEC29500-2_2016 shared-documentPropertiesExtended.xsd)
|
|
59
|
+
* is identical across docx/pptx/xlsx. Each package surfaces only the fields it populates
|
|
60
|
+
* (Pages/Words for docx, Slides for pptx, etc.) — all fields are optional.
|
|
61
|
+
*
|
|
62
|
+
* @module
|
|
63
|
+
*/
|
|
64
|
+
/** xsd:boolean lexical form — spec canonical form is "true"/"false" (Word's convention). */
|
|
65
|
+
const xsdBoolean = (value) => value ? "true" : "false";
|
|
66
|
+
const appPropertiesDesc = {
|
|
67
|
+
kind: "custom",
|
|
68
|
+
stringify(opts, _ctx) {
|
|
69
|
+
const p = ["<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">"];
|
|
70
|
+
if (opts.template !== void 0) p.push(`<Template>${escapeXml(opts.template)}</Template>`);
|
|
71
|
+
if (opts.manager !== void 0) p.push(`<Manager>${escapeXml(opts.manager)}</Manager>`);
|
|
72
|
+
if (opts.company !== void 0) p.push(`<Company>${escapeXml(opts.company)}</Company>`);
|
|
73
|
+
if (opts.pages !== void 0) p.push(`<Pages>${opts.pages}</Pages>`);
|
|
74
|
+
if (opts.words !== void 0) p.push(`<Words>${opts.words}</Words>`);
|
|
75
|
+
if (opts.characters !== void 0) p.push(`<Characters>${opts.characters}</Characters>`);
|
|
76
|
+
if (opts.lines !== void 0) p.push(`<Lines>${opts.lines}</Lines>`);
|
|
77
|
+
if (opts.paragraphs !== void 0) p.push(`<Paragraphs>${opts.paragraphs}</Paragraphs>`);
|
|
78
|
+
if (opts.slides !== void 0) p.push(`<Slides>${opts.slides}</Slides>`);
|
|
79
|
+
if (opts.notes !== void 0) p.push(`<Notes>${opts.notes}</Notes>`);
|
|
80
|
+
if (opts.totalTime !== void 0) p.push(`<TotalTime>${opts.totalTime}</TotalTime>`);
|
|
81
|
+
if (opts.hiddenSlides !== void 0) p.push(`<HiddenSlides>${opts.hiddenSlides}</HiddenSlides>`);
|
|
82
|
+
if (opts.mmClips !== void 0) p.push(`<MMClips>${opts.mmClips}</MMClips>`);
|
|
83
|
+
if (opts.scaleCrop !== void 0) p.push(`<ScaleCrop>${xsdBoolean(opts.scaleCrop)}</ScaleCrop>`);
|
|
84
|
+
if (opts.linksUpToDate !== void 0) p.push(`<LinksUpToDate>${xsdBoolean(opts.linksUpToDate)}</LinksUpToDate>`);
|
|
85
|
+
if (opts.charactersWithSpaces !== void 0) p.push(`<CharactersWithSpaces>${opts.charactersWithSpaces}</CharactersWithSpaces>`);
|
|
86
|
+
if (opts.sharedDoc !== void 0) p.push(`<SharedDoc>${xsdBoolean(opts.sharedDoc)}</SharedDoc>`);
|
|
87
|
+
if (opts.hyperlinkBase !== void 0) p.push(`<HyperlinkBase>${escapeXml(opts.hyperlinkBase)}</HyperlinkBase>`);
|
|
88
|
+
if (opts.hyperlinksChanged !== void 0) p.push(`<HyperlinksChanged>${xsdBoolean(opts.hyperlinksChanged)}</HyperlinksChanged>`);
|
|
89
|
+
if (opts.application !== void 0) p.push(`<Application>${escapeXml(opts.application)}</Application>`);
|
|
90
|
+
if (opts.appVersion !== void 0) p.push(`<AppVersion>${escapeXml(opts.appVersion)}</AppVersion>`);
|
|
91
|
+
if (opts.docSecurity !== void 0) p.push(`<DocSecurity>${opts.docSecurity}</DocSecurity>`);
|
|
92
|
+
p.push("</Properties>");
|
|
93
|
+
return p.join("");
|
|
79
94
|
},
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
parse(el, _ctx) {
|
|
96
|
+
const result = {};
|
|
97
|
+
for (const child of el.elements ?? []) {
|
|
98
|
+
if (typeof child.name !== "string") continue;
|
|
99
|
+
const text = child.elements?.[0]?.text;
|
|
100
|
+
switch (child.name) {
|
|
101
|
+
case "Template":
|
|
102
|
+
if (typeof text === "string") result.template = text;
|
|
103
|
+
break;
|
|
104
|
+
case "Manager":
|
|
105
|
+
if (typeof text === "string") result.manager = text;
|
|
106
|
+
break;
|
|
107
|
+
case "Company":
|
|
108
|
+
if (typeof text === "string") result.company = text;
|
|
109
|
+
break;
|
|
110
|
+
case "Pages":
|
|
111
|
+
if (typeof text === "string") result.pages = Number(text);
|
|
112
|
+
break;
|
|
113
|
+
case "Words":
|
|
114
|
+
if (typeof text === "string") result.words = Number(text);
|
|
115
|
+
break;
|
|
116
|
+
case "Characters":
|
|
117
|
+
if (typeof text === "string") result.characters = Number(text);
|
|
118
|
+
break;
|
|
119
|
+
case "Lines":
|
|
120
|
+
if (typeof text === "string") result.lines = Number(text);
|
|
121
|
+
break;
|
|
122
|
+
case "Paragraphs":
|
|
123
|
+
if (typeof text === "string") result.paragraphs = Number(text);
|
|
124
|
+
break;
|
|
125
|
+
case "Slides":
|
|
126
|
+
if (typeof text === "string") result.slides = Number(text);
|
|
127
|
+
break;
|
|
128
|
+
case "Notes":
|
|
129
|
+
if (typeof text === "string") result.notes = Number(text);
|
|
130
|
+
break;
|
|
131
|
+
case "TotalTime":
|
|
132
|
+
if (typeof text === "string") result.totalTime = Number(text);
|
|
133
|
+
break;
|
|
134
|
+
case "HiddenSlides":
|
|
135
|
+
if (typeof text === "string") result.hiddenSlides = Number(text);
|
|
136
|
+
break;
|
|
137
|
+
case "MMClips":
|
|
138
|
+
if (typeof text === "string") result.mmClips = Number(text);
|
|
139
|
+
break;
|
|
140
|
+
case "ScaleCrop":
|
|
141
|
+
if (typeof text === "string") result.scaleCrop = text === "1" || text === "true";
|
|
142
|
+
break;
|
|
143
|
+
case "LinksUpToDate":
|
|
144
|
+
if (typeof text === "string") result.linksUpToDate = text === "1" || text === "true";
|
|
145
|
+
break;
|
|
146
|
+
case "CharactersWithSpaces":
|
|
147
|
+
if (typeof text === "string") result.charactersWithSpaces = Number(text);
|
|
148
|
+
break;
|
|
149
|
+
case "SharedDoc":
|
|
150
|
+
if (typeof text === "string") result.sharedDoc = text === "1" || text === "true";
|
|
151
|
+
break;
|
|
152
|
+
case "HyperlinkBase":
|
|
153
|
+
if (typeof text === "string") result.hyperlinkBase = text;
|
|
154
|
+
break;
|
|
155
|
+
case "HyperlinksChanged":
|
|
156
|
+
if (typeof text === "string") result.hyperlinksChanged = text === "1" || text === "true";
|
|
157
|
+
break;
|
|
158
|
+
case "Application":
|
|
159
|
+
if (typeof text === "string") result.application = text;
|
|
160
|
+
break;
|
|
161
|
+
case "AppVersion":
|
|
162
|
+
if (typeof text === "string") result.appVersion = text;
|
|
163
|
+
break;
|
|
164
|
+
case "DocSecurity":
|
|
165
|
+
if (typeof text === "string") result.docSecurity = Number(text);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
83
170
|
}
|
|
84
|
-
|
|
171
|
+
};
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/opc/custom-properties.ts
|
|
85
174
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const n = Number(rev);
|
|
102
|
-
if (!isNaN(n)) props.revision = rev;
|
|
175
|
+
* Custom Properties module — shared OPC part (docProps/custom.xml).
|
|
176
|
+
*
|
|
177
|
+
* Format-agnostic: CT_CustomProperties (ISO-IEC29500-4_2016 shared-documentPropertiesCustom.xsd)
|
|
178
|
+
* is identical across docx/pptx/xlsx.
|
|
179
|
+
*
|
|
180
|
+
* @module
|
|
181
|
+
*/
|
|
182
|
+
const customPropertiesDesc = {
|
|
183
|
+
kind: "custom",
|
|
184
|
+
stringify(opts, _ctx) {
|
|
185
|
+
const p = ["<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties\" xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">"];
|
|
186
|
+
let pid = 2;
|
|
187
|
+
for (const prop of opts.properties) {
|
|
188
|
+
p.push(`<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="${pid}" name="${escapeXml(prop.name)}"><vt:lpwstr>${escapeXml(prop.value)}</vt:lpwstr></property>`);
|
|
189
|
+
pid++;
|
|
103
190
|
}
|
|
191
|
+
p.push("</Properties>");
|
|
192
|
+
return p.join("");
|
|
193
|
+
},
|
|
194
|
+
parse(el, _ctx) {
|
|
195
|
+
const properties = [];
|
|
196
|
+
for (const child of el.elements ?? []) {
|
|
197
|
+
if (child.name !== "property") continue;
|
|
198
|
+
const name = attr(child, "name");
|
|
199
|
+
if (!name) continue;
|
|
200
|
+
const valueEl = child.elements?.find((e) => e.name?.startsWith("vt:"));
|
|
201
|
+
const value = valueEl ? textOf(valueEl) ?? "" : "";
|
|
202
|
+
properties.push({
|
|
203
|
+
name,
|
|
204
|
+
value
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return { properties };
|
|
104
208
|
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
const CORE_PROPS_NS = Object.freeze({ _attr: Object.freeze({
|
|
108
|
-
"xmlns:cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
109
|
-
"xmlns:dc": "http://purl.org/dc/elements/1.1/",
|
|
110
|
-
"xmlns:dcmitype": "http://purl.org/dc/dcmitype/",
|
|
111
|
-
"xmlns:dcterms": "http://purl.org/dc/terms/",
|
|
112
|
-
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
|
|
113
|
-
}) });
|
|
114
|
-
const W3CDTF_ATTR = Object.freeze({ _attr: Object.freeze({ "xsi:type": "dcterms:W3CDTF" }) });
|
|
115
|
-
/**
|
|
116
|
-
* Build a cp:coreProperties XML object from metadata.
|
|
117
|
-
*
|
|
118
|
-
* Shared by docx and pptx to avoid duplicating namespace declarations
|
|
119
|
-
* and Dublin Core property construction.
|
|
120
|
-
*/
|
|
121
|
-
function buildCorePropertiesXml(opts) {
|
|
122
|
-
const children = [CORE_PROPS_NS];
|
|
123
|
-
if (opts.title) children.push({ "dc:title": [opts.title] });
|
|
124
|
-
if (opts.subject) children.push({ "dc:subject": [opts.subject] });
|
|
125
|
-
if (opts.creator) children.push({ "dc:creator": [opts.creator] });
|
|
126
|
-
if (opts.keywords) children.push({ "cp:keywords": [opts.keywords] });
|
|
127
|
-
if (opts.description) children.push({ "dc:description": [opts.description] });
|
|
128
|
-
children.push({ "cp:lastModifiedBy": [opts.lastModifiedBy || opts.creator || "Unknown"] });
|
|
129
|
-
if (opts.revision) children.push({ "cp:revision": [String(opts.revision)] });
|
|
130
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
131
|
-
children.push({ "dcterms:created": [W3CDTF_ATTR, now] });
|
|
132
|
-
children.push({ "dcterms:modified": [W3CDTF_ATTR, now] });
|
|
133
|
-
return { "cp:coreProperties": children };
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Build a cp:coreProperties XML string directly (fast path).
|
|
137
|
-
*
|
|
138
|
-
* Shared by pptx and xlsx to bypass the toXml() → xml() pipeline.
|
|
139
|
-
*/
|
|
140
|
-
function buildCorePropertiesXmlString(opts) {
|
|
141
|
-
const p = ["<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"];
|
|
142
|
-
if (opts.title) p.push(`<dc:title>${escapeXml(opts.title)}</dc:title>`);
|
|
143
|
-
if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);
|
|
144
|
-
if (opts.creator) p.push(`<dc:creator>${escapeXml(opts.creator)}</dc:creator>`);
|
|
145
|
-
if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);
|
|
146
|
-
if (opts.description) p.push(`<dc:description>${escapeXml(opts.description)}</dc:description>`);
|
|
147
|
-
p.push(`<cp:lastModifiedBy>${escapeXml(opts.lastModifiedBy || opts.creator || "Unknown")}</cp:lastModifiedBy>`);
|
|
148
|
-
if (opts.revision) p.push(`<cp:revision>${opts.revision}</cp:revision>`);
|
|
149
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
150
|
-
p.push(`<dcterms:created xsi:type="dcterms:W3CDTF">${now}</dcterms:created>`);
|
|
151
|
-
p.push(`<dcterms:modified xsi:type="dcterms:W3CDTF">${now}</dcterms:modified>`);
|
|
152
|
-
p.push("</cp:coreProperties>");
|
|
153
|
-
return p.join("");
|
|
154
|
-
}
|
|
209
|
+
};
|
|
155
210
|
//#endregion
|
|
156
211
|
//#region \0polyfill-node.global.js
|
|
157
212
|
var _polyfill_node_global_default = typeof _polyfill_node_global_default !== "undefined" ? _polyfill_node_global_default : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
@@ -1404,6 +1459,49 @@ function isSlowBuffer(obj) {
|
|
|
1404
1459
|
return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
|
|
1405
1460
|
}
|
|
1406
1461
|
//#endregion
|
|
1462
|
+
//#region src/util/base64.ts
|
|
1463
|
+
/**
|
|
1464
|
+
* Shared base64 encode/decode helpers.
|
|
1465
|
+
*
|
|
1466
|
+
* Both prefer the native `Uint8Array` base64 methods (Node 22+, modern
|
|
1467
|
+
* browsers): they avoid the intermediate binary string that `btoa`/`atob`
|
|
1468
|
+
* materialize and cannot stack-overflow on large buffers. Node `Buffer` is the
|
|
1469
|
+
* secondary path; a manual loop covers older runtimes.
|
|
1470
|
+
*
|
|
1471
|
+
* @module
|
|
1472
|
+
*/
|
|
1473
|
+
/**
|
|
1474
|
+
* Decode a base64 string into a `Uint8Array`.
|
|
1475
|
+
*
|
|
1476
|
+
* Prefers native `Uint8Array.fromBase64` (no intermediate binary string), then
|
|
1477
|
+
* Node `Buffer` (zero-copy), then `atob`.
|
|
1478
|
+
*/
|
|
1479
|
+
function decodeBase64(input) {
|
|
1480
|
+
const fromBase64 = Uint8Array.fromBase64;
|
|
1481
|
+
if (typeof fromBase64 === "function") return fromBase64.call(Uint8Array, input);
|
|
1482
|
+
if (typeof Buffer !== "undefined") return Buffer.from(input, "base64");
|
|
1483
|
+
return Uint8Array.from(atob(input), (c) => c.codePointAt(0));
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Encode a `Uint8Array` into a base64 string.
|
|
1487
|
+
*
|
|
1488
|
+
* Prefers native `Uint8Array.prototype.toBase64` (no intermediate binary
|
|
1489
|
+
* string), then Node `Buffer` (zero-copy), then a `btoa` fallback.
|
|
1490
|
+
*
|
|
1491
|
+
* The fallback builds the binary string in a loop rather than
|
|
1492
|
+
* `String.fromCharCode(...bytes)` — the spread form places every byte on the
|
|
1493
|
+
* call stack and overflows for large buffers (V8 caps function arguments near
|
|
1494
|
+
* ~65k).
|
|
1495
|
+
*/
|
|
1496
|
+
function encodeBase64(bytes) {
|
|
1497
|
+
const toBase64 = Uint8Array.prototype.toBase64;
|
|
1498
|
+
if (typeof toBase64 === "function") return toBase64.call(bytes);
|
|
1499
|
+
if (typeof Buffer !== "undefined") return Buffer.from(bytes).toString("base64");
|
|
1500
|
+
let binary = "";
|
|
1501
|
+
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
1502
|
+
return btoa(binary);
|
|
1503
|
+
}
|
|
1504
|
+
//#endregion
|
|
1407
1505
|
//#region src/opc/output.ts
|
|
1408
1506
|
/**
|
|
1409
1507
|
* Output type definitions for OOXML document export.
|
|
@@ -1421,7 +1519,7 @@ const convertOutput = (data, type, mimeType = OoxmlMimeType.DOCX) => {
|
|
|
1421
1519
|
case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: mimeType });
|
|
1422
1520
|
case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
1423
1521
|
case "uint8array": return data;
|
|
1424
|
-
case "base64": return
|
|
1522
|
+
case "base64": return encodeBase64(data);
|
|
1425
1523
|
case "string":
|
|
1426
1524
|
case "text":
|
|
1427
1525
|
case "binarystring": return strFromU8(data, true);
|
|
@@ -1616,16 +1714,6 @@ async function nativeZipAsync(files, level = 6) {
|
|
|
1616
1714
|
*
|
|
1617
1715
|
* @module
|
|
1618
1716
|
*/
|
|
1619
|
-
function toUint8Array$1(data) {
|
|
1620
|
-
if (data instanceof Uint8Array) return data;
|
|
1621
|
-
if (data instanceof ArrayBuffer || data instanceof SharedArrayBuffer) return new Uint8Array(data);
|
|
1622
|
-
if (data instanceof DataView) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
1623
|
-
if (typeof data === "string") return new TextEncoder().encode(data);
|
|
1624
|
-
if (Array.isArray(data)) return new Uint8Array(data);
|
|
1625
|
-
if (data instanceof Blob) throw new TypeError("Blob input requires async processing");
|
|
1626
|
-
if (data instanceof ReadableStream) throw new TypeError("ReadableStream input requires async processing");
|
|
1627
|
-
throw new TypeError(`Unsupported data type: ${typeof data}`);
|
|
1628
|
-
}
|
|
1629
1717
|
/** Default DEFLATE level for XML entries (SuperFast, matching MS Office). */
|
|
1630
1718
|
const ZIP_DEFLATE_LEVEL = 1;
|
|
1631
1719
|
/** Default level for media entries (STORE — no compression). */
|
|
@@ -1921,6 +2009,848 @@ function parseArchive(data) {
|
|
|
1921
2009
|
return new ParsedArchive(data);
|
|
1922
2010
|
}
|
|
1923
2011
|
//#endregion
|
|
2012
|
+
//#region src/opc/opc-consistency.ts
|
|
2013
|
+
/**
|
|
2014
|
+
* OPC (Open Packaging Convention) consistency validator.
|
|
2015
|
+
*
|
|
2016
|
+
* Pure function operating on an already-unzipped part map. Detects the three
|
|
2017
|
+
* classes of cross-part breakage that single-part XSD validation cannot see:
|
|
2018
|
+
*
|
|
2019
|
+
* - relationship integrity — dangling targets, duplicate rIds (O3/O7)
|
|
2020
|
+
* - content-type integrity — parts with no Override/Default, stale
|
|
2021
|
+
* Overrides pointing at absent parts (O5/O6)
|
|
2022
|
+
* - structural integrity — missing `always` parts, undeclared orphans
|
|
2023
|
+
* (O1/O2)
|
|
2024
|
+
*
|
|
2025
|
+
* O3/O5/O6/O7 are derived directly from the ZIP + `.rels` + `[Content_Types].xml`
|
|
2026
|
+
* and need no registry. O1/O2 consult {@link PackagePartRegistry}.
|
|
2027
|
+
*
|
|
2028
|
+
* Reference: ECMA-376 Part 2 (OPC).
|
|
2029
|
+
*
|
|
2030
|
+
* @module
|
|
2031
|
+
*/
|
|
2032
|
+
function rootElement(xml) {
|
|
2033
|
+
try {
|
|
2034
|
+
return xml2js(xml).elements?.find((e) => e.type === "element");
|
|
2035
|
+
} catch {
|
|
2036
|
+
return;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
function parseContentTypes(entries) {
|
|
2040
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
2041
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
2042
|
+
const xml = entries.get("[Content_Types].xml");
|
|
2043
|
+
const root = xml ? rootElement(xml) : void 0;
|
|
2044
|
+
if (!root) return {
|
|
2045
|
+
defaults,
|
|
2046
|
+
overrides
|
|
2047
|
+
};
|
|
2048
|
+
for (const child of root.elements ?? []) {
|
|
2049
|
+
if (child.type !== "element") continue;
|
|
2050
|
+
if (child.name === "Default") {
|
|
2051
|
+
const ext = String(child.attributes?.Extension ?? "").toLowerCase();
|
|
2052
|
+
const ct = String(child.attributes?.ContentType ?? "");
|
|
2053
|
+
if (ext && ct) defaults.set(ext, ct);
|
|
2054
|
+
} else if (child.name === "Override") {
|
|
2055
|
+
const partName = normalizePartName(String(child.attributes?.PartName ?? ""));
|
|
2056
|
+
const ct = String(child.attributes?.ContentType ?? "");
|
|
2057
|
+
if (partName && ct) overrides.set(partName, ct);
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
return {
|
|
2061
|
+
defaults,
|
|
2062
|
+
overrides
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
2065
|
+
function parseAllRels(entries) {
|
|
2066
|
+
const out = [];
|
|
2067
|
+
for (const [relsPath, xml] of entries) {
|
|
2068
|
+
if (!relsPath.endsWith(".rels")) continue;
|
|
2069
|
+
const root = rootElement(xml);
|
|
2070
|
+
if (!root) continue;
|
|
2071
|
+
const list = [];
|
|
2072
|
+
for (const child of root.elements ?? []) {
|
|
2073
|
+
if (child.type !== "element" || child.name !== "Relationship") continue;
|
|
2074
|
+
list.push({
|
|
2075
|
+
id: String(child.attributes?.Id ?? ""),
|
|
2076
|
+
type: String(child.attributes?.Type ?? ""),
|
|
2077
|
+
target: String(child.attributes?.Target ?? ""),
|
|
2078
|
+
targetMode: child.attributes?.TargetMode ? String(child.attributes?.TargetMode) : void 0
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
out.push({
|
|
2082
|
+
relsPath,
|
|
2083
|
+
entries: list
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
return out;
|
|
2087
|
+
}
|
|
2088
|
+
/** Strip the leading slash OPC uses on `PartName` to align with ZIP paths. */
|
|
2089
|
+
function normalizePartName(partName) {
|
|
2090
|
+
return partName.startsWith("/") ? partName.slice(1) : partName;
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Resolve a relationship `Target` (relative to its owning `.rels`) against the
|
|
2094
|
+
* ZIP root. Handles the `..` segments slides/masters use to reference siblings.
|
|
2095
|
+
*/
|
|
2096
|
+
function resolveRelTarget(relsPath, target) {
|
|
2097
|
+
const slash = relsPath.lastIndexOf("/");
|
|
2098
|
+
const relsDir = slash === -1 ? "" : relsPath.slice(0, slash);
|
|
2099
|
+
const base = relsDir === "_rels" ? "" : relsDir.endsWith("/_rels") ? relsDir.slice(0, -6) : relsDir;
|
|
2100
|
+
const segments = (base ? base.split("/") : []).concat(target.split("/"));
|
|
2101
|
+
const resolved = [];
|
|
2102
|
+
for (const seg of segments) {
|
|
2103
|
+
if (seg === "" || seg === ".") continue;
|
|
2104
|
+
if (seg === "..") resolved.pop();
|
|
2105
|
+
else resolved.push(seg);
|
|
2106
|
+
}
|
|
2107
|
+
return resolved.join("/");
|
|
2108
|
+
}
|
|
2109
|
+
/** Compile a registry path template (with `${i}`) into an anchored matcher. */
|
|
2110
|
+
function pathMatcher(template) {
|
|
2111
|
+
const pattern = template.replace(/\$\{i\}/g, "\0").replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(//g, "(\\d+)");
|
|
2112
|
+
return new RegExp(`^${pattern}$`);
|
|
2113
|
+
}
|
|
2114
|
+
function extensionOf(path) {
|
|
2115
|
+
const dot = path.lastIndexOf(".");
|
|
2116
|
+
return dot === -1 ? "" : path.slice(dot + 1).toLowerCase();
|
|
2117
|
+
}
|
|
2118
|
+
/**
|
|
2119
|
+
* Validate OPC consistency of an unzipped package.
|
|
2120
|
+
*
|
|
2121
|
+
* @param entries ZIP path → decoded XML/binary text. Binary parts (media,
|
|
2122
|
+
* fonts) are never parsed here — only their presence matters.
|
|
2123
|
+
* @param registry Declarative part expectations for the package format.
|
|
2124
|
+
* @returns Issues sorted by code then part. Empty array = consistent.
|
|
2125
|
+
*/
|
|
2126
|
+
function validateOpcConsistency(entries, registry) {
|
|
2127
|
+
const issues = [];
|
|
2128
|
+
const contentTypes = parseContentTypes(entries);
|
|
2129
|
+
const relsFiles = parseAllRels(entries);
|
|
2130
|
+
for (const def of registry.parts) {
|
|
2131
|
+
if (def.presence.kind !== "always" || def.path.includes("${i}")) continue;
|
|
2132
|
+
if (!entries.has(def.path)) issues.push({
|
|
2133
|
+
code: "O2",
|
|
2134
|
+
severity: "error",
|
|
2135
|
+
part: def.path,
|
|
2136
|
+
message: `required ${registry.format} part is absent from the package`
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
const matchers = registry.parts.map((def) => pathMatcher(def.path));
|
|
2140
|
+
for (const path of entries.keys()) {
|
|
2141
|
+
if (path === "[Content_Types].xml") continue;
|
|
2142
|
+
if (path.endsWith(".rels")) continue;
|
|
2143
|
+
if (registry.orphanWhitelist.some((prefix) => path.startsWith(prefix))) continue;
|
|
2144
|
+
if (matchers.some((re) => re.test(path))) continue;
|
|
2145
|
+
issues.push({
|
|
2146
|
+
code: "O1",
|
|
2147
|
+
severity: "warn",
|
|
2148
|
+
part: path,
|
|
2149
|
+
message: `part not declared in the ${registry.format} registry (possible orphan)`
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
for (const rf of relsFiles) for (const rel of rf.entries) {
|
|
2153
|
+
if (rel.targetMode === "External") continue;
|
|
2154
|
+
if (/^https?:\/\//i.test(rel.target)) continue;
|
|
2155
|
+
const resolved = resolveRelTarget(rf.relsPath, rel.target);
|
|
2156
|
+
if (!resolved || entries.has(resolved)) continue;
|
|
2157
|
+
issues.push({
|
|
2158
|
+
code: "O3",
|
|
2159
|
+
severity: "error",
|
|
2160
|
+
part: rf.relsPath,
|
|
2161
|
+
message: `relationship ${rel.id || "(no Id)"} (${rel.type}) Target "${rel.target}" resolves to absent part "${resolved}"`
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
for (const path of entries.keys()) {
|
|
2165
|
+
if (path === "[Content_Types].xml" || path.endsWith(".rels")) continue;
|
|
2166
|
+
if (contentTypes.overrides.has(path)) continue;
|
|
2167
|
+
const ext = extensionOf(path);
|
|
2168
|
+
if (ext && contentTypes.defaults.has(ext)) continue;
|
|
2169
|
+
issues.push({
|
|
2170
|
+
code: "O5",
|
|
2171
|
+
severity: "error",
|
|
2172
|
+
part: path,
|
|
2173
|
+
message: `part has no [Content_Types] Override and no Default covers extension "${ext || "(none)"}"`
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
for (const partName of contentTypes.overrides.keys()) {
|
|
2177
|
+
if (entries.has(partName)) continue;
|
|
2178
|
+
issues.push({
|
|
2179
|
+
code: "O6",
|
|
2180
|
+
severity: "error",
|
|
2181
|
+
part: `/${partName}`,
|
|
2182
|
+
message: `[Content_Types] Override references absent part "${partName}"`
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
for (const rf of relsFiles) {
|
|
2186
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2187
|
+
for (const rel of rf.entries) {
|
|
2188
|
+
if (!rel.id) continue;
|
|
2189
|
+
counts.set(rel.id, (counts.get(rel.id) ?? 0) + 1);
|
|
2190
|
+
}
|
|
2191
|
+
for (const [id, count] of counts) {
|
|
2192
|
+
if (count <= 1) continue;
|
|
2193
|
+
issues.push({
|
|
2194
|
+
code: "O7",
|
|
2195
|
+
severity: "warn",
|
|
2196
|
+
part: rf.relsPath,
|
|
2197
|
+
message: `duplicate relationship Id "${id}" appears ${count} times`
|
|
2198
|
+
});
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
return issues.sort((a, b) => a.code === b.code ? a.part.localeCompare(b.part) : a.code.localeCompare(b.code));
|
|
2202
|
+
}
|
|
2203
|
+
function summarizeOpcIssues(issues) {
|
|
2204
|
+
let errors = 0;
|
|
2205
|
+
let warnings = 0;
|
|
2206
|
+
for (const i of issues) if (i.severity === "error") errors++;
|
|
2207
|
+
else warnings++;
|
|
2208
|
+
return {
|
|
2209
|
+
errors,
|
|
2210
|
+
warnings
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
//#endregion
|
|
2214
|
+
//#region src/opc/part-registry.ts
|
|
2215
|
+
const DOCX_PARTS = {
|
|
2216
|
+
format: "docx",
|
|
2217
|
+
orphanWhitelist: [
|
|
2218
|
+
"word/media/",
|
|
2219
|
+
"word/fonts/",
|
|
2220
|
+
"word/embeddings/",
|
|
2221
|
+
"word/afchunks/",
|
|
2222
|
+
"customXml/",
|
|
2223
|
+
"_rels/",
|
|
2224
|
+
"word/_rels/",
|
|
2225
|
+
"docProps/",
|
|
2226
|
+
"[Content_Types].xml"
|
|
2227
|
+
],
|
|
2228
|
+
parts: [
|
|
2229
|
+
{
|
|
2230
|
+
path: "[Content_Types].xml",
|
|
2231
|
+
presence: { kind: "always" }
|
|
2232
|
+
},
|
|
2233
|
+
{
|
|
2234
|
+
path: "_rels/.rels",
|
|
2235
|
+
presence: { kind: "always" }
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
path: "word/document.xml",
|
|
2239
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",
|
|
2240
|
+
presence: { kind: "always" }
|
|
2241
|
+
},
|
|
2242
|
+
{
|
|
2243
|
+
path: "word/styles.xml",
|
|
2244
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml",
|
|
2245
|
+
presence: {
|
|
2246
|
+
kind: "conditional",
|
|
2247
|
+
flag: "freshCompile"
|
|
2248
|
+
}
|
|
2249
|
+
},
|
|
2250
|
+
{
|
|
2251
|
+
path: "word/numbering.xml",
|
|
2252
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",
|
|
2253
|
+
presence: {
|
|
2254
|
+
kind: "conditional",
|
|
2255
|
+
flag: "freshCompile"
|
|
2256
|
+
}
|
|
2257
|
+
},
|
|
2258
|
+
{
|
|
2259
|
+
path: "word/footnotes.xml",
|
|
2260
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
|
|
2261
|
+
presence: {
|
|
2262
|
+
kind: "conditional",
|
|
2263
|
+
flag: "freshCompile"
|
|
2264
|
+
}
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
path: "word/endnotes.xml",
|
|
2268
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml",
|
|
2269
|
+
presence: {
|
|
2270
|
+
kind: "conditional",
|
|
2271
|
+
flag: "freshCompile"
|
|
2272
|
+
}
|
|
2273
|
+
},
|
|
2274
|
+
{
|
|
2275
|
+
path: "word/settings.xml",
|
|
2276
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml",
|
|
2277
|
+
presence: {
|
|
2278
|
+
kind: "conditional",
|
|
2279
|
+
flag: "freshCompile"
|
|
2280
|
+
}
|
|
2281
|
+
},
|
|
2282
|
+
{
|
|
2283
|
+
path: "word/fontTable.xml",
|
|
2284
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml",
|
|
2285
|
+
presence: {
|
|
2286
|
+
kind: "conditional",
|
|
2287
|
+
flag: "freshCompile"
|
|
2288
|
+
}
|
|
2289
|
+
},
|
|
2290
|
+
{
|
|
2291
|
+
path: "docProps/core.xml",
|
|
2292
|
+
contentType: "application/vnd.openxmlformats-package.core-properties+xml",
|
|
2293
|
+
presence: {
|
|
2294
|
+
kind: "conditional",
|
|
2295
|
+
flag: "freshCompile"
|
|
2296
|
+
}
|
|
2297
|
+
},
|
|
2298
|
+
{
|
|
2299
|
+
path: "docProps/app.xml",
|
|
2300
|
+
contentType: "application/vnd.openxmlformats-officedocument.extended-properties+xml",
|
|
2301
|
+
presence: {
|
|
2302
|
+
kind: "conditional",
|
|
2303
|
+
flag: "freshCompile"
|
|
2304
|
+
}
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
path: "docProps/custom.xml",
|
|
2308
|
+
contentType: "application/vnd.openxmlformats-officedocument.custom-properties+xml",
|
|
2309
|
+
presence: {
|
|
2310
|
+
kind: "conditional",
|
|
2311
|
+
flag: "freshCompile"
|
|
2312
|
+
}
|
|
2313
|
+
},
|
|
2314
|
+
{
|
|
2315
|
+
path: "word/comments.xml",
|
|
2316
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml",
|
|
2317
|
+
presence: {
|
|
2318
|
+
kind: "conditional",
|
|
2319
|
+
flag: "hasComments"
|
|
2320
|
+
}
|
|
2321
|
+
},
|
|
2322
|
+
{
|
|
2323
|
+
path: "word/header${i}.xml",
|
|
2324
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",
|
|
2325
|
+
presence: {
|
|
2326
|
+
kind: "repeated",
|
|
2327
|
+
countFrom: "headerCount"
|
|
2328
|
+
}
|
|
2329
|
+
},
|
|
2330
|
+
{
|
|
2331
|
+
path: "word/footer${i}.xml",
|
|
2332
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",
|
|
2333
|
+
presence: {
|
|
2334
|
+
kind: "repeated",
|
|
2335
|
+
countFrom: "footerCount"
|
|
2336
|
+
}
|
|
2337
|
+
},
|
|
2338
|
+
{
|
|
2339
|
+
path: "word/charts/chart${i}.xml",
|
|
2340
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
|
|
2341
|
+
presence: {
|
|
2342
|
+
kind: "repeated",
|
|
2343
|
+
countFrom: "chartCount"
|
|
2344
|
+
}
|
|
2345
|
+
},
|
|
2346
|
+
{
|
|
2347
|
+
path: "word/diagrams/data${i}.xml",
|
|
2348
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml",
|
|
2349
|
+
presence: {
|
|
2350
|
+
kind: "repeated",
|
|
2351
|
+
countFrom: "smartArtCount"
|
|
2352
|
+
}
|
|
2353
|
+
},
|
|
2354
|
+
{
|
|
2355
|
+
path: "word/diagrams/layout${i}.xml",
|
|
2356
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml",
|
|
2357
|
+
presence: {
|
|
2358
|
+
kind: "repeated",
|
|
2359
|
+
countFrom: "smartArtCount"
|
|
2360
|
+
}
|
|
2361
|
+
},
|
|
2362
|
+
{
|
|
2363
|
+
path: "word/diagrams/quickStyle${i}.xml",
|
|
2364
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml",
|
|
2365
|
+
presence: {
|
|
2366
|
+
kind: "repeated",
|
|
2367
|
+
countFrom: "smartArtCount"
|
|
2368
|
+
}
|
|
2369
|
+
},
|
|
2370
|
+
{
|
|
2371
|
+
path: "word/diagrams/colors${i}.xml",
|
|
2372
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml",
|
|
2373
|
+
presence: {
|
|
2374
|
+
kind: "repeated",
|
|
2375
|
+
countFrom: "smartArtCount"
|
|
2376
|
+
}
|
|
2377
|
+
},
|
|
2378
|
+
{
|
|
2379
|
+
path: "word/diagrams/drawing${i}.xml",
|
|
2380
|
+
contentType: "application/vnd.ms-office.drawingml.diagramDrawing+xml",
|
|
2381
|
+
presence: {
|
|
2382
|
+
kind: "repeated",
|
|
2383
|
+
countFrom: "smartArtCount"
|
|
2384
|
+
}
|
|
2385
|
+
},
|
|
2386
|
+
{
|
|
2387
|
+
path: "word/bibliography.xml",
|
|
2388
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.bibliography+xml",
|
|
2389
|
+
presence: {
|
|
2390
|
+
kind: "conditional",
|
|
2391
|
+
flag: "hasBibliography"
|
|
2392
|
+
}
|
|
2393
|
+
},
|
|
2394
|
+
{
|
|
2395
|
+
path: "word/glossary/document.xml",
|
|
2396
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.glossary+xml",
|
|
2397
|
+
presence: {
|
|
2398
|
+
kind: "conditional",
|
|
2399
|
+
flag: "hasGlossary"
|
|
2400
|
+
}
|
|
2401
|
+
},
|
|
2402
|
+
{
|
|
2403
|
+
path: "word/webSettings.xml",
|
|
2404
|
+
contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml",
|
|
2405
|
+
presence: {
|
|
2406
|
+
kind: "conditional",
|
|
2407
|
+
flag: "hasWebSettings"
|
|
2408
|
+
}
|
|
2409
|
+
},
|
|
2410
|
+
{
|
|
2411
|
+
path: "word/theme/theme1.xml",
|
|
2412
|
+
presence: {
|
|
2413
|
+
kind: "conditional",
|
|
2414
|
+
flag: "rawParts theme"
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
]
|
|
2418
|
+
};
|
|
2419
|
+
const PPTX_PARTS = {
|
|
2420
|
+
format: "pptx",
|
|
2421
|
+
orphanWhitelist: [
|
|
2422
|
+
"ppt/media/",
|
|
2423
|
+
"ppt/embeddings/",
|
|
2424
|
+
"_rels/",
|
|
2425
|
+
"ppt/_rels/",
|
|
2426
|
+
"ppt/slideMasters/_rels/",
|
|
2427
|
+
"ppt/slideLayouts/_rels/",
|
|
2428
|
+
"ppt/slides/_rels/",
|
|
2429
|
+
"ppt/notesMasters/_rels/",
|
|
2430
|
+
"ppt/notesSlides/_rels/",
|
|
2431
|
+
"ppt/charts/_rels/",
|
|
2432
|
+
"ppt/diagrams/_rels/",
|
|
2433
|
+
"docProps/",
|
|
2434
|
+
"[Content_Types].xml"
|
|
2435
|
+
],
|
|
2436
|
+
parts: [
|
|
2437
|
+
{
|
|
2438
|
+
path: "[Content_Types].xml",
|
|
2439
|
+
presence: { kind: "always" }
|
|
2440
|
+
},
|
|
2441
|
+
{
|
|
2442
|
+
path: "_rels/.rels",
|
|
2443
|
+
presence: { kind: "always" }
|
|
2444
|
+
},
|
|
2445
|
+
{
|
|
2446
|
+
path: "ppt/presentation.xml",
|
|
2447
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml",
|
|
2448
|
+
presence: { kind: "always" }
|
|
2449
|
+
},
|
|
2450
|
+
{
|
|
2451
|
+
path: "docProps/core.xml",
|
|
2452
|
+
contentType: "application/vnd.openxmlformats-package.core-properties+xml",
|
|
2453
|
+
presence: {
|
|
2454
|
+
kind: "conditional",
|
|
2455
|
+
flag: "freshCompile"
|
|
2456
|
+
}
|
|
2457
|
+
},
|
|
2458
|
+
{
|
|
2459
|
+
path: "docProps/app.xml",
|
|
2460
|
+
contentType: "application/vnd.openxmlformats-officedocument.extended-properties+xml",
|
|
2461
|
+
presence: {
|
|
2462
|
+
kind: "conditional",
|
|
2463
|
+
flag: "freshCompile"
|
|
2464
|
+
}
|
|
2465
|
+
},
|
|
2466
|
+
{
|
|
2467
|
+
path: "ppt/theme/theme${i}.xml",
|
|
2468
|
+
contentType: "application/vnd.openxmlformats-officedocument.theme+xml",
|
|
2469
|
+
presence: {
|
|
2470
|
+
kind: "repeated",
|
|
2471
|
+
countFrom: "masters + notes/handout masters"
|
|
2472
|
+
}
|
|
2473
|
+
},
|
|
2474
|
+
{
|
|
2475
|
+
path: "ppt/presProps.xml",
|
|
2476
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.presProps+xml",
|
|
2477
|
+
presence: {
|
|
2478
|
+
kind: "conditional",
|
|
2479
|
+
flag: "freshCompile"
|
|
2480
|
+
}
|
|
2481
|
+
},
|
|
2482
|
+
{
|
|
2483
|
+
path: "ppt/viewProps.xml",
|
|
2484
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml",
|
|
2485
|
+
presence: {
|
|
2486
|
+
kind: "conditional",
|
|
2487
|
+
flag: "freshCompile"
|
|
2488
|
+
}
|
|
2489
|
+
},
|
|
2490
|
+
{
|
|
2491
|
+
path: "ppt/tableStyles.xml",
|
|
2492
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml",
|
|
2493
|
+
presence: {
|
|
2494
|
+
kind: "conditional",
|
|
2495
|
+
flag: "freshCompile"
|
|
2496
|
+
}
|
|
2497
|
+
},
|
|
2498
|
+
{
|
|
2499
|
+
path: "ppt/slideMasters/slideMaster${i}.xml",
|
|
2500
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml",
|
|
2501
|
+
presence: {
|
|
2502
|
+
kind: "repeated",
|
|
2503
|
+
countFrom: "masters.length"
|
|
2504
|
+
}
|
|
2505
|
+
},
|
|
2506
|
+
{
|
|
2507
|
+
path: "ppt/slideLayouts/slideLayout${i}.xml",
|
|
2508
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml",
|
|
2509
|
+
presence: {
|
|
2510
|
+
kind: "repeated",
|
|
2511
|
+
countFrom: "layouts.length"
|
|
2512
|
+
}
|
|
2513
|
+
},
|
|
2514
|
+
{
|
|
2515
|
+
path: "ppt/slides/slide${i}.xml",
|
|
2516
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.slide+xml",
|
|
2517
|
+
presence: {
|
|
2518
|
+
kind: "repeated",
|
|
2519
|
+
countFrom: "slides.length"
|
|
2520
|
+
}
|
|
2521
|
+
},
|
|
2522
|
+
{
|
|
2523
|
+
path: "ppt/notesMasters/notesMaster1.xml",
|
|
2524
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml",
|
|
2525
|
+
presence: {
|
|
2526
|
+
kind: "conditional",
|
|
2527
|
+
flag: "any slide has notes"
|
|
2528
|
+
}
|
|
2529
|
+
},
|
|
2530
|
+
{
|
|
2531
|
+
path: "ppt/handoutMasters/handoutMaster1.xml",
|
|
2532
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml",
|
|
2533
|
+
presence: {
|
|
2534
|
+
kind: "conditional",
|
|
2535
|
+
flag: "includeHandoutMaster"
|
|
2536
|
+
}
|
|
2537
|
+
},
|
|
2538
|
+
{
|
|
2539
|
+
path: "ppt/notesSlides/notesSlide${i}.xml",
|
|
2540
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml",
|
|
2541
|
+
presence: {
|
|
2542
|
+
kind: "repeated",
|
|
2543
|
+
countFrom: "slides with notes"
|
|
2544
|
+
}
|
|
2545
|
+
},
|
|
2546
|
+
{
|
|
2547
|
+
path: "ppt/commentAuthors.xml",
|
|
2548
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml",
|
|
2549
|
+
presence: {
|
|
2550
|
+
kind: "conditional",
|
|
2551
|
+
flag: "any slide has comments"
|
|
2552
|
+
}
|
|
2553
|
+
},
|
|
2554
|
+
{
|
|
2555
|
+
path: "ppt/comments/comment${i}.xml",
|
|
2556
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.comments+xml",
|
|
2557
|
+
presence: {
|
|
2558
|
+
kind: "repeated",
|
|
2559
|
+
countFrom: "slides with comments"
|
|
2560
|
+
}
|
|
2561
|
+
},
|
|
2562
|
+
{
|
|
2563
|
+
path: "ppt/charts/chart${i}.xml",
|
|
2564
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
|
|
2565
|
+
presence: {
|
|
2566
|
+
kind: "repeated",
|
|
2567
|
+
countFrom: "charts"
|
|
2568
|
+
}
|
|
2569
|
+
},
|
|
2570
|
+
{
|
|
2571
|
+
path: "ppt/diagrams/data${i}.xml",
|
|
2572
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml",
|
|
2573
|
+
presence: {
|
|
2574
|
+
kind: "repeated",
|
|
2575
|
+
countFrom: "smartArts"
|
|
2576
|
+
}
|
|
2577
|
+
},
|
|
2578
|
+
{
|
|
2579
|
+
path: "ppt/diagrams/layout${i}.xml",
|
|
2580
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml",
|
|
2581
|
+
presence: {
|
|
2582
|
+
kind: "repeated",
|
|
2583
|
+
countFrom: "smartArts"
|
|
2584
|
+
}
|
|
2585
|
+
},
|
|
2586
|
+
{
|
|
2587
|
+
path: "ppt/diagrams/quickStyle${i}.xml",
|
|
2588
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml",
|
|
2589
|
+
presence: {
|
|
2590
|
+
kind: "repeated",
|
|
2591
|
+
countFrom: "smartArts"
|
|
2592
|
+
}
|
|
2593
|
+
},
|
|
2594
|
+
{
|
|
2595
|
+
path: "ppt/diagrams/colors${i}.xml",
|
|
2596
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml",
|
|
2597
|
+
presence: {
|
|
2598
|
+
kind: "repeated",
|
|
2599
|
+
countFrom: "smartArts"
|
|
2600
|
+
}
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
path: "ppt/diagrams/drawing${i}.xml",
|
|
2604
|
+
contentType: "application/vnd.ms-office.drawingml.diagramDrawing+xml",
|
|
2605
|
+
presence: {
|
|
2606
|
+
kind: "repeated",
|
|
2607
|
+
countFrom: "smartArts"
|
|
2608
|
+
}
|
|
2609
|
+
},
|
|
2610
|
+
{
|
|
2611
|
+
path: "ppt/slideSyncPr/slideSyncPr${i}.xml",
|
|
2612
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.slideSyncProperties+xml",
|
|
2613
|
+
presence: {
|
|
2614
|
+
kind: "repeated",
|
|
2615
|
+
countFrom: "slides with slideSync"
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
]
|
|
2619
|
+
};
|
|
2620
|
+
const XLSX_PARTS = {
|
|
2621
|
+
format: "xlsx",
|
|
2622
|
+
orphanWhitelist: [
|
|
2623
|
+
"xl/media/",
|
|
2624
|
+
"xl/embeddings/",
|
|
2625
|
+
"_rels/",
|
|
2626
|
+
"xl/_rels/",
|
|
2627
|
+
"xl/worksheets/_rels/",
|
|
2628
|
+
"xl/chartsheets/_rels/",
|
|
2629
|
+
"xl/drawings/_rels/",
|
|
2630
|
+
"xl/pivotTables/_rels/",
|
|
2631
|
+
"xl/pivotCache/_rels/",
|
|
2632
|
+
"xl/externalLinks/_rels/",
|
|
2633
|
+
"docProps/",
|
|
2634
|
+
"[Content_Types].xml"
|
|
2635
|
+
],
|
|
2636
|
+
parts: [
|
|
2637
|
+
{
|
|
2638
|
+
path: "[Content_Types].xml",
|
|
2639
|
+
presence: { kind: "always" }
|
|
2640
|
+
},
|
|
2641
|
+
{
|
|
2642
|
+
path: "_rels/.rels",
|
|
2643
|
+
presence: { kind: "always" }
|
|
2644
|
+
},
|
|
2645
|
+
{
|
|
2646
|
+
path: "xl/workbook.xml",
|
|
2647
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",
|
|
2648
|
+
presence: { kind: "always" }
|
|
2649
|
+
},
|
|
2650
|
+
{
|
|
2651
|
+
path: "docProps/core.xml",
|
|
2652
|
+
contentType: "application/vnd.openxmlformats-package.core-properties+xml",
|
|
2653
|
+
presence: {
|
|
2654
|
+
kind: "conditional",
|
|
2655
|
+
flag: "freshCompile"
|
|
2656
|
+
}
|
|
2657
|
+
},
|
|
2658
|
+
{
|
|
2659
|
+
path: "docProps/app.xml",
|
|
2660
|
+
contentType: "application/vnd.openxmlformats-officedocument.extended-properties+xml",
|
|
2661
|
+
presence: {
|
|
2662
|
+
kind: "conditional",
|
|
2663
|
+
flag: "freshCompile"
|
|
2664
|
+
}
|
|
2665
|
+
},
|
|
2666
|
+
{
|
|
2667
|
+
path: "xl/styles.xml",
|
|
2668
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",
|
|
2669
|
+
presence: {
|
|
2670
|
+
kind: "conditional",
|
|
2671
|
+
flag: "freshCompile"
|
|
2672
|
+
}
|
|
2673
|
+
},
|
|
2674
|
+
{
|
|
2675
|
+
path: "xl/theme/theme1.xml",
|
|
2676
|
+
contentType: "application/vnd.openxmlformats-officedocument.theme+xml",
|
|
2677
|
+
presence: {
|
|
2678
|
+
kind: "conditional",
|
|
2679
|
+
flag: "freshCompile"
|
|
2680
|
+
}
|
|
2681
|
+
},
|
|
2682
|
+
{
|
|
2683
|
+
path: "xl/sharedStrings.xml",
|
|
2684
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",
|
|
2685
|
+
presence: {
|
|
2686
|
+
kind: "conditional",
|
|
2687
|
+
flag: "sharedStrings.count > 0"
|
|
2688
|
+
}
|
|
2689
|
+
},
|
|
2690
|
+
{
|
|
2691
|
+
path: "xl/worksheets/sheet${i}.xml",
|
|
2692
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
|
|
2693
|
+
presence: {
|
|
2694
|
+
kind: "repeated",
|
|
2695
|
+
countFrom: "worksheets.length"
|
|
2696
|
+
}
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
path: "xl/chartsheets/sheet${i}.xml",
|
|
2700
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml",
|
|
2701
|
+
presence: {
|
|
2702
|
+
kind: "repeated",
|
|
2703
|
+
countFrom: "chartsheets.length"
|
|
2704
|
+
}
|
|
2705
|
+
},
|
|
2706
|
+
{
|
|
2707
|
+
path: "xl/drawings/drawing${i}.xml",
|
|
2708
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawing+xml",
|
|
2709
|
+
presence: {
|
|
2710
|
+
kind: "conditional",
|
|
2711
|
+
flag: "worksheet has drawing"
|
|
2712
|
+
}
|
|
2713
|
+
},
|
|
2714
|
+
{
|
|
2715
|
+
path: "xl/comments${i}.xml",
|
|
2716
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml",
|
|
2717
|
+
presence: {
|
|
2718
|
+
kind: "conditional",
|
|
2719
|
+
flag: "worksheet.comments.length > 0"
|
|
2720
|
+
}
|
|
2721
|
+
},
|
|
2722
|
+
{
|
|
2723
|
+
path: "xl/drawings/vmlDrawing${i}.vml",
|
|
2724
|
+
presence: {
|
|
2725
|
+
kind: "conditional",
|
|
2726
|
+
flag: "worksheet.comments (legacy VML)"
|
|
2727
|
+
}
|
|
2728
|
+
},
|
|
2729
|
+
{
|
|
2730
|
+
path: "xl/charts/chart${i}.xml",
|
|
2731
|
+
contentType: "application/vnd.openxmlformats-officedocument.drawingml.chart+xml",
|
|
2732
|
+
presence: {
|
|
2733
|
+
kind: "repeated",
|
|
2734
|
+
countFrom: "charts"
|
|
2735
|
+
}
|
|
2736
|
+
},
|
|
2737
|
+
{
|
|
2738
|
+
path: "xl/pivotTables/pivotTable${i}.xml",
|
|
2739
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",
|
|
2740
|
+
presence: {
|
|
2741
|
+
kind: "repeated",
|
|
2742
|
+
countFrom: "pivotTables"
|
|
2743
|
+
}
|
|
2744
|
+
},
|
|
2745
|
+
{
|
|
2746
|
+
path: "xl/pivotCache/pivotCacheDefinition${i}.xml",
|
|
2747
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml",
|
|
2748
|
+
presence: {
|
|
2749
|
+
kind: "repeated",
|
|
2750
|
+
countFrom: "pivotCaches"
|
|
2751
|
+
}
|
|
2752
|
+
},
|
|
2753
|
+
{
|
|
2754
|
+
path: "xl/pivotCache/pivotCacheRecords${i}.xml",
|
|
2755
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml",
|
|
2756
|
+
presence: {
|
|
2757
|
+
kind: "repeated",
|
|
2758
|
+
countFrom: "pivotCaches"
|
|
2759
|
+
}
|
|
2760
|
+
},
|
|
2761
|
+
{
|
|
2762
|
+
path: "xl/tables/table${i}.xml",
|
|
2763
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",
|
|
2764
|
+
presence: {
|
|
2765
|
+
kind: "repeated",
|
|
2766
|
+
countFrom: "tables"
|
|
2767
|
+
}
|
|
2768
|
+
},
|
|
2769
|
+
{
|
|
2770
|
+
path: "xl/externalLinks/externalLink${i}.xml",
|
|
2771
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml",
|
|
2772
|
+
presence: {
|
|
2773
|
+
kind: "repeated",
|
|
2774
|
+
countFrom: "externalLinks.length"
|
|
2775
|
+
}
|
|
2776
|
+
},
|
|
2777
|
+
{
|
|
2778
|
+
path: "xl/calcChain.xml",
|
|
2779
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml",
|
|
2780
|
+
presence: {
|
|
2781
|
+
kind: "conditional",
|
|
2782
|
+
flag: "any formula cell"
|
|
2783
|
+
}
|
|
2784
|
+
},
|
|
2785
|
+
{
|
|
2786
|
+
path: "xl/revisionHeaders.xml",
|
|
2787
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml",
|
|
2788
|
+
presence: {
|
|
2789
|
+
kind: "conditional",
|
|
2790
|
+
flag: "revisionLog"
|
|
2791
|
+
}
|
|
2792
|
+
},
|
|
2793
|
+
{
|
|
2794
|
+
path: "xl/revisions/revision${i}.xml",
|
|
2795
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml",
|
|
2796
|
+
presence: {
|
|
2797
|
+
kind: "repeated",
|
|
2798
|
+
countFrom: "revisionLog.logs.length"
|
|
2799
|
+
}
|
|
2800
|
+
},
|
|
2801
|
+
{
|
|
2802
|
+
path: "xl/users.xml",
|
|
2803
|
+
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.users+xml",
|
|
2804
|
+
presence: {
|
|
2805
|
+
kind: "conditional",
|
|
2806
|
+
flag: "revisionLog.users"
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
]
|
|
2810
|
+
};
|
|
2811
|
+
const PART_REGISTRIES = {
|
|
2812
|
+
docx: DOCX_PARTS,
|
|
2813
|
+
pptx: PPTX_PARTS,
|
|
2814
|
+
xlsx: XLSX_PARTS
|
|
2815
|
+
};
|
|
2816
|
+
//#endregion
|
|
2817
|
+
//#region src/opc/content-type-overrides.ts
|
|
2818
|
+
/** Ensure a part path carries the leading slash an Override PartName requires. */
|
|
2819
|
+
function withLeadingSlash(partPath) {
|
|
2820
|
+
return partPath.startsWith("/") ? partPath : `/${partPath}`;
|
|
2821
|
+
}
|
|
2822
|
+
/**
|
|
2823
|
+
* Derive [Content_Types].xml Override entries for every registry part present
|
|
2824
|
+
* under `facts`. The `facts` keys mirror the registry's `flag` / `countFrom`
|
|
2825
|
+
* tokens: a boolean for `conditional` parts, a count for `repeated` parts.
|
|
2826
|
+
* Order follows `registry.parts`; OPC does not mandate Override order.
|
|
2827
|
+
*/
|
|
2828
|
+
function buildContentTypeOverrides(registry, facts) {
|
|
2829
|
+
const overrides = [];
|
|
2830
|
+
for (const part of registry.parts) {
|
|
2831
|
+
if (!part.contentType) continue;
|
|
2832
|
+
const presence = part.presence;
|
|
2833
|
+
if (presence.kind === "always") {
|
|
2834
|
+
if (!part.path.includes("${i}")) overrides.push({
|
|
2835
|
+
partName: withLeadingSlash(part.path),
|
|
2836
|
+
contentType: part.contentType
|
|
2837
|
+
});
|
|
2838
|
+
} else if (presence.kind === "conditional") {
|
|
2839
|
+
if (facts.get(presence.flag)) overrides.push({
|
|
2840
|
+
partName: withLeadingSlash(part.path),
|
|
2841
|
+
contentType: part.contentType
|
|
2842
|
+
});
|
|
2843
|
+
} else {
|
|
2844
|
+
const count = Number(facts.get(presence.countFrom) ?? 0);
|
|
2845
|
+
for (let i = 1; i <= count; i++) overrides.push({
|
|
2846
|
+
partName: withLeadingSlash(part.path.replace("${i}", String(i))),
|
|
2847
|
+
contentType: part.contentType
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
return overrides;
|
|
2852
|
+
}
|
|
2853
|
+
//#endregion
|
|
1924
2854
|
//#region src/drawingml/color/color-transform.ts
|
|
1925
2855
|
/**
|
|
1926
2856
|
* Creates color transform child elements as XML strings.
|
|
@@ -2496,6 +3426,38 @@ const createColorElement = (color) => {
|
|
|
2496
3426
|
*/
|
|
2497
3427
|
const createSolidFill = (options) => element("a:solidFill", void 0, [createColorElement(options)]);
|
|
2498
3428
|
//#endregion
|
|
3429
|
+
//#region src/util/data-type.ts
|
|
3430
|
+
/**
|
|
3431
|
+
* Binary input normalization.
|
|
3432
|
+
*
|
|
3433
|
+
* Accepts the full range of binary inputs (Buffer/Uint8Array/ArrayBuffer/
|
|
3434
|
+
* DataView/number[]/string/base64 data URL/…) and normalizes to `Uint8Array`.
|
|
3435
|
+
* Centralized here so every entry point (packer, patch, descriptor helpers)
|
|
3436
|
+
* shares one definition instead of re-declaring per module.
|
|
3437
|
+
*
|
|
3438
|
+
* @module
|
|
3439
|
+
*/
|
|
3440
|
+
const DATA_URL_RE = /^data:([\w.+-]+\/[\w.+-]+)?;base64,/;
|
|
3441
|
+
/** Test whether a string is a base64 data URL (`data:[mime];base64,...`). */
|
|
3442
|
+
function isBase64DataURL(input) {
|
|
3443
|
+
return DATA_URL_RE.test(input);
|
|
3444
|
+
}
|
|
3445
|
+
/** Normalize any supported binary input to a `Uint8Array`. */
|
|
3446
|
+
function toUint8Array(data) {
|
|
3447
|
+
if (data instanceof Uint8Array) return data;
|
|
3448
|
+
if (data instanceof ArrayBuffer) return new Uint8Array(data);
|
|
3449
|
+
if (data instanceof DataView) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
3450
|
+
if (typeof data === "string") {
|
|
3451
|
+
const match = data.match(DATA_URL_RE);
|
|
3452
|
+
if (match) return decodeBase64(data.slice(match[0].length));
|
|
3453
|
+
return new TextEncoder().encode(data);
|
|
3454
|
+
}
|
|
3455
|
+
if (Array.isArray(data)) return new Uint8Array(data);
|
|
3456
|
+
if (data instanceof Blob) throw new TypeError("Blob input requires async processing");
|
|
3457
|
+
if (data instanceof ReadableStream) throw new TypeError("ReadableStream input requires async processing");
|
|
3458
|
+
throw new TypeError(`Unsupported data type: ${typeof data}`);
|
|
3459
|
+
}
|
|
3460
|
+
//#endregion
|
|
2499
3461
|
//#region src/util/generators.ts
|
|
2500
3462
|
/**
|
|
2501
3463
|
* Unique ID generation utilities.
|
|
@@ -3001,7 +3963,7 @@ const createShadeElement = (shade) => {
|
|
|
3001
3963
|
});
|
|
3002
3964
|
const pathShade = shade;
|
|
3003
3965
|
const children = [];
|
|
3004
|
-
if (pathShade.
|
|
3966
|
+
if (pathShade.fillToRectangle) children.push(createRelativeRect("a:fillToRect", pathShade.fillToRectangle));
|
|
3005
3967
|
return element("a:path", { path: pathShade.path }, children);
|
|
3006
3968
|
};
|
|
3007
3969
|
/**
|
|
@@ -3035,7 +3997,7 @@ const createGradientFill = (options) => {
|
|
|
3035
3997
|
const stopElements = options.stops.map(createGradientStop);
|
|
3036
3998
|
children.push(element("a:gsLst", void 0, stopElements));
|
|
3037
3999
|
if (options.shade) children.push(createShadeElement(options.shade));
|
|
3038
|
-
if (options.
|
|
4000
|
+
if (options.tileRectangle) children.push(createRelativeRect("a:tileRect", options.tileRectangle));
|
|
3039
4001
|
return element("a:gradFill", {
|
|
3040
4002
|
flip: options.flip,
|
|
3041
4003
|
rotWithShape: options.rotateWithShape
|
|
@@ -3222,21 +4184,23 @@ const createPatternFill = (options) => {
|
|
|
3222
4184
|
function normalizeColor(color) {
|
|
3223
4185
|
return typeof color === "string" ? { value: color.replace("#", "") } : color;
|
|
3224
4186
|
}
|
|
3225
|
-
function toUint8Array(data) {
|
|
3226
|
-
return data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
3227
|
-
}
|
|
3228
4187
|
/**
|
|
3229
4188
|
* Extracts media data from a blip fill option, if present.
|
|
3230
4189
|
* Returns undefined for non-blip fills.
|
|
3231
4190
|
*
|
|
3232
4191
|
* The returned data should be registered with the document's media store
|
|
3233
4192
|
* during serialization so the packer can resolve the `{fileName}` placeholder.
|
|
4193
|
+
*
|
|
4194
|
+
* @param fill - Fill options to inspect
|
|
4195
|
+
* @param nameAllocator - Optional sequential name provider (e.g. a format
|
|
4196
|
+
* package's media counter). When omitted, falls back to a random id so the
|
|
4197
|
+
* function stays usable from contexts without a shared counter.
|
|
3234
4198
|
*/
|
|
3235
|
-
const extractBlipFillMedia = (fill) => {
|
|
4199
|
+
const extractBlipFillMedia = (fill, nameAllocator) => {
|
|
3236
4200
|
if (typeof fill === "string" || fill.type !== "blip") return void 0;
|
|
3237
4201
|
return {
|
|
3238
4202
|
data: toUint8Array(fill.data),
|
|
3239
|
-
fileName: `${uniqueId()}.${fill.imageType}`,
|
|
4203
|
+
fileName: nameAllocator ? nameAllocator(fill.imageType) : `${uniqueId()}.${fill.imageType}`,
|
|
3240
4204
|
type: fill.imageType
|
|
3241
4205
|
};
|
|
3242
4206
|
};
|
|
@@ -3268,7 +4232,7 @@ const buildFill = (options) => {
|
|
|
3268
4232
|
const children = [element("a:blip", {
|
|
3269
4233
|
cstate: "none",
|
|
3270
4234
|
"r:embed": `{${fileName}}`
|
|
3271
|
-
}, blipChildren.length > 0 ? blipChildren : void 0), createSourceRectangle(options.
|
|
4235
|
+
}, blipChildren.length > 0 ? blipChildren : void 0), createSourceRectangle(options.sourceRectangle)];
|
|
3272
4236
|
if (options.tile) children.push(createTileInfo(options.tile));
|
|
3273
4237
|
else children.push("<a:stretch><a:fillRect/></a:stretch>");
|
|
3274
4238
|
const attrs = {};
|
|
@@ -4477,11 +5441,11 @@ function stringifyPresetGeometry(options) {
|
|
|
4477
5441
|
const createGuideList = (name, guides) => {
|
|
4478
5442
|
return element(name, void 0, guides.map((guide) => `<a:gd name="${guide.name}" fmla="${guide.formula}"/>`));
|
|
4479
5443
|
};
|
|
4480
|
-
const
|
|
5444
|
+
const createAdjustPoint = (name, point) => element(name, void 0, [`<a:pt x="${point.x}" y="${point.y}"/>`]);
|
|
4481
5445
|
const createPathCommand = (cmd) => {
|
|
4482
5446
|
switch (cmd.command) {
|
|
4483
|
-
case "moveTo": return
|
|
4484
|
-
case "lineTo": return
|
|
5447
|
+
case "moveTo": return createAdjustPoint("a:moveTo", cmd.point);
|
|
5448
|
+
case "lineTo": return createAdjustPoint("a:lnTo", cmd.point);
|
|
4485
5449
|
case "arcTo": return `<a:arcTo wR="${cmd.widthRadius}" hR="${cmd.heightRadius}" stAng="${cmd.startAngle}" swAng="${cmd.sweepAngle}"/>`;
|
|
4486
5450
|
case "quadBezTo": return element("a:quadBezTo", void 0, cmd.points.map((pt) => `<a:pt x="${pt.x}" y="${pt.y}"/>`));
|
|
4487
5451
|
case "cubicBezTo": return element("a:cubicBezTo", void 0, cmd.points.map((pt) => `<a:pt x="${pt.x}" y="${pt.y}"/>`));
|
|
@@ -4536,7 +5500,7 @@ const createGeomRect = (rect) => `<a:rect l="${rect.left}" t="${rect.top}" r="${
|
|
|
4536
5500
|
* { command: "close" },
|
|
4537
5501
|
* ],
|
|
4538
5502
|
* }],
|
|
4539
|
-
*
|
|
5503
|
+
* textRectangle: { left: "2000000", top: "2000000", right: "8000000", bottom: "8000000" },
|
|
4540
5504
|
* });
|
|
4541
5505
|
* ```
|
|
4542
5506
|
*/
|
|
@@ -4546,7 +5510,7 @@ const createCustomGeometry = (options) => {
|
|
|
4546
5510
|
if (options.guides) children.push(createGuideList("a:gdLst", options.guides));
|
|
4547
5511
|
if (options.adjustHandles && options.adjustHandles.length > 0) children.push(element("a:ahLst", void 0, options.adjustHandles.map((h) => h.type === "xy" ? createXYAdjustHandle(h) : createPolarAdjustHandle(h))));
|
|
4548
5512
|
if (options.connectionSites && options.connectionSites.length > 0) children.push(element("a:cxnLst", void 0, options.connectionSites.map(createConnectionSite)));
|
|
4549
|
-
if (options.
|
|
5513
|
+
if (options.textRectangle) children.push(createGeomRect(options.textRectangle));
|
|
4550
5514
|
children.push(element("a:pathLst", void 0, options.pathList.map(createPath)));
|
|
4551
5515
|
return element("a:custGeom", void 0, children);
|
|
4552
5516
|
};
|
|
@@ -4708,7 +5672,7 @@ const createBlip = (options, blipEffects) => {
|
|
|
4708
5672
|
const createBlipFill = (blipOptions, fillOptions) => {
|
|
4709
5673
|
const children = [];
|
|
4710
5674
|
children.push(createBlip(blipOptions, fillOptions?.blipEffects));
|
|
4711
|
-
children.push(createSourceRectangle(fillOptions?.
|
|
5675
|
+
children.push(createSourceRectangle(fillOptions?.sourceRectangle));
|
|
4712
5676
|
if (fillOptions?.tile) children.push(createTileInfo(fillOptions.tile));
|
|
4713
5677
|
else children.push("<a:stretch><a:fillRect/></a:stretch>");
|
|
4714
5678
|
const attrs = {};
|
|
@@ -5015,10 +5979,10 @@ function createStyleMatrixRef(elementName, opts) {
|
|
|
5015
5979
|
}
|
|
5016
5980
|
/** Create border line element (a:ln with color) or a:lnRef */
|
|
5017
5981
|
function createThemeableLine(opts) {
|
|
5018
|
-
if (opts.
|
|
5982
|
+
if (opts.lineReference !== void 0) {
|
|
5019
5983
|
const children = [];
|
|
5020
5984
|
if (opts.color) children.push(toStr(opts.color));
|
|
5021
|
-
return element("a:lnRef", { idx: String(opts.
|
|
5985
|
+
return element("a:lnRef", { idx: String(opts.lineReference.idx) }, children.length > 0 ? children : void 0);
|
|
5022
5986
|
}
|
|
5023
5987
|
const children = [];
|
|
5024
5988
|
if (opts.color) children.push(toStr(opts.color));
|
|
@@ -5046,7 +6010,7 @@ function buildCellBorders(opts) {
|
|
|
5046
6010
|
}
|
|
5047
6011
|
function buildTextStyle(opts) {
|
|
5048
6012
|
const children = [];
|
|
5049
|
-
if (opts.
|
|
6013
|
+
if (opts.fontReference) children.push(createStyleMatrixRef("fontRef", opts.fontReference));
|
|
5050
6014
|
if (opts.color) children.push(toStr(opts.color));
|
|
5051
6015
|
const attrs = {};
|
|
5052
6016
|
if (opts.bold && opts.bold !== "def") attrs.b = onOffAttr(opts.bold);
|
|
@@ -5056,7 +6020,7 @@ function buildTextStyle(opts) {
|
|
|
5056
6020
|
function buildCellStyle(opts) {
|
|
5057
6021
|
const children = [];
|
|
5058
6022
|
if (opts.borders) children.push(buildCellBorders(opts.borders));
|
|
5059
|
-
if (opts.
|
|
6023
|
+
if (opts.fillReference) children.push(createStyleMatrixRef("fillRef", opts.fillReference));
|
|
5060
6024
|
else if (opts.fill) children.push(toStr(opts.fill));
|
|
5061
6025
|
return element("a:tcStyle", void 0, children);
|
|
5062
6026
|
}
|
|
@@ -5185,7 +6149,7 @@ function parseTableTextStyle(el) {
|
|
|
5185
6149
|
const i = attr(el, "i");
|
|
5186
6150
|
if (i === "on" || i === "off") opts.italic = i;
|
|
5187
6151
|
const fontRefEl = findChild(el, "a:fontRef");
|
|
5188
|
-
if (fontRefEl) opts.
|
|
6152
|
+
if (fontRefEl) opts.fontReference = parseStyleMatrixRef(fontRefEl);
|
|
5189
6153
|
for (const child of el.elements ?? []) {
|
|
5190
6154
|
if (child.name === "a:fontRef") continue;
|
|
5191
6155
|
opts.color = serializeChild(child);
|
|
@@ -5201,7 +6165,7 @@ function parseTableCellStyle(el) {
|
|
|
5201
6165
|
if (borders) opts.borders = borders;
|
|
5202
6166
|
}
|
|
5203
6167
|
const fillRefEl = findChild(el, "a:fillRef");
|
|
5204
|
-
if (fillRefEl) opts.
|
|
6168
|
+
if (fillRefEl) opts.fillReference = parseStyleMatrixRef(fillRefEl);
|
|
5205
6169
|
else for (const child of el.elements ?? []) {
|
|
5206
6170
|
if (child.name === "a:tcBdr") continue;
|
|
5207
6171
|
opts.fill = serializeChild(child);
|
|
@@ -5225,7 +6189,7 @@ function parseThemeableLine(el) {
|
|
|
5225
6189
|
const opts = {};
|
|
5226
6190
|
if (el.name === "a:lnRef") {
|
|
5227
6191
|
const idx = attrNum(el, "idx");
|
|
5228
|
-
if (idx !== void 0) opts.
|
|
6192
|
+
if (idx !== void 0) opts.lineReference = { idx };
|
|
5229
6193
|
} else {
|
|
5230
6194
|
const w = attrNum(el, "w");
|
|
5231
6195
|
if (w !== void 0) opts.width = w;
|
|
@@ -5283,25 +6247,25 @@ function createGraphicFrameLocking(opts) {
|
|
|
5283
6247
|
* @module
|
|
5284
6248
|
*/
|
|
5285
6249
|
/** Creates a dgm:adj element. */
|
|
5286
|
-
const
|
|
5287
|
-
const
|
|
6250
|
+
const createAdjust = (options) => `<dgm:adj idx="${options.idx}" val="${options.val}"/>`;
|
|
6251
|
+
const AnimationLevelValue = {
|
|
5288
6252
|
NONE: "none",
|
|
5289
6253
|
LEVEL: "lvl",
|
|
5290
6254
|
CENTER: "ctr"
|
|
5291
6255
|
};
|
|
5292
6256
|
/** Creates a dgm:animLvl element. */
|
|
5293
|
-
const
|
|
5294
|
-
const
|
|
6257
|
+
const createAnimationLevel = (options) => options?.val !== void 0 ? `<dgm:animLvl val="${options.val}"/>` : "<dgm:animLvl/>";
|
|
6258
|
+
const AnimateOneByOneValue = {
|
|
5295
6259
|
NONE: "none",
|
|
5296
6260
|
ONE: "one",
|
|
5297
6261
|
BRANCH: "branch"
|
|
5298
6262
|
};
|
|
5299
6263
|
/** Creates a dgm:animOne element. */
|
|
5300
|
-
const
|
|
6264
|
+
const createAnimateOneByOne = (options) => options?.val !== void 0 ? `<dgm:animOne val="${options.val}"/>` : "<dgm:animOne/>";
|
|
5301
6265
|
/** Creates a dgm:chMax element. */
|
|
5302
|
-
const
|
|
6266
|
+
const createMaxChildren = (options) => options?.val !== void 0 ? `<dgm:chMax val="${options.val}"/>` : "<dgm:chMax/>";
|
|
5303
6267
|
/** Creates a dgm:chPref element. */
|
|
5304
|
-
const
|
|
6268
|
+
const createPreferredChildren = (options) => options?.val !== void 0 ? `<dgm:chPref val="${options.val}"/>` : "<dgm:chPref/>";
|
|
5305
6269
|
/** Creates a dgm:orgChart element. */
|
|
5306
6270
|
const createOrgChart = (options) => options?.val !== void 0 ? `<dgm:orgChart val="${options.val}"/>` : "<dgm:orgChart/>";
|
|
5307
6271
|
const HierBranchStyle = {
|
|
@@ -5333,20 +6297,20 @@ const createHierBranch = (options) => options?.val !== void 0 ? `<dgm:hierBranch
|
|
|
5333
6297
|
* </xsd:complexType>
|
|
5334
6298
|
* ```
|
|
5335
6299
|
*/
|
|
5336
|
-
const
|
|
6300
|
+
const createPresentationLayoutVariables = (options) => {
|
|
5337
6301
|
const children = [];
|
|
5338
6302
|
if (options?.orgChart) children.push(createOrgChart(options.orgChart));
|
|
5339
|
-
if (options?.
|
|
5340
|
-
if (options?.
|
|
5341
|
-
if (options?.
|
|
5342
|
-
if (options?.
|
|
6303
|
+
if (options?.maxChildren) children.push(createMaxChildren(options.maxChildren));
|
|
6304
|
+
if (options?.preferredChildren) children.push(createPreferredChildren(options.preferredChildren));
|
|
6305
|
+
if (options?.animateOneByOne) children.push(createAnimateOneByOne(options.animateOneByOne));
|
|
6306
|
+
if (options?.animationLevel) children.push(createAnimationLevel(options.animationLevel));
|
|
5343
6307
|
if (options?.hierBranch) children.push(createHierBranch(options.hierBranch));
|
|
5344
6308
|
return element("dgm:presLayoutVars", void 0, children);
|
|
5345
6309
|
};
|
|
5346
6310
|
/** Creates a dgm:adjLst element containing dgm:adj children. */
|
|
5347
|
-
const
|
|
6311
|
+
const createAdjustList = (options) => {
|
|
5348
6312
|
const children = [];
|
|
5349
|
-
if (options?.
|
|
6313
|
+
if (options?.adjustments) for (const a of options.adjustments) children.push(createAdjust(a));
|
|
5350
6314
|
return element("dgm:adjLst", void 0, children);
|
|
5351
6315
|
};
|
|
5352
6316
|
//#endregion
|
|
@@ -5394,7 +6358,7 @@ const createCatLst = (categories) => {
|
|
|
5394
6358
|
* </xsd:complexType>
|
|
5395
6359
|
* ```
|
|
5396
6360
|
*/
|
|
5397
|
-
const
|
|
6361
|
+
const createColorsDefinitionHeader = (options) => {
|
|
5398
6362
|
const children = [];
|
|
5399
6363
|
for (const t of options.title) children.push(createNameEl("dgm:title", t));
|
|
5400
6364
|
for (const d of options.desc) children.push(createDescEl("dgm:desc", d));
|
|
@@ -5405,9 +6369,9 @@ const createColorsDefHdr = (options) => {
|
|
|
5405
6369
|
return element("dgm:colorsDefHdr", attrs, children);
|
|
5406
6370
|
};
|
|
5407
6371
|
/** Creates a dgm:colorsDefHdrLst element. */
|
|
5408
|
-
const
|
|
6372
|
+
const createColorsDefinitionHeaderList = (options) => {
|
|
5409
6373
|
const children = [];
|
|
5410
|
-
if (options?.headers) for (const hdr of options.headers) children.push(
|
|
6374
|
+
if (options?.headers) for (const hdr of options.headers) children.push(createColorsDefinitionHeader(hdr));
|
|
5411
6375
|
return element("dgm:colorsDefHdrLst", void 0, children);
|
|
5412
6376
|
};
|
|
5413
6377
|
/**
|
|
@@ -5429,7 +6393,7 @@ const createColorsDefHdrLst = (options) => {
|
|
|
5429
6393
|
* </xsd:complexType>
|
|
5430
6394
|
* ```
|
|
5431
6395
|
*/
|
|
5432
|
-
const
|
|
6396
|
+
const createLayoutDefinitionHeader = (options) => {
|
|
5433
6397
|
const children = [];
|
|
5434
6398
|
for (const t of options.title) children.push(createNameEl("dgm:title", t));
|
|
5435
6399
|
for (const d of options.desc) children.push(createDescEl("dgm:desc", d));
|
|
@@ -5441,9 +6405,9 @@ const createLayoutDefHdr = (options) => {
|
|
|
5441
6405
|
return element("dgm:layoutDefHdr", attrs, children);
|
|
5442
6406
|
};
|
|
5443
6407
|
/** Creates a dgm:layoutDefHdrLst element. */
|
|
5444
|
-
const
|
|
6408
|
+
const createLayoutDefinitionHeaderList = (options) => {
|
|
5445
6409
|
const children = [];
|
|
5446
|
-
if (options?.headers) for (const hdr of options.headers) children.push(
|
|
6410
|
+
if (options?.headers) for (const hdr of options.headers) children.push(createLayoutDefinitionHeader(hdr));
|
|
5447
6411
|
return element("dgm:layoutDefHdrLst", void 0, children);
|
|
5448
6412
|
};
|
|
5449
6413
|
/**
|
|
@@ -5464,7 +6428,7 @@ const createLayoutDefHdrLst = (options) => {
|
|
|
5464
6428
|
* </xsd:complexType>
|
|
5465
6429
|
* ```
|
|
5466
6430
|
*/
|
|
5467
|
-
const
|
|
6431
|
+
const createStyleDefinitionHeader = (options) => {
|
|
5468
6432
|
const children = [];
|
|
5469
6433
|
for (const t of options.title) children.push(createNameEl("dgm:title", t));
|
|
5470
6434
|
for (const d of options.desc) children.push(createDescEl("dgm:desc", d));
|
|
@@ -5475,9 +6439,9 @@ const createStyleDefHdr = (options) => {
|
|
|
5475
6439
|
return element("dgm:styleDefHdr", attrs, children);
|
|
5476
6440
|
};
|
|
5477
6441
|
/** Creates a dgm:styleDefHdrLst element. */
|
|
5478
|
-
const
|
|
6442
|
+
const createStyleDefinitionHeaderList = (options) => {
|
|
5479
6443
|
const children = [];
|
|
5480
|
-
if (options?.headers) for (const hdr of options.headers) children.push(
|
|
6444
|
+
if (options?.headers) for (const hdr of options.headers) children.push(createStyleDefinitionHeader(hdr));
|
|
5481
6445
|
return element("dgm:styleDefHdrLst", void 0, children);
|
|
5482
6446
|
};
|
|
5483
6447
|
//#endregion
|
|
@@ -5517,10 +6481,10 @@ const FontCollectionIndex = {
|
|
|
5517
6481
|
*/
|
|
5518
6482
|
const createDiagramStyle = (options) => {
|
|
5519
6483
|
const children = [];
|
|
5520
|
-
children.push(element("a:lnRef", { idx: options?.
|
|
5521
|
-
children.push(element("a:fillRef", { idx: options?.
|
|
5522
|
-
children.push(element("a:effectRef", { idx: options?.
|
|
5523
|
-
children.push(element("a:fontRef", { idx: options?.
|
|
6484
|
+
children.push(element("a:lnRef", { idx: options?.lineReference?.idx ?? 1 }, [createColorElement({ value: SchemeColor.ACCENT1 })]));
|
|
6485
|
+
children.push(element("a:fillRef", { idx: options?.fillReference?.idx ?? 1 }, [createColorElement({ value: SchemeColor.ACCENT1 })]));
|
|
6486
|
+
children.push(element("a:effectRef", { idx: options?.effectReference?.idx ?? 0 }, [createColorElement({ value: SchemeColor.ACCENT1 })]));
|
|
6487
|
+
children.push(element("a:fontRef", { idx: options?.fontReference?.idx ?? "minor" }, [createColorElement({ value: SchemeColor.TX1 })]));
|
|
5524
6488
|
return element("dgm:style", void 0, children);
|
|
5525
6489
|
};
|
|
5526
6490
|
const ColorMethod = {
|
|
@@ -5542,12 +6506,12 @@ const createColorList = (tag, options) => {
|
|
|
5542
6506
|
if (options?.hueDir) attrs.hueDir = options.hueDir;
|
|
5543
6507
|
return element(tag, hasAttrs ? attrs : void 0, children.length > 0 ? children : void 0);
|
|
5544
6508
|
};
|
|
5545
|
-
const
|
|
5546
|
-
const
|
|
5547
|
-
const
|
|
5548
|
-
const
|
|
5549
|
-
const
|
|
5550
|
-
const
|
|
6509
|
+
const createFillColorList = (options) => createColorList("dgm:fillClrLst", options);
|
|
6510
|
+
const createLineColorList = (options) => createColorList("dgm:linClrLst", options);
|
|
6511
|
+
const createEffectColorList = (options) => createColorList("dgm:effectClrLst", options);
|
|
6512
|
+
const createTextFillColorList = (options) => createColorList("dgm:txFillClrLst", options);
|
|
6513
|
+
const createTextLineColorList = (options) => createColorList("dgm:txLinClrLst", options);
|
|
6514
|
+
const createTextEffectColorList = (options) => createColorList("dgm:txEffectClrLst", options);
|
|
5551
6515
|
/**
|
|
5552
6516
|
* Creates a dgm:styleLbl element (CT_StyleLabel or CT_CTStyleLabel).
|
|
5553
6517
|
*
|
|
@@ -5581,14 +6545,14 @@ const createTxEffectClrLst = (options) => createColorList("dgm:txEffectClrLst",
|
|
|
5581
6545
|
* </xsd:complexType>
|
|
5582
6546
|
* ```
|
|
5583
6547
|
*/
|
|
5584
|
-
const
|
|
6548
|
+
const createStyleLabel = (options) => {
|
|
5585
6549
|
const children = [];
|
|
5586
|
-
if (options.
|
|
5587
|
-
if (options.
|
|
5588
|
-
if (options.
|
|
5589
|
-
if (options.
|
|
5590
|
-
if (options.
|
|
5591
|
-
if (options.
|
|
6550
|
+
if (options.fillColorList) children.push(createFillColorList(options.fillColorList));
|
|
6551
|
+
if (options.lineColorList) children.push(createLineColorList(options.lineColorList));
|
|
6552
|
+
if (options.effectColorList) children.push(createEffectColorList(options.effectColorList));
|
|
6553
|
+
if (options.textFillColorList) children.push(createTextFillColorList(options.textFillColorList));
|
|
6554
|
+
if (options.textLineColorList) children.push(createTextLineColorList(options.textLineColorList));
|
|
6555
|
+
if (options.textEffectColorList) children.push(createTextEffectColorList(options.textEffectColorList));
|
|
5592
6556
|
return element("dgm:styleLbl", { name: options.name }, children);
|
|
5593
6557
|
};
|
|
5594
6558
|
//#endregion
|
|
@@ -5606,7 +6570,7 @@ const createStyleLbl = (options) => {
|
|
|
5606
6570
|
* </xsd:complexType>
|
|
5607
6571
|
* ```
|
|
5608
6572
|
*/
|
|
5609
|
-
const
|
|
6573
|
+
const createDiagramRelationshipIds = (options) => `<dgm:relIds r:dm="${options.dm}" r:lo="${options.lo}" r:qs="${options.qs}" r:cs="${options.cs}"/>`;
|
|
5610
6574
|
//#endregion
|
|
5611
6575
|
//#region src/drawingml/diagram/diagram-props.ts
|
|
5612
6576
|
/**
|
|
@@ -5621,7 +6585,7 @@ const createDiagramRelIds = (options) => `<dgm:relIds r:dm="${options.dm}" r:lo=
|
|
|
5621
6585
|
*
|
|
5622
6586
|
* Generic extension list pattern used across OOXML.
|
|
5623
6587
|
*/
|
|
5624
|
-
const
|
|
6588
|
+
const createDiagramExtensionList = (options) => {
|
|
5625
6589
|
const children = [];
|
|
5626
6590
|
if (options?.extensions) for (const ext of options.extensions) children.push(`<a:ext uri="${ext.uri}"/>`);
|
|
5627
6591
|
return element("dgm:extLst", void 0, children);
|
|
@@ -5631,7 +6595,7 @@ const createDiagramExtLst = (options) => {
|
|
|
5631
6595
|
*
|
|
5632
6596
|
* Delegates to the shared createShape3D factory but wraps in dgm: namespace context.
|
|
5633
6597
|
*/
|
|
5634
|
-
const
|
|
6598
|
+
const createDiagramShape3D = (options) => createShape3D(options);
|
|
5635
6599
|
/**
|
|
5636
6600
|
* Creates a dgm:txPr element (CT_TextProps).
|
|
5637
6601
|
*
|
|
@@ -5644,7 +6608,7 @@ const createDiagramSp3d = (options) => createShape3D(options);
|
|
|
5644
6608
|
* </xsd:complexType>
|
|
5645
6609
|
* ```
|
|
5646
6610
|
*/
|
|
5647
|
-
const
|
|
6611
|
+
const createDiagramTextProperties = (_options) => "<dgm:txPr/>";
|
|
5648
6612
|
//#endregion
|
|
5649
6613
|
//#region src/drawingml/color/color-descriptors.ts
|
|
5650
6614
|
/**
|
|
@@ -5713,8 +6677,7 @@ const rgbColorDesc = {
|
|
|
5713
6677
|
return `<a:srgbClr val="${escapeXml(opts.value)}"/>`;
|
|
5714
6678
|
},
|
|
5715
6679
|
parse(el, _ctx) {
|
|
5716
|
-
const result = {};
|
|
5717
|
-
result.value = String(el.attributes?.["val"] ?? "");
|
|
6680
|
+
const result = { value: String(el.attributes?.["val"] ?? "") };
|
|
5718
6681
|
const transforms = readTransforms(el);
|
|
5719
6682
|
if (transforms) result.transforms = transforms;
|
|
5720
6683
|
return result;
|
|
@@ -5728,8 +6691,7 @@ const schemeColorDesc = {
|
|
|
5728
6691
|
return `<a:schemeClr val="${escapeXml(opts.value)}"/>`;
|
|
5729
6692
|
},
|
|
5730
6693
|
parse(el, _ctx) {
|
|
5731
|
-
const result = {};
|
|
5732
|
-
result.value = String(el.attributes?.["val"] ?? "");
|
|
6694
|
+
const result = { value: String(el.attributes?.["val"] ?? "") };
|
|
5733
6695
|
const transforms = readTransforms(el);
|
|
5734
6696
|
if (transforms) result.transforms = transforms;
|
|
5735
6697
|
return result;
|
|
@@ -5743,10 +6705,11 @@ const hslColorDesc = {
|
|
|
5743
6705
|
return `<a:hslClr hue="${opts.hue}" sat="${opts.saturation}" lum="${opts.luminance}"/>`;
|
|
5744
6706
|
},
|
|
5745
6707
|
parse(el, _ctx) {
|
|
5746
|
-
const result = {
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
6708
|
+
const result = {
|
|
6709
|
+
hue: Number(el.attributes?.["hue"] ?? 0),
|
|
6710
|
+
saturation: Number(el.attributes?.["sat"] ?? 0),
|
|
6711
|
+
luminance: Number(el.attributes?.["lum"] ?? 0)
|
|
6712
|
+
};
|
|
5750
6713
|
const transforms = readTransforms(el);
|
|
5751
6714
|
if (transforms) result.transforms = transforms;
|
|
5752
6715
|
return result;
|
|
@@ -5763,8 +6726,7 @@ const systemColorDesc = {
|
|
|
5763
6726
|
return `<a:sysClr ${attrStr}/>`;
|
|
5764
6727
|
},
|
|
5765
6728
|
parse(el, _ctx) {
|
|
5766
|
-
const result = {};
|
|
5767
|
-
result.value = String(el.attributes?.["val"] ?? "");
|
|
6729
|
+
const result = { value: String(el.attributes?.["val"] ?? "") };
|
|
5768
6730
|
const lastClr = el.attributes?.["lastClr"];
|
|
5769
6731
|
if (lastClr) result.lastClr = String(lastClr);
|
|
5770
6732
|
const transforms = readTransforms(el);
|
|
@@ -5780,8 +6742,7 @@ const presetColorDesc = {
|
|
|
5780
6742
|
return `<a:prstClr val="${escapeXml(opts.value)}"/>`;
|
|
5781
6743
|
},
|
|
5782
6744
|
parse(el, _ctx) {
|
|
5783
|
-
const result = {};
|
|
5784
|
-
result.value = String(el.attributes?.["val"] ?? "");
|
|
6745
|
+
const result = { value: String(el.attributes?.["val"] ?? "") };
|
|
5785
6746
|
const transforms = readTransforms(el);
|
|
5786
6747
|
if (transforms) result.transforms = transforms;
|
|
5787
6748
|
return result;
|
|
@@ -5795,10 +6756,11 @@ const scRgbColorDesc = {
|
|
|
5795
6756
|
return `<a:scrgbClr r="${escapeXml(opts.r)}" g="${escapeXml(opts.g)}" b="${escapeXml(opts.b)}"/>`;
|
|
5796
6757
|
},
|
|
5797
6758
|
parse(el, _ctx) {
|
|
5798
|
-
const result = {
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
6759
|
+
const result = {
|
|
6760
|
+
r: String(el.attributes?.["r"] ?? ""),
|
|
6761
|
+
g: String(el.attributes?.["g"] ?? ""),
|
|
6762
|
+
b: String(el.attributes?.["b"] ?? "")
|
|
6763
|
+
};
|
|
5802
6764
|
const transforms = readTransforms(el);
|
|
5803
6765
|
if (transforms) result.transforms = transforms;
|
|
5804
6766
|
return result;
|
|
@@ -5879,7 +6841,7 @@ function stringifyShade(shade) {
|
|
|
5879
6841
|
const parts = [];
|
|
5880
6842
|
if (pathShade.path) parts.push(`path="${escapeXml(pathShade.path)}"`);
|
|
5881
6843
|
const attrStr = parts.length ? " " + parts.join(" ") : "";
|
|
5882
|
-
if (pathShade.
|
|
6844
|
+
if (pathShade.fillToRectangle) return `<a:path${attrStr}>${stringifyRelativeRect("a:fillToRect", pathShade.fillToRectangle)}</a:path>`;
|
|
5883
6845
|
return `<a:path${attrStr}/>`;
|
|
5884
6846
|
}
|
|
5885
6847
|
const gradientFillDesc = {
|
|
@@ -5893,7 +6855,7 @@ const gradientFillDesc = {
|
|
|
5893
6855
|
}).join("");
|
|
5894
6856
|
parts.push(`<a:gsLst>${stopsXml}</a:gsLst>`);
|
|
5895
6857
|
if (opts.shade) parts.push(stringifyShade(opts.shade));
|
|
5896
|
-
if (opts.
|
|
6858
|
+
if (opts.tileRectangle) parts.push(stringifyRelativeRect("a:tileRect", opts.tileRectangle));
|
|
5897
6859
|
const attrParts = [];
|
|
5898
6860
|
if (opts.flip) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
|
|
5899
6861
|
if (opts.rotateWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotateWithShape ? 1 : 0}"`);
|
|
@@ -5919,15 +6881,15 @@ const gradientFillDesc = {
|
|
|
5919
6881
|
if (path) {
|
|
5920
6882
|
const shade = {};
|
|
5921
6883
|
if (path.attributes?.["path"] !== void 0) shade.path = String(path.attributes["path"]);
|
|
5922
|
-
const
|
|
5923
|
-
if (
|
|
6884
|
+
const fillToRectangle = findChild(path, "a:fillToRect");
|
|
6885
|
+
if (fillToRectangle) shade.fillToRectangle = readRelativeRect(fillToRectangle);
|
|
5924
6886
|
result.shade = shade;
|
|
5925
6887
|
}
|
|
5926
6888
|
}
|
|
5927
6889
|
if (el.attributes?.["flip"] !== void 0) result.flip = String(el.attributes["flip"]);
|
|
5928
6890
|
if (el.attributes?.["rotWithShape"] !== void 0) result.rotateWithShape = el.attributes["rotWithShape"] !== "0";
|
|
5929
|
-
const
|
|
5930
|
-
if (
|
|
6891
|
+
const tileRectangle = findChild(el, "a:tileRect");
|
|
6892
|
+
if (tileRectangle) result.tileRectangle = readRelativeRect(tileRectangle);
|
|
5931
6893
|
return result;
|
|
5932
6894
|
}
|
|
5933
6895
|
};
|
|
@@ -5993,17 +6955,17 @@ const fillDesc = {
|
|
|
5993
6955
|
const solidFill = resolve("a:solidFill");
|
|
5994
6956
|
if (solidFill) return {
|
|
5995
6957
|
type: "solid",
|
|
5996
|
-
color: parse(solidFillDesc, solidFill, ctx)
|
|
6958
|
+
color: parse$1(solidFillDesc, solidFill, ctx)
|
|
5997
6959
|
};
|
|
5998
6960
|
const gradFill = resolve("a:gradFill");
|
|
5999
6961
|
if (gradFill) return {
|
|
6000
6962
|
type: "gradient",
|
|
6001
|
-
options: parse(gradientFillDesc, gradFill, ctx)
|
|
6963
|
+
options: parse$1(gradientFillDesc, gradFill, ctx)
|
|
6002
6964
|
};
|
|
6003
6965
|
const pattFill = resolve("a:pattFill");
|
|
6004
6966
|
if (pattFill) return {
|
|
6005
6967
|
type: "pattern",
|
|
6006
|
-
...parse(patternFillDesc, pattFill, ctx)
|
|
6968
|
+
...parse$1(patternFillDesc, pattFill, ctx)
|
|
6007
6969
|
};
|
|
6008
6970
|
if (resolve("a:grpFill")) return { type: "group" };
|
|
6009
6971
|
return { type: "none" };
|
|
@@ -6013,7 +6975,7 @@ function readDirectColor(el, ctx) {
|
|
|
6013
6975
|
const color = parseColorChoice(el, ctx);
|
|
6014
6976
|
if (Object.keys(color).length > 0) return color;
|
|
6015
6977
|
const solidFill = findChild(el, "a:solidFill");
|
|
6016
|
-
if (solidFill) return parse(solidFillDesc, solidFill, ctx);
|
|
6978
|
+
if (solidFill) return parse$1(solidFillDesc, solidFill, ctx);
|
|
6017
6979
|
return { value: "" };
|
|
6018
6980
|
}
|
|
6019
6981
|
//#endregion
|
|
@@ -6045,7 +7007,7 @@ const outlineDesc = {
|
|
|
6045
7007
|
stringify(opts, ctx) {
|
|
6046
7008
|
const parts = [];
|
|
6047
7009
|
const attrParts = [];
|
|
6048
|
-
if (opts.width !== void 0) attrParts.push(`w="${opts.width}"`);
|
|
7010
|
+
if (opts.width !== void 0) attrParts.push(`w="${convertToEmu(opts.width)}"`);
|
|
6049
7011
|
if (opts.cap !== void 0) attrParts.push(`cap="${escapeXml(opts.cap)}"`);
|
|
6050
7012
|
if (opts.compoundLine !== void 0) attrParts.push(`cmpd="${escapeXml(opts.compoundLine)}"`);
|
|
6051
7013
|
if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(opts.align)}"`);
|
|
@@ -6079,12 +7041,12 @@ const outlineDesc = {
|
|
|
6079
7041
|
const solidFill = findChild(el, "a:solidFill");
|
|
6080
7042
|
if (solidFill) {
|
|
6081
7043
|
result.type = "solidFill";
|
|
6082
|
-
result.color = parse(solidFillDesc, solidFill, _ctx);
|
|
7044
|
+
result.color = parse$1(solidFillDesc, solidFill, _ctx);
|
|
6083
7045
|
}
|
|
6084
7046
|
if (findChild(el, "a:noFill")) result.type = "noFill";
|
|
6085
7047
|
if (findChild(el, "a:gradFill")) {
|
|
6086
7048
|
result.type = "gradFill";
|
|
6087
|
-
result.gradientFill = parse(gradientFillDesc, findChild(el, "a:gradFill"), _ctx);
|
|
7049
|
+
result.gradientFill = parse$1(gradientFillDesc, findChild(el, "a:gradFill"), _ctx);
|
|
6088
7050
|
}
|
|
6089
7051
|
const prstDash = findChild(el, "a:prstDash");
|
|
6090
7052
|
if (prstDash?.attributes?.["val"]) result.dash = String(prstDash.attributes["val"]);
|
|
@@ -6394,22 +7356,22 @@ const presetGeometryDesc = {
|
|
|
6394
7356
|
if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
|
|
6395
7357
|
const avLst = findChild(el, "a:avLst");
|
|
6396
7358
|
if (avLst) {
|
|
6397
|
-
const guides = parse(adjustmentValuesDesc, avLst, ctx);
|
|
7359
|
+
const guides = parse$1(adjustmentValuesDesc, avLst, ctx);
|
|
6398
7360
|
if (guides.length > 0) result.adjustmentValues = guides;
|
|
6399
7361
|
}
|
|
6400
7362
|
return result;
|
|
6401
7363
|
}
|
|
6402
7364
|
};
|
|
6403
|
-
function
|
|
7365
|
+
function stringifyAdjustPoint(pt) {
|
|
6404
7366
|
return `<a:pt x="${escapeXml(pt.x)}" y="${escapeXml(pt.y)}"/>`;
|
|
6405
7367
|
}
|
|
6406
7368
|
function stringifyPathCommand(cmd) {
|
|
6407
7369
|
switch (cmd.command) {
|
|
6408
|
-
case "moveTo": return `<a:moveTo>${
|
|
6409
|
-
case "lineTo": return `<a:lnTo>${
|
|
7370
|
+
case "moveTo": return `<a:moveTo>${stringifyAdjustPoint(cmd.point)}</a:moveTo>`;
|
|
7371
|
+
case "lineTo": return `<a:lnTo>${stringifyAdjustPoint(cmd.point)}</a:lnTo>`;
|
|
6410
7372
|
case "arcTo": return `<a:arcTo wR="${escapeXml(cmd.widthRadius)}" hR="${escapeXml(cmd.heightRadius)}" stAng="${escapeXml(cmd.startAngle)}" swAng="${escapeXml(cmd.sweepAngle)}"/>`;
|
|
6411
|
-
case "quadBezTo": return `<a:quadBezTo>${cmd.points.map(
|
|
6412
|
-
case "cubicBezTo": return `<a:cubicBezTo>${cmd.points.map(
|
|
7373
|
+
case "quadBezTo": return `<a:quadBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:quadBezTo>`;
|
|
7374
|
+
case "cubicBezTo": return `<a:cubicBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:cubicBezTo>`;
|
|
6413
7375
|
case "close": return "<a:close/>";
|
|
6414
7376
|
}
|
|
6415
7377
|
}
|
|
@@ -6425,7 +7387,7 @@ function stringifyPath(path) {
|
|
|
6425
7387
|
if (!cmds && !attrStr) return "<a:path/>";
|
|
6426
7388
|
return `<a:path${attrStr}>${cmds}</a:path>`;
|
|
6427
7389
|
}
|
|
6428
|
-
function
|
|
7390
|
+
function readAdjustPoint(el) {
|
|
6429
7391
|
if (!el.attributes) return void 0;
|
|
6430
7392
|
const x = el.attributes["x"];
|
|
6431
7393
|
const y = el.attributes["y"];
|
|
@@ -6440,7 +7402,7 @@ function readPathCommand(tag, el) {
|
|
|
6440
7402
|
case "a:moveTo": {
|
|
6441
7403
|
const pt = el.elements?.find((c) => c.name === "a:pt");
|
|
6442
7404
|
if (!pt) return void 0;
|
|
6443
|
-
const point =
|
|
7405
|
+
const point = readAdjustPoint(pt);
|
|
6444
7406
|
if (!point) return void 0;
|
|
6445
7407
|
return {
|
|
6446
7408
|
command: "moveTo",
|
|
@@ -6450,7 +7412,7 @@ function readPathCommand(tag, el) {
|
|
|
6450
7412
|
case "a:lnTo": {
|
|
6451
7413
|
const pt = el.elements?.find((c) => c.name === "a:pt");
|
|
6452
7414
|
if (!pt) return void 0;
|
|
6453
|
-
const point =
|
|
7415
|
+
const point = readAdjustPoint(pt);
|
|
6454
7416
|
if (!point) return void 0;
|
|
6455
7417
|
return {
|
|
6456
7418
|
command: "lineTo",
|
|
@@ -6469,7 +7431,7 @@ function readPathCommand(tag, el) {
|
|
|
6469
7431
|
};
|
|
6470
7432
|
}
|
|
6471
7433
|
case "a:quadBezTo": {
|
|
6472
|
-
const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(
|
|
7434
|
+
const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
|
|
6473
7435
|
if (points.length < 2) return void 0;
|
|
6474
7436
|
return {
|
|
6475
7437
|
command: "quadBezTo",
|
|
@@ -6477,7 +7439,7 @@ function readPathCommand(tag, el) {
|
|
|
6477
7439
|
};
|
|
6478
7440
|
}
|
|
6479
7441
|
case "a:cubicBezTo": {
|
|
6480
|
-
const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(
|
|
7442
|
+
const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
|
|
6481
7443
|
if (points.length < 3) return void 0;
|
|
6482
7444
|
return {
|
|
6483
7445
|
command: "cubicBezTo",
|
|
@@ -6642,7 +7604,7 @@ const customGeometryDesc = {
|
|
|
6642
7604
|
const inner = opts.connectionSites.map(stringifyConnectionSite).join("");
|
|
6643
7605
|
parts.push(`<a:cxnLst>${inner}</a:cxnLst>`);
|
|
6644
7606
|
}
|
|
6645
|
-
if (opts.
|
|
7607
|
+
if (opts.textRectangle) parts.push(stringifyGeomRect(opts.textRectangle));
|
|
6646
7608
|
const pathsXml = opts.pathList.map(stringifyPath).join("");
|
|
6647
7609
|
parts.push(`<a:pathLst>${pathsXml}</a:pathLst>`);
|
|
6648
7610
|
return `<a:custGeom>${parts.join("")}</a:custGeom>`;
|
|
@@ -6682,8 +7644,8 @@ const customGeometryDesc = {
|
|
|
6682
7644
|
}
|
|
6683
7645
|
const rect = findChild(el, "a:rect");
|
|
6684
7646
|
if (rect) {
|
|
6685
|
-
const
|
|
6686
|
-
if (
|
|
7647
|
+
const textRectangle = readGeomRect(rect);
|
|
7648
|
+
if (textRectangle) result.textRectangle = textRectangle;
|
|
6687
7649
|
}
|
|
6688
7650
|
const pathLst = findChild(el, "a:pathLst");
|
|
6689
7651
|
if (pathLst?.elements) {
|
|
@@ -6847,18 +7809,18 @@ const shape3DDesc = {
|
|
|
6847
7809
|
if (el.attributes?.["contourW"] !== void 0) result.contourW = Number(el.attributes["contourW"]);
|
|
6848
7810
|
if (el.attributes?.["prstMaterial"] !== void 0) result.prstMaterial = xsdMaterialType.from(String(el.attributes["prstMaterial"]));
|
|
6849
7811
|
const bevelT = findChild(el, "a:bevelT");
|
|
6850
|
-
if (bevelT) result.bevelT = parse(bevelDesc, bevelT, ctx);
|
|
7812
|
+
if (bevelT) result.bevelT = parse$1(bevelDesc, bevelT, ctx);
|
|
6851
7813
|
const bevelB = findChild(el, "a:bevelB");
|
|
6852
|
-
if (bevelB) result.bevelB = parse(bevelDesc, bevelB, ctx);
|
|
7814
|
+
if (bevelB) result.bevelB = parse$1(bevelDesc, bevelB, ctx);
|
|
6853
7815
|
const extrusionClr = findChild(el, "a:extrusionClr");
|
|
6854
7816
|
if (extrusionClr) {
|
|
6855
7817
|
const solidFill = findChild(extrusionClr, "a:solidFill");
|
|
6856
|
-
if (solidFill) result.extrusionColor = parse(solidFillDesc, solidFill, ctx);
|
|
7818
|
+
if (solidFill) result.extrusionColor = parse$1(solidFillDesc, solidFill, ctx);
|
|
6857
7819
|
}
|
|
6858
7820
|
const contourClr = findChild(el, "a:contourClr");
|
|
6859
7821
|
if (contourClr) {
|
|
6860
7822
|
const solidFill = findChild(contourClr, "a:solidFill");
|
|
6861
|
-
if (solidFill) result.contourColor = parse(solidFillDesc, solidFill, ctx);
|
|
7823
|
+
if (solidFill) result.contourColor = parse$1(solidFillDesc, solidFill, ctx);
|
|
6862
7824
|
}
|
|
6863
7825
|
return result;
|
|
6864
7826
|
}
|
|
@@ -6925,9 +7887,9 @@ const scene3DDesc = {
|
|
|
6925
7887
|
parse(el, ctx) {
|
|
6926
7888
|
const result = {};
|
|
6927
7889
|
const camera = findChild(el, "a:camera");
|
|
6928
|
-
if (camera) result.camera = parse(cameraDesc, camera, ctx);
|
|
7890
|
+
if (camera) result.camera = parse$1(cameraDesc, camera, ctx);
|
|
6929
7891
|
const lightRig = findChild(el, "a:lightRig");
|
|
6930
|
-
if (lightRig) result.lightRig = parse(lightRigDesc, lightRig, ctx);
|
|
7892
|
+
if (lightRig) result.lightRig = parse$1(lightRigDesc, lightRig, ctx);
|
|
6931
7893
|
const backdrop = findChild(el, "a:backdrop");
|
|
6932
7894
|
if (backdrop) result.backdrop = readBackdrop(backdrop);
|
|
6933
7895
|
return result;
|
|
@@ -7146,7 +8108,7 @@ function readBlipEffects(el, ctx) {
|
|
|
7146
8108
|
const alphaInv = findChild(el, "a:alphaInv");
|
|
7147
8109
|
if (alphaInv) {
|
|
7148
8110
|
const solidFill = findChild(alphaInv, "a:solidFill");
|
|
7149
|
-
if (solidFill) result.alphaInverse = parse(solidFillDesc, solidFill, ctx);
|
|
8111
|
+
if (solidFill) result.alphaInverse = parse$1(solidFillDesc, solidFill, ctx);
|
|
7150
8112
|
else result.alphaInverse = {};
|
|
7151
8113
|
}
|
|
7152
8114
|
const alphaModFix = findChild(el, "a:alphaModFix");
|
|
@@ -7166,19 +8128,19 @@ function readBlipEffects(el, ctx) {
|
|
|
7166
8128
|
const clrFrom = findChild(clrChange, "a:clrFrom");
|
|
7167
8129
|
if (clrFrom) {
|
|
7168
8130
|
const fromFill = findChild(clrFrom, "a:solidFill");
|
|
7169
|
-
if (fromFill) opts.from = parse(solidFillDesc, fromFill, ctx);
|
|
8131
|
+
if (fromFill) opts.from = parse$1(solidFillDesc, fromFill, ctx);
|
|
7170
8132
|
}
|
|
7171
8133
|
const clrTo = findChild(clrChange, "a:clrTo");
|
|
7172
8134
|
if (clrTo) {
|
|
7173
8135
|
const toFill = findChild(clrTo, "a:solidFill");
|
|
7174
|
-
if (toFill) opts.to = parse(solidFillDesc, toFill, ctx);
|
|
8136
|
+
if (toFill) opts.to = parse$1(solidFillDesc, toFill, ctx);
|
|
7175
8137
|
}
|
|
7176
8138
|
result.colorChange = opts;
|
|
7177
8139
|
}
|
|
7178
8140
|
const clrRepl = findChild(el, "a:clrRepl");
|
|
7179
8141
|
if (clrRepl) {
|
|
7180
8142
|
const solidFill = findChild(clrRepl, "a:solidFill");
|
|
7181
|
-
if (solidFill) result.colorRepl = { color: parse(solidFillDesc, solidFill, ctx) };
|
|
8143
|
+
if (solidFill) result.colorRepl = { color: parse$1(solidFillDesc, solidFill, ctx) };
|
|
7182
8144
|
}
|
|
7183
8145
|
const blur = findChild(el, "a:blur");
|
|
7184
8146
|
if (blur) {
|
|
@@ -7192,7 +8154,7 @@ function readBlipEffects(el, ctx) {
|
|
|
7192
8154
|
const fills = [];
|
|
7193
8155
|
for (const child of duotone.elements) {
|
|
7194
8156
|
const sf = findChild(child, "a:solidFill");
|
|
7195
|
-
if (sf) fills.push(parse(solidFillDesc, sf, ctx));
|
|
8157
|
+
if (sf) fills.push(parse$1(solidFillDesc, sf, ctx));
|
|
7196
8158
|
}
|
|
7197
8159
|
if (fills.length >= 2) result.duotone = {
|
|
7198
8160
|
color1: fills[0],
|
|
@@ -7241,8 +8203,8 @@ const blipFillDesc = {
|
|
|
7241
8203
|
}, ctx);
|
|
7242
8204
|
if (blipXml) parts.push(blipXml);
|
|
7243
8205
|
}
|
|
7244
|
-
if (opts.
|
|
7245
|
-
const srcRectXml = stringify$1(sourceRectangleDesc, opts.
|
|
8206
|
+
if (opts.sourceRectangle) {
|
|
8207
|
+
const srcRectXml = stringify$1(sourceRectangleDesc, opts.sourceRectangle, ctx);
|
|
7246
8208
|
if (srcRectXml) parts.push(srcRectXml);
|
|
7247
8209
|
}
|
|
7248
8210
|
if (opts.tile) {
|
|
@@ -7260,14 +8222,14 @@ const blipFillDesc = {
|
|
|
7260
8222
|
if (el.attributes?.["rotWithShape"] !== void 0) result.rotWithShape = el.attributes["rotWithShape"] !== "0";
|
|
7261
8223
|
const blip = findChild(el, "a:blip");
|
|
7262
8224
|
if (blip) {
|
|
7263
|
-
const blipResult = parse(blipDesc, blip, ctx);
|
|
8225
|
+
const blipResult = parse$1(blipDesc, blip, ctx);
|
|
7264
8226
|
if (blipResult.referenceId) result.referenceId = blipResult.referenceId;
|
|
7265
8227
|
if (blipResult.blipEffects) result.blipEffects = blipResult.blipEffects;
|
|
7266
8228
|
}
|
|
7267
8229
|
const srcRect = findChild(el, "a:srcRect");
|
|
7268
|
-
if (srcRect) result.
|
|
8230
|
+
if (srcRect) result.sourceRectangle = parse$1(sourceRectangleDesc, srcRect, ctx);
|
|
7269
8231
|
const tile = findChild(el, "a:tile");
|
|
7270
|
-
if (tile) result.tile = parse(tileDesc, tile, ctx);
|
|
8232
|
+
if (tile) result.tile = parse$1(tileDesc, tile, ctx);
|
|
7271
8233
|
return result;
|
|
7272
8234
|
}
|
|
7273
8235
|
};
|
|
@@ -7278,7 +8240,7 @@ const blipFillDesc = {
|
|
|
7278
8240
|
*
|
|
7279
8241
|
* @module
|
|
7280
8242
|
*/
|
|
7281
|
-
const
|
|
8243
|
+
const diagramRelationshipIdsDesc = {
|
|
7282
8244
|
kind: "custom",
|
|
7283
8245
|
stringify(opts, _ctx) {
|
|
7284
8246
|
return `<dgm:relIds r:dm="${escapeXml(opts.dm)}" r:lo="${escapeXml(opts.lo)}" r:qs="${escapeXml(opts.qs)}" r:cs="${escapeXml(opts.cs)}"/>`;
|
|
@@ -7297,30 +8259,30 @@ const diagramRelIdsDesc = {
|
|
|
7297
8259
|
const diagramStyleDesc = {
|
|
7298
8260
|
kind: "custom",
|
|
7299
8261
|
stringify(opts, _ctx) {
|
|
7300
|
-
return `<dgm:style><a:lnRef idx="${opts.
|
|
8262
|
+
return `<dgm:style><a:lnRef idx="${opts.lineReference?.idx ?? 1}"><a:schemeClr val="accent1"/></a:lnRef><a:fillRef idx="${opts.fillReference?.idx ?? 1}"><a:schemeClr val="accent1"/></a:fillRef><a:effectRef idx="${opts.effectReference?.idx ?? 0}"><a:schemeClr val="accent1"/></a:effectRef><a:fontRef idx="${escapeXml(opts.fontReference?.idx ?? "minor")}"><a:schemeClr val="tx1"/></a:fontRef></dgm:style>`;
|
|
7301
8263
|
},
|
|
7302
8264
|
parse(el, _ctx) {
|
|
7303
8265
|
const result = {};
|
|
7304
8266
|
const lnRef = findChild(el, "a:lnRef");
|
|
7305
|
-
if (lnRef?.attributes?.["idx"] !== void 0) result.
|
|
8267
|
+
if (lnRef?.attributes?.["idx"] !== void 0) result.lineReference = { idx: Number(lnRef.attributes["idx"]) };
|
|
7306
8268
|
const fillRef = findChild(el, "a:fillRef");
|
|
7307
|
-
if (fillRef?.attributes?.["idx"] !== void 0) result.
|
|
8269
|
+
if (fillRef?.attributes?.["idx"] !== void 0) result.fillReference = { idx: Number(fillRef.attributes["idx"]) };
|
|
7308
8270
|
const effectRef = findChild(el, "a:effectRef");
|
|
7309
|
-
if (effectRef?.attributes?.["idx"] !== void 0) result.
|
|
8271
|
+
if (effectRef?.attributes?.["idx"] !== void 0) result.effectReference = { idx: Number(effectRef.attributes["idx"]) };
|
|
7310
8272
|
const fontRef = findChild(el, "a:fontRef");
|
|
7311
|
-
if (fontRef?.attributes?.["idx"] !== void 0) result.
|
|
8273
|
+
if (fontRef?.attributes?.["idx"] !== void 0) result.fontReference = { idx: String(fontRef.attributes["idx"]) };
|
|
7312
8274
|
return result;
|
|
7313
8275
|
}
|
|
7314
8276
|
};
|
|
7315
|
-
const
|
|
8277
|
+
const presentationLayoutVariablesDesc = {
|
|
7316
8278
|
kind: "custom",
|
|
7317
8279
|
stringify(opts, _ctx) {
|
|
7318
8280
|
const parts = [];
|
|
7319
8281
|
if (opts.orgChart?.val !== void 0) parts.push(`<dgm:orgChart val="${opts.orgChart.val ? 1 : 0}"/>`);
|
|
7320
|
-
if (opts.
|
|
7321
|
-
if (opts.
|
|
7322
|
-
if (opts.
|
|
7323
|
-
if (opts.
|
|
8282
|
+
if (opts.maxChildren?.val !== void 0) parts.push(`<dgm:chMax val="${opts.maxChildren.val}"/>`);
|
|
8283
|
+
if (opts.preferredChildren?.val !== void 0) parts.push(`<dgm:chPref val="${opts.preferredChildren.val}"/>`);
|
|
8284
|
+
if (opts.animateOneByOne?.val !== void 0) parts.push(`<dgm:animOne val="${escapeXml(opts.animateOneByOne.val)}"/>`);
|
|
8285
|
+
if (opts.animationLevel?.val !== void 0) parts.push(`<dgm:animLvl val="${escapeXml(opts.animationLevel.val)}"/>`);
|
|
7324
8286
|
if (opts.hierBranch?.val !== void 0) parts.push(`<dgm:hierBranch val="${escapeXml(opts.hierBranch.val)}"/>`);
|
|
7325
8287
|
if (parts.length === 0) return `<dgm:presLayoutVars/>`;
|
|
7326
8288
|
return `<dgm:presLayoutVars>${parts.join("")}</dgm:presLayoutVars>`;
|
|
@@ -7330,19 +8292,19 @@ const presLayoutVarsDesc = {
|
|
|
7330
8292
|
const orgChart = findChild(el, "dgm:orgChart");
|
|
7331
8293
|
if (orgChart?.attributes?.["val"] !== void 0) result.orgChart = { val: orgChart.attributes["val"] === 1 || orgChart.attributes["val"] === "1" };
|
|
7332
8294
|
const chMax = findChild(el, "dgm:chMax");
|
|
7333
|
-
if (chMax?.attributes?.["val"] !== void 0) result.
|
|
8295
|
+
if (chMax?.attributes?.["val"] !== void 0) result.maxChildren = { val: Number(chMax.attributes["val"]) };
|
|
7334
8296
|
const chPref = findChild(el, "dgm:chPref");
|
|
7335
|
-
if (chPref?.attributes?.["val"] !== void 0) result.
|
|
8297
|
+
if (chPref?.attributes?.["val"] !== void 0) result.preferredChildren = { val: Number(chPref.attributes["val"]) };
|
|
7336
8298
|
const animOne = findChild(el, "dgm:animOne");
|
|
7337
|
-
if (animOne?.attributes?.["val"] !== void 0) result.
|
|
8299
|
+
if (animOne?.attributes?.["val"] !== void 0) result.animateOneByOne = { val: String(animOne.attributes["val"]) };
|
|
7338
8300
|
const animLvl = findChild(el, "dgm:animLvl");
|
|
7339
|
-
if (animLvl?.attributes?.["val"] !== void 0) result.
|
|
8301
|
+
if (animLvl?.attributes?.["val"] !== void 0) result.animationLevel = { val: String(animLvl.attributes["val"]) };
|
|
7340
8302
|
const hierBranch = findChild(el, "dgm:hierBranch");
|
|
7341
8303
|
if (hierBranch?.attributes?.["val"] !== void 0) result.hierBranch = { val: String(hierBranch.attributes["val"]) };
|
|
7342
8304
|
return result;
|
|
7343
8305
|
}
|
|
7344
8306
|
};
|
|
7345
|
-
const
|
|
8307
|
+
const diagramExtensionListDesc = {
|
|
7346
8308
|
kind: "custom",
|
|
7347
8309
|
stringify(opts, _ctx) {
|
|
7348
8310
|
if (!opts.extensions?.length) return void 0;
|
|
@@ -7391,17 +8353,6 @@ function compileMapping(mapping, overrides, media, mediaLevel = 0) {
|
|
|
7391
8353
|
*
|
|
7392
8354
|
* @module
|
|
7393
8355
|
*/
|
|
7394
|
-
let _bufToBase64;
|
|
7395
|
-
try {
|
|
7396
|
-
const { Buffer: Buf } = await import("node:buffer");
|
|
7397
|
-
_bufToBase64 = (bytes) => Buf.from(bytes).toString("base64");
|
|
7398
|
-
} catch {}
|
|
7399
|
-
function toBase64(bytes) {
|
|
7400
|
-
if (_bufToBase64) return _bufToBase64(bytes);
|
|
7401
|
-
let binary = "";
|
|
7402
|
-
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
7403
|
-
return btoa(binary);
|
|
7404
|
-
}
|
|
7405
8356
|
function utf16leEncode(str) {
|
|
7406
8357
|
const bytes = new Uint8Array(str.length * 2);
|
|
7407
8358
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -7438,7 +8389,7 @@ function hashPasswordAgile(password, salt, spinCount) {
|
|
|
7438
8389
|
buf[h.length + 3] = i >> 24 & 255;
|
|
7439
8390
|
h = sha512(buf);
|
|
7440
8391
|
}
|
|
7441
|
-
return
|
|
8392
|
+
return encodeBase64(new Uint8Array(h));
|
|
7442
8393
|
}
|
|
7443
8394
|
/**
|
|
7444
8395
|
* Derives a password hash for OOXML document protection.
|
|
@@ -7450,7 +8401,7 @@ function derivePasswordHash(password, spinCount = 1e5) {
|
|
|
7450
8401
|
const salt = randomBytes(16);
|
|
7451
8402
|
return {
|
|
7452
8403
|
hashValue: hashPasswordAgile(password, salt, spinCount),
|
|
7453
|
-
saltValue:
|
|
8404
|
+
saltValue: encodeBase64(salt),
|
|
7454
8405
|
spinCount,
|
|
7455
8406
|
algorithmName: "SHA-512"
|
|
7456
8407
|
};
|
|
@@ -7639,4 +8590,4 @@ function replaceHyperlinkPlaceholders(xml, hyperlinks, offset) {
|
|
|
7639
8590
|
return replacePlaceholders(xml, map);
|
|
7640
8591
|
}
|
|
7641
8592
|
//#endregion
|
|
7642
|
-
export { solidFillDesc as $, createTileInfo as $n,
|
|
8593
|
+
export { solidFillDesc as $, createTileInfo as $n, unzipSync$1 as $r, convertToTwip as $t, bevelDesc as A, createFillOverlayEffect as An, SchemeColor as Ar, createHierBranch as At, shapeLockingDesc as B, createLineEnd as Bn, PART_REGISTRIES as Br, createTableStyleList as Bt, diagramStyleDesc as C, PresetShadowVal as Cn, uniqueUuid as Cr, AnimateOneByOneValue as Ct, sourceRectangleDesc as D, createInnerShadowEffect as Dn, createSolidFill as Dr, createAdjustList as Dt, blipFillDesc as E, createOuterShadowEffect as En, createColorElement as Er, createAdjust as Et, customGeometryDesc as F, PresetDash as Fn, createPresetColor as Fr, createGraphicFrameLocking as Ft, patternFillDesc as G, extractBlipFillMedia as Gn, ParsedArchive as Gr, convertEmuToPoints as Gt, outlineDesc as H, createGroupFill as Hn, XLSX_PARTS as Hr, createTransformation as Ht, presetGeometryDesc as I, createOutline as In, createHslColor as Ir, createGroupLocking as It, parseColorChoice as J, PathShadeType as Jn, ZIP_STORED_LEVEL as Jr, convertMillimetersToTwip as Jt, getColorDescriptor as K, PresetPattern as Kn, parseArchive as Kr, convertInchesToEmu as Kt, graphicFrameLockingDesc as L, LineEndLength as Ln, createColorTransforms as Lr, createPictureLocking as Lt, shape3DDesc as M, LineCap as Mn, createScRgbColor as Mr, createOrgChart as Mt, groupTransform2DDesc as N, LineJoin as Nn, createRgbColor as Nr, createPreferredChildren as Nt, stretchDesc as O, createGlowEffect as On, SystemColor as Or, createAnimateOneByOne as Ot, transform2DDesc as P, PenAlignment as Pn, PresetColor as Pr, createPresentationLayoutVariables as Pt, schemeColorDesc as Q, TileAlignment as Qn, strFromU8$1 as Qr, convertToEmu as Qt, groupLockingDesc as R, LineEndType as Rn, buildContentTypeOverrides as Rr, createShapeLocking as Rt, diagramRelationshipIdsDesc as S, createReflectionEffect as Sn, uniqueNumericIdCreator as Sr, createStyleDefinitionHeaderList as St, blipDesc as T, RectAlignment as Tn, toUint8Array as Tr, HierBranchStyle as Tt, fillDesc as U, createNoFill as Un, summarizeOpcIssues as Ur, convertEmuToInches as Ut, effectListDesc as V, createCustomDash as Vn, PPTX_PARTS as Vr, parseTableStyleList as Vt, gradientFillDesc as W, buildFill as Wn, validateOpcConsistency as Wr, convertEmuToPixels as Wt, rgbColorDesc as X, createGradientFill as Xn, createZipStream as Xr, convertPointsToEmu as Xt, presetColorDesc as Y, TileFlipMode as Yn, createPacker as Yr, convertPixelsToEmu as Yt, scRgbColorDesc as Z, createGradientStop as Zn, levelForMediaName as Zr, convertPositionToEmu as Zt, derivePasswordHash as _, createScene3D as _n, xsdVerticalMergeRev as _r, createColorsDefinitionHeader as _t, getMediaRefs as a, encodeBase64 as ai, stringifyStretch as an, xsdLineEndSize as ar, ColorMethod as at, compileMapping as b, createEffectList as bn, hashedId as br, createLayoutDefinitionHeaderList as bt, hasPlaceholders as c, createDefault as ci, createExtentionList as cn, xsdPattern as cr, StyleMatrixIndex as ct, replaceHyperlinkPlaceholders as d, TargetModeType as di, stringifyAdjustmentValues as dn, xsdRectAlignment as dr, createFillColorList as dt, zipAndConvert as ei, convertUniversalMeasureToEmu as en, invertMap as er, systemColorDesc as et, replaceImagePlaceholders as f, PresetMaterialType as fn, xsdStrikeStyle as fr, createLineColorList as ft, replaceVideoPlaceholders as g, createBottomBevel as gn, xsdUnderlineStyle as gr, createTextLineColorList as gt, replaceSmartArtPlaceholders as h, createBevel as hn, xsdTextCaps as hr, createTextFillColorList as ht, formatId as i, decodeBase64 as ii, createTransform2D as in, xsdLineCap as ir, createDiagramRelationshipIds as it, scene3DDesc as j, CompoundLine as jn, createSchemeColor as jr, createMaxChildren as jt, tileDesc as k, BlendMode as kn, createSystemColor as kr, createAnimationLevel as kt, replaceAllPlaceholders as l, createOverride as li, createCustomGeometry as ln, xsdPenAlignment as lr, createDiagramStyle as lt, replaceNumberingPlaceholders as m, BevelPresetType as mn, xsdTextAnchor as mr, createTextEffectColorList as mt, collectPlaceholderKeys as n, OoxmlMimeType as ni, parseUniversalMeasure as nn, xsdCompoundLine as nr, createDiagramShape3D as nt, getReferencedMedia as o, customPropertiesDesc as oi, createBlipFill as on, xsdMaterialType as or, FontCollectionIndex as ot, replaceMediaPlaceholders as p, createShape3D as pn, xsdTextAlign as pr, createStyleLabel as pt, hslColorDesc as q, createPatternFill as qn, ZIP_DEFLATE_LEVEL as qr, convertInchesToTwip as qt, findAndReplaceImagePlaceholders as r, convertOutput as ri, createGroupTransform2D as rn, xsdEffectContainer as rr, createDiagramTextProperties as rt, getVideoRefs as s, appPropertiesDesc as si, createBlip as sn, xsdPathFillMode as sr, HueDirection as st, addSmartArtRelationships as t, zipSyncAndConvert as ti, convertUniversalMeasureToTwip as tn, xsdBlendMode as tr, createDiagramExtensionList as tt, replaceChartPlaceholders as u, Relationships as ui, stringifyPresetGeometry as un, xsdPresetShadow as ur, createEffectColorList as ut, hashPasswordAgile as v, createEffectDag as vn, createSourceRectangle as vr, createColorsDefinitionHeaderList as vt, presentationLayoutVariablesDesc as w, createPresetShadowEffect as wn, isBase64DataURL as wr, AnimationLevelValue as wt, diagramExtensionListDesc as x, createSoftEdgeEffect as xn, uniqueId as xr, createStyleDefinitionHeader as xt, randomBytes as y, calculateEffectExtent as yn, createBlipEffects as yr, createLayoutDefinitionHeader as yt, pictureLockingDesc as z, LineEndWidth as zn, DOCX_PARTS as zr, createTableStyle as zt };
|