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