@layers-app/editor 0.3.11 → 0.4.1-progress-bar.2
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 +215 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +6 -6
- package/dist/layers.-81wcqwR.js +41 -0
- package/dist/layers.0GG-c34P.js +36 -0
- package/dist/layers.0dm3eLYv.js +1265 -0
- package/dist/layers.0nFmx-Nl.js +1 -0
- package/dist/layers.1Z2fyz6H.js +7 -0
- package/dist/layers.2b70kvMG.js +9 -0
- package/dist/layers.3Vvyhk66.js +904 -0
- package/dist/layers.475BZq-C.js +4 -0
- package/dist/layers.52famHy6.js +1 -0
- package/dist/layers.6F0lZyGr.js +1 -0
- package/dist/layers.6iBZ8vbZ.js +7 -0
- package/dist/layers.7JqFgE4-.js +15 -0
- package/dist/layers.7Q7ZqlHQ.js +1 -0
- package/dist/layers.9QK1wiQj.js +1 -0
- package/dist/layers.9pNaFvaX.js +1 -0
- package/dist/layers.AhhllI1F.js +1088 -0
- package/dist/layers.B0UW1RmX.js +10 -0
- package/dist/layers.B19hGmey.js +1 -0
- package/dist/layers.B1jSvo4Q.js +282 -0
- package/dist/layers.B2QmFAKW.js +1 -0
- package/dist/layers.B3D4g2HH.js +1 -0
- package/dist/layers.B4KbvY3e.js +2235 -0
- package/dist/layers.B4b5hMwb.js +40 -0
- package/dist/layers.B4kpLyJz.js +39 -0
- package/dist/layers.B6ZNsH3T.js +21763 -0
- package/dist/layers.B6_dw_8p.js +7 -0
- package/dist/layers.B7X5RC-0.js +41 -0
- package/dist/layers.B9u9oq3T.js +5 -0
- package/dist/layers.BALYUkwP.js +139 -0
- package/dist/layers.BAtv1CM7.js +1 -0
- package/dist/layers.BBJp9IW9.js +39 -0
- package/dist/layers.BChOvfAr.js +33 -0
- package/dist/layers.BE8bNWW6.js +423 -0
- package/dist/layers.BEfOaBAZ.js +8 -0
- package/dist/layers.BHRWU6d9.js +32 -0
- package/dist/layers.BIeVwYKL.js +1 -0
- package/dist/layers.BJHPodZD.js +5 -0
- package/dist/layers.BJml6l4c.js +1619 -0
- package/dist/layers.BP5yLKDB.js +40 -0
- package/dist/layers.BSTBZrFn.js +1 -0
- package/dist/layers.BXFaNlXe.js +10 -0
- package/dist/layers.BY2fzSoa.js +320 -0
- package/dist/layers.BZ9Uzt2l.js +52 -0
- package/dist/layers.BbCfEXyj.js +55 -0
- package/dist/layers.BcAVvZP0.js +8 -0
- package/dist/layers.BddeOe_0.js +41 -0
- package/dist/layers.Bde9z6ba.js +9 -0
- package/dist/layers.Bdvy9kzf.js +37 -0
- package/dist/layers.Bf9MFDYo.js +37 -0
- package/dist/layers.BgOa2ZQq.js +7 -0
- package/dist/layers.BglhCs7Q.js +42 -0
- package/dist/layers.BhHN_OCL.js +41 -0
- package/dist/layers.BhOVSyoa.js +116 -0
- package/dist/layers.BiJ8hfRt.js +1510 -0
- package/dist/layers.Bk6BXLzz.js +425 -0
- package/dist/layers.Bm9nXP7b.js +4 -0
- package/dist/layers.BncZBAFy.js +4 -0
- package/dist/layers.BpilXLfW.js +6 -0
- package/dist/{layers.YZkXZvVS.js → layers.Bq-5GZP6.js} +20995 -19802
- package/dist/layers.BtlLD-Rz.js +11 -0
- package/dist/layers.BtpIOF4Z.js +9 -0
- package/dist/layers.Bu56Qesy.js +10 -0
- package/dist/layers.BxIw0gJL.js +11 -0
- package/dist/layers.ByYR4L98.js +8 -0
- package/dist/layers.C-pbN-0O.js +34 -0
- package/dist/layers.C0DJ9ilm.js +1 -0
- package/dist/layers.C0Lgw_Sx.js +11688 -0
- package/dist/layers.C2gAR4en.js +6 -0
- package/dist/layers.C4ceUEtT.js +6 -0
- package/dist/layers.C5RRQdrQ.js +39 -0
- package/dist/layers.C5U5RNdV.js +38 -0
- package/dist/layers.C5hVV8XE.js +10 -0
- package/dist/layers.C6jxjtyC.js +8 -0
- package/dist/layers.C7lIplJU.js +247 -0
- package/dist/layers.C83RWXIj.js +2966 -0
- package/dist/layers.C8_lu5UH.js +23 -0
- package/dist/layers.C9yHqpLC.js +1 -0
- package/dist/layers.CATiNc07.js +37 -0
- package/dist/layers.CCoKbqGZ.js +32 -0
- package/dist/layers.CCwQVeNG.js +96 -0
- package/dist/layers.CG1igXgx.js +65 -0
- package/dist/layers.CGE7HTrP.js +790 -0
- package/dist/layers.CGmH2sSj.js +160 -0
- package/dist/layers.CHZsXQcr.js +1 -0
- package/dist/layers.CJWyW1s7.js +33 -0
- package/dist/layers.CK2uPIaB.js +9 -0
- package/dist/layers.CKVT6drc.js +6 -0
- package/dist/layers.COAF7f8g.js +1 -0
- package/dist/layers.COS6XeQZ.js +8 -0
- package/dist/layers.CP5YFYP0.js +185 -0
- package/dist/layers.CQefO3zC.js +960 -0
- package/dist/layers.CRMWsjPz.js +6 -0
- package/dist/layers.CXXPElSu.js +40 -0
- package/dist/layers.CZ9XE70C.js +10 -0
- package/dist/layers.CZtDXioS.js +44 -0
- package/dist/layers.C_BxYlPZ.js +1580 -0
- package/dist/layers.C_UcfwnG.js +6 -0
- package/dist/layers.CaLgCU_I.js +32 -0
- package/dist/layers.CavVjyC7.js +32 -0
- package/dist/layers.Cd4UYQEy.js +5 -0
- package/dist/layers.CeERe4hA.js +803 -0
- package/dist/layers.CgTtEOpk.js +2479 -0
- package/dist/layers.CgYKHJl1.js +437 -0
- package/dist/layers.Cgmo79x3.js +11 -0
- package/dist/layers.CjMeAmJX.js +1034 -0
- package/dist/layers.Ck0n4XD7.js +1 -0
- package/dist/layers.CkJ9q_L1.js +1 -0
- package/dist/layers.Cl-Lwb04.js +8 -0
- package/dist/layers.CnZce7UZ.js +59 -0
- package/dist/layers.Co5PaFBV.js +257 -0
- package/dist/layers.CoC4j3uL.js +230 -0
- package/dist/layers.CopJUlxy.js +42 -0
- package/dist/layers.Cp-0WnDT.js +122 -0
- package/dist/layers.Cpwze_cl.js +40 -0
- package/dist/layers.CqVTtuYm.js +6 -0
- package/dist/layers.CrqG-Duk.js +5 -0
- package/dist/layers.Crw1IGs-.js +42 -0
- package/dist/layers.CsPue_MQ.js +51 -0
- package/dist/layers.Cs_T7j-N.js +1283 -0
- package/dist/layers.CtLZ9mwp.js +2 -0
- package/dist/layers.CukiNGgZ.js +186 -0
- package/dist/layers.CvbXz5-5.js +39 -0
- package/dist/layers.CxjTeNJ7.js +40 -0
- package/dist/layers.Cxopck3h.js +13 -0
- package/dist/layers.CyE3jBBZ.js +1126 -0
- package/dist/layers.Cy_IG1Gv.js +7 -0
- package/dist/layers.Cz1nKHwt.js +7 -0
- package/dist/layers.CzRcgWY1.js +21938 -0
- package/dist/layers.D0CU4TN8.js +8 -0
- package/dist/layers.D0_MMsE9.js +42 -0
- package/dist/layers.D0zn4_Mx.js +1 -0
- package/dist/layers.D2U67Gni.js +9 -0
- package/dist/layers.D34e2jIm.js +2 -0
- package/dist/layers.D3QNp_mQ.js +40 -0
- package/dist/layers.D4ZUbUXz.js +10 -0
- package/dist/layers.D4fGb2cV.js +1272 -0
- package/dist/layers.D7Lv0jOC.js +39 -0
- package/dist/layers.D7jGxypv.js +8 -0
- package/dist/layers.DA80zVTT.js +32 -0
- package/dist/layers.DAhZhj49.js +220 -0
- package/dist/layers.DC76pGI6.js +36 -0
- package/dist/layers.DCm28WHr.js +1 -0
- package/dist/layers.DEBlIxtT.js +1 -0
- package/dist/layers.DEHlDscq.js +8 -0
- package/dist/layers.DEiI3uTS.js +1 -0
- package/dist/layers.DFO1fD9L.js +6 -0
- package/dist/layers.DFVmKOXm.js +118 -0
- package/dist/layers.DGgRL8Nc.js +39 -0
- package/dist/layers.DHpypOQI.js +84 -0
- package/dist/layers.DJLV698B.js +793 -0
- package/dist/layers.DKZkGAQ_.js +202 -0
- package/dist/layers.DKeh-lZI.js +1 -0
- package/dist/layers.DLB4eAfo.js +1089 -0
- package/dist/layers.DLRyMrlf.js +10 -0
- package/dist/layers.DLwuMfdd.js +84 -0
- package/dist/layers.DMkBISW1.js +1 -0
- package/dist/layers.DN9HoVxI.js +18 -0
- package/dist/layers.DND9ZxpV.js +40 -0
- package/dist/layers.DOYs_uMx.js +802 -0
- package/dist/layers.DOrgOHBr.js +1 -0
- package/dist/layers.DRGpaHAX.js +41 -0
- package/dist/layers.D_AP_tA5.js +9 -0
- package/dist/layers.D_MmQzRm.js +207 -0
- package/dist/layers.D_sfrDwe.js +70 -0
- package/dist/layers.DaUhvLRp.js +10 -0
- package/dist/layers.DaoO_UDV.js +9 -0
- package/dist/layers.DbaKVP5e.js +1 -0
- package/dist/layers.Dbdn8XSd.js +1 -0
- package/dist/layers.DfR442P5.js +40 -0
- package/dist/layers.DfoJ9Kxs.js +1 -0
- package/dist/layers.DgpXAlfL.js +373 -0
- package/dist/layers.Dh54vG6t.js +268 -0
- package/dist/layers.DhcjxJPA.js +501 -0
- package/dist/layers.DhzzXhmQ.js +1359 -0
- package/dist/layers.Dixyg94K.js +36 -0
- package/dist/layers.Dj3HYSyh.js +7 -0
- package/dist/layers.DjUOC4st.js +16 -0
- package/dist/layers.DkLyYgOg.js +38 -0
- package/dist/layers.DkT2sxcJ.js +931 -0
- package/dist/layers.DkleVc4L.js +5 -0
- package/dist/layers.DoAq7C3B.js +139 -0
- package/dist/layers.Dr3N180D.js +35 -0
- package/dist/layers.Drb2mcdd.js +2 -0
- package/dist/layers.DtDMtcjv.js +84 -0
- package/dist/layers.DtOlJEpj.js +39 -0
- package/dist/layers.Dut27cU5.js +42 -0
- package/dist/layers.Dx5j_aMV.js +7 -0
- package/dist/layers.DxA6ocdw.js +70 -0
- package/dist/layers.Dy-AuShh.js +9 -0
- package/dist/layers.Dy1naDTQ.js +14 -0
- package/dist/layers.DyJZaSCk.js +40 -0
- package/dist/layers.DyU8JNlG.js +41 -0
- package/dist/layers.DytwjiIF.js +8 -0
- package/dist/layers.DyyemvLl.js +36 -0
- package/dist/layers.DzphOPQJ.js +19 -0
- package/dist/layers.J1ihPiBi.js +7 -0
- package/dist/layers.JWCLFILJ.js +1 -0
- package/dist/layers.JcQwzHu2.js +9 -0
- package/dist/layers.JnLVZ-1W.js +61 -0
- package/dist/layers.MfBuwYip.js +39 -0
- package/dist/layers.OMZyjZaa.js +1 -0
- package/dist/layers.OZhDjtkp.js +1 -0
- package/dist/layers.SNwJ50Yh.js +769 -0
- package/dist/layers.X930Wyd9.js +9 -0
- package/dist/layers.YBnRzjtX.js +1 -0
- package/dist/{layers.BnjxHNDK.js → layers.YE5h1RJ0.js} +84 -84
- package/dist/layers.YhDm2Yt0.js +37 -0
- package/dist/layers.ZE7W-HjF.js +10 -0
- package/dist/layers._ZR3qWqZ.js +41 -0
- package/dist/layers.b0h5ZBmD.js +61 -0
- package/dist/layers.b4ac2O9O.js +35 -0
- package/dist/layers.bzxdqd7a.js +11 -0
- package/dist/{layers.C125HTat.js → layers.fjeoVipI.js} +1 -1
- package/dist/layers.hEiS_6X7.js +1 -0
- package/dist/layers.hweLqW3I.js +261 -0
- package/dist/layers.iK5LSRjJ.js +11 -0
- package/dist/layers.ipZc_UQ4.js +8 -0
- package/dist/layers.itQhFK_P.js +48146 -0
- package/dist/layers.ix2kR4vq.js +9165 -0
- package/dist/layers.jLGyr7oL.js +3 -0
- package/dist/layers.k60iEoD4.js +41 -0
- package/dist/layers.l06k9Lu3.js +1 -0
- package/dist/layers.lCMwJpWR.js +4 -0
- package/dist/layers.lCpg7dOn.js +21 -0
- package/dist/layers.lPp5HcdT.js +40 -0
- package/dist/layers.lUeeFrHR.js +10 -0
- package/dist/layers.os9El-5G.js +39 -0
- package/dist/layers.pSPpASHH.js +35 -0
- package/dist/layers.s006AAsW.js +1 -0
- package/dist/layers.sFiVxDwP.js +1 -0
- package/dist/layers.sWO0agP4.js +295 -0
- package/dist/layers.tSiLqPQw.js +1 -0
- package/dist/layers.uZTzmOsK.js +38 -0
- package/dist/layers.uzGJX2RJ.js +14 -0
- package/dist/layers.vZPmwsoq.js +32 -0
- package/dist/layers.wBjmBWfX.js +1 -0
- package/package.json +33 -17
- package/dist/layers.Cjs5EBWM.js +0 -343
- package/dist/layers.DPccTctI.js +0 -285
- package/dist/layers.DZ8DrrVn.js +0 -53491
- package/dist/layers.QVaGPbs3.js +0 -161
- package/dist/layers.VK3NB7Nd.js +0 -1
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import * as v from "lodash-es";
|
|
2
|
+
import { l as M } from "./layers.D4fGb2cV.js";
|
|
3
|
+
import { G as U } from "./layers.C7lIplJU.js";
|
|
4
|
+
import { i as A, u as H, s as V, a as _, b as W, g as D, p as O, c as q, d as z, e as p, f as $, h as K, j as Q } from "./layers.AhhllI1F.js";
|
|
5
|
+
import { l as s, g as T, t as S, d as J } from "./layers.ix2kR4vq.js";
|
|
6
|
+
import { c as Y } from "./layers.C83RWXIj.js";
|
|
7
|
+
function m(e) {
|
|
8
|
+
var t = {
|
|
9
|
+
options: {
|
|
10
|
+
directed: e.isDirected(),
|
|
11
|
+
multigraph: e.isMultigraph(),
|
|
12
|
+
compound: e.isCompound()
|
|
13
|
+
},
|
|
14
|
+
nodes: Z(e),
|
|
15
|
+
edges: I(e)
|
|
16
|
+
};
|
|
17
|
+
return v.isUndefined(e.graph()) || (t.value = v.clone(e.graph())), t;
|
|
18
|
+
}
|
|
19
|
+
function Z(e) {
|
|
20
|
+
return v.map(e.nodes(), function(t) {
|
|
21
|
+
var n = e.node(t), r = e.parent(t), i = { v: t };
|
|
22
|
+
return v.isUndefined(n) || (i.value = n), v.isUndefined(r) || (i.parent = r), i;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function I(e) {
|
|
26
|
+
return v.map(e.edges(), function(t) {
|
|
27
|
+
var n = e.edge(t), r = { v: t.v, w: t.w };
|
|
28
|
+
return v.isUndefined(t.name) || (r.name = t.name), v.isUndefined(n) || (r.value = n), r;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
let l = {}, g = {}, L = {};
|
|
32
|
+
const tt = () => {
|
|
33
|
+
g = {}, L = {}, l = {};
|
|
34
|
+
}, B = (e, t) => (s.trace("In isDescendant", t, " ", e, " = ", g[t].includes(e)), !!g[t].includes(e)), et = (e, t) => (s.info("Descendants of ", t, " is ", g[t]), s.info("Edge is ", e), e.v === t || e.w === t ? !1 : g[t] ? g[t].includes(e.v) || B(e.v, t) || B(e.w, t) || g[t].includes(e.w) : (s.debug("Tilt, ", t, ",not in descendants"), !1)), R = (e, t, n, r) => {
|
|
35
|
+
s.warn(
|
|
36
|
+
"Copying children of ",
|
|
37
|
+
e,
|
|
38
|
+
"root",
|
|
39
|
+
r,
|
|
40
|
+
"data",
|
|
41
|
+
t.node(e),
|
|
42
|
+
r
|
|
43
|
+
);
|
|
44
|
+
const i = t.children(e) || [];
|
|
45
|
+
e !== r && i.push(e), s.warn("Copying (nodes) clusterId", e, "nodes", i), i.forEach((a) => {
|
|
46
|
+
if (t.children(a).length > 0)
|
|
47
|
+
R(a, t, n, r);
|
|
48
|
+
else {
|
|
49
|
+
const d = t.node(a);
|
|
50
|
+
s.info("cp ", a, " to ", r, " with parent ", e), n.setNode(a, d), r !== t.parent(a) && (s.warn("Setting parent", a, t.parent(a)), n.setParent(a, t.parent(a))), e !== r && a !== e ? (s.debug("Setting parent", a, e), n.setParent(a, e)) : (s.info("In copy ", e, "root", r, "data", t.node(e), r), s.debug(
|
|
51
|
+
"Not Setting parent for node=",
|
|
52
|
+
a,
|
|
53
|
+
"cluster!==rootId",
|
|
54
|
+
e !== r,
|
|
55
|
+
"node!==clusterId",
|
|
56
|
+
a !== e
|
|
57
|
+
));
|
|
58
|
+
const u = t.edges(a);
|
|
59
|
+
s.debug("Copying Edges", u), u.forEach((f) => {
|
|
60
|
+
s.info("Edge", f);
|
|
61
|
+
const h = t.edge(f.v, f.w, f.name);
|
|
62
|
+
s.info("Edge data", h, r);
|
|
63
|
+
try {
|
|
64
|
+
et(f, r) ? (s.info("Copying as ", f.v, f.w, h, f.name), n.setEdge(f.v, f.w, h, f.name), s.info("newGraph edges ", n.edges(), n.edge(n.edges()[0]))) : s.info(
|
|
65
|
+
"Skipping copy of edge ",
|
|
66
|
+
f.v,
|
|
67
|
+
"-->",
|
|
68
|
+
f.w,
|
|
69
|
+
" rootId: ",
|
|
70
|
+
r,
|
|
71
|
+
" clusterId:",
|
|
72
|
+
e
|
|
73
|
+
);
|
|
74
|
+
} catch (w) {
|
|
75
|
+
s.error(w);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
s.debug("Removing node", a), t.removeNode(a);
|
|
80
|
+
});
|
|
81
|
+
}, P = (e, t) => {
|
|
82
|
+
const n = t.children(e);
|
|
83
|
+
let r = [...n];
|
|
84
|
+
for (const i of n)
|
|
85
|
+
L[i] = e, r = [...r, ...P(i, t)];
|
|
86
|
+
return r;
|
|
87
|
+
}, C = (e, t) => {
|
|
88
|
+
s.trace("Searching", e);
|
|
89
|
+
const n = t.children(e);
|
|
90
|
+
if (s.trace("Searching children of id ", e, n), n.length < 1)
|
|
91
|
+
return s.trace("This is a valid node", e), e;
|
|
92
|
+
for (const r of n) {
|
|
93
|
+
const i = C(r, t);
|
|
94
|
+
if (i)
|
|
95
|
+
return s.trace("Found replacement for", e, " => ", i), i;
|
|
96
|
+
}
|
|
97
|
+
}, X = (e) => !l[e] || !l[e].externalConnections ? e : l[e] ? l[e].id : e, nt = (e, t) => {
|
|
98
|
+
if (!e || t > 10) {
|
|
99
|
+
s.debug("Opting out, no graph ");
|
|
100
|
+
return;
|
|
101
|
+
} else
|
|
102
|
+
s.debug("Opting in, graph ");
|
|
103
|
+
e.nodes().forEach(function(n) {
|
|
104
|
+
e.children(n).length > 0 && (s.warn(
|
|
105
|
+
"Cluster identified",
|
|
106
|
+
n,
|
|
107
|
+
" Replacement id in edges: ",
|
|
108
|
+
C(n, e)
|
|
109
|
+
), g[n] = P(n, e), l[n] = { id: C(n, e), clusterData: e.node(n) });
|
|
110
|
+
}), e.nodes().forEach(function(n) {
|
|
111
|
+
const r = e.children(n), i = e.edges();
|
|
112
|
+
r.length > 0 ? (s.debug("Cluster identified", n, g), i.forEach((a) => {
|
|
113
|
+
if (a.v !== n && a.w !== n) {
|
|
114
|
+
const d = B(a.v, n), u = B(a.w, n);
|
|
115
|
+
d ^ u && (s.warn("Edge: ", a, " leaves cluster ", n), s.warn("Descendants of XXX ", n, ": ", g[n]), l[n].externalConnections = !0);
|
|
116
|
+
}
|
|
117
|
+
})) : s.debug("Not a cluster ", n, g);
|
|
118
|
+
});
|
|
119
|
+
for (let n of Object.keys(l)) {
|
|
120
|
+
const r = l[n].id, i = e.parent(r);
|
|
121
|
+
i !== n && l[i] && !l[i].externalConnections && (l[n].id = i);
|
|
122
|
+
}
|
|
123
|
+
e.edges().forEach(function(n) {
|
|
124
|
+
const r = e.edge(n);
|
|
125
|
+
s.warn("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(n)), s.warn("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(e.edge(n)));
|
|
126
|
+
let i = n.v, a = n.w;
|
|
127
|
+
if (s.warn(
|
|
128
|
+
"Fix XXX",
|
|
129
|
+
l,
|
|
130
|
+
"ids:",
|
|
131
|
+
n.v,
|
|
132
|
+
n.w,
|
|
133
|
+
"Translating: ",
|
|
134
|
+
l[n.v],
|
|
135
|
+
" --- ",
|
|
136
|
+
l[n.w]
|
|
137
|
+
), l[n.v] && l[n.w] && l[n.v] === l[n.w]) {
|
|
138
|
+
s.warn("Fixing and trixing link to self - removing XXX", n.v, n.w, n.name), s.warn("Fixing and trixing - removing XXX", n.v, n.w, n.name), i = X(n.v), a = X(n.w), e.removeEdge(n.v, n.w, n.name);
|
|
139
|
+
const d = n.w + "---" + n.v;
|
|
140
|
+
e.setNode(d, {
|
|
141
|
+
domId: d,
|
|
142
|
+
id: d,
|
|
143
|
+
labelStyle: "",
|
|
144
|
+
labelText: r.label,
|
|
145
|
+
padding: 0,
|
|
146
|
+
shape: "labelRect",
|
|
147
|
+
style: ""
|
|
148
|
+
});
|
|
149
|
+
const u = structuredClone(r), f = structuredClone(r);
|
|
150
|
+
u.label = "", u.arrowTypeEnd = "none", f.label = "", u.fromCluster = n.v, f.toCluster = n.v, e.setEdge(i, d, u, n.name + "-cyclic-special"), e.setEdge(d, a, f, n.name + "-cyclic-special");
|
|
151
|
+
} else if (l[n.v] || l[n.w]) {
|
|
152
|
+
if (s.warn("Fixing and trixing - removing XXX", n.v, n.w, n.name), i = X(n.v), a = X(n.w), e.removeEdge(n.v, n.w, n.name), i !== n.v) {
|
|
153
|
+
const d = e.parent(i);
|
|
154
|
+
l[d].externalConnections = !0, r.fromCluster = n.v;
|
|
155
|
+
}
|
|
156
|
+
if (a !== n.w) {
|
|
157
|
+
const d = e.parent(a);
|
|
158
|
+
l[d].externalConnections = !0, r.toCluster = n.w;
|
|
159
|
+
}
|
|
160
|
+
s.warn("Fix Replacing with XXX", i, a, n.name), e.setEdge(i, a, r, n.name);
|
|
161
|
+
}
|
|
162
|
+
}), s.warn("Adjusted Graph", m(e)), k(e, 0), s.trace(l);
|
|
163
|
+
}, k = (e, t) => {
|
|
164
|
+
if (s.warn("extractor - ", t, m(e), e.children("D")), t > 10) {
|
|
165
|
+
s.error("Bailing out");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
let n = e.nodes(), r = !1;
|
|
169
|
+
for (const i of n) {
|
|
170
|
+
const a = e.children(i);
|
|
171
|
+
r = r || a.length > 0;
|
|
172
|
+
}
|
|
173
|
+
if (!r) {
|
|
174
|
+
s.debug("Done, no node has children", e.nodes());
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
s.debug("Nodes = ", n, t);
|
|
178
|
+
for (const i of n)
|
|
179
|
+
if (s.debug(
|
|
180
|
+
"Extracting node",
|
|
181
|
+
i,
|
|
182
|
+
l,
|
|
183
|
+
l[i] && !l[i].externalConnections,
|
|
184
|
+
!e.parent(i),
|
|
185
|
+
e.node(i),
|
|
186
|
+
e.children("D"),
|
|
187
|
+
" Depth ",
|
|
188
|
+
t
|
|
189
|
+
), !l[i])
|
|
190
|
+
s.debug("Not a cluster", i, t);
|
|
191
|
+
else if (!l[i].externalConnections && // !graph.parent(node) &&
|
|
192
|
+
e.children(i) && e.children(i).length > 0) {
|
|
193
|
+
s.warn(
|
|
194
|
+
"Cluster without external connections, without a parent and with children",
|
|
195
|
+
i,
|
|
196
|
+
t
|
|
197
|
+
);
|
|
198
|
+
let d = e.graph().rankdir === "TB" ? "LR" : "TB";
|
|
199
|
+
l[i] && l[i].clusterData && l[i].clusterData.dir && (d = l[i].clusterData.dir, s.warn("Fixing dir", l[i].clusterData.dir, d));
|
|
200
|
+
const u = new U({
|
|
201
|
+
multigraph: !0,
|
|
202
|
+
compound: !0
|
|
203
|
+
}).setGraph({
|
|
204
|
+
rankdir: d,
|
|
205
|
+
// Todo: set proper spacing
|
|
206
|
+
nodesep: 50,
|
|
207
|
+
ranksep: 50,
|
|
208
|
+
marginx: 8,
|
|
209
|
+
marginy: 8
|
|
210
|
+
}).setDefaultEdgeLabel(function() {
|
|
211
|
+
return {};
|
|
212
|
+
});
|
|
213
|
+
s.warn("Old graph before copy", m(e)), R(i, e, u, i), e.setNode(i, {
|
|
214
|
+
clusterNode: !0,
|
|
215
|
+
id: i,
|
|
216
|
+
clusterData: l[i].clusterData,
|
|
217
|
+
labelText: l[i].labelText,
|
|
218
|
+
graph: u
|
|
219
|
+
}), s.warn("New graph after copy node: (", i, ")", m(u)), s.debug("Old graph after copy", m(e));
|
|
220
|
+
} else
|
|
221
|
+
s.warn(
|
|
222
|
+
"Cluster ** ",
|
|
223
|
+
i,
|
|
224
|
+
" **not meeting the criteria !externalConnections:",
|
|
225
|
+
!l[i].externalConnections,
|
|
226
|
+
" no parent: ",
|
|
227
|
+
!e.parent(i),
|
|
228
|
+
" children ",
|
|
229
|
+
e.children(i) && e.children(i).length > 0,
|
|
230
|
+
e.children("D"),
|
|
231
|
+
t
|
|
232
|
+
), s.debug(l);
|
|
233
|
+
n = e.nodes(), s.warn("New list of nodes", n);
|
|
234
|
+
for (const i of n) {
|
|
235
|
+
const a = e.node(i);
|
|
236
|
+
s.warn(" Now next level", i, a), a.clusterNode && k(a.graph, t + 1);
|
|
237
|
+
}
|
|
238
|
+
}, F = (e, t) => {
|
|
239
|
+
if (t.length === 0)
|
|
240
|
+
return [];
|
|
241
|
+
let n = Object.assign(t);
|
|
242
|
+
return t.forEach((r) => {
|
|
243
|
+
const i = e.children(r), a = F(e, i);
|
|
244
|
+
n = [...n, ...a];
|
|
245
|
+
}), n;
|
|
246
|
+
}, it = (e) => F(e, e.children()), st = (e, t) => {
|
|
247
|
+
s.info("Creating subgraph rect for ", t.id, t);
|
|
248
|
+
const n = T(), r = e.insert("g").attr("class", "cluster" + (t.class ? " " + t.class : "")).attr("id", t.id), i = r.insert("rect", ":first-child"), a = S(n.flowchart.htmlLabels), d = r.insert("g").attr("class", "cluster-label"), u = t.labelType === "markdown" ? Y(d, t.labelText, { style: t.labelStyle, useHtmlLabels: a }) : d.node().appendChild($(t.labelText, t.labelStyle, void 0, !0));
|
|
249
|
+
let f = u.getBBox();
|
|
250
|
+
if (S(n.flowchart.htmlLabels)) {
|
|
251
|
+
const c = u.children[0], o = J(u);
|
|
252
|
+
f = c.getBoundingClientRect(), o.attr("width", f.width), o.attr("height", f.height);
|
|
253
|
+
}
|
|
254
|
+
const h = 0 * t.padding, w = h / 2, x = t.width <= f.width + h ? f.width + h : t.width;
|
|
255
|
+
t.width <= f.width + h ? t.diff = (f.width - t.width) / 2 - t.padding / 2 : t.diff = -t.padding / 2, s.trace("Data ", t, JSON.stringify(t)), i.attr("style", t.style).attr("rx", t.rx).attr("ry", t.ry).attr("x", t.x - x / 2).attr("y", t.y - t.height / 2 - w).attr("width", x).attr("height", t.height + h);
|
|
256
|
+
const { subGraphTitleTopMargin: E } = D(n);
|
|
257
|
+
a ? d.attr(
|
|
258
|
+
"transform",
|
|
259
|
+
// This puts the label on top of the box instead of inside it
|
|
260
|
+
`translate(${t.x - f.width / 2}, ${t.y - t.height / 2 + E})`
|
|
261
|
+
) : d.attr(
|
|
262
|
+
"transform",
|
|
263
|
+
// This puts the label on top of the box instead of inside it
|
|
264
|
+
`translate(${t.x}, ${t.y - t.height / 2 + E})`
|
|
265
|
+
);
|
|
266
|
+
const y = i.node().getBBox();
|
|
267
|
+
return t.width = y.width, t.height = y.height, t.intersect = function(c) {
|
|
268
|
+
return p(t, c);
|
|
269
|
+
}, r;
|
|
270
|
+
}, rt = (e, t) => {
|
|
271
|
+
const n = e.insert("g").attr("class", "note-cluster").attr("id", t.id), r = n.insert("rect", ":first-child"), i = 0 * t.padding, a = i / 2;
|
|
272
|
+
r.attr("rx", t.rx).attr("ry", t.ry).attr("x", t.x - t.width / 2 - a).attr("y", t.y - t.height / 2 - a).attr("width", t.width + i).attr("height", t.height + i).attr("fill", "none");
|
|
273
|
+
const d = r.node().getBBox();
|
|
274
|
+
return t.width = d.width, t.height = d.height, t.intersect = function(u) {
|
|
275
|
+
return p(t, u);
|
|
276
|
+
}, n;
|
|
277
|
+
}, at = (e, t) => {
|
|
278
|
+
const n = T(), r = e.insert("g").attr("class", t.classes).attr("id", t.id), i = r.insert("rect", ":first-child"), a = r.insert("g").attr("class", "cluster-label"), d = r.append("rect"), u = a.node().appendChild($(t.labelText, t.labelStyle, void 0, !0));
|
|
279
|
+
let f = u.getBBox();
|
|
280
|
+
if (S(n.flowchart.htmlLabels)) {
|
|
281
|
+
const c = u.children[0], o = J(u);
|
|
282
|
+
f = c.getBoundingClientRect(), o.attr("width", f.width), o.attr("height", f.height);
|
|
283
|
+
}
|
|
284
|
+
f = u.getBBox();
|
|
285
|
+
const h = 0 * t.padding, w = h / 2, x = t.width <= f.width + t.padding ? f.width + t.padding : t.width;
|
|
286
|
+
t.width <= f.width + t.padding ? t.diff = (f.width + t.padding * 0 - t.width) / 2 : t.diff = -t.padding / 2, i.attr("class", "outer").attr("x", t.x - x / 2 - w).attr("y", t.y - t.height / 2 - w).attr("width", x + h).attr("height", t.height + h), d.attr("class", "inner").attr("x", t.x - x / 2 - w).attr("y", t.y - t.height / 2 - w + f.height - 1).attr("width", x + h).attr("height", t.height + h - f.height - 3);
|
|
287
|
+
const { subGraphTitleTopMargin: E } = D(n);
|
|
288
|
+
a.attr(
|
|
289
|
+
"transform",
|
|
290
|
+
`translate(${t.x - f.width / 2}, ${t.y - t.height / 2 - t.padding / 3 + (S(n.flowchart.htmlLabels) ? 5 : 3) + E})`
|
|
291
|
+
);
|
|
292
|
+
const y = i.node().getBBox();
|
|
293
|
+
return t.height = y.height, t.intersect = function(c) {
|
|
294
|
+
return p(t, c);
|
|
295
|
+
}, r;
|
|
296
|
+
}, ct = (e, t) => {
|
|
297
|
+
const n = e.insert("g").attr("class", t.classes).attr("id", t.id), r = n.insert("rect", ":first-child"), i = 0 * t.padding, a = i / 2;
|
|
298
|
+
r.attr("class", "divider").attr("x", t.x - t.width / 2 - a).attr("y", t.y - t.height / 2).attr("width", t.width + i).attr("height", t.height + i);
|
|
299
|
+
const d = r.node().getBBox();
|
|
300
|
+
return t.width = d.width, t.height = d.height, t.diff = -t.padding / 2, t.intersect = function(u) {
|
|
301
|
+
return p(t, u);
|
|
302
|
+
}, n;
|
|
303
|
+
}, ot = { rect: st, roundedWithTitle: at, noteGroup: rt, divider: ct };
|
|
304
|
+
let G = {};
|
|
305
|
+
const lt = (e, t) => {
|
|
306
|
+
s.trace("Inserting cluster");
|
|
307
|
+
const n = t.shape || "rect";
|
|
308
|
+
G[t.id] = ot[n](e, t);
|
|
309
|
+
}, ft = () => {
|
|
310
|
+
G = {};
|
|
311
|
+
}, j = async (e, t, n, r, i, a) => {
|
|
312
|
+
s.info("Graph in recursive render: XXX", m(t), i);
|
|
313
|
+
const d = t.graph().rankdir;
|
|
314
|
+
s.trace("Dir in recursive render - dir:", d);
|
|
315
|
+
const u = e.insert("g").attr("class", "root");
|
|
316
|
+
t.nodes() ? s.info("Recursive render XXX", t.nodes()) : s.info("No nodes found for", t), t.edges().length > 0 && s.trace("Recursive edges", t.edge(t.edges()[0]));
|
|
317
|
+
const f = u.insert("g").attr("class", "clusters"), h = u.insert("g").attr("class", "edgePaths"), w = u.insert("g").attr("class", "edgeLabels"), x = u.insert("g").attr("class", "nodes");
|
|
318
|
+
await Promise.all(
|
|
319
|
+
t.nodes().map(async function(c) {
|
|
320
|
+
const o = t.node(c);
|
|
321
|
+
if (i !== void 0) {
|
|
322
|
+
const b = JSON.parse(JSON.stringify(i.clusterData));
|
|
323
|
+
s.info("Setting data for cluster XXX (", c, ") ", b, i), t.setNode(i.id, b), t.parent(c) || (s.trace("Setting parent", c, i.id), t.setParent(c, i.id, b));
|
|
324
|
+
}
|
|
325
|
+
if (s.info("(Insert) Node XXX" + c + ": " + JSON.stringify(t.node(c))), o && o.clusterNode) {
|
|
326
|
+
s.info("Cluster identified", c, o.width, t.node(c));
|
|
327
|
+
const b = await j(
|
|
328
|
+
x,
|
|
329
|
+
o.graph,
|
|
330
|
+
n,
|
|
331
|
+
r,
|
|
332
|
+
t.node(c),
|
|
333
|
+
a
|
|
334
|
+
), N = b.elem;
|
|
335
|
+
H(o, N), o.diff = b.diff || 0, s.info("Node bounds (abc123)", c, o, o.width, o.x, o.y), V(N, o), s.warn("Recursive render complete ", N, o);
|
|
336
|
+
} else
|
|
337
|
+
t.children(c).length > 0 ? (s.info("Cluster - the non recursive path XXX", c, o.id, o, t), s.info(C(o.id, t)), l[o.id] = { id: C(o.id, t), node: o }) : (s.info("Node - the non recursive path", c, o.id, o), await _(x, t.node(c), d));
|
|
338
|
+
})
|
|
339
|
+
), t.edges().forEach(function(c) {
|
|
340
|
+
const o = t.edge(c.v, c.w, c.name);
|
|
341
|
+
s.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(c)), s.info("Edge " + c.v + " -> " + c.w + ": ", c, " ", JSON.stringify(t.edge(c))), s.info("Fix", l, "ids:", c.v, c.w, "Translating: ", l[c.v], l[c.w]), W(w, o);
|
|
342
|
+
}), t.edges().forEach(function(c) {
|
|
343
|
+
s.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(c));
|
|
344
|
+
}), s.info("#############################################"), s.info("### Layout ###"), s.info("#############################################"), s.info(t), M(t), s.info("Graph after layout:", m(t));
|
|
345
|
+
let E = 0;
|
|
346
|
+
const { subGraphTitleTotalMargin: y } = D(a);
|
|
347
|
+
return it(t).forEach(function(c) {
|
|
348
|
+
const o = t.node(c);
|
|
349
|
+
s.info("Position " + c + ": " + JSON.stringify(t.node(c))), s.info(
|
|
350
|
+
"Position " + c + ": (" + o.x,
|
|
351
|
+
"," + o.y,
|
|
352
|
+
") width: ",
|
|
353
|
+
o.width,
|
|
354
|
+
" height: ",
|
|
355
|
+
o.height
|
|
356
|
+
), o && o.clusterNode ? (o.y += y, O(o)) : t.children(c).length > 0 ? (o.height += y, lt(f, o), l[o.id].node = o) : (o.y += y / 2, O(o));
|
|
357
|
+
}), t.edges().forEach(function(c) {
|
|
358
|
+
const o = t.edge(c);
|
|
359
|
+
s.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(o), o), o.points.forEach((N) => N.y += y / 2);
|
|
360
|
+
const b = q(h, c, o, l, n, t, r);
|
|
361
|
+
z(o, b);
|
|
362
|
+
}), t.nodes().forEach(function(c) {
|
|
363
|
+
const o = t.node(c);
|
|
364
|
+
s.info(c, o.type, o.diff), o.type === "group" && (E = o.diff);
|
|
365
|
+
}), { elem: u, diff: E };
|
|
366
|
+
}, xt = async (e, t, n, r, i) => {
|
|
367
|
+
A(e, n, r, i), K(), Q(), ft(), tt(), s.warn("Graph at first:", JSON.stringify(m(t))), nt(t), s.warn("Graph after:", JSON.stringify(m(t)));
|
|
368
|
+
const a = T();
|
|
369
|
+
await j(e, t, r, i, void 0, a);
|
|
370
|
+
};
|
|
371
|
+
export {
|
|
372
|
+
xt as r
|
|
373
|
+
};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { s as P, d as N, p as W } from "./layers.CQefO3zC.js";
|
|
2
|
+
import { g as t, d as H, l as b, e as R, j as T, r as v, u as U } from "./layers.ix2kR4vq.js";
|
|
3
|
+
import "lodash-es";
|
|
4
|
+
import { l as C } from "./layers.D4fGb2cV.js";
|
|
5
|
+
import { G as F } from "./layers.C7lIplJU.js";
|
|
6
|
+
import "./layers.B6ZNsH3T.js";
|
|
7
|
+
import { l as $ } from "./layers.CJWyW1s7.js";
|
|
8
|
+
const O = (e) => e.append("circle").attr("class", "start-state").attr("r", t().state.sizeUnit).attr("cx", t().state.padding + t().state.sizeUnit).attr("cy", t().state.padding + t().state.sizeUnit), X = (e) => e.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", t().state.textHeight).attr("class", "divider").attr("x2", t().state.textHeight * 2).attr("y1", 0).attr("y2", 0), J = (e, i) => {
|
|
9
|
+
const o = e.append("text").attr("x", 2 * t().state.padding).attr("y", t().state.textHeight + 2 * t().state.padding).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.id), c = o.node().getBBox();
|
|
10
|
+
return e.insert("rect", ":first-child").attr("x", t().state.padding).attr("y", t().state.padding).attr("width", c.width + 2 * t().state.padding).attr("height", c.height + 2 * t().state.padding).attr("rx", t().state.radius), o;
|
|
11
|
+
}, Y = (e, i) => {
|
|
12
|
+
const o = function(l, m, w) {
|
|
13
|
+
const E = l.append("tspan").attr("x", 2 * t().state.padding).text(m);
|
|
14
|
+
w || E.attr("dy", t().state.textHeight);
|
|
15
|
+
}, s = e.append("text").attr("x", 2 * t().state.padding).attr("y", t().state.textHeight + 1.3 * t().state.padding).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.descriptions[0]).node().getBBox(), g = s.height, p = e.append("text").attr("x", t().state.padding).attr(
|
|
16
|
+
"y",
|
|
17
|
+
g + t().state.padding * 0.4 + t().state.dividerMargin + t().state.textHeight
|
|
18
|
+
).attr("class", "state-description");
|
|
19
|
+
let a = !0, r = !0;
|
|
20
|
+
i.descriptions.forEach(function(l) {
|
|
21
|
+
a || (o(p, l, r), r = !1), a = !1;
|
|
22
|
+
});
|
|
23
|
+
const y = e.append("line").attr("x1", t().state.padding).attr("y1", t().state.padding + g + t().state.dividerMargin / 2).attr("y2", t().state.padding + g + t().state.dividerMargin / 2).attr("class", "descr-divider"), x = p.node().getBBox(), d = Math.max(x.width, s.width);
|
|
24
|
+
return y.attr("x2", d + 3 * t().state.padding), e.insert("rect", ":first-child").attr("x", t().state.padding).attr("y", t().state.padding).attr("width", d + 2 * t().state.padding).attr("height", x.height + g + 2 * t().state.padding).attr("rx", t().state.radius), e;
|
|
25
|
+
}, I = (e, i, o) => {
|
|
26
|
+
const c = t().state.padding, s = 2 * t().state.padding, g = e.node().getBBox(), p = g.width, a = g.x, r = e.append("text").attr("x", 0).attr("y", t().state.titleShift).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.id), x = r.node().getBBox().width + s;
|
|
27
|
+
let d = Math.max(x, p);
|
|
28
|
+
d === p && (d = d + s);
|
|
29
|
+
let l;
|
|
30
|
+
const m = e.node().getBBox();
|
|
31
|
+
i.doc, l = a - c, x > p && (l = (p - d) / 2 + c), Math.abs(a - m.x) < c && x > p && (l = a - (x - p) / 2);
|
|
32
|
+
const w = 1 - t().state.textHeight;
|
|
33
|
+
return e.insert("rect", ":first-child").attr("x", l).attr("y", w).attr("class", o ? "alt-composit" : "composit").attr("width", d).attr(
|
|
34
|
+
"height",
|
|
35
|
+
m.height + t().state.textHeight + t().state.titleShift + 1
|
|
36
|
+
).attr("rx", "0"), r.attr("x", l + c), x <= p && r.attr("x", a + (d - s) / 2 - x / 2 + c), e.insert("rect", ":first-child").attr("x", l).attr(
|
|
37
|
+
"y",
|
|
38
|
+
t().state.titleShift - t().state.textHeight - t().state.padding
|
|
39
|
+
).attr("width", d).attr("height", t().state.textHeight * 3).attr("rx", t().state.radius), e.insert("rect", ":first-child").attr("x", l).attr(
|
|
40
|
+
"y",
|
|
41
|
+
t().state.titleShift - t().state.textHeight - t().state.padding
|
|
42
|
+
).attr("width", d).attr("height", m.height + 3 + 2 * t().state.textHeight).attr("rx", t().state.radius), e;
|
|
43
|
+
}, _ = (e) => (e.append("circle").attr("class", "end-state-outer").attr("r", t().state.sizeUnit + t().state.miniPadding).attr(
|
|
44
|
+
"cx",
|
|
45
|
+
t().state.padding + t().state.sizeUnit + t().state.miniPadding
|
|
46
|
+
).attr(
|
|
47
|
+
"cy",
|
|
48
|
+
t().state.padding + t().state.sizeUnit + t().state.miniPadding
|
|
49
|
+
), e.append("circle").attr("class", "end-state-inner").attr("r", t().state.sizeUnit).attr("cx", t().state.padding + t().state.sizeUnit + 2).attr("cy", t().state.padding + t().state.sizeUnit + 2)), q = (e, i) => {
|
|
50
|
+
let o = t().state.forkWidth, c = t().state.forkHeight;
|
|
51
|
+
if (i.parentId) {
|
|
52
|
+
let s = o;
|
|
53
|
+
o = c, c = s;
|
|
54
|
+
}
|
|
55
|
+
return e.append("rect").style("stroke", "black").style("fill", "black").attr("width", o).attr("height", c).attr("x", t().state.padding).attr("y", t().state.padding);
|
|
56
|
+
}, Z = (e, i, o, c) => {
|
|
57
|
+
let s = 0;
|
|
58
|
+
const g = c.append("text");
|
|
59
|
+
g.style("text-anchor", "start"), g.attr("class", "noteText");
|
|
60
|
+
let p = e.replace(/\r\n/g, "<br/>");
|
|
61
|
+
p = p.replace(/\n/g, "<br/>");
|
|
62
|
+
const a = p.split(T.lineBreakRegex);
|
|
63
|
+
let r = 1.25 * t().state.noteMargin;
|
|
64
|
+
for (const y of a) {
|
|
65
|
+
const x = y.trim();
|
|
66
|
+
if (x.length > 0) {
|
|
67
|
+
const d = g.append("tspan");
|
|
68
|
+
if (d.text(x), r === 0) {
|
|
69
|
+
const l = d.node().getBBox();
|
|
70
|
+
r += l.height;
|
|
71
|
+
}
|
|
72
|
+
s += r, d.attr("x", i + t().state.noteMargin), d.attr("y", o + s + 1.25 * t().state.noteMargin);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { textWidth: g.node().getBBox().width, textHeight: s };
|
|
76
|
+
}, j = (e, i) => {
|
|
77
|
+
i.attr("class", "state-note");
|
|
78
|
+
const o = i.append("rect").attr("x", 0).attr("y", t().state.padding), c = i.append("g"), { textWidth: s, textHeight: g } = Z(e, 0, 0, c);
|
|
79
|
+
return o.attr("height", g + 2 * t().state.noteMargin), o.attr("width", s + t().state.noteMargin * 2), o;
|
|
80
|
+
}, L = function(e, i) {
|
|
81
|
+
const o = i.id, c = {
|
|
82
|
+
id: o,
|
|
83
|
+
label: i.id,
|
|
84
|
+
width: 0,
|
|
85
|
+
height: 0
|
|
86
|
+
}, s = e.append("g").attr("id", o).attr("class", "stateGroup");
|
|
87
|
+
i.type === "start" && O(s), i.type === "end" && _(s), (i.type === "fork" || i.type === "join") && q(s, i), i.type === "note" && j(i.note.text, s), i.type === "divider" && X(s), i.type === "default" && i.descriptions.length === 0 && J(s, i), i.type === "default" && i.descriptions.length > 0 && Y(s, i);
|
|
88
|
+
const g = s.node().getBBox();
|
|
89
|
+
return c.width = g.width + 2 * t().state.padding, c.height = g.height + 2 * t().state.padding, c;
|
|
90
|
+
};
|
|
91
|
+
let G = 0;
|
|
92
|
+
const K = function(e, i, o) {
|
|
93
|
+
const c = function(r) {
|
|
94
|
+
switch (r) {
|
|
95
|
+
case N.relationType.AGGREGATION:
|
|
96
|
+
return "aggregation";
|
|
97
|
+
case N.relationType.EXTENSION:
|
|
98
|
+
return "extension";
|
|
99
|
+
case N.relationType.COMPOSITION:
|
|
100
|
+
return "composition";
|
|
101
|
+
case N.relationType.DEPENDENCY:
|
|
102
|
+
return "dependency";
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
i.points = i.points.filter((r) => !Number.isNaN(r.y));
|
|
106
|
+
const s = i.points, g = $().x(function(r) {
|
|
107
|
+
return r.x;
|
|
108
|
+
}).y(function(r) {
|
|
109
|
+
return r.y;
|
|
110
|
+
}).curve(v), p = e.append("path").attr("d", g(s)).attr("id", "edge" + G).attr("class", "transition");
|
|
111
|
+
let a = "";
|
|
112
|
+
if (t().state.arrowMarkerAbsolute && (a = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search, a = a.replace(/\(/g, "\\("), a = a.replace(/\)/g, "\\)")), p.attr(
|
|
113
|
+
"marker-end",
|
|
114
|
+
"url(" + a + "#" + c(N.relationType.DEPENDENCY) + "End)"
|
|
115
|
+
), o.title !== void 0) {
|
|
116
|
+
const r = e.append("g").attr("class", "stateLabel"), { x: y, y: x } = U.calcLabelPosition(i.points), d = T.getRows(o.title);
|
|
117
|
+
let l = 0;
|
|
118
|
+
const m = [];
|
|
119
|
+
let w = 0, E = 0;
|
|
120
|
+
for (let u = 0; u <= d.length; u++) {
|
|
121
|
+
const h = r.append("text").attr("text-anchor", "middle").text(d[u]).attr("x", y).attr("y", x + l), f = h.node().getBBox();
|
|
122
|
+
w = Math.max(w, f.width), E = Math.min(E, f.x), b.info(f.x, y, x + l), l === 0 && (l = h.node().getBBox().height, b.info("Title height", l, x)), m.push(h);
|
|
123
|
+
}
|
|
124
|
+
let k = l * d.length;
|
|
125
|
+
if (d.length > 1) {
|
|
126
|
+
const u = (d.length - 1) * l * 0.5;
|
|
127
|
+
m.forEach((h, f) => h.attr("y", x + f * l - u)), k = l * d.length;
|
|
128
|
+
}
|
|
129
|
+
const n = r.node().getBBox();
|
|
130
|
+
r.insert("rect", ":first-child").attr("class", "box").attr("x", y - w / 2 - t().state.padding / 2).attr("y", x - k / 2 - t().state.padding / 2 - 3.5).attr("width", w + t().state.padding).attr("height", k + t().state.padding), b.info(n);
|
|
131
|
+
}
|
|
132
|
+
G++;
|
|
133
|
+
};
|
|
134
|
+
let B;
|
|
135
|
+
const z = {}, Q = function() {
|
|
136
|
+
}, V = function(e) {
|
|
137
|
+
e.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");
|
|
138
|
+
}, D = function(e, i, o, c) {
|
|
139
|
+
B = t().state;
|
|
140
|
+
const s = t().securityLevel;
|
|
141
|
+
let g;
|
|
142
|
+
s === "sandbox" && (g = H("#i" + i));
|
|
143
|
+
const p = s === "sandbox" ? H(g.nodes()[0].contentDocument.body) : H("body"), a = s === "sandbox" ? g.nodes()[0].contentDocument : document;
|
|
144
|
+
b.debug("Rendering diagram " + e);
|
|
145
|
+
const r = p.select(`[id='${i}']`);
|
|
146
|
+
V(r);
|
|
147
|
+
const y = c.db.getRootDoc();
|
|
148
|
+
A(y, r, void 0, !1, p, a, c);
|
|
149
|
+
const x = B.padding, d = r.node().getBBox(), l = d.width + x * 2, m = d.height + x * 2, w = l * 1.75;
|
|
150
|
+
R(r, m, w, B.useMaxWidth), r.attr(
|
|
151
|
+
"viewBox",
|
|
152
|
+
`${d.x - B.padding} ${d.y - B.padding} ` + l + " " + m
|
|
153
|
+
);
|
|
154
|
+
}, tt = (e) => e ? e.length * B.fontSizeFactor : 1, A = (e, i, o, c, s, g, p) => {
|
|
155
|
+
const a = new F({
|
|
156
|
+
compound: !0,
|
|
157
|
+
multigraph: !0
|
|
158
|
+
});
|
|
159
|
+
let r, y = !0;
|
|
160
|
+
for (r = 0; r < e.length; r++)
|
|
161
|
+
if (e[r].stmt === "relation") {
|
|
162
|
+
y = !1;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
o ? a.setGraph({
|
|
166
|
+
rankdir: "LR",
|
|
167
|
+
multigraph: !0,
|
|
168
|
+
compound: !0,
|
|
169
|
+
// acyclicer: 'greedy',
|
|
170
|
+
ranker: "tight-tree",
|
|
171
|
+
ranksep: y ? 1 : B.edgeLengthFactor,
|
|
172
|
+
nodeSep: y ? 1 : 50,
|
|
173
|
+
isMultiGraph: !0
|
|
174
|
+
// ranksep: 5,
|
|
175
|
+
// nodesep: 1
|
|
176
|
+
}) : a.setGraph({
|
|
177
|
+
rankdir: "TB",
|
|
178
|
+
multigraph: !0,
|
|
179
|
+
compound: !0,
|
|
180
|
+
// isCompound: true,
|
|
181
|
+
// acyclicer: 'greedy',
|
|
182
|
+
// ranker: 'longest-path'
|
|
183
|
+
ranksep: y ? 1 : B.edgeLengthFactor,
|
|
184
|
+
nodeSep: y ? 1 : 50,
|
|
185
|
+
ranker: "tight-tree",
|
|
186
|
+
// ranker: 'network-simplex'
|
|
187
|
+
isMultiGraph: !0
|
|
188
|
+
}), a.setDefaultEdgeLabel(function() {
|
|
189
|
+
return {};
|
|
190
|
+
}), p.db.extract(e);
|
|
191
|
+
const x = p.db.getStates(), d = p.db.getRelations(), l = Object.keys(x);
|
|
192
|
+
for (const n of l) {
|
|
193
|
+
const u = x[n];
|
|
194
|
+
o && (u.parentId = o);
|
|
195
|
+
let h;
|
|
196
|
+
if (u.doc) {
|
|
197
|
+
let f = i.append("g").attr("id", u.id).attr("class", "stateGroup");
|
|
198
|
+
h = A(u.doc, f, u.id, !c, s, g, p);
|
|
199
|
+
{
|
|
200
|
+
f = I(f, u, c);
|
|
201
|
+
let S = f.node().getBBox();
|
|
202
|
+
h.width = S.width, h.height = S.height + B.padding / 2, z[u.id] = { y: B.compositTitleSize };
|
|
203
|
+
}
|
|
204
|
+
} else
|
|
205
|
+
h = L(i, u);
|
|
206
|
+
if (u.note) {
|
|
207
|
+
const f = {
|
|
208
|
+
descriptions: [],
|
|
209
|
+
id: u.id + "-note",
|
|
210
|
+
note: u.note,
|
|
211
|
+
type: "note"
|
|
212
|
+
}, S = L(i, f);
|
|
213
|
+
u.note.position === "left of" ? (a.setNode(h.id + "-note", S), a.setNode(h.id, h)) : (a.setNode(h.id, h), a.setNode(h.id + "-note", S)), a.setParent(h.id, h.id + "-group"), a.setParent(h.id + "-note", h.id + "-group");
|
|
214
|
+
} else
|
|
215
|
+
a.setNode(h.id, h);
|
|
216
|
+
}
|
|
217
|
+
b.debug("Count=", a.nodeCount(), a);
|
|
218
|
+
let m = 0;
|
|
219
|
+
d.forEach(function(n) {
|
|
220
|
+
m++, b.debug("Setting edge", n), a.setEdge(
|
|
221
|
+
n.id1,
|
|
222
|
+
n.id2,
|
|
223
|
+
{
|
|
224
|
+
relation: n,
|
|
225
|
+
width: tt(n.title),
|
|
226
|
+
height: B.labelHeight * T.getRows(n.title).length,
|
|
227
|
+
labelpos: "c"
|
|
228
|
+
},
|
|
229
|
+
"id" + m
|
|
230
|
+
);
|
|
231
|
+
}), C(a), b.debug("Graph after layout", a.nodes());
|
|
232
|
+
const w = i.node();
|
|
233
|
+
a.nodes().forEach(function(n) {
|
|
234
|
+
n !== void 0 && a.node(n) !== void 0 ? (b.warn("Node " + n + ": " + JSON.stringify(a.node(n))), s.select("#" + w.id + " #" + n).attr(
|
|
235
|
+
"transform",
|
|
236
|
+
"translate(" + (a.node(n).x - a.node(n).width / 2) + "," + (a.node(n).y + (z[n] ? z[n].y : 0) - a.node(n).height / 2) + " )"
|
|
237
|
+
), s.select("#" + w.id + " #" + n).attr("data-x-shift", a.node(n).x - a.node(n).width / 2), g.querySelectorAll("#" + w.id + " #" + n + " .divider").forEach((h) => {
|
|
238
|
+
const f = h.parentElement;
|
|
239
|
+
let S = 0, M = 0;
|
|
240
|
+
f && (f.parentElement && (S = f.parentElement.getBBox().width), M = parseInt(f.getAttribute("data-x-shift"), 10), Number.isNaN(M) && (M = 0)), h.setAttribute("x1", 0 - M + 8), h.setAttribute("x2", S - M - 8);
|
|
241
|
+
})) : b.debug("No Node " + n + ": " + JSON.stringify(a.node(n)));
|
|
242
|
+
});
|
|
243
|
+
let E = w.getBBox();
|
|
244
|
+
a.edges().forEach(function(n) {
|
|
245
|
+
n !== void 0 && a.edge(n) !== void 0 && (b.debug("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(a.edge(n))), K(i, a.edge(n), a.edge(n).relation));
|
|
246
|
+
}), E = w.getBBox();
|
|
247
|
+
const k = {
|
|
248
|
+
id: o || "root",
|
|
249
|
+
label: o || "root",
|
|
250
|
+
width: 0,
|
|
251
|
+
height: 0
|
|
252
|
+
};
|
|
253
|
+
return k.width = E.width + 2 * B.padding, k.height = E.height + 2 * B.padding, b.debug("Doc rendered", k, a), k;
|
|
254
|
+
}, et = {
|
|
255
|
+
setConf: Q,
|
|
256
|
+
draw: D
|
|
257
|
+
}, ct = {
|
|
258
|
+
parser: W,
|
|
259
|
+
db: N,
|
|
260
|
+
renderer: et,
|
|
261
|
+
styles: P,
|
|
262
|
+
init: (e) => {
|
|
263
|
+
e.state || (e.state = {}), e.state.arrowMarkerAbsolute = e.arrowMarkerAbsolute, N.clear();
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
export {
|
|
267
|
+
ct as diagram
|
|
268
|
+
};
|