@8btc/xcanvas 0.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.
- package/README.md +70 -0
- package/dist/Tableau10-BqnYsPR6.js +9 -0
- package/dist/XCanvas-BxdLBkBz.js +27732 -0
- package/dist/_commonjs-dynamic-modules-TGKdzP3c.js +6 -0
- package/dist/ar-SA-G6X2FPQ2-DjqDLLYL.js +41 -0
- package/dist/arc-D1qX5GFf.js +132 -0
- package/dist/array-DgktLKBx.js +6 -0
- package/dist/az-AZ-76LH7QW2-D7LOsF3_.js +32 -0
- package/dist/bg-BG-XCXSNQG7-WI4tFn23.js +36 -0
- package/dist/blockDiagram-38ab4fdb-DtemKfEh.js +1811 -0
- package/dist/bn-BD-2XOGV67Q-Bugx_8fy.js +36 -0
- package/dist/c4Diagram-3d4e48cf-Byd2vU9K.js +2463 -0
- package/dist/ca-ES-6MX7JW3Y-6rFwKGsQ.js +39 -0
- package/dist/channel-BT_3Ze-Y.js +7 -0
- package/dist/chunk-EIO257PC-C7qD7hGu.js +1641 -0
- package/dist/classDiagram-70f12bd4-CwfYadk-.js +354 -0
- package/dist/classDiagram-v2-f2320105-B28MuM8f.js +284 -0
- package/dist/clone-D2FUK8WY.js +8 -0
- package/dist/createText-2e5e7dd3-Ca1JfQaJ.js +4914 -0
- package/dist/cs-CZ-2BRQDIVT-Dhd8XszK.js +42 -0
- package/dist/da-DK-5WZEPLOC-BhL87sSs.js +36 -0
- package/dist/de-DE-XR44H4JA-xSrZSV0J.js +39 -0
- package/dist/directory-open-01563666-XowynPwH.js +14 -0
- package/dist/directory-open-4ed118d0-BwYbu9dw.js +55 -0
- package/dist/edges-e0da2a9e-9VbVapWU.js +1840 -0
- package/dist/el-GR-BZB4AONW-DQORZ_pY.js +41 -0
- package/dist/en-B4ZKOASM-D2BVbEdz.js +39 -0
- package/dist/erDiagram-9861fffd-D4S9QDes.js +1318 -0
- package/dist/es-ES-U4NZUMDT-C0Q89-0V.js +40 -0
- package/dist/eu-ES-A7QVB2H4-BwBW3cEw.js +42 -0
- package/dist/fa-IR-HGAKTJCU-DtZ74rm4.js +39 -0
- package/dist/fi-FI-Z5N7JZ37-QvQan48z.js +37 -0
- package/dist/file-open-002ab408-BNIYSKAV.js +18 -0
- package/dist/file-open-7c801643-B_l1UXdI.js +15 -0
- package/dist/file-save-3189631c-vzijizFw.js +23 -0
- package/dist/file-save-745eba88-B5-wM56X.js +25 -0
- package/dist/flowDb-956e92f1-S6T8ppJw.js +1713 -0
- package/dist/flowDiagram-66a62f08-C6TTwS5_.js +1264 -0
- package/dist/flowDiagram-v2-96b9c2cf-CzfeUNGP.js +24 -0
- package/dist/flowchart-elk-definition-4a651766-CRv1kWtk.js +92922 -0
- package/dist/fr-FR-RHASNOE6-CZFiweNU.js +40 -0
- package/dist/ganttDiagram-c361ad54-CAnfd8Sw.js +3420 -0
- package/dist/gitGraphDiagram-72cf32ee-CSGI-xRI.js +1790 -0
- package/dist/gl-ES-HMX3MZ6V-Bqv2xL-V.js +41 -0
- package/dist/graph-Ct2tKpKj.js +1253 -0
- package/dist/he-IL-6SHJWFNN-kso30jhn.js +41 -0
- package/dist/hi-IN-IWLTKZ5I-Busk5oaa.js +35 -0
- package/dist/hu-HU-A5ZG7DT2-xSR2C2H0.js +38 -0
- package/dist/id-ID-SAP4L64H-BQQZYm1L.js +41 -0
- package/dist/image-EDRW2JGV-Cx7o2kxD.js +6 -0
- package/dist/image-blob-reduce.esm-BKPqMdie.js +2396 -0
- package/dist/index-3862675e-B3j3w-v_.js +663 -0
- package/dist/index-CLOU2Ikr.js +14364 -0
- package/dist/index.css +450 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +7 -0
- package/dist/index.umd.cjs +235477 -0
- package/dist/infoDiagram-f8f76790-NqA75uBo.js +510 -0
- package/dist/init-ZxktEp_H.js +16 -0
- package/dist/it-IT-JPQ66NNP-CAMVZrYt.js +42 -0
- package/dist/ja-JP-DBVTYXUO-CAX8A_Uj.js +39 -0
- package/dist/journeyDiagram-49397b02-By5oBzsZ.js +1182 -0
- package/dist/kaa-6HZHGXH3-4-o94cPY.js +32 -0
- package/dist/kab-KAB-ZGHBKWFO-CgyjjBvZ.js +39 -0
- package/dist/katex-C-jAQc2m.js +14516 -0
- package/dist/kk-KZ-P5N5QNE5-BEqZcwLA.js +32 -0
- package/dist/km-KH-HSX4SM5Z-DvKDbeH4.js +42 -0
- package/dist/ko-KR-MTYHY66A-DKCuAbKE.js +40 -0
- package/dist/ku-TR-6OUDTVRD-CNUs4cCe.js +40 -0
- package/dist/layout-AJxYKqQV.js +2292 -0
- package/dist/line-DJIf5OM8.js +45 -0
- package/dist/linear-Cfj4s4vI.js +539 -0
- package/dist/lt-LT-XHIRWOB4-gouzGdoW.js +34 -0
- package/dist/lv-LV-5QDEKY6T-CTvg1XFv.js +38 -0
- package/dist/mindmap-definition-fc14e90a-CBlwH_UF.js +35283 -0
- package/dist/mr-IN-CRQNXWMA-QeYm06Kq.js +44 -0
- package/dist/my-MM-5M5IBNSE-DG3k9ORf.js +32 -0
- package/dist/nb-NO-T6EIAALU-Cj995Nmg.js +41 -0
- package/dist/nl-NL-IS3SIHDZ-B-2H7xey.js +39 -0
- package/dist/nn-NO-6E72VCQL-DrAwKKTN.js +39 -0
- package/dist/oc-FR-POXYY2M6-CeyJD7tq.js +39 -0
- package/dist/ordinal-DSZU4PqD.js +76 -0
- package/dist/pa-IN-N4M65BXN-DHzi6mjo.js +35 -0
- package/dist/path-Cp2qmpkd.js +109 -0
- package/dist/percentages-BXMCSKIN-CDYsTuua.js +6 -0
- package/dist/pica-CzzcRNRD.js +1702 -0
- package/dist/pieDiagram-8a3498a8-DueGoZOh.js +768 -0
- package/dist/pl-PL-T2D74RX3-BBNEV2c6.js +40 -0
- package/dist/pt-BR-5N22H2LF-D2cTx_F0.js +40 -0
- package/dist/pt-PT-UZXXM6DQ-BddvLLsF.js +40 -0
- package/dist/quadrantDiagram-120e2f19-Tb6_oGIn.js +1198 -0
- package/dist/requirementDiagram-deff3bca-CEeg0ep-.js +1089 -0
- package/dist/ro-RO-JPDTUUEW-DynuW50i.js +42 -0
- package/dist/roundRect-CjfubgrN.js +152 -0
- package/dist/ru-RU-B4JR7IUQ-B5Hecrew.js +40 -0
- package/dist/sankeyDiagram-04a897e0-CGTLQ8Gm.js +1172 -0
- package/dist/sequenceDiagram-704730f1-CZ72D-Nd.js +3336 -0
- package/dist/si-LK-N5RQ5JYF-BGMa93tc.js +32 -0
- package/dist/sk-SK-C5VTKIMK-BttCAlBm.js +37 -0
- package/dist/sl-SI-NN7IZMDC-DTC59nzG.js +37 -0
- package/dist/stateDiagram-587899a1-XISZzz_f.js +451 -0
- package/dist/stateDiagram-v2-d93cdb3a-DbCcmzTc.js +319 -0
- package/dist/styles-6aaf32cf-CyfdkEib.js +1363 -0
- package/dist/styles-9a916d00-zQ92RrTB.js +1483 -0
- package/dist/styles-c10674c1-BWmkigmR.js +571 -0
- package/dist/subset-shared.chunk-BuFt2PpZ.js +8 -0
- package/dist/subset-worker.chunk-CgaFXU4O.js +14 -0
- package/dist/sv-SE-XGPEYMSR-BPDlPxC1.js +41 -0
- package/dist/svgDrawCommon-08f97a94-CJ0lufOi.js +100 -0
- package/dist/ta-IN-2NMHFXQM-CI1ZsNk9.js +40 -0
- package/dist/th-TH-HPSO5L25-CUM-w2Qt.js +33 -0
- package/dist/timeline-definition-85554ec2-DV6084Gl.js +1210 -0
- package/dist/tr-TR-DEFEU3FU-CGpyf_vD.js +38 -0
- package/dist/uk-UA-QMV73CPH-Bg15Mv3J.js +37 -0
- package/dist/vi-VN-M7AON7JQ-AYmca9so.js +36 -0
- package/dist/vite.svg +1 -0
- package/dist/xychartDiagram-e933f94c-P1e6EEaH.js +1796 -0
- package/dist/zh-CN-LNUGB5OW-Dem2Cc-c.js +41 -0
- package/dist/zh-HK-E62DVLB3-BjsDyiLI.js +32 -0
- package/dist/zh-TW-RAJ6MFWO-IDAsc9Pz.js +40 -0
- package/package.json +52 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { s as styles, d as db, p as parser$1 } from "./styles-6aaf32cf-CyfdkEib.js";
|
|
2
|
+
import { g as getConfig, d as select, l as log$1, e as configureSvgSize, k as common$1, t as curveBasis, u as utils } from "./index-CLOU2Ikr.js";
|
|
3
|
+
import { G as Graph } from "./graph-Ct2tKpKj.js";
|
|
4
|
+
import { l as layout } from "./layout-AJxYKqQV.js";
|
|
5
|
+
import { l as line } from "./line-DJIf5OM8.js";
|
|
6
|
+
const drawStartState = (g) => g.append("circle").attr("class", "start-state").attr("r", getConfig().state.sizeUnit).attr("cx", getConfig().state.padding + getConfig().state.sizeUnit).attr("cy", getConfig().state.padding + getConfig().state.sizeUnit);
|
|
7
|
+
const drawDivider = (g) => g.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", getConfig().state.textHeight).attr("class", "divider").attr("x2", getConfig().state.textHeight * 2).attr("y1", 0).attr("y2", 0);
|
|
8
|
+
const drawSimpleState = (g, stateDef) => {
|
|
9
|
+
const state = g.append("text").attr("x", 2 * getConfig().state.padding).attr("y", getConfig().state.textHeight + 2 * getConfig().state.padding).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.id);
|
|
10
|
+
const classBox = state.node().getBBox();
|
|
11
|
+
g.insert("rect", ":first-child").attr("x", getConfig().state.padding).attr("y", getConfig().state.padding).attr("width", classBox.width + 2 * getConfig().state.padding).attr("height", classBox.height + 2 * getConfig().state.padding).attr("rx", getConfig().state.radius);
|
|
12
|
+
return state;
|
|
13
|
+
};
|
|
14
|
+
const drawDescrState = (g, stateDef) => {
|
|
15
|
+
const addTspan = function(textEl, txt, isFirst2) {
|
|
16
|
+
const tSpan = textEl.append("tspan").attr("x", 2 * getConfig().state.padding).text(txt);
|
|
17
|
+
if (!isFirst2) {
|
|
18
|
+
tSpan.attr("dy", getConfig().state.textHeight);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const title = g.append("text").attr("x", 2 * getConfig().state.padding).attr("y", getConfig().state.textHeight + 1.3 * getConfig().state.padding).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.descriptions[0]);
|
|
22
|
+
const titleBox = title.node().getBBox();
|
|
23
|
+
const titleHeight = titleBox.height;
|
|
24
|
+
const description = g.append("text").attr("x", getConfig().state.padding).attr(
|
|
25
|
+
"y",
|
|
26
|
+
titleHeight + getConfig().state.padding * 0.4 + getConfig().state.dividerMargin + getConfig().state.textHeight
|
|
27
|
+
).attr("class", "state-description");
|
|
28
|
+
let isFirst = true;
|
|
29
|
+
let isSecond = true;
|
|
30
|
+
stateDef.descriptions.forEach(function(descr) {
|
|
31
|
+
if (!isFirst) {
|
|
32
|
+
addTspan(description, descr, isSecond);
|
|
33
|
+
isSecond = false;
|
|
34
|
+
}
|
|
35
|
+
isFirst = false;
|
|
36
|
+
});
|
|
37
|
+
const descrLine = g.append("line").attr("x1", getConfig().state.padding).attr("y1", getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2).attr("y2", getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2).attr("class", "descr-divider");
|
|
38
|
+
const descrBox = description.node().getBBox();
|
|
39
|
+
const width = Math.max(descrBox.width, titleBox.width);
|
|
40
|
+
descrLine.attr("x2", width + 3 * getConfig().state.padding);
|
|
41
|
+
g.insert("rect", ":first-child").attr("x", getConfig().state.padding).attr("y", getConfig().state.padding).attr("width", width + 2 * getConfig().state.padding).attr("height", descrBox.height + titleHeight + 2 * getConfig().state.padding).attr("rx", getConfig().state.radius);
|
|
42
|
+
return g;
|
|
43
|
+
};
|
|
44
|
+
const addTitleAndBox = (g, stateDef, altBkg) => {
|
|
45
|
+
const pad = getConfig().state.padding;
|
|
46
|
+
const dblPad = 2 * getConfig().state.padding;
|
|
47
|
+
const orgBox = g.node().getBBox();
|
|
48
|
+
const orgWidth = orgBox.width;
|
|
49
|
+
const orgX = orgBox.x;
|
|
50
|
+
const title = g.append("text").attr("x", 0).attr("y", getConfig().state.titleShift).attr("font-size", getConfig().state.fontSize).attr("class", "state-title").text(stateDef.id);
|
|
51
|
+
const titleBox = title.node().getBBox();
|
|
52
|
+
const titleWidth = titleBox.width + dblPad;
|
|
53
|
+
let width = Math.max(titleWidth, orgWidth);
|
|
54
|
+
if (width === orgWidth) {
|
|
55
|
+
width = width + dblPad;
|
|
56
|
+
}
|
|
57
|
+
let startX;
|
|
58
|
+
const graphBox = g.node().getBBox();
|
|
59
|
+
if (stateDef.doc)
|
|
60
|
+
;
|
|
61
|
+
startX = orgX - pad;
|
|
62
|
+
if (titleWidth > orgWidth) {
|
|
63
|
+
startX = (orgWidth - width) / 2 + pad;
|
|
64
|
+
}
|
|
65
|
+
if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) {
|
|
66
|
+
startX = orgX - (titleWidth - orgWidth) / 2;
|
|
67
|
+
}
|
|
68
|
+
const lineY = 1 - getConfig().state.textHeight;
|
|
69
|
+
g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr(
|
|
70
|
+
"height",
|
|
71
|
+
graphBox.height + getConfig().state.textHeight + getConfig().state.titleShift + 1
|
|
72
|
+
).attr("rx", "0");
|
|
73
|
+
title.attr("x", startX + pad);
|
|
74
|
+
if (titleWidth <= orgWidth) {
|
|
75
|
+
title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad);
|
|
76
|
+
}
|
|
77
|
+
g.insert("rect", ":first-child").attr("x", startX).attr(
|
|
78
|
+
"y",
|
|
79
|
+
getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding
|
|
80
|
+
).attr("width", width).attr("height", getConfig().state.textHeight * 3).attr("rx", getConfig().state.radius);
|
|
81
|
+
g.insert("rect", ":first-child").attr("x", startX).attr(
|
|
82
|
+
"y",
|
|
83
|
+
getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding
|
|
84
|
+
).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig().state.textHeight).attr("rx", getConfig().state.radius);
|
|
85
|
+
return g;
|
|
86
|
+
};
|
|
87
|
+
const drawEndState = (g) => {
|
|
88
|
+
g.append("circle").attr("class", "end-state-outer").attr("r", getConfig().state.sizeUnit + getConfig().state.miniPadding).attr(
|
|
89
|
+
"cx",
|
|
90
|
+
getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding
|
|
91
|
+
).attr(
|
|
92
|
+
"cy",
|
|
93
|
+
getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding
|
|
94
|
+
);
|
|
95
|
+
return g.append("circle").attr("class", "end-state-inner").attr("r", getConfig().state.sizeUnit).attr("cx", getConfig().state.padding + getConfig().state.sizeUnit + 2).attr("cy", getConfig().state.padding + getConfig().state.sizeUnit + 2);
|
|
96
|
+
};
|
|
97
|
+
const drawForkJoinState = (g, stateDef) => {
|
|
98
|
+
let width = getConfig().state.forkWidth;
|
|
99
|
+
let height = getConfig().state.forkHeight;
|
|
100
|
+
if (stateDef.parentId) {
|
|
101
|
+
let tmp = width;
|
|
102
|
+
width = height;
|
|
103
|
+
height = tmp;
|
|
104
|
+
}
|
|
105
|
+
return g.append("rect").style("stroke", "black").style("fill", "black").attr("width", width).attr("height", height).attr("x", getConfig().state.padding).attr("y", getConfig().state.padding);
|
|
106
|
+
};
|
|
107
|
+
const _drawLongText = (_text, x, y, g) => {
|
|
108
|
+
let textHeight = 0;
|
|
109
|
+
const textElem = g.append("text");
|
|
110
|
+
textElem.style("text-anchor", "start");
|
|
111
|
+
textElem.attr("class", "noteText");
|
|
112
|
+
let text = _text.replace(/\r\n/g, "<br/>");
|
|
113
|
+
text = text.replace(/\n/g, "<br/>");
|
|
114
|
+
const lines = text.split(common$1.lineBreakRegex);
|
|
115
|
+
let tHeight = 1.25 * getConfig().state.noteMargin;
|
|
116
|
+
for (const line2 of lines) {
|
|
117
|
+
const txt = line2.trim();
|
|
118
|
+
if (txt.length > 0) {
|
|
119
|
+
const span = textElem.append("tspan");
|
|
120
|
+
span.text(txt);
|
|
121
|
+
if (tHeight === 0) {
|
|
122
|
+
const textBounds = span.node().getBBox();
|
|
123
|
+
tHeight += textBounds.height;
|
|
124
|
+
}
|
|
125
|
+
textHeight += tHeight;
|
|
126
|
+
span.attr("x", x + getConfig().state.noteMargin);
|
|
127
|
+
span.attr("y", y + textHeight + 1.25 * getConfig().state.noteMargin);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return { textWidth: textElem.node().getBBox().width, textHeight };
|
|
131
|
+
};
|
|
132
|
+
const drawNote = (text, g) => {
|
|
133
|
+
g.attr("class", "state-note");
|
|
134
|
+
const note = g.append("rect").attr("x", 0).attr("y", getConfig().state.padding);
|
|
135
|
+
const rectElem = g.append("g");
|
|
136
|
+
const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
|
|
137
|
+
note.attr("height", textHeight + 2 * getConfig().state.noteMargin);
|
|
138
|
+
note.attr("width", textWidth + getConfig().state.noteMargin * 2);
|
|
139
|
+
return note;
|
|
140
|
+
};
|
|
141
|
+
const drawState = function(elem, stateDef) {
|
|
142
|
+
const id = stateDef.id;
|
|
143
|
+
const stateInfo = {
|
|
144
|
+
id,
|
|
145
|
+
label: stateDef.id,
|
|
146
|
+
width: 0,
|
|
147
|
+
height: 0
|
|
148
|
+
};
|
|
149
|
+
const g = elem.append("g").attr("id", id).attr("class", "stateGroup");
|
|
150
|
+
if (stateDef.type === "start") {
|
|
151
|
+
drawStartState(g);
|
|
152
|
+
}
|
|
153
|
+
if (stateDef.type === "end") {
|
|
154
|
+
drawEndState(g);
|
|
155
|
+
}
|
|
156
|
+
if (stateDef.type === "fork" || stateDef.type === "join") {
|
|
157
|
+
drawForkJoinState(g, stateDef);
|
|
158
|
+
}
|
|
159
|
+
if (stateDef.type === "note") {
|
|
160
|
+
drawNote(stateDef.note.text, g);
|
|
161
|
+
}
|
|
162
|
+
if (stateDef.type === "divider") {
|
|
163
|
+
drawDivider(g);
|
|
164
|
+
}
|
|
165
|
+
if (stateDef.type === "default" && stateDef.descriptions.length === 0) {
|
|
166
|
+
drawSimpleState(g, stateDef);
|
|
167
|
+
}
|
|
168
|
+
if (stateDef.type === "default" && stateDef.descriptions.length > 0) {
|
|
169
|
+
drawDescrState(g, stateDef);
|
|
170
|
+
}
|
|
171
|
+
const stateBox = g.node().getBBox();
|
|
172
|
+
stateInfo.width = stateBox.width + 2 * getConfig().state.padding;
|
|
173
|
+
stateInfo.height = stateBox.height + 2 * getConfig().state.padding;
|
|
174
|
+
return stateInfo;
|
|
175
|
+
};
|
|
176
|
+
let edgeCount = 0;
|
|
177
|
+
const drawEdge = function(elem, path, relation) {
|
|
178
|
+
const getRelationType = function(type) {
|
|
179
|
+
switch (type) {
|
|
180
|
+
case db.relationType.AGGREGATION:
|
|
181
|
+
return "aggregation";
|
|
182
|
+
case db.relationType.EXTENSION:
|
|
183
|
+
return "extension";
|
|
184
|
+
case db.relationType.COMPOSITION:
|
|
185
|
+
return "composition";
|
|
186
|
+
case db.relationType.DEPENDENCY:
|
|
187
|
+
return "dependency";
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
path.points = path.points.filter((p) => !Number.isNaN(p.y));
|
|
191
|
+
const lineData = path.points;
|
|
192
|
+
const lineFunction = line().x(function(d) {
|
|
193
|
+
return d.x;
|
|
194
|
+
}).y(function(d) {
|
|
195
|
+
return d.y;
|
|
196
|
+
}).curve(curveBasis);
|
|
197
|
+
const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition");
|
|
198
|
+
let url = "";
|
|
199
|
+
if (getConfig().state.arrowMarkerAbsolute) {
|
|
200
|
+
url = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search;
|
|
201
|
+
url = url.replace(/\(/g, "\\(");
|
|
202
|
+
url = url.replace(/\)/g, "\\)");
|
|
203
|
+
}
|
|
204
|
+
svgPath.attr(
|
|
205
|
+
"marker-end",
|
|
206
|
+
"url(" + url + "#" + getRelationType(db.relationType.DEPENDENCY) + "End)"
|
|
207
|
+
);
|
|
208
|
+
if (relation.title !== void 0) {
|
|
209
|
+
const label = elem.append("g").attr("class", "stateLabel");
|
|
210
|
+
const { x, y } = utils.calcLabelPosition(path.points);
|
|
211
|
+
const rows = common$1.getRows(relation.title);
|
|
212
|
+
let titleHeight = 0;
|
|
213
|
+
const titleRows = [];
|
|
214
|
+
let maxWidth = 0;
|
|
215
|
+
let minX = 0;
|
|
216
|
+
for (let i = 0; i <= rows.length; i++) {
|
|
217
|
+
const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight);
|
|
218
|
+
const boundsTmp = title.node().getBBox();
|
|
219
|
+
maxWidth = Math.max(maxWidth, boundsTmp.width);
|
|
220
|
+
minX = Math.min(minX, boundsTmp.x);
|
|
221
|
+
log$1.info(boundsTmp.x, x, y + titleHeight);
|
|
222
|
+
if (titleHeight === 0) {
|
|
223
|
+
const titleBox = title.node().getBBox();
|
|
224
|
+
titleHeight = titleBox.height;
|
|
225
|
+
log$1.info("Title height", titleHeight, y);
|
|
226
|
+
}
|
|
227
|
+
titleRows.push(title);
|
|
228
|
+
}
|
|
229
|
+
let boxHeight = titleHeight * rows.length;
|
|
230
|
+
if (rows.length > 1) {
|
|
231
|
+
const heightAdj = (rows.length - 1) * titleHeight * 0.5;
|
|
232
|
+
titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj));
|
|
233
|
+
boxHeight = titleHeight * rows.length;
|
|
234
|
+
}
|
|
235
|
+
const bounds = label.node().getBBox();
|
|
236
|
+
label.insert("rect", ":first-child").attr("class", "box").attr("x", x - maxWidth / 2 - getConfig().state.padding / 2).attr("y", y - boxHeight / 2 - getConfig().state.padding / 2 - 3.5).attr("width", maxWidth + getConfig().state.padding).attr("height", boxHeight + getConfig().state.padding);
|
|
237
|
+
log$1.info(bounds);
|
|
238
|
+
}
|
|
239
|
+
edgeCount++;
|
|
240
|
+
};
|
|
241
|
+
let conf;
|
|
242
|
+
const transformationLog = {};
|
|
243
|
+
const setConf = function() {
|
|
244
|
+
};
|
|
245
|
+
const insertMarkers = function(elem) {
|
|
246
|
+
elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z");
|
|
247
|
+
};
|
|
248
|
+
const draw = function(text, id, _version, diagObj) {
|
|
249
|
+
conf = getConfig().state;
|
|
250
|
+
const securityLevel = getConfig().securityLevel;
|
|
251
|
+
let sandboxElement;
|
|
252
|
+
if (securityLevel === "sandbox") {
|
|
253
|
+
sandboxElement = select("#i" + id);
|
|
254
|
+
}
|
|
255
|
+
const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
|
|
256
|
+
const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
|
|
257
|
+
log$1.debug("Rendering diagram " + text);
|
|
258
|
+
const diagram2 = root.select(`[id='${id}']`);
|
|
259
|
+
insertMarkers(diagram2);
|
|
260
|
+
const rootDoc = diagObj.db.getRootDoc();
|
|
261
|
+
renderDoc(rootDoc, diagram2, void 0, false, root, doc, diagObj);
|
|
262
|
+
const padding = conf.padding;
|
|
263
|
+
const bounds = diagram2.node().getBBox();
|
|
264
|
+
const width = bounds.width + padding * 2;
|
|
265
|
+
const height = bounds.height + padding * 2;
|
|
266
|
+
const svgWidth = width * 1.75;
|
|
267
|
+
configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth);
|
|
268
|
+
diagram2.attr(
|
|
269
|
+
"viewBox",
|
|
270
|
+
`${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height
|
|
271
|
+
);
|
|
272
|
+
};
|
|
273
|
+
const getLabelWidth = (text) => {
|
|
274
|
+
return text ? text.length * conf.fontSizeFactor : 1;
|
|
275
|
+
};
|
|
276
|
+
const renderDoc = (doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => {
|
|
277
|
+
const graph = new Graph({
|
|
278
|
+
compound: true,
|
|
279
|
+
multigraph: true
|
|
280
|
+
});
|
|
281
|
+
let i;
|
|
282
|
+
let edgeFreeDoc = true;
|
|
283
|
+
for (i = 0; i < doc.length; i++) {
|
|
284
|
+
if (doc[i].stmt === "relation") {
|
|
285
|
+
edgeFreeDoc = false;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (parentId) {
|
|
290
|
+
graph.setGraph({
|
|
291
|
+
rankdir: "LR",
|
|
292
|
+
multigraph: true,
|
|
293
|
+
compound: true,
|
|
294
|
+
// acyclicer: 'greedy',
|
|
295
|
+
ranker: "tight-tree",
|
|
296
|
+
ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
|
|
297
|
+
nodeSep: edgeFreeDoc ? 1 : 50,
|
|
298
|
+
isMultiGraph: true
|
|
299
|
+
// ranksep: 5,
|
|
300
|
+
// nodesep: 1
|
|
301
|
+
});
|
|
302
|
+
} else {
|
|
303
|
+
graph.setGraph({
|
|
304
|
+
rankdir: "TB",
|
|
305
|
+
multigraph: true,
|
|
306
|
+
compound: true,
|
|
307
|
+
// isCompound: true,
|
|
308
|
+
// acyclicer: 'greedy',
|
|
309
|
+
// ranker: 'longest-path'
|
|
310
|
+
ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
|
|
311
|
+
nodeSep: edgeFreeDoc ? 1 : 50,
|
|
312
|
+
ranker: "tight-tree",
|
|
313
|
+
// ranker: 'network-simplex'
|
|
314
|
+
isMultiGraph: true
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
graph.setDefaultEdgeLabel(function() {
|
|
318
|
+
return {};
|
|
319
|
+
});
|
|
320
|
+
diagObj.db.extract(doc);
|
|
321
|
+
const states = diagObj.db.getStates();
|
|
322
|
+
const relations = diagObj.db.getRelations();
|
|
323
|
+
const keys2 = Object.keys(states);
|
|
324
|
+
for (const key of keys2) {
|
|
325
|
+
const stateDef = states[key];
|
|
326
|
+
if (parentId) {
|
|
327
|
+
stateDef.parentId = parentId;
|
|
328
|
+
}
|
|
329
|
+
let node;
|
|
330
|
+
if (stateDef.doc) {
|
|
331
|
+
let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup");
|
|
332
|
+
node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj);
|
|
333
|
+
{
|
|
334
|
+
sub = addTitleAndBox(sub, stateDef, altBkg);
|
|
335
|
+
let boxBounds = sub.node().getBBox();
|
|
336
|
+
node.width = boxBounds.width;
|
|
337
|
+
node.height = boxBounds.height + conf.padding / 2;
|
|
338
|
+
transformationLog[stateDef.id] = { y: conf.compositTitleSize };
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
node = drawState(diagram2, stateDef);
|
|
342
|
+
}
|
|
343
|
+
if (stateDef.note) {
|
|
344
|
+
const noteDef = {
|
|
345
|
+
descriptions: [],
|
|
346
|
+
id: stateDef.id + "-note",
|
|
347
|
+
note: stateDef.note,
|
|
348
|
+
type: "note"
|
|
349
|
+
};
|
|
350
|
+
const note = drawState(diagram2, noteDef);
|
|
351
|
+
if (stateDef.note.position === "left of") {
|
|
352
|
+
graph.setNode(node.id + "-note", note);
|
|
353
|
+
graph.setNode(node.id, node);
|
|
354
|
+
} else {
|
|
355
|
+
graph.setNode(node.id, node);
|
|
356
|
+
graph.setNode(node.id + "-note", note);
|
|
357
|
+
}
|
|
358
|
+
graph.setParent(node.id, node.id + "-group");
|
|
359
|
+
graph.setParent(node.id + "-note", node.id + "-group");
|
|
360
|
+
} else {
|
|
361
|
+
graph.setNode(node.id, node);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
log$1.debug("Count=", graph.nodeCount(), graph);
|
|
365
|
+
let cnt = 0;
|
|
366
|
+
relations.forEach(function(relation) {
|
|
367
|
+
cnt++;
|
|
368
|
+
log$1.debug("Setting edge", relation);
|
|
369
|
+
graph.setEdge(
|
|
370
|
+
relation.id1,
|
|
371
|
+
relation.id2,
|
|
372
|
+
{
|
|
373
|
+
relation,
|
|
374
|
+
width: getLabelWidth(relation.title),
|
|
375
|
+
height: conf.labelHeight * common$1.getRows(relation.title).length,
|
|
376
|
+
labelpos: "c"
|
|
377
|
+
},
|
|
378
|
+
"id" + cnt
|
|
379
|
+
);
|
|
380
|
+
});
|
|
381
|
+
layout(graph);
|
|
382
|
+
log$1.debug("Graph after layout", graph.nodes());
|
|
383
|
+
const svgElem = diagram2.node();
|
|
384
|
+
graph.nodes().forEach(function(v) {
|
|
385
|
+
if (v !== void 0 && graph.node(v) !== void 0) {
|
|
386
|
+
log$1.warn("Node " + v + ": " + JSON.stringify(graph.node(v)));
|
|
387
|
+
root.select("#" + svgElem.id + " #" + v).attr(
|
|
388
|
+
"transform",
|
|
389
|
+
"translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y + (transformationLog[v] ? transformationLog[v].y : 0) - graph.node(v).height / 2) + " )"
|
|
390
|
+
);
|
|
391
|
+
root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2);
|
|
392
|
+
const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider");
|
|
393
|
+
dividers.forEach((divider) => {
|
|
394
|
+
const parent = divider.parentElement;
|
|
395
|
+
let pWidth = 0;
|
|
396
|
+
let pShift = 0;
|
|
397
|
+
if (parent) {
|
|
398
|
+
if (parent.parentElement) {
|
|
399
|
+
pWidth = parent.parentElement.getBBox().width;
|
|
400
|
+
}
|
|
401
|
+
pShift = parseInt(parent.getAttribute("data-x-shift"), 10);
|
|
402
|
+
if (Number.isNaN(pShift)) {
|
|
403
|
+
pShift = 0;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
divider.setAttribute("x1", 0 - pShift + 8);
|
|
407
|
+
divider.setAttribute("x2", pWidth - pShift - 8);
|
|
408
|
+
});
|
|
409
|
+
} else {
|
|
410
|
+
log$1.debug("No Node " + v + ": " + JSON.stringify(graph.node(v)));
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
let stateBox = svgElem.getBBox();
|
|
414
|
+
graph.edges().forEach(function(e) {
|
|
415
|
+
if (e !== void 0 && graph.edge(e) !== void 0) {
|
|
416
|
+
log$1.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
|
|
417
|
+
drawEdge(diagram2, graph.edge(e), graph.edge(e).relation);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
stateBox = svgElem.getBBox();
|
|
421
|
+
const stateInfo = {
|
|
422
|
+
id: parentId ? parentId : "root",
|
|
423
|
+
label: parentId ? parentId : "root",
|
|
424
|
+
width: 0,
|
|
425
|
+
height: 0
|
|
426
|
+
};
|
|
427
|
+
stateInfo.width = stateBox.width + 2 * conf.padding;
|
|
428
|
+
stateInfo.height = stateBox.height + 2 * conf.padding;
|
|
429
|
+
log$1.debug("Doc rendered", stateInfo, graph);
|
|
430
|
+
return stateInfo;
|
|
431
|
+
};
|
|
432
|
+
const renderer = {
|
|
433
|
+
setConf,
|
|
434
|
+
draw
|
|
435
|
+
};
|
|
436
|
+
const diagram = {
|
|
437
|
+
parser: parser$1,
|
|
438
|
+
db,
|
|
439
|
+
renderer,
|
|
440
|
+
styles,
|
|
441
|
+
init: (cnf) => {
|
|
442
|
+
if (!cnf.state) {
|
|
443
|
+
cnf.state = {};
|
|
444
|
+
}
|
|
445
|
+
cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
|
|
446
|
+
db.clear();
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
export {
|
|
450
|
+
diagram
|
|
451
|
+
};
|