@markasso/mcp 0.8.1 → 0.8.2

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.
@@ -20,6 +20,11 @@ var SHAPE_KINDS = [
20
20
  "manualInput",
21
21
  "delay"
22
22
  ];
23
+ var SHAPE_KIND_SET = new Set(SHAPE_KINDS);
24
+ /** Whether this version knows the kind (it has a definition and a name). */
25
+ function isShapeKind(kind) {
26
+ return SHAPE_KIND_SET.has(kind);
27
+ }
23
28
  /**
24
29
  * Arrowhead shapes. `open` is the classic two-stroke head; the others are
25
30
  * closed outlines, either hollow or filled with the stroke color (UML-style
@@ -489,6 +494,25 @@ function shapeCommandsToPathData(commands, ox, oy) {
489
494
  return `${cmd[0]} ${round2(cmd[1] + ox)} ${round2(cmd[2] + oy)}`;
490
495
  }).join(" ");
491
496
  }
497
+ /**
498
+ * Stand-in for a kind this version does not know (written by a newer one):
499
+ * a plain rectangle, so the element stays visible, selectable and
500
+ * connectable until the app is updated.
501
+ */
502
+ var UNKNOWN_SHAPE = {
503
+ outline: rectCommands,
504
+ sides: allSides,
505
+ textBox: (w, h) => ({
506
+ x: 0,
507
+ y: 0,
508
+ w,
509
+ h
510
+ })
511
+ };
512
+ /** The geometry of a kind, or the rectangle stand-in for an unknown one. */
513
+ function getShapeDefinition(kind) {
514
+ return isShapeKind(kind) ? SHAPE_DEFINITIONS[kind] : UNKNOWN_SHAPE;
515
+ }
492
516
  //#endregion
493
517
  //#region ../src/elements/stencils/generic.ts
494
518
  var K = CUBIC_CIRCLE_K;
@@ -3207,7 +3231,7 @@ function flattenShapeCommands(commands) {
3207
3231
  }
3208
3232
  /** Closed outline polygon of a shape in box-local coordinates. */
3209
3233
  function getShapeOutlinePolygon(kind, w, h) {
3210
- return flattenShapeCommands(SHAPE_DEFINITIONS[kind].outline(w, h))[0] ?? [];
3234
+ return flattenShapeCommands(getShapeDefinition(kind).outline(w, h))[0] ?? [];
3211
3235
  }
3212
3236
  /** Samples per cubic when looking for crossings, before refining them. */
3213
3237
  var EDGE_SCAN_STEPS = 32;
@@ -3268,7 +3292,7 @@ function getShapeSideEdge(kind, w, h, side, along) {
3268
3292
  };
3269
3293
  let start = null;
3270
3294
  let current = null;
3271
- for (const cmd of SHAPE_DEFINITIONS[kind].outline(w, h)) if (cmd[0] === "M") {
3295
+ for (const cmd of getShapeDefinition(kind).outline(w, h)) if (cmd[0] === "M") {
3272
3296
  if (start) break;
3273
3297
  start = current = [cmd[1], cmd[2]];
3274
3298
  } else if (cmd[0] === "L" && current) {
@@ -3286,7 +3310,7 @@ function getShapeSideEdge(kind, w, h, side, along) {
3286
3310
  return best;
3287
3311
  }
3288
3312
  function getShapeTextBox(kind, w, h) {
3289
- return SHAPE_DEFINITIONS[kind].textBox(w, h);
3313
+ return getShapeDefinition(kind).textBox(w, h);
3290
3314
  }
3291
3315
  /** Share of an ellipse's or rhombus's width its label wraps in. */
3292
3316
  var ROUND_LABEL_AREA = .7;
@@ -3977,7 +4001,7 @@ function sideSpan(el, dir) {
3977
4001
  const b = getElementBounds(el);
3978
4002
  const vertical = dir.dx === 0;
3979
4003
  if (el.type === "shape") {
3980
- const span = SHAPE_DEFINITIONS[el.kind].sides(b.w, b.h)[sideOf(dir)];
4004
+ const span = getShapeDefinition(el.kind).sides(b.w, b.h)[sideOf(dir)];
3981
4005
  if (!span || span[1] - span[0] < 1) return null;
3982
4006
  const offset = vertical ? b.x : b.y;
3983
4007
  return [span[0] + offset, span[1] + offset];
@@ -4606,7 +4630,7 @@ function shapeToSVG(el, ox, oy) {
4606
4630
  const { x: left, y: top, w, h } = normalizeRect(el);
4607
4631
  const x = left + ox;
4608
4632
  const y = top + oy;
4609
- const def = SHAPE_DEFINITIONS[el.kind];
4633
+ const def = getShapeDefinition(el.kind);
4610
4634
  const parts = [`<path d="${shapeCommandsToPathData(def.outline(w, h), x, y)}" ${shapeProps(el)}/>`];
4611
4635
  const details = def.details?.(w, h);
4612
4636
  if (details) parts.push(`<path d="${shapeCommandsToPathData(details, x, y)}" ${shapeProps({
@@ -4781,7 +4805,7 @@ function escapeXml(str) {
4781
4805
  }
4782
4806
  //#endregion
4783
4807
  //#region package.json
4784
- var version = "0.8.1";
4808
+ var version = "0.8.2";
4785
4809
  //#endregion
4786
4810
  //#region ../src/core/layout.ts
4787
4811
  /** Space kept on both sides of a label between ranks. */
@@ -6213,7 +6237,16 @@ var ARROW_HEADS = /* @__PURE__ */ new Set([
6213
6237
  "end",
6214
6238
  "both"
6215
6239
  ]);
6216
- var SHAPE_KIND_SET = new Set(SHAPE_KINDS);
6240
+ /**
6241
+ * Shape kinds a newer version may add look like the current ones: a short
6242
+ * camelCase word. An unknown kind of that form is kept (and drawn as a
6243
+ * rectangle) instead of dropped, so opening a newer board here and saving
6244
+ * it again never deletes its symbols.
6245
+ */
6246
+ var SHAPE_KIND_FORMAT = /^[a-z][A-Za-z0-9]{0,39}$/;
6247
+ function isAcceptedShapeKind(kind) {
6248
+ return isShapeKind(kind) || SHAPE_KIND_FORMAT.test(kind);
6249
+ }
6217
6250
  var ROUTINGS = new Set(CONNECTOR_ROUTINGS);
6218
6251
  var HEAD_STYLES = new Set(ARROW_HEAD_STYLES);
6219
6252
  function isRecord$1(value) {
@@ -6289,7 +6322,7 @@ function isValidElement(value) {
6289
6322
  case "rectangle":
6290
6323
  case "ellipse":
6291
6324
  case "rhombus": return hasBoxFields(value) && hasShapeLabelFields(value) && isOptionalFiniteNumber(value.cornerRadius, 0, 1e3);
6292
- case "shape": return hasBoxFields(value) && hasShapeLabelFields(value) && typeof value.kind === "string" && SHAPE_KIND_SET.has(value.kind);
6325
+ case "shape": return hasBoxFields(value) && hasShapeLabelFields(value) && typeof value.kind === "string" && isAcceptedShapeKind(value.kind);
6293
6326
  case "stencil": return hasBoxFields(value) && hasShapeLabelFields(value) && isValidStencilSource(value.source) && !(isRecord$1(value.source) && value.source.kind === "embedded" && value.rotation !== void 0 && value.rotation !== 0);
6294
6327
  case "line": return hasEndpointFields(value) && hasConnectorFields(value) && isOptionalFiniteNumber(value.cx) && isOptionalFiniteNumber(value.cy) && isOptionalEnum(value.arrowHead, ARROW_HEADS) && isOptionalEnum(value.startHeadStyle, HEAD_STYLES);
6295
6328
  case "arrow": return hasEndpointFields(value) && hasConnectorFields(value);
@@ -7790,7 +7823,7 @@ function autoSizeOf(el) {
7790
7823
  case "rectangle":
7791
7824
  case "ellipse":
7792
7825
  case "rhombus": return labelSize(el.type, el.label ?? "", DEFAULT_SIZES[el.type], el.labelFontSize);
7793
- case "shape": return labelSize(el.kind, el.label ?? "", DEFAULT_SIZES.shape, el.labelFontSize);
7826
+ case "shape": return labelSize(isShapeKind(el.kind) ? el.kind : "rectangle", el.label ?? "", DEFAULT_SIZES.shape, el.labelFontSize);
7794
7827
  default: return null;
7795
7828
  }
7796
7829
  }
@@ -7965,6 +7998,7 @@ function isElementPatch(value) {
7965
7998
  if ("id" in value || "type" in value) return false;
7966
7999
  if ("src" in value && !isImageSource(value.src)) return false;
7967
8000
  if ("source" in value && !isValidStencilSource(value.source)) return false;
8001
+ if ("kind" in value && !(typeof value.kind === "string" && isAcceptedShapeKind(value.kind))) return false;
7968
8002
  return true;
7969
8003
  }
7970
8004
  function isElementList(value) {
@@ -8040,7 +8074,7 @@ var CHECKS = {
8040
8074
  UNLOCK_ELEMENTS: (c) => isIdList(c.ids),
8041
8075
  SET_TEXT_MODE: (c) => TEXT_MODES.has(c.mode) && optionalIdList(c.ids),
8042
8076
  ALIGN_ELEMENTS: (c) => isListOf(c.moves, (move) => isId(move.id) && isNumber(move.x) && isNumber(move.y)),
8043
- APPLY_STYLE: (c) => optionalIdList(c.ids) && STYLE_STRINGS.every((key) => optionalString(c[key])) && STYLE_NUMBERS.every((key) => optionalNumber(c[key])) && STYLE_BOOLEANS.every((key) => optionalBoolean(c[key]))
8077
+ APPLY_STYLE: (c) => optionalIdList(c.ids) && (c.shapeKind === void 0 || typeof c.shapeKind === "string" && isShapeKind(c.shapeKind)) && STYLE_STRINGS.every((key) => optionalString(c[key])) && STYLE_NUMBERS.every((key) => optionalNumber(c[key])) && STYLE_BOOLEANS.every((key) => optionalBoolean(c[key]))
8044
8078
  };
8045
8079
  new Set(Object.keys(CHECKS));
8046
8080
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markasso/mcp",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "mcpName": "io.github.AlbertoBarrago/markasso",
5
5
  "description": "MCP server that lets AI agents create, read and edit Markasso diagrams, offline or live on a shared board",
6
6
  "type": "module",