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
|
@@ -112,11 +112,11 @@ function checkXmlLimits(xml, label2, limits = {}) {
|
|
|
112
112
|
throw new Error(`${label2} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function parseXml(xml,
|
|
116
|
-
const label2 =
|
|
115
|
+
function parseXml(xml, options2 = {}) {
|
|
116
|
+
const label2 = options2.label ?? "OOXML";
|
|
117
117
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
118
118
|
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
119
|
-
checkXmlLimits(xml, label2,
|
|
119
|
+
checkXmlLimits(xml, label2, options2.limits);
|
|
120
120
|
let parseError = "";
|
|
121
121
|
let parsed;
|
|
122
122
|
try {
|
|
@@ -2885,8 +2885,8 @@ function rgbToHsl(r, g2, b) {
|
|
|
2885
2885
|
}
|
|
2886
2886
|
return { h: h2, s: clampUnitInterval(s), l: clampUnitInterval(l) };
|
|
2887
2887
|
}
|
|
2888
|
-
function hslToRgb(h2, s, l, roundChannel = Math.round,
|
|
2889
|
-
const sC =
|
|
2888
|
+
function hslToRgb(h2, s, l, roundChannel = Math.round, options2) {
|
|
2889
|
+
const sC = options2?.clampSaturation === false ? s : clampUnitInterval(s);
|
|
2890
2890
|
const lC = clampUnitInterval(l);
|
|
2891
2891
|
const hN = (h2 % 360 + 360) % 360;
|
|
2892
2892
|
const c2 = (1 - Math.abs(2 * lC - 1)) * sC;
|
|
@@ -5065,13 +5065,13 @@ var APPLIED = /* @__PURE__ */ new Set([
|
|
|
5065
5065
|
"lumMod",
|
|
5066
5066
|
"lumOff"
|
|
5067
5067
|
]);
|
|
5068
|
-
function resolveDrawingColor(color2, theme3,
|
|
5068
|
+
function resolveDrawingColor(color2, theme3, options2) {
|
|
5069
5069
|
const base2 = baseHex(color2, theme3);
|
|
5070
5070
|
const rgb7 = base2 ? hexToRgbChannels(base2) : null;
|
|
5071
5071
|
if (!rgb7) return void 0;
|
|
5072
|
-
if (
|
|
5072
|
+
if (options2?.transformOrder === "document") {
|
|
5073
5073
|
const value3 = orderedColorTransforms(rgb7, color2.transforms);
|
|
5074
|
-
const round6 =
|
|
5074
|
+
const round6 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
|
|
5075
5075
|
return {
|
|
5076
5076
|
hex: `#${toHex(round6(value3.r))}${toHex(round6(value3.g))}${toHex(round6(value3.b))}`,
|
|
5077
5077
|
alpha: value3.alpha,
|
|
@@ -5122,7 +5122,7 @@ function resolveDrawingColor(color2, theme3, options) {
|
|
|
5122
5122
|
if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
|
|
5123
5123
|
const lumOff = parseDrawingFraction(find3("lumOff"));
|
|
5124
5124
|
if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
|
|
5125
|
-
const round6 =
|
|
5125
|
+
const round6 = options2?.hslRounding === "halfDown" ? (value3) => Math.ceil(value3 - 0.5) : Math.round;
|
|
5126
5126
|
({ r, g: g2, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round6));
|
|
5127
5127
|
}
|
|
5128
5128
|
let alpha = parseDrawingPercent(find3("alpha")) ?? 1;
|
|
@@ -14347,14 +14347,14 @@ function scottBinCount(values2, min, max) {
|
|
|
14347
14347
|
const width = 3.49 * sd * values2.length ** (-1 / 3);
|
|
14348
14348
|
return Math.max(1, Math.ceil((max - min) / width));
|
|
14349
14349
|
}
|
|
14350
|
-
function computeHistogramBins(values2,
|
|
14351
|
-
const closed =
|
|
14350
|
+
function computeHistogramBins(values2, options2, format5 = String) {
|
|
14351
|
+
const closed = options2.intervalClosed ?? "l";
|
|
14352
14352
|
const finite4 = values2.map((value3, sourceIndex) => ({ value: value3, sourceIndex })).filter((item) => Number.isFinite(item.value));
|
|
14353
14353
|
if (finite4.length === 0) {
|
|
14354
14354
|
return [];
|
|
14355
14355
|
}
|
|
14356
|
-
const underflow = typeof
|
|
14357
|
-
const overflow = typeof
|
|
14356
|
+
const underflow = typeof options2.underflow === "number" ? options2.underflow : void 0;
|
|
14357
|
+
const overflow = typeof options2.overflow === "number" ? options2.overflow : void 0;
|
|
14358
14358
|
const under = underflow === void 0 ? [] : finite4.filter(
|
|
14359
14359
|
(item) => closed === "r" ? item.value <= underflow : item.value < underflow
|
|
14360
14360
|
);
|
|
@@ -14371,8 +14371,8 @@ function computeHistogramBins(values2, options, format5 = String) {
|
|
|
14371
14371
|
if (regular.length > 0) {
|
|
14372
14372
|
const min = Math.min(...regular.map((item) => item.value));
|
|
14373
14373
|
const max = Math.max(...regular.map((item) => item.value));
|
|
14374
|
-
const requestedSize =
|
|
14375
|
-
const requestedCount =
|
|
14374
|
+
const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
|
|
14375
|
+
const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
|
|
14376
14376
|
const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
|
|
14377
14377
|
const count2 = requestedSize ? Math.max(
|
|
14378
14378
|
closed === "l" ? Math.floor((max - start) / requestedSize) + 1 : Math.ceil((max - start) / requestedSize),
|
|
@@ -14423,9 +14423,9 @@ function aggregateByCategory(values2, rawCategories) {
|
|
|
14423
14423
|
}
|
|
14424
14424
|
|
|
14425
14425
|
// chart/waterfall.ts
|
|
14426
|
-
function buildWaterfallSteps(values2,
|
|
14426
|
+
function buildWaterfallSteps(values2, options2) {
|
|
14427
14427
|
const subtotalIndices = new Set(
|
|
14428
|
-
|
|
14428
|
+
options2?.subtotalIndices ?? (values2.length > 0 ? [values2.length - 1] : [])
|
|
14429
14429
|
);
|
|
14430
14430
|
const steps = [];
|
|
14431
14431
|
let runningTotal = 0;
|
|
@@ -14970,12 +14970,12 @@ function resolveChartGradient(fill, resolve3) {
|
|
|
14970
14970
|
}
|
|
14971
14971
|
|
|
14972
14972
|
// chart/bar-cluster-geometry.ts
|
|
14973
|
-
function assertBarClusterOptions(
|
|
14973
|
+
function assertBarClusterOptions(options2) {
|
|
14974
14974
|
for (const [field2, min, max] of [
|
|
14975
14975
|
["barGapWidth", 0, 500],
|
|
14976
14976
|
["barOverlap", -100, 100]
|
|
14977
14977
|
]) {
|
|
14978
|
-
const value3 =
|
|
14978
|
+
const value3 = options2[field2];
|
|
14979
14979
|
if (value3 !== void 0 && (!Number.isInteger(value3) || value3 < min || value3 > max))
|
|
14980
14980
|
throw new RangeError(`${field2} must be an integer from ${min} to ${max}`);
|
|
14981
14981
|
}
|
|
@@ -16233,8 +16233,8 @@ function titleXml(context, title) {
|
|
|
16233
16233
|
chartTextXml(context, tx, false) + layoutXml(context, title.layout) + valXml("overlay", title.overlay) + shapePropertiesXml(context, title.spPr) + textBodyXml(context, title.txPr) + raw(context, title.extLst)
|
|
16234
16234
|
);
|
|
16235
16235
|
}
|
|
16236
|
-
function labelOptionsXml(context,
|
|
16237
|
-
return numberFormatXml(
|
|
16236
|
+
function labelOptionsXml(context, options2) {
|
|
16237
|
+
return numberFormatXml(options2.numberFormat) + shapePropertiesXml(context, options2.spPr) + textBodyXml(context, options2.txPr) + valXml("dLblPos", options2.position) + valXml("showLegendKey", options2.showLegendKey) + valXml("showVal", options2.showValue) + valXml("showCatName", options2.showCategoryName) + valXml("showSerName", options2.showSeriesName) + valXml("showPercent", options2.showPercent) + valXml("showBubbleSize", options2.showBubbleSize) + (options2.separator === void 0 ? "" : textElement("separator", options2.separator));
|
|
16238
16238
|
}
|
|
16239
16239
|
function labelXml(context, label2) {
|
|
16240
16240
|
return elementXml(
|
|
@@ -16404,7 +16404,7 @@ function styleXml(context, space) {
|
|
|
16404
16404
|
);
|
|
16405
16405
|
}
|
|
16406
16406
|
var relationship = (local, id3, content2 = "") => id3 === void 0 ? "" : elementXml(local, content2, ` r:id="${escapeAttribute(id3)}"`);
|
|
16407
|
-
function writeChartSpace(space,
|
|
16407
|
+
function writeChartSpace(space, options2 = {}) {
|
|
16408
16408
|
const bindings = new Map(CHART_ROOT_BINDINGS);
|
|
16409
16409
|
for (const { prefix: prefix3, uri } of space.namespaceDeclarations ?? [])
|
|
16410
16410
|
if (!bindings.has(prefix3) && /^[A-Za-z_][\w.-]*$/.test(prefix3)) bindings.set(prefix3, uri);
|
|
@@ -16419,9 +16419,77 @@ function writeChartSpace(space, options = {}) {
|
|
|
16419
16419
|
space.externalDataRelId,
|
|
16420
16420
|
valXml("autoUpdate", space.externalDataAutoUpdate)
|
|
16421
16421
|
) + raw(context, space.printSettings) + relationship("userShapes", space.userShapesRelId) + raw(context, space.extLst);
|
|
16422
|
-
const breakAfter =
|
|
16422
|
+
const breakAfter = options2.declarationBreak ?? "\r\n";
|
|
16423
16423
|
return `${DECLARATION2}${breakAfter}<c:chartSpace${declarations}>${body}</c:chartSpace>`;
|
|
16424
16424
|
}
|
|
16425
|
+
var AUTOMATIC_MARKER_CYCLE = [
|
|
16426
|
+
"diamond",
|
|
16427
|
+
"square",
|
|
16428
|
+
"triangle",
|
|
16429
|
+
"x",
|
|
16430
|
+
"star",
|
|
16431
|
+
"circle",
|
|
16432
|
+
"plus",
|
|
16433
|
+
"dot",
|
|
16434
|
+
"dash"
|
|
16435
|
+
];
|
|
16436
|
+
function automaticMarkerSymbol(seriesIdx) {
|
|
16437
|
+
const length = AUTOMATIC_MARKER_CYCLE.length;
|
|
16438
|
+
const normalized = (Math.trunc(seriesIdx) % length + length) % length;
|
|
16439
|
+
return AUTOMATIC_MARKER_CYCLE[Number.isFinite(normalized) ? normalized : 0];
|
|
16440
|
+
}
|
|
16441
|
+
|
|
16442
|
+
// chart/render/chart-view-markers.ts
|
|
16443
|
+
function summaryMarkers(source2, group2, seriesPosition) {
|
|
16444
|
+
if (!["line", "scatter", "radar"].includes(group2.kind)) return {};
|
|
16445
|
+
const enabled2 = group2.kind === "line" ? group2.marker === true : group2.kind === "radar" ? group2.radarStyle === "marker" : !["line", "smooth", "none"].includes(group2.scatterStyle ?? "marker");
|
|
16446
|
+
const symbol = source2.marker?.symbol;
|
|
16447
|
+
const marker4 = {
|
|
16448
|
+
...source2.marker,
|
|
16449
|
+
symbol: symbol && symbol !== "auto" ? symbol : source2.marker || enabled2 ? automaticMarkerSymbol(source2.index ?? seriesPosition) : "none"
|
|
16450
|
+
};
|
|
16451
|
+
const pointMarkers = {};
|
|
16452
|
+
for (const point2 of source2.dataPoints) {
|
|
16453
|
+
if (point2.index === void 0 || !point2.marker) continue;
|
|
16454
|
+
const override = point2.marker;
|
|
16455
|
+
pointMarkers[point2.index] = {
|
|
16456
|
+
...marker4,
|
|
16457
|
+
...override,
|
|
16458
|
+
...override.symbol === "auto" || !source2.marker && override.symbol === void 0 ? { symbol: automaticMarkerSymbol(source2.index ?? seriesPosition) } : {},
|
|
16459
|
+
...marker4.spPr || override.spPr ? {
|
|
16460
|
+
spPr: {
|
|
16461
|
+
...marker4.spPr,
|
|
16462
|
+
...override.spPr,
|
|
16463
|
+
...marker4.spPr?.line || override.spPr?.line ? { line: { ...marker4.spPr?.line, ...override.spPr?.line } } : {}
|
|
16464
|
+
}
|
|
16465
|
+
} : {}
|
|
16466
|
+
};
|
|
16467
|
+
}
|
|
16468
|
+
return { marker: marker4, ...Object.keys(pointMarkers).length ? { pointMarkers } : {} };
|
|
16469
|
+
}
|
|
16470
|
+
function seriesMarkerViews(source2, drawingColor2) {
|
|
16471
|
+
const fillColor = (fill) => fill?.kind === "none" ? "none" : fill?.kind === "solid" ? drawingColor2(fill.color) : void 0;
|
|
16472
|
+
const resolve3 = (marker4) => {
|
|
16473
|
+
const fill = fillColor(marker4.spPr?.fill);
|
|
16474
|
+
const stroke = fillColor(marker4.spPr?.line?.fill);
|
|
16475
|
+
const width = marker4.spPr?.line?.widthEmu;
|
|
16476
|
+
return {
|
|
16477
|
+
...marker4.symbol !== void 0 ? { symbol: marker4.symbol } : {},
|
|
16478
|
+
...marker4.size !== void 0 ? { size: marker4.size } : {},
|
|
16479
|
+
...fill !== void 0 ? { fill } : {},
|
|
16480
|
+
...stroke !== void 0 ? { stroke } : {},
|
|
16481
|
+
...width !== void 0 ? { strokeWidth: width / 9525 } : {}
|
|
16482
|
+
};
|
|
16483
|
+
};
|
|
16484
|
+
return {
|
|
16485
|
+
...source2.marker ? { marker: resolve3(source2.marker) } : {},
|
|
16486
|
+
...source2.pointMarkers ? {
|
|
16487
|
+
pointMarkers: Object.fromEntries(
|
|
16488
|
+
Object.entries(source2.pointMarkers).map(([i2, marker4]) => [i2, resolve3(marker4)])
|
|
16489
|
+
)
|
|
16490
|
+
} : {}
|
|
16491
|
+
};
|
|
16492
|
+
}
|
|
16425
16493
|
|
|
16426
16494
|
// chart/render/summary-analysis.ts
|
|
16427
16495
|
function summaryTrendline(source2) {
|
|
@@ -16464,17 +16532,17 @@ function summaryAnalysis(series) {
|
|
|
16464
16532
|
}
|
|
16465
16533
|
|
|
16466
16534
|
// chart/render/summary-labels.ts
|
|
16467
|
-
function level(
|
|
16535
|
+
function level(options2, custom) {
|
|
16468
16536
|
const out = {};
|
|
16469
|
-
if (
|
|
16470
|
-
if (
|
|
16471
|
-
if (
|
|
16472
|
-
if (
|
|
16473
|
-
if (
|
|
16474
|
-
if (
|
|
16475
|
-
if (
|
|
16476
|
-
if (
|
|
16477
|
-
if (
|
|
16537
|
+
if (options2.deleted !== void 0) out.deleted = options2.deleted;
|
|
16538
|
+
if (options2.showValue !== void 0) out.showValue = options2.showValue;
|
|
16539
|
+
if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
|
|
16540
|
+
if (options2.showSeriesName !== void 0) out.showSeriesName = options2.showSeriesName;
|
|
16541
|
+
if (options2.showPercent !== void 0) out.showPercent = options2.showPercent;
|
|
16542
|
+
if (options2.showBubbleSize !== void 0) out.showBubbleSize = options2.showBubbleSize;
|
|
16543
|
+
if (options2.separator !== void 0) out.separator = options2.separator;
|
|
16544
|
+
if (options2.position) out.position = options2.position;
|
|
16545
|
+
if (options2.numberFormat?.formatCode) out.numberFormat = options2.numberFormat.formatCode;
|
|
16478
16546
|
if (custom?.text !== void 0) out.text = custom.text;
|
|
16479
16547
|
return out;
|
|
16480
16548
|
}
|
|
@@ -16581,7 +16649,10 @@ function extraGroups(chartSpace, firstType) {
|
|
|
16581
16649
|
const type = group2.kind === "bar" ? "column" : group2.kind;
|
|
16582
16650
|
const entry3 = {
|
|
16583
16651
|
chartType: type,
|
|
16584
|
-
series: group2.series.map((source2) =>
|
|
16652
|
+
series: group2.series.map((source2, index3) => ({
|
|
16653
|
+
...chartSummarySeries(source2, type, group2.dataLabels),
|
|
16654
|
+
...summaryMarkers(source2, group2, index3)
|
|
16655
|
+
})),
|
|
16585
16656
|
secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
|
|
16586
16657
|
};
|
|
16587
16658
|
if (group2.grouping && GROUPINGS.has(group2.grouping))
|
|
@@ -16599,13 +16670,16 @@ function chartSummaryFromSpace(chartSpace, extras = {}) {
|
|
|
16599
16670
|
const group2 = chartSpace.plotArea.groups[0];
|
|
16600
16671
|
let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
|
|
16601
16672
|
if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
|
|
16602
|
-
const series = (group2?.series ?? []).map(
|
|
16603
|
-
|
|
16604
|
-
|
|
16673
|
+
const series = (group2?.series ?? []).map((source2, index3) => ({
|
|
16674
|
+
...chartSummarySeries(source2, chartType, group2?.dataLabels),
|
|
16675
|
+
...group2 ? summaryMarkers(source2, group2, index3) : {}
|
|
16676
|
+
}));
|
|
16605
16677
|
const summary = {
|
|
16606
16678
|
chartType,
|
|
16607
16679
|
series,
|
|
16608
|
-
showLegend: chartSpace.legend !== void 0
|
|
16680
|
+
showLegend: chartSpace.legend !== void 0,
|
|
16681
|
+
axes: chartSpace.plotArea.axes,
|
|
16682
|
+
axisIds: group2?.axisIds ?? []
|
|
16609
16683
|
};
|
|
16610
16684
|
const combined = extraGroups(chartSpace, chartType);
|
|
16611
16685
|
if (combined.length) summary.extraGroups = combined;
|
|
@@ -16957,14 +17031,14 @@ function* units(raw2) {
|
|
|
16957
17031
|
exp2++;
|
|
16958
17032
|
}
|
|
16959
17033
|
}
|
|
16960
|
-
function niceScale(dataMin, dataMax,
|
|
16961
|
-
const maxIntervals = Math.max(1,
|
|
17034
|
+
function niceScale(dataMin, dataMax, options2 = {}) {
|
|
17035
|
+
const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
|
|
16962
17036
|
let lo = Number.isFinite(dataMin) ? dataMin : 0;
|
|
16963
17037
|
let hi = Number.isFinite(dataMax) ? dataMax : 0;
|
|
16964
17038
|
if (lo > hi) [lo, hi] = [hi, lo];
|
|
16965
17039
|
if (lo === hi) {
|
|
16966
17040
|
if (lo === 0) hi = 1;
|
|
16967
|
-
else if (
|
|
17041
|
+
else if (options2.noZero) {
|
|
16968
17042
|
const pad8 = Math.abs(lo) * 0.1 || 1;
|
|
16969
17043
|
lo -= pad8;
|
|
16970
17044
|
hi += pad8;
|
|
@@ -16973,7 +17047,7 @@ function niceScale(dataMin, dataMax, options = {}) {
|
|
|
16973
17047
|
}
|
|
16974
17048
|
let fixedLo = false;
|
|
16975
17049
|
let fixedHi = false;
|
|
16976
|
-
if (!
|
|
17050
|
+
if (!options2.noZero) {
|
|
16977
17051
|
if (lo >= 0 && hi - lo >= hi / 6) {
|
|
16978
17052
|
lo = 0;
|
|
16979
17053
|
fixedLo = true;
|
|
@@ -17013,6 +17087,194 @@ function formatAxisValue(value3, percent = false) {
|
|
|
17013
17087
|
return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
|
|
17014
17088
|
}
|
|
17015
17089
|
|
|
17090
|
+
// chart/axis-range.ts
|
|
17091
|
+
function computeLogValueRange(series, logBase) {
|
|
17092
|
+
const allValues = series.flatMap((item) => item.values).filter((value3) => value3 !== null && Number.isFinite(value3) && value3 > 0);
|
|
17093
|
+
if (allValues.length === 0) {
|
|
17094
|
+
return { min: 1, max: logBase, span: 1, logScale: true, logBase };
|
|
17095
|
+
}
|
|
17096
|
+
const dataMin = Math.min(...allValues);
|
|
17097
|
+
const dataMax = Math.max(...allValues);
|
|
17098
|
+
const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
|
|
17099
|
+
const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
|
|
17100
|
+
const min = logBase ** logMin;
|
|
17101
|
+
const max = logBase ** Math.max(logMax, logMin + 1);
|
|
17102
|
+
return {
|
|
17103
|
+
min,
|
|
17104
|
+
max,
|
|
17105
|
+
span: Math.max(Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase), 1),
|
|
17106
|
+
logScale: true,
|
|
17107
|
+
logBase
|
|
17108
|
+
};
|
|
17109
|
+
}
|
|
17110
|
+
function withAxisBounds(automatic, axis, logBase) {
|
|
17111
|
+
const validMin = typeof axis?.min === "number" && Number.isFinite(axis.min) && (!logBase || axis.min > 0) ? axis.min : void 0;
|
|
17112
|
+
const validMax = typeof axis?.max === "number" && Number.isFinite(axis.max) && (!logBase || axis.max > 0) ? axis.max : void 0;
|
|
17113
|
+
const min = validMin ?? automatic.min;
|
|
17114
|
+
let max = validMax ?? automatic.max;
|
|
17115
|
+
const majorUnit = validMin === void 0 && validMax === void 0 ? automatic.majorUnit : void 0;
|
|
17116
|
+
if (max <= min) {
|
|
17117
|
+
max = logBase ? min * logBase : min + 1;
|
|
17118
|
+
}
|
|
17119
|
+
const span3 = logBase ? Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase) : max - min;
|
|
17120
|
+
return {
|
|
17121
|
+
min,
|
|
17122
|
+
max,
|
|
17123
|
+
span: Math.max(span3, Number.EPSILON),
|
|
17124
|
+
...majorUnit !== void 0 ? { majorUnit } : {},
|
|
17125
|
+
...logBase ? { logScale: true, logBase } : {},
|
|
17126
|
+
...axis?.orientation === "maxMin" ? { reverseOrder: true } : {}
|
|
17127
|
+
};
|
|
17128
|
+
}
|
|
17129
|
+
|
|
17130
|
+
// chart/axis-ticks.ts
|
|
17131
|
+
var LOG_EXPONENT_TOLERANCE = 1e-12;
|
|
17132
|
+
function generateLogTicks(range2) {
|
|
17133
|
+
if (!range2.logScale || !range2.logBase) {
|
|
17134
|
+
return [];
|
|
17135
|
+
}
|
|
17136
|
+
const base2 = range2.logBase;
|
|
17137
|
+
const logMin = Math.log(range2.min) / Math.log(base2);
|
|
17138
|
+
const logMax = Math.log(range2.max) / Math.log(base2);
|
|
17139
|
+
const firstExponent = Math.ceil(logMin - LOG_EXPONENT_TOLERANCE);
|
|
17140
|
+
const lastExponent = Math.floor(logMax + LOG_EXPONENT_TOLERANCE);
|
|
17141
|
+
if (lastExponent < firstExponent) {
|
|
17142
|
+
return range2.min === range2.max ? [range2.min] : [range2.min, range2.max];
|
|
17143
|
+
}
|
|
17144
|
+
return Array.from(
|
|
17145
|
+
{ length: lastExponent - firstExponent + 1 },
|
|
17146
|
+
(_unused, index3) => base2 ** (firstExponent + index3)
|
|
17147
|
+
);
|
|
17148
|
+
}
|
|
17149
|
+
function generateIntervalTicks(range2, unit3) {
|
|
17150
|
+
if (!Number.isFinite(unit3) || unit3 <= 0 || range2.logScale) {
|
|
17151
|
+
return [];
|
|
17152
|
+
}
|
|
17153
|
+
const tolerance = Math.max(1, Math.abs(range2.min), Math.abs(range2.max)) * 1e-12;
|
|
17154
|
+
const first3 = Math.ceil((range2.min - tolerance) / unit3);
|
|
17155
|
+
const last = Math.floor((range2.max + tolerance) / unit3);
|
|
17156
|
+
const count2 = Math.min(Math.max(last - first3 + 1, 0), 2e3);
|
|
17157
|
+
return Array.from({ length: count2 }, (_, index3) => (first3 + index3) * unit3);
|
|
17158
|
+
}
|
|
17159
|
+
function generateAxisTicks(range2, axis, defaultIntervals) {
|
|
17160
|
+
if (range2.logScale && range2.logBase) {
|
|
17161
|
+
return generateLogTicks(range2);
|
|
17162
|
+
}
|
|
17163
|
+
const explicit = generateIntervalTicks(range2, axis?.majorUnit ?? 0);
|
|
17164
|
+
if (explicit.length > 0) {
|
|
17165
|
+
return explicit;
|
|
17166
|
+
}
|
|
17167
|
+
const automatic = generateIntervalTicks(range2, range2.majorUnit ?? 0);
|
|
17168
|
+
if (automatic.length > 0) {
|
|
17169
|
+
return automatic;
|
|
17170
|
+
}
|
|
17171
|
+
return Array.from(
|
|
17172
|
+
{ length: defaultIntervals + 1 },
|
|
17173
|
+
(_, index3) => range2.min + range2.span / defaultIntervals * index3
|
|
17174
|
+
);
|
|
17175
|
+
}
|
|
17176
|
+
function generateMinorAxisTicks(range2, axis) {
|
|
17177
|
+
const minor = generateIntervalTicks(range2, axis?.minorUnit ?? 0);
|
|
17178
|
+
if (minor.length === 0) {
|
|
17179
|
+
return [];
|
|
17180
|
+
}
|
|
17181
|
+
const majorUnit = axis?.majorUnit;
|
|
17182
|
+
if (!majorUnit || !Number.isFinite(majorUnit) || majorUnit <= 0) {
|
|
17183
|
+
return minor;
|
|
17184
|
+
}
|
|
17185
|
+
const tolerance = Math.max(1, Math.abs(range2.min), Math.abs(range2.max)) * 1e-10;
|
|
17186
|
+
return minor.filter(
|
|
17187
|
+
(value3) => Math.abs(value3 / majorUnit - Math.round(value3 / majorUnit)) > tolerance
|
|
17188
|
+
);
|
|
17189
|
+
}
|
|
17190
|
+
|
|
17191
|
+
// chart/render/chart-view-axes.ts
|
|
17192
|
+
function options(axis) {
|
|
17193
|
+
return {
|
|
17194
|
+
...axis.scaling,
|
|
17195
|
+
...axis.scaling.logBase === void 0 ? {} : { logScale: true },
|
|
17196
|
+
...axis.majorUnit === void 0 ? {} : { majorUnit: axis.majorUnit },
|
|
17197
|
+
...axis.minorUnit === void 0 ? {} : { minorUnit: axis.minorUnit }
|
|
17198
|
+
};
|
|
17199
|
+
}
|
|
17200
|
+
function applyChartAxes(model, chart, color2) {
|
|
17201
|
+
if (!chart.axes?.length) return;
|
|
17202
|
+
const axes2 = chart.axes;
|
|
17203
|
+
const linked = axes2.filter((axis) => axis.id !== void 0 && chart.axisIds?.includes(axis.id));
|
|
17204
|
+
const candidates = linked.length ? linked : axes2;
|
|
17205
|
+
const xy = model.type === "scatter" || model.type === "bubble";
|
|
17206
|
+
const value3 = candidates.find((axis) => axis.kind === "val" && !["b", "t"].includes(axis.position ?? "")) ?? candidates.find((axis) => axis.kind === "val");
|
|
17207
|
+
const category = candidates.find(
|
|
17208
|
+
(axis) => xy ? axis.kind === "val" && axis !== value3 : axis.kind === "cat" || axis.kind === "date"
|
|
17209
|
+
);
|
|
17210
|
+
const secondary = axes2.find((axis) => axis.kind === "val" && axis !== value3 && axis !== category);
|
|
17211
|
+
const paint2 = (shape2) => {
|
|
17212
|
+
const ln2 = shape2?.line;
|
|
17213
|
+
const fill = ln2?.fill;
|
|
17214
|
+
const resolved = fill?.kind === "none" ? "none" : color2(fill?.kind === "solid" ? fill.color : void 0);
|
|
17215
|
+
return {
|
|
17216
|
+
...resolved === void 0 ? {} : { color: resolved },
|
|
17217
|
+
...ln2?.widthEmu === void 0 ? {} : { width: ln2.widthEmu / EMU_PER_PIXEL },
|
|
17218
|
+
...ln2?.dash === void 0 ? {} : { dash: ln2.dash }
|
|
17219
|
+
};
|
|
17220
|
+
};
|
|
17221
|
+
const bind = (axis, scale2, values2) => {
|
|
17222
|
+
const opts = options(axis);
|
|
17223
|
+
const automatic = opts.logScale ? computeLogValueRange(
|
|
17224
|
+
[{ values: values2 ?? [] }],
|
|
17225
|
+
opts.logBase && Number.isFinite(opts.logBase) && opts.logBase > 1 ? opts.logBase : 10
|
|
17226
|
+
) : {
|
|
17227
|
+
min: scale2?.min ?? 0,
|
|
17228
|
+
max: scale2?.max ?? 1,
|
|
17229
|
+
span: (scale2?.max ?? 1) - (scale2?.min ?? 0),
|
|
17230
|
+
...scale2 ? { majorUnit: scale2.majorUnit } : {}
|
|
17231
|
+
};
|
|
17232
|
+
const logBase = automatic.logBase;
|
|
17233
|
+
const range2 = withAxisBounds(automatic, opts, logBase);
|
|
17234
|
+
if (scale2) {
|
|
17235
|
+
scale2.min = range2.min;
|
|
17236
|
+
scale2.max = range2.max;
|
|
17237
|
+
scale2.ticks = generateAxisTicks(range2, opts, 5);
|
|
17238
|
+
}
|
|
17239
|
+
return {
|
|
17240
|
+
source: axis,
|
|
17241
|
+
range: range2,
|
|
17242
|
+
minorTicks: generateMinorAxisTicks(range2, opts),
|
|
17243
|
+
line: paint2(axis.spPr),
|
|
17244
|
+
majorGrid: paint2(axis.majorGridlinesSpPr),
|
|
17245
|
+
minorGrid: paint2(axis.minorGridlinesSpPr)
|
|
17246
|
+
};
|
|
17247
|
+
};
|
|
17248
|
+
const out = {};
|
|
17249
|
+
if (value3)
|
|
17250
|
+
out.value = bind(
|
|
17251
|
+
value3,
|
|
17252
|
+
model.valueAxis,
|
|
17253
|
+
[
|
|
17254
|
+
...model.series,
|
|
17255
|
+
...model.extraGroups?.filter((g2) => !g2.secondary).flatMap((g2) => g2.series) ?? []
|
|
17256
|
+
].flatMap((s) => s.values)
|
|
17257
|
+
);
|
|
17258
|
+
if (category)
|
|
17259
|
+
out.category = bind(
|
|
17260
|
+
category,
|
|
17261
|
+
model.xAxis ?? {
|
|
17262
|
+
min: 0,
|
|
17263
|
+
max: Math.max(1, model.categories.length - 1),
|
|
17264
|
+
majorUnit: 1,
|
|
17265
|
+
ticks: []
|
|
17266
|
+
},
|
|
17267
|
+
model.series.flatMap((s) => s.xValues ?? [])
|
|
17268
|
+
);
|
|
17269
|
+
if (secondary)
|
|
17270
|
+
out.secondary = bind(
|
|
17271
|
+
secondary,
|
|
17272
|
+
model.secondaryAxis,
|
|
17273
|
+
model.extraGroups?.filter((g2) => g2.secondary).flatMap((g2) => g2.series.flatMap((s) => s.values))
|
|
17274
|
+
);
|
|
17275
|
+
model.axes = out;
|
|
17276
|
+
}
|
|
17277
|
+
|
|
17016
17278
|
// chart/render/chart-view-analysis.ts
|
|
17017
17279
|
function strokeOf(line3, fallback, resolve3) {
|
|
17018
17280
|
if (line3?.fill?.kind === "none") return void 0;
|
|
@@ -17062,15 +17324,15 @@ function seriesName(series, index3, evaluateRef2) {
|
|
|
17062
17324
|
const fromRef = resolveRef(series.nameRef, evaluateRef2)?.map(toText).filter((t) => t !== "").join(" ");
|
|
17063
17325
|
return fromRef || series.name || `Series${index3 + 1}`;
|
|
17064
17326
|
}
|
|
17065
|
-
function seriesContext(chart, theme3,
|
|
17327
|
+
function seriesContext(chart, theme3, options2) {
|
|
17066
17328
|
const scheme = chartColorScheme(theme3);
|
|
17067
17329
|
const resolver = { scheme: (name3) => scheme[name3] };
|
|
17068
17330
|
return {
|
|
17069
17331
|
theme: theme3,
|
|
17070
17332
|
scheme,
|
|
17071
17333
|
palette: chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette),
|
|
17072
|
-
evaluateRef:
|
|
17073
|
-
seriesColor:
|
|
17334
|
+
evaluateRef: options2.evaluateRef ?? (() => []),
|
|
17335
|
+
seriesColor: options2.seriesColor,
|
|
17074
17336
|
drawingColor: (color2) => color2 && drawingColorCss(resolveDrawingColor(color2, resolver, { transformOrder: "document" })),
|
|
17075
17337
|
gradient: (fill) => fill?.kind === "gradient" ? resolveChartGradient(
|
|
17076
17338
|
fill,
|
|
@@ -17096,7 +17358,11 @@ function seriesView(ctx, s, index3, total2, categoriesOf) {
|
|
|
17096
17358
|
})
|
|
17097
17359
|
);
|
|
17098
17360
|
if (Object.keys(points).length) view.pointGradients = points;
|
|
17099
|
-
Object.assign(
|
|
17361
|
+
Object.assign(
|
|
17362
|
+
view,
|
|
17363
|
+
analysisView(s, color2, ctx.drawingColor),
|
|
17364
|
+
seriesMarkerViews(s, ctx.drawingColor)
|
|
17365
|
+
);
|
|
17100
17366
|
return view;
|
|
17101
17367
|
}
|
|
17102
17368
|
|
|
@@ -17391,11 +17657,11 @@ function histogramView(chart, model) {
|
|
|
17391
17657
|
const first3 = model.series[0];
|
|
17392
17658
|
if (!first3) return;
|
|
17393
17659
|
const raw2 = first3.values.map((v) => v ?? Number.NaN);
|
|
17394
|
-
const
|
|
17395
|
-
const bins =
|
|
17660
|
+
const options2 = chart.histogram ?? {};
|
|
17661
|
+
const bins = options2.aggregateByCategory ? aggregateByCategory(
|
|
17396
17662
|
first3.values.map((v) => v ?? 0),
|
|
17397
17663
|
model.categories
|
|
17398
|
-
) : computeHistogramBins(raw2,
|
|
17664
|
+
) : computeHistogramBins(raw2, options2, formatAxisValue);
|
|
17399
17665
|
model.categories = bins.map((bin) => bin.label);
|
|
17400
17666
|
first3.values = bins.map((bin) => bin.value);
|
|
17401
17667
|
model.barGapWidth = 0;
|
|
@@ -17419,11 +17685,11 @@ var SUPPORTED = /* @__PURE__ */ new Set([
|
|
|
17419
17685
|
"treemap",
|
|
17420
17686
|
"sunburst"
|
|
17421
17687
|
]);
|
|
17422
|
-
function chartSummaryView(chart, theme3,
|
|
17688
|
+
function chartSummaryView(chart, theme3, options2 = {}) {
|
|
17423
17689
|
const type = chart.chartType;
|
|
17424
17690
|
const radial = type === "pie" || type === "doughnut";
|
|
17425
17691
|
const byPoint = radial || type === "treemap" || type === "sunburst";
|
|
17426
|
-
const ctx = seriesContext(chart, theme3,
|
|
17692
|
+
const ctx = seriesContext(chart, theme3, options2);
|
|
17427
17693
|
const { palette, scheme, drawingColor: drawingColor2 } = ctx;
|
|
17428
17694
|
const grouping = chart.grouping ?? (type === "bar" || type === "column" ? "clustered" : "standard");
|
|
17429
17695
|
const rawCategories = [];
|
|
@@ -17509,6 +17775,7 @@ function chartSummaryView(chart, theme3, options = {}) {
|
|
|
17509
17775
|
else if (!byPoint) model.valueAxis = valueAxis(model);
|
|
17510
17776
|
applyDataLabels(model, chart.series, extra);
|
|
17511
17777
|
chartExtraAxes(model);
|
|
17778
|
+
applyChartAxes(model, chart, ctx.drawingColor);
|
|
17512
17779
|
return model;
|
|
17513
17780
|
}
|
|
17514
17781
|
|
|
@@ -22178,8 +22445,8 @@ function createWorksheet(name3, sheetId5) {
|
|
|
22178
22445
|
preserved: /* @__PURE__ */ new Map()
|
|
22179
22446
|
};
|
|
22180
22447
|
}
|
|
22181
|
-
function createWorkbook(
|
|
22182
|
-
const names =
|
|
22448
|
+
function createWorkbook(options2 = {}) {
|
|
22449
|
+
const names = options2.sheets?.length ? options2.sheets : ["Sheet1"];
|
|
22183
22450
|
return {
|
|
22184
22451
|
sheets: names.map((name3, index3) => createWorksheet(name3, index3 + 1)),
|
|
22185
22452
|
styles: [defaultCellStyle()],
|
|
@@ -23394,15 +23661,15 @@ function renderAbs(v, section3, generalWidth) {
|
|
|
23394
23661
|
}
|
|
23395
23662
|
return { text: text8, zero: general === "0" };
|
|
23396
23663
|
}
|
|
23397
|
-
function hashFill(
|
|
23398
|
-
const width =
|
|
23399
|
-
const one2 =
|
|
23664
|
+
function hashFill(options2) {
|
|
23665
|
+
const width = options2.width ?? 0;
|
|
23666
|
+
const one2 = options2.measure ? options2.measure("#") : 1;
|
|
23400
23667
|
return "#".repeat(Math.max(1, Math.floor(one2 > 0 ? width / one2 : width)));
|
|
23401
23668
|
}
|
|
23402
|
-
function fitNumber(value3, format5,
|
|
23403
|
-
const date1904 =
|
|
23404
|
-
const width =
|
|
23405
|
-
const fits = (text8) => (
|
|
23669
|
+
function fitNumber(value3, format5, options2) {
|
|
23670
|
+
const date1904 = options2.date1904 ?? false;
|
|
23671
|
+
const width = options2.width ?? 0;
|
|
23672
|
+
const fits = (text8) => (options2.measure ? options2.measure(text8) : text8.length) <= width;
|
|
23406
23673
|
const first3 = formatNumber(value3, format5, date1904);
|
|
23407
23674
|
if (fits(first3.text) || first3.text === OVERFLOW_TEXT) return first3;
|
|
23408
23675
|
const choice2 = chooseSection(compileFormat(format5), value3);
|
|
@@ -23413,7 +23680,7 @@ function fitNumber(value3, format5, options) {
|
|
|
23413
23680
|
if (fits(next.text)) return next;
|
|
23414
23681
|
}
|
|
23415
23682
|
}
|
|
23416
|
-
const fill = hashFill(
|
|
23683
|
+
const fill = hashFill(options2);
|
|
23417
23684
|
return first3.color ? { text: fill, color: first3.color } : { text: fill };
|
|
23418
23685
|
}
|
|
23419
23686
|
function formatNumber(value3, format5, date1904, generalWidth) {
|
|
@@ -23435,13 +23702,13 @@ function formatNumber(value3, format5, date1904, generalWidth) {
|
|
|
23435
23702
|
const minus = value3 < 0 && !abs2 && !zero;
|
|
23436
23703
|
return result(minus ? `-${text8}` : text8, section3);
|
|
23437
23704
|
}
|
|
23438
|
-
function formatValue(value3, format5,
|
|
23705
|
+
function formatValue(value3, format5, options2 = {}) {
|
|
23439
23706
|
if (value3 === null) return { text: "" };
|
|
23440
23707
|
if (typeof value3 === "boolean") return { text: value3 ? "TRUE" : "FALSE" };
|
|
23441
23708
|
if (typeof value3 === "string") return formatText(value3, compileFormat(format5).text);
|
|
23442
23709
|
if (isCellError(value3)) return { text: value3.error };
|
|
23443
|
-
if (
|
|
23444
|
-
return formatNumber(value3, format5,
|
|
23710
|
+
if (options2.width !== void 0) return fitNumber(value3, format5, options2);
|
|
23711
|
+
return formatNumber(value3, format5, options2.date1904 ?? false);
|
|
23445
23712
|
}
|
|
23446
23713
|
function isDateFormat(format5) {
|
|
23447
23714
|
return compileFormat(format5).isDate;
|
|
@@ -23652,7 +23919,7 @@ function parseFractionInput(text8) {
|
|
|
23652
23919
|
numFmt: den < 10 ? "# ?/?" : "# ??/??"
|
|
23653
23920
|
};
|
|
23654
23921
|
}
|
|
23655
|
-
function parseCellInput(text8,
|
|
23922
|
+
function parseCellInput(text8, options2 = {}) {
|
|
23656
23923
|
if (text8 === "") return { value: null };
|
|
23657
23924
|
if (text8.startsWith("=") && text8.length > 1) return { value: null, formula: text8.slice(1) };
|
|
23658
23925
|
if (text8.startsWith("'")) return { value: text8.slice(1) };
|
|
@@ -23663,7 +23930,7 @@ function parseCellInput(text8, options = {}) {
|
|
|
23663
23930
|
if (upper2 === "TRUE" || upper2 === "FALSE") return { value: upper2 === "TRUE" };
|
|
23664
23931
|
if (isErrorCode(upper2)) return { value: cellError(upper2) };
|
|
23665
23932
|
}
|
|
23666
|
-
const parsed = parseNumberInput(trimmed2) ?? parseFractionInput(trimmed2) ?? parseDateTimeInput(trimmed2,
|
|
23933
|
+
const parsed = parseNumberInput(trimmed2) ?? parseFractionInput(trimmed2) ?? parseDateTimeInput(trimmed2, options2.date1904 ?? false);
|
|
23667
23934
|
if (!parsed) return { value: text8 };
|
|
23668
23935
|
return parsed.numFmt ? { value: parsed.value, numFmt: parsed.numFmt } : { value: parsed.value };
|
|
23669
23936
|
}
|
|
@@ -24605,7 +24872,7 @@ var pivotColumnFields = (pivot) => [
|
|
|
24605
24872
|
// i18n/locale.ts
|
|
24606
24873
|
var SUPPORTED_OFFICE_LOCALES = ["en", "fr", "de", "es", "zh-CN"];
|
|
24607
24874
|
var DEFAULT_REJECTED_SUBTAGS = ["hant", "tw", "hk", "mo"];
|
|
24608
|
-
function normalizeLocale(input, supported2, fallback,
|
|
24875
|
+
function normalizeLocale(input, supported2, fallback, options2 = {}) {
|
|
24609
24876
|
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
24610
24877
|
const language = parts[0];
|
|
24611
24878
|
if (!language) return fallback;
|
|
@@ -24614,7 +24881,7 @@ function normalizeLocale(input, supported2, fallback, options = {}) {
|
|
|
24614
24881
|
if (exact) return exact;
|
|
24615
24882
|
const base2 = find3(language);
|
|
24616
24883
|
if (base2) return base2;
|
|
24617
|
-
const rejected =
|
|
24884
|
+
const rejected = options2.rejectedSubtags ?? DEFAULT_REJECTED_SUBTAGS;
|
|
24618
24885
|
if (parts.slice(1).some((part) => rejected.includes(part))) return fallback;
|
|
24619
24886
|
return supported2.find((item) => item.toLowerCase().split("-")[0] === language && item.includes("-")) ?? fallback;
|
|
24620
24887
|
}
|
|
@@ -24814,8 +25081,8 @@ function trimmedCaptions(caps) {
|
|
|
24814
25081
|
}
|
|
24815
25082
|
return Object.keys(out).length ? out : void 0;
|
|
24816
25083
|
}
|
|
24817
|
-
function authoredCaptions(
|
|
24818
|
-
const own2 =
|
|
25084
|
+
function authoredCaptions(options2) {
|
|
25085
|
+
const own2 = options2.captions ?? localizedPivotCaptions(options2.locale);
|
|
24819
25086
|
return own2 && Object.keys(own2).length ? structuredClone(own2) : void 0;
|
|
24820
25087
|
}
|
|
24821
25088
|
|
|
@@ -28914,6 +29181,8 @@ function parseChart(xml, anchor, partName, name3) {
|
|
|
28914
29181
|
showLegend: summary.showLegend,
|
|
28915
29182
|
partName
|
|
28916
29183
|
};
|
|
29184
|
+
if (summary.axes) object.axes = summary.axes;
|
|
29185
|
+
if (summary.axisIds) object.axisIds = summary.axisIds;
|
|
28917
29186
|
if (summary.grouping) object.grouping = summary.grouping;
|
|
28918
29187
|
if (summary.barGapWidth !== void 0) object.barGapWidth = summary.barGapWidth;
|
|
28919
29188
|
if (summary.barOverlap !== void 0) object.barOverlap = summary.barOverlap;
|
|
@@ -29458,9 +29727,9 @@ function readPrintOptions(node3) {
|
|
|
29458
29727
|
for (const key2 of KEYS) if (boolAttr(node3, key2)) out[key2] = true;
|
|
29459
29728
|
return Object.keys(out).length ? out : void 0;
|
|
29460
29729
|
}
|
|
29461
|
-
function printOptionsXml(
|
|
29462
|
-
if (!
|
|
29463
|
-
const attrs3 = KEYS.filter((key2) =>
|
|
29730
|
+
function printOptionsXml(options2) {
|
|
29731
|
+
if (!options2) return "";
|
|
29732
|
+
const attrs3 = KEYS.filter((key2) => options2[key2]).map((key2) => ` ${key2}="1"`);
|
|
29464
29733
|
return attrs3.length ? `<printOptions${attrs3.join("")}/>` : "";
|
|
29465
29734
|
}
|
|
29466
29735
|
|
|
@@ -30247,10 +30516,10 @@ var PackageWriter = class {
|
|
|
30247
30516
|
async build() {
|
|
30248
30517
|
const zip = new JSZip();
|
|
30249
30518
|
const date2 = new Date(Date.UTC(1980, 0, 1));
|
|
30250
|
-
const
|
|
30251
|
-
zip.file("[Content_Types].xml", this.contentTypesXml(),
|
|
30519
|
+
const options2 = { date: date2, createFolders: false };
|
|
30520
|
+
zip.file("[Content_Types].xml", this.contentTypesXml(), options2);
|
|
30252
30521
|
const names = [...this.parts.keys()].sort((a2, b) => rank2(a2) - rank2(b) || a2.localeCompare(b));
|
|
30253
|
-
for (const name3 of names) zip.file(name3, this.parts.get(name3) ?? "",
|
|
30522
|
+
for (const name3 of names) zip.file(name3, this.parts.get(name3) ?? "", options2);
|
|
30254
30523
|
return zip.generateAsync({
|
|
30255
30524
|
type: "uint8array",
|
|
30256
30525
|
compression: "DEFLATE",
|
|
@@ -31662,7 +31931,7 @@ var int3 = (value3) => Math.trunc(num2(value3));
|
|
|
31662
31931
|
var optNum = (args, i2, fallback) => i2 < args.length ? num2(args[i2]) : fallback;
|
|
31663
31932
|
var optBool = (args, i2, fallback) => i2 < args.length ? bool(args[i2]) : fallback;
|
|
31664
31933
|
var omitted = (args, i2) => i2 >= args.length || args[i2] === null;
|
|
31665
|
-
function collectNumbers(ctx, args,
|
|
31934
|
+
function collectNumbers(ctx, args, options2 = {}) {
|
|
31666
31935
|
const out = [];
|
|
31667
31936
|
for (const arg of args) {
|
|
31668
31937
|
ctx.forEach(arg, (value3, kind) => {
|
|
@@ -31671,7 +31940,7 @@ function collectNumbers(ctx, args, options = {}) {
|
|
|
31671
31940
|
return;
|
|
31672
31941
|
}
|
|
31673
31942
|
if (isError(value3)) {
|
|
31674
|
-
if (
|
|
31943
|
+
if (options2.ignoreErrors) return;
|
|
31675
31944
|
throw new ErrorSignal(value3);
|
|
31676
31945
|
}
|
|
31677
31946
|
if (kind === "direct") {
|
|
@@ -31679,7 +31948,7 @@ function collectNumbers(ctx, args, options = {}) {
|
|
|
31679
31948
|
else out.push(toNumber2(value3));
|
|
31680
31949
|
return;
|
|
31681
31950
|
}
|
|
31682
|
-
if (
|
|
31951
|
+
if (options2.includeAll) {
|
|
31683
31952
|
if (typeof value3 === "boolean") out.push(value3 ? 1 : 0);
|
|
31684
31953
|
else if (typeof value3 === "string") out.push(0);
|
|
31685
31954
|
}
|
|
@@ -36631,11 +36900,11 @@ var SUM_FUNCTIONS = [
|
|
|
36631
36900
|
255,
|
|
36632
36901
|
(args, ctx) => {
|
|
36633
36902
|
const code = int3(args[0]);
|
|
36634
|
-
const
|
|
36635
|
-
if (code < 1 || code > 19 ||
|
|
36636
|
-
const skipNested =
|
|
36637
|
-
const skipHidden =
|
|
36638
|
-
const skipErrors =
|
|
36903
|
+
const options2 = int3(args[1]);
|
|
36904
|
+
if (code < 1 || code > 19 || options2 < 0 || options2 > 7) fail(ERR.VALUE);
|
|
36905
|
+
const skipNested = options2 <= 3;
|
|
36906
|
+
const skipHidden = options2 === 1 || options2 === 3 || options2 === 5 || options2 === 7;
|
|
36907
|
+
const skipErrors = options2 === 2 || options2 === 3 || options2 === 6 || options2 === 7;
|
|
36639
36908
|
if (code >= 14) {
|
|
36640
36909
|
if (args.length !== 4) fail(ERR.VALUE);
|
|
36641
36910
|
const values2 = subtotalValues(ctx, [args[2] ?? null], skipHidden, skipErrors, skipNested);
|
|
@@ -41197,9 +41466,9 @@ var Deferred = class {
|
|
|
41197
41466
|
};
|
|
41198
41467
|
var MAX_NESTED_COMPUTE = 40;
|
|
41199
41468
|
var EngineHost = class {
|
|
41200
|
-
constructor(workbook,
|
|
41469
|
+
constructor(workbook, options2) {
|
|
41201
41470
|
this.workbook = workbook;
|
|
41202
|
-
this.options =
|
|
41471
|
+
this.options = options2;
|
|
41203
41472
|
}
|
|
41204
41473
|
workbook;
|
|
41205
41474
|
options;
|
|
@@ -42296,8 +42565,8 @@ var Engine = class extends EngineStructure {
|
|
|
42296
42565
|
return [...this.cycles].map(({ sheet, row: row3, col }) => ({ sheet, row: row3, col }));
|
|
42297
42566
|
}
|
|
42298
42567
|
};
|
|
42299
|
-
function createCalcEngine(workbook,
|
|
42300
|
-
return new Engine(workbook,
|
|
42568
|
+
function createCalcEngine(workbook, options2 = {}) {
|
|
42569
|
+
return new Engine(workbook, options2);
|
|
42301
42570
|
}
|
|
42302
42571
|
|
|
42303
42572
|
// xlsx/formula/move.ts
|
|
@@ -48655,15 +48924,15 @@ function pasteAt(ctx, s, at2, payload, request) {
|
|
|
48655
48924
|
function pasteSelection(ctx, sheet, selection, payload, request) {
|
|
48656
48925
|
const dest = normalizeRange(selection);
|
|
48657
48926
|
const clip = typeof payload === "string" ? { tsv: payload, html: "", cells: cellsFromText(ctx.workbook, payload) } : payload;
|
|
48658
|
-
const
|
|
48659
|
-
if (
|
|
48660
|
-
return pasteWidths(ctx, sheet, dest, clip.cells,
|
|
48661
|
-
const height =
|
|
48662
|
-
const width =
|
|
48927
|
+
const options2 = resolvePasteOptions(request);
|
|
48928
|
+
if (options2.mode === "widths")
|
|
48929
|
+
return pasteWidths(ctx, sheet, dest, clip.cells, options2.transpose, !!clip.cut);
|
|
48930
|
+
const height = options2.transpose ? clip.cells.cols : clip.cells.rows;
|
|
48931
|
+
const width = options2.transpose ? clip.cells.rows : clip.cells.cols;
|
|
48663
48932
|
const rows = dest.end.row - dest.start.row + 1;
|
|
48664
48933
|
const cols = dest.end.col - dest.start.col + 1;
|
|
48665
48934
|
if (clip.cut || !height || !width || rows === 1 && cols === 1 || dest.start.row === 0 && dest.end.row === MAX_ROW || dest.start.col === 0 && dest.end.col === MAX_COL)
|
|
48666
|
-
return pasteAt(ctx, sheet, dest.start, clip,
|
|
48935
|
+
return pasteAt(ctx, sheet, dest.start, clip, options2);
|
|
48667
48936
|
if (rows % height || cols % width)
|
|
48668
48937
|
throw new RangeError("The copy and paste areas are not compatible sizes.");
|
|
48669
48938
|
if (rows * cols > 25e4) throw new RangeError("The selected paste area is too large.");
|
|
@@ -48683,16 +48952,16 @@ function pasteSelection(ctx, sheet, selection, payload, request) {
|
|
|
48683
48952
|
() => {
|
|
48684
48953
|
for (let row3 = dest.start.row; row3 <= dest.end.row; row3 += height)
|
|
48685
48954
|
for (let col = dest.start.col; col <= dest.end.col; col += width)
|
|
48686
|
-
pasteAt(tileContext, sheet, { row: row3, col }, tileClip,
|
|
48687
|
-
if (["all", "formats", "noBorders", "mergeFormats"].includes(
|
|
48955
|
+
pasteAt(tileContext, sheet, { row: row3, col }, tileClip, options2);
|
|
48956
|
+
if (["all", "formats", "noBorders", "mergeFormats"].includes(options2.mode))
|
|
48688
48957
|
pasteConditionalFormats(
|
|
48689
48958
|
sheetAt(ctx.workbook, sheet),
|
|
48690
48959
|
dest,
|
|
48691
48960
|
clip.cells,
|
|
48692
|
-
|
|
48693
|
-
|
|
48961
|
+
options2.transpose,
|
|
48962
|
+
options2.skipBlanks,
|
|
48694
48963
|
void 0,
|
|
48695
|
-
|
|
48964
|
+
options2.mode === "mergeFormats"
|
|
48696
48965
|
);
|
|
48697
48966
|
return dest;
|
|
48698
48967
|
},
|
|
@@ -49143,7 +49412,7 @@ function numberInputText(value3, numFmt, date1904 = false) {
|
|
|
49143
49412
|
if (/%/.test(numFmt.replace(/"[^"]*"|\\./g, ""))) return `${plainNumber(value3 * 100)}%`;
|
|
49144
49413
|
return plainNumber(value3);
|
|
49145
49414
|
}
|
|
49146
|
-
function formulaBarText(workbook, cell,
|
|
49415
|
+
function formulaBarText(workbook, cell, options2 = {}) {
|
|
49147
49416
|
if (!cell) return "";
|
|
49148
49417
|
if (cell.formula !== void 0) return `=${cell.formula}`;
|
|
49149
49418
|
const value3 = cell.value;
|
|
@@ -49157,7 +49426,7 @@ function formulaBarText(workbook, cell, options = {}) {
|
|
|
49157
49426
|
workbook.date1904
|
|
49158
49427
|
);
|
|
49159
49428
|
const text8 = cell.richText?.length ? cell.richText.map((run2) => run2.text).join("") : value3;
|
|
49160
|
-
if (text8 === "" ||
|
|
49429
|
+
if (text8 === "" || options2.quote === false) return text8;
|
|
49161
49430
|
const parsed = parseCellInput(text8, { date1904: workbook.date1904 });
|
|
49162
49431
|
const literal2 = parsed.formula === void 0 && parsed.value === text8;
|
|
49163
49432
|
return literal2 ? text8 : `'${text8}`;
|
|
@@ -49783,9 +50052,9 @@ var SessionCalculator = class {
|
|
|
49783
50052
|
// xlsx/edit/goal-solver.ts
|
|
49784
50053
|
var DEFAULT_GOAL_ITERATIONS = 100;
|
|
49785
50054
|
var DEFAULT_GOAL_MAX_CHANGE = 1e-3;
|
|
49786
|
-
function solveGoal(f6, goal, start,
|
|
49787
|
-
const maxIterations =
|
|
49788
|
-
const tolerance =
|
|
50055
|
+
function solveGoal(f6, goal, start, options2 = {}) {
|
|
50056
|
+
const maxIterations = options2.maxIterations ?? DEFAULT_GOAL_ITERATIONS;
|
|
50057
|
+
const tolerance = options2.maxChange ?? DEFAULT_GOAL_MAX_CHANGE;
|
|
49789
50058
|
let iterations = 0;
|
|
49790
50059
|
let best;
|
|
49791
50060
|
let negative;
|
|
@@ -50262,10 +50531,10 @@ function columnOverrides(sheet, mdw, defaultPx) {
|
|
|
50262
50531
|
}
|
|
50263
50532
|
return out;
|
|
50264
50533
|
}
|
|
50265
|
-
function createGridMetrics(sheet,
|
|
50266
|
-
const zoom = zoomPercent(
|
|
50534
|
+
function createGridMetrics(sheet, options2 = {}) {
|
|
50535
|
+
const zoom = zoomPercent(options2.zoom ?? sheet.view.zoom);
|
|
50267
50536
|
const factor = zoom / 100;
|
|
50268
|
-
const mdw =
|
|
50537
|
+
const mdw = options2.mdw ?? DEFAULT_MAX_DIGIT_WIDTH;
|
|
50269
50538
|
const scale2 = (px2) => px2 > 0 ? Math.max(1, Math.round(px2 * factor)) : 0;
|
|
50270
50539
|
const defaultColPx = defaultColumnPixels(sheet.defaultColWidth, mdw);
|
|
50271
50540
|
const colOverrides = [...columnOverrides(sheet, mdw, defaultColPx)].map(
|
|
@@ -50287,8 +50556,8 @@ function createGridMetrics(sheet, options = {}) {
|
|
|
50287
50556
|
for (const merge2 of sheet.merges) lastColUsed = Math.max(lastColUsed, merge2.end.col);
|
|
50288
50557
|
for (const info of sheet.columns)
|
|
50289
50558
|
if (info.max < MAX_COL) lastColUsed = Math.max(lastColUsed, info.max);
|
|
50290
|
-
const lastRow = Math.min(MAX_ROW, lastRowUsed + (
|
|
50291
|
-
const lastCol = Math.min(MAX_COL, lastColUsed + (
|
|
50559
|
+
const lastRow = Math.min(MAX_ROW, lastRowUsed + (options2.extraRows ?? 50));
|
|
50560
|
+
const lastCol = Math.min(MAX_COL, lastColUsed + (options2.extraCols ?? 20));
|
|
50292
50561
|
return {
|
|
50293
50562
|
zoom,
|
|
50294
50563
|
lastRow,
|
|
@@ -50508,37 +50777,37 @@ function writePivot(ctx, s, pivot, old, label2, inside2) {
|
|
|
50508
50777
|
);
|
|
50509
50778
|
}
|
|
50510
50779
|
var startRow = (range2, offset2) => range2.start.row + offset2;
|
|
50511
|
-
function createPivotTable(ctx, s, destination,
|
|
50512
|
-
const data = pivotSourceData(ctx.workbook, s,
|
|
50513
|
-
const name3 =
|
|
50780
|
+
function createPivotTable(ctx, s, destination, options2) {
|
|
50781
|
+
const data = pivotSourceData(ctx.workbook, s, options2.source);
|
|
50782
|
+
const name3 = options2.name ?? uniqueName(ctx);
|
|
50514
50783
|
checkName2(ctx, name3);
|
|
50515
|
-
const aggregate2 =
|
|
50516
|
-
const captions = authoredCaptions(
|
|
50784
|
+
const aggregate2 = options2.aggregate ?? "sum";
|
|
50785
|
+
const captions = authoredCaptions(options2);
|
|
50517
50786
|
const pivot = {
|
|
50518
50787
|
...data,
|
|
50519
50788
|
...captions ? { captions } : {},
|
|
50520
50789
|
name: name3,
|
|
50521
|
-
rowField:
|
|
50522
|
-
layout:
|
|
50523
|
-
subtotalPosition:
|
|
50524
|
-
...
|
|
50525
|
-
...
|
|
50526
|
-
...
|
|
50527
|
-
...
|
|
50790
|
+
rowField: options2.rowField,
|
|
50791
|
+
layout: options2.layout ?? "tabular",
|
|
50792
|
+
subtotalPosition: options2.subtotalPosition ?? (options2.layout && options2.layout !== "tabular" ? "top" : "bottom"),
|
|
50793
|
+
...options2.secondRowField ? { secondRowField: options2.secondRowField } : {},
|
|
50794
|
+
...options2.secondRowField && options2.moreRowFields?.length ? { moreRowFields: [...options2.moreRowFields] } : {},
|
|
50795
|
+
...options2.fieldSubtotals?.length ? { fieldSubtotals: normalizedFieldSubtotals(options2.fieldSubtotals) } : {},
|
|
50796
|
+
...options2.dateGroups?.length ? { dateGroups: structuredClone(options2.dateGroups) } : {},
|
|
50528
50797
|
...ctx.workbook.date1904 ? { date1904: true } : {},
|
|
50529
|
-
...
|
|
50530
|
-
...
|
|
50531
|
-
valueField:
|
|
50798
|
+
...options2.subtotals !== void 0 ? { subtotals: options2.subtotals } : {},
|
|
50799
|
+
...options2.repeatLabels !== void 0 ? { repeatLabels: options2.repeatLabels } : {},
|
|
50800
|
+
valueField: options2.valueField,
|
|
50532
50801
|
aggregate: aggregate2,
|
|
50533
|
-
valueCaption: pivotCaption(aggregate2,
|
|
50534
|
-
...
|
|
50535
|
-
...
|
|
50536
|
-
...
|
|
50537
|
-
...
|
|
50538
|
-
...
|
|
50802
|
+
valueCaption: pivotCaption(aggregate2, options2.valueField, { captions }),
|
|
50803
|
+
...options2.pageFilter !== void 0 ? { pageFilter: structuredClone(options2.pageFilter) } : {},
|
|
50804
|
+
...options2.fieldGroups?.length ? { fieldGroups: structuredClone(options2.fieldGroups) } : {},
|
|
50805
|
+
...options2.valuesAxis !== void 0 ? { valuesAxis: options2.valuesAxis } : {},
|
|
50806
|
+
...options2.valuesPosition !== void 0 ? { valuesPosition: options2.valuesPosition } : {},
|
|
50807
|
+
...options2.additionalValues ? { additionalValues: normalizedPivotMeasures(options2.additionalValues, { captions }) } : {},
|
|
50539
50808
|
location: { start: { ...destination }, end: { ...destination } },
|
|
50540
|
-
...
|
|
50541
|
-
...
|
|
50809
|
+
...options2.columnField ? { columnField: options2.columnField } : {},
|
|
50810
|
+
...options2.columnField && options2.moreColumnFields?.length ? { moreColumnFields: [...options2.moreColumnFields] } : {}
|
|
50542
50811
|
};
|
|
50543
50812
|
if (pivot.dateGroups) reconcileDateAxes(pivot);
|
|
50544
50813
|
const dates = pivotDateFieldsOf(ctx.workbook, s, pivot);
|
|
@@ -54503,7 +54772,7 @@ function displayText2(value3, style3, numFmt, workbook, sheet) {
|
|
|
54503
54772
|
});
|
|
54504
54773
|
return formatted.color ? { text: formatted.text, color: formatted.color } : { text: formatted.text };
|
|
54505
54774
|
}
|
|
54506
|
-
function cellView(workbook, sheetIndex2, row3, col, cf,
|
|
54775
|
+
function cellView(workbook, sheetIndex2, row3, col, cf, options2 = {}) {
|
|
54507
54776
|
const sheet = workbook.sheets[sheetIndex2];
|
|
54508
54777
|
if (!sheet) throw new RangeError(`No sheet at index ${sheetIndex2}`);
|
|
54509
54778
|
const cell = getCell(sheet, row3, col);
|
|
@@ -54541,10 +54810,10 @@ function cellView(workbook, sheetIndex2, row3, col, cf, options = {}) {
|
|
|
54541
54810
|
vAlign: alignment.vertical ?? "bottom",
|
|
54542
54811
|
wrap: wrap3,
|
|
54543
54812
|
shrink,
|
|
54544
|
-
indentPx: indentable ? (alignment.indent ?? 0) * (
|
|
54813
|
+
indentPx: indentable ? (alignment.indent ?? 0) * (options2.indentPx ?? INDENT_PX_PER_LEVEL) : 0,
|
|
54545
54814
|
rotation,
|
|
54546
54815
|
isNumber,
|
|
54547
|
-
overflow: (formulaText !== void 0 || typeof value3 === "string" && value3 !== "") && !wrap3 && !shrink && rotation === 0 && !vertical2 && hAlign !== "fill" && !(
|
|
54816
|
+
overflow: (formulaText !== void 0 || typeof value3 === "string" && value3 !== "") && !wrap3 && !shrink && rotation === 0 && !vertical2 && hAlign !== "fill" && !(options2.merged ?? sheet.merges.some((m) => rangeContains(m, { row: row3, col }))),
|
|
54548
54817
|
hasComment: sheet.comments.some((c2) => c2.address.row === row3 && c2.address.col === col),
|
|
54549
54818
|
hasHyperlink: false,
|
|
54550
54819
|
validationList: sheet.dataValidations.some(
|
|
@@ -55158,11 +55427,11 @@ function check2(workbook, dv, value3, at2, evaluate) {
|
|
|
55158
55427
|
if (dv.type === "whole" && !Number.isInteger(n)) return false;
|
|
55159
55428
|
return compare(operator, n, a2, b);
|
|
55160
55429
|
}
|
|
55161
|
-
function validateCellInput(workbook, sheet, row3, col, value3,
|
|
55430
|
+
function validateCellInput(workbook, sheet, row3, col, value3, options2 = {}) {
|
|
55162
55431
|
const dv = validationAt(workbook, sheet, row3, col);
|
|
55163
55432
|
if (!dv || dv.type === "none" || dv.showErrorMessage !== true) return { ok: true };
|
|
55164
55433
|
if (value3 === null || value3 === "") return dv.allowBlank === false ? failure(dv) : { ok: true };
|
|
55165
|
-
const evaluate =
|
|
55434
|
+
const evaluate = options2.evaluate ?? defaultEvaluate(workbook);
|
|
55166
55435
|
return check2(workbook, dv, value3, { sheet, row: row3, col }, evaluate) ? { ok: true } : failure(dv);
|
|
55167
55436
|
}
|
|
55168
55437
|
function failure(dv) {
|
|
@@ -55176,10 +55445,10 @@ function failure(dv) {
|
|
|
55176
55445
|
}
|
|
55177
55446
|
|
|
55178
55447
|
// xlsx/edit/session.ts
|
|
55179
|
-
function createEditSession(workbook,
|
|
55448
|
+
function createEditSession(workbook, options2 = {}) {
|
|
55180
55449
|
const calc = createCalcEngine(workbook);
|
|
55181
|
-
const autoRecalc =
|
|
55182
|
-
const history = new History(
|
|
55450
|
+
const autoRecalc = options2.recalc ?? true;
|
|
55451
|
+
const history = new History(options2.historyLimit ?? 100);
|
|
55183
55452
|
const listeners = /* @__PURE__ */ new Set();
|
|
55184
55453
|
let open;
|
|
55185
55454
|
const emit = (change) => {
|
|
@@ -55278,8 +55547,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
55278
55547
|
return result2;
|
|
55279
55548
|
};
|
|
55280
55549
|
const ctx = { workbook, calc, run: run2 };
|
|
55281
|
-
if (
|
|
55282
|
-
const autoRows =
|
|
55550
|
+
if (options2.defaultSheetBase) ctx.defaultSheetBase = options2.defaultSheetBase;
|
|
55551
|
+
const autoRows = options2.autoRowHeight ?? true;
|
|
55283
55552
|
const refitRows = (current) => {
|
|
55284
55553
|
const { sheet: s, kind, ranges } = current;
|
|
55285
55554
|
if (!autoRows || s === void 0 || !ranges.length || !current.step.entries.length) return;
|
|
@@ -55287,7 +55556,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
55287
55556
|
const sheet = workbook.sheets[s];
|
|
55288
55557
|
if (!sheet) return;
|
|
55289
55558
|
try {
|
|
55290
|
-
autoGrowRows(ctx, s, rowsToRefit(sheet, ranges),
|
|
55559
|
+
autoGrowRows(ctx, s, rowsToRefit(sheet, ranges), options2.measureText);
|
|
55291
55560
|
} catch (error) {
|
|
55292
55561
|
const message = `Row height update failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
55293
55562
|
if (!workbook.warnings.includes(message)) workbook.warnings.push(message);
|
|
@@ -55350,7 +55619,7 @@ function createEditSession(workbook, options = {}) {
|
|
|
55350
55619
|
setDefinedName: (name3) => setDefinedName(ctx, name3),
|
|
55351
55620
|
deleteDefinedName: (name3, localSheet) => deleteDefinedName(ctx, name3, localSheet),
|
|
55352
55621
|
setDrawingAnchor: (s, index3, anchor) => setDrawingAnchor(ctx, s, index3, anchor),
|
|
55353
|
-
createPivotTable: (s, destination,
|
|
55622
|
+
createPivotTable: (s, destination, options3) => createPivotTable(ctx, s, destination, options3),
|
|
55354
55623
|
refreshPivotTable: (s, name3, patch2) => refreshPivotTable(ctx, s, name3, patch2),
|
|
55355
55624
|
deletePivotTable: (s, name3) => deletePivotTable(ctx, s, name3),
|
|
55356
55625
|
setSlicerSelection: (cache3, keys) => setSlicerSelection(ctx, cache3, keys),
|
|
@@ -55400,8 +55669,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
55400
55669
|
setDocumentProperties: (patch2) => setDocumentProperties(ctx, patch2),
|
|
55401
55670
|
setAutoRecalc: (enabled2) => setCalcMode(ctx, enabled2 ? "auto" : "manual"),
|
|
55402
55671
|
autoRecalc: () => autoRecalc && calcModeOf(workbook) === "auto",
|
|
55403
|
-
calculateNow(
|
|
55404
|
-
calculator.now(
|
|
55672
|
+
calculateNow(options3) {
|
|
55673
|
+
calculator.now(options3?.full ?? false);
|
|
55405
55674
|
emit({ kind: "cells", label: "Calculate now", structural: false });
|
|
55406
55675
|
},
|
|
55407
55676
|
prepareCalculation: (opts) => calculator.prepare(opts?.timeRemaining),
|
|
@@ -55905,8 +56174,8 @@ var VisioPackage = class _VisioPackage {
|
|
|
55905
56174
|
if (Date.now() >= this.deadline)
|
|
55906
56175
|
fail2("LIMIT_RUNTIME", "Visio package processing deadline exceeded");
|
|
55907
56176
|
};
|
|
55908
|
-
static async open(input,
|
|
55909
|
-
const limits = { ...DEFAULTS2, ...
|
|
56177
|
+
static async open(input, options2 = {}) {
|
|
56178
|
+
const limits = { ...DEFAULTS2, ...options2 };
|
|
55910
56179
|
for (const value3 of Object.values(limits))
|
|
55911
56180
|
if (!Number.isFinite(value3) || value3 <= 0)
|
|
55912
56181
|
fail2("INVALID_LIMITS", "Package limits must be finite positive numbers");
|
|
@@ -56387,16 +56656,16 @@ function emfInputView(input) {
|
|
|
56387
56656
|
return null;
|
|
56388
56657
|
}
|
|
56389
56658
|
}
|
|
56390
|
-
function emfInputOptions(
|
|
56391
|
-
if (!
|
|
56659
|
+
function emfInputOptions(options2) {
|
|
56660
|
+
if (!options2 || typeof options2 !== "object") return null;
|
|
56392
56661
|
try {
|
|
56393
|
-
const prototype = Object.getPrototypeOf(
|
|
56662
|
+
const prototype = Object.getPrototypeOf(options2);
|
|
56394
56663
|
if (prototype !== null && prototype !== Object.prototype) return null;
|
|
56395
56664
|
const snapshot = {};
|
|
56396
56665
|
for (const key2 of Object.keys(
|
|
56397
56666
|
VISIO_EMF_ADMISSION_LIMITS
|
|
56398
56667
|
)) {
|
|
56399
|
-
const descriptor = Object.getOwnPropertyDescriptor(
|
|
56668
|
+
const descriptor = Object.getOwnPropertyDescriptor(options2, key2);
|
|
56400
56669
|
if (!descriptor) continue;
|
|
56401
56670
|
if (!("value" in descriptor)) return null;
|
|
56402
56671
|
const value3 = descriptor.value;
|
|
@@ -56412,18 +56681,18 @@ function emfInputOptions(options) {
|
|
|
56412
56681
|
|
|
56413
56682
|
// visio/emf-admission-context.ts
|
|
56414
56683
|
var EmfAdmissionContext = class {
|
|
56415
|
-
constructor(view,
|
|
56684
|
+
constructor(view, options2) {
|
|
56416
56685
|
this.view = view;
|
|
56417
56686
|
this.limits = { ...VISIO_EMF_ADMISSION_LIMITS };
|
|
56418
|
-
if (!
|
|
56687
|
+
if (!options2 || typeof options2 !== "object") {
|
|
56419
56688
|
this.emit("invalid", "limits", "Expected an options object.");
|
|
56420
56689
|
return;
|
|
56421
56690
|
}
|
|
56422
|
-
const cap =
|
|
56691
|
+
const cap = options2.maxDiagnostics;
|
|
56423
56692
|
if (cap !== void 0 && Number.isInteger(cap) && cap > 0 && cap <= this.limits.maxDiagnostics)
|
|
56424
56693
|
this.limits.maxDiagnostics = cap;
|
|
56425
56694
|
for (const key2 of Object.keys(VISIO_EMF_ADMISSION_LIMITS)) {
|
|
56426
|
-
const value3 =
|
|
56695
|
+
const value3 = options2[key2];
|
|
56427
56696
|
if (value3 === void 0) continue;
|
|
56428
56697
|
if (!Number.isSafeInteger(value3) || value3 < 1 || value3 > this.limits[key2])
|
|
56429
56698
|
this.emit("invalid", "limits", "Limits must be positive integers below the hard ceiling.");
|
|
@@ -56976,8 +57245,8 @@ function inspectEmfObjectRecord(c2) {
|
|
|
56976
57245
|
}
|
|
56977
57246
|
|
|
56978
57247
|
// visio/emf-admission.ts
|
|
56979
|
-
function inspectVisioEmfAdmission(input,
|
|
56980
|
-
const snapshot = emfInputOptions(
|
|
57248
|
+
function inspectVisioEmfAdmission(input, options2 = {}) {
|
|
57249
|
+
const snapshot = emfInputOptions(options2);
|
|
56981
57250
|
const view = snapshot === null ? null : emfInputView(input);
|
|
56982
57251
|
const c2 = new EmfAdmissionContext(view ?? new DataView(new ArrayBuffer(0)), snapshot ?? {});
|
|
56983
57252
|
if (snapshot === null) {
|
|
@@ -57201,9 +57470,9 @@ function record(value3, allowed) {
|
|
|
57201
57470
|
}
|
|
57202
57471
|
return result2;
|
|
57203
57472
|
}
|
|
57204
|
-
function limitsFor(
|
|
57473
|
+
function limitsFor(options2) {
|
|
57205
57474
|
const result2 = { ...VISIO_FOREIGN_VECTOR_LIMITS };
|
|
57206
|
-
const values2 = record(
|
|
57475
|
+
const values2 = record(options2, Object.keys(result2));
|
|
57207
57476
|
for (const key2 of Object.keys(values2)) {
|
|
57208
57477
|
const value3 = values2[key2];
|
|
57209
57478
|
if (typeof value3 !== "number" || !Number.isSafeInteger(value3) || value3 < 1 || value3 > result2[key2])
|
|
@@ -57557,9 +57826,9 @@ var ATTRS = {
|
|
|
57557
57826
|
clipPath: ["id", "clipPathUnits", "clip-rule", ...BASE2]
|
|
57558
57827
|
};
|
|
57559
57828
|
var ID = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
|
|
57560
|
-
function sanitizeVisioForeignVectorTree(root,
|
|
57829
|
+
function sanitizeVisioForeignVectorTree(root, options2 = {}) {
|
|
57561
57830
|
try {
|
|
57562
|
-
return sanitize(root, limitsFor(
|
|
57831
|
+
return sanitize(root, limitsFor(options2));
|
|
57563
57832
|
} catch (error) {
|
|
57564
57833
|
if (error instanceof VisioForeignVectorError) throw error;
|
|
57565
57834
|
unsafe("Unable to inspect converter output safely.");
|
|
@@ -58075,10 +58344,10 @@ function jpeg(bytes, limits) {
|
|
|
58075
58344
|
}
|
|
58076
58345
|
return invalid("JPEG has no image terminator.");
|
|
58077
58346
|
}
|
|
58078
|
-
function inspectVisioRasterImage(bytes,
|
|
58079
|
-
if (!
|
|
58347
|
+
function inspectVisioRasterImage(bytes, options2 = {}) {
|
|
58348
|
+
if (!options2 || typeof options2 !== "object" || Array.isArray(options2))
|
|
58080
58349
|
throw new VisioImageError("invalid-limit", "Image limits must be an options object.");
|
|
58081
|
-
const limits = { ...VISIO_RASTER_IMAGE_LIMITS, ...
|
|
58350
|
+
const limits = { ...VISIO_RASTER_IMAGE_LIMITS, ...options2 };
|
|
58082
58351
|
for (const key2 of Object.keys(VISIO_RASTER_IMAGE_LIMITS)) {
|
|
58083
58352
|
const value3 = limits[key2];
|
|
58084
58353
|
if (!Number.isSafeInteger(value3) || value3 <= 0 || value3 > VISIO_RASTER_IMAGE_LIMITS[key2])
|
|
@@ -58089,10 +58358,10 @@ function inspectVisioRasterImage(bytes, options = {}) {
|
|
|
58089
58358
|
throw new VisioImageError("image-limit", "Raster image bytes exceed the configured limit.");
|
|
58090
58359
|
return inspect2(bytes, limits);
|
|
58091
58360
|
}
|
|
58092
|
-
async function readVisioImage(pkg, sourcePart, foreignData, report,
|
|
58361
|
+
async function readVisioImage(pkg, sourcePart, foreignData, report, options2 = {}) {
|
|
58093
58362
|
const limits = {
|
|
58094
58363
|
...VISIO_RASTER_IMAGE_LIMITS,
|
|
58095
|
-
...
|
|
58364
|
+
...options2
|
|
58096
58365
|
};
|
|
58097
58366
|
if (Object.values(limits).some((value3) => !Number.isSafeInteger(value3) || value3 <= 0))
|
|
58098
58367
|
throw new VisioPackageError("INVALID_LIMIT", "Image limits must be positive safe integers.");
|
|
@@ -58352,7 +58621,7 @@ async function readEmbeddedChartObject(pkg, sourcePart, foreignData, report) {
|
|
|
58352
58621
|
}
|
|
58353
58622
|
|
|
58354
58623
|
// visio/prepare-images.ts
|
|
58355
|
-
async function prepareImages(shapes, pkg, sourcePart, report,
|
|
58624
|
+
async function prepareImages(shapes, pkg, sourcePart, report, options2, converter) {
|
|
58356
58625
|
for (const shape2 of shapes) {
|
|
58357
58626
|
if (shape2.deleted) continue;
|
|
58358
58627
|
const localReport = (code, message, extra) => report(code, message, { part: sourcePart, shapeId: shape2.id, ...extra });
|
|
@@ -58380,12 +58649,12 @@ async function prepareImages(shapes, pkg, sourcePart, report, options, converter
|
|
|
58380
58649
|
sourcePart,
|
|
58381
58650
|
shape2.foreignData,
|
|
58382
58651
|
localReport,
|
|
58383
|
-
|
|
58652
|
+
options2
|
|
58384
58653
|
);
|
|
58385
58654
|
if (image) shape2.image = image;
|
|
58386
58655
|
}
|
|
58387
58656
|
}
|
|
58388
|
-
await prepareImages(shape2.children, pkg, sourcePart, report,
|
|
58657
|
+
await prepareImages(shape2.children, pkg, sourcePart, report, options2, converter);
|
|
58389
58658
|
}
|
|
58390
58659
|
}
|
|
58391
58660
|
|
|
@@ -62853,8 +63122,8 @@ function readVisioAnnotations(sheet, pageId2) {
|
|
|
62853
63122
|
}
|
|
62854
63123
|
|
|
62855
63124
|
// visio/shape-metadata.ts
|
|
62856
|
-
function createMetadataBudget(
|
|
62857
|
-
const maxRows =
|
|
63125
|
+
function createMetadataBudget(options2 = {}) {
|
|
63126
|
+
const maxRows = options2.maxRows ?? 1e5, maxCharacters = options2.maxCharacters ?? 5e6;
|
|
62858
63127
|
if (![maxRows, maxCharacters].every((v) => Number.isSafeInteger(v) && v > 0))
|
|
62859
63128
|
throw new VisioPackageError("INVALID_LIMIT", "Metadata limits must be positive safe integers.");
|
|
62860
63129
|
let rows = 0, characters = 0;
|
|
@@ -64421,21 +64690,21 @@ function option(value3, fallback) {
|
|
|
64421
64690
|
throw new VisioPackageError("INVALID_LIMIT", "Parser limits must be positive safe integers.");
|
|
64422
64691
|
return value3;
|
|
64423
64692
|
}
|
|
64424
|
-
async function parseVsdx(input,
|
|
64425
|
-
const deadline = Date.now() + (
|
|
64693
|
+
async function parseVsdx(input, options2 = {}) {
|
|
64694
|
+
const deadline = Date.now() + (options2.limits?.maxRuntimeMs ?? 1e4);
|
|
64426
64695
|
const checkTime = () => {
|
|
64427
64696
|
if (Date.now() >= deadline)
|
|
64428
64697
|
throw new VisioPackageError("LIMIT_RUNTIME", "Visio parsing deadline exceeded.");
|
|
64429
64698
|
};
|
|
64430
|
-
const maxShapes = option(
|
|
64431
|
-
const maxCurveWork = option(
|
|
64699
|
+
const maxShapes = option(options2.maxShapes, 25e3), maxShapeDepth = option(options2.maxShapeDepth, 64);
|
|
64700
|
+
const maxCurveWork = option(options2.maxCurveWork, 2e7);
|
|
64432
64701
|
let curveWork = 0;
|
|
64433
|
-
const maxGeometry = option(
|
|
64434
|
-
const maxDiagnostics = option(
|
|
64435
|
-
const maxRuns = option(
|
|
64702
|
+
const maxGeometry = option(options2.maxGeometryCommands, 5e5), maxText = option(options2.maxTextCharacters, 5e6);
|
|
64703
|
+
const maxDiagnostics = option(options2.maxDiagnostics, 2e3);
|
|
64704
|
+
const maxRuns = option(options2.maxTextRuns, 1e5), maxParagraphs = option(options2.maxParagraphs, 5e4);
|
|
64436
64705
|
const diagnosticState = diagnosticCollector(maxDiagnostics);
|
|
64437
64706
|
const report = diagnosticState.report;
|
|
64438
|
-
const pkg = await VisioPackage.open(input,
|
|
64707
|
+
const pkg = await VisioPackage.open(input, options2.limits);
|
|
64439
64708
|
const types = await pkg.readXml("[Content_Types].xml", "Types");
|
|
64440
64709
|
if (types.namespaceURI !== "http://schemas.openxmlformats.org/package/2006/content-types")
|
|
64441
64710
|
throw new VisioPackageError("INVALID_CONTENT_TYPES", "Invalid content type namespace.");
|
|
@@ -64445,7 +64714,7 @@ async function parseVsdx(input, options = {}) {
|
|
|
64445
64714
|
const documentType = elements(types).find(
|
|
64446
64715
|
(node3) => node3.localName === "Override" && attribute3(node3, "PartName") === `/${documentPart}`
|
|
64447
64716
|
)?.getAttribute("ContentType");
|
|
64448
|
-
if (documentType !== "application/vnd.ms-visio.drawing.main+xml" && !(
|
|
64717
|
+
if (documentType !== "application/vnd.ms-visio.drawing.main+xml" && !(options2.stencil && documentType && STENCIL_MAIN_TYPES.has(documentType)))
|
|
64449
64718
|
throw new VisioPackageError(
|
|
64450
64719
|
"UNSUPPORTED_FORMAT",
|
|
64451
64720
|
"Only VSDX drawing packages are supported; VSD, VDX, VSDM and templates are not supported."
|
|
@@ -64518,8 +64787,8 @@ async function parseVsdx(input, options = {}) {
|
|
|
64518
64787
|
pkg,
|
|
64519
64788
|
part,
|
|
64520
64789
|
report,
|
|
64521
|
-
|
|
64522
|
-
|
|
64790
|
+
options2.images,
|
|
64791
|
+
options2.metafileConverter
|
|
64523
64792
|
);
|
|
64524
64793
|
masters.set(id3, masterShapes2);
|
|
64525
64794
|
masterRecords.push({ id: id3, node: master2, shapes: masterShapes2 });
|
|
@@ -64527,7 +64796,7 @@ async function parseVsdx(input, options = {}) {
|
|
|
64527
64796
|
}
|
|
64528
64797
|
let geometryCount = 0, textCount = 0, expansionCount = 0, textRuns = 0, paragraphCount = 0;
|
|
64529
64798
|
const context = {
|
|
64530
|
-
metadataBudget: createMetadataBudget(
|
|
64799
|
+
metadataBudget: createMetadataBudget(options2.metadata),
|
|
64531
64800
|
layerBudget: createLayerBudget(),
|
|
64532
64801
|
masters,
|
|
64533
64802
|
layers: /* @__PURE__ */ new Map(),
|
|
@@ -64579,11 +64848,11 @@ async function parseVsdx(input, options = {}) {
|
|
|
64579
64848
|
}
|
|
64580
64849
|
};
|
|
64581
64850
|
const documentMasters = listVisioMasters(masterRecords, context, {
|
|
64582
|
-
metadataBudget: createMetadataBudget(
|
|
64851
|
+
metadataBudget: createMetadataBudget(options2.metadata),
|
|
64583
64852
|
layerBudget: createLayerBudget()
|
|
64584
64853
|
});
|
|
64585
|
-
const pagesPart = await related(pkg, documentPart, "pages", !
|
|
64586
|
-
if (!pagesPart && !
|
|
64854
|
+
const pagesPart = await related(pkg, documentPart, "pages", !options2.stencil);
|
|
64855
|
+
if (!pagesPart && !options2.stencil)
|
|
64587
64856
|
throw new VisioPackageError("INVALID_DOCUMENT", "Missing Visio pages part.");
|
|
64588
64857
|
const pages = [], pageIds2 = /* @__PURE__ */ new Set();
|
|
64589
64858
|
const comments = [];
|
|
@@ -64637,8 +64906,8 @@ async function parseVsdx(input, options = {}) {
|
|
|
64637
64906
|
pkg,
|
|
64638
64907
|
part,
|
|
64639
64908
|
localReport,
|
|
64640
|
-
|
|
64641
|
-
|
|
64909
|
+
options2.images,
|
|
64910
|
+
options2.metafileConverter
|
|
64642
64911
|
);
|
|
64643
64912
|
const shapes = normalizeShapes(rawShapes, context);
|
|
64644
64913
|
normalizeVisioPageGeometry(shapes, drawingToPageScale, checkTime);
|
|
@@ -65968,9 +66237,9 @@ function cellUnit(name3, relative) {
|
|
|
65968
66237
|
return !relative && /\.[XY]\d+$/i.test(name3) ? "length" : "scalar";
|
|
65969
66238
|
}
|
|
65970
66239
|
var isBooleanLiteral = (ref) => ref.shapeId === void 0 && /^(true|false)$/i.test(ref.cell);
|
|
65971
|
-
function indexCells2(roots,
|
|
66240
|
+
function indexCells2(roots, options2) {
|
|
65972
66241
|
const cells3 = /* @__PURE__ */ new Map();
|
|
65973
|
-
const maxCells = bound(
|
|
66242
|
+
const maxCells = bound(options2.maxCells, 1e5);
|
|
65974
66243
|
const add4 = (item) => {
|
|
65975
66244
|
const id3 = key(item);
|
|
65976
66245
|
if (cells3.has(id3)) fail2("EDIT_AMBIGUOUS_CELL", "Duplicate local ShapeSheet cell.");
|
|
@@ -65996,11 +66265,11 @@ function indexCells2(roots, options) {
|
|
|
65996
66265
|
const visit2 = (parent, inherited, nested) => {
|
|
65997
66266
|
for (const container of children3(parent, "Shapes"))
|
|
65998
66267
|
for (const node3 of children3(container, "Shape")) {
|
|
65999
|
-
|
|
66268
|
+
options2.check?.();
|
|
66000
66269
|
const shapeId2 = attribute3(node3, "ID");
|
|
66001
66270
|
if (!shapeId2 || ids.has(shapeId2)) fail2("INVALID_SHAPE_ID", "Shape IDs must be unique.");
|
|
66002
66271
|
ids.add(shapeId2);
|
|
66003
|
-
const unsafe2 = inherited || nested || node3.hasAttribute("Master") || node3.hasAttribute("MasterShape") || attribute3(node3, "Type") === "Group" || !isLocalForeignFrameShape(node3) && (attribute3(node3, "Type") !== void 0 && attribute3(node3, "Type") !== "Shape" || children3(node3, "ForeignData").length > 0 || children3(node3, "Rel").length > 0) || connected.has(shapeId2) && !
|
|
66272
|
+
const unsafe2 = inherited || nested || node3.hasAttribute("Master") || node3.hasAttribute("MasterShape") || attribute3(node3, "Type") === "Group" || !isLocalForeignFrameShape(node3) && (attribute3(node3, "Type") !== void 0 && attribute3(node3, "Type") !== "Shape" || children3(node3, "ForeignData").length > 0 || children3(node3, "Rel").length > 0) || connected.has(shapeId2) && !options2.glueShapes?.has(node3) || !options2.lineEditShapes?.has(node3) && children3(node3, "Cell").some(
|
|
66004
66273
|
(cell) => /^(BeginX|BeginY|EndX|EndY)$/i.test(attribute3(cell, "N") ?? "") || attribute3(cell, "N")?.toLowerCase() === "oned" && (attribute3(cell, "V") !== "0" || !!executableCellFormula(attribute3(cell, "F")) || attribute3(cell, "F") === "Inh")
|
|
66005
66274
|
) || children3(node3, "Shapes").length > 0 || ["1", "true"].includes(attribute3(node3, "Del") ?? "");
|
|
66006
66275
|
sheets.push({ node: node3, shapeId: shapeId2, unsafe: unsafe2 });
|
|
@@ -66093,7 +66362,7 @@ function indexCells2(roots, options) {
|
|
|
66093
66362
|
}
|
|
66094
66363
|
}
|
|
66095
66364
|
for (const node3 of Array.from(root.getElementsByTagName("*"))) {
|
|
66096
|
-
|
|
66365
|
+
options2.check?.();
|
|
66097
66366
|
if (node3.hasAttribute("F") && !indexedNodes.has(node3))
|
|
66098
66367
|
fail2(
|
|
66099
66368
|
"EDIT_UNKNOWN_DEPENDENCY",
|
|
@@ -66105,12 +66374,12 @@ function indexCells2(roots, options) {
|
|
|
66105
66374
|
}
|
|
66106
66375
|
|
|
66107
66376
|
// visio/edit-recalculate-values.ts
|
|
66108
|
-
function createVisioCellEvaluator(cells3,
|
|
66377
|
+
function createVisioCellEvaluator(cells3, options2 = {}, verifyCaches = false) {
|
|
66109
66378
|
const active = /* @__PURE__ */ new Set(), values2 = /* @__PURE__ */ new Map();
|
|
66110
|
-
let steps = bound(
|
|
66111
|
-
const maxDepth = bound(
|
|
66379
|
+
let steps = bound(options2.maxSteps, 1e5);
|
|
66380
|
+
const maxDepth = bound(options2.maxDepth, 64);
|
|
66112
66381
|
const evaluate = (id3) => {
|
|
66113
|
-
|
|
66382
|
+
options2.check?.();
|
|
66114
66383
|
if (--steps < 0)
|
|
66115
66384
|
fail2("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
|
|
66116
66385
|
const cached6 = values2.get(id3);
|
|
@@ -66119,7 +66388,7 @@ function createVisioCellEvaluator(cells3, options = {}, verifyCaches = false) {
|
|
|
66119
66388
|
if (active.size >= maxDepth)
|
|
66120
66389
|
fail2("LIMIT_FORMULA_DEPTH", "ShapeSheet dependency depth limit exceeded.");
|
|
66121
66390
|
const item = cells3.get(id3);
|
|
66122
|
-
if (!item || item.unsafe && (!item.node || !
|
|
66391
|
+
if (!item || item.unsafe && (!item.node || !options2.masterMovePins?.has(item.node) && !options2.groupRotationCells?.has(item.node)))
|
|
66123
66392
|
fail2(
|
|
66124
66393
|
"EDIT_UNSUPPORTED_DEPENDENCY",
|
|
66125
66394
|
"Affected formula references missing, inherited or grouped cells."
|
|
@@ -66143,7 +66412,7 @@ function createVisioCellEvaluator(cells3, options = {}, verifyCaches = false) {
|
|
|
66143
66412
|
key({ pageId: item.pageId, shapeId: ref.shapeId ?? item.shapeId, cell: ref.cell })
|
|
66144
66413
|
),
|
|
66145
66414
|
{
|
|
66146
|
-
...
|
|
66415
|
+
...options2.pageContext?.get(item.pageId),
|
|
66147
66416
|
onStep: () => {
|
|
66148
66417
|
if (--steps < 0)
|
|
66149
66418
|
fail2("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
|
|
@@ -66175,8 +66444,8 @@ function createVisioCellEvaluator(cells3, options = {}, verifyCaches = false) {
|
|
|
66175
66444
|
}
|
|
66176
66445
|
|
|
66177
66446
|
// visio/edit-recalculate.ts
|
|
66178
|
-
function recalculateVisioCells(roots, changed,
|
|
66179
|
-
const cells3 = indexCells2(roots,
|
|
66447
|
+
function recalculateVisioCells(roots, changed, options2 = {}) {
|
|
66448
|
+
const cells3 = indexCells2(roots, options2);
|
|
66180
66449
|
const reverse2 = /* @__PURE__ */ new Map();
|
|
66181
66450
|
for (const [id3, item] of cells3)
|
|
66182
66451
|
for (const dependency of item.dependencies) {
|
|
@@ -66186,9 +66455,9 @@ function recalculateVisioCells(roots, changed, options = {}) {
|
|
|
66186
66455
|
}
|
|
66187
66456
|
const affected = new Set(changed.map(key));
|
|
66188
66457
|
const pending2 = [...affected];
|
|
66189
|
-
const maxAffected = bound(
|
|
66458
|
+
const maxAffected = bound(options2.maxAffectedCells, 1e4);
|
|
66190
66459
|
for (let i2 = 0; i2 < pending2.length; i2++) {
|
|
66191
|
-
|
|
66460
|
+
options2.check?.();
|
|
66192
66461
|
for (const id3 of reverse2.get(pending2[i2]) ?? [])
|
|
66193
66462
|
if (!affected.has(id3)) {
|
|
66194
66463
|
affected.add(id3);
|
|
@@ -66197,7 +66466,7 @@ function recalculateVisioCells(roots, changed, options = {}) {
|
|
|
66197
66466
|
if (affected.size > maxAffected)
|
|
66198
66467
|
fail2("LIMIT_FORMULA_AFFECTED", "Affected ShapeSheet cell limit exceeded.");
|
|
66199
66468
|
}
|
|
66200
|
-
const evaluate = createVisioCellEvaluator(cells3,
|
|
66469
|
+
const evaluate = createVisioCellEvaluator(cells3, options2);
|
|
66201
66470
|
const values2 = /* @__PURE__ */ new Map();
|
|
66202
66471
|
for (const id3 of affected) values2.set(id3, evaluate(id3));
|
|
66203
66472
|
const pages = /* @__PURE__ */ new Set();
|
|
@@ -66213,10 +66482,10 @@ function recalculateVisioCells(roots, changed, options = {}) {
|
|
|
66213
66482
|
}
|
|
66214
66483
|
return [...pages];
|
|
66215
66484
|
}
|
|
66216
|
-
function assertVisioShapesUnreferenced(roots, removed,
|
|
66217
|
-
const cells3 = indexCells2(roots,
|
|
66485
|
+
function assertVisioShapesUnreferenced(roots, removed, options2 = {}) {
|
|
66486
|
+
const cells3 = indexCells2(roots, options2);
|
|
66218
66487
|
for (const cell of cells3.values()) {
|
|
66219
|
-
|
|
66488
|
+
options2.check?.();
|
|
66220
66489
|
if (removed.get(cell.pageId)?.has(cell.shapeId)) continue;
|
|
66221
66490
|
if (cell.dependencies.some((id3) => {
|
|
66222
66491
|
const parts = JSON.parse(id3);
|
|
@@ -66227,24 +66496,24 @@ function assertVisioShapesUnreferenced(roots, removed, options = {}) {
|
|
|
66227
66496
|
for (const [pageId2, ids] of removed)
|
|
66228
66497
|
for (const connections2 of children3(roots.get(pageId2), "Connects"))
|
|
66229
66498
|
for (const connection of children3(connections2, "Connect")) {
|
|
66230
|
-
|
|
66499
|
+
options2.check?.();
|
|
66231
66500
|
if (["FromSheet", "ToSheet"].some((name3) => ids.has(attribute3(connection, name3) ?? "")))
|
|
66232
66501
|
fail2("EDIT_REFERENCED_DELETE", "Shape participates in a Connect record.");
|
|
66233
66502
|
}
|
|
66234
66503
|
}
|
|
66235
|
-
function assertVisioShapeUnreferenced(roots, pageId2, shapeId2,
|
|
66236
|
-
assertVisioShapesUnreferenced(roots, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]),
|
|
66504
|
+
function assertVisioShapeUnreferenced(roots, pageId2, shapeId2, options2 = {}) {
|
|
66505
|
+
assertVisioShapesUnreferenced(roots, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]), options2);
|
|
66237
66506
|
}
|
|
66238
|
-
function createVisioDependencyQuery(roots,
|
|
66239
|
-
const cells3 = indexCells2(roots,
|
|
66507
|
+
function createVisioDependencyQuery(roots, options2 = {}) {
|
|
66508
|
+
const cells3 = indexCells2(roots, options2);
|
|
66240
66509
|
return (source2, targets) => {
|
|
66241
66510
|
const wanted = new Set(targets.map(key));
|
|
66242
66511
|
const seen = /* @__PURE__ */ new Set();
|
|
66243
66512
|
const pending2 = [key(source2)];
|
|
66244
|
-
const maxSteps = bound(
|
|
66513
|
+
const maxSteps = bound(options2.maxSteps, 1e5);
|
|
66245
66514
|
let found = false;
|
|
66246
66515
|
while (pending2.length) {
|
|
66247
|
-
|
|
66516
|
+
options2.check?.();
|
|
66248
66517
|
const id3 = pending2.pop();
|
|
66249
66518
|
if (seen.has(id3)) continue;
|
|
66250
66519
|
seen.add(id3);
|
|
@@ -67376,13 +67645,13 @@ function unique3(items, key2, what) {
|
|
|
67376
67645
|
return result2;
|
|
67377
67646
|
}
|
|
67378
67647
|
var cellMap2 = (parent) => unique3(children3(parent, "Cell"), (cell) => attribute3(cell, "N") ?? "", "cell");
|
|
67379
|
-
function instanceSheet(instance, template,
|
|
67648
|
+
function instanceSheet(instance, template, options2 = {}) {
|
|
67380
67649
|
for (const node3 of [instance, template]) {
|
|
67381
67650
|
const type = attribute3(node3, "Type");
|
|
67382
|
-
if (!(
|
|
67651
|
+
if (!(options2.group ? ["Shape", "Group", void 0] : ["Shape", void 0]).includes(type) || !options2.group && children3(node3, "Shapes").length > 0 || children3(node3, "ForeignData").length || deleted2(node3))
|
|
67383
67652
|
fail2(
|
|
67384
67653
|
"UNSUPPORTED_INSTANCE_EDIT",
|
|
67385
|
-
|
|
67654
|
+
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."
|
|
67386
67655
|
);
|
|
67387
67656
|
}
|
|
67388
67657
|
if (template.hasAttribute("Master") || template.hasAttribute("MasterShape"))
|
|
@@ -67461,7 +67730,7 @@ function effectiveFormula(cell) {
|
|
|
67461
67730
|
return own2 === "Inh" ? executableCellFormula(attribute3(cell.inherited, "F")) : executableCellFormula(own2);
|
|
67462
67731
|
}
|
|
67463
67732
|
var AFTER_SECTIONS = ["Text", "Data1", "Data2", "Data3", "ForeignData", "Shapes"];
|
|
67464
|
-
function writeInstanceCell(sheet, cell, value3,
|
|
67733
|
+
function writeInstanceCell(sheet, cell, value3, options2 = {}) {
|
|
67465
67734
|
const { instance } = sheet;
|
|
67466
67735
|
const create2 = (name3) => instance.ownerDocument.createElementNS(instance.namespaceURI, name3);
|
|
67467
67736
|
let node3 = cell.local;
|
|
@@ -67507,9 +67776,9 @@ function writeInstanceCell(sheet, cell, value3, options = {}) {
|
|
|
67507
67776
|
}
|
|
67508
67777
|
node3.setAttribute("V", value3);
|
|
67509
67778
|
node3.removeAttribute("E");
|
|
67510
|
-
const unit3 =
|
|
67511
|
-
if (unit3 !== void 0 && (created ||
|
|
67512
|
-
if (
|
|
67779
|
+
const unit3 = options2.unit ?? attribute3(cell.inherited, "U");
|
|
67780
|
+
if (unit3 !== void 0 && (created || options2.unit !== void 0)) node3.setAttribute("U", unit3);
|
|
67781
|
+
if (options2.formula) node3.setAttribute("F", options2.formula);
|
|
67513
67782
|
else node3.removeAttribute("F");
|
|
67514
67783
|
return node3;
|
|
67515
67784
|
}
|
|
@@ -69669,7 +69938,7 @@ function proveConnectorShape(shape2, route = routeOf(shape2)) {
|
|
|
69669
69938
|
"Only right-angle and curved connectors drawn here can be rerouted."
|
|
69670
69939
|
);
|
|
69671
69940
|
}
|
|
69672
|
-
function rerouteConnector(roots, pageId2, glue, check3,
|
|
69941
|
+
function rerouteConnector(roots, pageId2, glue, check3, options2 = {}) {
|
|
69673
69942
|
const root = roots.get(pageId2);
|
|
69674
69943
|
const shape2 = glue.shape;
|
|
69675
69944
|
const stencil = isStencilConnector(shape2);
|
|
@@ -69681,7 +69950,7 @@ function rerouteConnector(roots, pageId2, glue, check3, options = {}) {
|
|
|
69681
69950
|
if (target2) return glueSites(root, target2);
|
|
69682
69951
|
return [
|
|
69683
69952
|
{
|
|
69684
|
-
point:
|
|
69953
|
+
point: options2.free?.[end] ?? {
|
|
69685
69954
|
x: numeric4(local.get(`${prefix2(end)}X`)),
|
|
69686
69955
|
y: numeric4(local.get(`${prefix2(end)}Y`))
|
|
69687
69956
|
}
|
|
@@ -69690,7 +69959,7 @@ function rerouteConnector(roots, pageId2, glue, check3, options = {}) {
|
|
|
69690
69959
|
};
|
|
69691
69960
|
const chosen = chooseSites(sites("begin"), sites("end"));
|
|
69692
69961
|
if (isStencilLine(shape2)) {
|
|
69693
|
-
if (
|
|
69962
|
+
if (options2.route && options2.route !== "straight")
|
|
69694
69963
|
fail2(
|
|
69695
69964
|
"UNSUPPORTED_GEOMETRY_EDIT",
|
|
69696
69965
|
"This connector is a straight line from a stencil; only Visio's Dynamic connector can be restyled."
|
|
@@ -69709,12 +69978,12 @@ function rerouteConnector(roots, pageId2, glue, check3, options = {}) {
|
|
|
69709
69978
|
const target2 = glue.ends[end];
|
|
69710
69979
|
return target2 && target2.point === void 0 ? walkShape(glueBox(root, target2.target)) : { point: sites(end)[0].point };
|
|
69711
69980
|
};
|
|
69712
|
-
const route =
|
|
69981
|
+
const route = options2.route ?? current;
|
|
69713
69982
|
if (route === "straight" && current === "straight" && ENDS.every(
|
|
69714
69983
|
(end) => sameLineCoordinate(numeric4(local.get(`${prefix2(end)}X`)), chosen[end].point.x) && sameLineCoordinate(numeric4(local.get(`${prefix2(end)}Y`)), chosen[end].point.y)
|
|
69715
69984
|
))
|
|
69716
69985
|
return [];
|
|
69717
|
-
if (
|
|
69986
|
+
if (options2.route) setRouteCells(shape2, options2.route);
|
|
69718
69987
|
const obstacles = route === "right-angle" ? connectorObstacles(
|
|
69719
69988
|
root,
|
|
69720
69989
|
/* @__PURE__ */ new Set([
|
|
@@ -70066,14 +70335,14 @@ async function measuresOwnText(root, shapeId2, template, check3) {
|
|
|
70066
70335
|
return false;
|
|
70067
70336
|
}
|
|
70068
70337
|
}
|
|
70069
|
-
async function refreshTextSizes(targets, result2,
|
|
70338
|
+
async function refreshTextSizes(targets, result2, options2, deadline) {
|
|
70070
70339
|
if (!targets.length || !result2.changedParts.length) return result2;
|
|
70071
70340
|
const check3 = () => {
|
|
70072
70341
|
if (Date.now() >= deadline) throw new VisioPackageError("LIMIT_RUNTIME", "Deadline exceeded.");
|
|
70073
70342
|
};
|
|
70074
70343
|
const limits = {
|
|
70075
70344
|
...DEFAULTS2,
|
|
70076
|
-
...
|
|
70345
|
+
...options2.limits,
|
|
70077
70346
|
maxInputBytes: Math.max(DEFAULTS2.maxInputBytes, result2.bytes.length),
|
|
70078
70347
|
maxRuntimeMs: Math.max(1, deadline - Date.now())
|
|
70079
70348
|
};
|
|
@@ -70163,7 +70432,7 @@ async function refreshTextSizes(targets, result2, options, deadline) {
|
|
|
70163
70432
|
}
|
|
70164
70433
|
const bytes = await writeEditedPackage(
|
|
70165
70434
|
parts,
|
|
70166
|
-
|
|
70435
|
+
options2.maxOutputBytes ?? limits.maxInputBytes,
|
|
70167
70436
|
deadline,
|
|
70168
70437
|
check3
|
|
70169
70438
|
);
|
|
@@ -70432,14 +70701,14 @@ function cacheRows(path2) {
|
|
|
70432
70701
|
}
|
|
70433
70702
|
return rows.every((row3) => Number.isFinite(row3.x) && Number.isFinite(row3.y)) ? rows : [];
|
|
70434
70703
|
}
|
|
70435
|
-
async function refreshLineJumpCaches(pageIds2, source2, result2,
|
|
70704
|
+
async function refreshLineJumpCaches(pageIds2, source2, result2, options2, deadline) {
|
|
70436
70705
|
if (!pageIds2.size || !result2.changedParts.length) return result2;
|
|
70437
70706
|
const check3 = () => {
|
|
70438
70707
|
if (Date.now() >= deadline) fail2("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|
|
70439
70708
|
};
|
|
70440
70709
|
const limits = {
|
|
70441
70710
|
...DEFAULTS2,
|
|
70442
|
-
...
|
|
70711
|
+
...options2.limits,
|
|
70443
70712
|
maxRuntimeMs: Math.max(1, deadline - Date.now())
|
|
70444
70713
|
};
|
|
70445
70714
|
const { pkg, parts, pages } = await openEditablePackage(result2.bytes, limits, check3);
|
|
@@ -70519,7 +70788,7 @@ async function refreshLineJumpCaches(pageIds2, source2, result2, options, deadli
|
|
|
70519
70788
|
return {
|
|
70520
70789
|
bytes: await writeEditedPackage(
|
|
70521
70790
|
parts,
|
|
70522
|
-
|
|
70791
|
+
options2.maxOutputBytes ?? limits.maxInputBytes,
|
|
70523
70792
|
deadline,
|
|
70524
70793
|
check3
|
|
70525
70794
|
),
|
|
@@ -74541,9 +74810,9 @@ function snapshotStencilMasterDrop(edit) {
|
|
|
74541
74810
|
y: edit.y
|
|
74542
74811
|
};
|
|
74543
74812
|
}
|
|
74544
|
-
async function editVsdxMasterDrops(source2, commands,
|
|
74545
|
-
const limits = { ...DEFAULTS2, ...
|
|
74546
|
-
const maxOutput =
|
|
74813
|
+
async function editVsdxMasterDrops(source2, commands, options2, lone, apply3) {
|
|
74814
|
+
const limits = { ...DEFAULTS2, ...options2.limits };
|
|
74815
|
+
const maxOutput = options2.maxOutputBytes ?? limits.maxInputBytes;
|
|
74547
74816
|
const deadline = Date.now() + limits.maxRuntimeMs;
|
|
74548
74817
|
const check3 = () => {
|
|
74549
74818
|
if (Date.now() >= deadline) fail2("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|
|
@@ -75739,12 +76008,12 @@ function resizeVisioShapeAtAnchor(roots, document, edit, check3, glueShapes = /*
|
|
|
75739
76008
|
}
|
|
75740
76009
|
|
|
75741
76010
|
// visio/edit-transform-formula.ts
|
|
75742
|
-
function editableTransformCell(roots, edit, node3, check3,
|
|
76011
|
+
function editableTransformCell(roots, edit, node3, check3, options2 = {}) {
|
|
75743
76012
|
const formula = executableCellFormula(attribute3(node3, "F"));
|
|
75744
76013
|
if (!formula || !analyzeVisioFormula(formula).references.length) return editableCell(node3);
|
|
75745
76014
|
const evaluate = createVisioCellEvaluator(
|
|
75746
|
-
indexCells2(roots, { ...
|
|
75747
|
-
{ ...
|
|
76015
|
+
indexCells2(roots, { ...options2, check: check3 }),
|
|
76016
|
+
{ ...options2, check: check3 },
|
|
75748
76017
|
true
|
|
75749
76018
|
);
|
|
75750
76019
|
editableCell(
|
|
@@ -76213,7 +76482,7 @@ async function assertDuplicateScope(pkg, pagePaths, targetPage, newIds, check3,
|
|
|
76213
76482
|
}
|
|
76214
76483
|
|
|
76215
76484
|
// visio/formula-master.ts
|
|
76216
|
-
function analyzeVisioMasterFormula(source2,
|
|
76485
|
+
function analyzeVisioMasterFormula(source2, options2) {
|
|
76217
76486
|
const ast = parseVisioFormula(source2);
|
|
76218
76487
|
const analysis = analyzeVisioFormula(ast);
|
|
76219
76488
|
const references = /* @__PURE__ */ new Map();
|
|
@@ -76234,7 +76503,7 @@ function analyzeVisioMasterFormula(source2, options) {
|
|
|
76234
76503
|
if (["TEXTWIDTH", "TEXTHEIGHT", "SHAPETEXT"].includes(node3.name)) {
|
|
76235
76504
|
const text8 = node3.args[0];
|
|
76236
76505
|
const count2 = node3.name === "TEXTHEIGHT" ? node3.args.length === 2 : node3.args.length === 1;
|
|
76237
|
-
local =
|
|
76506
|
+
local = options2.textFieldFree && count2 && text8?.kind === "reference" && text8.reference.shapeId === void 0 && text8.reference.cell.toLowerCase() === "thetext";
|
|
76238
76507
|
readsText = true;
|
|
76239
76508
|
}
|
|
76240
76509
|
if (["LUM", "HUE", "SAT"].includes(node3.name)) {
|
|
@@ -76869,16 +77138,16 @@ async function recalculatePageFormulas(pkg, pagesPart, pages, paths, dirty, chec
|
|
|
76869
77138
|
);
|
|
76870
77139
|
}
|
|
76871
77140
|
if (!needed) return;
|
|
76872
|
-
const
|
|
77141
|
+
const options2 = { check: check3, pageContext: after };
|
|
76873
77142
|
const changed = [];
|
|
76874
|
-
for (const cell of indexCells2(roots,
|
|
77143
|
+
for (const cell of indexCells2(roots, options2).values()) {
|
|
76875
77144
|
if (!cell.node) continue;
|
|
76876
77145
|
const functions = pageFunctions(attribute3(cell.node, "F") ?? "");
|
|
76877
77146
|
const old = before.get(cell.pageId), current = after.get(cell.pageId);
|
|
76878
77147
|
if (functions.has("PAGENUMBER") && old?.pageNumber !== current.pageNumber || functions.has("PAGECOUNT") && old?.pageCount !== current.pageCount)
|
|
76879
77148
|
changed.push(cell);
|
|
76880
77149
|
}
|
|
76881
|
-
for (const id3 of recalculateVisioCells(roots, changed,
|
|
77150
|
+
for (const id3 of recalculateVisioCells(roots, changed, options2)) {
|
|
76882
77151
|
const root = roots.get(id3);
|
|
76883
77152
|
const sheet = sheets.get(id3);
|
|
76884
77153
|
if (sheet) {
|
|
@@ -80201,14 +80470,14 @@ async function editVsdxComments(pkg, parts, pages, edits, limits, maxOutput, dea
|
|
|
80201
80470
|
}
|
|
80202
80471
|
|
|
80203
80472
|
// visio/clipboard.ts
|
|
80204
|
-
async function captureVisioClipboard(input, pageId2, shapeIds2,
|
|
80473
|
+
async function captureVisioClipboard(input, pageId2, shapeIds2, options2 = {}) {
|
|
80205
80474
|
pageId2 = clipboardId(pageId2);
|
|
80206
80475
|
if (!Array.isArray(shapeIds2) || !shapeIds2.length || shapeIds2.length > 1e3)
|
|
80207
80476
|
fail2("INVALID_CLIPBOARD", "Capture requires one to 1000 selected shapes.");
|
|
80208
80477
|
const selected2 = shapeIds2.map(clipboardId);
|
|
80209
80478
|
if (new Set(selected2).size !== selected2.length)
|
|
80210
80479
|
fail2("INVALID_CLIPBOARD", "Capture selection must be unique.");
|
|
80211
|
-
const limits = { ...DEFAULTS2, ...
|
|
80480
|
+
const limits = { ...DEFAULTS2, ...options2.limits };
|
|
80212
80481
|
for (const value3 of Object.values(limits))
|
|
80213
80482
|
if (!Number.isSafeInteger(value3) || value3 <= 0)
|
|
80214
80483
|
fail2("INVALID_LIMITS", "Capture limits require positive safe integers.");
|
|
@@ -80295,13 +80564,13 @@ async function retarget(clipboard, bytes, pageId2, limits) {
|
|
|
80295
80564
|
fail2("UNSUPPORTED_SUBPROCESS", "The new page does not share the source page settings.");
|
|
80296
80565
|
return { ...clipboard, pageContext: target2.xml };
|
|
80297
80566
|
}
|
|
80298
|
-
async function editVsdxSubprocess(source2, edit,
|
|
80299
|
-
const limits = { ...DEFAULTS2, ...
|
|
80567
|
+
async function editVsdxSubprocess(source2, edit, options2) {
|
|
80568
|
+
const limits = { ...DEFAULTS2, ...options2.limits };
|
|
80300
80569
|
const deadline = Date.now() + limits.maxRuntimeMs;
|
|
80301
80570
|
const remaining = () => {
|
|
80302
80571
|
const time = deadline - Date.now();
|
|
80303
80572
|
if (time <= 0) fail2("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|
|
80304
|
-
return { ...
|
|
80573
|
+
return { ...options2, limits: { ...options2.limits, maxRuntimeMs: time } };
|
|
80305
80574
|
};
|
|
80306
80575
|
const changed = /* @__PURE__ */ new Set();
|
|
80307
80576
|
const diagnostics = /* @__PURE__ */ new Map();
|
|
@@ -81435,7 +81704,7 @@ function positive4(value3) {
|
|
|
81435
81704
|
fail2("INVALID_LIMITS", "Edit limits must be positive safe integers.");
|
|
81436
81705
|
return value3;
|
|
81437
81706
|
}
|
|
81438
|
-
async function editVsdx(input, edits,
|
|
81707
|
+
async function editVsdx(input, edits, options2 = {}) {
|
|
81439
81708
|
const clock = {
|
|
81440
81709
|
deadline: 0,
|
|
81441
81710
|
autoSize: /* @__PURE__ */ new Set(),
|
|
@@ -81443,36 +81712,36 @@ async function editVsdx(input, edits, options = {}) {
|
|
|
81443
81712
|
jumpPages: /* @__PURE__ */ new Set(),
|
|
81444
81713
|
jumpSource: void 0
|
|
81445
81714
|
};
|
|
81446
|
-
const edited = await editVsdxTransaction(input, edits,
|
|
81447
|
-
const resized = await refreshTextSizes(clock.textSizes, edited,
|
|
81715
|
+
const edited = await editVsdxTransaction(input, edits, options2, clock);
|
|
81716
|
+
const resized = await refreshTextSizes(clock.textSizes, edited, options2, clock.deadline);
|
|
81448
81717
|
const result2 = await refreshLineJumpCaches(
|
|
81449
81718
|
clock.jumpPages,
|
|
81450
81719
|
clock.jumpSource,
|
|
81451
81720
|
resized,
|
|
81452
|
-
|
|
81721
|
+
options2,
|
|
81453
81722
|
clock.deadline
|
|
81454
81723
|
);
|
|
81455
81724
|
return growAutoSizePages(
|
|
81456
81725
|
clock.autoSize,
|
|
81457
81726
|
result2,
|
|
81458
81727
|
(bytes, growth) => editVsdxTransaction(bytes, growth, {
|
|
81459
|
-
...
|
|
81460
|
-
limits: { ...
|
|
81728
|
+
...options2,
|
|
81729
|
+
limits: { ...options2.limits, maxRuntimeMs: Math.max(1, clock.deadline - Date.now()) }
|
|
81461
81730
|
})
|
|
81462
81731
|
);
|
|
81463
81732
|
}
|
|
81464
|
-
async function editVsdxTransaction(input, edits,
|
|
81733
|
+
async function editVsdxTransaction(input, edits, options2, clock = {
|
|
81465
81734
|
deadline: 0,
|
|
81466
81735
|
autoSize: /* @__PURE__ */ new Set(),
|
|
81467
81736
|
textSizes: [],
|
|
81468
81737
|
jumpPages: /* @__PURE__ */ new Set(),
|
|
81469
81738
|
jumpSource: void 0
|
|
81470
81739
|
}) {
|
|
81471
|
-
const limits = { ...DEFAULTS2, ...
|
|
81740
|
+
const limits = { ...DEFAULTS2, ...options2.limits };
|
|
81472
81741
|
for (const value3 of Object.values(limits)) positive4(value3);
|
|
81473
|
-
const maxEdits = positive4(
|
|
81474
|
-
const maxText = positive4(
|
|
81475
|
-
const maxOutput = positive4(
|
|
81742
|
+
const maxEdits = positive4(options2.maxEdits ?? 1e3);
|
|
81743
|
+
const maxText = positive4(options2.maxTextCharacters ?? 1e6);
|
|
81744
|
+
const maxOutput = positive4(options2.maxOutputBytes ?? limits.maxInputBytes);
|
|
81476
81745
|
const deadline = Date.now() + limits.maxRuntimeMs;
|
|
81477
81746
|
clock.deadline = deadline;
|
|
81478
81747
|
const check3 = () => {
|
|
@@ -81491,13 +81760,13 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
81491
81760
|
if (subprocess) {
|
|
81492
81761
|
if (allCommands.length !== 1)
|
|
81493
81762
|
fail2("EDIT_MIXED_SUBPROCESS_TRANSACTION", "A subprocess requires its own transaction.");
|
|
81494
|
-
return editVsdxSubprocess(original, subprocess,
|
|
81763
|
+
return editVsdxSubprocess(original, subprocess, options2);
|
|
81495
81764
|
}
|
|
81496
81765
|
if (allCommands.some(isVisioMasterDrop))
|
|
81497
81766
|
return editVsdxMasterDrops(
|
|
81498
81767
|
original,
|
|
81499
81768
|
allCommands,
|
|
81500
|
-
|
|
81769
|
+
options2,
|
|
81501
81770
|
async (bytes2, instance, info) => {
|
|
81502
81771
|
const opened = await openEditablePackage(bytes2, limits, check3);
|
|
81503
81772
|
return editVsdxMasterInstance(
|
|
@@ -81512,7 +81781,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
81512
81781
|
info
|
|
81513
81782
|
);
|
|
81514
81783
|
},
|
|
81515
|
-
(bytes2, rest) => editVsdx(bytes2, rest,
|
|
81784
|
+
(bytes2, rest) => editVsdx(bytes2, rest, options2)
|
|
81516
81785
|
);
|
|
81517
81786
|
const { pkg, parts, pages } = await openEditablePackage(original, limits, check3);
|
|
81518
81787
|
const builtIn = await changeStencilShapeToBuiltIn(
|
|
@@ -81521,7 +81790,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
81521
81790
|
pages,
|
|
81522
81791
|
allCommands,
|
|
81523
81792
|
{ limits, maxOutput, deadline, check: check3 },
|
|
81524
|
-
(bytes2, edits2) => editVsdx(bytes2, edits2,
|
|
81793
|
+
(bytes2, edits2) => editVsdx(bytes2, edits2, options2)
|
|
81525
81794
|
);
|
|
81526
81795
|
if (builtIn) return builtIn;
|
|
81527
81796
|
if (allCommands.some(isVisioCommentEdit)) {
|
|
@@ -81604,8 +81873,8 @@ async function editVsdxTransaction(input, edits, options, clock = {
|
|
|
81604
81873
|
check3
|
|
81605
81874
|
);
|
|
81606
81875
|
const moved = await editVsdxTransaction(resized.bytes, commands, {
|
|
81607
|
-
...
|
|
81608
|
-
limits: { ...
|
|
81876
|
+
...options2,
|
|
81877
|
+
limits: { ...options2.limits, maxRuntimeMs: Math.max(1, deadline - Date.now()) }
|
|
81609
81878
|
});
|
|
81610
81879
|
return {
|
|
81611
81880
|
bytes: moved.bytes,
|