@eventcatalog/visualiser 5.0.0-beta.9 → 5.0.1

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.
@@ -13,7 +13,7 @@ import {
13
13
  isCarrier,
14
14
  isMessageNode,
15
15
  layoutWithElk
16
- } from "./chunk-Z3G354GF.mjs";
16
+ } from "./chunk-NOHQEQD7.mjs";
17
17
 
18
18
  // src/components/NodeGraph.tsx
19
19
  import {
@@ -7663,6 +7663,16 @@ var ROUTE_TOLERANCE = { x: 60, y: 400 };
7663
7663
  var isStraight = (a, b) => a.x === b.x || a.y === b.y;
7664
7664
  var add = (a, b) => ({ x: a.x + b.x, y: a.y + b.y });
7665
7665
  var NOT_MOVED = { x: 0, y: 0 };
7666
+ var END_INSET = 8;
7667
+ var alongSide = (end, node, height) => {
7668
+ if (!node?.height || !height) return end;
7669
+ const fromMiddle = end.y - (node.y + node.height / 2);
7670
+ const furthest = Math.max(height / 2 - END_INSET, 0);
7671
+ return {
7672
+ x: end.x,
7673
+ y: node.y + height / 2 + Math.min(Math.max(fromMiddle, -furthest), furthest)
7674
+ };
7675
+ };
7666
7676
  var getRoutePath = (route, source, target, {
7667
7677
  // Ends at a specific handle (e.g. a service listed in a domain) go exactly
7668
7678
  // to it, rather than where the layout spread them along the node's side
@@ -7670,13 +7680,22 @@ var getRoutePath = (route, source, target, {
7670
7680
  toTargetHandle = false,
7671
7681
  // How far the source and target have moved since they were laid out
7672
7682
  sourceMoved = NOT_MOVED,
7673
- targetMoved = NOT_MOVED
7683
+ targetMoved = NOT_MOVED,
7684
+ // How tall the source and target render
7685
+ sourceHeight,
7686
+ targetHeight
7674
7687
  } = {}) => {
7675
7688
  const { points } = route;
7676
7689
  if (points.length < 2) return void 0;
7677
7690
  const last = points.length - 1;
7678
- const start = add(points[0], sourceMoved);
7679
- const end = add(points[last], targetMoved);
7691
+ const start = add(
7692
+ alongSide(points[0], route.source, sourceHeight),
7693
+ sourceMoved
7694
+ );
7695
+ const end = add(
7696
+ alongSide(points[last], route.target, targetHeight),
7697
+ targetMoved
7698
+ );
7680
7699
  const fits = (a, b) => Math.abs(a.x - b.x) <= ROUTE_TOLERANCE.x && Math.abs(a.y - b.y) <= ROUTE_TOLERANCE.y;
7681
7700
  if (!fits(start, source) || !fits(end, target)) return void 0;
7682
7701
  const movedTogether = Math.abs(sourceMoved.x - targetMoved.x) < 1 && Math.abs(sourceMoved.y - targetMoved.y) < 1;
@@ -7737,7 +7756,7 @@ var getMoved = (state, nodeId, at) => {
7737
7756
  return position && { x: position.x - at.x, y: position.y - at.y };
7738
7757
  };
7739
7758
  var isSamePoint = (a, b) => a.x === b.x && a.y === b.y;
7740
- var isSameEdgeState = (a, b) => a.zIndex === b.zIndex && (a.moved === b.moved || !!a.moved && !!b.moved && isSamePoint(a.moved[0], b.moved[0]) && isSamePoint(a.moved[1], b.moved[1]));
7759
+ var isSameEdgeState = (a, b) => a.zIndex === b.zIndex && a.heights?.[0] === b.heights?.[0] && a.heights?.[1] === b.heights?.[1] && (a.moved === b.moved || !!a.moved && !!b.moved && isSamePoint(a.moved[0], b.moved[0]) && isSamePoint(a.moved[1], b.moved[1]));
7741
7760
  var useRoute = ({
7742
7761
  data,
7743
7762
  source,
@@ -7750,7 +7769,7 @@ var useRoute = ({
7750
7769
  targetHandleId
7751
7770
  }, [path, labelX, labelY]) => {
7752
7771
  const route = data?.route;
7753
- const { moved, zIndex } = useStore3(
7772
+ const { moved, heights, zIndex } = useStore3(
7754
7773
  useCallback6(
7755
7774
  (state) => {
7756
7775
  const z = (nodeId) => {
@@ -7761,9 +7780,11 @@ var useRoute = ({
7761
7780
  if (!route?.source || !route.target) return { zIndex: zIndex2 };
7762
7781
  const sourceMoved = getMoved(state, source, route.source);
7763
7782
  const targetMoved = getMoved(state, target, route.target);
7783
+ const height = (nodeId) => state.nodeLookup.get(nodeId)?.measured.height;
7764
7784
  return {
7765
7785
  zIndex: zIndex2,
7766
- moved: sourceMoved && targetMoved ? [sourceMoved, targetMoved] : void 0
7786
+ moved: sourceMoved && targetMoved ? [sourceMoved, targetMoved] : void 0,
7787
+ heights: [height(source), height(target)]
7767
7788
  };
7768
7789
  },
7769
7790
  [route, source, target]
@@ -7778,7 +7799,9 @@ var useRoute = ({
7778
7799
  toSourceHandle: !!sourceHandleId,
7779
7800
  toTargetHandle: !!targetHandleId,
7780
7801
  sourceMoved: moved[0],
7781
- targetMoved: moved[1]
7802
+ targetMoved: moved[1],
7803
+ sourceHeight: heights?.[0],
7804
+ targetHeight: heights?.[1]
7782
7805
  }
7783
7806
  );
7784
7807
  if (!routed) return [path, labelX, labelY, zIndex];
@@ -13449,7 +13472,14 @@ var toSnapshot = (nodes, edges, place) => {
13449
13472
  source: edge.source,
13450
13473
  target: edge.target,
13451
13474
  ...typeof edge.label === "string" && { label: edge.label },
13452
- ...route && { route: { points: route.points, label: route.label } }
13475
+ ...route && {
13476
+ route: {
13477
+ points: route.points,
13478
+ label: route.label,
13479
+ sourceHeight: route.source?.height,
13480
+ targetHeight: route.target?.height
13481
+ }
13482
+ }
13453
13483
  };
13454
13484
  })
13455
13485
  };
@@ -15706,4 +15736,4 @@ export {
15706
15736
  edgeTypes,
15707
15737
  exportNodeGraphForStudio
15708
15738
  };
15709
- //# sourceMappingURL=chunk-6OORHWMU.mjs.map
15739
+ //# sourceMappingURL=chunk-KVTGV7VK.mjs.map