@diagrammo/dgmo 0.46.0 → 0.47.0
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/advanced.d.cts +3 -855
- package/dist/advanced.d.ts +3 -855
- package/dist/advanced.js +541 -70107
- package/dist/analyzer-UYKBXAKR.js +15 -0
- package/dist/auto.cjs +1 -1
- package/dist/auto.js +1 -1
- package/dist/auto.mjs +1 -1
- package/dist/block.js +83 -69417
- package/dist/calculator-LDYQCDDY.js +11 -0
- package/dist/charts-d3-QOZHKTCT.js +25 -0
- package/dist/chunk-2DXMZRWJ.js +800 -0
- package/dist/chunk-2LACINWN.js +786 -0
- package/dist/chunk-33LCUH4H.js +893 -0
- package/dist/chunk-3CIOJ5YJ.js +35 -0
- package/dist/chunk-3HDBAXF5.js +86 -0
- package/dist/chunk-3JLKYGBQ.js +290 -0
- package/dist/chunk-3MQQNXPD.js +415 -0
- package/dist/chunk-3R5POCTZ.js +967 -0
- package/dist/chunk-3SMGIJDD.js +112 -0
- package/dist/chunk-44CM72SQ.js +409 -0
- package/dist/chunk-4GRI7MEB.js +1604 -0
- package/dist/chunk-4OHACBGX.js +606 -0
- package/dist/chunk-5DH3KYFH.js +21 -0
- package/dist/chunk-5MLYVTYM.js +76 -0
- package/dist/chunk-5QXL4NYS.js +553 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-6EK55ART.js +117 -0
- package/dist/chunk-6FZYCKXB.js +2065 -0
- package/dist/chunk-6HO5ZTXK.js +277 -0
- package/dist/chunk-6KFWC4CO.js +7 -0
- package/dist/chunk-6MTWIQVO.js +121 -0
- package/dist/chunk-6NYWYNBI.js +329 -0
- package/dist/chunk-6SM5NJQH.js +620 -0
- package/dist/chunk-725LDASD.js +422 -0
- package/dist/chunk-76OWZ3BA.js +130 -0
- package/dist/chunk-7JEGTRLD.js +338 -0
- package/dist/chunk-A44USUV7.js +923 -0
- package/dist/chunk-A4GOY3PE.js +25 -0
- package/dist/chunk-A4VFQH5G.js +251 -0
- package/dist/chunk-AELOBFW5.js +375 -0
- package/dist/chunk-AN2MOO5T.js +522 -0
- package/dist/chunk-BMR4CIEO.js +41 -0
- package/dist/chunk-BS7SV7C3.js +51 -0
- package/dist/chunk-BUPDIHML.js +613 -0
- package/dist/chunk-BUVJFRPY.js +887 -0
- package/dist/chunk-C3Z4DX3V.js +112 -0
- package/dist/chunk-CI2G3OEB.js +1818 -0
- package/dist/chunk-CKNVO24D.js +54 -0
- package/dist/chunk-CUVHQHZ7.js +391 -0
- package/dist/chunk-CXK4DZH3.js +114 -0
- package/dist/chunk-DKEPS5LH.js +315 -0
- package/dist/chunk-DU7W62N5.js +487 -0
- package/dist/chunk-DZAQBW35.js +751 -0
- package/dist/chunk-EB6FPQUP.js +316 -0
- package/dist/chunk-EMS2SK26.js +376 -0
- package/dist/chunk-ERLBPDGU.js +510 -0
- package/dist/chunk-EVCVDTXE.js +732 -0
- package/dist/chunk-FCIIHT24.js +384 -0
- package/dist/chunk-FFUN5D66.js +97 -0
- package/dist/chunk-FITOLXSX.js +714 -0
- package/dist/chunk-FMDSF3OV.js +68 -0
- package/dist/chunk-FNB3PNGF.js +410 -0
- package/dist/chunk-G2H74XJZ.js +2104 -0
- package/dist/chunk-GMR5MFHJ.js +339 -0
- package/dist/chunk-H6PI3KJT.js +305 -0
- package/dist/chunk-I46X5VUA.js +59 -0
- package/dist/chunk-I5IGB56C.js +255 -0
- package/dist/chunk-IH6ZMVQ5.js +3950 -0
- package/dist/chunk-IJZFN3HM.js +463 -0
- package/dist/chunk-IPWPWM6R.js +3079 -0
- package/dist/chunk-IYULMRBE.js +23 -0
- package/dist/chunk-IZMRON6C.js +167 -0
- package/dist/chunk-J5FIXQRT.js +813 -0
- package/dist/chunk-JED6ZDEE.js +73 -0
- package/dist/chunk-JEUJOX5X.js +136 -0
- package/dist/chunk-JM4LEPY3.js +436 -0
- package/dist/chunk-L3UHP6TD.js +101 -0
- package/dist/chunk-L66GEFB6.js +524 -0
- package/dist/chunk-LIOHW36Z.js +469 -0
- package/dist/chunk-LP7EC4MI.js +16 -0
- package/dist/chunk-MITI6NOL.js +548 -0
- package/dist/chunk-MO5YHHMQ.js +168 -0
- package/dist/chunk-MZSBFAPJ.js +885 -0
- package/dist/chunk-NNAAJVBU.js +9 -0
- package/dist/chunk-NOTA6TEI.js +47 -0
- package/dist/chunk-NURGB5Z4.js +335 -0
- package/dist/chunk-NX4EQS3U.js +1062 -0
- package/dist/chunk-NXMESY4J.js +1 -0
- package/dist/chunk-OJR3MQYV.js +1458 -0
- package/dist/chunk-OURHMODR.js +454 -0
- package/dist/chunk-P235SVAH.js +1057 -0
- package/dist/chunk-P4RH4OSP.js +1038 -0
- package/dist/chunk-P6T66CCZ.js +226 -0
- package/dist/chunk-PBAHEPLQ.js +223 -0
- package/dist/chunk-PBHE5UG6.js +1530 -0
- package/dist/chunk-PDKUANDZ.js +35 -0
- package/dist/chunk-PWIHZ6NJ.js +296 -0
- package/dist/chunk-QEBUY5NY.js +1685 -0
- package/dist/chunk-QLCCJEJI.js +253 -0
- package/dist/chunk-QOOUC2J5.js +52 -0
- package/dist/chunk-QYTPPDAO.js +402 -0
- package/dist/chunk-R3XI2VC7.js +801 -0
- package/dist/chunk-RCERWOJR.js +154 -0
- package/dist/chunk-RJE5JTVK.js +362 -0
- package/dist/chunk-RTLBSQ3G.js +1155 -0
- package/dist/chunk-RUNNI6VE.js +448 -0
- package/dist/chunk-RVMRZAPB.js +354 -0
- package/dist/chunk-RYEGFMUO.js +955 -0
- package/dist/chunk-RZCF2VVM.js +528 -0
- package/dist/chunk-SML67VPV.js +1025 -0
- package/dist/chunk-SQ7IY53Q.js +44 -0
- package/dist/chunk-SQAG3UXH.js +161 -0
- package/dist/chunk-SRTU6HMQ.js +1851 -0
- package/dist/chunk-T2OE3YQB.js +550 -0
- package/dist/chunk-T3UBLACL.js +299 -0
- package/dist/chunk-TLVIHFRO.js +296 -0
- package/dist/chunk-TYS6CSS5.js +52 -0
- package/dist/chunk-U6EQI3U6.js +130 -0
- package/dist/chunk-UJ4FJLBF.js +86 -0
- package/dist/chunk-ULOEATBZ.js +347 -0
- package/dist/chunk-UNCCZ3NU.js +127 -0
- package/dist/chunk-USZW2HHU.js +197 -0
- package/dist/chunk-UWN33VNX.js +1610 -0
- package/dist/chunk-UZ7EZW3B.js +40 -0
- package/dist/chunk-VOKGH627.js +37 -0
- package/dist/chunk-WBRZJOEC.js +204 -0
- package/dist/chunk-WCSOJFU3.js +380 -0
- package/dist/chunk-WCT3NYCV.js +160 -0
- package/dist/chunk-WVAJFAIA.js +529 -0
- package/dist/chunk-X5LCYCL5.js +394 -0
- package/dist/chunk-XAKEUMEJ.js +1256 -0
- package/dist/chunk-Y2ZE3MSG.js +590 -0
- package/dist/chunk-Y3J7VR52.js +646 -0
- package/dist/chunk-Y5QGVTVC.js +33 -0
- package/dist/chunk-YAA6IID3.js +548 -0
- package/dist/chunk-YGJTDXVR.js +692 -0
- package/dist/chunk-YRYKTYMQ.js +186 -0
- package/dist/chunk-YYVTBZZC.js +61 -0
- package/dist/chunk-Z5CGSFJB.js +647 -0
- package/dist/chunk-Z72XRXD4.js +787 -0
- package/dist/chunk-ZGR7ULFJ.js +978 -0
- package/dist/chunk-ZJEL4H2R.js +851 -0
- package/dist/chunk-ZO27FGJS.js +554 -0
- package/dist/collapse-CLPJD2RL.js +11 -0
- package/dist/collapse-SLINJQW6.js +9 -0
- package/dist/collapse-ZWUFFCK2.js +9 -0
- package/dist/compute-G55RG53N.js +8 -0
- package/dist/dgmo-router-DZCIDUO5.js +73 -0
- package/dist/dimensions-J3FHIMJ6.js +22 -0
- package/dist/element.cjs +1 -1
- package/dist/element.js +1 -1
- package/dist/element.mjs +1 -1
- package/dist/flowchart-parser-ZNSKIBVR.js +21 -0
- package/dist/flowchart-renderer-ZAEOL4DX.js +35 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -469
- package/dist/index.d.ts +3 -469
- package/dist/index.js +137 -69685
- package/dist/layout-46N4JJYK.js +17 -0
- package/dist/layout-5RA6QWR6.js +26 -0
- package/dist/layout-5T6RH5M6.js +14 -0
- package/dist/layout-7QXCNOVS.js +13 -0
- package/dist/layout-EE6GE46Y.js +17 -0
- package/dist/layout-G23F7LDH.js +9 -0
- package/dist/layout-HRBZPFCN.js +23 -0
- package/dist/layout-HWDSRX5E.js +20 -0
- package/dist/layout-HYZPWAK5.js +18 -0
- package/dist/layout-N76NR4ZO.js +19 -0
- package/dist/layout-OB3RI63S.js +14 -0
- package/dist/layout-S2QBYSK2.js +15 -0
- package/dist/layout-UM5F4DJB.js +15 -0
- package/dist/layout-search-OYV77HHS.js +1655 -0
- package/dist/load-data-EHDDZ5ZS.js +8 -0
- package/dist/palettes-PRJ2RI6D.js +56 -0
- package/dist/parser-2MFP2H2E.js +11 -0
- package/dist/parser-3STE62GB.js +21 -0
- package/dist/parser-4FL2CMDG.js +18 -0
- package/dist/parser-4OGOBJJ4.js +13 -0
- package/dist/parser-6BTRLKRZ.js +15 -0
- package/dist/parser-AQETEVRW.js +21 -0
- package/dist/parser-CFZD5IBL.js +12 -0
- package/dist/parser-FUSKFGZN.js +16 -0
- package/dist/parser-I6KXEYFK.js +13 -0
- package/dist/parser-IXSZZQHY.js +18 -0
- package/dist/parser-JAL2HD4I.js +13 -0
- package/dist/parser-KNSQSKQO.js +20 -0
- package/dist/parser-N5O4IHUN.js +13 -0
- package/dist/parser-NGU3ETO6.js +16 -0
- package/dist/parser-NRAI6O25.js +19 -0
- package/dist/parser-O5J4VBII.js +11 -0
- package/dist/parser-OV7NOBW6.js +21 -0
- package/dist/parser-PQ3POX45.js +23 -0
- package/dist/parser-TFZFBVWN.js +11 -0
- package/dist/parser-TRTHDFPP.js +18 -0
- package/dist/parser-VQP2UJ6W.js +11 -0
- package/dist/parser-XDVELHRK.js +13 -0
- package/dist/parser-XKRP7QKP.js +11 -0
- package/dist/parser-Y6WTBU76.js +14 -0
- package/dist/parser-ZSDPZYQP.js +12 -0
- package/dist/renderer-2XQQQ6QR.js +28 -0
- package/dist/renderer-5NDVNDAZ.js +26 -0
- package/dist/renderer-6EEZHMH4.js +26 -0
- package/dist/renderer-6W5462RB.js +43 -0
- package/dist/renderer-7MVLWWQD.js +22 -0
- package/dist/renderer-AWWAF6XD.js +33 -0
- package/dist/renderer-BYCNMBF7.js +34 -0
- package/dist/renderer-CLJHQPBJ.js +29 -0
- package/dist/renderer-GHPZMFU2.js +15 -0
- package/dist/renderer-JGBKUCZD.js +16 -0
- package/dist/renderer-KQB7UGDS.js +19 -0
- package/dist/renderer-PGX2TKVS.js +24 -0
- package/dist/renderer-QIWVHWZO.js +15 -0
- package/dist/renderer-RPOA5YPZ.js +35 -0
- package/dist/renderer-SMIBCRVB.js +24 -0
- package/dist/renderer-T7YKC5VP.js +28 -0
- package/dist/renderer-TOCOVLHS.js +37 -0
- package/dist/renderer-UWA5XS74.js +39 -0
- package/dist/renderer-VACVQYML.js +25 -0
- package/dist/renderer-W4M6QLIJ.js +37 -0
- package/dist/renderer-WZRREQ2P.js +23 -0
- package/dist/renderer-YY2OSF6E.js +27 -0
- package/dist/renderer-Z7I3W2PP.js +24 -0
- package/dist/renderer-ZGNTUWC4.js +22 -0
- package/dist/renderer-ZTR3DER3.js +19 -0
- package/dist/renderer-radial-C32GPJQ7.js +21 -0
- package/dist/resolver-NOAA7ID7.js +13 -0
- package/dist/state-collapse-HCGD6IVJ.js +8 -0
- package/dist/state-parser-Z2V23ATR.js +18 -0
- package/dist/state-renderer-RFYHSP4K.js +34 -0
- package/dist/themes-1-CuKpeH.d.cts +908 -0
- package/dist/themes-1-CuKpeH.d.ts +908 -0
- package/package.json +1 -1
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHAR_WIDTH_RATIO,
|
|
3
|
+
measureText,
|
|
4
|
+
truncateText
|
|
5
|
+
} from "./chunk-WCT3NYCV.js";
|
|
6
|
+
|
|
7
|
+
// src/infra/layout.ts
|
|
8
|
+
import dagre from "@dagrejs/dagre";
|
|
9
|
+
var MIN_NODE_WIDTH = 140;
|
|
10
|
+
var NODE_HEADER_HEIGHT = 28;
|
|
11
|
+
var META_LINE_HEIGHT = 14;
|
|
12
|
+
var NODE_SEPARATOR_GAP = 4;
|
|
13
|
+
var NODE_PAD_BOTTOM = 10;
|
|
14
|
+
var ROLE_DOT_ROW = 12;
|
|
15
|
+
var COLLAPSE_BAR_HEIGHT = 6;
|
|
16
|
+
var NODE_FONT_SIZE = 13;
|
|
17
|
+
var META_FONT_SIZE = 10;
|
|
18
|
+
var EDGE_LABEL_FONT_SIZE = 11;
|
|
19
|
+
var PADDING_X = 24;
|
|
20
|
+
var GROUP_PADDING = 20;
|
|
21
|
+
var GROUP_HEADER_HEIGHT = 24;
|
|
22
|
+
var EDGE_MARGIN = 60;
|
|
23
|
+
var DISPLAY_KEYS = /* @__PURE__ */ new Set([
|
|
24
|
+
"cache-hit",
|
|
25
|
+
"firewall-block",
|
|
26
|
+
"ratelimit-rps",
|
|
27
|
+
"latency-ms",
|
|
28
|
+
"uptime",
|
|
29
|
+
"instances",
|
|
30
|
+
"max-rps",
|
|
31
|
+
"cb-error-threshold",
|
|
32
|
+
"cb-latency-threshold-ms",
|
|
33
|
+
"concurrency",
|
|
34
|
+
"duration-ms",
|
|
35
|
+
"cold-start-ms",
|
|
36
|
+
"buffer",
|
|
37
|
+
"drain-rate",
|
|
38
|
+
"retention-hours",
|
|
39
|
+
"partitions"
|
|
40
|
+
]);
|
|
41
|
+
var DISPLAY_NAMES = {
|
|
42
|
+
"cache-hit": "cache hit",
|
|
43
|
+
"firewall-block": "firewall block",
|
|
44
|
+
"ratelimit-rps": "rate limit RPS",
|
|
45
|
+
"latency-ms": "latency",
|
|
46
|
+
uptime: "uptime",
|
|
47
|
+
instances: "instances",
|
|
48
|
+
"max-rps": "max RPS",
|
|
49
|
+
"cb-error-threshold": "CB error threshold",
|
|
50
|
+
"cb-latency-threshold-ms": "CB latency threshold",
|
|
51
|
+
concurrency: "concurrency",
|
|
52
|
+
"duration-ms": "duration",
|
|
53
|
+
"cold-start-ms": "cold start",
|
|
54
|
+
buffer: "buffer",
|
|
55
|
+
"drain-rate": "drain rate",
|
|
56
|
+
"retention-hours": "retention",
|
|
57
|
+
partitions: "partitions"
|
|
58
|
+
};
|
|
59
|
+
function countDisplayProps(node, expanded, options) {
|
|
60
|
+
if (!expanded) return 0;
|
|
61
|
+
let count = node.properties.filter((p) => DISPLAY_KEYS.has(p.key)).length;
|
|
62
|
+
if (options) {
|
|
63
|
+
const hasLatency = node.properties.some((p) => p.key === "latency-ms");
|
|
64
|
+
const hasUptime = node.properties.some((p) => p.key === "uptime");
|
|
65
|
+
const isServerless = node.properties.some((p) => p.key === "concurrency");
|
|
66
|
+
const defaultLatency = parseFloat(options["default-latency-ms"] ?? "") || 0;
|
|
67
|
+
const defaultUptime = parseFloat(options["default-uptime"] ?? "") || 0;
|
|
68
|
+
if (!hasLatency && !isServerless && defaultLatency > 0) count++;
|
|
69
|
+
if (!hasUptime && defaultUptime > 0 && defaultUptime < 100) count++;
|
|
70
|
+
}
|
|
71
|
+
return count;
|
|
72
|
+
}
|
|
73
|
+
function countComputedRows(node, expanded) {
|
|
74
|
+
let count = 0;
|
|
75
|
+
if (node.computedConcurrentInvocations > 0) count += 1;
|
|
76
|
+
const p = node.computedLatencyPercentiles;
|
|
77
|
+
if (p.p50 > 0 || p.p90 > 0 || p.p99 > 0) count += expanded ? 3 : 1;
|
|
78
|
+
if (node.computedUptime < 1) {
|
|
79
|
+
const declaredUptime = node.properties.find((p2) => p2.key === "uptime");
|
|
80
|
+
const declaredVal = declaredUptime ? Number(declaredUptime.value) / 100 : 1;
|
|
81
|
+
const differs = Math.abs(node.computedUptime - declaredVal) > 1e-6;
|
|
82
|
+
if (differs || node.isEdge) count += 1;
|
|
83
|
+
}
|
|
84
|
+
if (node.computedAvailability < 1) count += 1;
|
|
85
|
+
if (node.computedCbState === "open") count += 1;
|
|
86
|
+
if (node.queueMetrics) {
|
|
87
|
+
if (node.queueMetrics.fillRate > 0) count += 1;
|
|
88
|
+
if (node.queueMetrics.fillRate > 0 && node.queueMetrics.timeToOverflow < Infinity)
|
|
89
|
+
count += 1;
|
|
90
|
+
}
|
|
91
|
+
return count;
|
|
92
|
+
}
|
|
93
|
+
function hasRoles(node) {
|
|
94
|
+
if (node.isEdge) return false;
|
|
95
|
+
return node.properties.some((p) => DISPLAY_KEYS.has(p.key));
|
|
96
|
+
}
|
|
97
|
+
function computeNodeWidth(node, expanded, options) {
|
|
98
|
+
const badgeVal = node.computedConcurrentInvocations === 0 && node.computedInstances > 1 ? node.computedInstances : 0;
|
|
99
|
+
const badgeWidth = badgeVal > 0 ? measureText(`${badgeVal}x`, META_FONT_SIZE) + 2 * CHAR_WIDTH_RATIO * NODE_FONT_SIZE : 0;
|
|
100
|
+
const labelWidth = measureText(node.label, NODE_FONT_SIZE) + badgeWidth + PADDING_X;
|
|
101
|
+
const allKeys = [];
|
|
102
|
+
if (node.computedRps > 0) allKeys.push("RPS");
|
|
103
|
+
if (expanded) {
|
|
104
|
+
for (const p of node.properties) {
|
|
105
|
+
const dk = DISPLAY_NAMES[p.key];
|
|
106
|
+
if (dk) allKeys.push(dk);
|
|
107
|
+
}
|
|
108
|
+
if (options) {
|
|
109
|
+
const hasLatency = node.properties.some((p) => p.key === "latency-ms");
|
|
110
|
+
const hasUptime = node.properties.some((p) => p.key === "uptime");
|
|
111
|
+
const isServerless = node.properties.some((p) => p.key === "concurrency");
|
|
112
|
+
if (!hasLatency && !isServerless && (parseFloat(options["default-latency-ms"] ?? "") || 0) > 0)
|
|
113
|
+
allKeys.push("latency");
|
|
114
|
+
if (!hasUptime && (parseFloat(options["default-uptime"] ?? "") || 0) > 0 && parseFloat(options["default-uptime"] ?? "") < 100)
|
|
115
|
+
allKeys.push("uptime");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const computedRows = countComputedRows(node, expanded);
|
|
119
|
+
if (computedRows > 0) {
|
|
120
|
+
if (node.computedConcurrentInvocations > 0) allKeys.push("instances");
|
|
121
|
+
const perc = node.computedLatencyPercentiles;
|
|
122
|
+
if (perc.p50 > 0 || perc.p90 > 0 || perc.p99 > 0) {
|
|
123
|
+
if (expanded) {
|
|
124
|
+
allKeys.push("p50", "p90", "p99");
|
|
125
|
+
} else {
|
|
126
|
+
allKeys.push("p90");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (node.computedUptime < 1) {
|
|
130
|
+
const declaredUptime = node.properties.find((p) => p.key === "uptime");
|
|
131
|
+
const declaredVal = declaredUptime ? Number(declaredUptime.value) / 100 : 1;
|
|
132
|
+
if (Math.abs(node.computedUptime - declaredVal) > 1e-6 || node.isEdge) {
|
|
133
|
+
allKeys.push("eff. uptime");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (node.computedAvailability < 1) allKeys.push("availability");
|
|
137
|
+
if (node.computedCbState === "open") allKeys.push("CB");
|
|
138
|
+
if (node.queueMetrics) {
|
|
139
|
+
if (node.queueMetrics.fillRate > 0) allKeys.push("lag");
|
|
140
|
+
if (node.queueMetrics.fillRate > 0 && node.queueMetrics.timeToOverflow < Infinity)
|
|
141
|
+
allKeys.push("overflow");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (allKeys.length === 0) return Math.max(MIN_NODE_WIDTH, labelWidth);
|
|
145
|
+
const keyColWidth = Math.max(
|
|
146
|
+
...allKeys.map((k) => measureText(`${k}: `, META_FONT_SIZE))
|
|
147
|
+
);
|
|
148
|
+
let maxRowWidth = 0;
|
|
149
|
+
if (node.computedRps > 0) {
|
|
150
|
+
const nodeMaxRps = getNumProp(node, "max-rps", 0);
|
|
151
|
+
const nodeRateLimit = getNumProp(node, "ratelimit-rps", 0);
|
|
152
|
+
const nodeConcurrency = getNumProp(node, "concurrency", 0);
|
|
153
|
+
const nodeDurationMs = getNumProp(node, "duration-ms", 100);
|
|
154
|
+
const serverlessCap = nodeConcurrency > 0 ? nodeConcurrency / (nodeDurationMs / 1e3) : 0;
|
|
155
|
+
const effectiveCap = serverlessCap > 0 ? serverlessCap : nodeMaxRps > 0 && nodeRateLimit > 0 ? Math.min(nodeMaxRps * node.computedInstances, nodeRateLimit) : nodeMaxRps > 0 ? nodeMaxRps * node.computedInstances : nodeRateLimit > 0 ? nodeRateLimit : 0;
|
|
156
|
+
const rpsVal = effectiveCap > 0 && !node.isEdge ? `${formatRpsShort(node.computedRps)} / ${formatRpsShort(effectiveCap)}` : formatRps(node.computedRps);
|
|
157
|
+
maxRowWidth = Math.max(
|
|
158
|
+
maxRowWidth,
|
|
159
|
+
keyColWidth + measureText(rpsVal, META_FONT_SIZE)
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (expanded) {
|
|
163
|
+
for (const p of node.properties) {
|
|
164
|
+
const dk = DISPLAY_NAMES[p.key];
|
|
165
|
+
if (!dk) continue;
|
|
166
|
+
const numVal = typeof p.value === "number" ? p.value : parseFloat(String(p.value)) || 0;
|
|
167
|
+
const PCT_KEYS = [
|
|
168
|
+
"cache-hit",
|
|
169
|
+
"firewall-block",
|
|
170
|
+
"uptime",
|
|
171
|
+
"cb-error-threshold"
|
|
172
|
+
];
|
|
173
|
+
const valStr = p.key === "max-rps" || p.key === "ratelimit-rps" ? formatRpsShort(numVal) : p.key === "latency-ms" || p.key === "cb-latency-threshold-ms" || p.key === "duration-ms" || p.key === "cold-start-ms" ? formatMs(numVal) : PCT_KEYS.includes(p.key) ? `${numVal}%` : String(p.value);
|
|
174
|
+
maxRowWidth = Math.max(
|
|
175
|
+
maxRowWidth,
|
|
176
|
+
keyColWidth + measureText(valStr, META_FONT_SIZE)
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (computedRows > 0) {
|
|
181
|
+
const perc = node.computedLatencyPercentiles;
|
|
182
|
+
const msValues = expanded ? [perc.p50, perc.p90, perc.p99] : [perc.p90];
|
|
183
|
+
for (const ms of msValues) {
|
|
184
|
+
if (ms > 0) {
|
|
185
|
+
maxRowWidth = Math.max(
|
|
186
|
+
maxRowWidth,
|
|
187
|
+
keyColWidth + measureText(formatMs(ms), META_FONT_SIZE)
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (perc.p90 > 0) {
|
|
192
|
+
const rawThreshold = node.properties.find((p) => p.key === "slo-p90-latency-ms")?.value ?? options?.["slo-p90-latency-ms"];
|
|
193
|
+
const threshold = rawThreshold != null ? parseFloat(String(rawThreshold)) : NaN;
|
|
194
|
+
if (!isNaN(threshold) && threshold > 0) {
|
|
195
|
+
const combinedVal = `${formatMs(perc.p90)} / ${formatMs(threshold)}`;
|
|
196
|
+
maxRowWidth = Math.max(
|
|
197
|
+
maxRowWidth,
|
|
198
|
+
keyColWidth + measureText(combinedVal, META_FONT_SIZE)
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (node.computedUptime < 1) {
|
|
203
|
+
maxRowWidth = Math.max(
|
|
204
|
+
maxRowWidth,
|
|
205
|
+
keyColWidth + measureText(formatUptime(node.computedUptime), META_FONT_SIZE)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
if (node.computedAvailability < 1) {
|
|
209
|
+
maxRowWidth = Math.max(
|
|
210
|
+
maxRowWidth,
|
|
211
|
+
keyColWidth + measureText(formatUptime(node.computedAvailability), META_FONT_SIZE)
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
if (node.computedCbState === "open") {
|
|
215
|
+
maxRowWidth = Math.max(
|
|
216
|
+
maxRowWidth,
|
|
217
|
+
measureText("CB: OPEN", META_FONT_SIZE) + 8
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const DESC_MAX_WIDTH = 120 * CHAR_WIDTH_RATIO * META_FONT_SIZE;
|
|
222
|
+
const descLines = expanded && node.description && !node.isEdge ? node.description : [];
|
|
223
|
+
let descWidth = 0;
|
|
224
|
+
for (const dl of descLines) {
|
|
225
|
+
const truncated = truncateText(dl, META_FONT_SIZE, DESC_MAX_WIDTH);
|
|
226
|
+
descWidth = Math.max(
|
|
227
|
+
descWidth,
|
|
228
|
+
measureText(truncated, META_FONT_SIZE) + PADDING_X
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return Math.max(MIN_NODE_WIDTH, labelWidth, maxRowWidth + 20, descWidth);
|
|
232
|
+
}
|
|
233
|
+
function computeNodeHeight(node, expanded, options) {
|
|
234
|
+
const propCount = countDisplayProps(node, expanded, options);
|
|
235
|
+
const computedCount = countComputedRows(node, expanded);
|
|
236
|
+
const hasRps = node.computedRps > 0;
|
|
237
|
+
const descLineCount = expanded && node.description && !node.isEdge ? node.description.length : 0;
|
|
238
|
+
const descH = descLineCount * META_LINE_HEIGHT;
|
|
239
|
+
if (propCount === 0 && computedCount === 0 && !hasRps)
|
|
240
|
+
return NODE_HEADER_HEIGHT + descH + NODE_PAD_BOTTOM;
|
|
241
|
+
let h = NODE_HEADER_HEIGHT + descH + NODE_SEPARATOR_GAP;
|
|
242
|
+
const computedSectionCount = (hasRps ? 1 : 0) + computedCount;
|
|
243
|
+
h += computedSectionCount * META_LINE_HEIGHT;
|
|
244
|
+
if (computedSectionCount > 0 && propCount > 0) h += NODE_SEPARATOR_GAP;
|
|
245
|
+
h += propCount * META_LINE_HEIGHT;
|
|
246
|
+
if (hasRoles(node)) h += ROLE_DOT_ROW;
|
|
247
|
+
h += NODE_PAD_BOTTOM;
|
|
248
|
+
if (node.id.startsWith("[")) h += COLLAPSE_BAR_HEIGHT;
|
|
249
|
+
return h;
|
|
250
|
+
}
|
|
251
|
+
function formatRps(rps) {
|
|
252
|
+
if (rps >= 1e3) return `${(rps / 1e3).toFixed(1)}k rps`;
|
|
253
|
+
return `${Math.round(rps)} rps`;
|
|
254
|
+
}
|
|
255
|
+
function formatRpsShort(rps) {
|
|
256
|
+
if (rps >= 1e3) return `${(rps / 1e3).toFixed(1)}k`;
|
|
257
|
+
return `${Math.round(rps)}`;
|
|
258
|
+
}
|
|
259
|
+
function getNumProp(node, key, fallback) {
|
|
260
|
+
const p = node.properties.find((pr) => pr.key === key);
|
|
261
|
+
if (!p) return fallback;
|
|
262
|
+
return typeof p.value === "number" ? p.value : parseFloat(String(p.value)) || fallback;
|
|
263
|
+
}
|
|
264
|
+
function formatMs(ms) {
|
|
265
|
+
if (ms >= 1e3) return `${(ms / 1e3).toFixed(1)}s`;
|
|
266
|
+
return `${Math.round(ms)}ms`;
|
|
267
|
+
}
|
|
268
|
+
function formatUptime(fraction) {
|
|
269
|
+
const pct = fraction * 100;
|
|
270
|
+
if (pct >= 99.99) return "99.99%";
|
|
271
|
+
if (pct >= 99.9) return `${pct.toFixed(2)}%`;
|
|
272
|
+
if (pct >= 99) return `${pct.toFixed(1)}%`;
|
|
273
|
+
return `${pct.toFixed(1)}%`;
|
|
274
|
+
}
|
|
275
|
+
var GROUP_GAP = GROUP_PADDING * 2 + GROUP_HEADER_HEIGHT;
|
|
276
|
+
function separateGroups(groups, nodes, isLR, maxIterations = 20) {
|
|
277
|
+
const groupDeltas = /* @__PURE__ */ new Map();
|
|
278
|
+
let converged = false;
|
|
279
|
+
for (let iter = 0; iter < maxIterations; iter++) {
|
|
280
|
+
let anyOverlap = false;
|
|
281
|
+
for (let i = 0; i < groups.length; i++) {
|
|
282
|
+
for (let j = i + 1; j < groups.length; j++) {
|
|
283
|
+
const ga = groups[i];
|
|
284
|
+
const gb = groups[j];
|
|
285
|
+
const primaryOverlap = isLR ? Math.min(ga.y + ga.height, gb.y + gb.height) - Math.max(ga.y, gb.y) : Math.min(ga.x + ga.width, gb.x + gb.width) - Math.max(ga.x, gb.x);
|
|
286
|
+
if (primaryOverlap <= 0) continue;
|
|
287
|
+
const crossOverlap = isLR ? Math.min(ga.x + ga.width, gb.x + gb.width) - Math.max(ga.x, gb.x) : Math.min(ga.y + ga.height, gb.y + gb.height) - Math.max(ga.y, gb.y);
|
|
288
|
+
if (crossOverlap <= 0) continue;
|
|
289
|
+
anyOverlap = true;
|
|
290
|
+
const shift = primaryOverlap + GROUP_GAP;
|
|
291
|
+
const aCenter = isLR ? ga.y + ga.height / 2 : ga.x + ga.width / 2;
|
|
292
|
+
const bCenter = isLR ? gb.y + gb.height / 2 : gb.x + gb.width / 2;
|
|
293
|
+
const groupToShift = aCenter <= bCenter ? gb : ga;
|
|
294
|
+
if (isLR) groupToShift.y += shift;
|
|
295
|
+
else groupToShift.x += shift;
|
|
296
|
+
const prev = groupDeltas.get(groupToShift.id) ?? { dx: 0, dy: 0 };
|
|
297
|
+
if (isLR)
|
|
298
|
+
groupDeltas.set(groupToShift.id, {
|
|
299
|
+
dx: prev.dx,
|
|
300
|
+
dy: prev.dy + shift
|
|
301
|
+
});
|
|
302
|
+
else
|
|
303
|
+
groupDeltas.set(groupToShift.id, {
|
|
304
|
+
dx: prev.dx + shift,
|
|
305
|
+
dy: prev.dy
|
|
306
|
+
});
|
|
307
|
+
for (const node of nodes) {
|
|
308
|
+
if (node.groupId === groupToShift.id) {
|
|
309
|
+
if (isLR) node.y += shift;
|
|
310
|
+
else node.x += shift;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (!anyOverlap) {
|
|
316
|
+
converged = true;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (!converged && maxIterations > 0) {
|
|
321
|
+
console.warn(
|
|
322
|
+
`separateGroups: hit maxIterations (${maxIterations}) without fully resolving all group overlaps`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
return groupDeltas;
|
|
326
|
+
}
|
|
327
|
+
function fixEdgeWaypoints(edges, nodes, groupDeltas) {
|
|
328
|
+
if (groupDeltas.size === 0) return;
|
|
329
|
+
const nodeToGroup = /* @__PURE__ */ new Map();
|
|
330
|
+
for (const node of nodes) nodeToGroup.set(node.id, node.groupId);
|
|
331
|
+
for (const edge of edges) {
|
|
332
|
+
const srcGroup = nodeToGroup.get(edge.sourceId) ?? null;
|
|
333
|
+
const tgtGroup = nodeToGroup.get(edge.targetId) ?? null;
|
|
334
|
+
const srcDelta = srcGroup ? groupDeltas.get(srcGroup) : void 0;
|
|
335
|
+
const tgtDelta = tgtGroup ? groupDeltas.get(tgtGroup) : void 0;
|
|
336
|
+
if (!srcDelta && !tgtDelta) continue;
|
|
337
|
+
if (srcDelta && tgtDelta && srcGroup !== tgtGroup) {
|
|
338
|
+
edge.points = [];
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
const delta = srcDelta ?? tgtDelta;
|
|
342
|
+
for (const pt of edge.points) {
|
|
343
|
+
pt.x += delta.dx;
|
|
344
|
+
pt.y += delta.dy;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function layoutInfra(computed, expandedNodeIds, collapsedNodes) {
|
|
349
|
+
if (computed.nodes.length === 0) {
|
|
350
|
+
return {
|
|
351
|
+
nodes: [],
|
|
352
|
+
edges: [],
|
|
353
|
+
groups: [],
|
|
354
|
+
options: {},
|
|
355
|
+
direction: computed.direction,
|
|
356
|
+
width: 0,
|
|
357
|
+
height: 0
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const isLR = computed.direction !== "TB";
|
|
361
|
+
const g = new dagre.graphlib.Graph();
|
|
362
|
+
g.setGraph({
|
|
363
|
+
rankdir: computed.direction === "TB" ? "TB" : "LR",
|
|
364
|
+
nodesep: isLR ? 70 : 60,
|
|
365
|
+
ranksep: isLR ? 150 : 120,
|
|
366
|
+
edgesep: 30
|
|
367
|
+
});
|
|
368
|
+
g.setDefaultEdgeLabel(() => ({}));
|
|
369
|
+
const groupedNodeIds = /* @__PURE__ */ new Set();
|
|
370
|
+
for (const node of computed.nodes) {
|
|
371
|
+
if (node.groupId) groupedNodeIds.add(node.id);
|
|
372
|
+
}
|
|
373
|
+
const GROUP_INFLATE = GROUP_PADDING * 2 + GROUP_HEADER_HEIGHT;
|
|
374
|
+
const widthMap = /* @__PURE__ */ new Map();
|
|
375
|
+
const heightMap = /* @__PURE__ */ new Map();
|
|
376
|
+
for (const node of computed.nodes) {
|
|
377
|
+
const isNodeCollapsed = collapsedNodes?.has(node.id) ?? false;
|
|
378
|
+
const expanded = !isNodeCollapsed && (expandedNodeIds?.has(node.id) ?? false);
|
|
379
|
+
const width = computeNodeWidth(node, expanded, computed.options);
|
|
380
|
+
const height = isNodeCollapsed ? NODE_HEADER_HEIGHT + NODE_PAD_BOTTOM : computeNodeHeight(node, expanded, computed.options);
|
|
381
|
+
widthMap.set(node.id, width);
|
|
382
|
+
heightMap.set(node.id, height);
|
|
383
|
+
const inGroup = groupedNodeIds.has(node.id);
|
|
384
|
+
g.setNode(node.id, {
|
|
385
|
+
label: node.label,
|
|
386
|
+
width: inGroup && !isLR ? width + GROUP_INFLATE : width,
|
|
387
|
+
height: inGroup && isLR ? height + GROUP_INFLATE : height
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
const groupChildIds = /* @__PURE__ */ new Set();
|
|
391
|
+
for (const node of computed.nodes) {
|
|
392
|
+
if (node.groupId) groupChildIds.add(node.id);
|
|
393
|
+
}
|
|
394
|
+
const groupChildren = /* @__PURE__ */ new Map();
|
|
395
|
+
for (const node of computed.nodes) {
|
|
396
|
+
if (node.groupId) {
|
|
397
|
+
const list = groupChildren.get(node.groupId) ?? [];
|
|
398
|
+
list.push(node.id);
|
|
399
|
+
groupChildren.set(node.groupId, list);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
for (const edge of computed.edges) {
|
|
403
|
+
const children = groupChildren.get(edge.targetId);
|
|
404
|
+
if (children && children.length > 0) {
|
|
405
|
+
for (const childId of children) {
|
|
406
|
+
g.setEdge(edge.sourceId, childId, { label: edge.label });
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
g.setEdge(edge.sourceId, edge.targetId, { label: edge.label });
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
dagre.layout(g);
|
|
413
|
+
const layoutNodes = computed.nodes.map(
|
|
414
|
+
(node) => {
|
|
415
|
+
const pos = g.node(node.id);
|
|
416
|
+
return {
|
|
417
|
+
id: node.id,
|
|
418
|
+
label: node.label,
|
|
419
|
+
x: pos.x,
|
|
420
|
+
y: pos.y,
|
|
421
|
+
width: widthMap.get(node.id) ?? MIN_NODE_WIDTH,
|
|
422
|
+
height: heightMap.get(node.id) ?? NODE_HEADER_HEIGHT + NODE_PAD_BOTTOM,
|
|
423
|
+
computedRps: node.computedRps,
|
|
424
|
+
overloaded: node.overloaded,
|
|
425
|
+
rateLimited: node.rateLimited,
|
|
426
|
+
isEdge: node.isEdge,
|
|
427
|
+
groupId: node.groupId,
|
|
428
|
+
computedLatencyMs: node.computedLatencyMs,
|
|
429
|
+
computedLatencyPercentiles: node.computedLatencyPercentiles,
|
|
430
|
+
computedUptime: node.computedUptime,
|
|
431
|
+
computedAvailability: node.computedAvailability,
|
|
432
|
+
computedAvailabilityPercentiles: node.computedAvailabilityPercentiles,
|
|
433
|
+
computedInstances: node.computedInstances,
|
|
434
|
+
computedConcurrentInvocations: node.computedConcurrentInvocations,
|
|
435
|
+
computedCbState: node.computedCbState,
|
|
436
|
+
...node.childHealthState !== void 0 && {
|
|
437
|
+
childHealthState: node.childHealthState
|
|
438
|
+
},
|
|
439
|
+
...node.queueMetrics !== void 0 && {
|
|
440
|
+
queueMetrics: node.queueMetrics
|
|
441
|
+
},
|
|
442
|
+
properties: node.properties,
|
|
443
|
+
tags: node.tags,
|
|
444
|
+
...node.description !== void 0 && {
|
|
445
|
+
description: node.description
|
|
446
|
+
},
|
|
447
|
+
lineNumber: node.lineNumber
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
const layoutEdges = [];
|
|
452
|
+
for (const edge of computed.edges) {
|
|
453
|
+
const children = groupChildren.get(edge.targetId);
|
|
454
|
+
if (children && children.length > 0) {
|
|
455
|
+
const edgeData = g.edge(edge.sourceId, children[0]);
|
|
456
|
+
layoutEdges.push({
|
|
457
|
+
sourceId: edge.sourceId,
|
|
458
|
+
targetId: edge.targetId,
|
|
459
|
+
label: edge.label,
|
|
460
|
+
async: edge.async,
|
|
461
|
+
computedRps: edge.computedRps,
|
|
462
|
+
split: edge.split,
|
|
463
|
+
fanout: edge.fanout,
|
|
464
|
+
points: edgeData?.points ?? [],
|
|
465
|
+
lineNumber: edge.lineNumber
|
|
466
|
+
});
|
|
467
|
+
} else {
|
|
468
|
+
const edgeData = g.edge(edge.sourceId, edge.targetId);
|
|
469
|
+
layoutEdges.push({
|
|
470
|
+
sourceId: edge.sourceId,
|
|
471
|
+
targetId: edge.targetId,
|
|
472
|
+
label: edge.label,
|
|
473
|
+
async: edge.async,
|
|
474
|
+
computedRps: edge.computedRps,
|
|
475
|
+
split: edge.split,
|
|
476
|
+
fanout: edge.fanout,
|
|
477
|
+
points: edgeData?.points ?? [],
|
|
478
|
+
lineNumber: edge.lineNumber
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const layoutGroups = computed.groups.map(
|
|
483
|
+
(group) => {
|
|
484
|
+
const childNodes = layoutNodes.filter((n) => n.groupId === group.id);
|
|
485
|
+
if (childNodes.length === 0) {
|
|
486
|
+
return {
|
|
487
|
+
id: group.id,
|
|
488
|
+
label: group.label,
|
|
489
|
+
x: 0,
|
|
490
|
+
y: 0,
|
|
491
|
+
width: MIN_NODE_WIDTH,
|
|
492
|
+
height: NODE_HEADER_HEIGHT + NODE_PAD_BOTTOM,
|
|
493
|
+
...group.instances !== void 0 && { instances: group.instances },
|
|
494
|
+
lineNumber: group.lineNumber
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
let minX2 = Infinity, minY2 = Infinity, maxX2 = -Infinity, maxY2 = -Infinity;
|
|
498
|
+
for (const child of childNodes) {
|
|
499
|
+
const left = child.x - child.width / 2;
|
|
500
|
+
const right = child.x + child.width / 2;
|
|
501
|
+
const top = child.y - child.height / 2;
|
|
502
|
+
const bottom = child.y + child.height / 2;
|
|
503
|
+
if (left < minX2) minX2 = left;
|
|
504
|
+
if (right > maxX2) maxX2 = right;
|
|
505
|
+
if (top < minY2) minY2 = top;
|
|
506
|
+
if (bottom > maxY2) maxY2 = bottom;
|
|
507
|
+
}
|
|
508
|
+
return {
|
|
509
|
+
id: group.id,
|
|
510
|
+
label: group.label,
|
|
511
|
+
x: minX2 - GROUP_PADDING,
|
|
512
|
+
y: minY2 - GROUP_PADDING - GROUP_HEADER_HEIGHT,
|
|
513
|
+
width: maxX2 - minX2 + GROUP_PADDING * 2,
|
|
514
|
+
height: maxY2 - minY2 + GROUP_PADDING * 2 + GROUP_HEADER_HEIGHT,
|
|
515
|
+
...group.instances !== void 0 && { instances: group.instances },
|
|
516
|
+
lineNumber: group.lineNumber
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
);
|
|
520
|
+
const groupDeltas = separateGroups(layoutGroups, layoutNodes, isLR);
|
|
521
|
+
fixEdgeWaypoints(layoutEdges, layoutNodes, groupDeltas);
|
|
522
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
523
|
+
for (const node of layoutNodes) {
|
|
524
|
+
const left = node.x - node.width / 2;
|
|
525
|
+
const right = node.x + node.width / 2;
|
|
526
|
+
const top = node.y - node.height / 2;
|
|
527
|
+
const bottom = node.y + node.height / 2;
|
|
528
|
+
if (left < minX) minX = left;
|
|
529
|
+
if (right > maxX) maxX = right;
|
|
530
|
+
if (top < minY) minY = top;
|
|
531
|
+
if (bottom > maxY) maxY = bottom;
|
|
532
|
+
}
|
|
533
|
+
for (const group of layoutGroups) {
|
|
534
|
+
if (group.x < minX) minX = group.x;
|
|
535
|
+
if (group.x + group.width > maxX) maxX = group.x + group.width;
|
|
536
|
+
if (group.y < minY) minY = group.y;
|
|
537
|
+
if (group.y + group.height > maxY) maxY = group.y + group.height;
|
|
538
|
+
}
|
|
539
|
+
for (const edge of layoutEdges) {
|
|
540
|
+
for (const pt of edge.points) {
|
|
541
|
+
if (pt.x < minX) minX = pt.x;
|
|
542
|
+
if (pt.x > maxX) maxX = pt.x;
|
|
543
|
+
if (pt.y < minY) minY = pt.y;
|
|
544
|
+
if (pt.y > maxY) maxY = pt.y;
|
|
545
|
+
}
|
|
546
|
+
if (edge.label) {
|
|
547
|
+
const midIdx = Math.floor(edge.points.length / 2);
|
|
548
|
+
const midPt = edge.points[midIdx];
|
|
549
|
+
if (midPt) {
|
|
550
|
+
const halfWidth = (measureText(edge.label, EDGE_LABEL_FONT_SIZE) + 8) / 2;
|
|
551
|
+
if (midPt.x - halfWidth < minX) minX = midPt.x - halfWidth;
|
|
552
|
+
if (midPt.x + halfWidth > maxX) maxX = midPt.x + halfWidth;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const shiftX = -minX + EDGE_MARGIN;
|
|
557
|
+
const shiftY = -minY + EDGE_MARGIN;
|
|
558
|
+
for (const node of layoutNodes) {
|
|
559
|
+
node.x += shiftX;
|
|
560
|
+
node.y += shiftY;
|
|
561
|
+
}
|
|
562
|
+
for (const edge of layoutEdges) {
|
|
563
|
+
for (const pt of edge.points) {
|
|
564
|
+
pt.x += shiftX;
|
|
565
|
+
pt.y += shiftY;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
for (const group of layoutGroups) {
|
|
569
|
+
group.x += shiftX;
|
|
570
|
+
group.y += shiftY;
|
|
571
|
+
}
|
|
572
|
+
const totalWidth = maxX + shiftX + EDGE_MARGIN;
|
|
573
|
+
const totalHeight = maxY + shiftY + EDGE_MARGIN;
|
|
574
|
+
return {
|
|
575
|
+
nodes: layoutNodes,
|
|
576
|
+
edges: layoutEdges,
|
|
577
|
+
groups: layoutGroups,
|
|
578
|
+
options: computed.options,
|
|
579
|
+
direction: computed.direction,
|
|
580
|
+
width: totalWidth,
|
|
581
|
+
height: totalHeight
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
export {
|
|
586
|
+
separateGroups,
|
|
587
|
+
fixEdgeWaypoints,
|
|
588
|
+
layoutInfra
|
|
589
|
+
};
|
|
590
|
+
//# sourceMappingURL=chunk-Y2ZE3MSG.js.map
|