ooxml-core 1.4.0 → 1.5.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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Outlines for Visio's Basic Shapes stencil, written as local geometry the core can create and
3
+ * resize: every path is a closed run of RelMoveTo/RelLineTo rows in the shape's own box (0 to 1,
4
+ * Y up). Curved outlines (the can) are polylines. Ellipse and Circle are not here; they use the
5
+ * native Ellipse row through `create-ellipse`.
6
+ */
7
+ export declare const VISIO_BASIC_SHAPES: readonly ['rectangle', 'square', 'triangle', 'right-triangle', 'pentagon', 'hexagon', 'octagon', 'star', 'diamond', 'rounded-rectangle', 'cross', 'parallelogram', 'trapezoid', 'can', 'cube', 'chevron'];
8
+ export type VisioBasicShape = (typeof VISIO_BASIC_SHAPES)[number];
9
+ export type VisioOutlinePoint = readonly [x: number, y: number];
10
+ export interface VisioBasicOutline {
11
+ /** Closed paths, drawn in order; each becomes one Geometry section. */
12
+ paths: readonly (readonly VisioOutlinePoint[])[];
13
+ /** Corner radius as a fraction of the shorter side, written to the Rounding cell. */
14
+ rounding?: number;
15
+ }
16
+ export declare const isVisioBasicShape: (value: unknown) => value is VisioBasicShape;
17
+ export declare function visioBasicShapeOutline(shape: VisioBasicShape): VisioBasicOutline;
18
+ //# sourceMappingURL=basic-shapes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic-shapes.d.ts","sourceRoot":"","sources":["../../visio/basic-shapes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,YAC9B,WAAW,EACX,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,SAAS,EACT,MAAM,EACN,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,eAAe,EACf,WAAW,EACX,KAAK,EACL,MAAM,EACN,SAAS,CACA,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAChE,MAAM,WAAW,iBAAiB;IACjC,uEAAuE;IACvE,KAAK,EAAE,SAAS,CAAC,SAAS,iBAAiB,EAAE,CAAC,EAAE,CAAC;IACjD,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,KAAK,IAAI,eACD,CAAC;AAwL5D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,GAAG,iBAAiB,CAEhF"}
@@ -1,3 +1,4 @@
1
+ import { type VisioBasicShape } from './basic-shapes.js';
1
2
  import { type VisioTextRangesEdit } from './edit-text-range-commands.js';
2
3
  export type { VisioTextRange, VisioTextRangesEdit } from './edit-text-range-commands.js';
3
4
  import { type VisioResizeAnchor } from './resize-anchor.js';
@@ -40,6 +41,7 @@ export type VisioGeometryEdit = (Target & {
40
41
  endY: number;
41
42
  }) | (BoxCreation & {
42
43
  type: 'create-rectangle';
44
+ shape?: VisioBasicShape;
43
45
  }) | (BoxCreation & {
44
46
  type: 'create-ellipse';
45
47
  }) | (BoxCreation & {
@@ -1 +1 @@
1
- {"version":3,"file":"edit-commands.d.ts","sourceRoot":"","sources":["../../visio/edit-commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAA2B,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACnG,YAAY,EAAE,wBAAwB,EAAE,MAAM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B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACd;AACD,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACb;AACD,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CACf;AACD,sGAAsG;AACtG,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AACD,MAAM,MAAM,aAAa,GACtB,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,eAAe,GACf,iBAAiB,CAAC;AACrB,MAAM,MAAM,SAAS,GAClB,aAAa,GACb,mBAAmB,GACnB,iBAAiB,GACjB,aAAa,GACb,eAAe,GACf,wBAAwB,GACxB,oBAAoB,GACpB,mBAAmB,CAAC;AACvB,eAAO,MAAM,eAAe,SAAU,SAAS,KAAG,IAAI,IAAI,aAK5B,CAAC;AAE/B,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,EAAE,CA8BtE;AAED,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACb,SAAS,EAAE,CAuJb"}
@@ -1 +1 @@
1
- {"version":3,"file":"edit-shape-create.d.ts","sourceRoot":"","sources":["../../visio/edit-shape-create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AA2DzD,wBAAgB,eAAe,CAC9B,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,OAAO,CAA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O,EACjB,IAAI,EAAE,OAAO,CAAC,iBAAiB,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,GACvD,OAAO,CAkDT"}
@@ -15257,10 +15257,10 @@ function replaceRecord(input, drawing, record5, replacement) {
15257
15257
  if (!(block.format & 2) || ![8, 12, 13].includes(block.format >>> 4))
15258
15258
  throw new VsdError("unsafe-block-relocation");
15259
15259
  try {
15260
- const fit = encodeVsdBlockToSize(decoded, block.length);
15261
- if (!fit)
15260
+ const fit2 = encodeVsdBlockToSize(decoded, block.length);
15261
+ if (!fit2)
15262
15262
  throw new VsdError("unsafe-block-relocation");
15263
- stored = fit.bytes;
15263
+ stored = fit2.bytes;
15264
15264
  } catch (error) {
15265
15265
  if (error instanceof VsdCompressionFitError)
15266
15266
  throw new VsdError(`compression-${error.reason}`);
@@ -17726,6 +17726,203 @@ async function replaceScopedTextRanges(pkg, pagePaths, roots, document, edit, ch
17726
17726
  return true;
17727
17727
  }
17728
17728
 
17729
+ // visio/basic-shapes.ts
17730
+ var VISIO_BASIC_SHAPES = [
17731
+ "rectangle",
17732
+ "square",
17733
+ "triangle",
17734
+ "right-triangle",
17735
+ "pentagon",
17736
+ "hexagon",
17737
+ "octagon",
17738
+ "star",
17739
+ "diamond",
17740
+ "rounded-rectangle",
17741
+ "cross",
17742
+ "parallelogram",
17743
+ "trapezoid",
17744
+ "can",
17745
+ "cube",
17746
+ "chevron"
17747
+ ];
17748
+ var isVisioBasicShape = (value) => VISIO_BASIC_SHAPES.includes(value);
17749
+ function fit(points) {
17750
+ const xs = points.map(([x]) => x), ys = points.map(([, y]) => y);
17751
+ const left = Math.min(...xs), bottom = Math.min(...ys);
17752
+ const width = Math.max(...xs) - left, height = Math.max(...ys) - bottom;
17753
+ return points.map(([x, y]) => [(x - left) / width, (y - bottom) / height]);
17754
+ }
17755
+ function polygon(count, inner) {
17756
+ const steps = inner === void 0 ? count : count * 2;
17757
+ return fit(
17758
+ Array.from({ length: steps }, (_, index) => {
17759
+ const radius = inner !== void 0 && index % 2 ? inner : 1;
17760
+ const angle = Math.PI / 2 + index * 2 * Math.PI / steps;
17761
+ return [radius * Math.cos(angle), radius * Math.sin(angle)];
17762
+ })
17763
+ );
17764
+ }
17765
+ function arc(cy, ry, from, to) {
17766
+ const segments = 12;
17767
+ return Array.from({ length: segments + 1 }, (_, index) => {
17768
+ const angle = from + (to - from) * index / segments;
17769
+ return [0.5 + 0.5 * Math.cos(angle), cy + ry * Math.sin(angle)];
17770
+ });
17771
+ }
17772
+ var box = [
17773
+ [0, 0],
17774
+ [1, 0],
17775
+ [1, 1],
17776
+ [0, 1]
17777
+ ];
17778
+ var LID = 0.2;
17779
+ var CUT = 1 / (2 + Math.SQRT2);
17780
+ var OUTLINES = {
17781
+ rectangle: { paths: [box] },
17782
+ square: { paths: [box] },
17783
+ triangle: {
17784
+ paths: [
17785
+ [
17786
+ [0, 0],
17787
+ [1, 0],
17788
+ [0.5, 1]
17789
+ ]
17790
+ ]
17791
+ },
17792
+ "right-triangle": {
17793
+ paths: [
17794
+ [
17795
+ [0, 0],
17796
+ [1, 0],
17797
+ [0, 1]
17798
+ ]
17799
+ ]
17800
+ },
17801
+ pentagon: { paths: [polygon(5)] },
17802
+ hexagon: {
17803
+ paths: [
17804
+ [
17805
+ [0.25, 0],
17806
+ [0.75, 0],
17807
+ [1, 0.5],
17808
+ [0.75, 1],
17809
+ [0.25, 1],
17810
+ [0, 0.5]
17811
+ ]
17812
+ ]
17813
+ },
17814
+ octagon: {
17815
+ paths: [
17816
+ [
17817
+ [CUT, 0],
17818
+ [1 - CUT, 0],
17819
+ [1, CUT],
17820
+ [1, 1 - CUT],
17821
+ [1 - CUT, 1],
17822
+ [CUT, 1],
17823
+ [0, 1 - CUT],
17824
+ [0, CUT]
17825
+ ]
17826
+ ]
17827
+ },
17828
+ star: { paths: [polygon(5, 0.382)] },
17829
+ diamond: {
17830
+ paths: [
17831
+ [
17832
+ [0.5, 0],
17833
+ [1, 0.5],
17834
+ [0.5, 1],
17835
+ [0, 0.5]
17836
+ ]
17837
+ ]
17838
+ },
17839
+ "rounded-rectangle": { paths: [box], rounding: 0.15 },
17840
+ cross: {
17841
+ paths: [
17842
+ [
17843
+ [1 / 3, 0],
17844
+ [2 / 3, 0],
17845
+ [2 / 3, 1 / 3],
17846
+ [1, 1 / 3],
17847
+ [1, 2 / 3],
17848
+ [2 / 3, 2 / 3],
17849
+ [2 / 3, 1],
17850
+ [1 / 3, 1],
17851
+ [1 / 3, 2 / 3],
17852
+ [0, 2 / 3],
17853
+ [0, 1 / 3],
17854
+ [1 / 3, 1 / 3]
17855
+ ]
17856
+ ]
17857
+ },
17858
+ parallelogram: {
17859
+ paths: [
17860
+ [
17861
+ [0, 0],
17862
+ [0.75, 0],
17863
+ [1, 1],
17864
+ [0.25, 1]
17865
+ ]
17866
+ ]
17867
+ },
17868
+ trapezoid: {
17869
+ paths: [
17870
+ [
17871
+ [0, 0],
17872
+ [1, 0],
17873
+ [0.75, 1],
17874
+ [0.25, 1]
17875
+ ]
17876
+ ]
17877
+ },
17878
+ can: {
17879
+ paths: [
17880
+ // The body: down the left side, round the front of the base, up the right side and
17881
+ // back along the front of the lid.
17882
+ [...arc(LID / 2, LID / 2, Math.PI, 2 * Math.PI), ...arc(1 - LID / 2, LID / 2, 0, -Math.PI)],
17883
+ // The lid, drawn over the body.
17884
+ arc(1 - LID / 2, LID / 2, 0, 2 * Math.PI).slice(0, -1)
17885
+ ]
17886
+ },
17887
+ cube: {
17888
+ paths: [
17889
+ [
17890
+ [0, 0],
17891
+ [0.75, 0],
17892
+ [0.75, 0.75],
17893
+ [0, 0.75]
17894
+ ],
17895
+ [
17896
+ [0, 0.75],
17897
+ [0.75, 0.75],
17898
+ [1, 1],
17899
+ [0.25, 1]
17900
+ ],
17901
+ [
17902
+ [0.75, 0],
17903
+ [1, 0.25],
17904
+ [1, 1],
17905
+ [0.75, 0.75]
17906
+ ]
17907
+ ]
17908
+ },
17909
+ chevron: {
17910
+ paths: [
17911
+ [
17912
+ [0, 0],
17913
+ [0.75, 0],
17914
+ [1, 0.5],
17915
+ [0.75, 1],
17916
+ [0, 1],
17917
+ [0.25, 0.5]
17918
+ ]
17919
+ ]
17920
+ }
17921
+ };
17922
+ function visioBasicShapeOutline(shape) {
17923
+ return OUTLINES[shape];
17924
+ }
17925
+
17729
17926
  // visio/edit-text-range-commands.ts
17730
17927
  var invalidXmlText = /[\u0000-\u0008\u000b\u000c\u000d\u000e-\u001f\ufffe\uffff]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
17731
17928
  function textRangeBoundary(text, offset) {
@@ -18111,7 +18308,10 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
18111
18308
  return { ...target, type: edit.type, beginX, beginY, endX, endY };
18112
18309
  }
18113
18310
  case "create-rectangle":
18114
- case "create-ellipse":
18311
+ case "create-ellipse": {
18312
+ const shape = edit.type === "create-rectangle" ? edit.shape : void 0;
18313
+ if (shape !== void 0 && !isVisioBasicShape(shape))
18314
+ fail("INVALID_EDIT", "Unknown basic shape.");
18115
18315
  return {
18116
18316
  ...target,
18117
18317
  type: edit.type,
@@ -18119,8 +18319,10 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
18119
18319
  y: numeric5(edit.y),
18120
18320
  width: numeric5(edit.width, true),
18121
18321
  height: numeric5(edit.height, true),
18122
- ...edit.text === void 0 ? {} : { text: text(edit.text) }
18322
+ ...edit.text === void 0 ? {} : { text: text(edit.text) },
18323
+ ...shape === void 0 ? {} : { shape }
18123
18324
  };
18325
+ }
18124
18326
  case "rotate-shape":
18125
18327
  return { ...target, type: edit.type, angle: numeric5(edit.angle) };
18126
18328
  case "flip-shape":
@@ -18534,24 +18736,25 @@ function createRectangle(root2, document, edit) {
18534
18736
  }
18535
18737
  const doc = root2.ownerDocument;
18536
18738
  const node = (name) => doc.createElementNS(root2.namespaceURI, name);
18537
- const section = node("Section");
18538
- section.setAttribute("N", "Geometry");
18539
- section.setAttribute("IX", "0");
18540
- for (const [index, [x, y]] of [
18541
- [0, 0],
18542
- [1, 0],
18543
- [1, 1],
18544
- [0, 1],
18545
- [0, 0]
18546
- ].entries()) {
18547
- const row = node("Row");
18548
- row.setAttribute("IX", String(index + 1));
18549
- row.setAttribute("T", index ? "RelLineTo" : "RelMoveTo");
18550
- setCell(row, "X", x);
18551
- setCell(row, "Y", y);
18552
- section.appendChild(row);
18739
+ const outline = visioBasicShapeOutline(
18740
+ edit.type === "create-rectangle" ? edit.shape ?? "rectangle" : "rectangle"
18741
+ );
18742
+ if (outline.rounding)
18743
+ setCell(shape, "Rounding", outline.rounding * Math.min(edit.width, edit.height));
18744
+ for (const [sectionIndex, points] of outline.paths.entries()) {
18745
+ const section = node("Section");
18746
+ section.setAttribute("N", "Geometry");
18747
+ section.setAttribute("IX", String(sectionIndex));
18748
+ for (const [index, [x, y]] of [...points, points[0]].entries()) {
18749
+ const row = node("Row");
18750
+ row.setAttribute("IX", String(index + 1));
18751
+ row.setAttribute("T", index ? "RelLineTo" : "RelMoveTo");
18752
+ setCell(row, "X", x);
18753
+ setCell(row, "Y", y);
18754
+ section.appendChild(row);
18755
+ }
18756
+ shape.appendChild(section);
18553
18757
  }
18554
- shape.appendChild(section);
18555
18758
  const text = node("Text");
18556
18759
  text.appendChild(doc.createTextNode(encodeVisioPlainText(edit.text ?? "")));
18557
18760
  shape.appendChild(text);
@@ -22425,6 +22628,7 @@ function trimVisioArrowLine(path, start, end, beginExtension = 0) {
22425
22628
  return `M ${point2(start)}${base > start ? ` L ${point2(base)}` : ""} L ${point2(length - end)}`;
22426
22629
  }
22427
22630
 
22631
+ exports.VISIO_BASIC_SHAPES = VISIO_BASIC_SHAPES;
22428
22632
  exports.VISIO_CLIPBOARD_MAGIC = VISIO_CLIPBOARD_MAGIC;
22429
22633
  exports.VISIO_CLIPBOARD_MAX_CHARS = VISIO_CLIPBOARD_MAX_CHARS;
22430
22634
  exports.VISIO_EMF_ADMISSION_LIMITS = VISIO_EMF_ADMISSION_LIMITS;
@@ -22445,6 +22649,7 @@ exports.evaluateVisioFormula = evaluateVisioFormula;
22445
22649
  exports.getVisioPageLayers = getVisioPageLayers;
22446
22650
  exports.inspectVisioEmfAdmission = inspectVisioEmfAdmission;
22447
22651
  exports.inspectVisioRasterImage = inspectVisioRasterImage;
22652
+ exports.isVisioBasicShape = isVisioBasicShape;
22448
22653
  exports.layoutVisioFilledArrowLine = layoutVisioFilledArrowLine;
22449
22654
  exports.loadVisio = loadVisio;
22450
22655
  exports.parseLegacyVsd = parseLegacyVsd;
@@ -22455,6 +22660,7 @@ exports.sanitizeVisioForeignVectorTree = sanitizeVisioForeignVectorTree;
22455
22660
  exports.serializeVisioClipboard = serializeVisioClipboard;
22456
22661
  exports.trimVisioArrowLine = trimVisioArrowLine;
22457
22662
  exports.validateVisioForeignVector = validateVisioForeignVector;
22663
+ exports.visioBasicShapeOutline = visioBasicShapeOutline;
22458
22664
  exports.visioFilledArrow = visioFilledArrow;
22459
22665
  exports.visioFormulaCachedValue = visioFormulaCachedValue;
22460
22666
  exports.visioOpenArrowExtent = visioOpenArrowExtent;
@@ -13,6 +13,7 @@ export { convertVisioMetafile, type VisioMetafileTreeConverter, type VisioMetafi
13
13
  export { editVsdx, type VisioEdit, type VisioGeometryEdit, type VisioTextEdit, type VisioTextRange, type VisioTextRangesEdit, type VisioPageInsert, type VisioPageReorder, type VisioPageRename, type VisioPageDelete, type VisioPageSizeEdit, type VisioPageEdit, type VisioFormatEdit, type VisioTextFormatEdit, type VisioShapeFormatEdit, type VisioShapeOrderEdit, type VisioDuplicateShapesEdit, type VisioPasteShapesEdit, type VisioResizeAnchor, type EditVsdxOptions, type EditVsdxResult, } from './edit.js';
14
14
  export { captureVisioClipboard, serializeVisioClipboard, deserializeVisioClipboard, VISIO_CLIPBOARD_MAGIC, VISIO_CLIPBOARD_MAX_CHARS, type VisioClipboardSnapshot, } from './clipboard.js';
15
15
  export { createVsdx, type CreateVsdxOptions } from './create-document.js';
16
+ export { VISIO_BASIC_SHAPES, isVisioBasicShape, visioBasicShapeOutline, type VisioBasicShape, type VisioBasicOutline, type VisioOutlinePoint, } from './basic-shapes.js';
16
17
  export { parseVisioFormula, analyzeVisioFormula, evaluateVisioFormula, visioFormulaCachedValue, VisioFormulaError, type VisioFormulaAst, type VisioFormulaLimits, type VisioFormulaValue, type VisioFormulaReference, type VisioFormulaUnit, } from './formula.js';
17
18
  export { visioOpenArrowExtent, visioOpenArrowPath } from './open-arrow.js';
18
19
  export { visioFilledArrow, trimVisioArrowLine, layoutVisioFilledArrowLine, type VisioFilledArrow, type VisioArrowLineLayout, } from './filled-arrow.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../visio/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,mBAAmB,SAAS,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EACN,0BAA0B,EAC1B,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,GACjC,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5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K,gBAAgB,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GACzB,MAAM,gBAAgB,CAAC"}
@@ -15251,10 +15251,10 @@ function replaceRecord(input, drawing, record5, replacement) {
15251
15251
  if (!(block.format & 2) || ![8, 12, 13].includes(block.format >>> 4))
15252
15252
  throw new VsdError("unsafe-block-relocation");
15253
15253
  try {
15254
- const fit = encodeVsdBlockToSize(decoded, block.length);
15255
- if (!fit)
15254
+ const fit2 = encodeVsdBlockToSize(decoded, block.length);
15255
+ if (!fit2)
15256
15256
  throw new VsdError("unsafe-block-relocation");
15257
- stored = fit.bytes;
15257
+ stored = fit2.bytes;
15258
15258
  } catch (error) {
15259
15259
  if (error instanceof VsdCompressionFitError)
15260
15260
  throw new VsdError(`compression-${error.reason}`);
@@ -17720,6 +17720,203 @@ async function replaceScopedTextRanges(pkg, pagePaths, roots, document, edit, ch
17720
17720
  return true;
17721
17721
  }
17722
17722
 
17723
+ // visio/basic-shapes.ts
17724
+ var VISIO_BASIC_SHAPES = [
17725
+ "rectangle",
17726
+ "square",
17727
+ "triangle",
17728
+ "right-triangle",
17729
+ "pentagon",
17730
+ "hexagon",
17731
+ "octagon",
17732
+ "star",
17733
+ "diamond",
17734
+ "rounded-rectangle",
17735
+ "cross",
17736
+ "parallelogram",
17737
+ "trapezoid",
17738
+ "can",
17739
+ "cube",
17740
+ "chevron"
17741
+ ];
17742
+ var isVisioBasicShape = (value) => VISIO_BASIC_SHAPES.includes(value);
17743
+ function fit(points) {
17744
+ const xs = points.map(([x]) => x), ys = points.map(([, y]) => y);
17745
+ const left = Math.min(...xs), bottom = Math.min(...ys);
17746
+ const width = Math.max(...xs) - left, height = Math.max(...ys) - bottom;
17747
+ return points.map(([x, y]) => [(x - left) / width, (y - bottom) / height]);
17748
+ }
17749
+ function polygon(count, inner) {
17750
+ const steps = inner === void 0 ? count : count * 2;
17751
+ return fit(
17752
+ Array.from({ length: steps }, (_, index) => {
17753
+ const radius = inner !== void 0 && index % 2 ? inner : 1;
17754
+ const angle = Math.PI / 2 + index * 2 * Math.PI / steps;
17755
+ return [radius * Math.cos(angle), radius * Math.sin(angle)];
17756
+ })
17757
+ );
17758
+ }
17759
+ function arc(cy, ry, from, to) {
17760
+ const segments = 12;
17761
+ return Array.from({ length: segments + 1 }, (_, index) => {
17762
+ const angle = from + (to - from) * index / segments;
17763
+ return [0.5 + 0.5 * Math.cos(angle), cy + ry * Math.sin(angle)];
17764
+ });
17765
+ }
17766
+ var box = [
17767
+ [0, 0],
17768
+ [1, 0],
17769
+ [1, 1],
17770
+ [0, 1]
17771
+ ];
17772
+ var LID = 0.2;
17773
+ var CUT = 1 / (2 + Math.SQRT2);
17774
+ var OUTLINES = {
17775
+ rectangle: { paths: [box] },
17776
+ square: { paths: [box] },
17777
+ triangle: {
17778
+ paths: [
17779
+ [
17780
+ [0, 0],
17781
+ [1, 0],
17782
+ [0.5, 1]
17783
+ ]
17784
+ ]
17785
+ },
17786
+ "right-triangle": {
17787
+ paths: [
17788
+ [
17789
+ [0, 0],
17790
+ [1, 0],
17791
+ [0, 1]
17792
+ ]
17793
+ ]
17794
+ },
17795
+ pentagon: { paths: [polygon(5)] },
17796
+ hexagon: {
17797
+ paths: [
17798
+ [
17799
+ [0.25, 0],
17800
+ [0.75, 0],
17801
+ [1, 0.5],
17802
+ [0.75, 1],
17803
+ [0.25, 1],
17804
+ [0, 0.5]
17805
+ ]
17806
+ ]
17807
+ },
17808
+ octagon: {
17809
+ paths: [
17810
+ [
17811
+ [CUT, 0],
17812
+ [1 - CUT, 0],
17813
+ [1, CUT],
17814
+ [1, 1 - CUT],
17815
+ [1 - CUT, 1],
17816
+ [CUT, 1],
17817
+ [0, 1 - CUT],
17818
+ [0, CUT]
17819
+ ]
17820
+ ]
17821
+ },
17822
+ star: { paths: [polygon(5, 0.382)] },
17823
+ diamond: {
17824
+ paths: [
17825
+ [
17826
+ [0.5, 0],
17827
+ [1, 0.5],
17828
+ [0.5, 1],
17829
+ [0, 0.5]
17830
+ ]
17831
+ ]
17832
+ },
17833
+ "rounded-rectangle": { paths: [box], rounding: 0.15 },
17834
+ cross: {
17835
+ paths: [
17836
+ [
17837
+ [1 / 3, 0],
17838
+ [2 / 3, 0],
17839
+ [2 / 3, 1 / 3],
17840
+ [1, 1 / 3],
17841
+ [1, 2 / 3],
17842
+ [2 / 3, 2 / 3],
17843
+ [2 / 3, 1],
17844
+ [1 / 3, 1],
17845
+ [1 / 3, 2 / 3],
17846
+ [0, 2 / 3],
17847
+ [0, 1 / 3],
17848
+ [1 / 3, 1 / 3]
17849
+ ]
17850
+ ]
17851
+ },
17852
+ parallelogram: {
17853
+ paths: [
17854
+ [
17855
+ [0, 0],
17856
+ [0.75, 0],
17857
+ [1, 1],
17858
+ [0.25, 1]
17859
+ ]
17860
+ ]
17861
+ },
17862
+ trapezoid: {
17863
+ paths: [
17864
+ [
17865
+ [0, 0],
17866
+ [1, 0],
17867
+ [0.75, 1],
17868
+ [0.25, 1]
17869
+ ]
17870
+ ]
17871
+ },
17872
+ can: {
17873
+ paths: [
17874
+ // The body: down the left side, round the front of the base, up the right side and
17875
+ // back along the front of the lid.
17876
+ [...arc(LID / 2, LID / 2, Math.PI, 2 * Math.PI), ...arc(1 - LID / 2, LID / 2, 0, -Math.PI)],
17877
+ // The lid, drawn over the body.
17878
+ arc(1 - LID / 2, LID / 2, 0, 2 * Math.PI).slice(0, -1)
17879
+ ]
17880
+ },
17881
+ cube: {
17882
+ paths: [
17883
+ [
17884
+ [0, 0],
17885
+ [0.75, 0],
17886
+ [0.75, 0.75],
17887
+ [0, 0.75]
17888
+ ],
17889
+ [
17890
+ [0, 0.75],
17891
+ [0.75, 0.75],
17892
+ [1, 1],
17893
+ [0.25, 1]
17894
+ ],
17895
+ [
17896
+ [0.75, 0],
17897
+ [1, 0.25],
17898
+ [1, 1],
17899
+ [0.75, 0.75]
17900
+ ]
17901
+ ]
17902
+ },
17903
+ chevron: {
17904
+ paths: [
17905
+ [
17906
+ [0, 0],
17907
+ [0.75, 0],
17908
+ [1, 0.5],
17909
+ [0.75, 1],
17910
+ [0, 1],
17911
+ [0.25, 0.5]
17912
+ ]
17913
+ ]
17914
+ }
17915
+ };
17916
+ function visioBasicShapeOutline(shape) {
17917
+ return OUTLINES[shape];
17918
+ }
17919
+
17723
17920
  // visio/edit-text-range-commands.ts
17724
17921
  var invalidXmlText = /[\u0000-\u0008\u000b\u000c\u000d\u000e-\u001f\ufffe\uffff]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
17725
17922
  function textRangeBoundary(text, offset) {
@@ -18105,7 +18302,10 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
18105
18302
  return { ...target, type: edit.type, beginX, beginY, endX, endY };
18106
18303
  }
18107
18304
  case "create-rectangle":
18108
- case "create-ellipse":
18305
+ case "create-ellipse": {
18306
+ const shape = edit.type === "create-rectangle" ? edit.shape : void 0;
18307
+ if (shape !== void 0 && !isVisioBasicShape(shape))
18308
+ fail("INVALID_EDIT", "Unknown basic shape.");
18109
18309
  return {
18110
18310
  ...target,
18111
18311
  type: edit.type,
@@ -18113,8 +18313,10 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
18113
18313
  y: numeric5(edit.y),
18114
18314
  width: numeric5(edit.width, true),
18115
18315
  height: numeric5(edit.height, true),
18116
- ...edit.text === void 0 ? {} : { text: text(edit.text) }
18316
+ ...edit.text === void 0 ? {} : { text: text(edit.text) },
18317
+ ...shape === void 0 ? {} : { shape }
18117
18318
  };
18319
+ }
18118
18320
  case "rotate-shape":
18119
18321
  return { ...target, type: edit.type, angle: numeric5(edit.angle) };
18120
18322
  case "flip-shape":
@@ -18528,24 +18730,25 @@ function createRectangle(root2, document, edit) {
18528
18730
  }
18529
18731
  const doc = root2.ownerDocument;
18530
18732
  const node = (name) => doc.createElementNS(root2.namespaceURI, name);
18531
- const section = node("Section");
18532
- section.setAttribute("N", "Geometry");
18533
- section.setAttribute("IX", "0");
18534
- for (const [index, [x, y]] of [
18535
- [0, 0],
18536
- [1, 0],
18537
- [1, 1],
18538
- [0, 1],
18539
- [0, 0]
18540
- ].entries()) {
18541
- const row = node("Row");
18542
- row.setAttribute("IX", String(index + 1));
18543
- row.setAttribute("T", index ? "RelLineTo" : "RelMoveTo");
18544
- setCell(row, "X", x);
18545
- setCell(row, "Y", y);
18546
- section.appendChild(row);
18733
+ const outline = visioBasicShapeOutline(
18734
+ edit.type === "create-rectangle" ? edit.shape ?? "rectangle" : "rectangle"
18735
+ );
18736
+ if (outline.rounding)
18737
+ setCell(shape, "Rounding", outline.rounding * Math.min(edit.width, edit.height));
18738
+ for (const [sectionIndex, points] of outline.paths.entries()) {
18739
+ const section = node("Section");
18740
+ section.setAttribute("N", "Geometry");
18741
+ section.setAttribute("IX", String(sectionIndex));
18742
+ for (const [index, [x, y]] of [...points, points[0]].entries()) {
18743
+ const row = node("Row");
18744
+ row.setAttribute("IX", String(index + 1));
18745
+ row.setAttribute("T", index ? "RelLineTo" : "RelMoveTo");
18746
+ setCell(row, "X", x);
18747
+ setCell(row, "Y", y);
18748
+ section.appendChild(row);
18749
+ }
18750
+ shape.appendChild(section);
18547
18751
  }
18548
- shape.appendChild(section);
18549
18752
  const text = node("Text");
18550
18753
  text.appendChild(doc.createTextNode(encodeVisioPlainText(edit.text ?? "")));
18551
18754
  shape.appendChild(text);
@@ -22419,4 +22622,4 @@ function trimVisioArrowLine(path, start, end, beginExtension = 0) {
22419
22622
  return `M ${point2(start)}${base > start ? ` L ${point2(base)}` : ""} L ${point2(length - end)}`;
22420
22623
  }
22421
22624
 
22422
- export { VISIO_CLIPBOARD_MAGIC, VISIO_CLIPBOARD_MAX_CHARS, VISIO_EMF_ADMISSION_LIMITS, VISIO_FOREIGN_VECTOR_LIMITS, VISIO_RASTER_IMAGE_LIMITS, VISIO_VISIBILITY_LIMITS, VisioForeignVectorError, VisioFormulaError, VisioImageError, VisioPackageError, analyzeVisioFormula, captureVisioClipboard, convertVisioMetafile, createVsdx, deserializeVisioClipboard, editVsdx, evaluateVisioFormula, getVisioPageLayers, inspectVisioEmfAdmission, inspectVisioRasterImage, layoutVisioFilledArrowLine, loadVisio, parseLegacyVsd, parseVisioFormula, parseVsdx, resolveVisioPageVisibility, sanitizeVisioForeignVectorTree, serializeVisioClipboard, trimVisioArrowLine, validateVisioForeignVector, visioFilledArrow, visioFormulaCachedValue, visioOpenArrowExtent, visioOpenArrowPath };
22625
+ export { VISIO_BASIC_SHAPES, VISIO_CLIPBOARD_MAGIC, VISIO_CLIPBOARD_MAX_CHARS, VISIO_EMF_ADMISSION_LIMITS, VISIO_FOREIGN_VECTOR_LIMITS, VISIO_RASTER_IMAGE_LIMITS, VISIO_VISIBILITY_LIMITS, VisioForeignVectorError, VisioFormulaError, VisioImageError, VisioPackageError, analyzeVisioFormula, captureVisioClipboard, convertVisioMetafile, createVsdx, deserializeVisioClipboard, editVsdx, evaluateVisioFormula, getVisioPageLayers, inspectVisioEmfAdmission, inspectVisioRasterImage, isVisioBasicShape, layoutVisioFilledArrowLine, loadVisio, parseLegacyVsd, parseVisioFormula, parseVsdx, resolveVisioPageVisibility, sanitizeVisioForeignVectorTree, serializeVisioClipboard, trimVisioArrowLine, validateVisioForeignVector, visioBasicShapeOutline, visioFilledArrow, visioFormulaCachedValue, visioOpenArrowExtent, visioOpenArrowPath };