@localstack/appinspector-ui 1.0.131 → 1.0.132
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.cjs +51 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31694,39 +31694,70 @@ var ServiceNode = memo12(({ data, selected }) => {
|
|
|
31694
31694
|
// src/components/trace-graph/utils.ts
|
|
31695
31695
|
import dagre from "@dagrejs/dagre";
|
|
31696
31696
|
var getLayoutedNodesAndEdges = (inputNodes, inputEdges) => {
|
|
31697
|
-
const dagreGraph = new dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
|
31698
31697
|
const direction = "LR";
|
|
31699
31698
|
const nodeWidth = 200;
|
|
31700
31699
|
const nodeHeight = 80;
|
|
31701
|
-
|
|
31700
|
+
const nodeIds = new Set(inputNodes.map((n) => n.id));
|
|
31701
|
+
const validEdges = inputEdges.filter((error) => nodeIds.has(error.source) && nodeIds.has(error.target));
|
|
31702
|
+
const buildGraph = () => {
|
|
31703
|
+
const g2 = new dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
|
31704
|
+
g2.setGraph({ rankdir: direction });
|
|
31705
|
+
for (const node of inputNodes) {
|
|
31706
|
+
g2.setNode(node.id, { height: nodeHeight, width: nodeWidth });
|
|
31707
|
+
}
|
|
31708
|
+
for (const edge of validEdges) {
|
|
31709
|
+
g2.setEdge(edge.source, edge.target);
|
|
31710
|
+
}
|
|
31711
|
+
return g2;
|
|
31712
|
+
};
|
|
31713
|
+
const naturalGraph = buildGraph();
|
|
31714
|
+
dagre.layout(naturalGraph);
|
|
31715
|
+
const naturalYMap = new Map(
|
|
31716
|
+
inputNodes.map((n) => [n.id, naturalGraph.node(n.id).y])
|
|
31717
|
+
);
|
|
31702
31718
|
const timestampMap = new Map(
|
|
31703
31719
|
inputNodes.map((n) => [n.id, n.data.event.start_time_unix_nano])
|
|
31704
31720
|
);
|
|
31705
|
-
|
|
31706
|
-
|
|
31707
|
-
|
|
31708
|
-
|
|
31709
|
-
dagreGraph.setEdge(edge.source, edge.target);
|
|
31710
|
-
}
|
|
31721
|
+
const parentMap = new Map(
|
|
31722
|
+
inputNodes.filter((n) => n.data.event.parent_span_id !== null).map((n) => [n.id, n.data.event.parent_span_id])
|
|
31723
|
+
);
|
|
31724
|
+
const dagreGraph = buildGraph();
|
|
31711
31725
|
dagre.layout(dagreGraph, {
|
|
31712
31726
|
customOrder: (g2) => {
|
|
31713
31727
|
const rankMap = /* @__PURE__ */ new Map();
|
|
31714
31728
|
for (const nodeId of g2.nodes()) {
|
|
31715
31729
|
const rank = g2.node(nodeId).rank;
|
|
31716
31730
|
if (rank === void 0) continue;
|
|
31717
|
-
const
|
|
31718
|
-
|
|
31719
|
-
rankMap.set(rank,
|
|
31720
|
-
}
|
|
31721
|
-
for (const
|
|
31722
|
-
|
|
31723
|
-
|
|
31724
|
-
const
|
|
31725
|
-
|
|
31731
|
+
const bucket = rankMap.get(rank) ?? [];
|
|
31732
|
+
bucket.push(nodeId);
|
|
31733
|
+
rankMap.set(rank, bucket);
|
|
31734
|
+
}
|
|
31735
|
+
for (const nodeIds2 of rankMap.values()) {
|
|
31736
|
+
const siblingGroups = /* @__PURE__ */ new Map();
|
|
31737
|
+
for (const nodeId of nodeIds2) {
|
|
31738
|
+
const key = parentMap.get(nodeId) ?? `__root_${nodeId}`;
|
|
31739
|
+
const group3 = siblingGroups.get(key) ?? [];
|
|
31740
|
+
group3.push(nodeId);
|
|
31741
|
+
siblingGroups.set(key, group3);
|
|
31742
|
+
}
|
|
31743
|
+
for (const group3 of siblingGroups.values()) {
|
|
31744
|
+
group3.sort((a3, b3) => {
|
|
31745
|
+
const tsA = timestampMap.get(a3) ?? "";
|
|
31746
|
+
const tsB = timestampMap.get(b3) ?? "";
|
|
31747
|
+
return tsA.localeCompare(tsB);
|
|
31748
|
+
});
|
|
31749
|
+
}
|
|
31750
|
+
const sortedGroups = [...siblingGroups.values()].toSorted((groupA, groupB) => {
|
|
31751
|
+
const minYA = Math.min(...groupA.map((id2) => naturalYMap.get(id2) ?? 0));
|
|
31752
|
+
const minYB = Math.min(...groupB.map((id2) => naturalYMap.get(id2) ?? 0));
|
|
31753
|
+
return minYA - minYB;
|
|
31726
31754
|
});
|
|
31727
|
-
|
|
31728
|
-
|
|
31729
|
-
|
|
31755
|
+
let orderIndex = 0;
|
|
31756
|
+
for (const group3 of sortedGroups) {
|
|
31757
|
+
for (const nodeId of group3) {
|
|
31758
|
+
;
|
|
31759
|
+
g2.node(nodeId).order = orderIndex++;
|
|
31760
|
+
}
|
|
31730
31761
|
}
|
|
31731
31762
|
}
|
|
31732
31763
|
}
|