@markdy/core 0.8.25 → 0.8.26

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.
Files changed (2) hide show
  1. package/dist/index.js +69 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3393,7 +3393,12 @@ function diffDiagramASTs(beforeAST, afterAST) {
3393
3393
  if (!beforeEdgeMap.has(key)) {
3394
3394
  edgeDiffs.push({ key, status: "added", after: afterEdge });
3395
3395
  } else {
3396
- edgeDiffs.push({ key, status: "unchanged", before: beforeEdgeMap.get(key), after: afterEdge });
3396
+ const beforeEdge = beforeEdgeMap.get(key);
3397
+ if (beforeEdge.label !== afterEdge.label) {
3398
+ edgeDiffs.push({ key, status: "modified", before: beforeEdge, after: afterEdge });
3399
+ } else {
3400
+ edgeDiffs.push({ key, status: "unchanged", before: beforeEdge, after: afterEdge });
3401
+ }
3397
3402
  }
3398
3403
  }
3399
3404
  for (const [key, beforeEdge] of beforeEdgeMap) {
@@ -3572,16 +3577,72 @@ function routeOrthogonalEdge(sourceBox, targetBox) {
3572
3577
  const start = getBoxPortPosition(sourceBox, sourcePort);
3573
3578
  const end = getBoxPortPosition(targetBox, targetPort);
3574
3579
  const waypoints = [];
3580
+ const MARGIN = 20;
3575
3581
  if (sourcePort === "right" && targetPort === "left") {
3576
- const midX = (start.x + end.x) / 2;
3577
- waypoints.push({ x: midX, y: start.y });
3578
- waypoints.push({ x: midX, y: end.y });
3582
+ if (start.x <= end.x - MARGIN * 2) {
3583
+ const midX = (start.x + end.x) / 2;
3584
+ waypoints.push({ x: midX, y: start.y });
3585
+ waypoints.push({ x: midX, y: end.y });
3586
+ } else {
3587
+ waypoints.push({ x: start.x + MARGIN, y: start.y });
3588
+ const midY = (start.y + end.y) / 2;
3589
+ waypoints.push({ x: start.x + MARGIN, y: midY });
3590
+ waypoints.push({ x: end.x - MARGIN, y: midY });
3591
+ waypoints.push({ x: end.x - MARGIN, y: end.y });
3592
+ }
3593
+ } else if (sourcePort === "left" && targetPort === "right") {
3594
+ if (start.x >= end.x + MARGIN * 2) {
3595
+ const midX = (start.x + end.x) / 2;
3596
+ waypoints.push({ x: midX, y: start.y });
3597
+ waypoints.push({ x: midX, y: end.y });
3598
+ } else {
3599
+ waypoints.push({ x: start.x - MARGIN, y: start.y });
3600
+ const midY = (start.y + end.y) / 2;
3601
+ waypoints.push({ x: start.x - MARGIN, y: midY });
3602
+ waypoints.push({ x: end.x + MARGIN, y: midY });
3603
+ waypoints.push({ x: end.x + MARGIN, y: end.y });
3604
+ }
3579
3605
  } else if (sourcePort === "bottom" && targetPort === "top") {
3580
- const midY = (start.y + end.y) / 2;
3581
- waypoints.push({ x: start.x, y: midY });
3582
- waypoints.push({ x: end.x, y: midY });
3606
+ if (start.y <= end.y - MARGIN * 2) {
3607
+ const midY = (start.y + end.y) / 2;
3608
+ waypoints.push({ x: start.x, y: midY });
3609
+ waypoints.push({ x: end.x, y: midY });
3610
+ } else {
3611
+ waypoints.push({ x: start.x, y: start.y + MARGIN });
3612
+ const midX = (start.x + end.x) / 2;
3613
+ waypoints.push({ x: midX, y: start.y + MARGIN });
3614
+ waypoints.push({ x: midX, y: end.y - MARGIN });
3615
+ waypoints.push({ x: end.x, y: end.y - MARGIN });
3616
+ }
3617
+ } else if (sourcePort === "top" && targetPort === "bottom") {
3618
+ if (start.y >= end.y + MARGIN * 2) {
3619
+ const midY = (start.y + end.y) / 2;
3620
+ waypoints.push({ x: start.x, y: midY });
3621
+ waypoints.push({ x: end.x, y: midY });
3622
+ } else {
3623
+ waypoints.push({ x: start.x, y: start.y - MARGIN });
3624
+ const midX = (start.x + end.x) / 2;
3625
+ waypoints.push({ x: midX, y: start.y - MARGIN });
3626
+ waypoints.push({ x: midX, y: end.y + MARGIN });
3627
+ waypoints.push({ x: end.x, y: end.y + MARGIN });
3628
+ }
3583
3629
  } else {
3584
- waypoints.push({ x: end.x, y: start.y });
3630
+ if (sourcePort === "right") waypoints.push({ x: start.x + MARGIN, y: start.y });
3631
+ else if (sourcePort === "left") waypoints.push({ x: start.x - MARGIN, y: start.y });
3632
+ else if (sourcePort === "top") waypoints.push({ x: start.x, y: start.y - MARGIN });
3633
+ else if (sourcePort === "bottom") waypoints.push({ x: start.x, y: start.y + MARGIN });
3634
+ const p1 = waypoints[0] || start;
3635
+ let p2;
3636
+ if (targetPort === "right") p2 = { x: end.x + MARGIN, y: end.y };
3637
+ else if (targetPort === "left") p2 = { x: end.x - MARGIN, y: end.y };
3638
+ else if (targetPort === "top") p2 = { x: end.x, y: end.y - MARGIN };
3639
+ else p2 = { x: end.x, y: end.y + MARGIN };
3640
+ if (sourcePort === "left" || sourcePort === "right") {
3641
+ waypoints.push({ x: p1.x, y: p2.y });
3642
+ } else {
3643
+ waypoints.push({ x: p2.x, y: p1.y });
3644
+ }
3645
+ waypoints.push(p2);
3585
3646
  }
3586
3647
  let svgPathData = `M ${start.x} ${start.y}`;
3587
3648
  for (const wp of waypoints) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdy/core",
3
- "version": "0.8.25",
3
+ "version": "0.8.26",
4
4
  "description": "Diagram-native MarkdyScript parser and compiler (auto-layout, edge routing, cue scheduling) — zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "type": "module",