ooxml-core 1.18.0 → 1.19.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/{PptxHandler-X6AO6LKJ.mjs → PptxHandler-5GBBVJCR.mjs} +2 -2
- package/dist/{PptxHandler-5X4VOWAO.mjs → PptxHandler-H43MAMTO.mjs} +1 -1
- package/dist/{PptxHandler-4AHDZDA5.cjs → PptxHandler-ZHPGBSAF.cjs} +2 -2
- package/dist/{PresentationBuilder-UY3S4YE2.mjs → PresentationBuilder-7ZSUKCX5.mjs} +1 -1
- package/dist/{PresentationBuilder-LRX55PXA.mjs → PresentationBuilder-IJW42L3R.mjs} +2 -2
- package/dist/{PresentationBuilder-MJB4LIFS.cjs → PresentationBuilder-O4H4MMWB.cjs} +4 -4
- package/dist/automation/index.cjs +535 -266
- package/dist/automation/index.mjs +535 -266
- package/dist/chart/axis-range-auto.d.ts +10 -0
- package/dist/chart/axis-range-auto.d.ts.map +1 -0
- package/dist/chart/axis-range-types.d.ts +27 -0
- package/dist/chart/axis-range-types.d.ts.map +1 -0
- package/dist/chart/axis-range.d.ts +37 -0
- package/dist/chart/axis-range.d.ts.map +1 -0
- package/dist/chart/axis-ticks.d.ts +8 -0
- package/dist/chart/axis-ticks.d.ts.map +1 -0
- package/dist/chart/index.cjs +815 -165
- package/dist/chart/index.d.ts +6 -0
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.mjs +795 -166
- package/dist/chart/line-dash.d.ts +2 -0
- package/dist/chart/line-dash.d.ts.map +1 -0
- package/dist/chart/marker-shape.d.ts +70 -0
- package/dist/chart/marker-shape.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-axes.d.ts +9 -0
- package/dist/chart/render/chart-svg-axes.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-markers.d.ts +6 -0
- package/dist/chart/render/chart-svg-markers.d.ts.map +1 -0
- package/dist/chart/render/chart-svg-radial.d.ts.map +1 -1
- package/dist/chart/render/chart-svg-xy.d.ts.map +1 -1
- package/dist/chart/render/chart-view-axes.d.ts +30 -0
- package/dist/chart/render/chart-view-axes.d.ts.map +1 -0
- package/dist/chart/render/chart-view-markers.d.ts +27 -0
- package/dist/chart/render/chart-view-markers.d.ts.map +1 -0
- package/dist/chart/render/chart-view-series.d.ts.map +1 -1
- package/dist/chart/render/chart-view.d.ts +4 -1
- package/dist/chart/render/chart-view.d.ts.map +1 -1
- package/dist/chart/render/index.d.ts +2 -0
- package/dist/chart/render/index.d.ts.map +1 -1
- package/dist/chart/render/summary-from-space.d.ts.map +1 -1
- package/dist/chart/render/summary.d.ts +6 -1
- package/dist/chart/render/summary.d.ts.map +1 -1
- package/dist/{chunk-7NWQUCGX.mjs → chunk-3XFPCZKB.mjs} +1 -1
- package/dist/{chunk-Z5Y53IZD.mjs → chunk-75GLSRZE.mjs} +4 -4
- package/dist/{chunk-LT7RCEHY.mjs → chunk-BIVNVDAH.mjs} +1 -1
- package/dist/{chunk-I5ZE3VLI.mjs → chunk-QBJRB6WW.mjs} +1 -1
- package/dist/{chunk-U7IDT6VT.mjs → chunk-RUZEMWDI.mjs} +1 -1
- package/dist/docx/index.cjs +695 -168
- package/dist/docx/index.mjs +695 -168
- package/dist/docx/layout/index.cjs +697 -170
- package/dist/docx/layout/index.mjs +697 -170
- package/dist/docx/ui/index.cjs +704 -177
- package/dist/docx/ui/index.mjs +704 -177
- package/dist/index.cjs +912 -262
- package/dist/index.mjs +912 -262
- package/dist/pptx/automation/index.cjs +54 -0
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/cli/index.cjs +54 -0
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.mjs +2 -2
- 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 +54 -0
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +71 -5
- package/dist/teams/index.mjs +71 -5
- package/dist/visio/index.cjs +483 -214
- package/dist/visio/index.mjs +483 -214
- package/dist/visio/ui/index.cjs +504 -235
- package/dist/visio/ui/index.mjs +504 -235
- package/dist/xlsx/edit/chart-colors.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +818 -281
- package/dist/xlsx/index.mjs +818 -281
- package/dist/xlsx/load/index.cjs +58 -5
- package/dist/xlsx/load/index.mjs +58 -5
- package/dist/xlsx/read/chart.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +835 -298
- package/dist/xlsx/ui/index.mjs +835 -298
- package/package.json +1 -1
- /package/dist/{chunk-C363NN2C.mjs → chunk-H6TNNXJK.mjs} +0 -0
- /package/dist/{chunk-R4BCOQHB.cjs → chunk-MHMVD23Y.cjs} +0 -0
package/dist/visio/ui/index.mjs
CHANGED
|
@@ -1127,11 +1127,11 @@ function checkXmlLimits(xml, label2, limits = {}) {
|
|
|
1127
1127
|
throw new Error(`${label2} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
|
-
function parseXml(xml,
|
|
1131
|
-
const label2 =
|
|
1130
|
+
function parseXml(xml, options2 = {}) {
|
|
1131
|
+
const label2 = options2.label ?? "OOXML";
|
|
1132
1132
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
1133
1133
|
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
1134
|
-
checkXmlLimits(xml, label2,
|
|
1134
|
+
checkXmlLimits(xml, label2, options2.limits);
|
|
1135
1135
|
let parseError = "";
|
|
1136
1136
|
let parsed;
|
|
1137
1137
|
try {
|
|
@@ -1649,8 +1649,8 @@ var VisioPackage = class _VisioPackage {
|
|
|
1649
1649
|
if (Date.now() >= this.deadline)
|
|
1650
1650
|
fail("LIMIT_RUNTIME", "Visio package processing deadline exceeded");
|
|
1651
1651
|
};
|
|
1652
|
-
static async open(input,
|
|
1653
|
-
const limits = { ...DEFAULTS, ...
|
|
1652
|
+
static async open(input, options2 = {}) {
|
|
1653
|
+
const limits = { ...DEFAULTS, ...options2 };
|
|
1654
1654
|
for (const value3 of Object.values(limits))
|
|
1655
1655
|
if (!Number.isFinite(value3) || value3 <= 0)
|
|
1656
1656
|
fail("INVALID_LIMITS", "Package limits must be finite positive numbers");
|
|
@@ -2169,10 +2169,10 @@ function jpeg(bytes, limits) {
|
|
|
2169
2169
|
}
|
|
2170
2170
|
return invalid("JPEG has no image terminator.");
|
|
2171
2171
|
}
|
|
2172
|
-
function inspectVisioRasterImage(bytes,
|
|
2173
|
-
if (!
|
|
2172
|
+
function inspectVisioRasterImage(bytes, options2 = {}) {
|
|
2173
|
+
if (!options2 || typeof options2 !== "object" || Array.isArray(options2))
|
|
2174
2174
|
throw new VisioImageError("invalid-limit", "Image limits must be an options object.");
|
|
2175
|
-
const limits = { ...VISIO_RASTER_IMAGE_LIMITS, ...
|
|
2175
|
+
const limits = { ...VISIO_RASTER_IMAGE_LIMITS, ...options2 };
|
|
2176
2176
|
for (const key2 of Object.keys(VISIO_RASTER_IMAGE_LIMITS)) {
|
|
2177
2177
|
const value3 = limits[key2];
|
|
2178
2178
|
if (!Number.isSafeInteger(value3) || value3 <= 0 || value3 > VISIO_RASTER_IMAGE_LIMITS[key2])
|
|
@@ -2183,10 +2183,10 @@ function inspectVisioRasterImage(bytes, options = {}) {
|
|
|
2183
2183
|
throw new VisioImageError("image-limit", "Raster image bytes exceed the configured limit.");
|
|
2184
2184
|
return inspect(bytes, limits);
|
|
2185
2185
|
}
|
|
2186
|
-
async function readVisioImage(pkg, sourcePart, foreignData, report,
|
|
2186
|
+
async function readVisioImage(pkg, sourcePart, foreignData, report, options2 = {}) {
|
|
2187
2187
|
const limits = {
|
|
2188
2188
|
...VISIO_RASTER_IMAGE_LIMITS,
|
|
2189
|
-
...
|
|
2189
|
+
...options2
|
|
2190
2190
|
};
|
|
2191
2191
|
if (Object.values(limits).some((value3) => !Number.isSafeInteger(value3) || value3 <= 0))
|
|
2192
2192
|
throw new VisioPackageError("INVALID_LIMIT", "Image limits must be positive safe integers.");
|
|
@@ -4649,9 +4649,9 @@ function cellUnit(name3, relative) {
|
|
|
4649
4649
|
return !relative && /\.[XY]\d+$/i.test(name3) ? "length" : "scalar";
|
|
4650
4650
|
}
|
|
4651
4651
|
var isBooleanLiteral = (ref) => ref.shapeId === void 0 && /^(true|false)$/i.test(ref.cell);
|
|
4652
|
-
function indexCells(roots2,
|
|
4652
|
+
function indexCells(roots2, options2) {
|
|
4653
4653
|
const cells4 = /* @__PURE__ */ new Map();
|
|
4654
|
-
const maxCells = bound(
|
|
4654
|
+
const maxCells = bound(options2.maxCells, 1e5);
|
|
4655
4655
|
const add = (item) => {
|
|
4656
4656
|
const id3 = key(item);
|
|
4657
4657
|
if (cells4.has(id3)) fail("EDIT_AMBIGUOUS_CELL", "Duplicate local ShapeSheet cell.");
|
|
@@ -4677,11 +4677,11 @@ function indexCells(roots2, options) {
|
|
|
4677
4677
|
const visit = (parent, inherited, nested) => {
|
|
4678
4678
|
for (const container of children2(parent, "Shapes"))
|
|
4679
4679
|
for (const node3 of children2(container, "Shape")) {
|
|
4680
|
-
|
|
4680
|
+
options2.check?.();
|
|
4681
4681
|
const shapeId2 = attribute2(node3, "ID");
|
|
4682
4682
|
if (!shapeId2 || ids.has(shapeId2)) fail("INVALID_SHAPE_ID", "Shape IDs must be unique.");
|
|
4683
4683
|
ids.add(shapeId2);
|
|
4684
|
-
const unsafe2 = inherited || nested || node3.hasAttribute("Master") || node3.hasAttribute("MasterShape") || attribute2(node3, "Type") === "Group" || !isLocalForeignFrameShape(node3) && (attribute2(node3, "Type") !== void 0 && attribute2(node3, "Type") !== "Shape" || children2(node3, "ForeignData").length > 0 || children2(node3, "Rel").length > 0) || connected.has(shapeId2) && !
|
|
4684
|
+
const unsafe2 = inherited || nested || node3.hasAttribute("Master") || node3.hasAttribute("MasterShape") || attribute2(node3, "Type") === "Group" || !isLocalForeignFrameShape(node3) && (attribute2(node3, "Type") !== void 0 && attribute2(node3, "Type") !== "Shape" || children2(node3, "ForeignData").length > 0 || children2(node3, "Rel").length > 0) || connected.has(shapeId2) && !options2.glueShapes?.has(node3) || !options2.lineEditShapes?.has(node3) && children2(node3, "Cell").some(
|
|
4685
4685
|
(cell) => /^(BeginX|BeginY|EndX|EndY)$/i.test(attribute2(cell, "N") ?? "") || attribute2(cell, "N")?.toLowerCase() === "oned" && (attribute2(cell, "V") !== "0" || !!executableCellFormula(attribute2(cell, "F")) || attribute2(cell, "F") === "Inh")
|
|
4686
4686
|
) || children2(node3, "Shapes").length > 0 || ["1", "true"].includes(attribute2(node3, "Del") ?? "");
|
|
4687
4687
|
sheets.push({ node: node3, shapeId: shapeId2, unsafe: unsafe2 });
|
|
@@ -4774,7 +4774,7 @@ function indexCells(roots2, options) {
|
|
|
4774
4774
|
}
|
|
4775
4775
|
}
|
|
4776
4776
|
for (const node3 of Array.from(root2.getElementsByTagName("*"))) {
|
|
4777
|
-
|
|
4777
|
+
options2.check?.();
|
|
4778
4778
|
if (node3.hasAttribute("F") && !indexedNodes.has(node3))
|
|
4779
4779
|
fail(
|
|
4780
4780
|
"EDIT_UNKNOWN_DEPENDENCY",
|
|
@@ -4786,12 +4786,12 @@ function indexCells(roots2, options) {
|
|
|
4786
4786
|
}
|
|
4787
4787
|
|
|
4788
4788
|
// visio/edit-recalculate-values.ts
|
|
4789
|
-
function createVisioCellEvaluator(cells4,
|
|
4789
|
+
function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
|
|
4790
4790
|
const active = /* @__PURE__ */ new Set(), values = /* @__PURE__ */ new Map();
|
|
4791
|
-
let steps = bound(
|
|
4792
|
-
const maxDepth = bound(
|
|
4791
|
+
let steps = bound(options2.maxSteps, 1e5);
|
|
4792
|
+
const maxDepth = bound(options2.maxDepth, 64);
|
|
4793
4793
|
const evaluate = (id3) => {
|
|
4794
|
-
|
|
4794
|
+
options2.check?.();
|
|
4795
4795
|
if (--steps < 0)
|
|
4796
4796
|
fail("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
|
|
4797
4797
|
const cached5 = values.get(id3);
|
|
@@ -4800,7 +4800,7 @@ function createVisioCellEvaluator(cells4, options = {}, verifyCaches = false) {
|
|
|
4800
4800
|
if (active.size >= maxDepth)
|
|
4801
4801
|
fail("LIMIT_FORMULA_DEPTH", "ShapeSheet dependency depth limit exceeded.");
|
|
4802
4802
|
const item = cells4.get(id3);
|
|
4803
|
-
if (!item || item.unsafe && (!item.node || !
|
|
4803
|
+
if (!item || item.unsafe && (!item.node || !options2.masterMovePins?.has(item.node) && !options2.groupRotationCells?.has(item.node)))
|
|
4804
4804
|
fail(
|
|
4805
4805
|
"EDIT_UNSUPPORTED_DEPENDENCY",
|
|
4806
4806
|
"Affected formula references missing, inherited or grouped cells."
|
|
@@ -4824,7 +4824,7 @@ function createVisioCellEvaluator(cells4, options = {}, verifyCaches = false) {
|
|
|
4824
4824
|
key({ pageId: item.pageId, shapeId: ref.shapeId ?? item.shapeId, cell: ref.cell })
|
|
4825
4825
|
),
|
|
4826
4826
|
{
|
|
4827
|
-
...
|
|
4827
|
+
...options2.pageContext?.get(item.pageId),
|
|
4828
4828
|
onStep: () => {
|
|
4829
4829
|
if (--steps < 0)
|
|
4830
4830
|
fail("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
|
|
@@ -4856,8 +4856,8 @@ function createVisioCellEvaluator(cells4, options = {}, verifyCaches = false) {
|
|
|
4856
4856
|
}
|
|
4857
4857
|
|
|
4858
4858
|
// visio/edit-recalculate.ts
|
|
4859
|
-
function recalculateVisioCells(roots2, changed,
|
|
4860
|
-
const cells4 = indexCells(roots2,
|
|
4859
|
+
function recalculateVisioCells(roots2, changed, options2 = {}) {
|
|
4860
|
+
const cells4 = indexCells(roots2, options2);
|
|
4861
4861
|
const reverse = /* @__PURE__ */ new Map();
|
|
4862
4862
|
for (const [id3, item] of cells4)
|
|
4863
4863
|
for (const dependency of item.dependencies) {
|
|
@@ -4867,9 +4867,9 @@ function recalculateVisioCells(roots2, changed, options = {}) {
|
|
|
4867
4867
|
}
|
|
4868
4868
|
const affected = new Set(changed.map(key));
|
|
4869
4869
|
const pending2 = [...affected];
|
|
4870
|
-
const maxAffected = bound(
|
|
4870
|
+
const maxAffected = bound(options2.maxAffectedCells, 1e4);
|
|
4871
4871
|
for (let i = 0; i < pending2.length; i++) {
|
|
4872
|
-
|
|
4872
|
+
options2.check?.();
|
|
4873
4873
|
for (const id3 of reverse.get(pending2[i]) ?? [])
|
|
4874
4874
|
if (!affected.has(id3)) {
|
|
4875
4875
|
affected.add(id3);
|
|
@@ -4878,7 +4878,7 @@ function recalculateVisioCells(roots2, changed, options = {}) {
|
|
|
4878
4878
|
if (affected.size > maxAffected)
|
|
4879
4879
|
fail("LIMIT_FORMULA_AFFECTED", "Affected ShapeSheet cell limit exceeded.");
|
|
4880
4880
|
}
|
|
4881
|
-
const evaluate = createVisioCellEvaluator(cells4,
|
|
4881
|
+
const evaluate = createVisioCellEvaluator(cells4, options2);
|
|
4882
4882
|
const values = /* @__PURE__ */ new Map();
|
|
4883
4883
|
for (const id3 of affected) values.set(id3, evaluate(id3));
|
|
4884
4884
|
const pages = /* @__PURE__ */ new Set();
|
|
@@ -4894,10 +4894,10 @@ function recalculateVisioCells(roots2, changed, options = {}) {
|
|
|
4894
4894
|
}
|
|
4895
4895
|
return [...pages];
|
|
4896
4896
|
}
|
|
4897
|
-
function assertVisioShapesUnreferenced(roots2, removed,
|
|
4898
|
-
const cells4 = indexCells(roots2,
|
|
4897
|
+
function assertVisioShapesUnreferenced(roots2, removed, options2 = {}) {
|
|
4898
|
+
const cells4 = indexCells(roots2, options2);
|
|
4899
4899
|
for (const cell of cells4.values()) {
|
|
4900
|
-
|
|
4900
|
+
options2.check?.();
|
|
4901
4901
|
if (removed.get(cell.pageId)?.has(cell.shapeId)) continue;
|
|
4902
4902
|
if (cell.dependencies.some((id3) => {
|
|
4903
4903
|
const parts = JSON.parse(id3);
|
|
@@ -4908,24 +4908,24 @@ function assertVisioShapesUnreferenced(roots2, removed, options = {}) {
|
|
|
4908
4908
|
for (const [pageId2, ids] of removed)
|
|
4909
4909
|
for (const connections2 of children2(roots2.get(pageId2), "Connects"))
|
|
4910
4910
|
for (const connection of children2(connections2, "Connect")) {
|
|
4911
|
-
|
|
4911
|
+
options2.check?.();
|
|
4912
4912
|
if (["FromSheet", "ToSheet"].some((name3) => ids.has(attribute2(connection, name3) ?? "")))
|
|
4913
4913
|
fail("EDIT_REFERENCED_DELETE", "Shape participates in a Connect record.");
|
|
4914
4914
|
}
|
|
4915
4915
|
}
|
|
4916
|
-
function assertVisioShapeUnreferenced(roots2, pageId2, shapeId2,
|
|
4917
|
-
assertVisioShapesUnreferenced(roots2, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]),
|
|
4916
|
+
function assertVisioShapeUnreferenced(roots2, pageId2, shapeId2, options2 = {}) {
|
|
4917
|
+
assertVisioShapesUnreferenced(roots2, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]), options2);
|
|
4918
4918
|
}
|
|
4919
|
-
function createVisioDependencyQuery(roots2,
|
|
4920
|
-
const cells4 = indexCells(roots2,
|
|
4919
|
+
function createVisioDependencyQuery(roots2, options2 = {}) {
|
|
4920
|
+
const cells4 = indexCells(roots2, options2);
|
|
4921
4921
|
return (source, targets) => {
|
|
4922
4922
|
const wanted = new Set(targets.map(key));
|
|
4923
4923
|
const seen = /* @__PURE__ */ new Set();
|
|
4924
4924
|
const pending2 = [key(source)];
|
|
4925
|
-
const maxSteps = bound(
|
|
4925
|
+
const maxSteps = bound(options2.maxSteps, 1e5);
|
|
4926
4926
|
let found = false;
|
|
4927
4927
|
while (pending2.length) {
|
|
4928
|
-
|
|
4928
|
+
options2.check?.();
|
|
4929
4929
|
const id3 = pending2.pop();
|
|
4930
4930
|
if (seen.has(id3)) continue;
|
|
4931
4931
|
seen.add(id3);
|
|
@@ -8837,16 +8837,16 @@ function emfInputView(input) {
|
|
|
8837
8837
|
return null;
|
|
8838
8838
|
}
|
|
8839
8839
|
}
|
|
8840
|
-
function emfInputOptions(
|
|
8841
|
-
if (!
|
|
8840
|
+
function emfInputOptions(options2) {
|
|
8841
|
+
if (!options2 || typeof options2 !== "object") return null;
|
|
8842
8842
|
try {
|
|
8843
|
-
const prototype = Object.getPrototypeOf(
|
|
8843
|
+
const prototype = Object.getPrototypeOf(options2);
|
|
8844
8844
|
if (prototype !== null && prototype !== Object.prototype) return null;
|
|
8845
8845
|
const snapshot = {};
|
|
8846
8846
|
for (const key2 of Object.keys(
|
|
8847
8847
|
VISIO_EMF_ADMISSION_LIMITS
|
|
8848
8848
|
)) {
|
|
8849
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
8849
|
+
const descriptor = Object.getOwnPropertyDescriptor(options2, key2);
|
|
8850
8850
|
if (!descriptor) continue;
|
|
8851
8851
|
if (!("value" in descriptor)) return null;
|
|
8852
8852
|
const value3 = descriptor.value;
|
|
@@ -8862,18 +8862,18 @@ function emfInputOptions(options) {
|
|
|
8862
8862
|
|
|
8863
8863
|
// visio/emf-admission-context.ts
|
|
8864
8864
|
var EmfAdmissionContext = class {
|
|
8865
|
-
constructor(view,
|
|
8865
|
+
constructor(view, options2) {
|
|
8866
8866
|
this.view = view;
|
|
8867
8867
|
this.limits = { ...VISIO_EMF_ADMISSION_LIMITS };
|
|
8868
|
-
if (!
|
|
8868
|
+
if (!options2 || typeof options2 !== "object") {
|
|
8869
8869
|
this.emit("invalid", "limits", "Expected an options object.");
|
|
8870
8870
|
return;
|
|
8871
8871
|
}
|
|
8872
|
-
const cap =
|
|
8872
|
+
const cap = options2.maxDiagnostics;
|
|
8873
8873
|
if (cap !== void 0 && Number.isInteger(cap) && cap > 0 && cap <= this.limits.maxDiagnostics)
|
|
8874
8874
|
this.limits.maxDiagnostics = cap;
|
|
8875
8875
|
for (const key2 of Object.keys(VISIO_EMF_ADMISSION_LIMITS)) {
|
|
8876
|
-
const value3 =
|
|
8876
|
+
const value3 = options2[key2];
|
|
8877
8877
|
if (value3 === void 0) continue;
|
|
8878
8878
|
if (!Number.isSafeInteger(value3) || value3 < 1 || value3 > this.limits[key2])
|
|
8879
8879
|
this.emit("invalid", "limits", "Limits must be positive integers below the hard ceiling.");
|
|
@@ -9426,8 +9426,8 @@ function inspectEmfObjectRecord(c2) {
|
|
|
9426
9426
|
}
|
|
9427
9427
|
|
|
9428
9428
|
// visio/emf-admission.ts
|
|
9429
|
-
function inspectVisioEmfAdmission(input,
|
|
9430
|
-
const snapshot = emfInputOptions(
|
|
9429
|
+
function inspectVisioEmfAdmission(input, options2 = {}) {
|
|
9430
|
+
const snapshot = emfInputOptions(options2);
|
|
9431
9431
|
const view = snapshot === null ? null : emfInputView(input);
|
|
9432
9432
|
const c2 = new EmfAdmissionContext(view ?? new DataView(new ArrayBuffer(0)), snapshot ?? {});
|
|
9433
9433
|
if (snapshot === null) {
|
|
@@ -9654,9 +9654,9 @@ function record(value3, allowed) {
|
|
|
9654
9654
|
}
|
|
9655
9655
|
return result2;
|
|
9656
9656
|
}
|
|
9657
|
-
function limitsFor(
|
|
9657
|
+
function limitsFor(options2) {
|
|
9658
9658
|
const result2 = { ...VISIO_FOREIGN_VECTOR_LIMITS };
|
|
9659
|
-
const values = record(
|
|
9659
|
+
const values = record(options2, Object.keys(result2));
|
|
9660
9660
|
for (const key2 of Object.keys(values)) {
|
|
9661
9661
|
const value3 = values[key2];
|
|
9662
9662
|
if (typeof value3 !== "number" || !Number.isSafeInteger(value3) || value3 < 1 || value3 > result2[key2])
|
|
@@ -10002,9 +10002,9 @@ var PAINT = {
|
|
|
10002
10002
|
fillOpacity: "fill-opacity",
|
|
10003
10003
|
strokeOpacity: "stroke-opacity"
|
|
10004
10004
|
};
|
|
10005
|
-
function validateVisioForeignVector(value3,
|
|
10005
|
+
function validateVisioForeignVector(value3, options2 = {}) {
|
|
10006
10006
|
try {
|
|
10007
|
-
return validate(value3, limitsFor(
|
|
10007
|
+
return validate(value3, limitsFor(options2));
|
|
10008
10008
|
} catch (error) {
|
|
10009
10009
|
if (error instanceof VisioForeignVectorError) throw error;
|
|
10010
10010
|
unsafe("Unable to inspect vector scene safely.");
|
|
@@ -10166,9 +10166,9 @@ var ATTRS = {
|
|
|
10166
10166
|
clipPath: ["id", "clipPathUnits", "clip-rule", ...BASE]
|
|
10167
10167
|
};
|
|
10168
10168
|
var ID2 = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
|
|
10169
|
-
function sanitizeVisioForeignVectorTree(root2,
|
|
10169
|
+
function sanitizeVisioForeignVectorTree(root2, options2 = {}) {
|
|
10170
10170
|
try {
|
|
10171
|
-
return sanitize(root2, limitsFor(
|
|
10171
|
+
return sanitize(root2, limitsFor(options2));
|
|
10172
10172
|
} catch (error) {
|
|
10173
10173
|
if (error instanceof VisioForeignVectorError) throw error;
|
|
10174
10174
|
unsafe("Unable to inspect converter output safely.");
|
|
@@ -11707,15 +11707,15 @@ function renderAbs(v, section3, generalWidth) {
|
|
|
11707
11707
|
}
|
|
11708
11708
|
return { text: text8, zero: general === "0" };
|
|
11709
11709
|
}
|
|
11710
|
-
function hashFill(
|
|
11711
|
-
const width =
|
|
11712
|
-
const one =
|
|
11710
|
+
function hashFill(options2) {
|
|
11711
|
+
const width = options2.width ?? 0;
|
|
11712
|
+
const one = options2.measure ? options2.measure("#") : 1;
|
|
11713
11713
|
return "#".repeat(Math.max(1, Math.floor(one > 0 ? width / one : width)));
|
|
11714
11714
|
}
|
|
11715
|
-
function fitNumber(value3, format5,
|
|
11716
|
-
const date1904 =
|
|
11717
|
-
const width =
|
|
11718
|
-
const fits = (text8) => (
|
|
11715
|
+
function fitNumber(value3, format5, options2) {
|
|
11716
|
+
const date1904 = options2.date1904 ?? false;
|
|
11717
|
+
const width = options2.width ?? 0;
|
|
11718
|
+
const fits = (text8) => (options2.measure ? options2.measure(text8) : text8.length) <= width;
|
|
11719
11719
|
const first2 = formatNumber2(value3, format5, date1904);
|
|
11720
11720
|
if (fits(first2.text) || first2.text === OVERFLOW_TEXT) return first2;
|
|
11721
11721
|
const choice2 = chooseSection(compileFormat(format5), value3);
|
|
@@ -11726,7 +11726,7 @@ function fitNumber(value3, format5, options) {
|
|
|
11726
11726
|
if (fits(next.text)) return next;
|
|
11727
11727
|
}
|
|
11728
11728
|
}
|
|
11729
|
-
const fill = hashFill(
|
|
11729
|
+
const fill = hashFill(options2);
|
|
11730
11730
|
return first2.color ? { text: fill, color: first2.color } : { text: fill };
|
|
11731
11731
|
}
|
|
11732
11732
|
function formatNumber2(value3, format5, date1904, generalWidth) {
|
|
@@ -11748,13 +11748,13 @@ function formatNumber2(value3, format5, date1904, generalWidth) {
|
|
|
11748
11748
|
const minus = value3 < 0 && !abs && !zero;
|
|
11749
11749
|
return result(minus ? `-${text8}` : text8, section3);
|
|
11750
11750
|
}
|
|
11751
|
-
function formatValue(value3, format5,
|
|
11751
|
+
function formatValue(value3, format5, options2 = {}) {
|
|
11752
11752
|
if (value3 === null) return { text: "" };
|
|
11753
11753
|
if (typeof value3 === "boolean") return { text: value3 ? "TRUE" : "FALSE" };
|
|
11754
11754
|
if (typeof value3 === "string") return formatText(value3, compileFormat(format5).text);
|
|
11755
11755
|
if (isCellError(value3)) return { text: value3.error };
|
|
11756
|
-
if (
|
|
11757
|
-
return formatNumber2(value3, format5,
|
|
11756
|
+
if (options2.width !== void 0) return fitNumber(value3, format5, options2);
|
|
11757
|
+
return formatNumber2(value3, format5, options2.date1904 ?? false);
|
|
11758
11758
|
}
|
|
11759
11759
|
function isDateFormat(format5) {
|
|
11760
11760
|
return compileFormat(format5).isDate;
|
|
@@ -15796,8 +15796,8 @@ function rgbToHsl(r, g, b) {
|
|
|
15796
15796
|
}
|
|
15797
15797
|
return { h, s: clampUnitInterval(s), l: clampUnitInterval(l) };
|
|
15798
15798
|
}
|
|
15799
|
-
function hslToRgb(h, s, l, roundChannel = Math.round,
|
|
15800
|
-
const sC =
|
|
15799
|
+
function hslToRgb(h, s, l, roundChannel = Math.round, options2) {
|
|
15800
|
+
const sC = options2?.clampSaturation === false ? s : clampUnitInterval(s);
|
|
15801
15801
|
const lC = clampUnitInterval(l);
|
|
15802
15802
|
const hN = (h % 360 + 360) % 360;
|
|
15803
15803
|
const c2 = (1 - Math.abs(2 * lC - 1)) * sC;
|
|
@@ -16310,13 +16310,13 @@ var APPLIED = /* @__PURE__ */ new Set([
|
|
|
16310
16310
|
"lumMod",
|
|
16311
16311
|
"lumOff"
|
|
16312
16312
|
]);
|
|
16313
|
-
function resolveDrawingColor(color2, theme2,
|
|
16313
|
+
function resolveDrawingColor(color2, theme2, options2) {
|
|
16314
16314
|
const base2 = baseHex(color2, theme2);
|
|
16315
16315
|
const rgb6 = base2 ? hexToRgbChannels(base2) : null;
|
|
16316
16316
|
if (!rgb6) return void 0;
|
|
16317
|
-
if (
|
|
16317
|
+
if (options2?.transformOrder === "document") {
|
|
16318
16318
|
const value3 = orderedColorTransforms(rgb6, color2.transforms);
|
|
16319
|
-
const round6 =
|
|
16319
|
+
const round6 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
|
|
16320
16320
|
return {
|
|
16321
16321
|
hex: `#${toHex(round6(value3.r))}${toHex(round6(value3.g))}${toHex(round6(value3.b))}`,
|
|
16322
16322
|
alpha: value3.alpha,
|
|
@@ -16367,7 +16367,7 @@ function resolveDrawingColor(color2, theme2, options) {
|
|
|
16367
16367
|
if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
|
|
16368
16368
|
const lumOff = parseDrawingFraction(find("lumOff"));
|
|
16369
16369
|
if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
|
|
16370
|
-
const round6 =
|
|
16370
|
+
const round6 = options2?.hslRounding === "halfDown" ? (value3) => Math.ceil(value3 - 0.5) : Math.round;
|
|
16371
16371
|
({ r, g, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round6));
|
|
16372
16372
|
}
|
|
16373
16373
|
let alpha = parseDrawingPercent(find("alpha")) ?? 1;
|
|
@@ -19177,6 +19177,74 @@ function parseChartSpace(source) {
|
|
|
19177
19177
|
);
|
|
19178
19178
|
return { chartSpace, issues: context.issues };
|
|
19179
19179
|
}
|
|
19180
|
+
var AUTOMATIC_MARKER_CYCLE = [
|
|
19181
|
+
"diamond",
|
|
19182
|
+
"square",
|
|
19183
|
+
"triangle",
|
|
19184
|
+
"x",
|
|
19185
|
+
"star",
|
|
19186
|
+
"circle",
|
|
19187
|
+
"plus",
|
|
19188
|
+
"dot",
|
|
19189
|
+
"dash"
|
|
19190
|
+
];
|
|
19191
|
+
function automaticMarkerSymbol(seriesIdx) {
|
|
19192
|
+
const length = AUTOMATIC_MARKER_CYCLE.length;
|
|
19193
|
+
const normalized = (Math.trunc(seriesIdx) % length + length) % length;
|
|
19194
|
+
return AUTOMATIC_MARKER_CYCLE[Number.isFinite(normalized) ? normalized : 0];
|
|
19195
|
+
}
|
|
19196
|
+
|
|
19197
|
+
// chart/render/chart-view-markers.ts
|
|
19198
|
+
function summaryMarkers(source, group2, seriesPosition) {
|
|
19199
|
+
if (!["line", "scatter", "radar"].includes(group2.kind)) return {};
|
|
19200
|
+
const enabled = group2.kind === "line" ? group2.marker === true : group2.kind === "radar" ? group2.radarStyle === "marker" : !["line", "smooth", "none"].includes(group2.scatterStyle ?? "marker");
|
|
19201
|
+
const symbol = source.marker?.symbol;
|
|
19202
|
+
const marker3 = {
|
|
19203
|
+
...source.marker,
|
|
19204
|
+
symbol: symbol && symbol !== "auto" ? symbol : source.marker || enabled ? automaticMarkerSymbol(source.index ?? seriesPosition) : "none"
|
|
19205
|
+
};
|
|
19206
|
+
const pointMarkers = {};
|
|
19207
|
+
for (const point2 of source.dataPoints) {
|
|
19208
|
+
if (point2.index === void 0 || !point2.marker) continue;
|
|
19209
|
+
const override = point2.marker;
|
|
19210
|
+
pointMarkers[point2.index] = {
|
|
19211
|
+
...marker3,
|
|
19212
|
+
...override,
|
|
19213
|
+
...override.symbol === "auto" || !source.marker && override.symbol === void 0 ? { symbol: automaticMarkerSymbol(source.index ?? seriesPosition) } : {},
|
|
19214
|
+
...marker3.spPr || override.spPr ? {
|
|
19215
|
+
spPr: {
|
|
19216
|
+
...marker3.spPr,
|
|
19217
|
+
...override.spPr,
|
|
19218
|
+
...marker3.spPr?.line || override.spPr?.line ? { line: { ...marker3.spPr?.line, ...override.spPr?.line } } : {}
|
|
19219
|
+
}
|
|
19220
|
+
} : {}
|
|
19221
|
+
};
|
|
19222
|
+
}
|
|
19223
|
+
return { marker: marker3, ...Object.keys(pointMarkers).length ? { pointMarkers } : {} };
|
|
19224
|
+
}
|
|
19225
|
+
function seriesMarkerViews(source, drawingColor2) {
|
|
19226
|
+
const fillColor = (fill) => fill?.kind === "none" ? "none" : fill?.kind === "solid" ? drawingColor2(fill.color) : void 0;
|
|
19227
|
+
const resolve = (marker3) => {
|
|
19228
|
+
const fill = fillColor(marker3.spPr?.fill);
|
|
19229
|
+
const stroke = fillColor(marker3.spPr?.line?.fill);
|
|
19230
|
+
const width = marker3.spPr?.line?.widthEmu;
|
|
19231
|
+
return {
|
|
19232
|
+
...marker3.symbol !== void 0 ? { symbol: marker3.symbol } : {},
|
|
19233
|
+
...marker3.size !== void 0 ? { size: marker3.size } : {},
|
|
19234
|
+
...fill !== void 0 ? { fill } : {},
|
|
19235
|
+
...stroke !== void 0 ? { stroke } : {},
|
|
19236
|
+
...width !== void 0 ? { strokeWidth: width / 9525 } : {}
|
|
19237
|
+
};
|
|
19238
|
+
};
|
|
19239
|
+
return {
|
|
19240
|
+
...source.marker ? { marker: resolve(source.marker) } : {},
|
|
19241
|
+
...source.pointMarkers ? {
|
|
19242
|
+
pointMarkers: Object.fromEntries(
|
|
19243
|
+
Object.entries(source.pointMarkers).map(([i, marker3]) => [i, resolve(marker3)])
|
|
19244
|
+
)
|
|
19245
|
+
} : {}
|
|
19246
|
+
};
|
|
19247
|
+
}
|
|
19180
19248
|
|
|
19181
19249
|
// chart/render/summary-analysis.ts
|
|
19182
19250
|
function summaryTrendline(source) {
|
|
@@ -19500,17 +19568,17 @@ function composeDataLabelText(input) {
|
|
|
19500
19568
|
}
|
|
19501
19569
|
|
|
19502
19570
|
// chart/render/summary-labels.ts
|
|
19503
|
-
function level(
|
|
19571
|
+
function level(options2, custom) {
|
|
19504
19572
|
const out = {};
|
|
19505
|
-
if (
|
|
19506
|
-
if (
|
|
19507
|
-
if (
|
|
19508
|
-
if (
|
|
19509
|
-
if (
|
|
19510
|
-
if (
|
|
19511
|
-
if (
|
|
19512
|
-
if (
|
|
19513
|
-
if (
|
|
19573
|
+
if (options2.deleted !== void 0) out.deleted = options2.deleted;
|
|
19574
|
+
if (options2.showValue !== void 0) out.showValue = options2.showValue;
|
|
19575
|
+
if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
|
|
19576
|
+
if (options2.showSeriesName !== void 0) out.showSeriesName = options2.showSeriesName;
|
|
19577
|
+
if (options2.showPercent !== void 0) out.showPercent = options2.showPercent;
|
|
19578
|
+
if (options2.showBubbleSize !== void 0) out.showBubbleSize = options2.showBubbleSize;
|
|
19579
|
+
if (options2.separator !== void 0) out.separator = options2.separator;
|
|
19580
|
+
if (options2.position) out.position = options2.position;
|
|
19581
|
+
if (options2.numberFormat?.formatCode) out.numberFormat = options2.numberFormat.formatCode;
|
|
19514
19582
|
if (custom?.text !== void 0) out.text = custom.text;
|
|
19515
19583
|
return out;
|
|
19516
19584
|
}
|
|
@@ -19617,7 +19685,10 @@ function extraGroups(chartSpace, firstType) {
|
|
|
19617
19685
|
const type = group2.kind === "bar" ? "column" : group2.kind;
|
|
19618
19686
|
const entry3 = {
|
|
19619
19687
|
chartType: type,
|
|
19620
|
-
series: group2.series.map((source) =>
|
|
19688
|
+
series: group2.series.map((source, index2) => ({
|
|
19689
|
+
...chartSummarySeries(source, type, group2.dataLabels),
|
|
19690
|
+
...summaryMarkers(source, group2, index2)
|
|
19691
|
+
})),
|
|
19621
19692
|
secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
|
|
19622
19693
|
};
|
|
19623
19694
|
if (group2.grouping && GROUPINGS.has(group2.grouping))
|
|
@@ -19635,13 +19706,16 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
19635
19706
|
const group2 = chartSpace.plotArea.groups[0];
|
|
19636
19707
|
let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
|
|
19637
19708
|
if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
|
|
19638
|
-
const series = (group2?.series ?? []).map(
|
|
19639
|
-
|
|
19640
|
-
|
|
19709
|
+
const series = (group2?.series ?? []).map((source, index2) => ({
|
|
19710
|
+
...chartSummarySeries(source, chartType, group2?.dataLabels),
|
|
19711
|
+
...group2 ? summaryMarkers(source, group2, index2) : {}
|
|
19712
|
+
}));
|
|
19641
19713
|
const summary = {
|
|
19642
19714
|
chartType,
|
|
19643
19715
|
series,
|
|
19644
|
-
showLegend: chartSpace.legend !== void 0
|
|
19716
|
+
showLegend: chartSpace.legend !== void 0,
|
|
19717
|
+
axes: chartSpace.plotArea.axes,
|
|
19718
|
+
axisIds: group2?.axisIds ?? []
|
|
19645
19719
|
};
|
|
19646
19720
|
const combined = extraGroups(chartSpace, chartType);
|
|
19647
19721
|
if (combined.length) summary.extraGroups = combined;
|
|
@@ -19724,6 +19798,8 @@ function parseChart(xml, anchor, partName, name3) {
|
|
|
19724
19798
|
showLegend: summary.showLegend,
|
|
19725
19799
|
partName
|
|
19726
19800
|
};
|
|
19801
|
+
if (summary.axes) object.axes = summary.axes;
|
|
19802
|
+
if (summary.axisIds) object.axisIds = summary.axisIds;
|
|
19727
19803
|
if (summary.grouping) object.grouping = summary.grouping;
|
|
19728
19804
|
if (summary.barGapWidth !== void 0) object.barGapWidth = summary.barGapWidth;
|
|
19729
19805
|
if (summary.barOverlap !== void 0) object.barOverlap = summary.barOverlap;
|
|
@@ -21144,14 +21220,14 @@ function* units2(raw) {
|
|
|
21144
21220
|
exp++;
|
|
21145
21221
|
}
|
|
21146
21222
|
}
|
|
21147
|
-
function niceScale(dataMin, dataMax,
|
|
21148
|
-
const maxIntervals = Math.max(1,
|
|
21223
|
+
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
21224
|
+
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
21149
21225
|
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
21150
21226
|
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
21151
21227
|
if (lo > hi) [lo, hi] = [hi, lo];
|
|
21152
21228
|
if (lo === hi) {
|
|
21153
21229
|
if (lo === 0) hi = 1;
|
|
21154
|
-
else if (
|
|
21230
|
+
else if (options2.noZero) {
|
|
21155
21231
|
const pad5 = Math.abs(lo) * 0.1 || 1;
|
|
21156
21232
|
lo -= pad5;
|
|
21157
21233
|
hi += pad5;
|
|
@@ -21160,7 +21236,7 @@ function niceScale(dataMin, dataMax, options = {}) {
|
|
|
21160
21236
|
}
|
|
21161
21237
|
let fixedLo = false;
|
|
21162
21238
|
let fixedHi = false;
|
|
21163
|
-
if (!
|
|
21239
|
+
if (!options2.noZero) {
|
|
21164
21240
|
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
21165
21241
|
lo = 0;
|
|
21166
21242
|
fixedLo = true;
|
|
@@ -21200,6 +21276,194 @@ function formatAxisValue(value3, percent = false) {
|
|
|
21200
21276
|
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
21201
21277
|
}
|
|
21202
21278
|
|
|
21279
|
+
// chart/axis-range.ts
|
|
21280
|
+
function computeLogValueRange(series, logBase) {
|
|
21281
|
+
const allValues = series.flatMap((item) => item.values).filter((value3) => value3 !== null && Number.isFinite(value3) && value3 > 0);
|
|
21282
|
+
if (allValues.length === 0) {
|
|
21283
|
+
return { min: 1, max: logBase, span: 1, logScale: true, logBase };
|
|
21284
|
+
}
|
|
21285
|
+
const dataMin = Math.min(...allValues);
|
|
21286
|
+
const dataMax = Math.max(...allValues);
|
|
21287
|
+
const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
|
|
21288
|
+
const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
|
|
21289
|
+
const min = logBase ** logMin;
|
|
21290
|
+
const max = logBase ** Math.max(logMax, logMin + 1);
|
|
21291
|
+
return {
|
|
21292
|
+
min,
|
|
21293
|
+
max,
|
|
21294
|
+
span: Math.max(Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase), 1),
|
|
21295
|
+
logScale: true,
|
|
21296
|
+
logBase
|
|
21297
|
+
};
|
|
21298
|
+
}
|
|
21299
|
+
function withAxisBounds(automatic, axis, logBase) {
|
|
21300
|
+
const validMin = typeof axis?.min === "number" && Number.isFinite(axis.min) && (!logBase || axis.min > 0) ? axis.min : void 0;
|
|
21301
|
+
const validMax = typeof axis?.max === "number" && Number.isFinite(axis.max) && (!logBase || axis.max > 0) ? axis.max : void 0;
|
|
21302
|
+
const min = validMin ?? automatic.min;
|
|
21303
|
+
let max = validMax ?? automatic.max;
|
|
21304
|
+
const majorUnit = validMin === void 0 && validMax === void 0 ? automatic.majorUnit : void 0;
|
|
21305
|
+
if (max <= min) {
|
|
21306
|
+
max = logBase ? min * logBase : min + 1;
|
|
21307
|
+
}
|
|
21308
|
+
const span = logBase ? Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase) : max - min;
|
|
21309
|
+
return {
|
|
21310
|
+
min,
|
|
21311
|
+
max,
|
|
21312
|
+
span: Math.max(span, Number.EPSILON),
|
|
21313
|
+
...majorUnit !== void 0 ? { majorUnit } : {},
|
|
21314
|
+
...logBase ? { logScale: true, logBase } : {},
|
|
21315
|
+
...axis?.orientation === "maxMin" ? { reverseOrder: true } : {}
|
|
21316
|
+
};
|
|
21317
|
+
}
|
|
21318
|
+
|
|
21319
|
+
// chart/axis-ticks.ts
|
|
21320
|
+
var LOG_EXPONENT_TOLERANCE = 1e-12;
|
|
21321
|
+
function generateLogTicks(range2) {
|
|
21322
|
+
if (!range2.logScale || !range2.logBase) {
|
|
21323
|
+
return [];
|
|
21324
|
+
}
|
|
21325
|
+
const base2 = range2.logBase;
|
|
21326
|
+
const logMin = Math.log(range2.min) / Math.log(base2);
|
|
21327
|
+
const logMax = Math.log(range2.max) / Math.log(base2);
|
|
21328
|
+
const firstExponent = Math.ceil(logMin - LOG_EXPONENT_TOLERANCE);
|
|
21329
|
+
const lastExponent = Math.floor(logMax + LOG_EXPONENT_TOLERANCE);
|
|
21330
|
+
if (lastExponent < firstExponent) {
|
|
21331
|
+
return range2.min === range2.max ? [range2.min] : [range2.min, range2.max];
|
|
21332
|
+
}
|
|
21333
|
+
return Array.from(
|
|
21334
|
+
{ length: lastExponent - firstExponent + 1 },
|
|
21335
|
+
(_unused, index2) => base2 ** (firstExponent + index2)
|
|
21336
|
+
);
|
|
21337
|
+
}
|
|
21338
|
+
function generateIntervalTicks(range2, unit3) {
|
|
21339
|
+
if (!Number.isFinite(unit3) || unit3 <= 0 || range2.logScale) {
|
|
21340
|
+
return [];
|
|
21341
|
+
}
|
|
21342
|
+
const tolerance = Math.max(1, Math.abs(range2.min), Math.abs(range2.max)) * 1e-12;
|
|
21343
|
+
const first2 = Math.ceil((range2.min - tolerance) / unit3);
|
|
21344
|
+
const last = Math.floor((range2.max + tolerance) / unit3);
|
|
21345
|
+
const count = Math.min(Math.max(last - first2 + 1, 0), 2e3);
|
|
21346
|
+
return Array.from({ length: count }, (_, index2) => (first2 + index2) * unit3);
|
|
21347
|
+
}
|
|
21348
|
+
function generateAxisTicks(range2, axis, defaultIntervals) {
|
|
21349
|
+
if (range2.logScale && range2.logBase) {
|
|
21350
|
+
return generateLogTicks(range2);
|
|
21351
|
+
}
|
|
21352
|
+
const explicit = generateIntervalTicks(range2, axis?.majorUnit ?? 0);
|
|
21353
|
+
if (explicit.length > 0) {
|
|
21354
|
+
return explicit;
|
|
21355
|
+
}
|
|
21356
|
+
const automatic = generateIntervalTicks(range2, range2.majorUnit ?? 0);
|
|
21357
|
+
if (automatic.length > 0) {
|
|
21358
|
+
return automatic;
|
|
21359
|
+
}
|
|
21360
|
+
return Array.from(
|
|
21361
|
+
{ length: defaultIntervals + 1 },
|
|
21362
|
+
(_, index2) => range2.min + range2.span / defaultIntervals * index2
|
|
21363
|
+
);
|
|
21364
|
+
}
|
|
21365
|
+
function generateMinorAxisTicks(range2, axis) {
|
|
21366
|
+
const minor = generateIntervalTicks(range2, axis?.minorUnit ?? 0);
|
|
21367
|
+
if (minor.length === 0) {
|
|
21368
|
+
return [];
|
|
21369
|
+
}
|
|
21370
|
+
const majorUnit = axis?.majorUnit;
|
|
21371
|
+
if (!majorUnit || !Number.isFinite(majorUnit) || majorUnit <= 0) {
|
|
21372
|
+
return minor;
|
|
21373
|
+
}
|
|
21374
|
+
const tolerance = Math.max(1, Math.abs(range2.min), Math.abs(range2.max)) * 1e-10;
|
|
21375
|
+
return minor.filter(
|
|
21376
|
+
(value3) => Math.abs(value3 / majorUnit - Math.round(value3 / majorUnit)) > tolerance
|
|
21377
|
+
);
|
|
21378
|
+
}
|
|
21379
|
+
|
|
21380
|
+
// chart/render/chart-view-axes.ts
|
|
21381
|
+
function options(axis) {
|
|
21382
|
+
return {
|
|
21383
|
+
...axis.scaling,
|
|
21384
|
+
...axis.scaling.logBase === void 0 ? {} : { logScale: true },
|
|
21385
|
+
...axis.majorUnit === void 0 ? {} : { majorUnit: axis.majorUnit },
|
|
21386
|
+
...axis.minorUnit === void 0 ? {} : { minorUnit: axis.minorUnit }
|
|
21387
|
+
};
|
|
21388
|
+
}
|
|
21389
|
+
function applyChartAxes(model, chart, color2) {
|
|
21390
|
+
if (!chart.axes?.length) return;
|
|
21391
|
+
const axes = chart.axes;
|
|
21392
|
+
const linked = axes.filter((axis) => axis.id !== void 0 && chart.axisIds?.includes(axis.id));
|
|
21393
|
+
const candidates = linked.length ? linked : axes;
|
|
21394
|
+
const xy = model.type === "scatter" || model.type === "bubble";
|
|
21395
|
+
const value3 = candidates.find((axis) => axis.kind === "val" && !["b", "t"].includes(axis.position ?? "")) ?? candidates.find((axis) => axis.kind === "val");
|
|
21396
|
+
const category = candidates.find(
|
|
21397
|
+
(axis) => xy ? axis.kind === "val" && axis !== value3 : axis.kind === "cat" || axis.kind === "date"
|
|
21398
|
+
);
|
|
21399
|
+
const secondary = axes.find((axis) => axis.kind === "val" && axis !== value3 && axis !== category);
|
|
21400
|
+
const paint2 = (shape) => {
|
|
21401
|
+
const ln = shape?.line;
|
|
21402
|
+
const fill = ln?.fill;
|
|
21403
|
+
const resolved = fill?.kind === "none" ? "none" : color2(fill?.kind === "solid" ? fill.color : void 0);
|
|
21404
|
+
return {
|
|
21405
|
+
...resolved === void 0 ? {} : { color: resolved },
|
|
21406
|
+
...ln?.widthEmu === void 0 ? {} : { width: ln.widthEmu / EMU_PER_PIXEL },
|
|
21407
|
+
...ln?.dash === void 0 ? {} : { dash: ln.dash }
|
|
21408
|
+
};
|
|
21409
|
+
};
|
|
21410
|
+
const bind = (axis, scale, values) => {
|
|
21411
|
+
const opts = options(axis);
|
|
21412
|
+
const automatic = opts.logScale ? computeLogValueRange(
|
|
21413
|
+
[{ values: values ?? [] }],
|
|
21414
|
+
opts.logBase && Number.isFinite(opts.logBase) && opts.logBase > 1 ? opts.logBase : 10
|
|
21415
|
+
) : {
|
|
21416
|
+
min: scale?.min ?? 0,
|
|
21417
|
+
max: scale?.max ?? 1,
|
|
21418
|
+
span: (scale?.max ?? 1) - (scale?.min ?? 0),
|
|
21419
|
+
...scale ? { majorUnit: scale.majorUnit } : {}
|
|
21420
|
+
};
|
|
21421
|
+
const logBase = automatic.logBase;
|
|
21422
|
+
const range2 = withAxisBounds(automatic, opts, logBase);
|
|
21423
|
+
if (scale) {
|
|
21424
|
+
scale.min = range2.min;
|
|
21425
|
+
scale.max = range2.max;
|
|
21426
|
+
scale.ticks = generateAxisTicks(range2, opts, 5);
|
|
21427
|
+
}
|
|
21428
|
+
return {
|
|
21429
|
+
source: axis,
|
|
21430
|
+
range: range2,
|
|
21431
|
+
minorTicks: generateMinorAxisTicks(range2, opts),
|
|
21432
|
+
line: paint2(axis.spPr),
|
|
21433
|
+
majorGrid: paint2(axis.majorGridlinesSpPr),
|
|
21434
|
+
minorGrid: paint2(axis.minorGridlinesSpPr)
|
|
21435
|
+
};
|
|
21436
|
+
};
|
|
21437
|
+
const out = {};
|
|
21438
|
+
if (value3)
|
|
21439
|
+
out.value = bind(
|
|
21440
|
+
value3,
|
|
21441
|
+
model.valueAxis,
|
|
21442
|
+
[
|
|
21443
|
+
...model.series,
|
|
21444
|
+
...model.extraGroups?.filter((g) => !g.secondary).flatMap((g) => g.series) ?? []
|
|
21445
|
+
].flatMap((s) => s.values)
|
|
21446
|
+
);
|
|
21447
|
+
if (category)
|
|
21448
|
+
out.category = bind(
|
|
21449
|
+
category,
|
|
21450
|
+
model.xAxis ?? {
|
|
21451
|
+
min: 0,
|
|
21452
|
+
max: Math.max(1, model.categories.length - 1),
|
|
21453
|
+
majorUnit: 1,
|
|
21454
|
+
ticks: []
|
|
21455
|
+
},
|
|
21456
|
+
model.series.flatMap((s) => s.xValues ?? [])
|
|
21457
|
+
);
|
|
21458
|
+
if (secondary)
|
|
21459
|
+
out.secondary = bind(
|
|
21460
|
+
secondary,
|
|
21461
|
+
model.secondaryAxis,
|
|
21462
|
+
model.extraGroups?.filter((g) => g.secondary).flatMap((g) => g.series.flatMap((s) => s.values))
|
|
21463
|
+
);
|
|
21464
|
+
model.axes = out;
|
|
21465
|
+
}
|
|
21466
|
+
|
|
21203
21467
|
// chart/hierarchy.ts
|
|
21204
21468
|
function normalizeLevels(levels, pointCount) {
|
|
21205
21469
|
return levels.map((level2) => {
|
|
@@ -21422,15 +21686,15 @@ function seriesName(series, index2, evaluateRef2) {
|
|
|
21422
21686
|
const fromRef = resolveRef(series.nameRef, evaluateRef2)?.map(toText).filter((t) => t !== "").join(" ");
|
|
21423
21687
|
return fromRef || series.name || `Series${index2 + 1}`;
|
|
21424
21688
|
}
|
|
21425
|
-
function seriesContext(chart, theme2,
|
|
21689
|
+
function seriesContext(chart, theme2, options2) {
|
|
21426
21690
|
const scheme = chartColorScheme(theme2);
|
|
21427
21691
|
const resolver = { scheme: (name3) => scheme[name3] };
|
|
21428
21692
|
return {
|
|
21429
21693
|
theme: theme2,
|
|
21430
21694
|
scheme,
|
|
21431
21695
|
palette: chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette),
|
|
21432
|
-
evaluateRef:
|
|
21433
|
-
seriesColor:
|
|
21696
|
+
evaluateRef: options2.evaluateRef ?? (() => []),
|
|
21697
|
+
seriesColor: options2.seriesColor,
|
|
21434
21698
|
drawingColor: (color2) => color2 && drawingColorCss(resolveDrawingColor(color2, resolver, { transformOrder: "document" })),
|
|
21435
21699
|
gradient: (fill) => fill?.kind === "gradient" ? resolveChartGradient(
|
|
21436
21700
|
fill,
|
|
@@ -21456,7 +21720,11 @@ function seriesView(ctx, s, index2, total, categoriesOf) {
|
|
|
21456
21720
|
})
|
|
21457
21721
|
);
|
|
21458
21722
|
if (Object.keys(points2).length) view.pointGradients = points2;
|
|
21459
|
-
Object.assign(
|
|
21723
|
+
Object.assign(
|
|
21724
|
+
view,
|
|
21725
|
+
analysisView(s, color2, ctx.drawingColor),
|
|
21726
|
+
seriesMarkerViews(s, ctx.drawingColor)
|
|
21727
|
+
);
|
|
21460
21728
|
return view;
|
|
21461
21729
|
}
|
|
21462
21730
|
|
|
@@ -21721,14 +21989,14 @@ function scottBinCount(values, min, max) {
|
|
|
21721
21989
|
const width = 3.49 * sd * values.length ** (-1 / 3);
|
|
21722
21990
|
return Math.max(1, Math.ceil((max - min) / width));
|
|
21723
21991
|
}
|
|
21724
|
-
function computeHistogramBins(values,
|
|
21725
|
-
const closed =
|
|
21992
|
+
function computeHistogramBins(values, options2, format5 = String) {
|
|
21993
|
+
const closed = options2.intervalClosed ?? "l";
|
|
21726
21994
|
const finite5 = values.map((value3, sourceIndex) => ({ value: value3, sourceIndex })).filter((item) => Number.isFinite(item.value));
|
|
21727
21995
|
if (finite5.length === 0) {
|
|
21728
21996
|
return [];
|
|
21729
21997
|
}
|
|
21730
|
-
const underflow = typeof
|
|
21731
|
-
const overflow = typeof
|
|
21998
|
+
const underflow = typeof options2.underflow === "number" ? options2.underflow : void 0;
|
|
21999
|
+
const overflow = typeof options2.overflow === "number" ? options2.overflow : void 0;
|
|
21732
22000
|
const under = underflow === void 0 ? [] : finite5.filter(
|
|
21733
22001
|
(item) => closed === "r" ? item.value <= underflow : item.value < underflow
|
|
21734
22002
|
);
|
|
@@ -21745,8 +22013,8 @@ function computeHistogramBins(values, options, format5 = String) {
|
|
|
21745
22013
|
if (regular.length > 0) {
|
|
21746
22014
|
const min = Math.min(...regular.map((item) => item.value));
|
|
21747
22015
|
const max = Math.max(...regular.map((item) => item.value));
|
|
21748
|
-
const requestedSize =
|
|
21749
|
-
const requestedCount =
|
|
22016
|
+
const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
|
|
22017
|
+
const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
|
|
21750
22018
|
const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
|
|
21751
22019
|
const count = requestedSize ? Math.max(
|
|
21752
22020
|
closed === "l" ? Math.floor((max - start) / requestedSize) + 1 : Math.ceil((max - start) / requestedSize),
|
|
@@ -21797,9 +22065,9 @@ function aggregateByCategory(values, rawCategories) {
|
|
|
21797
22065
|
}
|
|
21798
22066
|
|
|
21799
22067
|
// chart/waterfall.ts
|
|
21800
|
-
function buildWaterfallSteps(values,
|
|
22068
|
+
function buildWaterfallSteps(values, options2) {
|
|
21801
22069
|
const subtotalIndices = new Set(
|
|
21802
|
-
|
|
22070
|
+
options2?.subtotalIndices ?? (values.length > 0 ? [values.length - 1] : [])
|
|
21803
22071
|
);
|
|
21804
22072
|
const steps = [];
|
|
21805
22073
|
let runningTotal = 0;
|
|
@@ -21883,11 +22151,11 @@ function histogramView(chart, model) {
|
|
|
21883
22151
|
const first2 = model.series[0];
|
|
21884
22152
|
if (!first2) return;
|
|
21885
22153
|
const raw = first2.values.map((v) => v ?? Number.NaN);
|
|
21886
|
-
const
|
|
21887
|
-
const bins =
|
|
22154
|
+
const options2 = chart.histogram ?? {};
|
|
22155
|
+
const bins = options2.aggregateByCategory ? aggregateByCategory(
|
|
21888
22156
|
first2.values.map((v) => v ?? 0),
|
|
21889
22157
|
model.categories
|
|
21890
|
-
) : computeHistogramBins(raw,
|
|
22158
|
+
) : computeHistogramBins(raw, options2, formatAxisValue);
|
|
21891
22159
|
model.categories = bins.map((bin) => bin.label);
|
|
21892
22160
|
first2.values = bins.map((bin) => bin.value);
|
|
21893
22161
|
model.barGapWidth = 0;
|
|
@@ -21911,11 +22179,11 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
21911
22179
|
"treemap",
|
|
21912
22180
|
"sunburst"
|
|
21913
22181
|
]);
|
|
21914
|
-
function chartSummaryView(chart, theme2,
|
|
22182
|
+
function chartSummaryView(chart, theme2, options2 = {}) {
|
|
21915
22183
|
const type = chart.chartType;
|
|
21916
22184
|
const radial = type === "pie" || type === "doughnut";
|
|
21917
22185
|
const byPoint = radial || type === "treemap" || type === "sunburst";
|
|
21918
|
-
const ctx = seriesContext(chart, theme2,
|
|
22186
|
+
const ctx = seriesContext(chart, theme2, options2);
|
|
21919
22187
|
const { palette, scheme, drawingColor: drawingColor2 } = ctx;
|
|
21920
22188
|
const grouping = chart.grouping ?? (type === "bar" || type === "column" ? "clustered" : "standard");
|
|
21921
22189
|
const rawCategories = [];
|
|
@@ -22001,6 +22269,7 @@ function chartSummaryView(chart, theme2, options = {}) {
|
|
|
22001
22269
|
else if (!byPoint) model.valueAxis = valueAxis(model);
|
|
22002
22270
|
applyDataLabels(model, chart.series, extra);
|
|
22003
22271
|
chartExtraAxes(model);
|
|
22272
|
+
applyChartAxes(model, chart, ctx.drawingColor);
|
|
22004
22273
|
return model;
|
|
22005
22274
|
}
|
|
22006
22275
|
|
|
@@ -22095,7 +22364,7 @@ async function readEmbeddedChartObject(pkg, sourcePart, foreignData, report) {
|
|
|
22095
22364
|
}
|
|
22096
22365
|
|
|
22097
22366
|
// visio/prepare-images.ts
|
|
22098
|
-
async function prepareImages(shapes, pkg, sourcePart, report,
|
|
22367
|
+
async function prepareImages(shapes, pkg, sourcePart, report, options2, converter) {
|
|
22099
22368
|
for (const shape of shapes) {
|
|
22100
22369
|
if (shape.deleted) continue;
|
|
22101
22370
|
const localReport = (code, message, extra) => report(code, message, { part: sourcePart, shapeId: shape.id, ...extra });
|
|
@@ -22123,12 +22392,12 @@ async function prepareImages(shapes, pkg, sourcePart, report, options, converter
|
|
|
22123
22392
|
sourcePart,
|
|
22124
22393
|
shape.foreignData,
|
|
22125
22394
|
localReport,
|
|
22126
|
-
|
|
22395
|
+
options2
|
|
22127
22396
|
);
|
|
22128
22397
|
if (image) shape.image = image;
|
|
22129
22398
|
}
|
|
22130
22399
|
}
|
|
22131
|
-
await prepareImages(shape.children, pkg, sourcePart, report,
|
|
22400
|
+
await prepareImages(shape.children, pkg, sourcePart, report, options2, converter);
|
|
22132
22401
|
}
|
|
22133
22402
|
}
|
|
22134
22403
|
|
|
@@ -25237,8 +25506,8 @@ function diagnosticCollector(maxCount) {
|
|
|
25237
25506
|
}
|
|
25238
25507
|
|
|
25239
25508
|
// visio/shape-metadata.ts
|
|
25240
|
-
function createMetadataBudget(
|
|
25241
|
-
const maxRows =
|
|
25509
|
+
function createMetadataBudget(options2 = {}) {
|
|
25510
|
+
const maxRows = options2.maxRows ?? 1e5, maxCharacters = options2.maxCharacters ?? 5e6;
|
|
25242
25511
|
if (![maxRows, maxCharacters].every((v) => Number.isSafeInteger(v) && v > 0))
|
|
25243
25512
|
throw new VisioPackageError("INVALID_LIMIT", "Metadata limits must be positive safe integers.");
|
|
25244
25513
|
let rows = 0, characters = 0;
|
|
@@ -26478,21 +26747,21 @@ function option(value3, fallback) {
|
|
|
26478
26747
|
throw new VisioPackageError("INVALID_LIMIT", "Parser limits must be positive safe integers.");
|
|
26479
26748
|
return value3;
|
|
26480
26749
|
}
|
|
26481
|
-
async function parseVsdx(input,
|
|
26482
|
-
const deadline = Date.now() + (
|
|
26750
|
+
async function parseVsdx(input, options2 = {}) {
|
|
26751
|
+
const deadline = Date.now() + (options2.limits?.maxRuntimeMs ?? 1e4);
|
|
26483
26752
|
const checkTime = () => {
|
|
26484
26753
|
if (Date.now() >= deadline)
|
|
26485
26754
|
throw new VisioPackageError("LIMIT_RUNTIME", "Visio parsing deadline exceeded.");
|
|
26486
26755
|
};
|
|
26487
|
-
const maxShapes = option(
|
|
26488
|
-
const maxCurveWork = option(
|
|
26756
|
+
const maxShapes = option(options2.maxShapes, 25e3), maxShapeDepth = option(options2.maxShapeDepth, 64);
|
|
26757
|
+
const maxCurveWork = option(options2.maxCurveWork, 2e7);
|
|
26489
26758
|
let curveWork = 0;
|
|
26490
|
-
const maxGeometry = option(
|
|
26491
|
-
const maxDiagnostics = option(
|
|
26492
|
-
const maxRuns = option(
|
|
26759
|
+
const maxGeometry = option(options2.maxGeometryCommands, 5e5), maxText = option(options2.maxTextCharacters, 5e6);
|
|
26760
|
+
const maxDiagnostics = option(options2.maxDiagnostics, 2e3);
|
|
26761
|
+
const maxRuns = option(options2.maxTextRuns, 1e5), maxParagraphs = option(options2.maxParagraphs, 5e4);
|
|
26493
26762
|
const diagnosticState = diagnosticCollector(maxDiagnostics);
|
|
26494
26763
|
const report = diagnosticState.report;
|
|
26495
|
-
const pkg = await VisioPackage.open(input,
|
|
26764
|
+
const pkg = await VisioPackage.open(input, options2.limits);
|
|
26496
26765
|
const types = await pkg.readXml("[Content_Types].xml", "Types");
|
|
26497
26766
|
if (types.namespaceURI !== "http://schemas.openxmlformats.org/package/2006/content-types")
|
|
26498
26767
|
throw new VisioPackageError("INVALID_CONTENT_TYPES", "Invalid content type namespace.");
|
|
@@ -26502,7 +26771,7 @@ async function parseVsdx(input, options = {}) {
|
|
|
26502
26771
|
const documentType = elements(types).find(
|
|
26503
26772
|
(node3) => node3.localName === "Override" && attribute2(node3, "PartName") === `/${documentPart2}`
|
|
26504
26773
|
)?.getAttribute("ContentType");
|
|
26505
|
-
if (documentType !== "application/vnd.ms-visio.drawing.main+xml" && !(
|
|
26774
|
+
if (documentType !== "application/vnd.ms-visio.drawing.main+xml" && !(options2.stencil && documentType && STENCIL_MAIN_TYPES.has(documentType)))
|
|
26506
26775
|
throw new VisioPackageError(
|
|
26507
26776
|
"UNSUPPORTED_FORMAT",
|
|
26508
26777
|
"Only VSDX drawing packages are supported; VSD, VDX, VSDM and templates are not supported."
|
|
@@ -26575,8 +26844,8 @@ async function parseVsdx(input, options = {}) {
|
|
|
26575
26844
|
pkg,
|
|
26576
26845
|
part,
|
|
26577
26846
|
report,
|
|
26578
|
-
|
|
26579
|
-
|
|
26847
|
+
options2.images,
|
|
26848
|
+
options2.metafileConverter
|
|
26580
26849
|
);
|
|
26581
26850
|
masters.set(id3, masterShapes2);
|
|
26582
26851
|
masterRecords.push({ id: id3, node: master2, shapes: masterShapes2 });
|
|
@@ -26584,7 +26853,7 @@ async function parseVsdx(input, options = {}) {
|
|
|
26584
26853
|
}
|
|
26585
26854
|
let geometryCount = 0, textCount = 0, expansionCount = 0, textRuns = 0, paragraphCount = 0;
|
|
26586
26855
|
const context = {
|
|
26587
|
-
metadataBudget: createMetadataBudget(
|
|
26856
|
+
metadataBudget: createMetadataBudget(options2.metadata),
|
|
26588
26857
|
layerBudget: createLayerBudget(),
|
|
26589
26858
|
masters,
|
|
26590
26859
|
layers: /* @__PURE__ */ new Map(),
|
|
@@ -26636,11 +26905,11 @@ async function parseVsdx(input, options = {}) {
|
|
|
26636
26905
|
}
|
|
26637
26906
|
};
|
|
26638
26907
|
const documentMasters = listVisioMasters(masterRecords, context, {
|
|
26639
|
-
metadataBudget: createMetadataBudget(
|
|
26908
|
+
metadataBudget: createMetadataBudget(options2.metadata),
|
|
26640
26909
|
layerBudget: createLayerBudget()
|
|
26641
26910
|
});
|
|
26642
|
-
const pagesPart = await related(pkg, documentPart2, "pages", !
|
|
26643
|
-
if (!pagesPart && !
|
|
26911
|
+
const pagesPart = await related(pkg, documentPart2, "pages", !options2.stencil);
|
|
26912
|
+
if (!pagesPart && !options2.stencil)
|
|
26644
26913
|
throw new VisioPackageError("INVALID_DOCUMENT", "Missing Visio pages part.");
|
|
26645
26914
|
const pages = [], pageIds2 = /* @__PURE__ */ new Set();
|
|
26646
26915
|
const comments = [];
|
|
@@ -26694,8 +26963,8 @@ async function parseVsdx(input, options = {}) {
|
|
|
26694
26963
|
pkg,
|
|
26695
26964
|
part,
|
|
26696
26965
|
localReport,
|
|
26697
|
-
|
|
26698
|
-
|
|
26966
|
+
options2.images,
|
|
26967
|
+
options2.metafileConverter
|
|
26699
26968
|
);
|
|
26700
26969
|
const shapes = normalizeShapes(rawShapes, context);
|
|
26701
26970
|
normalizeVisioPageGeometry(shapes, drawingToPageScale, checkTime);
|
|
@@ -27489,9 +27758,9 @@ function snapshotStencilMasterDrop(edit) {
|
|
|
27489
27758
|
y: edit.y
|
|
27490
27759
|
};
|
|
27491
27760
|
}
|
|
27492
|
-
async function editVsdxMasterDrops(source, commands,
|
|
27493
|
-
const limits = { ...DEFAULTS, ...
|
|
27494
|
-
const maxOutput =
|
|
27761
|
+
async function editVsdxMasterDrops(source, commands, options2, lone, apply5) {
|
|
27762
|
+
const limits = { ...DEFAULTS, ...options2.limits };
|
|
27763
|
+
const maxOutput = options2.maxOutputBytes ?? limits.maxInputBytes;
|
|
27495
27764
|
const deadline = Date.now() + limits.maxRuntimeMs;
|
|
27496
27765
|
const check = () => {
|
|
27497
27766
|
if (Date.now() >= deadline) fail("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|
|
@@ -29522,13 +29791,13 @@ function unique(items, key2, what) {
|
|
|
29522
29791
|
return result2;
|
|
29523
29792
|
}
|
|
29524
29793
|
var cellMap2 = (parent) => unique(children2(parent, "Cell"), (cell) => attribute2(cell, "N") ?? "", "cell");
|
|
29525
|
-
function instanceSheet(instance, template,
|
|
29794
|
+
function instanceSheet(instance, template, options2 = {}) {
|
|
29526
29795
|
for (const node3 of [instance, template]) {
|
|
29527
29796
|
const type = attribute2(node3, "Type");
|
|
29528
|
-
if (!(
|
|
29797
|
+
if (!(options2.group ? ["Shape", "Group", void 0] : ["Shape", void 0]).includes(type) || !options2.group && children2(node3, "Shapes").length > 0 || children2(node3, "ForeignData").length || deleted2(node3))
|
|
29529
29798
|
fail(
|
|
29530
29799
|
"UNSUPPORTED_INSTANCE_EDIT",
|
|
29531
|
-
|
|
29800
|
+
options2.group ? "A stencil shape that holds a picture or a deleted part cannot be changed." : "Only stencil shapes made of one plain shape can be changed; grouped, picture and deleted ones cannot."
|
|
29532
29801
|
);
|
|
29533
29802
|
}
|
|
29534
29803
|
if (template.hasAttribute("Master") || template.hasAttribute("MasterShape"))
|
|
@@ -29607,7 +29876,7 @@ function effectiveFormula(cell) {
|
|
|
29607
29876
|
return own === "Inh" ? executableCellFormula(attribute2(cell.inherited, "F")) : executableCellFormula(own);
|
|
29608
29877
|
}
|
|
29609
29878
|
var AFTER_SECTIONS = ["Text", "Data1", "Data2", "Data3", "ForeignData", "Shapes"];
|
|
29610
|
-
function writeInstanceCell(sheet, cell, value3,
|
|
29879
|
+
function writeInstanceCell(sheet, cell, value3, options2 = {}) {
|
|
29611
29880
|
const { instance } = sheet;
|
|
29612
29881
|
const create2 = (name3) => instance.ownerDocument.createElementNS(instance.namespaceURI, name3);
|
|
29613
29882
|
let node3 = cell.local;
|
|
@@ -29653,9 +29922,9 @@ function writeInstanceCell(sheet, cell, value3, options = {}) {
|
|
|
29653
29922
|
}
|
|
29654
29923
|
node3.setAttribute("V", value3);
|
|
29655
29924
|
node3.removeAttribute("E");
|
|
29656
|
-
const unit3 =
|
|
29657
|
-
if (unit3 !== void 0 && (created ||
|
|
29658
|
-
if (
|
|
29925
|
+
const unit3 = options2.unit ?? attribute2(cell.inherited, "U");
|
|
29926
|
+
if (unit3 !== void 0 && (created || options2.unit !== void 0)) node3.setAttribute("U", unit3);
|
|
29927
|
+
if (options2.formula) node3.setAttribute("F", options2.formula);
|
|
29659
29928
|
else node3.removeAttribute("F");
|
|
29660
29929
|
return node3;
|
|
29661
29930
|
}
|
|
@@ -30964,7 +31233,7 @@ function proveConnectorShape(shape, route = routeOf(shape)) {
|
|
|
30964
31233
|
"Only right-angle and curved connectors drawn here can be rerouted."
|
|
30965
31234
|
);
|
|
30966
31235
|
}
|
|
30967
|
-
function rerouteConnector(roots2, pageId2, glue, check,
|
|
31236
|
+
function rerouteConnector(roots2, pageId2, glue, check, options2 = {}) {
|
|
30968
31237
|
const root2 = roots2.get(pageId2);
|
|
30969
31238
|
const shape = glue.shape;
|
|
30970
31239
|
const stencil = isStencilConnector(shape);
|
|
@@ -30976,7 +31245,7 @@ function rerouteConnector(roots2, pageId2, glue, check, options = {}) {
|
|
|
30976
31245
|
if (target2) return glueSites(root2, target2);
|
|
30977
31246
|
return [
|
|
30978
31247
|
{
|
|
30979
|
-
point:
|
|
31248
|
+
point: options2.free?.[end] ?? {
|
|
30980
31249
|
x: numeric(local.get(`${prefix(end)}X`)),
|
|
30981
31250
|
y: numeric(local.get(`${prefix(end)}Y`))
|
|
30982
31251
|
}
|
|
@@ -30985,7 +31254,7 @@ function rerouteConnector(roots2, pageId2, glue, check, options = {}) {
|
|
|
30985
31254
|
};
|
|
30986
31255
|
const chosen = chooseSites(sites("begin"), sites("end"));
|
|
30987
31256
|
if (isStencilLine(shape)) {
|
|
30988
|
-
if (
|
|
31257
|
+
if (options2.route && options2.route !== "straight")
|
|
30989
31258
|
fail(
|
|
30990
31259
|
"UNSUPPORTED_GEOMETRY_EDIT",
|
|
30991
31260
|
"This connector is a straight line from a stencil; only Visio's Dynamic connector can be restyled."
|
|
@@ -31004,12 +31273,12 @@ function rerouteConnector(roots2, pageId2, glue, check, options = {}) {
|
|
|
31004
31273
|
const target2 = glue.ends[end];
|
|
31005
31274
|
return target2 && target2.point === void 0 ? walkShape(glueBox(root2, target2.target)) : { point: sites(end)[0].point };
|
|
31006
31275
|
};
|
|
31007
|
-
const route =
|
|
31276
|
+
const route = options2.route ?? current;
|
|
31008
31277
|
if (route === "straight" && current === "straight" && ENDS.every(
|
|
31009
31278
|
(end) => sameLineCoordinate(numeric(local.get(`${prefix(end)}X`)), chosen[end].point.x) && sameLineCoordinate(numeric(local.get(`${prefix(end)}Y`)), chosen[end].point.y)
|
|
31010
31279
|
))
|
|
31011
31280
|
return [];
|
|
31012
|
-
if (
|
|
31281
|
+
if (options2.route) setRouteCells(shape, options2.route);
|
|
31013
31282
|
const obstacles = route === "right-angle" ? connectorObstacles(
|
|
31014
31283
|
root2,
|
|
31015
31284
|
/* @__PURE__ */ new Set([
|
|
@@ -31361,14 +31630,14 @@ async function measuresOwnText(root2, shapeId2, template, check) {
|
|
|
31361
31630
|
return false;
|
|
31362
31631
|
}
|
|
31363
31632
|
}
|
|
31364
|
-
async function refreshTextSizes(targets, result2,
|
|
31633
|
+
async function refreshTextSizes(targets, result2, options2, deadline) {
|
|
31365
31634
|
if (!targets.length || !result2.changedParts.length) return result2;
|
|
31366
31635
|
const check = () => {
|
|
31367
31636
|
if (Date.now() >= deadline) throw new VisioPackageError("LIMIT_RUNTIME", "Deadline exceeded.");
|
|
31368
31637
|
};
|
|
31369
31638
|
const limits = {
|
|
31370
31639
|
...DEFAULTS,
|
|
31371
|
-
...
|
|
31640
|
+
...options2.limits,
|
|
31372
31641
|
maxInputBytes: Math.max(DEFAULTS.maxInputBytes, result2.bytes.length),
|
|
31373
31642
|
maxRuntimeMs: Math.max(1, deadline - Date.now())
|
|
31374
31643
|
};
|
|
@@ -31458,7 +31727,7 @@ async function refreshTextSizes(targets, result2, options, deadline) {
|
|
|
31458
31727
|
}
|
|
31459
31728
|
const bytes = await writeEditedPackage(
|
|
31460
31729
|
parts,
|
|
31461
|
-
|
|
31730
|
+
options2.maxOutputBytes ?? limits.maxInputBytes,
|
|
31462
31731
|
deadline,
|
|
31463
31732
|
check
|
|
31464
31733
|
);
|
|
@@ -31727,14 +31996,14 @@ function cacheRows(path2) {
|
|
|
31727
31996
|
}
|
|
31728
31997
|
return rows.every((row2) => Number.isFinite(row2.x) && Number.isFinite(row2.y)) ? rows : [];
|
|
31729
31998
|
}
|
|
31730
|
-
async function refreshLineJumpCaches(pageIds2, source, result2,
|
|
31999
|
+
async function refreshLineJumpCaches(pageIds2, source, result2, options2, deadline) {
|
|
31731
32000
|
if (!pageIds2.size || !result2.changedParts.length) return result2;
|
|
31732
32001
|
const check = () => {
|
|
31733
32002
|
if (Date.now() >= deadline) fail("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|
|
31734
32003
|
};
|
|
31735
32004
|
const limits = {
|
|
31736
32005
|
...DEFAULTS,
|
|
31737
|
-
...
|
|
32006
|
+
...options2.limits,
|
|
31738
32007
|
maxRuntimeMs: Math.max(1, deadline - Date.now())
|
|
31739
32008
|
};
|
|
31740
32009
|
const { pkg, parts, pages } = await openEditablePackage(result2.bytes, limits, check);
|
|
@@ -31814,7 +32083,7 @@ async function refreshLineJumpCaches(pageIds2, source, result2, options, deadlin
|
|
|
31814
32083
|
return {
|
|
31815
32084
|
bytes: await writeEditedPackage(
|
|
31816
32085
|
parts,
|
|
31817
|
-
|
|
32086
|
+
options2.maxOutputBytes ?? limits.maxInputBytes,
|
|
31818
32087
|
deadline,
|
|
31819
32088
|
check
|
|
31820
32089
|
),
|
|
@@ -33530,12 +33799,12 @@ function resizeVisioShapeAtAnchor(roots2, document, edit, check, glueShapes = /*
|
|
|
33530
33799
|
}
|
|
33531
33800
|
|
|
33532
33801
|
// visio/edit-transform-formula.ts
|
|
33533
|
-
function editableTransformCell(roots2, edit, node3, check,
|
|
33802
|
+
function editableTransformCell(roots2, edit, node3, check, options2 = {}) {
|
|
33534
33803
|
const formula = executableCellFormula(attribute2(node3, "F"));
|
|
33535
33804
|
if (!formula || !analyzeVisioFormula(formula).references.length) return editableCell(node3);
|
|
33536
33805
|
const evaluate = createVisioCellEvaluator(
|
|
33537
|
-
indexCells(roots2, { ...
|
|
33538
|
-
{ ...
|
|
33806
|
+
indexCells(roots2, { ...options2, check }),
|
|
33807
|
+
{ ...options2, check },
|
|
33539
33808
|
true
|
|
33540
33809
|
);
|
|
33541
33810
|
editableCell(
|
|
@@ -34004,7 +34273,7 @@ async function assertDuplicateScope(pkg, pagePaths, targetPage, newIds, check, s
|
|
|
34004
34273
|
}
|
|
34005
34274
|
|
|
34006
34275
|
// visio/formula-master.ts
|
|
34007
|
-
function analyzeVisioMasterFormula(source,
|
|
34276
|
+
function analyzeVisioMasterFormula(source, options2) {
|
|
34008
34277
|
const ast = parseVisioFormula(source);
|
|
34009
34278
|
const analysis = analyzeVisioFormula(ast);
|
|
34010
34279
|
const references = /* @__PURE__ */ new Map();
|
|
@@ -34025,7 +34294,7 @@ function analyzeVisioMasterFormula(source, options) {
|
|
|
34025
34294
|
if (["TEXTWIDTH", "TEXTHEIGHT", "SHAPETEXT"].includes(node3.name)) {
|
|
34026
34295
|
const text8 = node3.args[0];
|
|
34027
34296
|
const count = node3.name === "TEXTHEIGHT" ? node3.args.length === 2 : node3.args.length === 1;
|
|
34028
|
-
local =
|
|
34297
|
+
local = options2.textFieldFree && count && text8?.kind === "reference" && text8.reference.shapeId === void 0 && text8.reference.cell.toLowerCase() === "thetext";
|
|
34029
34298
|
readsText = true;
|
|
34030
34299
|
}
|
|
34031
34300
|
if (["LUM", "HUE", "SAT"].includes(node3.name)) {
|
|
@@ -34660,16 +34929,16 @@ async function recalculatePageFormulas(pkg, pagesPart, pages, paths, dirty, chec
|
|
|
34660
34929
|
);
|
|
34661
34930
|
}
|
|
34662
34931
|
if (!needed) return;
|
|
34663
|
-
const
|
|
34932
|
+
const options2 = { check, pageContext: after };
|
|
34664
34933
|
const changed = [];
|
|
34665
|
-
for (const cell of indexCells(roots2,
|
|
34934
|
+
for (const cell of indexCells(roots2, options2).values()) {
|
|
34666
34935
|
if (!cell.node) continue;
|
|
34667
34936
|
const functions = pageFunctions(attribute2(cell.node, "F") ?? "");
|
|
34668
34937
|
const old = before.get(cell.pageId), current = after.get(cell.pageId);
|
|
34669
34938
|
if (functions.has("PAGENUMBER") && old?.pageNumber !== current.pageNumber || functions.has("PAGECOUNT") && old?.pageCount !== current.pageCount)
|
|
34670
34939
|
changed.push(cell);
|
|
34671
34940
|
}
|
|
34672
|
-
for (const id3 of recalculateVisioCells(roots2, changed,
|
|
34941
|
+
for (const id3 of recalculateVisioCells(roots2, changed, options2)) {
|
|
34673
34942
|
const root2 = roots2.get(id3);
|
|
34674
34943
|
const sheet = sheets.get(id3);
|
|
34675
34944
|
if (sheet) {
|
|
@@ -37992,14 +38261,14 @@ async function editVsdxComments(pkg, parts, pages, edits, limits, maxOutput, dea
|
|
|
37992
38261
|
}
|
|
37993
38262
|
|
|
37994
38263
|
// visio/clipboard.ts
|
|
37995
|
-
async function captureVisioClipboard(input, pageId2, shapeIds2,
|
|
38264
|
+
async function captureVisioClipboard(input, pageId2, shapeIds2, options2 = {}) {
|
|
37996
38265
|
pageId2 = clipboardId(pageId2);
|
|
37997
38266
|
if (!Array.isArray(shapeIds2) || !shapeIds2.length || shapeIds2.length > 1e3)
|
|
37998
38267
|
fail("INVALID_CLIPBOARD", "Capture requires one to 1000 selected shapes.");
|
|
37999
38268
|
const selected2 = shapeIds2.map(clipboardId);
|
|
38000
38269
|
if (new Set(selected2).size !== selected2.length)
|
|
38001
38270
|
fail("INVALID_CLIPBOARD", "Capture selection must be unique.");
|
|
38002
|
-
const limits = { ...DEFAULTS, ...
|
|
38271
|
+
const limits = { ...DEFAULTS, ...options2.limits };
|
|
38003
38272
|
for (const value3 of Object.values(limits))
|
|
38004
38273
|
if (!Number.isSafeInteger(value3) || value3 <= 0)
|
|
38005
38274
|
fail("INVALID_LIMITS", "Capture limits require positive safe integers.");
|
|
@@ -38086,13 +38355,13 @@ async function retarget(clipboard, bytes, pageId2, limits) {
|
|
|
38086
38355
|
fail("UNSUPPORTED_SUBPROCESS", "The new page does not share the source page settings.");
|
|
38087
38356
|
return { ...clipboard, pageContext: target2.xml };
|
|
38088
38357
|
}
|
|
38089
|
-
async function editVsdxSubprocess(source, edit,
|
|
38090
|
-
const limits = { ...DEFAULTS, ...
|
|
38358
|
+
async function editVsdxSubprocess(source, edit, options2) {
|
|
38359
|
+
const limits = { ...DEFAULTS, ...options2.limits };
|
|
38091
38360
|
const deadline = Date.now() + limits.maxRuntimeMs;
|
|
38092
38361
|
const remaining = () => {
|
|
38093
38362
|
const time = deadline - Date.now();
|
|
38094
38363
|
if (time <= 0) fail("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|
|
38095
|
-
return { ...
|
|
38364
|
+
return { ...options2, limits: { ...options2.limits, maxRuntimeMs: time } };
|
|
38096
38365
|
};
|
|
38097
38366
|
const changed = /* @__PURE__ */ new Set();
|
|
38098
38367
|
const diagnostics = /* @__PURE__ */ new Map();
|
|
@@ -38679,7 +38948,7 @@ function positive2(value3) {
|
|
|
38679
38948
|
fail("INVALID_LIMITS", "Edit limits must be positive safe integers.");
|
|
38680
38949
|
return value3;
|
|
38681
38950
|
}
|
|
38682
|
-
async function editVsdx(input, edits,
|
|
38951
|
+
async function editVsdx(input, edits, options2 = {}) {
|
|
38683
38952
|
const clock = {
|
|
38684
38953
|
deadline: 0,
|
|
38685
38954
|
autoSize: /* @__PURE__ */ new Set(),
|
|
@@ -38687,36 +38956,36 @@ async function editVsdx(input, edits, options = {}) {
|
|
|
38687
38956
|
jumpPages: /* @__PURE__ */ new Set(),
|
|
38688
38957
|
jumpSource: void 0
|
|
38689
38958
|
};
|
|
38690
|
-
const edited = await editVsdxTransaction(input, edits,
|
|
38691
|
-
const resized = await refreshTextSizes(clock.textSizes, edited,
|
|
38959
|
+
const edited = await editVsdxTransaction(input, edits, options2, clock);
|
|
38960
|
+
const resized = await refreshTextSizes(clock.textSizes, edited, options2, clock.deadline);
|
|
38692
38961
|
const result2 = await refreshLineJumpCaches(
|
|
38693
38962
|
clock.jumpPages,
|
|
38694
38963
|
clock.jumpSource,
|
|
38695
38964
|
resized,
|
|
38696
|
-
|
|
38965
|
+
options2,
|
|
38697
38966
|
clock.deadline
|
|
38698
38967
|
);
|
|
38699
38968
|
return growAutoSizePages(
|
|
38700
38969
|
clock.autoSize,
|
|
38701
38970
|
result2,
|
|
38702
38971
|
(bytes, growth) => editVsdxTransaction(bytes, growth, {
|
|
38703
|
-
...
|
|
38704
|
-
limits: { ...
|
|
38972
|
+
...options2,
|
|
38973
|
+
limits: { ...options2.limits, maxRuntimeMs: Math.max(1, clock.deadline - Date.now()) }
|
|
38705
38974
|
})
|
|
38706
38975
|
);
|
|
38707
38976
|
}
|
|
38708
|
-
async function editVsdxTransaction(input, edits,
|
|
38977
|
+
async function editVsdxTransaction(input, edits, options2, clock = {
|
|
38709
38978
|
deadline: 0,
|
|
38710
38979
|
autoSize: /* @__PURE__ */ new Set(),
|
|
38711
38980
|
textSizes: [],
|
|
38712
38981
|
jumpPages: /* @__PURE__ */ new Set(),
|
|
38713
38982
|
jumpSource: void 0
|
|
38714
38983
|
}) {
|
|
38715
|
-
const limits = { ...DEFAULTS, ...
|
|
38984
|
+
const limits = { ...DEFAULTS, ...options2.limits };
|
|
38716
38985
|
for (const value3 of Object.values(limits)) positive2(value3);
|
|
38717
|
-
const maxEdits = positive2(
|
|
38718
|
-
const maxText = positive2(
|
|
38719
|
-
const maxOutput = positive2(
|
|
38986
|
+
const maxEdits = positive2(options2.maxEdits ?? 1e3);
|
|
38987
|
+
const maxText = positive2(options2.maxTextCharacters ?? 1e6);
|
|
38988
|
+
const maxOutput = positive2(options2.maxOutputBytes ?? limits.maxInputBytes);
|
|
38720
38989
|
const deadline = Date.now() + limits.maxRuntimeMs;
|
|
38721
38990
|
clock.deadline = deadline;
|
|
38722
38991
|
const check = () => {
|
|
@@ -38735,13 +39004,13 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
38735
39004
|
if (subprocess) {
|
|
38736
39005
|
if (allCommands.length !== 1)
|
|
38737
39006
|
fail("EDIT_MIXED_SUBPROCESS_TRANSACTION", "A subprocess requires its own transaction.");
|
|
38738
|
-
return editVsdxSubprocess(original, subprocess,
|
|
39007
|
+
return editVsdxSubprocess(original, subprocess, options2);
|
|
38739
39008
|
}
|
|
38740
39009
|
if (allCommands.some(isVisioMasterDrop))
|
|
38741
39010
|
return editVsdxMasterDrops(
|
|
38742
39011
|
original,
|
|
38743
39012
|
allCommands,
|
|
38744
|
-
|
|
39013
|
+
options2,
|
|
38745
39014
|
async (bytes2, instance, info) => {
|
|
38746
39015
|
const opened = await openEditablePackage(bytes2, limits, check);
|
|
38747
39016
|
return editVsdxMasterInstance(
|
|
@@ -38756,7 +39025,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
38756
39025
|
info
|
|
38757
39026
|
);
|
|
38758
39027
|
},
|
|
38759
|
-
(bytes2, rest) => editVsdx(bytes2, rest,
|
|
39028
|
+
(bytes2, rest) => editVsdx(bytes2, rest, options2)
|
|
38760
39029
|
);
|
|
38761
39030
|
const { pkg, parts, pages } = await openEditablePackage(original, limits, check);
|
|
38762
39031
|
const builtIn = await changeStencilShapeToBuiltIn(
|
|
@@ -38765,7 +39034,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
38765
39034
|
pages,
|
|
38766
39035
|
allCommands,
|
|
38767
39036
|
{ limits, maxOutput, deadline, check },
|
|
38768
|
-
(bytes2, edits2) => editVsdx(bytes2, edits2,
|
|
39037
|
+
(bytes2, edits2) => editVsdx(bytes2, edits2, options2)
|
|
38769
39038
|
);
|
|
38770
39039
|
if (builtIn) return builtIn;
|
|
38771
39040
|
if (allCommands.some(isVisioCommentEdit)) {
|
|
@@ -38848,8 +39117,8 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
38848
39117
|
check
|
|
38849
39118
|
);
|
|
38850
39119
|
const moved = await editVsdxTransaction(resized.bytes, commands, {
|
|
38851
|
-
...
|
|
38852
|
-
limits: { ...
|
|
39120
|
+
...options2,
|
|
39121
|
+
limits: { ...options2.limits, maxRuntimeMs: Math.max(1, deadline - Date.now()) }
|
|
38853
39122
|
});
|
|
38854
39123
|
return {
|
|
38855
39124
|
bytes: moved.bytes,
|
|
@@ -39291,8 +39560,8 @@ function documentPart() {
|
|
|
39291
39560
|
});
|
|
39292
39561
|
return document;
|
|
39293
39562
|
}
|
|
39294
|
-
async function createVsdx(
|
|
39295
|
-
const width =
|
|
39563
|
+
async function createVsdx(options2 = {}) {
|
|
39564
|
+
const width = options2.width ?? 8.5, height = options2.height ?? 11;
|
|
39296
39565
|
if (![width, height].every(
|
|
39297
39566
|
(value3) => typeof value3 === "number" && Number.isFinite(value3) && value3 > 0 && value3 <= 1e6
|
|
39298
39567
|
))
|
|
@@ -39365,7 +39634,7 @@ async function createVsdx(options = {}) {
|
|
|
39365
39634
|
Page: "0",
|
|
39366
39635
|
ViewScale: "-1"
|
|
39367
39636
|
});
|
|
39368
|
-
const stencils = [...new Set(
|
|
39637
|
+
const stencils = [...new Set(options2.stencils ?? [])];
|
|
39369
39638
|
if (stencils.some((id3) => !Object.hasOwn(VISIO_STENCIL_FILES, id3)))
|
|
39370
39639
|
fail("INVALID_EDIT", "Unknown built-in stencil.");
|
|
39371
39640
|
stencils.forEach((id3, index2) => {
|
|
@@ -40857,18 +41126,18 @@ function visioChangeMasterCommand(document, page, selection, masterId) {
|
|
|
40857
41126
|
}
|
|
40858
41127
|
|
|
40859
41128
|
// geometry/align-distribute.ts
|
|
40860
|
-
function usesSlideReference(elementCount,
|
|
40861
|
-
if (!
|
|
41129
|
+
function usesSlideReference(elementCount, options2) {
|
|
41130
|
+
if (!options2?.slideSize) {
|
|
40862
41131
|
return false;
|
|
40863
41132
|
}
|
|
40864
|
-
return
|
|
41133
|
+
return options2.reference === "slide";
|
|
40865
41134
|
}
|
|
40866
|
-
function resolveAlignReferenceBox(elements2,
|
|
41135
|
+
function resolveAlignReferenceBox(elements2, options2) {
|
|
40867
41136
|
if (elements2.length === 0) {
|
|
40868
41137
|
return null;
|
|
40869
41138
|
}
|
|
40870
|
-
if (usesSlideReference(elements2.length,
|
|
40871
|
-
return { minX: 0, minY: 0, maxX:
|
|
41139
|
+
if (usesSlideReference(elements2.length, options2)) {
|
|
41140
|
+
return { minX: 0, minY: 0, maxX: options2.slideSize.width, maxY: options2.slideSize.height };
|
|
40872
41141
|
}
|
|
40873
41142
|
if (elements2.length < 2) {
|
|
40874
41143
|
return null;
|
|
@@ -40880,9 +41149,9 @@ function resolveAlignReferenceBox(elements2, options) {
|
|
|
40880
41149
|
maxY: Math.max(...elements2.map((e) => e.y + e.height))
|
|
40881
41150
|
};
|
|
40882
41151
|
}
|
|
40883
|
-
function alignElements(elements2, edge,
|
|
41152
|
+
function alignElements(elements2, edge, options2) {
|
|
40884
41153
|
const result2 = /* @__PURE__ */ new Map();
|
|
40885
|
-
const ref = resolveAlignReferenceBox(elements2,
|
|
41154
|
+
const ref = resolveAlignReferenceBox(elements2, options2);
|
|
40886
41155
|
if (!ref) {
|
|
40887
41156
|
return result2;
|
|
40888
41157
|
}
|
|
@@ -41477,12 +41746,12 @@ function visioFileMasterDropCommand(page, master2, stencil, centre2) {
|
|
|
41477
41746
|
// visio/ui/draw-plan.ts
|
|
41478
41747
|
var SNAP = 1 / 16;
|
|
41479
41748
|
var boundedNumber = (value3) => Number.isFinite(value3) && Math.abs(value3) <= 1e6;
|
|
41480
|
-
function visioDrawingPoint(page, point2,
|
|
41749
|
+
function visioDrawingPoint(page, point2, options2 = {}) {
|
|
41481
41750
|
if (![point2.x, point2.y, page.width, page.height].every(boundedNumber) || page.width <= 0 || page.height <= 0)
|
|
41482
41751
|
return void 0;
|
|
41483
41752
|
const coordinate = (value3, maximum) => {
|
|
41484
|
-
const bounded6 =
|
|
41485
|
-
return
|
|
41753
|
+
const bounded6 = options2.bounded === false ? value3 : Math.max(0, Math.min(maximum, value3));
|
|
41754
|
+
return options2.snap === false ? bounded6 : Math.round(bounded6 / SNAP) * SNAP;
|
|
41486
41755
|
};
|
|
41487
41756
|
return { x: coordinate(point2.x, page.width), y: coordinate(point2.y, page.height) };
|
|
41488
41757
|
}
|
|
@@ -41770,10 +42039,10 @@ function strokeExtent(points2) {
|
|
|
41770
42039
|
const xs = points2.map((point2) => point2.x), ys = points2.map((point2) => point2.y);
|
|
41771
42040
|
return Math.hypot(Math.max(...xs) - Math.min(...xs), Math.max(...ys) - Math.min(...ys));
|
|
41772
42041
|
}
|
|
41773
|
-
function visioPathDrawPlan(page, kind, samples,
|
|
42042
|
+
function visioPathDrawPlan(page, kind, samples, options2 = {}) {
|
|
41774
42043
|
if (!isVisioPathTool(kind) || !Array.isArray(samples) || samples.length > MAX_SAMPLES)
|
|
41775
42044
|
throw new Error("Invalid path drawing tool or samples.");
|
|
41776
|
-
const tolerance =
|
|
42045
|
+
const tolerance = options2.tolerance ?? VISIO_PATH_TOLERANCE;
|
|
41777
42046
|
if (!(tolerance > 0) || !bounded5(tolerance)) throw new Error("Invalid path fitting tolerance.");
|
|
41778
42047
|
const points2 = visioCleanSamples(samples).filter((point2) => bounded5(point2.x) && bounded5(point2.y));
|
|
41779
42048
|
if (points2.length < 2 || strokeExtent(points2) < MINIMUM) return void 0;
|
|
@@ -42714,9 +42983,9 @@ function pageIssues(page, enabled) {
|
|
|
42714
42983
|
}
|
|
42715
42984
|
return issues;
|
|
42716
42985
|
}
|
|
42717
|
-
function checkVisioDiagram(document,
|
|
42718
|
-
const enabled = new Set(
|
|
42719
|
-
const limit2 =
|
|
42986
|
+
function checkVisioDiagram(document, options2 = {}) {
|
|
42987
|
+
const enabled = new Set(options2.ruleSets ?? VISIO_DIAGRAM_RULE_SETS.map((set) => set.id));
|
|
42988
|
+
const limit2 = options2.maxIssues ?? 5e3;
|
|
42720
42989
|
const issues = [];
|
|
42721
42990
|
for (const page of document.pages) {
|
|
42722
42991
|
if (page.isBackground) continue;
|
|
@@ -42748,12 +43017,12 @@ var BASE_COLUMNS = [
|
|
|
42748
43017
|
"Pin Y (in)",
|
|
42749
43018
|
"Text"
|
|
42750
43019
|
];
|
|
42751
|
-
function visioShapeReport(document,
|
|
42752
|
-
const limit2 =
|
|
43020
|
+
function visioShapeReport(document, options2 = {}) {
|
|
43021
|
+
const limit2 = options2.maxRows ?? 25e3;
|
|
42753
43022
|
const rows = [];
|
|
42754
43023
|
const keys = /* @__PURE__ */ new Set();
|
|
42755
43024
|
let truncated = false;
|
|
42756
|
-
const pages =
|
|
43025
|
+
const pages = options2.pageIndex === void 0 ? document.pages.filter((page) => !page.isBackground) : document.pages.slice(options2.pageIndex, options2.pageIndex + 1);
|
|
42757
43026
|
for (const page of pages) {
|
|
42758
43027
|
const visit = (shapes) => {
|
|
42759
43028
|
for (const shape of shapes) {
|
|
@@ -42897,8 +43166,8 @@ var typed = (cell) => {
|
|
|
42897
43166
|
const result2 = cellText(cell);
|
|
42898
43167
|
return typeof cell === "string" ? { ...result2, raw: text7(cell).trim() } : result2;
|
|
42899
43168
|
};
|
|
42900
|
-
function visioDataTable(grid,
|
|
42901
|
-
const header =
|
|
43169
|
+
function visioDataTable(grid, options2 = {}) {
|
|
43170
|
+
const header = options2.header ?? true;
|
|
42902
43171
|
const width = Math.min(
|
|
42903
43172
|
VISIO_DATA_LIMITS.maxColumns,
|
|
42904
43173
|
Math.max(0, ...grid.map((row2) => row2.length))
|
|
@@ -43103,14 +43372,14 @@ function visioRemoveDataGraphicEdits(page, shapeIds2, kind) {
|
|
|
43103
43372
|
}
|
|
43104
43373
|
return edits;
|
|
43105
43374
|
}
|
|
43106
|
-
function visioDataGraphicEdits(page, shapeIds2,
|
|
43375
|
+
function visioDataGraphicEdits(page, shapeIds2, options2) {
|
|
43107
43376
|
const targets = page.shapes.filter(
|
|
43108
|
-
(shape) => shapeIds2.includes(shape.id) && !visioDataGraphicMarker(shape) && visioShapeDataRow(shape,
|
|
43377
|
+
(shape) => shapeIds2.includes(shape.id) && !visioDataGraphicMarker(shape) && visioShapeDataRow(shape, options2.field)
|
|
43109
43378
|
);
|
|
43110
|
-
const edits =
|
|
43379
|
+
const edits = options2.kind === "color" ? [] : visioRemoveDataGraphicEdits(
|
|
43111
43380
|
page,
|
|
43112
43381
|
targets.map((shape) => shape.id),
|
|
43113
|
-
|
|
43382
|
+
options2.kind
|
|
43114
43383
|
);
|
|
43115
43384
|
const ratio = page.drawingToPageScale ?? 1;
|
|
43116
43385
|
let next = Number(visioNextShapeId(page));
|
|
@@ -43120,16 +43389,16 @@ function visioDataGraphicEdits(page, shapeIds2, options) {
|
|
|
43120
43389
|
pageId: page.id,
|
|
43121
43390
|
shapeId: shapeId2,
|
|
43122
43391
|
row: VISIO_DATA_GRAPHIC_ROW,
|
|
43123
|
-
data: hidden(
|
|
43392
|
+
data: hidden(options2.kind, owner)
|
|
43124
43393
|
});
|
|
43125
|
-
const values = targets.map((shape) => visioShapeDataNumber(shape,
|
|
43394
|
+
const values = targets.map((shape) => visioShapeDataNumber(shape, options2.field));
|
|
43126
43395
|
const known = values.filter((value3) => value3 !== void 0);
|
|
43127
|
-
const min =
|
|
43128
|
-
const max =
|
|
43129
|
-
const colors =
|
|
43396
|
+
const min = options2.min ?? Math.min(0, ...known);
|
|
43397
|
+
const max = options2.max ?? Math.max(...known, min + 1);
|
|
43398
|
+
const colors = options2.kind === "color" ? visioColorRules(
|
|
43130
43399
|
page,
|
|
43131
43400
|
targets.map((s) => s.id),
|
|
43132
|
-
|
|
43401
|
+
options2.field
|
|
43133
43402
|
) : void 0;
|
|
43134
43403
|
for (const [index2, shape] of targets.entries()) {
|
|
43135
43404
|
const box5 = visioShapePageBox(page, shape);
|
|
@@ -43143,8 +43412,8 @@ function visioDataGraphicEdits(page, shapeIds2, options) {
|
|
|
43143
43412
|
pageId: page.id,
|
|
43144
43413
|
...shape.kind === "shape" && !shape.masterId && !shape.children.length ? { followShapeId: shape.id } : {}
|
|
43145
43414
|
};
|
|
43146
|
-
if (
|
|
43147
|
-
const text8 = visioShapeDataText(shape,
|
|
43415
|
+
if (options2.kind === "text") {
|
|
43416
|
+
const text8 = visioShapeDataText(shape, options2.field) ?? "";
|
|
43148
43417
|
const shapeId2 = id3();
|
|
43149
43418
|
edits.push(
|
|
43150
43419
|
{
|
|
@@ -43159,7 +43428,7 @@ function visioDataGraphicEdits(page, shapeIds2, options) {
|
|
|
43159
43428
|
},
|
|
43160
43429
|
mark(shapeId2, shape.id)
|
|
43161
43430
|
);
|
|
43162
|
-
} else if (
|
|
43431
|
+
} else if (options2.kind === "bar") {
|
|
43163
43432
|
if (value3 === void 0) continue;
|
|
43164
43433
|
const barWidth = Math.min(Math.max(width, 0.8), 2);
|
|
43165
43434
|
const fraction = Math.max(0, Math.min(1, (value3 - min) / (max - min || 1)));
|
|
@@ -43201,7 +43470,7 @@ function visioDataGraphicEdits(page, shapeIds2, options) {
|
|
|
43201
43470
|
mark(bar, shape.id)
|
|
43202
43471
|
);
|
|
43203
43472
|
}
|
|
43204
|
-
} else if (
|
|
43473
|
+
} else if (options2.kind === "icon") {
|
|
43205
43474
|
if (value3 === void 0) continue;
|
|
43206
43475
|
const share = (value3 - min) / (max - min || 1);
|
|
43207
43476
|
const color2 = share >= 2 / 3 ? VISIO_DATA_GRAPHIC_ICONS.high : share >= 1 / 3 ? VISIO_DATA_GRAPHIC_ICONS.mid : VISIO_DATA_GRAPHIC_ICONS.low;
|
|
@@ -43228,7 +43497,7 @@ function visioDataGraphicEdits(page, shapeIds2, options) {
|
|
|
43228
43497
|
pageId: page.id,
|
|
43229
43498
|
shapeId: shape.id,
|
|
43230
43499
|
row: VISIO_DATA_GRAPHIC_FILL_ROW,
|
|
43231
|
-
data: hidden(
|
|
43500
|
+
data: hidden(options2.field, shape.style.fill)
|
|
43232
43501
|
});
|
|
43233
43502
|
edits.push({
|
|
43234
43503
|
...target2,
|
|
@@ -43369,7 +43638,7 @@ function space2(groups, start, size3, minimumGap) {
|
|
|
43369
43638
|
});
|
|
43370
43639
|
return result2;
|
|
43371
43640
|
}
|
|
43372
|
-
function autoAlignBoxes(boxes,
|
|
43641
|
+
function autoAlignBoxes(boxes, options2 = {}) {
|
|
43373
43642
|
if (new Set(boxes.map((box5) => box5.id)).size !== boxes.length)
|
|
43374
43643
|
throw new Error("Auto align box IDs must be unique.");
|
|
43375
43644
|
if (!boxes.every(
|
|
@@ -43378,9 +43647,9 @@ function autoAlignBoxes(boxes, options = {}) {
|
|
|
43378
43647
|
throw new Error("Auto align boxes must be finite.");
|
|
43379
43648
|
const result2 = /* @__PURE__ */ new Map();
|
|
43380
43649
|
if (!boxes.length) return result2;
|
|
43381
|
-
const toleranceX =
|
|
43382
|
-
const toleranceY =
|
|
43383
|
-
const minimumGap =
|
|
43650
|
+
const toleranceX = options2.tolerance?.x ?? median(boxes.map((box5) => box5.width)) / 2;
|
|
43651
|
+
const toleranceY = options2.tolerance?.y ?? median(boxes.map((box5) => box5.height)) / 2;
|
|
43652
|
+
const minimumGap = options2.minimumGap ?? 0;
|
|
43384
43653
|
const rows = clusters(boxes, (box5) => box5.y + box5.height / 2, toleranceY);
|
|
43385
43654
|
const columns = clusters(boxes, (box5) => box5.x + box5.width / 2, toleranceX);
|
|
43386
43655
|
const ys = space2(
|
|
@@ -43617,10 +43886,10 @@ function placeGrid(ids, size3, spacing) {
|
|
|
43617
43886
|
height: size3.get(id3).height
|
|
43618
43887
|
}));
|
|
43619
43888
|
}
|
|
43620
|
-
function layoutGraph(nodes, edges, style2,
|
|
43889
|
+
function layoutGraph(nodes, edges, style2, options2 = {}) {
|
|
43621
43890
|
if (!GRAPH_LAYOUT_STYLES.includes(style2)) throw new Error("Unknown graph layout style.");
|
|
43622
|
-
const spacing =
|
|
43623
|
-
const layerSpacing =
|
|
43891
|
+
const spacing = options2.spacing ?? 0.5;
|
|
43892
|
+
const layerSpacing = options2.layerSpacing ?? spacing;
|
|
43624
43893
|
if (![spacing, layerSpacing].every((value3) => Number.isFinite(value3) && value3 >= 0))
|
|
43625
43894
|
throw new Error("Layout spacing must be finite and not negative.");
|
|
43626
43895
|
const size3 = /* @__PURE__ */ new Map();
|
|
@@ -43752,12 +44021,12 @@ function moves(page, boxes, targets) {
|
|
|
43752
44021
|
}
|
|
43753
44022
|
return commands;
|
|
43754
44023
|
}
|
|
43755
|
-
function visioReLayoutCommands(page, style2, ids,
|
|
44024
|
+
function visioReLayoutCommands(page, style2, ids, options2 = {}) {
|
|
43756
44025
|
if (!VISIO_LAYOUT_STYLES.includes(style2)) return void 0;
|
|
43757
44026
|
if (ids && (ids.length > 1e3 || new Set(ids).size !== ids.length)) return void 0;
|
|
43758
44027
|
const { boxes, skipped } = scope(page, ids && ids.length > 1 ? ids : void 0);
|
|
43759
44028
|
if (boxes.length < 2) return void 0;
|
|
43760
|
-
const spacing =
|
|
44029
|
+
const spacing = options2.spacing ?? 0.5;
|
|
43761
44030
|
const inScope = new Set(boxes.map((box5) => box5.shape.id));
|
|
43762
44031
|
const edges = visioConnectorEdges(page).filter(
|
|
43763
44032
|
(edge) => inScope.has(edge.from) && inScope.has(edge.to)
|
|
@@ -43768,7 +44037,7 @@ function visioReLayoutCommands(page, style2, ids, options = {}) {
|
|
|
43768
44037
|
boxes.map((box5) => ({ id: box5.shape.id, width: box5.width, height: box5.height })),
|
|
43769
44038
|
edges,
|
|
43770
44039
|
style2,
|
|
43771
|
-
{ spacing, layerSpacing:
|
|
44040
|
+
{ spacing, layerSpacing: options2.layerSpacing ?? spacing * 1.5 }
|
|
43772
44041
|
);
|
|
43773
44042
|
} catch {
|
|
43774
44043
|
return void 0;
|
|
@@ -44072,17 +44341,17 @@ function visioShapeSnapBox(shape) {
|
|
|
44072
44341
|
};
|
|
44073
44342
|
return Object.values(box5).every(Number.isFinite) ? box5 : void 0;
|
|
44074
44343
|
}
|
|
44075
|
-
function visioSnapMoveDelta(page, ids, delta,
|
|
44344
|
+
function visioSnapMoveDelta(page, ids, delta, options2) {
|
|
44076
44345
|
const unchanged = { delta, lines: [] };
|
|
44077
44346
|
const usable = (value3) => value3 !== void 0 && value3 > 0 && Number.isFinite(value3) ? value3 : 0;
|
|
44078
|
-
const source =
|
|
44347
|
+
const source = options2.grid;
|
|
44079
44348
|
const grid = typeof source === "object" ? {
|
|
44080
44349
|
x: usable(source.x),
|
|
44081
44350
|
y: usable(source.y),
|
|
44082
44351
|
originX: Number.isFinite(source.originX) ? source.originX : 0,
|
|
44083
44352
|
originY: Number.isFinite(source.originY) ? source.originY : 0
|
|
44084
44353
|
} : { x: usable(source), y: usable(source), originX: 0, originY: 0 };
|
|
44085
|
-
if (!
|
|
44354
|
+
if (!options2.shapes && !options2.guides && !grid.x && !grid.y || !(options2.threshold > 0))
|
|
44086
44355
|
return unchanged;
|
|
44087
44356
|
const moving = new Set(ids);
|
|
44088
44357
|
const boxes = ids.map((id3) => visioMovementShape(page, id3)).map((shape) => shape && visioShapeSnapBox(shape));
|
|
@@ -44093,18 +44362,18 @@ function visioSnapMoveDelta(page, ids, delta, options) {
|
|
|
44093
44362
|
const bottom = Math.max(...boxes.map((box6) => box6.y + box6.height));
|
|
44094
44363
|
const box5 = { x: left + delta.x, y: top - delta.y, width: right2 - left, height: bottom - top };
|
|
44095
44364
|
const others = [];
|
|
44096
|
-
if (
|
|
44365
|
+
if (options2.shapes)
|
|
44097
44366
|
for (const shape of page.shapes) {
|
|
44098
44367
|
if (moving.has(shape.id) || shape.hidden || shape.visibility?.guide) continue;
|
|
44099
44368
|
const other = visioShapeSnapBox(shape);
|
|
44100
44369
|
if (other && (other.width > 0 || other.height > 0)) others.push(other);
|
|
44101
44370
|
}
|
|
44102
|
-
if (
|
|
44371
|
+
if (options2.guides)
|
|
44103
44372
|
for (const guide of visioPageGuides(page))
|
|
44104
44373
|
others.push(
|
|
44105
44374
|
guide.orientation === "vertical" ? { x: guide.position, y: -1e6, width: 0, height: 4e6 } : { x: -1e6, y: -guide.position, width: 4e6, height: 0 }
|
|
44106
44375
|
);
|
|
44107
|
-
const snapped = computeSnap(box5, others,
|
|
44376
|
+
const snapped = computeSnap(box5, others, options2.threshold);
|
|
44108
44377
|
const axes = new Set(snapped.guides.map((line2) => line2.axis));
|
|
44109
44378
|
if (grid.x && !axes.has("x")) snapped.x = gridEdge(snapped.x, box5.width, grid.x, grid.originX);
|
|
44110
44379
|
if (grid.y && !axes.has("y")) snapped.y = gridEdge(snapped.y, box5.height, grid.y, -grid.originY);
|
|
@@ -44187,7 +44456,7 @@ function visioTextSource(text8) {
|
|
|
44187
44456
|
}
|
|
44188
44457
|
var high = (value3) => !!value3 && /[\ud800-\udbff]/.test(value3);
|
|
44189
44458
|
var low = (value3) => !!value3 && /[\udc00-\udfff]/.test(value3);
|
|
44190
|
-
function visioTextDraftEdit(page, shapeId2, draft,
|
|
44459
|
+
function visioTextDraftEdit(page, shapeId2, draft, options2 = {}) {
|
|
44191
44460
|
const shape = visioTextShape(page, shapeId2);
|
|
44192
44461
|
if (!shape) return refuse4("The shape is no longer on this page.");
|
|
44193
44462
|
const text8 = shape.text;
|
|
@@ -44195,7 +44464,7 @@ function visioTextDraftEdit(page, shapeId2, draft, options = {}) {
|
|
|
44195
44464
|
if (draft === display) return void 0;
|
|
44196
44465
|
const fields2 = text8.fields ?? [];
|
|
44197
44466
|
const target2 = { pageId: page.id, shapeId: shapeId2 };
|
|
44198
|
-
if (!fields2.length && !
|
|
44467
|
+
if (!fields2.length && !options2.ranges)
|
|
44199
44468
|
return { type: "replace-plain-text", ...target2, text: draft };
|
|
44200
44469
|
let start = 0;
|
|
44201
44470
|
const limit2 = Math.min(display.length, draft.length);
|