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/mcp.cjs CHANGED
@@ -15581,21 +15581,29 @@ function renderSequenceAscii(text, config, colorMode, theme) {
15581
15581
  }
15582
15582
  const leftNoteWidth = new Array(diagram.actors.length).fill(0);
15583
15583
  const rightNoteWidth = new Array(diagram.actors.length).fill(0);
15584
- for (const note of diagram.notes) {
15585
- if (note.position !== "left" && note.position !== "right") continue;
15586
- const aIdx = actorIdx.get(note.actorIds[0]) ?? 0;
15584
+ const overNoteHalfLeft = new Array(diagram.actors.length).fill(0);
15585
+ const overNoteHalfRight = new Array(diagram.actors.length).fill(0);
15586
+ for (const note of diagram.notes) if (note.position === "left" || note.position === "right") {
15587
+ const aIdx = actorIndexOf(note.actorIds[0]);
15587
15588
  const w = noteBoxWidth(note);
15588
15589
  if (note.position === "left") leftNoteWidth[aIdx] = Math.max(leftNoteWidth[aIdx], w);
15589
15590
  else rightNoteWidth[aIdx] = Math.max(rightNoteWidth[aIdx], w);
15591
+ } else if (note.position === "over" && note.actorIds.length === 1) {
15592
+ const aIdx = actorIndexOf(note.actorIds[0]);
15593
+ const w = noteBoxWidth(note);
15594
+ const halfLeft = Math.floor(w / 2);
15595
+ const halfRight = w - halfLeft;
15596
+ overNoteHalfLeft[aIdx] = Math.max(overNoteHalfLeft[aIdx], halfLeft);
15597
+ overNoteHalfRight[aIdx] = Math.max(overNoteHalfRight[aIdx], halfRight);
15590
15598
  }
15591
15599
  const minLifelineGap = paddingOffset(config.paddingX, 5, 10, 4);
15592
- const llX = [Math.max(halfBox[0] + (boxSpanOf[0] === -1 ? 0 : 2), leftNoteWidth[0] + 1)];
15600
+ const llX = [Math.max(halfBox[0] + (boxSpanOf[0] === -1 ? 0 : 2), leftNoteWidth[0] + 1, overNoteHalfLeft[0])];
15593
15601
  for (let i = 1; i < diagram.actors.length; i++) {
15594
15602
  const prevSpan = boxSpanOf[i - 1];
15595
15603
  const thisSpan = boxSpanOf[i];
15596
15604
  const walls = prevSpan === thisSpan ? 0 : (prevSpan === -1 ? 0 : 1) + (thisSpan === -1 ? 0 : 1);
15597
15605
  const wallExtra = walls === 0 ? 0 : walls * 2 - 1;
15598
- const noteGapNeed = Math.max(rightNoteWidth[i - 1], leftNoteWidth[i]) + 2;
15606
+ const noteGapNeed = Math.max(rightNoteWidth[i - 1], leftNoteWidth[i], overNoteHalfRight[i - 1], overNoteHalfLeft[i]) + 2;
15599
15607
  const gap = Math.max(halfBox[i - 1] + halfBox[i] + 2 + wallExtra, adjMaxWidth[i - 1] + 2, noteGapNeed, minLifelineGap);
15600
15608
  llX[i] = llX[i - 1] + gap;
15601
15609
  }
@@ -16400,27 +16408,90 @@ function renderClassAscii(text, config, colorMode, theme, options = {}) {
16400
16408
  for (let lv = 0; lv <= maxLevel; lv++) {
16401
16409
  const group = levelGroups[lv];
16402
16410
  if (group.length === 0) continue;
16411
+ const blockKeyOf = (id) => {
16412
+ const pset = parents.get(id);
16413
+ return pset && pset.size > 0 ? [...pset].sort().join(",") : `root:${id}`;
16414
+ };
16415
+ const blockMembers = /* @__PURE__ */ new Map();
16416
+ for (const id of group) {
16417
+ const key = blockKeyOf(id);
16418
+ let members = blockMembers.get(key);
16419
+ if (!members) {
16420
+ members = [];
16421
+ blockMembers.set(key, members);
16422
+ }
16423
+ members.push(id);
16424
+ }
16425
+ const baselineSlotLeft = /* @__PURE__ */ new Map();
16426
+ const slotWidthOf = /* @__PURE__ */ new Map();
16427
+ const leftPadOf = /* @__PURE__ */ new Map();
16428
+ {
16429
+ let x = 0;
16430
+ for (const id of group) {
16431
+ const w = classBoxW.get(id);
16432
+ const reach = columnReach.get(id);
16433
+ const leftPad = Math.max(0, reach.left - Math.floor(w / 2));
16434
+ const rightPad = Math.max(0, reach.right - (w - 1 - Math.floor(w / 2)));
16435
+ baselineSlotLeft.set(id, x);
16436
+ slotWidthOf.set(id, leftPad + w + rightPad);
16437
+ leftPadOf.set(id, leftPad);
16438
+ x += leftPad + w + rightPad + hGap;
16439
+ }
16440
+ }
16403
16441
  let currentX = 0;
16404
16442
  let maxH = 0;
16405
- for (const id of group) {
16443
+ /** Places one class's box at slot-left `slotLeft`, advancing `currentX`/`maxH`/`maxSlotEnd`. */
16444
+ const placeAt = (id, slotLeft) => {
16406
16445
  const cls = classById.get(id);
16407
16446
  const w = classBoxW.get(id);
16408
16447
  const h = classBoxH.get(id);
16409
- const reach = columnReach.get(id);
16410
- const leftPad = Math.max(0, reach.left - Math.floor(w / 2));
16411
- const rightPad = Math.max(0, reach.right - (w - 1 - Math.floor(w / 2)));
16448
+ const leftPad = leftPadOf.get(id);
16449
+ const slotWidth = slotWidthOf.get(id);
16412
16450
  placed.set(id, {
16413
16451
  cls,
16414
16452
  sections: classSections.get(id),
16415
- x: currentX + leftPad,
16453
+ x: slotLeft + leftPad,
16416
16454
  y: currentY,
16417
16455
  width: w,
16418
16456
  height: h
16419
16457
  });
16420
- const slotWidth = leftPad + w + rightPad;
16421
- maxSlotEnd = Math.max(maxSlotEnd, currentX + slotWidth);
16422
- currentX += slotWidth + hGap;
16458
+ maxSlotEnd = Math.max(maxSlotEnd, slotLeft + slotWidth);
16459
+ currentX = slotLeft + slotWidth + hGap;
16423
16460
  maxH = Math.max(maxH, h);
16461
+ };
16462
+ const placedThisLevel = /* @__PURE__ */ new Set();
16463
+ for (const id of group) {
16464
+ if (placedThisLevel.has(id)) continue;
16465
+ const key = blockKeyOf(id);
16466
+ const pset = parents.get(id);
16467
+ const qualifying = pset ? [...pset].filter((pid) => level.get(pid) < lv) : [];
16468
+ if (qualifying.length === 0) {
16469
+ placeAt(id, Math.max(baselineSlotLeft.get(id), currentX, 0));
16470
+ placedThisLevel.add(id);
16471
+ continue;
16472
+ }
16473
+ const members = blockMembers.get(key);
16474
+ const parentCenters = qualifying.map((pid) => {
16475
+ const p = placed.get(pid);
16476
+ return p.x + Math.floor(p.width / 2);
16477
+ });
16478
+ const desiredCenter = Math.round(parentCenters.reduce((sum, c) => sum + c, 0) / parentCenters.length);
16479
+ let totalWidth = 0;
16480
+ for (let i = 0; i < members.length; i++) {
16481
+ totalWidth += slotWidthOf.get(members[i]);
16482
+ if (i < members.length - 1) totalWidth += hGap;
16483
+ }
16484
+ const firstLeftPad = leftPadOf.get(members[0]);
16485
+ const lastMember = members[members.length - 1];
16486
+ const lastRightPad = slotWidthOf.get(lastMember) - leftPadOf.get(lastMember) - classBoxW.get(lastMember);
16487
+ const visibleWidth = totalWidth - firstLeftPad - lastRightPad;
16488
+ const blockDesiredLeft = desiredCenter - firstLeftPad - Math.floor(visibleWidth / 2);
16489
+ let memberX = Math.max(blockDesiredLeft, currentX, 0);
16490
+ for (const memberId of members) {
16491
+ placeAt(memberId, memberX);
16492
+ placedThisLevel.add(memberId);
16493
+ memberX = currentX;
16494
+ }
16424
16495
  }
16425
16496
  currentY += maxH + vGap;
16426
16497
  }