zombie-mermaid 2.2.2 → 2.2.3
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/ascii.cjs +7 -7
- package/dist/ascii.cjs.map +1 -1
- package/dist/ascii.js +943 -913
- package/dist/ascii.js.map +1 -1
- package/dist/cli.js +3265 -3229
- package/dist/index.cjs +51 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +191 -161
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +84 -13
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.js +84 -13
- package/dist/mcp.js.map +1 -1
- package/package.json +3 -3
- package/packages/ascii-renderer/src/class-diagram.ts +192 -12
- package/packages/ascii-renderer/src/sequence.ts +42 -8
- package/src/__tests__/ascii-class-box-occupancy.test.ts +82 -43
- package/src/__tests__/ascii-class-detour-label-routing-487.test.ts +8 -8
- package/src/__tests__/ascii-class-parent-alignment-971.test.ts +139 -0
- package/src/__tests__/ascii-class-parent-alignment-972.test.ts +208 -0
- package/src/__tests__/ascii-sequence-form-invariants.test.ts +51 -0
package/dist/mcp.js
CHANGED
|
@@ -15556,21 +15556,29 @@ function renderSequenceAscii(text, config, colorMode, theme) {
|
|
|
15556
15556
|
}
|
|
15557
15557
|
const leftNoteWidth = new Array(diagram.actors.length).fill(0);
|
|
15558
15558
|
const rightNoteWidth = new Array(diagram.actors.length).fill(0);
|
|
15559
|
-
|
|
15560
|
-
|
|
15561
|
-
|
|
15559
|
+
const overNoteHalfLeft = new Array(diagram.actors.length).fill(0);
|
|
15560
|
+
const overNoteHalfRight = new Array(diagram.actors.length).fill(0);
|
|
15561
|
+
for (const note of diagram.notes) if (note.position === "left" || note.position === "right") {
|
|
15562
|
+
const aIdx = actorIndexOf(note.actorIds[0]);
|
|
15562
15563
|
const w = noteBoxWidth(note);
|
|
15563
15564
|
if (note.position === "left") leftNoteWidth[aIdx] = Math.max(leftNoteWidth[aIdx], w);
|
|
15564
15565
|
else rightNoteWidth[aIdx] = Math.max(rightNoteWidth[aIdx], w);
|
|
15566
|
+
} else if (note.position === "over" && note.actorIds.length === 1) {
|
|
15567
|
+
const aIdx = actorIndexOf(note.actorIds[0]);
|
|
15568
|
+
const w = noteBoxWidth(note);
|
|
15569
|
+
const halfLeft = Math.floor(w / 2);
|
|
15570
|
+
const halfRight = w - halfLeft;
|
|
15571
|
+
overNoteHalfLeft[aIdx] = Math.max(overNoteHalfLeft[aIdx], halfLeft);
|
|
15572
|
+
overNoteHalfRight[aIdx] = Math.max(overNoteHalfRight[aIdx], halfRight);
|
|
15565
15573
|
}
|
|
15566
15574
|
const minLifelineGap = paddingOffset(config.paddingX, 5, 10, 4);
|
|
15567
|
-
const llX = [Math.max(halfBox[0] + (boxSpanOf[0] === -1 ? 0 : 2), leftNoteWidth[0] + 1)];
|
|
15575
|
+
const llX = [Math.max(halfBox[0] + (boxSpanOf[0] === -1 ? 0 : 2), leftNoteWidth[0] + 1, overNoteHalfLeft[0])];
|
|
15568
15576
|
for (let i = 1; i < diagram.actors.length; i++) {
|
|
15569
15577
|
const prevSpan = boxSpanOf[i - 1];
|
|
15570
15578
|
const thisSpan = boxSpanOf[i];
|
|
15571
15579
|
const walls = prevSpan === thisSpan ? 0 : (prevSpan === -1 ? 0 : 1) + (thisSpan === -1 ? 0 : 1);
|
|
15572
15580
|
const wallExtra = walls === 0 ? 0 : walls * 2 - 1;
|
|
15573
|
-
const noteGapNeed = Math.max(rightNoteWidth[i - 1], leftNoteWidth[i]) + 2;
|
|
15581
|
+
const noteGapNeed = Math.max(rightNoteWidth[i - 1], leftNoteWidth[i], overNoteHalfRight[i - 1], overNoteHalfLeft[i]) + 2;
|
|
15574
15582
|
const gap = Math.max(halfBox[i - 1] + halfBox[i] + 2 + wallExtra, adjMaxWidth[i - 1] + 2, noteGapNeed, minLifelineGap);
|
|
15575
15583
|
llX[i] = llX[i - 1] + gap;
|
|
15576
15584
|
}
|
|
@@ -16375,27 +16383,90 @@ function renderClassAscii(text, config, colorMode, theme, options = {}) {
|
|
|
16375
16383
|
for (let lv = 0; lv <= maxLevel; lv++) {
|
|
16376
16384
|
const group = levelGroups[lv];
|
|
16377
16385
|
if (group.length === 0) continue;
|
|
16386
|
+
const blockKeyOf = (id) => {
|
|
16387
|
+
const pset = parents.get(id);
|
|
16388
|
+
return pset && pset.size > 0 ? [...pset].sort().join(",") : `root:${id}`;
|
|
16389
|
+
};
|
|
16390
|
+
const blockMembers = /* @__PURE__ */ new Map();
|
|
16391
|
+
for (const id of group) {
|
|
16392
|
+
const key = blockKeyOf(id);
|
|
16393
|
+
let members = blockMembers.get(key);
|
|
16394
|
+
if (!members) {
|
|
16395
|
+
members = [];
|
|
16396
|
+
blockMembers.set(key, members);
|
|
16397
|
+
}
|
|
16398
|
+
members.push(id);
|
|
16399
|
+
}
|
|
16400
|
+
const baselineSlotLeft = /* @__PURE__ */ new Map();
|
|
16401
|
+
const slotWidthOf = /* @__PURE__ */ new Map();
|
|
16402
|
+
const leftPadOf = /* @__PURE__ */ new Map();
|
|
16403
|
+
{
|
|
16404
|
+
let x = 0;
|
|
16405
|
+
for (const id of group) {
|
|
16406
|
+
const w = classBoxW.get(id);
|
|
16407
|
+
const reach = columnReach.get(id);
|
|
16408
|
+
const leftPad = Math.max(0, reach.left - Math.floor(w / 2));
|
|
16409
|
+
const rightPad = Math.max(0, reach.right - (w - 1 - Math.floor(w / 2)));
|
|
16410
|
+
baselineSlotLeft.set(id, x);
|
|
16411
|
+
slotWidthOf.set(id, leftPad + w + rightPad);
|
|
16412
|
+
leftPadOf.set(id, leftPad);
|
|
16413
|
+
x += leftPad + w + rightPad + hGap;
|
|
16414
|
+
}
|
|
16415
|
+
}
|
|
16378
16416
|
let currentX = 0;
|
|
16379
16417
|
let maxH = 0;
|
|
16380
|
-
|
|
16418
|
+
/** Places one class's box at slot-left `slotLeft`, advancing `currentX`/`maxH`/`maxSlotEnd`. */
|
|
16419
|
+
const placeAt = (id, slotLeft) => {
|
|
16381
16420
|
const cls = classById.get(id);
|
|
16382
16421
|
const w = classBoxW.get(id);
|
|
16383
16422
|
const h = classBoxH.get(id);
|
|
16384
|
-
const
|
|
16385
|
-
const
|
|
16386
|
-
const rightPad = Math.max(0, reach.right - (w - 1 - Math.floor(w / 2)));
|
|
16423
|
+
const leftPad = leftPadOf.get(id);
|
|
16424
|
+
const slotWidth = slotWidthOf.get(id);
|
|
16387
16425
|
placed.set(id, {
|
|
16388
16426
|
cls,
|
|
16389
16427
|
sections: classSections.get(id),
|
|
16390
|
-
x:
|
|
16428
|
+
x: slotLeft + leftPad,
|
|
16391
16429
|
y: currentY,
|
|
16392
16430
|
width: w,
|
|
16393
16431
|
height: h
|
|
16394
16432
|
});
|
|
16395
|
-
|
|
16396
|
-
|
|
16397
|
-
currentX += slotWidth + hGap;
|
|
16433
|
+
maxSlotEnd = Math.max(maxSlotEnd, slotLeft + slotWidth);
|
|
16434
|
+
currentX = slotLeft + slotWidth + hGap;
|
|
16398
16435
|
maxH = Math.max(maxH, h);
|
|
16436
|
+
};
|
|
16437
|
+
const placedThisLevel = /* @__PURE__ */ new Set();
|
|
16438
|
+
for (const id of group) {
|
|
16439
|
+
if (placedThisLevel.has(id)) continue;
|
|
16440
|
+
const key = blockKeyOf(id);
|
|
16441
|
+
const pset = parents.get(id);
|
|
16442
|
+
const qualifying = pset ? [...pset].filter((pid) => level.get(pid) < lv) : [];
|
|
16443
|
+
if (qualifying.length === 0) {
|
|
16444
|
+
placeAt(id, Math.max(baselineSlotLeft.get(id), currentX, 0));
|
|
16445
|
+
placedThisLevel.add(id);
|
|
16446
|
+
continue;
|
|
16447
|
+
}
|
|
16448
|
+
const members = blockMembers.get(key);
|
|
16449
|
+
const parentCenters = qualifying.map((pid) => {
|
|
16450
|
+
const p = placed.get(pid);
|
|
16451
|
+
return p.x + Math.floor(p.width / 2);
|
|
16452
|
+
});
|
|
16453
|
+
const desiredCenter = Math.round(parentCenters.reduce((sum, c) => sum + c, 0) / parentCenters.length);
|
|
16454
|
+
let totalWidth = 0;
|
|
16455
|
+
for (let i = 0; i < members.length; i++) {
|
|
16456
|
+
totalWidth += slotWidthOf.get(members[i]);
|
|
16457
|
+
if (i < members.length - 1) totalWidth += hGap;
|
|
16458
|
+
}
|
|
16459
|
+
const firstLeftPad = leftPadOf.get(members[0]);
|
|
16460
|
+
const lastMember = members[members.length - 1];
|
|
16461
|
+
const lastRightPad = slotWidthOf.get(lastMember) - leftPadOf.get(lastMember) - classBoxW.get(lastMember);
|
|
16462
|
+
const visibleWidth = totalWidth - firstLeftPad - lastRightPad;
|
|
16463
|
+
const blockDesiredLeft = desiredCenter - firstLeftPad - Math.floor(visibleWidth / 2);
|
|
16464
|
+
let memberX = Math.max(blockDesiredLeft, currentX, 0);
|
|
16465
|
+
for (const memberId of members) {
|
|
16466
|
+
placeAt(memberId, memberX);
|
|
16467
|
+
placedThisLevel.add(memberId);
|
|
16468
|
+
memberX = currentX;
|
|
16469
|
+
}
|
|
16399
16470
|
}
|
|
16400
16471
|
currentY += maxH + vGap;
|
|
16401
16472
|
}
|