@eventcatalog/visualiser 4.1.3 → 4.1.4

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/index.mjs CHANGED
@@ -9538,6 +9538,26 @@ var createDagreGraph = ({
9538
9538
  graph.setDefaultEdgeLabel(() => ({}));
9539
9539
  return graph;
9540
9540
  };
9541
+ var LARGE_GRAPH_NODE_THRESHOLD = 80;
9542
+ var LARGE_GRAPH_EDGE_THRESHOLD = 200;
9543
+ var LARGE_GRAPH_RANKER = "tight-tree";
9544
+ var selectDagreRanker = (nodeCount, edgeCount, explicitRanker) => {
9545
+ if (explicitRanker) return explicitRanker;
9546
+ if (nodeCount >= LARGE_GRAPH_NODE_THRESHOLD || edgeCount >= LARGE_GRAPH_EDGE_THRESHOLD) {
9547
+ return LARGE_GRAPH_RANKER;
9548
+ }
9549
+ return void 0;
9550
+ };
9551
+ var layoutDagreGraph = (flow) => {
9552
+ const label = flow.graph() || {};
9553
+ const nodeCount = flow.nodeCount();
9554
+ const edgeCount = flow.edgeCount();
9555
+ const ranker = selectDagreRanker(nodeCount, edgeCount, label.ranker);
9556
+ if (ranker && label.ranker !== ranker) {
9557
+ flow.setGraph({ ...label, ranker });
9558
+ }
9559
+ dagre.layout(flow);
9560
+ };
9541
9561
  var createEdge = (edgeOptions) => {
9542
9562
  return {
9543
9563
  label: "subscribed by",
@@ -9580,7 +9600,7 @@ var getNodesAndEdgesFromDagre = ({
9580
9600
  edges.forEach((edge) => {
9581
9601
  flow.setEdge(edge.source, edge.target);
9582
9602
  });
9583
- dagre.layout(flow);
9603
+ layoutDagreGraph(flow);
9584
9604
  return {
9585
9605
  nodes: calculatedNodes(flow, nodes),
9586
9606
  edges
@@ -11581,7 +11601,7 @@ function AllNotesModal({
11581
11601
  import dagre3 from "dagre";
11582
11602
  import { Fragment as Fragment15, jsx as jsx52, jsxs as jsxs49 } from "react/jsx-runtime";
11583
11603
  var POSITION_CHANGE_THRESHOLD = 1;
11584
- var LARGE_GRAPH_NODE_THRESHOLD = 30;
11604
+ var LARGE_GRAPH_NODE_THRESHOLD2 = 30;
11585
11605
  var NODE_ORIGIN = [0.1, 0.1];
11586
11606
  var INITIAL_FIT_VIEW_OPTIONS = { padding: 0.2, duration: 0 };
11587
11607
  var MINIMAP_STYLE = {
@@ -12020,7 +12040,7 @@ var NodeGraphBuilder = ({
12020
12040
  g.setEdge(sourceTop, targetTop);
12021
12041
  }
12022
12042
  });
12023
- dagre3.layout(g);
12043
+ layoutDagreGraph(g);
12024
12044
  const positioned = nextNodes.map((node) => {
12025
12045
  if (node.parentId) {
12026
12046
  const parent = nextNodes.find((n) => n.id === node.parentId);
@@ -12111,7 +12131,7 @@ var NodeGraphBuilder = ({
12111
12131
  g.setEdge(e.source, e.target);
12112
12132
  }
12113
12133
  });
12114
- dagre3.layout(g);
12134
+ layoutDagreGraph(g);
12115
12135
  let minX = Infinity;
12116
12136
  let minY = Infinity;
12117
12137
  let maxX = -Infinity;
@@ -12730,7 +12750,7 @@ var NodeGraphBuilder = ({
12730
12750
  if (storedAnimateMessages !== null) {
12731
12751
  setAnimateMessages(storedAnimateMessages === "true");
12732
12752
  } else {
12733
- setAnimateMessages(initialNodes.length <= LARGE_GRAPH_NODE_THRESHOLD);
12753
+ setAnimateMessages(initialNodes.length <= LARGE_GRAPH_NODE_THRESHOLD2);
12734
12754
  }
12735
12755
  }
12736
12756
  }, [animated, disableMessageAnimation, initialNodes.length]);
@@ -13727,6 +13747,9 @@ export {
13727
13747
  Flow_default as FlowNode,
13728
13748
  FocusModeModal_default as FocusModeModal,
13729
13749
  GroupNode_default as GroupNode,
13750
+ LARGE_GRAPH_EDGE_THRESHOLD,
13751
+ LARGE_GRAPH_NODE_THRESHOLD,
13752
+ LARGE_GRAPH_RANKER,
13730
13753
  LabelledDefaultEdge,
13731
13754
  LabelledSmoothStepEdge,
13732
13755
  LabelledStepEdge,
@@ -13774,9 +13797,11 @@ export {
13774
13797
  getNestedEntityProperties,
13775
13798
  getNodesAndEdgesFromDagre,
13776
13799
  getPropertyTypeLabel,
13800
+ layoutDagreGraph,
13777
13801
  layoutGraph,
13778
13802
  nodeComponents,
13779
13803
  nodeConfigs,
13780
- normalizeOwners
13804
+ normalizeOwners,
13805
+ selectDagreRanker
13781
13806
  };
13782
13807
  //# sourceMappingURL=index.mjs.map