ooxml-core 1.6.2 → 1.7.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/automation/index.cjs +481 -231
- package/dist/automation/index.mjs +481 -231
- package/dist/geometry/index.cjs +25 -0
- package/dist/geometry/index.d.ts +1 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/geometry/index.mjs +24 -1
- package/dist/geometry/nudge.d.ts +12 -0
- package/dist/geometry/nudge.d.ts.map +1 -0
- package/dist/geometry/rotation-drag.d.ts +6 -0
- package/dist/geometry/rotation-drag.d.ts.map +1 -1
- package/dist/index.cjs +25 -0
- package/dist/index.mjs +25 -0
- package/dist/pptx/automation/index.cjs +7 -2
- package/dist/pptx/cli/index.cjs +7 -2
- package/dist/pptx/converter/index.cjs +7 -2
- package/dist/pptx/index.cjs +7 -2
- package/dist/teams/index.cjs +7 -2
- package/dist/teams/index.mjs +7 -2
- package/dist/visio/edit-commands.d.ts +3 -1
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-layer-properties.d.ts +22 -0
- package/dist/visio/edit-layer-properties.d.ts.map +1 -0
- package/dist/visio/edit-text-instance.d.ts +21 -0
- package/dist/visio/edit-text-instance.d.ts.map +1 -0
- package/dist/visio/edit-text-ranges.d.ts.map +1 -1
- package/dist/visio/edit-text-scope.d.ts +6 -1
- package/dist/visio/edit-text-scope.d.ts.map +1 -1
- package/dist/visio/edit-text-target.d.ts +11 -1
- package/dist/visio/edit-text-target.d.ts.map +1 -1
- package/dist/visio/edit-text.d.ts +2 -1
- package/dist/visio/edit-text.d.ts.map +1 -1
- package/dist/visio/edit.d.ts +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/index.cjs +470 -220
- package/dist/visio/index.d.ts +1 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +470 -220
- package/dist/visio/text-fields.d.ts.map +1 -1
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/edit-error.d.ts +4 -1
- package/dist/visio/ui/edit-error.d.ts.map +1 -1
- package/dist/visio/ui/guides.d.ts +5 -0
- package/dist/visio/ui/guides.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +19768 -1874
- package/dist/visio/ui/index.d.ts +1 -0
- package/dist/visio/ui/index.d.ts.map +1 -1
- package/dist/visio/ui/index.mjs +19765 -1877
- package/dist/visio/ui/sample-drawing.d.ts +8 -0
- package/dist/visio/ui/sample-drawing.d.ts.map +1 -0
- package/dist/visio/ui/shape-move.d.ts +6 -0
- package/dist/visio/ui/shape-move.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/visio/index.cjs
CHANGED
|
@@ -4107,7 +4107,7 @@ function assertUnlayeredShape(shape, document) {
|
|
|
4107
4107
|
}
|
|
4108
4108
|
|
|
4109
4109
|
// visio/edit-text-target.ts
|
|
4110
|
-
function
|
|
4110
|
+
function textTarget(root2, shapeId2, check) {
|
|
4111
4111
|
const shapeChildren = (parent) => {
|
|
4112
4112
|
const containers = children2(parent, "Shapes");
|
|
4113
4113
|
if (containers.length > 1)
|
|
@@ -4115,35 +4115,145 @@ function localTextTarget(root2, document, shapeId2, check) {
|
|
|
4115
4115
|
return children2(containers[0], "Shape");
|
|
4116
4116
|
};
|
|
4117
4117
|
const shapes = /* @__PURE__ */ new Map();
|
|
4118
|
-
const pending = shapeChildren(root2).map((node2) => ({
|
|
4118
|
+
const pending = shapeChildren(root2).map((node2) => ({
|
|
4119
|
+
node: node2,
|
|
4120
|
+
masterId: void 0,
|
|
4121
|
+
deleted: false
|
|
4122
|
+
}));
|
|
4119
4123
|
while (pending.length) {
|
|
4120
4124
|
check();
|
|
4121
4125
|
const item = pending.pop(), id3 = attribute2(item.node, "ID");
|
|
4122
4126
|
if (!id3 || shapes.has(id3))
|
|
4123
4127
|
fail("INVALID_SHAPE_ID", "Local shape IDs must be present and unique.");
|
|
4124
|
-
const
|
|
4128
|
+
const masterId = attribute2(item.node, "Master") ?? item.masterId;
|
|
4125
4129
|
const deleted = item.deleted || ["1", "true"].includes(attribute2(item.node, "Del") ?? "");
|
|
4126
|
-
shapes.set(id3, { node: item.node,
|
|
4127
|
-
for (const node2 of shapeChildren(item.node)) pending.push({ node: node2,
|
|
4130
|
+
shapes.set(id3, { node: item.node, masterId, deleted });
|
|
4131
|
+
for (const node2 of shapeChildren(item.node)) pending.push({ node: node2, masterId, deleted });
|
|
4128
4132
|
}
|
|
4129
4133
|
const target2 = shapes.get(shapeId2);
|
|
4130
4134
|
if (!target2) fail("EDIT_TARGET_NOT_FOUND", "Local shape does not exist.");
|
|
4131
|
-
if (target2.
|
|
4132
|
-
|
|
4135
|
+
if (target2.deleted) fail("UNSUPPORTED_TEXT_EDIT", "Deleted shapes cannot be edited.");
|
|
4136
|
+
const masterShapeId = attribute2(target2.node, "MasterShape");
|
|
4137
|
+
if (masterShapeId !== void 0 && target2.masterId === void 0)
|
|
4138
|
+
fail("UNSUPPORTED_TEXT_EDIT", "The shape refers to a master that is not on this page.");
|
|
4139
|
+
return {
|
|
4140
|
+
node: target2.node,
|
|
4141
|
+
...target2.masterId !== void 0 ? { masterId: target2.masterId } : {},
|
|
4142
|
+
...masterShapeId !== void 0 ? { masterShapeId } : {}
|
|
4143
|
+
};
|
|
4144
|
+
}
|
|
4145
|
+
function localTextTarget(root2, document, shapeId2, check) {
|
|
4146
|
+
const target2 = textTarget(root2, shapeId2, check);
|
|
4147
|
+
if (target2.masterId !== void 0)
|
|
4148
|
+
fail("UNSUPPORTED_TEXT_EDIT", "Text ranges and fields of stencil shapes cannot be edited.");
|
|
4133
4149
|
assertShapeLocks(target2.node, document, ["LockTextEdit"]);
|
|
4134
4150
|
return target2.node;
|
|
4135
4151
|
}
|
|
4136
4152
|
|
|
4153
|
+
// visio/edit-text-instance.ts
|
|
4154
|
+
var fieldSections = (shape) => children2(shape, "Section").filter((section2) => attribute2(section2, "N") === "Field");
|
|
4155
|
+
var isMarkup = (node2) => node2.nodeType !== 3 && node2.nodeType !== 4;
|
|
4156
|
+
var knownMarkup = (text3) => Array.from(text3.childNodes).every(
|
|
4157
|
+
(node2) => !isMarkup(node2) || ["cp", "pp", "tp", "fld"].includes(node2.localName)
|
|
4158
|
+
);
|
|
4159
|
+
function assertUnlocked(shape, template) {
|
|
4160
|
+
const local = children2(shape, "Cell").some((cell) => attribute2(cell, "N") === "LockTextEdit");
|
|
4161
|
+
for (const cell of children2(local ? shape : template, "Cell")) {
|
|
4162
|
+
if (attribute2(cell, "N") !== "LockTextEdit") continue;
|
|
4163
|
+
if (cell.hasAttribute("E") || cell.hasAttribute("F") || Number(attribute2(cell, "V")) !== 0)
|
|
4164
|
+
fail("EDIT_PROTECTED_CELL", "The shape is protected against text editing.");
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
function single(shape, what) {
|
|
4168
|
+
const texts = children2(shape, "Text");
|
|
4169
|
+
if (texts.length > 1) fail("UNSUPPORTED_TEXT_EDIT", `${what} has more than one Text element.`);
|
|
4170
|
+
return texts[0];
|
|
4171
|
+
}
|
|
4172
|
+
function insertBeforeTail(shape, node2, tail) {
|
|
4173
|
+
const after = Array.from(shape.childNodes).find(
|
|
4174
|
+
(child3) => child3.nodeType === 1 && tail.includes(child3.localName)
|
|
4175
|
+
);
|
|
4176
|
+
shape.insertBefore(node2, after ?? null);
|
|
4177
|
+
}
|
|
4178
|
+
var AFTER_TEXT = ["Data1", "Data2", "Data3", "ForeignData", "Shapes"];
|
|
4179
|
+
function replaceInstanceText(shape, template, text3) {
|
|
4180
|
+
const local = single(shape, "The shape");
|
|
4181
|
+
const inherited = single(template, "The master shape");
|
|
4182
|
+
if (local && Array.from(local.childNodes).some(isMarkup))
|
|
4183
|
+
fail(
|
|
4184
|
+
"UNSUPPORTED_TEXT_EDIT",
|
|
4185
|
+
"This stencil shape has its own formatted text; edit part of the text instead."
|
|
4186
|
+
);
|
|
4187
|
+
if (!local && inherited && !knownMarkup(inherited))
|
|
4188
|
+
fail("UNSUPPORTED_TEXT_EDIT", "The master text has markup this editor does not know.");
|
|
4189
|
+
if (fieldSections(shape).length)
|
|
4190
|
+
fail("UNSUPPORTED_TEXT_EDIT", "This stencil shape has its own text fields; edit around them.");
|
|
4191
|
+
assertUnlocked(shape, template);
|
|
4192
|
+
const fields = local ? [] : fieldSections(template).flatMap((section2) => children2(section2, "Row"));
|
|
4193
|
+
const current = local ?? inherited;
|
|
4194
|
+
if (!fields.length && current && !Array.from(current.childNodes).some(isMarkup)) {
|
|
4195
|
+
if (decodeVisioPlainText(current.textContent ?? "") === text3) return false;
|
|
4196
|
+
}
|
|
4197
|
+
const document = shape.ownerDocument;
|
|
4198
|
+
if (fields.length) {
|
|
4199
|
+
const section2 = document.createElementNS(shape.namespaceURI, "Section");
|
|
4200
|
+
section2.setAttribute("N", "Field");
|
|
4201
|
+
for (const row2 of fields) {
|
|
4202
|
+
const index = attribute2(row2, "IX");
|
|
4203
|
+
if (index === void 0)
|
|
4204
|
+
fail("UNSUPPORTED_TEXT_EDIT", "The master text fields cannot be identified.");
|
|
4205
|
+
const removed = document.createElementNS(shape.namespaceURI, "Row");
|
|
4206
|
+
removed.setAttribute("IX", index);
|
|
4207
|
+
removed.setAttribute("Del", "1");
|
|
4208
|
+
section2.appendChild(removed);
|
|
4209
|
+
}
|
|
4210
|
+
insertBeforeTail(shape, section2, ["Text", ...AFTER_TEXT]);
|
|
4211
|
+
}
|
|
4212
|
+
let node2 = local;
|
|
4213
|
+
if (!node2) {
|
|
4214
|
+
node2 = document.createElementNS(shape.namespaceURI, "Text");
|
|
4215
|
+
insertBeforeTail(shape, node2, AFTER_TEXT);
|
|
4216
|
+
}
|
|
4217
|
+
while (node2.firstChild) node2.removeChild(node2.firstChild);
|
|
4218
|
+
node2.appendChild(document.createTextNode(encodeVisioPlainText(text3)));
|
|
4219
|
+
return true;
|
|
4220
|
+
}
|
|
4221
|
+
function instanceTextNode(shape, template) {
|
|
4222
|
+
const local = single(shape, "The shape");
|
|
4223
|
+
assertUnlocked(shape, template);
|
|
4224
|
+
if (local) return { text: local, discard: () => {
|
|
4225
|
+
} };
|
|
4226
|
+
const inherited = single(template, "The master shape");
|
|
4227
|
+
if (!inherited) fail("UNSUPPORTED_TEXT_RANGE", "The stencil shape has no text to edit.");
|
|
4228
|
+
if (!knownMarkup(inherited))
|
|
4229
|
+
fail("UNSUPPORTED_TEXT_RANGE", "The master text has markup this editor does not know.");
|
|
4230
|
+
if (fieldSections(shape).length)
|
|
4231
|
+
fail("UNSUPPORTED_TEXT_RANGE", "This stencil shape overrides its master text fields.");
|
|
4232
|
+
const text3 = shape.ownerDocument.importNode(inherited, true);
|
|
4233
|
+
insertBeforeTail(shape, text3, AFTER_TEXT);
|
|
4234
|
+
return { text: text3, discard: () => void shape.removeChild(text3) };
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4137
4237
|
// visio/edit-text.ts
|
|
4138
|
-
|
|
4238
|
+
var plain = (node2) => Array.from(node2.childNodes).every((item) => item.nodeType === 3 || item.nodeType === 4);
|
|
4239
|
+
var hasFields = (shape) => children2(shape, "Section").some((section2) => attribute2(section2, "N") === "Field");
|
|
4240
|
+
async function replacePlainText(root2, document, shapeId2, text3, check, assertDependencies2, masterTemplate2) {
|
|
4241
|
+
const found = textTarget(root2, shapeId2, check);
|
|
4242
|
+
if (found.masterId !== void 0) {
|
|
4243
|
+
if (!masterTemplate2)
|
|
4244
|
+
fail("UNSUPPORTED_TEXT_EDIT", "Stencil shapes cannot be edited without their masters.");
|
|
4245
|
+
const template = await masterTemplate2(found.masterId, found.masterShapeId);
|
|
4246
|
+
check();
|
|
4247
|
+
return replaceInstanceText(found.node, template, text3);
|
|
4248
|
+
}
|
|
4139
4249
|
const target2 = localTextTarget(root2, document, shapeId2, check);
|
|
4140
4250
|
const texts = children2(target2, "Text");
|
|
4141
4251
|
if (texts.length !== 1)
|
|
4142
4252
|
fail("UNSUPPORTED_TEXT_EDIT", "Editing requires one existing local Text element.");
|
|
4143
4253
|
const node2 = texts[0];
|
|
4144
|
-
if (
|
|
4254
|
+
if (!plain(node2))
|
|
4145
4255
|
fail("UNSUPPORTED_TEXT_EDIT", "Rich text, fields and unknown text markup cannot be edited.");
|
|
4146
|
-
if (
|
|
4256
|
+
if (hasFields(target2))
|
|
4147
4257
|
fail(
|
|
4148
4258
|
"UNSUPPORTED_TEXT_EDIT",
|
|
4149
4259
|
"Replacing all text would remove its text fields; edit the text around the fields instead."
|
|
@@ -8473,31 +8583,32 @@ var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "S
|
|
|
8473
8583
|
var pad = (value, length = 2) => String(value).padStart(length, "0");
|
|
8474
8584
|
function formatDate(date2, picture) {
|
|
8475
8585
|
const hours = date2.getUTCHours();
|
|
8476
|
-
const tokens2 =
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8586
|
+
const tokens2 = new Map(
|
|
8587
|
+
Object.entries({
|
|
8588
|
+
yyyy: () => pad(date2.getUTCFullYear(), 4),
|
|
8589
|
+
yy: () => pad(date2.getUTCFullYear() % 100),
|
|
8590
|
+
MMMM: () => MONTHS[date2.getUTCMonth()],
|
|
8591
|
+
MMM: () => MONTHS[date2.getUTCMonth()].slice(0, 3),
|
|
8592
|
+
MM: () => pad(date2.getUTCMonth() + 1),
|
|
8593
|
+
M: () => String(date2.getUTCMonth() + 1),
|
|
8594
|
+
dddd: () => DAYS[date2.getUTCDay()],
|
|
8595
|
+
ddd: () => DAYS[date2.getUTCDay()].slice(0, 3),
|
|
8596
|
+
dd: () => pad(date2.getUTCDate()),
|
|
8597
|
+
d: () => String(date2.getUTCDate()),
|
|
8598
|
+
HH: () => pad(hours),
|
|
8599
|
+
H: () => String(hours),
|
|
8600
|
+
hh: () => pad(hours % 12 || 12),
|
|
8601
|
+
h: () => String(hours % 12 || 12),
|
|
8602
|
+
mm: () => pad(date2.getUTCMinutes()),
|
|
8603
|
+
ss: () => pad(date2.getUTCSeconds()),
|
|
8604
|
+
tt: () => hours < 12 ? "AM" : "PM"
|
|
8605
|
+
})
|
|
8606
|
+
);
|
|
8495
8607
|
return picture.replace(
|
|
8496
8608
|
/yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
|
|
8497
8609
|
(token) => {
|
|
8498
8610
|
if (token.startsWith('"')) return token.slice(1, -1);
|
|
8499
|
-
|
|
8500
|
-
return typeof format === "function" ? format() : token;
|
|
8611
|
+
return tokens2.get(token)?.() ?? token;
|
|
8501
8612
|
}
|
|
8502
8613
|
);
|
|
8503
8614
|
}
|
|
@@ -14901,8 +15012,8 @@ function columnName(col) {
|
|
|
14901
15012
|
return name3;
|
|
14902
15013
|
}
|
|
14903
15014
|
function quoteSheetName(name3) {
|
|
14904
|
-
const
|
|
14905
|
-
return
|
|
15015
|
+
const plain2 = /^[A-Za-z_][A-Za-z0-9_.]*$/.test(name3) && !/^[A-Za-z]{1,3}[0-9]+$/.test(name3) && !/^[Rr][0-9]*([Cc][0-9]*)?$/.test(name3) && !/^(TRUE|FALSE)$/i.test(name3);
|
|
15016
|
+
return plain2 ? name3 : `'${name3.replace(/'/g, "''")}'`;
|
|
14906
15017
|
}
|
|
14907
15018
|
function formatNumber2(value) {
|
|
14908
15019
|
return String(value).replace("e", "E");
|
|
@@ -15731,8 +15842,8 @@ function parseSupBook(data) {
|
|
|
15731
15842
|
function sheetRange(first2, last) {
|
|
15732
15843
|
if (first2 === last)
|
|
15733
15844
|
return quoteSheetName(first2);
|
|
15734
|
-
const
|
|
15735
|
-
return
|
|
15845
|
+
const plain2 = quoteSheetName(first2) === first2 && quoteSheetName(last) === last;
|
|
15846
|
+
return plain2 ? `${first2}:${last}` : `'${`${first2}:${last}`.replace(/'/g, "''")}'`;
|
|
15736
15847
|
}
|
|
15737
15848
|
function parseGlobals(records) {
|
|
15738
15849
|
const first2 = records[0];
|
|
@@ -21101,7 +21212,201 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
|
|
|
21101
21212
|
}
|
|
21102
21213
|
}
|
|
21103
21214
|
|
|
21215
|
+
// visio/edit-master-index.ts
|
|
21216
|
+
function inheritedProtection(node2, ancestor) {
|
|
21217
|
+
try {
|
|
21218
|
+
const boolean2 = (cell) => {
|
|
21219
|
+
if (!cell || cell.hasAttribute("E"))
|
|
21220
|
+
fail("EDIT_PROTECTED_CELL", "Inherited protection has an unresolved or error cache.");
|
|
21221
|
+
const value = visioFormulaCachedValue(attribute2(cell, "V") ?? "", attribute2(cell, "U"));
|
|
21222
|
+
if (value.unit !== "scalar" || ![0, 1].includes(value.value))
|
|
21223
|
+
fail("EDIT_PROTECTED_CELL", "Inherited protection requires scalar boolean caches.");
|
|
21224
|
+
return value.value;
|
|
21225
|
+
};
|
|
21226
|
+
if (boolean2(node2) !== boolean2(ancestor))
|
|
21227
|
+
fail(
|
|
21228
|
+
"EDIT_PROTECTED_CELL",
|
|
21229
|
+
"Delegated master style protection cache disagrees with its ancestor."
|
|
21230
|
+
);
|
|
21231
|
+
} catch (error) {
|
|
21232
|
+
fail(
|
|
21233
|
+
"EDIT_PROTECTED_CELL",
|
|
21234
|
+
`Inherited master style protection cannot be proven: ${error instanceof Error ? error.message : "invalid cache"}`
|
|
21235
|
+
);
|
|
21236
|
+
}
|
|
21237
|
+
}
|
|
21238
|
+
function masterCells(sheet, charge = () => {
|
|
21239
|
+
}) {
|
|
21240
|
+
const result = /* @__PURE__ */ new Map();
|
|
21241
|
+
if (!sheet) return result;
|
|
21242
|
+
const add = (name3, node2) => {
|
|
21243
|
+
charge();
|
|
21244
|
+
const id3 = name3.toLowerCase();
|
|
21245
|
+
if (result.has(id3) && result.get(id3) !== node2)
|
|
21246
|
+
fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Ambiguous effective master cells.");
|
|
21247
|
+
result.set(id3, node2);
|
|
21248
|
+
};
|
|
21249
|
+
for (const node2 of children2(sheet, "Cell")) add(attribute2(node2, "N") ?? "", node2);
|
|
21250
|
+
for (const section2 of children2(sheet, "Section")) {
|
|
21251
|
+
const name3 = attribute2(section2, "N") ?? "";
|
|
21252
|
+
const prefix2 = name3 === "Geometry" ? `Geometry${Number(attribute2(section2, "IX") ?? "0") + 1}` : name3 === "Control" ? "Controls" : name3;
|
|
21253
|
+
for (const node2 of children2(section2, "Cell"))
|
|
21254
|
+
add(`${prefix2}.${attribute2(node2, "N") ?? ""}`, node2);
|
|
21255
|
+
for (const row2 of children2(section2, "Row"))
|
|
21256
|
+
for (const node2 of children2(row2, "Cell")) {
|
|
21257
|
+
const n = attribute2(node2, "N") ?? "";
|
|
21258
|
+
const rowName = attribute2(row2, "N");
|
|
21259
|
+
const index = attribute2(row2, "IX") ?? (prefix2 === "Controls" && /^Row_\d+$/.test(rowName ?? "") ? String(Number(rowName.slice(4)) - 1) : void 0);
|
|
21260
|
+
const ix = index ?? "0", r = rowName ?? (prefix2 === "Controls" ? `Row_${Number(ix) + 1}` : ix);
|
|
21261
|
+
add(
|
|
21262
|
+
name3 === "Geometry" || ["Controls", "Scratch", "Connection"].includes(prefix2) ? `${prefix2}.${n}${ix}` : n === "Value" && ["User", "Prop"].includes(name3) ? `${prefix2}.${r}` : `${prefix2}.${r}.${n}`,
|
|
21263
|
+
node2
|
|
21264
|
+
);
|
|
21265
|
+
if (name3 !== "Geometry") add(`${prefix2}.${r}.${n}`, node2);
|
|
21266
|
+
if (prefix2 === "Controls" && n === "X") add(`${prefix2}.${r}`, node2);
|
|
21267
|
+
if (name3 !== "Geometry" && index !== void 0) add(`${prefix2}.$row${ix}.${n}`, node2);
|
|
21268
|
+
}
|
|
21269
|
+
}
|
|
21270
|
+
return result;
|
|
21271
|
+
}
|
|
21272
|
+
function masterShapes(root2) {
|
|
21273
|
+
const result = [], pending = [root2];
|
|
21274
|
+
while (pending.length) {
|
|
21275
|
+
const parent = pending.pop();
|
|
21276
|
+
for (const container of children2(parent, "Shapes"))
|
|
21277
|
+
for (const shape of children2(container, "Shape")) {
|
|
21278
|
+
result.push(shape);
|
|
21279
|
+
pending.push(shape);
|
|
21280
|
+
}
|
|
21281
|
+
}
|
|
21282
|
+
return result;
|
|
21283
|
+
}
|
|
21284
|
+
function assertMasterMarkup(root2, known, check) {
|
|
21285
|
+
for (const node2 of [root2, ...Array.from(root2.getElementsByTagName("*"))]) {
|
|
21286
|
+
check();
|
|
21287
|
+
if (node2.namespaceURI === root2.namespaceURI && node2.hasAttribute("F") && !known.has(node2))
|
|
21288
|
+
fail(
|
|
21289
|
+
"EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY",
|
|
21290
|
+
"Master formula outside admitted sheet cells has unknown scope."
|
|
21291
|
+
);
|
|
21292
|
+
}
|
|
21293
|
+
}
|
|
21294
|
+
function masterStyleCells(document, template, instance, check, charge = () => {
|
|
21295
|
+
}, verifyMovementProtection = false) {
|
|
21296
|
+
const styles = /* @__PURE__ */ new Map();
|
|
21297
|
+
for (const container of children2(document, "StyleSheets"))
|
|
21298
|
+
for (const style2 of children2(container, "StyleSheet")) {
|
|
21299
|
+
charge();
|
|
21300
|
+
const id3 = attribute2(style2, "ID");
|
|
21301
|
+
if (!id3 || styles.has(id3))
|
|
21302
|
+
fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Ambiguous master style IDs.");
|
|
21303
|
+
styles.set(id3, style2);
|
|
21304
|
+
}
|
|
21305
|
+
const defaults = children2(document, "DocumentSheet")[0];
|
|
21306
|
+
const collect = (id3, category, seen = /* @__PURE__ */ new Set()) => {
|
|
21307
|
+
check();
|
|
21308
|
+
if (seen.has(id3) || seen.size >= 64)
|
|
21309
|
+
fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Invalid inherited master style ancestry.");
|
|
21310
|
+
seen.add(id3);
|
|
21311
|
+
const style2 = styles.get(id3);
|
|
21312
|
+
if (!style2) fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Missing inherited master style.");
|
|
21313
|
+
const own = masterCells(style2, charge);
|
|
21314
|
+
assertMasterMarkup(style2, new Set(own.values()), check);
|
|
21315
|
+
const parent = attribute2(style2, category);
|
|
21316
|
+
const result2 = parent !== void 0 && parent !== id3 ? collect(parent, category, seen) : /* @__PURE__ */ new Map();
|
|
21317
|
+
for (const [name3, node2] of own) {
|
|
21318
|
+
charge();
|
|
21319
|
+
if (attribute2(node2, "F") !== "Inh") result2.set(name3, node2);
|
|
21320
|
+
else if (verifyMovementProtection && /^lock(move[xy]|width|height|aspect|delete)$/.test(name3)) {
|
|
21321
|
+
charge();
|
|
21322
|
+
inheritedProtection(node2, result2.get(name3));
|
|
21323
|
+
}
|
|
21324
|
+
}
|
|
21325
|
+
return result2;
|
|
21326
|
+
};
|
|
21327
|
+
const result = /* @__PURE__ */ new Map();
|
|
21328
|
+
for (const category of ["LineStyle", "FillStyle", "TextStyle"]) {
|
|
21329
|
+
const id3 = attribute2(instance, category) ?? attribute2(template, category) ?? attribute2(defaults, category) ?? (styles.has("0") ? "0" : void 0);
|
|
21330
|
+
if (id3 !== void 0)
|
|
21331
|
+
for (const [name3, node2] of collect(id3, category)) {
|
|
21332
|
+
charge();
|
|
21333
|
+
if (result.has(name3) && result.get(name3) !== node2)
|
|
21334
|
+
fail(
|
|
21335
|
+
"EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY",
|
|
21336
|
+
"Master style categories have ambiguous overlapping inputs."
|
|
21337
|
+
);
|
|
21338
|
+
result.set(name3, node2);
|
|
21339
|
+
}
|
|
21340
|
+
}
|
|
21341
|
+
return result;
|
|
21342
|
+
}
|
|
21343
|
+
function overlay(cells4, additions, kind, charge) {
|
|
21344
|
+
const aliases = /* @__PURE__ */ new Map(), inherited = /* @__PURE__ */ new Map();
|
|
21345
|
+
for (const [name3, source] of cells4) {
|
|
21346
|
+
charge();
|
|
21347
|
+
const names = aliases.get(source.node) ?? /* @__PURE__ */ new Set();
|
|
21348
|
+
names.add(name3);
|
|
21349
|
+
aliases.set(source.node, names);
|
|
21350
|
+
}
|
|
21351
|
+
for (const [name3, node2] of additions) {
|
|
21352
|
+
charge();
|
|
21353
|
+
const source = cells4.get(name3);
|
|
21354
|
+
if (source) inherited.set(node2, source);
|
|
21355
|
+
}
|
|
21356
|
+
for (const [name3, node2] of additions) {
|
|
21357
|
+
charge();
|
|
21358
|
+
if (attribute2(node2, "F") === "Inh") {
|
|
21359
|
+
const source = cells4.get(name3) ?? inherited.get(node2);
|
|
21360
|
+
if (!source)
|
|
21361
|
+
fail(
|
|
21362
|
+
"EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY",
|
|
21363
|
+
"Inherited master cell has no effective source."
|
|
21364
|
+
);
|
|
21365
|
+
cells4.set(name3, source);
|
|
21366
|
+
const names2 = aliases.get(source.node) ?? /* @__PURE__ */ new Set();
|
|
21367
|
+
names2.add(name3);
|
|
21368
|
+
aliases.set(source.node, names2);
|
|
21369
|
+
continue;
|
|
21370
|
+
}
|
|
21371
|
+
const previous = cells4.get(name3), names = aliases.get(node2) ?? /* @__PURE__ */ new Set();
|
|
21372
|
+
if (previous && previous.node !== node2) {
|
|
21373
|
+
for (const alias of aliases.get(previous.node) ?? []) {
|
|
21374
|
+
charge();
|
|
21375
|
+
cells4.set(alias, { node: node2, kind });
|
|
21376
|
+
names.add(alias);
|
|
21377
|
+
}
|
|
21378
|
+
aliases.delete(previous.node);
|
|
21379
|
+
}
|
|
21380
|
+
cells4.set(name3, { node: node2, kind });
|
|
21381
|
+
names.add(name3);
|
|
21382
|
+
aliases.set(node2, names);
|
|
21383
|
+
}
|
|
21384
|
+
}
|
|
21385
|
+
|
|
21104
21386
|
// visio/edit-text-scope.ts
|
|
21387
|
+
function masterTemplate(pkg) {
|
|
21388
|
+
const missing = () => fail("UNSUPPORTED_TEXT_EDIT", "The master of this stencil shape cannot be resolved.");
|
|
21389
|
+
return async (masterId, masterShapeId) => {
|
|
21390
|
+
const documentPart2 = await related(pkg, "", "document");
|
|
21391
|
+
const mastersPart = documentPart2 && await related(pkg, documentPart2, "masters", false);
|
|
21392
|
+
if (!mastersPart) return missing();
|
|
21393
|
+
const definitions = children2(await visioXml(pkg, mastersPart, "Masters"), "Master").filter(
|
|
21394
|
+
(node2) => attribute2(node2, "ID") === masterId
|
|
21395
|
+
);
|
|
21396
|
+
if (definitions.length !== 1) return missing();
|
|
21397
|
+
const root2 = await visioXml(
|
|
21398
|
+
pkg,
|
|
21399
|
+
await indexedPart(pkg, mastersPart, definitions[0], "master"),
|
|
21400
|
+
"MasterContents"
|
|
21401
|
+
);
|
|
21402
|
+
if (masterShapeId === void 0) {
|
|
21403
|
+
const tops = children2(children2(root2, "Shapes")[0], "Shape");
|
|
21404
|
+
return tops.length === 1 ? tops[0] : missing();
|
|
21405
|
+
}
|
|
21406
|
+
const matches = masterShapes(root2).filter((shape) => attribute2(shape, "ID") === masterShapeId);
|
|
21407
|
+
return matches.length === 1 ? matches[0] : missing();
|
|
21408
|
+
};
|
|
21409
|
+
}
|
|
21105
21410
|
function replaceScopedPlainText(pkg, pagePaths, roots, document, edit, check) {
|
|
21106
21411
|
return replacePlainText(
|
|
21107
21412
|
roots.get(edit.pageId),
|
|
@@ -21117,7 +21422,8 @@ function replaceScopedPlainText(pkg, pagePaths, roots, document, edit, check) {
|
|
|
21117
21422
|
shape,
|
|
21118
21423
|
/* @__PURE__ */ new Map([["TheText", text3]]),
|
|
21119
21424
|
check
|
|
21120
|
-
)
|
|
21425
|
+
),
|
|
21426
|
+
masterTemplate(pkg)
|
|
21121
21427
|
);
|
|
21122
21428
|
}
|
|
21123
21429
|
|
|
@@ -21241,12 +21547,17 @@ function textRangeNodes(node2, edit) {
|
|
|
21241
21547
|
|
|
21242
21548
|
// visio/edit-text-ranges.ts
|
|
21243
21549
|
async function replaceScopedTextRanges(pkg, pagePaths, roots, document, edit, check) {
|
|
21244
|
-
const
|
|
21550
|
+
const found = textTarget(roots.get(edit.pageId), edit.shapeId, check);
|
|
21551
|
+
const instance = found.masterId === void 0 ? void 0 : instanceTextNode(
|
|
21552
|
+
found.node,
|
|
21553
|
+
await masterTemplate(pkg)(found.masterId, found.masterShapeId)
|
|
21554
|
+
);
|
|
21555
|
+
const shape = instance ? found.node : localTextTarget(roots.get(edit.pageId), document, edit.shapeId, check);
|
|
21245
21556
|
const texts = children2(shape, "Text");
|
|
21246
21557
|
if (texts.length !== 1)
|
|
21247
21558
|
fail("UNSUPPORTED_TEXT_RANGE", "Range editing requires one existing local Text element.");
|
|
21248
21559
|
const text3 = texts[0];
|
|
21249
|
-
if (Array.from(text3.childNodes).some((node2) => ![3, 4].includes(node2.nodeType))) {
|
|
21560
|
+
if (!instance && Array.from(text3.childNodes).some((node2) => ![3, 4].includes(node2.nodeType))) {
|
|
21250
21561
|
const characters = effectiveFormattingRows(shape, document, "Character"), paragraphs = effectiveFormattingRows(shape, document, "Paragraph");
|
|
21251
21562
|
assertFormattingText(shape, characters, paragraphs);
|
|
21252
21563
|
}
|
|
@@ -21263,16 +21574,20 @@ async function replaceScopedTextRanges(pkg, pagePaths, roots, document, edit, ch
|
|
|
21263
21574
|
}
|
|
21264
21575
|
}
|
|
21265
21576
|
const plan = textRangeNodes(text3, edit);
|
|
21266
|
-
if (!plan.changed)
|
|
21267
|
-
|
|
21268
|
-
|
|
21269
|
-
|
|
21270
|
-
|
|
21271
|
-
|
|
21272
|
-
|
|
21273
|
-
|
|
21274
|
-
|
|
21275
|
-
|
|
21577
|
+
if (!plan.changed) {
|
|
21578
|
+
instance?.discard();
|
|
21579
|
+
return false;
|
|
21580
|
+
}
|
|
21581
|
+
if (!instance)
|
|
21582
|
+
await assertFormattingDependencies(
|
|
21583
|
+
pkg,
|
|
21584
|
+
pagePaths,
|
|
21585
|
+
roots,
|
|
21586
|
+
edit.pageId,
|
|
21587
|
+
shape,
|
|
21588
|
+
/* @__PURE__ */ new Map([["TheText", text3]]),
|
|
21589
|
+
check
|
|
21590
|
+
);
|
|
21276
21591
|
check();
|
|
21277
21592
|
while (text3.firstChild) text3.removeChild(text3.firstChild);
|
|
21278
21593
|
for (const node2 of plan.nodes) text3.appendChild(node2);
|
|
@@ -22284,6 +22599,96 @@ function snapshotAssignLayers(edit) {
|
|
|
22284
22599
|
};
|
|
22285
22600
|
}
|
|
22286
22601
|
|
|
22602
|
+
// visio/edit-layer-properties.ts
|
|
22603
|
+
var FLAGS = [
|
|
22604
|
+
["visible", "Visible"],
|
|
22605
|
+
["print", "Print"],
|
|
22606
|
+
["lock", "Lock"]
|
|
22607
|
+
];
|
|
22608
|
+
function snapshotLayerProperties(edit) {
|
|
22609
|
+
if (typeof edit.pageId !== "string" || !edit.pageId || edit.pageId.length > 256)
|
|
22610
|
+
fail("INVALID_EDIT", "Invalid edit target.");
|
|
22611
|
+
if (typeof edit.layerId !== "string" || !/^(0|[1-9]\d{0,9})$/.test(edit.layerId))
|
|
22612
|
+
fail("INVALID_EDIT", "Layer IDs must be canonical unsigned integers.");
|
|
22613
|
+
const result = {
|
|
22614
|
+
type: "set-layer-properties",
|
|
22615
|
+
pageId: edit.pageId,
|
|
22616
|
+
layerId: edit.layerId
|
|
22617
|
+
};
|
|
22618
|
+
for (const [key2] of FLAGS) {
|
|
22619
|
+
const value = edit[key2];
|
|
22620
|
+
if (value === void 0) continue;
|
|
22621
|
+
if (typeof value !== "boolean") fail("INVALID_EDIT", "Layer flags are true or false.");
|
|
22622
|
+
result[key2] = value;
|
|
22623
|
+
}
|
|
22624
|
+
if (!FLAGS.some(([key2]) => result[key2] !== void 0))
|
|
22625
|
+
fail("INVALID_EDIT", "A layer edit needs at least one flag.");
|
|
22626
|
+
return result;
|
|
22627
|
+
}
|
|
22628
|
+
async function editVsdxLayerProperties(pkg, parts, pages, edits, limits, maxOutput, deadline, check) {
|
|
22629
|
+
const documentPart2 = await related(pkg, "", "document");
|
|
22630
|
+
const pagesPart = await related(pkg, documentPart2, "pages");
|
|
22631
|
+
const source = await visioXml(pkg, pagesPart, "Pages");
|
|
22632
|
+
const pageList = source.ownerDocument.cloneNode(true).documentElement;
|
|
22633
|
+
let changed = false;
|
|
22634
|
+
for (const edit of edits) {
|
|
22635
|
+
check();
|
|
22636
|
+
if (!pages.has(edit.pageId)) fail("EDIT_TARGET_NOT_FOUND", "Page does not exist.");
|
|
22637
|
+
const page = children2(pageList, "Page").find((node2) => attribute2(node2, "ID") === edit.pageId);
|
|
22638
|
+
const sheets = page ? children2(page, "PageSheet") : [];
|
|
22639
|
+
if (sheets.length !== 1) fail("UNSUPPORTED_LAYER_EDIT", "One explicit PageSheet is required.");
|
|
22640
|
+
const sections = children2(sheets[0], "Section").filter(
|
|
22641
|
+
(node2) => attribute2(node2, "N") === "Layer"
|
|
22642
|
+
);
|
|
22643
|
+
if (sections.length !== 1)
|
|
22644
|
+
fail("EDIT_TARGET_NOT_FOUND", "The layer does not belong to this page.");
|
|
22645
|
+
const rows = children2(sections[0], "Row").filter(
|
|
22646
|
+
(row3) => attribute2(row3, "IX") === edit.layerId
|
|
22647
|
+
);
|
|
22648
|
+
if (rows.length !== 1 || rows[0].hasAttribute("Del"))
|
|
22649
|
+
fail("EDIT_TARGET_NOT_FOUND", "The layer does not belong to this page.");
|
|
22650
|
+
const row2 = rows[0];
|
|
22651
|
+
for (const [key2, name3] of FLAGS) {
|
|
22652
|
+
const value = edit[key2];
|
|
22653
|
+
if (value === void 0) continue;
|
|
22654
|
+
const cells4 = children2(row2, "Cell").filter((cell2) => attribute2(cell2, "N") === name3);
|
|
22655
|
+
if (cells4.length > 1) fail("UNSUPPORTED_LAYER_EDIT", `Duplicate layer ${name3} cells.`);
|
|
22656
|
+
let cell = cells4[0];
|
|
22657
|
+
if (cell && (cell.hasAttribute("E") || executableCellFormula(attribute2(cell, "F"))))
|
|
22658
|
+
fail("UNSUPPORTED_LAYER_EDIT", `The layer's ${name3} flag is set by a formula.`);
|
|
22659
|
+
const next = value ? "1" : "0";
|
|
22660
|
+
if (cell && attribute2(cell, "V") === next) continue;
|
|
22661
|
+
if (!cell) {
|
|
22662
|
+
cell = row2.ownerDocument.createElementNS(row2.namespaceURI, "Cell");
|
|
22663
|
+
cell.setAttribute("N", name3);
|
|
22664
|
+
row2.appendChild(cell);
|
|
22665
|
+
}
|
|
22666
|
+
cell.setAttribute("V", next);
|
|
22667
|
+
changed = true;
|
|
22668
|
+
}
|
|
22669
|
+
}
|
|
22670
|
+
const original = parts.get(pagesPart);
|
|
22671
|
+
if (!changed)
|
|
22672
|
+
return {
|
|
22673
|
+
bytes: await writeEditedPackage(parts, maxOutput, deadline, check),
|
|
22674
|
+
changedParts: [],
|
|
22675
|
+
diagnostics: []
|
|
22676
|
+
};
|
|
22677
|
+
const serialized = serializeEditedXml(pageList, limits, check);
|
|
22678
|
+
const total = [...parts.values()].reduce((sum, bytes2) => sum + bytes2.length, 0) + serialized.bytes.length - (original?.length ?? 0);
|
|
22679
|
+
if (total > limits.maxTotalBytes) fail("LIMIT_TOTAL", "Edited package total exceeds limit.");
|
|
22680
|
+
parts.set(pagesPart, serialized.bytes);
|
|
22681
|
+
const bytes = await writeEditedPackage(parts, maxOutput, deadline, check);
|
|
22682
|
+
const verified = await openEditablePackage(
|
|
22683
|
+
bytes,
|
|
22684
|
+
{ ...limits, maxInputBytes: maxOutput, maxRuntimeMs: Math.max(1, deadline - Date.now()) },
|
|
22685
|
+
check
|
|
22686
|
+
);
|
|
22687
|
+
await visioXml(verified.pkg, pagesPart, "Pages");
|
|
22688
|
+
check();
|
|
22689
|
+
return { bytes, changedParts: [pagesPart], diagnostics: [] };
|
|
22690
|
+
}
|
|
22691
|
+
|
|
22287
22692
|
// visio/edit-guide-commands.ts
|
|
22288
22693
|
var isVisioGuideEdit = (edit) => edit.type === "create-guide" || edit.type === "move-guide" || edit.type === "delete-guide";
|
|
22289
22694
|
function snapshotGuideEdit(edit) {
|
|
@@ -22866,6 +23271,7 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
|
|
|
22866
23271
|
if (edit.type === "insert-picture") return snapshotPictureInsert(edit);
|
|
22867
23272
|
if (edit.type === "set-page-theme") return snapshotPageTheme(edit);
|
|
22868
23273
|
if (edit.type === "assign-layers") return snapshotAssignLayers(edit);
|
|
23274
|
+
if (edit.type === "set-layer-properties") return snapshotLayerProperties(edit);
|
|
22869
23275
|
if (isVisioGuideEdit(edit)) return snapshotGuideEdit(edit);
|
|
22870
23276
|
if (isVisioMetadataEdit(edit)) return snapshotMetadataEdit(edit);
|
|
22871
23277
|
if (isVisioGroupEdit(edit)) return snapshotGroupEdit(edit);
|
|
@@ -24776,177 +25182,6 @@ function analyzeVisioMasterFormula(source, options) {
|
|
|
24776
25182
|
return { ...analysis, references: [...references.values()], dynamic: dynamic2, readsText, readsTheme };
|
|
24777
25183
|
}
|
|
24778
25184
|
|
|
24779
|
-
// visio/edit-master-index.ts
|
|
24780
|
-
function inheritedProtection(node2, ancestor) {
|
|
24781
|
-
try {
|
|
24782
|
-
const boolean2 = (cell) => {
|
|
24783
|
-
if (!cell || cell.hasAttribute("E"))
|
|
24784
|
-
fail("EDIT_PROTECTED_CELL", "Inherited protection has an unresolved or error cache.");
|
|
24785
|
-
const value = visioFormulaCachedValue(attribute2(cell, "V") ?? "", attribute2(cell, "U"));
|
|
24786
|
-
if (value.unit !== "scalar" || ![0, 1].includes(value.value))
|
|
24787
|
-
fail("EDIT_PROTECTED_CELL", "Inherited protection requires scalar boolean caches.");
|
|
24788
|
-
return value.value;
|
|
24789
|
-
};
|
|
24790
|
-
if (boolean2(node2) !== boolean2(ancestor))
|
|
24791
|
-
fail(
|
|
24792
|
-
"EDIT_PROTECTED_CELL",
|
|
24793
|
-
"Delegated master style protection cache disagrees with its ancestor."
|
|
24794
|
-
);
|
|
24795
|
-
} catch (error) {
|
|
24796
|
-
fail(
|
|
24797
|
-
"EDIT_PROTECTED_CELL",
|
|
24798
|
-
`Inherited master style protection cannot be proven: ${error instanceof Error ? error.message : "invalid cache"}`
|
|
24799
|
-
);
|
|
24800
|
-
}
|
|
24801
|
-
}
|
|
24802
|
-
function masterCells(sheet, charge = () => {
|
|
24803
|
-
}) {
|
|
24804
|
-
const result = /* @__PURE__ */ new Map();
|
|
24805
|
-
if (!sheet) return result;
|
|
24806
|
-
const add = (name3, node2) => {
|
|
24807
|
-
charge();
|
|
24808
|
-
const id3 = name3.toLowerCase();
|
|
24809
|
-
if (result.has(id3) && result.get(id3) !== node2)
|
|
24810
|
-
fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Ambiguous effective master cells.");
|
|
24811
|
-
result.set(id3, node2);
|
|
24812
|
-
};
|
|
24813
|
-
for (const node2 of children2(sheet, "Cell")) add(attribute2(node2, "N") ?? "", node2);
|
|
24814
|
-
for (const section2 of children2(sheet, "Section")) {
|
|
24815
|
-
const name3 = attribute2(section2, "N") ?? "";
|
|
24816
|
-
const prefix2 = name3 === "Geometry" ? `Geometry${Number(attribute2(section2, "IX") ?? "0") + 1}` : name3 === "Control" ? "Controls" : name3;
|
|
24817
|
-
for (const node2 of children2(section2, "Cell"))
|
|
24818
|
-
add(`${prefix2}.${attribute2(node2, "N") ?? ""}`, node2);
|
|
24819
|
-
for (const row2 of children2(section2, "Row"))
|
|
24820
|
-
for (const node2 of children2(row2, "Cell")) {
|
|
24821
|
-
const n = attribute2(node2, "N") ?? "";
|
|
24822
|
-
const rowName = attribute2(row2, "N");
|
|
24823
|
-
const index = attribute2(row2, "IX") ?? (prefix2 === "Controls" && /^Row_\d+$/.test(rowName ?? "") ? String(Number(rowName.slice(4)) - 1) : void 0);
|
|
24824
|
-
const ix = index ?? "0", r = rowName ?? (prefix2 === "Controls" ? `Row_${Number(ix) + 1}` : ix);
|
|
24825
|
-
add(
|
|
24826
|
-
name3 === "Geometry" || ["Controls", "Scratch", "Connection"].includes(prefix2) ? `${prefix2}.${n}${ix}` : n === "Value" && ["User", "Prop"].includes(name3) ? `${prefix2}.${r}` : `${prefix2}.${r}.${n}`,
|
|
24827
|
-
node2
|
|
24828
|
-
);
|
|
24829
|
-
if (name3 !== "Geometry") add(`${prefix2}.${r}.${n}`, node2);
|
|
24830
|
-
if (prefix2 === "Controls" && n === "X") add(`${prefix2}.${r}`, node2);
|
|
24831
|
-
if (name3 !== "Geometry" && index !== void 0) add(`${prefix2}.$row${ix}.${n}`, node2);
|
|
24832
|
-
}
|
|
24833
|
-
}
|
|
24834
|
-
return result;
|
|
24835
|
-
}
|
|
24836
|
-
function masterShapes(root2) {
|
|
24837
|
-
const result = [], pending = [root2];
|
|
24838
|
-
while (pending.length) {
|
|
24839
|
-
const parent = pending.pop();
|
|
24840
|
-
for (const container of children2(parent, "Shapes"))
|
|
24841
|
-
for (const shape of children2(container, "Shape")) {
|
|
24842
|
-
result.push(shape);
|
|
24843
|
-
pending.push(shape);
|
|
24844
|
-
}
|
|
24845
|
-
}
|
|
24846
|
-
return result;
|
|
24847
|
-
}
|
|
24848
|
-
function assertMasterMarkup(root2, known, check) {
|
|
24849
|
-
for (const node2 of [root2, ...Array.from(root2.getElementsByTagName("*"))]) {
|
|
24850
|
-
check();
|
|
24851
|
-
if (node2.namespaceURI === root2.namespaceURI && node2.hasAttribute("F") && !known.has(node2))
|
|
24852
|
-
fail(
|
|
24853
|
-
"EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY",
|
|
24854
|
-
"Master formula outside admitted sheet cells has unknown scope."
|
|
24855
|
-
);
|
|
24856
|
-
}
|
|
24857
|
-
}
|
|
24858
|
-
function masterStyleCells(document, template, instance, check, charge = () => {
|
|
24859
|
-
}, verifyMovementProtection = false) {
|
|
24860
|
-
const styles = /* @__PURE__ */ new Map();
|
|
24861
|
-
for (const container of children2(document, "StyleSheets"))
|
|
24862
|
-
for (const style2 of children2(container, "StyleSheet")) {
|
|
24863
|
-
charge();
|
|
24864
|
-
const id3 = attribute2(style2, "ID");
|
|
24865
|
-
if (!id3 || styles.has(id3))
|
|
24866
|
-
fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Ambiguous master style IDs.");
|
|
24867
|
-
styles.set(id3, style2);
|
|
24868
|
-
}
|
|
24869
|
-
const defaults = children2(document, "DocumentSheet")[0];
|
|
24870
|
-
const collect = (id3, category, seen = /* @__PURE__ */ new Set()) => {
|
|
24871
|
-
check();
|
|
24872
|
-
if (seen.has(id3) || seen.size >= 64)
|
|
24873
|
-
fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Invalid inherited master style ancestry.");
|
|
24874
|
-
seen.add(id3);
|
|
24875
|
-
const style2 = styles.get(id3);
|
|
24876
|
-
if (!style2) fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Missing inherited master style.");
|
|
24877
|
-
const own = masterCells(style2, charge);
|
|
24878
|
-
assertMasterMarkup(style2, new Set(own.values()), check);
|
|
24879
|
-
const parent = attribute2(style2, category);
|
|
24880
|
-
const result2 = parent !== void 0 && parent !== id3 ? collect(parent, category, seen) : /* @__PURE__ */ new Map();
|
|
24881
|
-
for (const [name3, node2] of own) {
|
|
24882
|
-
charge();
|
|
24883
|
-
if (attribute2(node2, "F") !== "Inh") result2.set(name3, node2);
|
|
24884
|
-
else if (verifyMovementProtection && /^lock(move[xy]|width|height|aspect|delete)$/.test(name3)) {
|
|
24885
|
-
charge();
|
|
24886
|
-
inheritedProtection(node2, result2.get(name3));
|
|
24887
|
-
}
|
|
24888
|
-
}
|
|
24889
|
-
return result2;
|
|
24890
|
-
};
|
|
24891
|
-
const result = /* @__PURE__ */ new Map();
|
|
24892
|
-
for (const category of ["LineStyle", "FillStyle", "TextStyle"]) {
|
|
24893
|
-
const id3 = attribute2(instance, category) ?? attribute2(template, category) ?? attribute2(defaults, category) ?? (styles.has("0") ? "0" : void 0);
|
|
24894
|
-
if (id3 !== void 0)
|
|
24895
|
-
for (const [name3, node2] of collect(id3, category)) {
|
|
24896
|
-
charge();
|
|
24897
|
-
if (result.has(name3) && result.get(name3) !== node2)
|
|
24898
|
-
fail(
|
|
24899
|
-
"EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY",
|
|
24900
|
-
"Master style categories have ambiguous overlapping inputs."
|
|
24901
|
-
);
|
|
24902
|
-
result.set(name3, node2);
|
|
24903
|
-
}
|
|
24904
|
-
}
|
|
24905
|
-
return result;
|
|
24906
|
-
}
|
|
24907
|
-
function overlay(cells4, additions, kind, charge) {
|
|
24908
|
-
const aliases = /* @__PURE__ */ new Map(), inherited = /* @__PURE__ */ new Map();
|
|
24909
|
-
for (const [name3, source] of cells4) {
|
|
24910
|
-
charge();
|
|
24911
|
-
const names = aliases.get(source.node) ?? /* @__PURE__ */ new Set();
|
|
24912
|
-
names.add(name3);
|
|
24913
|
-
aliases.set(source.node, names);
|
|
24914
|
-
}
|
|
24915
|
-
for (const [name3, node2] of additions) {
|
|
24916
|
-
charge();
|
|
24917
|
-
const source = cells4.get(name3);
|
|
24918
|
-
if (source) inherited.set(node2, source);
|
|
24919
|
-
}
|
|
24920
|
-
for (const [name3, node2] of additions) {
|
|
24921
|
-
charge();
|
|
24922
|
-
if (attribute2(node2, "F") === "Inh") {
|
|
24923
|
-
const source = cells4.get(name3) ?? inherited.get(node2);
|
|
24924
|
-
if (!source)
|
|
24925
|
-
fail(
|
|
24926
|
-
"EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY",
|
|
24927
|
-
"Inherited master cell has no effective source."
|
|
24928
|
-
);
|
|
24929
|
-
cells4.set(name3, source);
|
|
24930
|
-
const names2 = aliases.get(source.node) ?? /* @__PURE__ */ new Set();
|
|
24931
|
-
names2.add(name3);
|
|
24932
|
-
aliases.set(source.node, names2);
|
|
24933
|
-
continue;
|
|
24934
|
-
}
|
|
24935
|
-
const previous = cells4.get(name3), names = aliases.get(node2) ?? /* @__PURE__ */ new Set();
|
|
24936
|
-
if (previous && previous.node !== node2) {
|
|
24937
|
-
for (const alias of aliases.get(previous.node) ?? []) {
|
|
24938
|
-
charge();
|
|
24939
|
-
cells4.set(alias, { node: node2, kind });
|
|
24940
|
-
names.add(alias);
|
|
24941
|
-
}
|
|
24942
|
-
aliases.delete(previous.node);
|
|
24943
|
-
}
|
|
24944
|
-
cells4.set(name3, { node: node2, kind });
|
|
24945
|
-
names.add(name3);
|
|
24946
|
-
aliases.set(node2, names);
|
|
24947
|
-
}
|
|
24948
|
-
}
|
|
24949
|
-
|
|
24950
25185
|
// visio/edit-master-scope.ts
|
|
24951
25186
|
function problem(message) {
|
|
24952
25187
|
return fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", message);
|
|
@@ -29334,6 +29569,21 @@ async function editVsdxTransaction(input, edits, options, clock = { deadline: 0,
|
|
|
29334
29569
|
check
|
|
29335
29570
|
);
|
|
29336
29571
|
}
|
|
29572
|
+
const layerFlags = allCommands.filter((command2) => command2.type === "set-layer-properties");
|
|
29573
|
+
if (layerFlags.length) {
|
|
29574
|
+
if (layerFlags.length !== allCommands.length)
|
|
29575
|
+
fail("EDIT_MIXED_LAYER_TRANSACTION", "Layer properties require their own transaction.");
|
|
29576
|
+
return editVsdxLayerProperties(
|
|
29577
|
+
pkg,
|
|
29578
|
+
parts,
|
|
29579
|
+
pages,
|
|
29580
|
+
layerFlags,
|
|
29581
|
+
limits,
|
|
29582
|
+
maxOutput,
|
|
29583
|
+
deadline,
|
|
29584
|
+
check
|
|
29585
|
+
);
|
|
29586
|
+
}
|
|
29337
29587
|
const layers = allCommands.filter((command2) => command2.type === "assign-layers");
|
|
29338
29588
|
if (layers.length) {
|
|
29339
29589
|
if (layers.length !== allCommands.length)
|
|
@@ -29515,7 +29765,7 @@ async function editVsdxTransaction(input, edits, options, clock = { deadline: 0,
|
|
|
29515
29765
|
))
|
|
29516
29766
|
dirty.set(pages.get(pageId2), roots.get(pageId2));
|
|
29517
29767
|
duplicateChanged = true;
|
|
29518
|
-
} else if (command2.type !== "insert-picture" && command2.type !== "set-page-theme" && command2.type !== "create-subprocess" && !isVisioCommentEdit(command2) && !isVisioDataEdit(command2) && command2.type !== "assign-layers") {
|
|
29768
|
+
} else if (command2.type !== "insert-picture" && command2.type !== "set-page-theme" && command2.type !== "create-subprocess" && !isVisioCommentEdit(command2) && !isVisioDataEdit(command2) && command2.type !== "assign-layers" && command2.type !== "set-layer-properties") {
|
|
29519
29769
|
for (const pageId2 of applyGeometryEdit(roots, document, command2, check, masterMovePins))
|
|
29520
29770
|
dirty.set(pages.get(pageId2), roots.get(pageId2));
|
|
29521
29771
|
}
|