ooxml-core 1.23.0 → 1.24.1
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/README.md +2 -2
- package/dist/{PptxHandler-FSKKPZZC.mjs → PptxHandler-5TWAQWPK.mjs} +2 -2
- package/dist/{PptxHandler-H7MEWJJJ.mjs → PptxHandler-KBJ4TN3T.mjs} +1 -1
- package/dist/{PptxHandler-DNSXWTQV.cjs → PptxHandler-KFEE7O7W.cjs} +2 -2
- package/dist/{PresentationBuilder-7TSENZTX.mjs → PresentationBuilder-SCT5AQBP.mjs} +1 -1
- package/dist/{PresentationBuilder-RIJWQSEU.mjs → PresentationBuilder-SVHIKT4C.mjs} +2 -2
- package/dist/{PresentationBuilder-A5NI35VN.cjs → PresentationBuilder-SXLRXYDI.cjs} +4 -4
- package/dist/automation/index.cjs +553 -335
- package/dist/automation/index.d.ts +1 -0
- package/dist/automation/index.d.ts.map +1 -1
- package/dist/automation/index.mjs +552 -336
- package/dist/automation/live.d.ts +89 -0
- package/dist/automation/live.d.ts.map +1 -0
- package/dist/{chunk-4QPOJCJG.mjs → chunk-7N7C5BNM.mjs} +1 -1
- package/dist/{chunk-DLFMCZZT.mjs → chunk-CWCDFPKN.mjs} +1 -1
- package/dist/{chunk-LF5E5ZOH.mjs → chunk-GVP262WE.mjs} +25 -62
- package/dist/{chunk-VQF6HQEE.mjs → chunk-KVKTHGIY.mjs} +1 -1
- package/dist/{chunk-BA7Z6ATM.mjs → chunk-NE7626A4.mjs} +4 -4
- package/dist/{chunk-Q5PKBQXH.mjs → chunk-ON7XVRHQ.mjs} +26 -63
- package/dist/{chunk-HL3FBJ6X.cjs → chunk-XK55DEUD.cjs} +25 -62
- package/dist/docx/ui/customization.d.ts +30 -0
- package/dist/docx/ui/customization.d.ts.map +1 -0
- package/dist/docx/ui/index.cjs +51 -0
- package/dist/docx/ui/index.d.ts +1 -0
- package/dist/docx/ui/index.d.ts.map +1 -1
- package/dist/docx/ui/index.mjs +46 -1
- package/dist/embedding/backstage.d.ts +48 -0
- package/dist/embedding/backstage.d.ts.map +1 -0
- package/dist/embedding/capabilities.d.ts +60 -0
- package/dist/embedding/capabilities.d.ts.map +1 -0
- package/dist/embedding/customization.d.ts +32 -0
- package/dist/embedding/customization.d.ts.map +1 -0
- package/dist/embedding/index.cjs +229 -0
- package/dist/embedding/index.d.ts +7 -0
- package/dist/embedding/index.d.ts.map +1 -0
- package/dist/embedding/index.mjs +204 -0
- package/dist/embedding/menu-commands.d.ts +66 -0
- package/dist/embedding/menu-commands.d.ts.map +1 -0
- package/dist/embedding/regions.d.ts +58 -0
- package/dist/embedding/regions.d.ts.map +1 -0
- package/dist/embedding/storage.d.ts +111 -0
- package/dist/embedding/storage.d.ts.map +1 -0
- package/dist/index.cjs +233 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +233 -1
- package/dist/pptx/automation/index.cjs +25 -67
- package/dist/pptx/automation/index.d.ts +3 -2
- package/dist/pptx/automation/index.d.ts.map +1 -1
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-Q5mM8kIR.d.ts → index-4FmgJajb.d.ts} +3 -2
- package/dist/pptx/chunks/index-4FmgJajb.d.ts.map +1 -0
- package/dist/pptx/chunks/index-C3xhAMSa.d.ts +837 -0
- package/dist/pptx/chunks/index-C3xhAMSa.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-CPhsd7Df.d.ts → index-nKQ4s7FA.d.ts} +24 -834
- package/dist/pptx/chunks/index-nKQ4s7FA.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +25 -67
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.d.ts +1 -1
- package/dist/pptx/editor/render/slide-operations.cjs +1 -1
- package/dist/pptx/editor/render/slide-operations.mjs +1 -1
- package/dist/pptx/index.cjs +25 -67
- package/dist/pptx/index.d.ts +4 -3
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/node/index.cjs +40 -0
- package/dist/pptx/node/index.d.ts +13 -0
- package/dist/pptx/node/index.d.ts.map +1 -0
- package/dist/pptx/node/index.mjs +40 -0
- package/dist/visio/collab/compose.d.ts.map +1 -1
- package/dist/visio/collab/fixups.d.ts.map +1 -1
- package/dist/visio/collab/index.cjs +167 -62
- package/dist/visio/collab/index.mjs +167 -62
- package/dist/visio/collab/keys.d.ts +2 -0
- package/dist/visio/collab/keys.d.ts.map +1 -1
- package/dist/visio/collab/pieces.d.ts +7 -0
- package/dist/visio/collab/pieces.d.ts.map +1 -1
- package/dist/visio/collab/read-ids.d.ts +7 -1
- package/dist/visio/collab/read-ids.d.ts.map +1 -1
- package/dist/visio/collab/read-parts.d.ts.map +1 -1
- package/dist/visio/collab/read-shapes.d.ts +0 -1
- package/dist/visio/collab/read-shapes.d.ts.map +1 -1
- package/dist/visio/collab/read.d.ts.map +1 -1
- package/dist/visio/collab/schema.d.ts +1 -1
- package/dist/visio/collab/schema.d.ts.map +1 -1
- package/dist/visio/collab/snapshot-contents.d.ts.map +1 -1
- package/dist/visio/collab/write-shapes.d.ts.map +1 -1
- package/dist/visio/collab/zip-store.d.ts +4 -0
- package/dist/visio/collab/zip-store.d.ts.map +1 -0
- package/dist/visio/document-level.d.ts +57 -0
- package/dist/visio/document-level.d.ts.map +1 -0
- package/dist/visio/index.cjs +543 -444
- package/dist/visio/index.d.ts +1 -0
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +543 -444
- package/dist/visio/layers.d.ts +3 -0
- package/dist/visio/layers.d.ts.map +1 -1
- package/dist/visio/package.d.ts +9 -0
- package/dist/visio/package.d.ts.map +1 -1
- package/dist/visio/parser.d.ts +7 -0
- package/dist/visio/parser.d.ts.map +1 -1
- package/dist/visio/shape-metadata.d.ts +3 -0
- package/dist/visio/shape-metadata.d.ts.map +1 -1
- package/dist/visio/ui/contract.d.ts +27 -2
- package/dist/visio/ui/contract.d.ts.map +1 -1
- package/dist/visio/ui/customization.d.ts +46 -0
- package/dist/visio/ui/customization.d.ts.map +1 -0
- package/dist/visio/ui/index.cjs +454 -316
- package/dist/visio/ui/index.d.ts +1 -0
- package/dist/visio/ui/index.d.ts.map +1 -1
- package/dist/visio/ui/index.mjs +452 -317
- package/dist/xlsx/ui/commands.d.ts +2 -0
- package/dist/xlsx/ui/commands.d.ts.map +1 -1
- package/dist/xlsx/ui/customization.d.ts +49 -0
- package/dist/xlsx/ui/customization.d.ts.map +1 -0
- package/dist/xlsx/ui/index.cjs +39 -1
- package/dist/xlsx/ui/index.d.ts +1 -0
- package/dist/xlsx/ui/index.d.ts.map +1 -1
- package/dist/xlsx/ui/index.mjs +37 -2
- package/package.json +11 -1
- package/dist/pptx/chunks/index-CPhsd7Df.d.ts.map +0 -1
- package/dist/pptx/chunks/index-Q5mM8kIR.d.ts.map +0 -1
|
@@ -58145,7 +58145,7 @@ function isValidSpinCount(spinCount, maxSpinCount = DEFAULT_MAX_SPIN_COUNT) {
|
|
|
58145
58145
|
const limit3 = Math.min(maxSpinCount, MAX_SPIN_COUNT);
|
|
58146
58146
|
return spinCount === void 0 || Number.isInteger(spinCount) && spinCount >= 0 && spinCount <= limit3;
|
|
58147
58147
|
}
|
|
58148
|
-
function spinPasswordHash(password, salt, spinCount,
|
|
58148
|
+
function spinPasswordHash(password, salt, spinCount, digest2) {
|
|
58149
58149
|
const input2 = new Uint8Array(salt.length + password.length * 2);
|
|
58150
58150
|
input2.set(salt);
|
|
58151
58151
|
for (let i2 = 0; i2 < password.length; i2++) {
|
|
@@ -58153,21 +58153,21 @@ function spinPasswordHash(password, salt, spinCount, digest) {
|
|
|
58153
58153
|
input2[salt.length + i2 * 2] = code & 255;
|
|
58154
58154
|
input2[salt.length + i2 * 2 + 1] = code >> 8;
|
|
58155
58155
|
}
|
|
58156
|
-
let value3 =
|
|
58156
|
+
let value3 = digest2(input2);
|
|
58157
58157
|
const buffer = new Uint8Array(value3.length + 4);
|
|
58158
58158
|
const view = new DataView(buffer.buffer);
|
|
58159
58159
|
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
58160
58160
|
buffer.set(value3);
|
|
58161
58161
|
view.setUint32(value3.length, i2, true);
|
|
58162
|
-
value3 =
|
|
58162
|
+
value3 = digest2(buffer);
|
|
58163
58163
|
}
|
|
58164
58164
|
return value3;
|
|
58165
58165
|
}
|
|
58166
58166
|
function hashBytes(password, { algorithmName, saltValue, spinCount }, limits) {
|
|
58167
|
-
const
|
|
58167
|
+
const digest2 = digestFunction(algorithmName);
|
|
58168
58168
|
const salt = decodeBase64(saltValue);
|
|
58169
|
-
if (!
|
|
58170
|
-
return spinPasswordHash(password, salt, spinCount ?? 0,
|
|
58169
|
+
if (!digest2 || !salt || !isValidSpinCount(spinCount, limits.maxSpinCount)) return void 0;
|
|
58170
|
+
return spinPasswordHash(password, salt, spinCount ?? 0, digest2);
|
|
58171
58171
|
}
|
|
58172
58172
|
function verifyPasswordHash(password, hash2, limits = {}) {
|
|
58173
58173
|
if (!digestFunction(hash2.algorithmName)) return void 0;
|
|
@@ -61229,6 +61229,7 @@ var VisioPackage = class _VisioPackage {
|
|
|
61229
61229
|
relationshipCache = /* @__PURE__ */ new Map();
|
|
61230
61230
|
byteCache = /* @__PURE__ */ new Map();
|
|
61231
61231
|
decodedNames = /* @__PURE__ */ new Map();
|
|
61232
|
+
noted;
|
|
61232
61233
|
totalOutput = 0;
|
|
61233
61234
|
totalXmlNodes = 0;
|
|
61234
61235
|
check = () => {
|
|
@@ -61263,7 +61264,26 @@ var VisioPackage = class _VisioPackage {
|
|
|
61263
61264
|
);
|
|
61264
61265
|
}
|
|
61265
61266
|
}
|
|
61267
|
+
/**
|
|
61268
|
+
* Starts noting every part this package is asked about (read, listed in a relationship, or
|
|
61269
|
+
* checked for). The returned function stops noting and gives each part with a print of its
|
|
61270
|
+
* declared CRC-32 and size (empty when absent), which is what {@link printOf} compares.
|
|
61271
|
+
*/
|
|
61272
|
+
record() {
|
|
61273
|
+
const noted = /* @__PURE__ */ new Set();
|
|
61274
|
+
this.noted = noted;
|
|
61275
|
+
return () => {
|
|
61276
|
+
if (this.noted === noted) this.noted = void 0;
|
|
61277
|
+
return [...noted].sort().map((path3) => [path3, this.printOf(path3)]);
|
|
61278
|
+
};
|
|
61279
|
+
}
|
|
61280
|
+
/** The declared CRC-32 and size of a part, or an empty string when the package lacks it. */
|
|
61281
|
+
printOf(path3) {
|
|
61282
|
+
const entry3 = this.entries.get(path3);
|
|
61283
|
+
return entry3 && !entry3.directory ? `${entry3.crc}:${entry3.size}` : "";
|
|
61284
|
+
}
|
|
61266
61285
|
has(path3) {
|
|
61286
|
+
this.noted?.add(path3);
|
|
61267
61287
|
return this.entries.get(path3)?.directory === false;
|
|
61268
61288
|
}
|
|
61269
61289
|
paths() {
|
|
@@ -61271,6 +61291,7 @@ var VisioPackage = class _VisioPackage {
|
|
|
61271
61291
|
}
|
|
61272
61292
|
async readXml(path3, expectedRoot) {
|
|
61273
61293
|
this.check();
|
|
61294
|
+
this.noted?.add(path3);
|
|
61274
61295
|
safePath(path3);
|
|
61275
61296
|
let pending2 = this.cache.get(path3);
|
|
61276
61297
|
if (!pending2) {
|
|
@@ -61286,6 +61307,7 @@ var VisioPackage = class _VisioPackage {
|
|
|
61286
61307
|
/** Validated declared size, so resource-specific limits can reject before inflation. */
|
|
61287
61308
|
getPartByteLength(path3) {
|
|
61288
61309
|
this.check();
|
|
61310
|
+
this.noted?.add(path3);
|
|
61289
61311
|
safePath(path3);
|
|
61290
61312
|
const entry3 = this.entries.get(path3);
|
|
61291
61313
|
if (!entry3 || entry3.directory) fail3("MISSING_PART", `Missing package part: ${path3}`);
|
|
@@ -61294,6 +61316,7 @@ var VisioPackage = class _VisioPackage {
|
|
|
61294
61316
|
/** Shared package-owned bytes. Treat the returned buffer as immutable. */
|
|
61295
61317
|
async readBytes(path3) {
|
|
61296
61318
|
this.check();
|
|
61319
|
+
this.noted?.add(path3);
|
|
61297
61320
|
safePath(path3);
|
|
61298
61321
|
let pending2 = this.byteCache.get(path3);
|
|
61299
61322
|
if (!pending2) {
|
|
@@ -61387,6 +61410,10 @@ var VisioPackage = class _VisioPackage {
|
|
|
61387
61410
|
}
|
|
61388
61411
|
async relationships(sourcePart) {
|
|
61389
61412
|
this.check();
|
|
61413
|
+
if (this.noted && sourcePart) {
|
|
61414
|
+
const slash = sourcePart.lastIndexOf("/");
|
|
61415
|
+
this.noted.add(`${sourcePart.slice(0, slash + 1)}_rels/${sourcePart.slice(slash + 1)}.rels`);
|
|
61416
|
+
} else this.noted?.add("_rels/.rels");
|
|
61390
61417
|
let pending2 = this.relationshipCache.get(sourcePart);
|
|
61391
61418
|
if (!pending2) {
|
|
61392
61419
|
pending2 = this.loadRelationships(sourcePart);
|
|
@@ -61420,6 +61447,7 @@ var VisioPackage = class _VisioPackage {
|
|
|
61420
61447
|
const actual = mode === "Internal" ? this.decodedNames.get(resolved) : void 0;
|
|
61421
61448
|
if (mode === "Internal" && !actual)
|
|
61422
61449
|
fail3("INVALID_RELATIONSHIP", `Missing relationship target: ${resolved}`);
|
|
61450
|
+
if (actual) this.noted?.add(actual);
|
|
61423
61451
|
result2.set(id4, { id: id4, type, target: actual ?? resolved, mode });
|
|
61424
61452
|
}
|
|
61425
61453
|
return result2;
|
|
@@ -67774,6 +67802,10 @@ function createLayerBudget() {
|
|
|
67774
67802
|
memberships += count3;
|
|
67775
67803
|
if (memberships > 1e5)
|
|
67776
67804
|
throw new VisioPackageError("METADATA_LIMIT", "Layer membership budget exceeded.");
|
|
67805
|
+
},
|
|
67806
|
+
state: () => [memberships, characters],
|
|
67807
|
+
restore(state) {
|
|
67808
|
+
[memberships, characters] = state;
|
|
67777
67809
|
}
|
|
67778
67810
|
};
|
|
67779
67811
|
}
|
|
@@ -67845,97 +67877,6 @@ function shapeLayers(sheet2, layers, report, budget = createLayerBudget()) {
|
|
|
67845
67877
|
};
|
|
67846
67878
|
}
|
|
67847
67879
|
|
|
67848
|
-
// visio/theme.ts
|
|
67849
|
-
var VISIO_SCHEME_SLOTS = [
|
|
67850
|
-
"dk1",
|
|
67851
|
-
"lt1",
|
|
67852
|
-
"accent1",
|
|
67853
|
-
"accent2",
|
|
67854
|
-
"accent3",
|
|
67855
|
-
"accent4",
|
|
67856
|
-
"accent5",
|
|
67857
|
-
"accent6"
|
|
67858
|
-
];
|
|
67859
|
-
var componentId = (node4) => integer5(themeChild(node4, "schemeID", THEME_NS)?.getAttribute("schemeEnum"));
|
|
67860
|
-
async function loadVisioThemes(pkg, source2, report) {
|
|
67861
|
-
const result2 = [];
|
|
67862
|
-
for (const rel of (await pkg.relationships(source2)).values()) {
|
|
67863
|
-
if (rel.type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" || rel.mode === "External")
|
|
67864
|
-
continue;
|
|
67865
|
-
const root = await pkg.readXml(rel.target, "theme");
|
|
67866
|
-
if (root.namespaceURI !== DRAWING_NS) {
|
|
67867
|
-
report("unsupported-theme", "A theme uses an unsupported XML namespace.", {
|
|
67868
|
-
part: rel.target
|
|
67869
|
-
});
|
|
67870
|
-
continue;
|
|
67871
|
-
}
|
|
67872
|
-
const base3 = themeChild(root, "themeElements");
|
|
67873
|
-
const palette = themeChild(base3, "clrScheme");
|
|
67874
|
-
const scheme = parseTheme(root).colorScheme.colors;
|
|
67875
|
-
const colors = /* @__PURE__ */ new Map();
|
|
67876
|
-
for (const name4 of VISIO_SCHEME_SLOTS) {
|
|
67877
|
-
const color3 = scheme[name4];
|
|
67878
|
-
if (color3 && parsedColorChoice(themeChild(palette, name4))) colors.set(name4, color3);
|
|
67879
|
-
}
|
|
67880
|
-
const background2 = parsedColorChoice(extension(palette, "bkgnd"));
|
|
67881
|
-
if (background2) colors.set("bkgnd", background2);
|
|
67882
|
-
const variants = themeChildren(
|
|
67883
|
-
extension(palette, "variationClrSchemeLst"),
|
|
67884
|
-
"variationClrScheme",
|
|
67885
|
-
THEME_NS
|
|
67886
|
-
).slice(0, 4).map((variant) => {
|
|
67887
|
-
const entries = /* @__PURE__ */ new Map();
|
|
67888
|
-
for (let index4 = 1; index4 <= 7; index4++) {
|
|
67889
|
-
const choice2 = parsedColorChoice(themeChild(variant, `varColor${index4}`, THEME_NS));
|
|
67890
|
-
if (choice2) entries.set(String(index4), choice2);
|
|
67891
|
-
}
|
|
67892
|
-
return entries;
|
|
67893
|
-
});
|
|
67894
|
-
const format8 = themeChild(base3, "fmtScheme");
|
|
67895
|
-
const connector2 = extension(base3, "fmtConnectorScheme");
|
|
67896
|
-
const fonts = extension(base3, "fontStylesGroup");
|
|
67897
|
-
const name3 = root.getAttribute("name");
|
|
67898
|
-
result2.push({
|
|
67899
|
-
...name3 ? { name: name3.slice(0, 256) } : {},
|
|
67900
|
-
colorId: integer5(extension(palette, "schemeID")?.getAttribute("schemeEnum")),
|
|
67901
|
-
effectId: componentId(extension(base3, "fmtSchemeEx")),
|
|
67902
|
-
connectorId: componentId(extension(base3, "fmtConnectorSchemeEx")),
|
|
67903
|
-
colors,
|
|
67904
|
-
variants,
|
|
67905
|
-
variationStyles: themeChildren(
|
|
67906
|
-
extension(base3, "variationStyleSchemeLst"),
|
|
67907
|
-
"variationStyleScheme",
|
|
67908
|
-
THEME_NS
|
|
67909
|
-
).slice(0, 4).map((variant) => themeChildren(variant, "varStyle", THEME_NS).slice(0, 4)),
|
|
67910
|
-
fills: formatList(format8, "fillStyleLst"),
|
|
67911
|
-
effects: themeChildren(themeChild(format8, "effectStyleLst"), "effectStyle").slice(0, 6),
|
|
67912
|
-
lines: themeChildren(themeChild(format8, "lnStyleLst"), "ln").slice(0, 6),
|
|
67913
|
-
fonts: themeChildren(themeChild(fonts, "fontStyles", THEME_NS), "fontProps", THEME_NS).slice(
|
|
67914
|
-
0,
|
|
67915
|
-
6
|
|
67916
|
-
),
|
|
67917
|
-
connectorFills: formatList(connector2, "fillStyleLst"),
|
|
67918
|
-
connectorEffects: themeChildren(themeChild(connector2, "effectStyleLst"), "effectStyle").slice(
|
|
67919
|
-
0,
|
|
67920
|
-
6
|
|
67921
|
-
),
|
|
67922
|
-
connectorLines: themeChildren(themeChild(connector2, "lnStyleLst"), "ln").slice(0, 6),
|
|
67923
|
-
connectorFonts: themeChildren(
|
|
67924
|
-
themeChild(fonts, "connectorFontStyles", THEME_NS),
|
|
67925
|
-
"fontProps",
|
|
67926
|
-
THEME_NS
|
|
67927
|
-
).slice(0, 6)
|
|
67928
|
-
});
|
|
67929
|
-
}
|
|
67930
|
-
return result2;
|
|
67931
|
-
}
|
|
67932
|
-
function formatList(parent, name3) {
|
|
67933
|
-
const list2 = themeChild(parent, name3);
|
|
67934
|
-
return list2 ? Array.from(list2.childNodes).filter(
|
|
67935
|
-
(node4) => node4.nodeType === 1 && node4.namespaceURI === DRAWING_NS
|
|
67936
|
-
).slice(0, 6) : [];
|
|
67937
|
-
}
|
|
67938
|
-
|
|
67939
67880
|
// visio/theme-builtins.ts
|
|
67940
67881
|
var VISIO_BUILT_IN_THEME_IDS = [
|
|
67941
67882
|
"office",
|
|
@@ -68099,6 +68040,346 @@ function diagnosticCollector(maxCount) {
|
|
|
68099
68040
|
};
|
|
68100
68041
|
}
|
|
68101
68042
|
|
|
68043
|
+
// visio/print-settings.ts
|
|
68044
|
+
var NAMES = [
|
|
68045
|
+
"PaperKind",
|
|
68046
|
+
"PrintPageOrientation",
|
|
68047
|
+
"PageLeftMargin",
|
|
68048
|
+
"PageRightMargin",
|
|
68049
|
+
"PageTopMargin",
|
|
68050
|
+
"PageBottomMargin",
|
|
68051
|
+
"ScaleX",
|
|
68052
|
+
"ScaleY",
|
|
68053
|
+
"OnPage",
|
|
68054
|
+
"PagesX",
|
|
68055
|
+
"PagesY",
|
|
68056
|
+
"CenterX",
|
|
68057
|
+
"CenterY"
|
|
68058
|
+
];
|
|
68059
|
+
var BOOLEAN = /* @__PURE__ */ new Set(["OnPage", "CenterX", "CenterY"]);
|
|
68060
|
+
var LENGTH = /* @__PURE__ */ new Set(["PageLeftMargin", "PageRightMargin", "PageTopMargin", "PageBottomMargin"]);
|
|
68061
|
+
var CANONICAL = new Map(
|
|
68062
|
+
[...NAMES, "PageWidth", "PageHeight", "PageScale", "DrawingScale"].map((name3) => [
|
|
68063
|
+
name3.toLowerCase(),
|
|
68064
|
+
name3
|
|
68065
|
+
])
|
|
68066
|
+
);
|
|
68067
|
+
function indexCells(sheet2) {
|
|
68068
|
+
const cells3 = /* @__PURE__ */ new Map();
|
|
68069
|
+
let duplicate = false;
|
|
68070
|
+
for (const node4 of children3(sheet2, "Cell")) {
|
|
68071
|
+
const name3 = attribute3(node4, "N") ?? "", canonical3 = CANONICAL.get(name3.toLowerCase());
|
|
68072
|
+
if (!canonical3) continue;
|
|
68073
|
+
if (canonical3 !== name3) duplicate = true;
|
|
68074
|
+
const values2 = cells3.get(canonical3) ?? [];
|
|
68075
|
+
if (values2.length < 2) values2.push(node4);
|
|
68076
|
+
cells3.set(canonical3, values2);
|
|
68077
|
+
if (values2.length > 1) duplicate = true;
|
|
68078
|
+
}
|
|
68079
|
+
return { cells: cells3, duplicate };
|
|
68080
|
+
}
|
|
68081
|
+
function createVisioPrintSettingsReader(documentSheets, rootStyles) {
|
|
68082
|
+
const indexes2 = { document: indexCells(documentSheets[0]), root: indexCells(rootStyles[0]) };
|
|
68083
|
+
return (pageSheets) => readVisioPrintCountSettings(pageSheets, documentSheets, rootStyles, indexes2);
|
|
68084
|
+
}
|
|
68085
|
+
function readVisioPrintCountSettings(pageSheets, documentSheets, rootStyles, indexes2) {
|
|
68086
|
+
let refusal;
|
|
68087
|
+
const refuse4 = (reason) => {
|
|
68088
|
+
refusal ??= reason;
|
|
68089
|
+
};
|
|
68090
|
+
if (pageSheets.length !== 1) refuse4("ambiguous-page-sheet");
|
|
68091
|
+
if (documentSheets.length > 1) refuse4("ambiguous-document-sheet");
|
|
68092
|
+
if (!documentSheets.length) refuse4("missing-setting");
|
|
68093
|
+
if (rootStyles.length > 1) refuse4("duplicate-setting");
|
|
68094
|
+
const root = rootStyles[0];
|
|
68095
|
+
if (!root || attribute3(root, "ID") !== "0" || attribute3(root, "NameU") !== "No Style")
|
|
68096
|
+
refuse4("unsupported-print-style");
|
|
68097
|
+
for (const sheet2 of [...pageSheets, ...documentSheets])
|
|
68098
|
+
for (const name3 of ["LineStyle", "FillStyle", "TextStyle"])
|
|
68099
|
+
if (attribute3(sheet2, name3) !== "0") refuse4("unsupported-print-style");
|
|
68100
|
+
for (const name3 of ["LineStyle", "FillStyle", "TextStyle"])
|
|
68101
|
+
if (attribute3(root, name3) !== void 0) refuse4("unsupported-print-style");
|
|
68102
|
+
const localIndex = indexCells(pageSheets[0]), rootIndex = indexes2?.root ?? indexCells(root);
|
|
68103
|
+
const documentIndex = indexes2?.document ?? indexCells(documentSheets[0]);
|
|
68104
|
+
if (localIndex.duplicate || rootIndex.duplicate || documentIndex.duplicate)
|
|
68105
|
+
refuse4("duplicate-setting");
|
|
68106
|
+
const local = localIndex.cells, inherited = rootIndex.cells;
|
|
68107
|
+
const read = (node4, name3, origin) => {
|
|
68108
|
+
const invalid3 = () => {
|
|
68109
|
+
refuse4(origin === "local" ? "invalid-local-setting" : "invalid-document-setting");
|
|
68110
|
+
return void 0;
|
|
68111
|
+
};
|
|
68112
|
+
if (node4.hasAttribute("E")) return invalid3();
|
|
68113
|
+
let raw2 = (attribute3(node4, "V") ?? "").trim();
|
|
68114
|
+
if (!raw2 || raw2.length > 128) return invalid3();
|
|
68115
|
+
if (BOOLEAN.has(name3)) {
|
|
68116
|
+
if (!["0", "1", "false", "true"].includes(raw2)) return invalid3();
|
|
68117
|
+
raw2 = raw2 === "true" ? "1" : raw2 === "false" ? "0" : raw2;
|
|
68118
|
+
}
|
|
68119
|
+
try {
|
|
68120
|
+
const value3 = visioFormulaCachedValue(raw2, attribute3(node4, "U"));
|
|
68121
|
+
const length = LENGTH.has(name3) || /^(PageWidth|PageHeight|PageScale|DrawingScale)$/.test(name3);
|
|
68122
|
+
if (!["scalar", ...length ? ["length"] : []].includes(value3.unit) || Math.abs(value3.value) > 1e9)
|
|
68123
|
+
return invalid3();
|
|
68124
|
+
const formula = attribute3(node4, "F");
|
|
68125
|
+
if (formula !== void 0) {
|
|
68126
|
+
const source2 = formula.trim();
|
|
68127
|
+
if (/^(true|false)$/i.test(source2)) {
|
|
68128
|
+
if ((source2.toLowerCase() === "true" ? 1 : 0) !== value3.value) return invalid3();
|
|
68129
|
+
} else {
|
|
68130
|
+
if (!source2 || source2 === "Inh") return invalid3();
|
|
68131
|
+
const limits = { maxLength: 512, maxNodes: 64, maxDepth: 16, maxSteps: 128 };
|
|
68132
|
+
const analysis = analyzeVisioFormula(source2, limits);
|
|
68133
|
+
if (analysis.dynamic || analysis.guarded || analysis.references.length || analysis.unsupportedFunctions.length) {
|
|
68134
|
+
refuse4("dynamic-setting");
|
|
68135
|
+
return void 0;
|
|
68136
|
+
}
|
|
68137
|
+
const evaluated = evaluateVisioFormula(
|
|
68138
|
+
source2,
|
|
68139
|
+
() => {
|
|
68140
|
+
throw new Error("Unexpected reference");
|
|
68141
|
+
},
|
|
68142
|
+
limits
|
|
68143
|
+
);
|
|
68144
|
+
if (evaluated.value !== value3.value || !["scalar", ...length ? ["length"] : []].includes(evaluated.unit))
|
|
68145
|
+
return invalid3();
|
|
68146
|
+
}
|
|
68147
|
+
}
|
|
68148
|
+
return value3.value;
|
|
68149
|
+
} catch {
|
|
68150
|
+
return invalid3();
|
|
68151
|
+
}
|
|
68152
|
+
};
|
|
68153
|
+
const values2 = /* @__PURE__ */ new Map();
|
|
68154
|
+
for (const name3 of NAMES) {
|
|
68155
|
+
const nodes = local.get(name3) ?? inherited.get(name3);
|
|
68156
|
+
if (!nodes?.length) continue;
|
|
68157
|
+
if (nodes.length !== 1) continue;
|
|
68158
|
+
const value3 = read(nodes[0], name3, local.has(name3) ? "local" : "document");
|
|
68159
|
+
if (value3 !== void 0) values2.set(name3, value3);
|
|
68160
|
+
}
|
|
68161
|
+
for (const name3 of ["PageWidth", "PageHeight", "PageScale", "DrawingScale"]) {
|
|
68162
|
+
const nodes = local.get(name3);
|
|
68163
|
+
if (!nodes || nodes.length !== 1 || !(read(nodes[0], name3, "local") > 0))
|
|
68164
|
+
refuse4("unusable-drawing-scale");
|
|
68165
|
+
}
|
|
68166
|
+
const setup = {};
|
|
68167
|
+
const paper = values2.get("PaperKind");
|
|
68168
|
+
if (paper !== void 0 && Number.isSafeInteger(paper) && paper >= 0 && paper <= 65535)
|
|
68169
|
+
setup.paperKind = paper;
|
|
68170
|
+
else if (paper !== void 0)
|
|
68171
|
+
refuse4(local.has("PaperKind") ? "invalid-local-setting" : "invalid-document-setting");
|
|
68172
|
+
const orientation = values2.get("PrintPageOrientation");
|
|
68173
|
+
if (orientation === 0 || orientation === 1 || orientation === 2)
|
|
68174
|
+
setup.printPageOrientation = orientation;
|
|
68175
|
+
else if (orientation !== void 0)
|
|
68176
|
+
refuse4(
|
|
68177
|
+
local.has("PrintPageOrientation") ? "invalid-local-setting" : "invalid-document-setting"
|
|
68178
|
+
);
|
|
68179
|
+
const margins = ["Left", "Right", "Top", "Bottom"].map((side2) => values2.get(`Page${side2}Margin`));
|
|
68180
|
+
if (margins.every((n) => n !== void 0 && n >= 0 && n <= 1e3))
|
|
68181
|
+
setup.margins = {
|
|
68182
|
+
left: margins[0],
|
|
68183
|
+
right: margins[1],
|
|
68184
|
+
top: margins[2],
|
|
68185
|
+
bottom: margins[3]
|
|
68186
|
+
};
|
|
68187
|
+
else if (margins.some((n) => n !== void 0 && (n < 0 || n > 1e3)))
|
|
68188
|
+
refuse4("unusable-print-area");
|
|
68189
|
+
for (const [name3, key2] of [
|
|
68190
|
+
["ScaleX", "printZoom"],
|
|
68191
|
+
["ScaleY", "printZoomY"],
|
|
68192
|
+
["PagesX", "printPagesAcross"],
|
|
68193
|
+
["PagesY", "printPagesDown"]
|
|
68194
|
+
]) {
|
|
68195
|
+
const value3 = values2.get(name3);
|
|
68196
|
+
if (value3 !== void 0) {
|
|
68197
|
+
if ((name3 === "PagesX" || name3 === "PagesY") && (!Number.isSafeInteger(value3) || value3 < 1))
|
|
68198
|
+
refuse4(local.has(name3) ? "invalid-local-setting" : "invalid-document-setting");
|
|
68199
|
+
else setup[key2] = value3;
|
|
68200
|
+
}
|
|
68201
|
+
}
|
|
68202
|
+
for (const [name3, key2] of [
|
|
68203
|
+
["OnPage", "printFitToPages"],
|
|
68204
|
+
["CenterX", "printCenterX"],
|
|
68205
|
+
["CenterY", "printCenterY"]
|
|
68206
|
+
]) {
|
|
68207
|
+
const value3 = values2.get(name3);
|
|
68208
|
+
if (value3 !== void 0) setup[key2] = value3 === 1;
|
|
68209
|
+
}
|
|
68210
|
+
if (refusal) setup.printCountRefusal = refusal;
|
|
68211
|
+
return setup;
|
|
68212
|
+
}
|
|
68213
|
+
|
|
68214
|
+
// visio/theme.ts
|
|
68215
|
+
var VISIO_SCHEME_SLOTS = [
|
|
68216
|
+
"dk1",
|
|
68217
|
+
"lt1",
|
|
68218
|
+
"accent1",
|
|
68219
|
+
"accent2",
|
|
68220
|
+
"accent3",
|
|
68221
|
+
"accent4",
|
|
68222
|
+
"accent5",
|
|
68223
|
+
"accent6"
|
|
68224
|
+
];
|
|
68225
|
+
var componentId = (node4) => integer5(themeChild(node4, "schemeID", THEME_NS)?.getAttribute("schemeEnum"));
|
|
68226
|
+
async function loadVisioThemes(pkg, source2, report) {
|
|
68227
|
+
const result2 = [];
|
|
68228
|
+
for (const rel of (await pkg.relationships(source2)).values()) {
|
|
68229
|
+
if (rel.type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" || rel.mode === "External")
|
|
68230
|
+
continue;
|
|
68231
|
+
const root = await pkg.readXml(rel.target, "theme");
|
|
68232
|
+
if (root.namespaceURI !== DRAWING_NS) {
|
|
68233
|
+
report("unsupported-theme", "A theme uses an unsupported XML namespace.", {
|
|
68234
|
+
part: rel.target
|
|
68235
|
+
});
|
|
68236
|
+
continue;
|
|
68237
|
+
}
|
|
68238
|
+
const base3 = themeChild(root, "themeElements");
|
|
68239
|
+
const palette = themeChild(base3, "clrScheme");
|
|
68240
|
+
const scheme = parseTheme(root).colorScheme.colors;
|
|
68241
|
+
const colors = /* @__PURE__ */ new Map();
|
|
68242
|
+
for (const name4 of VISIO_SCHEME_SLOTS) {
|
|
68243
|
+
const color3 = scheme[name4];
|
|
68244
|
+
if (color3 && parsedColorChoice(themeChild(palette, name4))) colors.set(name4, color3);
|
|
68245
|
+
}
|
|
68246
|
+
const background2 = parsedColorChoice(extension(palette, "bkgnd"));
|
|
68247
|
+
if (background2) colors.set("bkgnd", background2);
|
|
68248
|
+
const variants = themeChildren(
|
|
68249
|
+
extension(palette, "variationClrSchemeLst"),
|
|
68250
|
+
"variationClrScheme",
|
|
68251
|
+
THEME_NS
|
|
68252
|
+
).slice(0, 4).map((variant) => {
|
|
68253
|
+
const entries = /* @__PURE__ */ new Map();
|
|
68254
|
+
for (let index4 = 1; index4 <= 7; index4++) {
|
|
68255
|
+
const choice2 = parsedColorChoice(themeChild(variant, `varColor${index4}`, THEME_NS));
|
|
68256
|
+
if (choice2) entries.set(String(index4), choice2);
|
|
68257
|
+
}
|
|
68258
|
+
return entries;
|
|
68259
|
+
});
|
|
68260
|
+
const format8 = themeChild(base3, "fmtScheme");
|
|
68261
|
+
const connector2 = extension(base3, "fmtConnectorScheme");
|
|
68262
|
+
const fonts = extension(base3, "fontStylesGroup");
|
|
68263
|
+
const name3 = root.getAttribute("name");
|
|
68264
|
+
result2.push({
|
|
68265
|
+
...name3 ? { name: name3.slice(0, 256) } : {},
|
|
68266
|
+
colorId: integer5(extension(palette, "schemeID")?.getAttribute("schemeEnum")),
|
|
68267
|
+
effectId: componentId(extension(base3, "fmtSchemeEx")),
|
|
68268
|
+
connectorId: componentId(extension(base3, "fmtConnectorSchemeEx")),
|
|
68269
|
+
colors,
|
|
68270
|
+
variants,
|
|
68271
|
+
variationStyles: themeChildren(
|
|
68272
|
+
extension(base3, "variationStyleSchemeLst"),
|
|
68273
|
+
"variationStyleScheme",
|
|
68274
|
+
THEME_NS
|
|
68275
|
+
).slice(0, 4).map((variant) => themeChildren(variant, "varStyle", THEME_NS).slice(0, 4)),
|
|
68276
|
+
fills: formatList(format8, "fillStyleLst"),
|
|
68277
|
+
effects: themeChildren(themeChild(format8, "effectStyleLst"), "effectStyle").slice(0, 6),
|
|
68278
|
+
lines: themeChildren(themeChild(format8, "lnStyleLst"), "ln").slice(0, 6),
|
|
68279
|
+
fonts: themeChildren(themeChild(fonts, "fontStyles", THEME_NS), "fontProps", THEME_NS).slice(
|
|
68280
|
+
0,
|
|
68281
|
+
6
|
|
68282
|
+
),
|
|
68283
|
+
connectorFills: formatList(connector2, "fillStyleLst"),
|
|
68284
|
+
connectorEffects: themeChildren(themeChild(connector2, "effectStyleLst"), "effectStyle").slice(
|
|
68285
|
+
0,
|
|
68286
|
+
6
|
|
68287
|
+
),
|
|
68288
|
+
connectorLines: themeChildren(themeChild(connector2, "lnStyleLst"), "ln").slice(0, 6),
|
|
68289
|
+
connectorFonts: themeChildren(
|
|
68290
|
+
themeChild(fonts, "connectorFontStyles", THEME_NS),
|
|
68291
|
+
"fontProps",
|
|
68292
|
+
THEME_NS
|
|
68293
|
+
).slice(0, 6)
|
|
68294
|
+
});
|
|
68295
|
+
}
|
|
68296
|
+
return result2;
|
|
68297
|
+
}
|
|
68298
|
+
function formatList(parent, name3) {
|
|
68299
|
+
const list2 = themeChild(parent, name3);
|
|
68300
|
+
return list2 ? Array.from(list2.childNodes).filter(
|
|
68301
|
+
(node4) => node4.nodeType === 1 && node4.namespaceURI === DRAWING_NS
|
|
68302
|
+
).slice(0, 6) : [];
|
|
68303
|
+
}
|
|
68304
|
+
|
|
68305
|
+
// visio/document-level.ts
|
|
68306
|
+
function optionsKey(options2) {
|
|
68307
|
+
const { metafileConverter: _converter, pages: _pages, documentCache: _cache, ...rest } = options2;
|
|
68308
|
+
return JSON.stringify(rest);
|
|
68309
|
+
}
|
|
68310
|
+
var cacheMatches = (entry3, pkg, options2) => entry3 !== void 0 && entry3.options === optionsKey(options2) && entry3.converter === options2.metafileConverter && entry3.reads.every(([path3, print]) => pkg.printOf(path3) === print);
|
|
68311
|
+
async function readDocumentLevel(pkg, documentPart, options2, checkTime, forward) {
|
|
68312
|
+
const reports = [];
|
|
68313
|
+
const report = (...args) => {
|
|
68314
|
+
reports.push(args);
|
|
68315
|
+
forward(...args);
|
|
68316
|
+
};
|
|
68317
|
+
const documentRoot = await visioXml(pkg, documentPart, "VisioDocument");
|
|
68318
|
+
const resources = {
|
|
68319
|
+
colors: /* @__PURE__ */ new Map(),
|
|
68320
|
+
fonts: /* @__PURE__ */ new Map(),
|
|
68321
|
+
themes: await loadVisioThemes(pkg, documentPart, report)
|
|
68322
|
+
};
|
|
68323
|
+
for (const color3 of children3(child6(documentRoot, "Colors"), "ColorEntry"))
|
|
68324
|
+
resources.colors.set(attribute3(color3, "IX") ?? "", attribute3(color3, "RGB") ?? "");
|
|
68325
|
+
const faceNames = children3(child6(documentRoot, "FaceNames"), "FaceName");
|
|
68326
|
+
if (faceNames.length > 1e4)
|
|
68327
|
+
throw new VisioPackageError(
|
|
68328
|
+
"METADATA_LIMIT",
|
|
68329
|
+
"Document font count exceeds its metadata limit."
|
|
68330
|
+
);
|
|
68331
|
+
let fontCharacters = 0;
|
|
68332
|
+
faceNames.forEach((font, index4) => {
|
|
68333
|
+
checkTime();
|
|
68334
|
+
fontCharacters += (attribute3(font, "Name") ?? attribute3(font, "NameU") ?? "Arial").length;
|
|
68335
|
+
if (fontCharacters > 1e6)
|
|
68336
|
+
throw new VisioPackageError(
|
|
68337
|
+
"METADATA_LIMIT",
|
|
68338
|
+
"Document fonts exceed aggregate metadata limits."
|
|
68339
|
+
);
|
|
68340
|
+
resources.fonts.set(
|
|
68341
|
+
metadata(attribute3(font, "ID") ?? String(index4), 256, "Font ID"),
|
|
68342
|
+
metadata(attribute3(font, "Name") ?? attribute3(font, "NameU") ?? "Arial", 1024, "Font name")
|
|
68343
|
+
);
|
|
68344
|
+
});
|
|
68345
|
+
const styles = /* @__PURE__ */ new Map();
|
|
68346
|
+
for (const style3 of children3(child6(documentRoot, "StyleSheets"), "StyleSheet"))
|
|
68347
|
+
styles.set(metadata(attribute3(style3, "ID") ?? "", 256, "Style ID"), {
|
|
68348
|
+
sheet: readSheet(style3),
|
|
68349
|
+
attributes: metadataAttributes(style3)
|
|
68350
|
+
});
|
|
68351
|
+
const rootStyle = styles.get("0");
|
|
68352
|
+
if (rootStyle?.attributes.get("NameU") === "No Style") resources.rootSheet = rootStyle.sheet;
|
|
68353
|
+
const printStyleGroups = children3(documentRoot, "StyleSheets");
|
|
68354
|
+
const readPrintSettings = createVisioPrintSettingsReader(
|
|
68355
|
+
children3(documentRoot, "DocumentSheet"),
|
|
68356
|
+
printStyleGroups.length === 1 ? children3(printStyleGroups[0], "StyleSheet").filter((node4) => attribute3(node4, "ID") === "0") : []
|
|
68357
|
+
);
|
|
68358
|
+
const masters = /* @__PURE__ */ new Map();
|
|
68359
|
+
const masterRecords = [];
|
|
68360
|
+
const mastersPart = await related(pkg, documentPart, "masters", false);
|
|
68361
|
+
if (mastersPart) {
|
|
68362
|
+
for (const master2 of children3(await visioXml(pkg, mastersPart, "Masters"), "Master")) {
|
|
68363
|
+
const part = await indexedPart(pkg, mastersPart, master2, "master");
|
|
68364
|
+
const id4 = metadata(attribute3(master2, "ID") ?? "", 256, "Master ID");
|
|
68365
|
+
if (!id4 || masters.has(id4))
|
|
68366
|
+
throw new VisioPackageError("INVALID_MASTER_ID", "Master IDs must be present and unique.");
|
|
68367
|
+
const masterShapes2 = readShapes(await visioXml(pkg, part, "MasterContents"));
|
|
68368
|
+
await prepareImages(
|
|
68369
|
+
masterShapes2,
|
|
68370
|
+
pkg,
|
|
68371
|
+
part,
|
|
68372
|
+
report,
|
|
68373
|
+
options2.images,
|
|
68374
|
+
options2.metafileConverter
|
|
68375
|
+
);
|
|
68376
|
+
masters.set(id4, masterShapes2);
|
|
68377
|
+
masterRecords.push({ id: id4, node: master2, shapes: masterShapes2 });
|
|
68378
|
+
}
|
|
68379
|
+
}
|
|
68380
|
+
return { documentRoot, resources, styles, readPrintSettings, masters, masterRecords, reports };
|
|
68381
|
+
}
|
|
68382
|
+
|
|
68102
68383
|
// visio/comments.ts
|
|
68103
68384
|
var VISIO_COMMENTS_CONTENT_TYPE = "application/vnd.ms-visio.comments+xml";
|
|
68104
68385
|
var VISIO_COMMENTS_RELATIONSHIP = "http://schemas.microsoft.com/visio/2010/relationships/comments";
|
|
@@ -68199,6 +68480,10 @@ function createMetadataBudget(options2 = {}) {
|
|
|
68199
68480
|
if (characters > maxCharacters)
|
|
68200
68481
|
throw new VisioPackageError("METADATA_LIMIT", "Shape metadata character budget exceeded.");
|
|
68201
68482
|
return value3;
|
|
68483
|
+
},
|
|
68484
|
+
state: () => [rows, characters],
|
|
68485
|
+
restore(state) {
|
|
68486
|
+
[rows, characters] = state;
|
|
68202
68487
|
}
|
|
68203
68488
|
};
|
|
68204
68489
|
}
|
|
@@ -69319,177 +69604,6 @@ function readVisioPageSetup(cells3) {
|
|
|
69319
69604
|
return Object.keys(result2).length ? result2 : void 0;
|
|
69320
69605
|
}
|
|
69321
69606
|
|
|
69322
|
-
// visio/print-settings.ts
|
|
69323
|
-
var NAMES = [
|
|
69324
|
-
"PaperKind",
|
|
69325
|
-
"PrintPageOrientation",
|
|
69326
|
-
"PageLeftMargin",
|
|
69327
|
-
"PageRightMargin",
|
|
69328
|
-
"PageTopMargin",
|
|
69329
|
-
"PageBottomMargin",
|
|
69330
|
-
"ScaleX",
|
|
69331
|
-
"ScaleY",
|
|
69332
|
-
"OnPage",
|
|
69333
|
-
"PagesX",
|
|
69334
|
-
"PagesY",
|
|
69335
|
-
"CenterX",
|
|
69336
|
-
"CenterY"
|
|
69337
|
-
];
|
|
69338
|
-
var BOOLEAN = /* @__PURE__ */ new Set(["OnPage", "CenterX", "CenterY"]);
|
|
69339
|
-
var LENGTH = /* @__PURE__ */ new Set(["PageLeftMargin", "PageRightMargin", "PageTopMargin", "PageBottomMargin"]);
|
|
69340
|
-
var CANONICAL = new Map(
|
|
69341
|
-
[...NAMES, "PageWidth", "PageHeight", "PageScale", "DrawingScale"].map((name3) => [
|
|
69342
|
-
name3.toLowerCase(),
|
|
69343
|
-
name3
|
|
69344
|
-
])
|
|
69345
|
-
);
|
|
69346
|
-
function indexCells(sheet2) {
|
|
69347
|
-
const cells3 = /* @__PURE__ */ new Map();
|
|
69348
|
-
let duplicate = false;
|
|
69349
|
-
for (const node4 of children3(sheet2, "Cell")) {
|
|
69350
|
-
const name3 = attribute3(node4, "N") ?? "", canonical3 = CANONICAL.get(name3.toLowerCase());
|
|
69351
|
-
if (!canonical3) continue;
|
|
69352
|
-
if (canonical3 !== name3) duplicate = true;
|
|
69353
|
-
const values2 = cells3.get(canonical3) ?? [];
|
|
69354
|
-
if (values2.length < 2) values2.push(node4);
|
|
69355
|
-
cells3.set(canonical3, values2);
|
|
69356
|
-
if (values2.length > 1) duplicate = true;
|
|
69357
|
-
}
|
|
69358
|
-
return { cells: cells3, duplicate };
|
|
69359
|
-
}
|
|
69360
|
-
function createVisioPrintSettingsReader(documentSheets, rootStyles) {
|
|
69361
|
-
const indexes2 = { document: indexCells(documentSheets[0]), root: indexCells(rootStyles[0]) };
|
|
69362
|
-
return (pageSheets) => readVisioPrintCountSettings(pageSheets, documentSheets, rootStyles, indexes2);
|
|
69363
|
-
}
|
|
69364
|
-
function readVisioPrintCountSettings(pageSheets, documentSheets, rootStyles, indexes2) {
|
|
69365
|
-
let refusal;
|
|
69366
|
-
const refuse4 = (reason) => {
|
|
69367
|
-
refusal ??= reason;
|
|
69368
|
-
};
|
|
69369
|
-
if (pageSheets.length !== 1) refuse4("ambiguous-page-sheet");
|
|
69370
|
-
if (documentSheets.length > 1) refuse4("ambiguous-document-sheet");
|
|
69371
|
-
if (!documentSheets.length) refuse4("missing-setting");
|
|
69372
|
-
if (rootStyles.length > 1) refuse4("duplicate-setting");
|
|
69373
|
-
const root = rootStyles[0];
|
|
69374
|
-
if (!root || attribute3(root, "ID") !== "0" || attribute3(root, "NameU") !== "No Style")
|
|
69375
|
-
refuse4("unsupported-print-style");
|
|
69376
|
-
for (const sheet2 of [...pageSheets, ...documentSheets])
|
|
69377
|
-
for (const name3 of ["LineStyle", "FillStyle", "TextStyle"])
|
|
69378
|
-
if (attribute3(sheet2, name3) !== "0") refuse4("unsupported-print-style");
|
|
69379
|
-
for (const name3 of ["LineStyle", "FillStyle", "TextStyle"])
|
|
69380
|
-
if (attribute3(root, name3) !== void 0) refuse4("unsupported-print-style");
|
|
69381
|
-
const localIndex = indexCells(pageSheets[0]), rootIndex = indexes2?.root ?? indexCells(root);
|
|
69382
|
-
const documentIndex = indexes2?.document ?? indexCells(documentSheets[0]);
|
|
69383
|
-
if (localIndex.duplicate || rootIndex.duplicate || documentIndex.duplicate)
|
|
69384
|
-
refuse4("duplicate-setting");
|
|
69385
|
-
const local = localIndex.cells, inherited = rootIndex.cells;
|
|
69386
|
-
const read = (node4, name3, origin) => {
|
|
69387
|
-
const invalid3 = () => {
|
|
69388
|
-
refuse4(origin === "local" ? "invalid-local-setting" : "invalid-document-setting");
|
|
69389
|
-
return void 0;
|
|
69390
|
-
};
|
|
69391
|
-
if (node4.hasAttribute("E")) return invalid3();
|
|
69392
|
-
let raw2 = (attribute3(node4, "V") ?? "").trim();
|
|
69393
|
-
if (!raw2 || raw2.length > 128) return invalid3();
|
|
69394
|
-
if (BOOLEAN.has(name3)) {
|
|
69395
|
-
if (!["0", "1", "false", "true"].includes(raw2)) return invalid3();
|
|
69396
|
-
raw2 = raw2 === "true" ? "1" : raw2 === "false" ? "0" : raw2;
|
|
69397
|
-
}
|
|
69398
|
-
try {
|
|
69399
|
-
const value3 = visioFormulaCachedValue(raw2, attribute3(node4, "U"));
|
|
69400
|
-
const length = LENGTH.has(name3) || /^(PageWidth|PageHeight|PageScale|DrawingScale)$/.test(name3);
|
|
69401
|
-
if (!["scalar", ...length ? ["length"] : []].includes(value3.unit) || Math.abs(value3.value) > 1e9)
|
|
69402
|
-
return invalid3();
|
|
69403
|
-
const formula = attribute3(node4, "F");
|
|
69404
|
-
if (formula !== void 0) {
|
|
69405
|
-
const source2 = formula.trim();
|
|
69406
|
-
if (/^(true|false)$/i.test(source2)) {
|
|
69407
|
-
if ((source2.toLowerCase() === "true" ? 1 : 0) !== value3.value) return invalid3();
|
|
69408
|
-
} else {
|
|
69409
|
-
if (!source2 || source2 === "Inh") return invalid3();
|
|
69410
|
-
const limits = { maxLength: 512, maxNodes: 64, maxDepth: 16, maxSteps: 128 };
|
|
69411
|
-
const analysis = analyzeVisioFormula(source2, limits);
|
|
69412
|
-
if (analysis.dynamic || analysis.guarded || analysis.references.length || analysis.unsupportedFunctions.length) {
|
|
69413
|
-
refuse4("dynamic-setting");
|
|
69414
|
-
return void 0;
|
|
69415
|
-
}
|
|
69416
|
-
const evaluated = evaluateVisioFormula(
|
|
69417
|
-
source2,
|
|
69418
|
-
() => {
|
|
69419
|
-
throw new Error("Unexpected reference");
|
|
69420
|
-
},
|
|
69421
|
-
limits
|
|
69422
|
-
);
|
|
69423
|
-
if (evaluated.value !== value3.value || !["scalar", ...length ? ["length"] : []].includes(evaluated.unit))
|
|
69424
|
-
return invalid3();
|
|
69425
|
-
}
|
|
69426
|
-
}
|
|
69427
|
-
return value3.value;
|
|
69428
|
-
} catch {
|
|
69429
|
-
return invalid3();
|
|
69430
|
-
}
|
|
69431
|
-
};
|
|
69432
|
-
const values2 = /* @__PURE__ */ new Map();
|
|
69433
|
-
for (const name3 of NAMES) {
|
|
69434
|
-
const nodes = local.get(name3) ?? inherited.get(name3);
|
|
69435
|
-
if (!nodes?.length) continue;
|
|
69436
|
-
if (nodes.length !== 1) continue;
|
|
69437
|
-
const value3 = read(nodes[0], name3, local.has(name3) ? "local" : "document");
|
|
69438
|
-
if (value3 !== void 0) values2.set(name3, value3);
|
|
69439
|
-
}
|
|
69440
|
-
for (const name3 of ["PageWidth", "PageHeight", "PageScale", "DrawingScale"]) {
|
|
69441
|
-
const nodes = local.get(name3);
|
|
69442
|
-
if (!nodes || nodes.length !== 1 || !(read(nodes[0], name3, "local") > 0))
|
|
69443
|
-
refuse4("unusable-drawing-scale");
|
|
69444
|
-
}
|
|
69445
|
-
const setup = {};
|
|
69446
|
-
const paper = values2.get("PaperKind");
|
|
69447
|
-
if (paper !== void 0 && Number.isSafeInteger(paper) && paper >= 0 && paper <= 65535)
|
|
69448
|
-
setup.paperKind = paper;
|
|
69449
|
-
else if (paper !== void 0)
|
|
69450
|
-
refuse4(local.has("PaperKind") ? "invalid-local-setting" : "invalid-document-setting");
|
|
69451
|
-
const orientation = values2.get("PrintPageOrientation");
|
|
69452
|
-
if (orientation === 0 || orientation === 1 || orientation === 2)
|
|
69453
|
-
setup.printPageOrientation = orientation;
|
|
69454
|
-
else if (orientation !== void 0)
|
|
69455
|
-
refuse4(
|
|
69456
|
-
local.has("PrintPageOrientation") ? "invalid-local-setting" : "invalid-document-setting"
|
|
69457
|
-
);
|
|
69458
|
-
const margins = ["Left", "Right", "Top", "Bottom"].map((side2) => values2.get(`Page${side2}Margin`));
|
|
69459
|
-
if (margins.every((n) => n !== void 0 && n >= 0 && n <= 1e3))
|
|
69460
|
-
setup.margins = {
|
|
69461
|
-
left: margins[0],
|
|
69462
|
-
right: margins[1],
|
|
69463
|
-
top: margins[2],
|
|
69464
|
-
bottom: margins[3]
|
|
69465
|
-
};
|
|
69466
|
-
else if (margins.some((n) => n !== void 0 && (n < 0 || n > 1e3)))
|
|
69467
|
-
refuse4("unusable-print-area");
|
|
69468
|
-
for (const [name3, key2] of [
|
|
69469
|
-
["ScaleX", "printZoom"],
|
|
69470
|
-
["ScaleY", "printZoomY"],
|
|
69471
|
-
["PagesX", "printPagesAcross"],
|
|
69472
|
-
["PagesY", "printPagesDown"]
|
|
69473
|
-
]) {
|
|
69474
|
-
const value3 = values2.get(name3);
|
|
69475
|
-
if (value3 !== void 0) {
|
|
69476
|
-
if ((name3 === "PagesX" || name3 === "PagesY") && (!Number.isSafeInteger(value3) || value3 < 1))
|
|
69477
|
-
refuse4(local.has(name3) ? "invalid-local-setting" : "invalid-document-setting");
|
|
69478
|
-
else setup[key2] = value3;
|
|
69479
|
-
}
|
|
69480
|
-
}
|
|
69481
|
-
for (const [name3, key2] of [
|
|
69482
|
-
["OnPage", "printFitToPages"],
|
|
69483
|
-
["CenterX", "printCenterX"],
|
|
69484
|
-
["CenterY", "printCenterY"]
|
|
69485
|
-
]) {
|
|
69486
|
-
const value3 = values2.get(name3);
|
|
69487
|
-
if (value3 !== void 0) setup[key2] = value3 === 1;
|
|
69488
|
-
}
|
|
69489
|
-
if (refusal) setup.printCountRefusal = refusal;
|
|
69490
|
-
return setup;
|
|
69491
|
-
}
|
|
69492
|
-
|
|
69493
69607
|
// visio/page-layout.ts
|
|
69494
69608
|
var VISIO_GRID_DENSITIES = Object.freeze([0, 2, 4, 8]);
|
|
69495
69609
|
var VISIO_RULER_DENSITIES = Object.freeze([8, 16, 32]);
|
|
@@ -69792,69 +69906,18 @@ async function parseVsdx(input2, options2 = {}) {
|
|
|
69792
69906
|
);
|
|
69793
69907
|
}
|
|
69794
69908
|
}
|
|
69795
|
-
const
|
|
69796
|
-
const
|
|
69797
|
-
|
|
69798
|
-
|
|
69799
|
-
|
|
69800
|
-
|
|
69801
|
-
|
|
69802
|
-
|
|
69803
|
-
const
|
|
69804
|
-
|
|
69805
|
-
|
|
69806
|
-
|
|
69807
|
-
"Document font count exceeds its metadata limit."
|
|
69808
|
-
);
|
|
69809
|
-
let fontCharacters = 0;
|
|
69810
|
-
faceNames.forEach((font, index4) => {
|
|
69811
|
-
checkTime();
|
|
69812
|
-
fontCharacters += (attribute3(font, "Name") ?? attribute3(font, "NameU") ?? "Arial").length;
|
|
69813
|
-
if (fontCharacters > 1e6)
|
|
69814
|
-
throw new VisioPackageError(
|
|
69815
|
-
"METADATA_LIMIT",
|
|
69816
|
-
"Document fonts exceed aggregate metadata limits."
|
|
69817
|
-
);
|
|
69818
|
-
resources.fonts.set(
|
|
69819
|
-
metadata(attribute3(font, "ID") ?? String(index4), 256, "Font ID"),
|
|
69820
|
-
metadata(attribute3(font, "Name") ?? attribute3(font, "NameU") ?? "Arial", 1024, "Font name")
|
|
69821
|
-
);
|
|
69822
|
-
});
|
|
69823
|
-
const styles = /* @__PURE__ */ new Map();
|
|
69824
|
-
for (const style3 of children3(child6(documentRoot, "StyleSheets"), "StyleSheet"))
|
|
69825
|
-
styles.set(metadata(attribute3(style3, "ID") ?? "", 256, "Style ID"), {
|
|
69826
|
-
sheet: readSheet(style3),
|
|
69827
|
-
attributes: metadataAttributes(style3)
|
|
69828
|
-
});
|
|
69829
|
-
const rootStyle = styles.get("0");
|
|
69830
|
-
if (rootStyle?.attributes.get("NameU") === "No Style") resources.rootSheet = rootStyle.sheet;
|
|
69831
|
-
const printStyleGroups = children3(documentRoot, "StyleSheets");
|
|
69832
|
-
const readPrintSettings = createVisioPrintSettingsReader(
|
|
69833
|
-
children3(documentRoot, "DocumentSheet"),
|
|
69834
|
-
printStyleGroups.length === 1 ? children3(printStyleGroups[0], "StyleSheet").filter((node4) => attribute3(node4, "ID") === "0") : []
|
|
69835
|
-
);
|
|
69836
|
-
const masters = /* @__PURE__ */ new Map();
|
|
69837
|
-
const masterRecords = [];
|
|
69838
|
-
const mastersPart = await related(pkg, documentPart, "masters", false);
|
|
69839
|
-
if (mastersPart) {
|
|
69840
|
-
for (const master2 of children3(await visioXml(pkg, mastersPart, "Masters"), "Master")) {
|
|
69841
|
-
const part = await indexedPart(pkg, mastersPart, master2, "master");
|
|
69842
|
-
const id4 = metadata(attribute3(master2, "ID") ?? "", 256, "Master ID");
|
|
69843
|
-
if (!id4 || masters.has(id4))
|
|
69844
|
-
throw new VisioPackageError("INVALID_MASTER_ID", "Master IDs must be present and unique.");
|
|
69845
|
-
const masterShapes2 = readShapes(await visioXml(pkg, part, "MasterContents"));
|
|
69846
|
-
await prepareImages(
|
|
69847
|
-
masterShapes2,
|
|
69848
|
-
pkg,
|
|
69849
|
-
part,
|
|
69850
|
-
report,
|
|
69851
|
-
options2.images,
|
|
69852
|
-
options2.metafileConverter
|
|
69853
|
-
);
|
|
69854
|
-
masters.set(id4, masterShapes2);
|
|
69855
|
-
masterRecords.push({ id: id4, node: master2, shapes: masterShapes2 });
|
|
69856
|
-
}
|
|
69857
|
-
}
|
|
69909
|
+
const cache3 = options2.documentCache;
|
|
69910
|
+
const cached7 = cacheMatches(cache3?.entry, pkg, options2) ? cache3.entry : void 0;
|
|
69911
|
+
const stopRecording = cache3 && !cached7 ? pkg.record() : void 0;
|
|
69912
|
+
let level2;
|
|
69913
|
+
if (cached7) {
|
|
69914
|
+
level2 = cached7.level;
|
|
69915
|
+
for (const args of level2.reports) report(...args);
|
|
69916
|
+
} else level2 = await readDocumentLevel(pkg, documentPart, options2, checkTime, report);
|
|
69917
|
+
const { documentRoot, styles, readPrintSettings, masters, masterRecords } = level2;
|
|
69918
|
+
const resources = { ...level2.resources };
|
|
69919
|
+
delete resources.pageCells;
|
|
69920
|
+
delete resources.fieldContext;
|
|
69858
69921
|
let geometryCount = 0, textCount = 0, expansionCount = 0, textRuns = 0, paragraphCount = 0;
|
|
69859
69922
|
const context = {
|
|
69860
69923
|
metadataBudget: createMetadataBudget(options2.metadata),
|
|
@@ -69908,10 +69971,46 @@ async function parseVsdx(input2, options2 = {}) {
|
|
|
69908
69971
|
throw new VisioPackageError("TEXT_LIMIT", "Text character limit exceeded.");
|
|
69909
69972
|
}
|
|
69910
69973
|
};
|
|
69911
|
-
|
|
69912
|
-
|
|
69913
|
-
|
|
69914
|
-
|
|
69974
|
+
let documentMasters;
|
|
69975
|
+
if (cached7) {
|
|
69976
|
+
const { counters } = cached7.listed;
|
|
69977
|
+
curveWork = counters.curveWork;
|
|
69978
|
+
geometryCount = counters.geometry;
|
|
69979
|
+
textCount = counters.text;
|
|
69980
|
+
expansionCount = counters.expansion;
|
|
69981
|
+
textRuns = counters.textRuns;
|
|
69982
|
+
paragraphCount = counters.paragraphs;
|
|
69983
|
+
context.shapeCount = counters.shapes;
|
|
69984
|
+
context.metadataBudget.restore(counters.metadata);
|
|
69985
|
+
context.layerBudget.restore(counters.layers);
|
|
69986
|
+
documentMasters = cached7.listed.documentMasters;
|
|
69987
|
+
} else {
|
|
69988
|
+
documentMasters = listVisioMasters(masterRecords, context, {
|
|
69989
|
+
metadataBudget: createMetadataBudget(options2.metadata),
|
|
69990
|
+
layerBudget: createLayerBudget()
|
|
69991
|
+
});
|
|
69992
|
+
if (cache3 && stopRecording)
|
|
69993
|
+
cache3.entry = {
|
|
69994
|
+
options: optionsKey(options2),
|
|
69995
|
+
converter: options2.metafileConverter,
|
|
69996
|
+
reads: stopRecording(),
|
|
69997
|
+
level: { ...level2, resources: { ...resources } },
|
|
69998
|
+
listed: {
|
|
69999
|
+
documentMasters,
|
|
70000
|
+
counters: {
|
|
70001
|
+
curveWork,
|
|
70002
|
+
geometry: geometryCount,
|
|
70003
|
+
text: textCount,
|
|
70004
|
+
expansion: expansionCount,
|
|
70005
|
+
textRuns,
|
|
70006
|
+
paragraphs: paragraphCount,
|
|
70007
|
+
shapes: context.shapeCount,
|
|
70008
|
+
metadata: context.metadataBudget.state(),
|
|
70009
|
+
layers: context.layerBudget.state()
|
|
70010
|
+
}
|
|
70011
|
+
}
|
|
70012
|
+
};
|
|
70013
|
+
}
|
|
69915
70014
|
const pagesPart = await related(pkg, documentPart, "pages", !options2.stencil);
|
|
69916
70015
|
if (!pagesPart && !options2.stencil)
|
|
69917
70016
|
throw new VisioPackageError("INVALID_DOCUMENT", "Missing Visio pages part.");
|
|
@@ -107515,6 +107614,123 @@ function findAutomationTool(name3) {
|
|
|
107515
107614
|
return void 0;
|
|
107516
107615
|
}
|
|
107517
107616
|
|
|
107617
|
+
// automation/live.ts
|
|
107618
|
+
var digest = (bytes) => Array.from(sha256(bytes), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
107619
|
+
function createLiveToolHost(tools, options2 = {}) {
|
|
107620
|
+
const editors = /* @__PURE__ */ new Map();
|
|
107621
|
+
const serve = tools.filter((tool) => tool.kind !== "create");
|
|
107622
|
+
const queues = /* @__PURE__ */ new Map();
|
|
107623
|
+
function editorFor(target3) {
|
|
107624
|
+
if (typeof target3 !== "string" || target3 === "")
|
|
107625
|
+
throw new Error("Every call needs a target: the id of the document to act on.");
|
|
107626
|
+
const editor = editors.get(target3);
|
|
107627
|
+
if (!editor) throw new Error(`No open document is registered as "${target3}".`);
|
|
107628
|
+
return editor;
|
|
107629
|
+
}
|
|
107630
|
+
async function run2(name3, call) {
|
|
107631
|
+
const tool = serve.find((candidate) => candidate.name === name3);
|
|
107632
|
+
if (!tool) throw new Error(`Unknown tool "${name3}".`);
|
|
107633
|
+
const editor = editorFor(call?.target);
|
|
107634
|
+
const target3 = call.target;
|
|
107635
|
+
if (tool.format !== editor.format)
|
|
107636
|
+
throw new Error(
|
|
107637
|
+
`${name3} works on ${tool.format} documents, but "${target3}" is a ${editor.format} document.`
|
|
107638
|
+
);
|
|
107639
|
+
const before = new Uint8Array(await editor.save());
|
|
107640
|
+
if (tool.kind === "read")
|
|
107641
|
+
return { target: target3, tool: name3, result: await tool.run(before, call.params), changed: false };
|
|
107642
|
+
if (editor.readOnly) throw new Error(`"${target3}" is read-only, so it cannot be edited.`);
|
|
107643
|
+
const { bytes: after, ...result2 } = await tool.run(before, call.params);
|
|
107644
|
+
if (!after) return { target: target3, tool: name3, result: result2, changed: false };
|
|
107645
|
+
if (options2.review) {
|
|
107646
|
+
const accepted = await options2.review({
|
|
107647
|
+
target: target3,
|
|
107648
|
+
tool: name3,
|
|
107649
|
+
params: call.params,
|
|
107650
|
+
result: result2,
|
|
107651
|
+
before,
|
|
107652
|
+
after
|
|
107653
|
+
});
|
|
107654
|
+
if (!accepted)
|
|
107655
|
+
return { target: target3, tool: name3, result: { ...result2, discarded: true }, changed: false };
|
|
107656
|
+
}
|
|
107657
|
+
if (editor.readOnly)
|
|
107658
|
+
throw new Error(`"${target3}" became read-only, so the edit was not applied.`);
|
|
107659
|
+
if (digest(new Uint8Array(await editor.save())) !== digest(before))
|
|
107660
|
+
throw new Error(`"${target3}" changed while the edit was prepared; read it again and retry.`);
|
|
107661
|
+
await editor.load(after);
|
|
107662
|
+
return { target: target3, tool: name3, result: result2, changed: true };
|
|
107663
|
+
}
|
|
107664
|
+
return {
|
|
107665
|
+
register(id4, editor) {
|
|
107666
|
+
if (editors.has(id4)) throw new Error(`A document is already registered as "${id4}".`);
|
|
107667
|
+
editors.set(id4, editor);
|
|
107668
|
+
return () => {
|
|
107669
|
+
if (editors.get(id4) === editor) editors.delete(id4);
|
|
107670
|
+
};
|
|
107671
|
+
},
|
|
107672
|
+
targets: () => [...editors].map(([id4, editor]) => ({
|
|
107673
|
+
id: id4,
|
|
107674
|
+
format: editor.format,
|
|
107675
|
+
readOnly: Boolean(editor.readOnly)
|
|
107676
|
+
})),
|
|
107677
|
+
describe() {
|
|
107678
|
+
const open2 = new Set([...editors.values()].map((editor) => editor.format));
|
|
107679
|
+
return serve.filter((tool) => open2.has(tool.format)).map((tool) => {
|
|
107680
|
+
const schema = tool.jsonSchema();
|
|
107681
|
+
return {
|
|
107682
|
+
name: tool.name,
|
|
107683
|
+
description: tool.description,
|
|
107684
|
+
kind: tool.kind,
|
|
107685
|
+
format: tool.format,
|
|
107686
|
+
inputSchema: {
|
|
107687
|
+
type: "object",
|
|
107688
|
+
additionalProperties: false,
|
|
107689
|
+
properties: {
|
|
107690
|
+
target: {
|
|
107691
|
+
type: "string",
|
|
107692
|
+
description: "The id of the open document to act on."
|
|
107693
|
+
},
|
|
107694
|
+
params: schema
|
|
107695
|
+
},
|
|
107696
|
+
required: ["target"]
|
|
107697
|
+
}
|
|
107698
|
+
};
|
|
107699
|
+
});
|
|
107700
|
+
},
|
|
107701
|
+
call(name3, call) {
|
|
107702
|
+
const key2 = typeof call?.target === "string" ? call.target : "";
|
|
107703
|
+
const next = (queues.get(key2) ?? Promise.resolve()).then(
|
|
107704
|
+
() => run2(name3, call),
|
|
107705
|
+
() => run2(name3, call)
|
|
107706
|
+
);
|
|
107707
|
+
queues.set(
|
|
107708
|
+
key2,
|
|
107709
|
+
next.catch(() => void 0)
|
|
107710
|
+
);
|
|
107711
|
+
return next;
|
|
107712
|
+
}
|
|
107713
|
+
};
|
|
107714
|
+
}
|
|
107715
|
+
function liveEditorFromElement(format8, element3, name3) {
|
|
107716
|
+
return {
|
|
107717
|
+
format: format8,
|
|
107718
|
+
save: async () => {
|
|
107719
|
+
if (element3.commitEdit && !element3.commitEdit())
|
|
107720
|
+
throw new Error("Finish the current cell edit before using the document.");
|
|
107721
|
+
if (format8 === "visio" && element3.exportVsdx) return (await element3.exportVsdx()).bytes;
|
|
107722
|
+
if (!element3.saveBytes) throw new Error("The editor cannot save its document.");
|
|
107723
|
+
return element3.saveBytes();
|
|
107724
|
+
},
|
|
107725
|
+
load: async (bytes) => {
|
|
107726
|
+
await element3.load(bytes, name3);
|
|
107727
|
+
},
|
|
107728
|
+
get readOnly() {
|
|
107729
|
+
return element3.readOnly === true;
|
|
107730
|
+
}
|
|
107731
|
+
};
|
|
107732
|
+
}
|
|
107733
|
+
|
|
107518
107734
|
exports.UNTRUSTED_NOTE = UNTRUSTED_NOTE;
|
|
107519
107735
|
exports.XLSX_EDIT_LIMITS = XLSX_EDIT_LIMITS;
|
|
107520
107736
|
exports.applyXlsxEdits = applyXlsxEdits;
|
|
@@ -107524,6 +107740,7 @@ exports.checkEditProposal = checkEditProposal;
|
|
|
107524
107740
|
exports.createDocx = createDocx;
|
|
107525
107741
|
exports.createDocxFromOutline = createDocxFromOutline;
|
|
107526
107742
|
exports.createEditProposal = createEditProposal;
|
|
107743
|
+
exports.createLiveToolHost = createLiveToolHost;
|
|
107527
107744
|
exports.createXlsx = createXlsx;
|
|
107528
107745
|
exports.createXlsxFromSheets = createXlsxFromSheets;
|
|
107529
107746
|
exports.documentDigest = documentDigest;
|
|
@@ -107536,6 +107753,7 @@ exports.inspectDocx = inspectDocx;
|
|
|
107536
107753
|
exports.inspectVisio = inspectVisio;
|
|
107537
107754
|
exports.inspectXlsx = inspectXlsx;
|
|
107538
107755
|
exports.listDocxFormFields = listDocxFormFields;
|
|
107756
|
+
exports.liveEditorFromElement = liveEditorFromElement;
|
|
107539
107757
|
exports.proposeXlsxEdits = proposeXlsxEdits;
|
|
107540
107758
|
exports.readXlsxFilledCells = readXlsxFilledCells;
|
|
107541
107759
|
exports.readXlsxRange = readXlsxRange;
|