@markasso/mcp 0.8.0 → 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.
- package/dist/markasso-mcp.js +251 -31
- package/package.json +1 -1
package/dist/markasso-mcp.js
CHANGED
|
@@ -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
|
|
@@ -63,6 +68,19 @@ function quarter(x0, y0, x1, y1, startAxis) {
|
|
|
63
68
|
y1
|
|
64
69
|
];
|
|
65
70
|
}
|
|
71
|
+
/** Middle half of `0..length`: the usable part of a cap or a point. */
|
|
72
|
+
function middleHalf(length) {
|
|
73
|
+
return [length * .25, length * .75];
|
|
74
|
+
}
|
|
75
|
+
/** Every side usable along its full length. */
|
|
76
|
+
function allSides(w, h) {
|
|
77
|
+
return {
|
|
78
|
+
top: [0, w],
|
|
79
|
+
right: [0, h],
|
|
80
|
+
bottom: [0, w],
|
|
81
|
+
left: [0, h]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
66
84
|
function rectCommands(w, h) {
|
|
67
85
|
return [
|
|
68
86
|
[
|
|
@@ -115,6 +133,16 @@ var SHAPE_DEFINITIONS = {
|
|
|
115
133
|
["Z"]
|
|
116
134
|
];
|
|
117
135
|
},
|
|
136
|
+
sides(w, h) {
|
|
137
|
+
const r = Math.min(w / 2, h / 2);
|
|
138
|
+
const flat = w - 2 * r >= w * .5 ? [r, w - r] : middleHalf(w);
|
|
139
|
+
return {
|
|
140
|
+
top: flat,
|
|
141
|
+
right: middleHalf(h),
|
|
142
|
+
bottom: flat,
|
|
143
|
+
left: middleHalf(h)
|
|
144
|
+
};
|
|
145
|
+
},
|
|
118
146
|
textBox(w, h) {
|
|
119
147
|
const r = Math.min(w / 2, h / 2);
|
|
120
148
|
return {
|
|
@@ -152,6 +180,15 @@ var SHAPE_DEFINITIONS = {
|
|
|
152
180
|
["Z"]
|
|
153
181
|
];
|
|
154
182
|
},
|
|
183
|
+
sides(w, h) {
|
|
184
|
+
const s = Math.min(w * .2, h * .5);
|
|
185
|
+
return {
|
|
186
|
+
top: [s, w],
|
|
187
|
+
right: [0, h],
|
|
188
|
+
bottom: [0, w - s],
|
|
189
|
+
left: [0, h]
|
|
190
|
+
};
|
|
191
|
+
},
|
|
155
192
|
textBox(w, h) {
|
|
156
193
|
const s = Math.min(w * .2, h * .5);
|
|
157
194
|
return {
|
|
@@ -194,6 +231,15 @@ var SHAPE_DEFINITIONS = {
|
|
|
194
231
|
["Z"]
|
|
195
232
|
];
|
|
196
233
|
},
|
|
234
|
+
sides(w, h) {
|
|
235
|
+
const base = h - h * .1;
|
|
236
|
+
return {
|
|
237
|
+
top: [0, w],
|
|
238
|
+
right: [0, base],
|
|
239
|
+
bottom: [0, w],
|
|
240
|
+
left: [0, base]
|
|
241
|
+
};
|
|
242
|
+
},
|
|
197
243
|
textBox(w, h) {
|
|
198
244
|
return {
|
|
199
245
|
x: 0,
|
|
@@ -224,6 +270,15 @@ var SHAPE_DEFINITIONS = {
|
|
|
224
270
|
["Z"]
|
|
225
271
|
];
|
|
226
272
|
},
|
|
273
|
+
sides(w, h) {
|
|
274
|
+
const ry = Math.min(h * .15, w * .25);
|
|
275
|
+
return {
|
|
276
|
+
top: middleHalf(w),
|
|
277
|
+
right: [ry, h - ry],
|
|
278
|
+
bottom: middleHalf(w),
|
|
279
|
+
left: [ry, h - ry]
|
|
280
|
+
};
|
|
281
|
+
},
|
|
227
282
|
details(w, h) {
|
|
228
283
|
const ry = Math.min(h * .15, w * .25);
|
|
229
284
|
return [
|
|
@@ -248,6 +303,7 @@ var SHAPE_DEFINITIONS = {
|
|
|
248
303
|
},
|
|
249
304
|
predefinedProcess: {
|
|
250
305
|
outline: rectCommands,
|
|
306
|
+
sides: allSides,
|
|
251
307
|
details(w, h) {
|
|
252
308
|
const d = Math.min(w * .1, 16);
|
|
253
309
|
return [
|
|
@@ -320,6 +376,15 @@ var SHAPE_DEFINITIONS = {
|
|
|
320
376
|
["Z"]
|
|
321
377
|
];
|
|
322
378
|
},
|
|
379
|
+
sides(w, h) {
|
|
380
|
+
const s = Math.min(w * .2, h * .5);
|
|
381
|
+
return {
|
|
382
|
+
top: [s, w - s],
|
|
383
|
+
right: middleHalf(h),
|
|
384
|
+
bottom: [s, w - s],
|
|
385
|
+
left: middleHalf(h)
|
|
386
|
+
};
|
|
387
|
+
},
|
|
323
388
|
textBox(w, h) {
|
|
324
389
|
const s = Math.min(w * .2, h * .5);
|
|
325
390
|
return {
|
|
@@ -356,6 +421,14 @@ var SHAPE_DEFINITIONS = {
|
|
|
356
421
|
["Z"]
|
|
357
422
|
];
|
|
358
423
|
},
|
|
424
|
+
sides(w, h) {
|
|
425
|
+
return {
|
|
426
|
+
top: [0, w],
|
|
427
|
+
right: [0, h],
|
|
428
|
+
bottom: [0, w],
|
|
429
|
+
left: [h * .25, h]
|
|
430
|
+
};
|
|
431
|
+
},
|
|
359
432
|
textBox(w, h) {
|
|
360
433
|
const t = h * .25;
|
|
361
434
|
return {
|
|
@@ -390,6 +463,15 @@ var SHAPE_DEFINITIONS = {
|
|
|
390
463
|
["Z"]
|
|
391
464
|
];
|
|
392
465
|
},
|
|
466
|
+
sides(w, h) {
|
|
467
|
+
const r = Math.min(w / 2, h / 2);
|
|
468
|
+
return {
|
|
469
|
+
top: [0, w - r],
|
|
470
|
+
right: middleHalf(h),
|
|
471
|
+
bottom: [0, w - r],
|
|
472
|
+
left: [0, h]
|
|
473
|
+
};
|
|
474
|
+
},
|
|
393
475
|
textBox(w, h) {
|
|
394
476
|
const r = Math.min(w / 2, h / 2);
|
|
395
477
|
return {
|
|
@@ -412,6 +494,25 @@ function shapeCommandsToPathData(commands, ox, oy) {
|
|
|
412
494
|
return `${cmd[0]} ${round2(cmd[1] + ox)} ${round2(cmd[2] + oy)}`;
|
|
413
495
|
}).join(" ");
|
|
414
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
|
+
}
|
|
415
516
|
//#endregion
|
|
416
517
|
//#region ../src/elements/stencils/generic.ts
|
|
417
518
|
var K = CUBIC_CIRCLE_K;
|
|
@@ -3130,10 +3231,86 @@ function flattenShapeCommands(commands) {
|
|
|
3130
3231
|
}
|
|
3131
3232
|
/** Closed outline polygon of a shape in box-local coordinates. */
|
|
3132
3233
|
function getShapeOutlinePolygon(kind, w, h) {
|
|
3133
|
-
return flattenShapeCommands(
|
|
3234
|
+
return flattenShapeCommands(getShapeDefinition(kind).outline(w, h))[0] ?? [];
|
|
3235
|
+
}
|
|
3236
|
+
/** Samples per cubic when looking for crossings, before refining them. */
|
|
3237
|
+
var EDGE_SCAN_STEPS = 32;
|
|
3238
|
+
/** Bisection rounds per crossing: far below a pixel on any shape size. */
|
|
3239
|
+
var EDGE_REFINE_STEPS = 40;
|
|
3240
|
+
/**
|
|
3241
|
+
* Where a side's outline lies at `along` (x for top and bottom, y for left
|
|
3242
|
+
* and right), in box-local coordinates: the outline crossing of the line
|
|
3243
|
+
* through `along` perpendicular to the side, the outermost one toward that
|
|
3244
|
+
* side. Curves are intersected exactly (scanned, then refined by
|
|
3245
|
+
* bisection), not through the flattened polygon, so an end placed there
|
|
3246
|
+
* touches the drawn stroke on large shapes too. Null when the line misses
|
|
3247
|
+
* the outline.
|
|
3248
|
+
*/
|
|
3249
|
+
function getShapeSideEdge(kind, w, h, side, along) {
|
|
3250
|
+
const vertical = side === "top" || side === "bottom";
|
|
3251
|
+
const outward = side === "bottom" || side === "right" ? 1 : -1;
|
|
3252
|
+
/** Along and across coordinates of a point. */
|
|
3253
|
+
const a = (p) => vertical ? p[0] : p[1];
|
|
3254
|
+
const c = (p) => vertical ? p[1] : p[0];
|
|
3255
|
+
let best = null;
|
|
3256
|
+
const consider = (at) => {
|
|
3257
|
+
if (best === null || at * outward > best * outward) best = at;
|
|
3258
|
+
};
|
|
3259
|
+
const line = (p, q) => {
|
|
3260
|
+
const lo = Math.min(a(p), a(q));
|
|
3261
|
+
const hi = Math.max(a(p), a(q));
|
|
3262
|
+
if (along < lo || along > hi) return;
|
|
3263
|
+
const span = a(q) - a(p);
|
|
3264
|
+
if (Math.abs(span) < 1e-9) {
|
|
3265
|
+
consider(c(p));
|
|
3266
|
+
consider(c(q));
|
|
3267
|
+
} else consider(c(p) + (along - a(p)) / span * (c(q) - c(p)));
|
|
3268
|
+
};
|
|
3269
|
+
const cubic = (p0, p1, p2, p3) => {
|
|
3270
|
+
const at = (t) => [cubicAt(p0[0], p1[0], p2[0], p3[0], t), cubicAt(p0[1], p1[1], p2[1], p3[1], t)];
|
|
3271
|
+
const offset = (t) => a(at(t)) - along;
|
|
3272
|
+
let t0 = 0;
|
|
3273
|
+
let f0 = offset(0);
|
|
3274
|
+
for (let i = 1; i <= EDGE_SCAN_STEPS; i++) {
|
|
3275
|
+
const t1 = i / EDGE_SCAN_STEPS;
|
|
3276
|
+
const f1 = offset(t1);
|
|
3277
|
+
if (f0 === 0) consider(c(at(t0)));
|
|
3278
|
+
else if (f0 * f1 < 0) {
|
|
3279
|
+
let lo = t0;
|
|
3280
|
+
let hi = t1;
|
|
3281
|
+
for (let k = 0; k < EDGE_REFINE_STEPS; k++) {
|
|
3282
|
+
const mid = (lo + hi) / 2;
|
|
3283
|
+
if (offset(lo) * offset(mid) <= 0) hi = mid;
|
|
3284
|
+
else lo = mid;
|
|
3285
|
+
}
|
|
3286
|
+
consider(c(at((lo + hi) / 2)));
|
|
3287
|
+
}
|
|
3288
|
+
t0 = t1;
|
|
3289
|
+
f0 = f1;
|
|
3290
|
+
}
|
|
3291
|
+
if (f0 === 0) consider(c(at(1)));
|
|
3292
|
+
};
|
|
3293
|
+
let start = null;
|
|
3294
|
+
let current = null;
|
|
3295
|
+
for (const cmd of getShapeDefinition(kind).outline(w, h)) if (cmd[0] === "M") {
|
|
3296
|
+
if (start) break;
|
|
3297
|
+
start = current = [cmd[1], cmd[2]];
|
|
3298
|
+
} else if (cmd[0] === "L" && current) {
|
|
3299
|
+
const next = [cmd[1], cmd[2]];
|
|
3300
|
+
line(current, next);
|
|
3301
|
+
current = next;
|
|
3302
|
+
} else if (cmd[0] === "C" && current) {
|
|
3303
|
+
const next = [cmd[5], cmd[6]];
|
|
3304
|
+
cubic(current, [cmd[1], cmd[2]], [cmd[3], cmd[4]], next);
|
|
3305
|
+
current = next;
|
|
3306
|
+
} else if (cmd[0] === "Z" && current && start) {
|
|
3307
|
+
line(current, start);
|
|
3308
|
+
current = start;
|
|
3309
|
+
}
|
|
3310
|
+
return best;
|
|
3134
3311
|
}
|
|
3135
3312
|
function getShapeTextBox(kind, w, h) {
|
|
3136
|
-
return
|
|
3313
|
+
return getShapeDefinition(kind).textBox(w, h);
|
|
3137
3314
|
}
|
|
3138
3315
|
/** Share of an ellipse's or rhombus's width its label wraps in. */
|
|
3139
3316
|
var ROUND_LABEL_AREA = .7;
|
|
@@ -3614,9 +3791,8 @@ function planElbowEnds(el, allElements) {
|
|
|
3614
3791
|
if (s && e && startEl && endEl && !el.startAnchor && !el.endAnchor) {
|
|
3615
3792
|
const shared = sharedOffset(startEl, s.dir, endEl, e.dir);
|
|
3616
3793
|
if (shared !== null) {
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
e.point = vertical ? [shared, e.point[1]] : [e.point[0], shared];
|
|
3794
|
+
placeAlong(s, startEl, shared);
|
|
3795
|
+
placeAlong(e, endEl, shared);
|
|
3620
3796
|
aligned = true;
|
|
3621
3797
|
}
|
|
3622
3798
|
}
|
|
@@ -3685,8 +3861,8 @@ function spreadAlongSide(preferred, lo, hi) {
|
|
|
3685
3861
|
* connectors do not cross each other. Returns the ends it moved, with their
|
|
3686
3862
|
* new coordinate along the side (x for top/bottom, y for left/right).
|
|
3687
3863
|
*
|
|
3688
|
-
* Pinned ends, hidden connectors, self-loops and sides
|
|
3689
|
-
* (see
|
|
3864
|
+
* Pinned ends, hidden connectors, self-loops and sides with a single port
|
|
3865
|
+
* (see sideSpan) keep their planned point, and a side with a single
|
|
3690
3866
|
* end is left alone. The result depends only on the scene, so every live
|
|
3691
3867
|
* peer computes the same routes; it is cached per elements array, which is
|
|
3692
3868
|
* immutable, so a frame resolving N connectors plans each of them once
|
|
@@ -3718,7 +3894,7 @@ function elbowPortSlots(allElements) {
|
|
|
3718
3894
|
]];
|
|
3719
3895
|
const added = [];
|
|
3720
3896
|
for (const [end, node, anchor, other, which] of ends) {
|
|
3721
|
-
if (!end || !node || anchor || !
|
|
3897
|
+
if (!end || !node || anchor || !sideSpan(node, end.dir)) continue;
|
|
3722
3898
|
const axis = end.dir.dx === 0 ? 0 : 1;
|
|
3723
3899
|
const depth = (other[0] - end.point[0]) * end.dir.dx + (other[1] - end.point[1]) * end.dir.dy;
|
|
3724
3900
|
const member = {
|
|
@@ -3747,7 +3923,7 @@ function elbowPortSlots(allElements) {
|
|
|
3747
3923
|
const order = [...groups.entries()].sort(([ka, a], [kb, b]) => b.length - a.length || (ka < kb ? -1 : ka > kb ? 1 : 0));
|
|
3748
3924
|
for (const [, members] of order) {
|
|
3749
3925
|
const { node, dir } = members[0];
|
|
3750
|
-
const [lo, hi] =
|
|
3926
|
+
const [lo, hi] = sideSpan(node, dir);
|
|
3751
3927
|
const preferred = /* @__PURE__ */ new Map();
|
|
3752
3928
|
for (const m of members) {
|
|
3753
3929
|
const partner = partnerOf.get(m.key);
|
|
@@ -3755,7 +3931,8 @@ function elbowPortSlots(allElements) {
|
|
|
3755
3931
|
preferred.set(m, there !== void 0 && there >= lo && there <= hi ? there : m.at);
|
|
3756
3932
|
}
|
|
3757
3933
|
const pref = (m) => preferred.get(m);
|
|
3758
|
-
|
|
3934
|
+
const grid = (m) => Math.round(pref(m) * 100);
|
|
3935
|
+
members.sort((a, b) => grid(a) - grid(b) || a.angle - b.angle || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
3759
3936
|
const placed = spreadAlongSide(members.map(pref), lo, hi);
|
|
3760
3937
|
members.forEach((m, i) => {
|
|
3761
3938
|
placedAt.set(m.key, placed[i]);
|
|
@@ -3765,9 +3942,32 @@ function elbowPortSlots(allElements) {
|
|
|
3765
3942
|
portSlotCache.set(allElements, slots);
|
|
3766
3943
|
return slots;
|
|
3767
3944
|
}
|
|
3768
|
-
/**
|
|
3769
|
-
|
|
3770
|
-
|
|
3945
|
+
/**
|
|
3946
|
+
* Moves an end's point to `along` on its side's axis. On a flowchart symbol
|
|
3947
|
+
* the point also moves across, onto the outline, since that side may be
|
|
3948
|
+
* slanted or curved; flat sides keep their line.
|
|
3949
|
+
*/
|
|
3950
|
+
function placeAlong(end, node, along) {
|
|
3951
|
+
const vertical = end.dir.dx === 0;
|
|
3952
|
+
let across = vertical ? end.point[1] : end.point[0];
|
|
3953
|
+
if (node.type === "shape" && !node.rotation) {
|
|
3954
|
+
const b = getElementBounds(node);
|
|
3955
|
+
const [start, length] = vertical ? [b.x, b.w] : [b.y, b.h];
|
|
3956
|
+
const local = Math.min(Math.max(along - start, 0), length);
|
|
3957
|
+
const edge = getShapeSideEdge(node.kind, b.w, b.h, sideOf(end.dir), local);
|
|
3958
|
+
if (edge !== null) {
|
|
3959
|
+
across = edge + (vertical ? b.y : b.x);
|
|
3960
|
+
const outer = vertical ? end.dir.dy === 1 ? b.y + b.h : b.y : end.dir.dx === 1 ? b.x + b.w : b.x;
|
|
3961
|
+
end.stub = 16 + Math.abs(outer - across);
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
end.point = vertical ? [along, across] : [across, along];
|
|
3965
|
+
}
|
|
3966
|
+
/** The box side an outward axis direction leaves by. */
|
|
3967
|
+
function sideOf(dir) {
|
|
3968
|
+
if (dir.dy === -1) return "top";
|
|
3969
|
+
if (dir.dy === 1) return "bottom";
|
|
3970
|
+
return dir.dx === 1 ? "right" : "left";
|
|
3771
3971
|
}
|
|
3772
3972
|
/**
|
|
3773
3973
|
* Polyline a connector is drawn along: its two resolved ends, or the full
|
|
@@ -3784,22 +3984,32 @@ function resolveConnectorRoute(el, allElements) {
|
|
|
3784
3984
|
const slots = elbowPortSlots(allElements);
|
|
3785
3985
|
const startSlot = slots.get(slotKey(el.id, "start"));
|
|
3786
3986
|
const endSlot = slots.get(slotKey(el.id, "end"));
|
|
3787
|
-
if (s && startSlot !== void 0) placeAlong(s, startSlot);
|
|
3788
|
-
if (e && endSlot !== void 0) placeAlong(e, endSlot);
|
|
3987
|
+
if (s && plan.startEl && startSlot !== void 0) placeAlong(s, plan.startEl, startSlot);
|
|
3988
|
+
if (e && plan.endEl && endSlot !== void 0) placeAlong(e, plan.endEl, endSlot);
|
|
3789
3989
|
return computeElbowRoute(s?.point ?? plan.start, s?.dir ?? null, e?.point ?? plan.end, e?.dir ?? null, s?.stub, e?.stub);
|
|
3790
3990
|
}
|
|
3791
3991
|
/**
|
|
3792
|
-
*
|
|
3793
|
-
* top/bottom, y for left/right)
|
|
3794
|
-
*
|
|
3992
|
+
* Stretch of the side a connector leaves `el` by where several ends can
|
|
3993
|
+
* spread, along that side (x for top/bottom, y for left/right): a flat side
|
|
3994
|
+
* inset from rounded corners, or the stretch a flowchart symbol declares
|
|
3995
|
+
* (see ShapeSides), which may be slanted or curved. Null for sides with a
|
|
3996
|
+
* single port (ellipse, rhombus, round or pointed symbol ends) and for
|
|
3997
|
+
* rotated elements.
|
|
3795
3998
|
*/
|
|
3796
|
-
function
|
|
3999
|
+
function sideSpan(el, dir) {
|
|
3797
4000
|
if (el.rotation) return null;
|
|
3798
|
-
if (el.type !== "rectangle" && el.type !== "stencil" && el.type !== "text" && el.type !== "image") return null;
|
|
3799
4001
|
const b = getElementBounds(el);
|
|
4002
|
+
const vertical = dir.dx === 0;
|
|
4003
|
+
if (el.type === "shape") {
|
|
4004
|
+
const span = getShapeDefinition(el.kind).sides(b.w, b.h)[sideOf(dir)];
|
|
4005
|
+
if (!span || span[1] - span[0] < 1) return null;
|
|
4006
|
+
const offset = vertical ? b.x : b.y;
|
|
4007
|
+
return [span[0] + offset, span[1] + offset];
|
|
4008
|
+
}
|
|
4009
|
+
if (el.type !== "rectangle" && el.type !== "stencil" && el.type !== "text" && el.type !== "image") return null;
|
|
3800
4010
|
const side = el.type === "stencil" && dir.dy === 1 ? getStencilLabelBox(el) ?? b : b;
|
|
3801
4011
|
const inset = el.type === "rectangle" ? el.cornerRadius ?? 0 : 0;
|
|
3802
|
-
const [lo, hi] =
|
|
4012
|
+
const [lo, hi] = vertical ? [side.x, side.x + side.w] : [side.y, side.y + side.h];
|
|
3803
4013
|
return hi - lo > inset * 2 ? [lo + inset, hi - inset] : null;
|
|
3804
4014
|
}
|
|
3805
4015
|
/**
|
|
@@ -3812,8 +4022,8 @@ function flatSideRange(el, dir) {
|
|
|
3812
4022
|
*/
|
|
3813
4023
|
function sharedOffset(startEl, startDir, endEl, endDir) {
|
|
3814
4024
|
if (startDir.dx !== -endDir.dx || startDir.dy !== -endDir.dy) return null;
|
|
3815
|
-
const a =
|
|
3816
|
-
const b =
|
|
4025
|
+
const a = sideSpan(startEl, startDir);
|
|
4026
|
+
const b = sideSpan(endEl, endDir);
|
|
3817
4027
|
if (!a || !b) return null;
|
|
3818
4028
|
const lo = Math.max(a[0], b[0]);
|
|
3819
4029
|
const hi = Math.min(a[1], b[1]);
|
|
@@ -3976,7 +4186,7 @@ function getConnectorLabelSize(el) {
|
|
|
3976
4186
|
};
|
|
3977
4187
|
}
|
|
3978
4188
|
function isCurved(el) {
|
|
3979
|
-
return el.type === "line" && el.cx !== void 0 && el.cy !== void 0;
|
|
4189
|
+
return el.type === "line" && el.routing !== "elbow" && el.cx !== void 0 && el.cy !== void 0;
|
|
3980
4190
|
}
|
|
3981
4191
|
/** Polyline the connector is drawn along (curves sampled). */
|
|
3982
4192
|
function polylineOf$1(el, elements) {
|
|
@@ -4420,7 +4630,7 @@ function shapeToSVG(el, ox, oy) {
|
|
|
4420
4630
|
const { x: left, y: top, w, h } = normalizeRect(el);
|
|
4421
4631
|
const x = left + ox;
|
|
4422
4632
|
const y = top + oy;
|
|
4423
|
-
const def =
|
|
4633
|
+
const def = getShapeDefinition(el.kind);
|
|
4424
4634
|
const parts = [`<path d="${shapeCommandsToPathData(def.outline(w, h), x, y)}" ${shapeProps(el)}/>`];
|
|
4425
4635
|
const details = def.details?.(w, h);
|
|
4426
4636
|
if (details) parts.push(`<path d="${shapeCommandsToPathData(details, x, y)}" ${shapeProps({
|
|
@@ -4595,7 +4805,7 @@ function escapeXml(str) {
|
|
|
4595
4805
|
}
|
|
4596
4806
|
//#endregion
|
|
4597
4807
|
//#region package.json
|
|
4598
|
-
var version = "0.8.
|
|
4808
|
+
var version = "0.8.2";
|
|
4599
4809
|
//#endregion
|
|
4600
4810
|
//#region ../src/core/layout.ts
|
|
4601
4811
|
/** Space kept on both sides of a label between ranks. */
|
|
@@ -6027,7 +6237,16 @@ var ARROW_HEADS = /* @__PURE__ */ new Set([
|
|
|
6027
6237
|
"end",
|
|
6028
6238
|
"both"
|
|
6029
6239
|
]);
|
|
6030
|
-
|
|
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
|
+
}
|
|
6031
6250
|
var ROUTINGS = new Set(CONNECTOR_ROUTINGS);
|
|
6032
6251
|
var HEAD_STYLES = new Set(ARROW_HEAD_STYLES);
|
|
6033
6252
|
function isRecord$1(value) {
|
|
@@ -6103,7 +6322,7 @@ function isValidElement(value) {
|
|
|
6103
6322
|
case "rectangle":
|
|
6104
6323
|
case "ellipse":
|
|
6105
6324
|
case "rhombus": return hasBoxFields(value) && hasShapeLabelFields(value) && isOptionalFiniteNumber(value.cornerRadius, 0, 1e3);
|
|
6106
|
-
case "shape": return hasBoxFields(value) && hasShapeLabelFields(value) && typeof value.kind === "string" &&
|
|
6325
|
+
case "shape": return hasBoxFields(value) && hasShapeLabelFields(value) && typeof value.kind === "string" && isAcceptedShapeKind(value.kind);
|
|
6107
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);
|
|
6108
6327
|
case "line": return hasEndpointFields(value) && hasConnectorFields(value) && isOptionalFiniteNumber(value.cx) && isOptionalFiniteNumber(value.cy) && isOptionalEnum(value.arrowHead, ARROW_HEADS) && isOptionalEnum(value.startHeadStyle, HEAD_STYLES);
|
|
6109
6328
|
case "arrow": return hasEndpointFields(value) && hasConnectorFields(value);
|
|
@@ -7604,7 +7823,7 @@ function autoSizeOf(el) {
|
|
|
7604
7823
|
case "rectangle":
|
|
7605
7824
|
case "ellipse":
|
|
7606
7825
|
case "rhombus": return labelSize(el.type, el.label ?? "", DEFAULT_SIZES[el.type], el.labelFontSize);
|
|
7607
|
-
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);
|
|
7608
7827
|
default: return null;
|
|
7609
7828
|
}
|
|
7610
7829
|
}
|
|
@@ -7779,6 +7998,7 @@ function isElementPatch(value) {
|
|
|
7779
7998
|
if ("id" in value || "type" in value) return false;
|
|
7780
7999
|
if ("src" in value && !isImageSource(value.src)) return false;
|
|
7781
8000
|
if ("source" in value && !isValidStencilSource(value.source)) return false;
|
|
8001
|
+
if ("kind" in value && !(typeof value.kind === "string" && isAcceptedShapeKind(value.kind))) return false;
|
|
7782
8002
|
return true;
|
|
7783
8003
|
}
|
|
7784
8004
|
function isElementList(value) {
|
|
@@ -7854,7 +8074,7 @@ var CHECKS = {
|
|
|
7854
8074
|
UNLOCK_ELEMENTS: (c) => isIdList(c.ids),
|
|
7855
8075
|
SET_TEXT_MODE: (c) => TEXT_MODES.has(c.mode) && optionalIdList(c.ids),
|
|
7856
8076
|
ALIGN_ELEMENTS: (c) => isListOf(c.moves, (move) => isId(move.id) && isNumber(move.x) && isNumber(move.y)),
|
|
7857
|
-
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]))
|
|
7858
8078
|
};
|
|
7859
8079
|
new Set(Object.keys(CHECKS));
|
|
7860
8080
|
/**
|
|
@@ -8471,7 +8691,7 @@ function isConnector(el) {
|
|
|
8471
8691
|
/** Polyline the connector is drawn along (curves sampled). */
|
|
8472
8692
|
function polylineOf(el, elements) {
|
|
8473
8693
|
const route = resolveConnectorRoute(el, elements);
|
|
8474
|
-
if (el.type !== "line" || el.cx === void 0 || el.cy === void 0 || route.length !== 2) return route;
|
|
8694
|
+
if (el.type !== "line" || el.routing === "elbow" || el.cx === void 0 || el.cy === void 0 || route.length !== 2) return route;
|
|
8475
8695
|
const [[x1, y1], [x2, y2]] = route;
|
|
8476
8696
|
const { cx, cy } = el;
|
|
8477
8697
|
return Array.from({ length: 13 }, (_, i) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markasso/mcp",
|
|
3
|
-
"version": "0.8.
|
|
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",
|