@draftably/editor 0.0.0-stage → 0.1.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/README.md +26 -2
- package/dist/LICENSE +21 -0
- package/dist/assets/engine.worker-DmHew5f6.js +6813 -0
- package/dist/assets/import-d2.worker-CnXfFXoa.js +5395 -0
- package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +87 -0
- package/dist/chunks/arc-rJj0TtXf.js +83 -0
- package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +4781 -0
- package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +1440 -0
- package/dist/chunks/browser-iNhbPsGc.js +40 -0
- package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +1524 -0
- package/dist/chunks/channel-qMvPU6eH.js +5 -0
- package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +670 -0
- package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +18 -0
- package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +262 -0
- package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +68 -0
- package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +19 -0
- package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +8 -0
- package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +19 -0
- package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +8 -0
- package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +451 -0
- package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +1570 -0
- package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +2608 -0
- package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +22361 -0
- package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +299 -0
- package/dist/chunks/cytoscape.esm-CRsF_JA3.js +18791 -0
- package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +2157 -0
- package/dist/chunks/defaultLocale-BgPVtth8.js +171 -0
- package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +531 -0
- package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +153 -0
- package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +346 -0
- package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +480 -0
- package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +219 -0
- package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +2586 -0
- package/dist/chunks/dot-importer-B23jwEkx.js +1547 -0
- package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +109 -0
- package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +49229 -0
- package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +1064 -0
- package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +1771 -0
- package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +2729 -0
- package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +815 -0
- package/dist/chunks/graph-CKJmgLki.js +1541 -0
- package/dist/chunks/import-core-C-I1wGfw.js +145 -0
- package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +24 -0
- package/dist/chunks/init-DjUOC4st.js +16 -0
- package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +624 -0
- package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +834 -0
- package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +724 -0
- package/dist/chunks/katex-BsrBVQKd.js +11314 -0
- package/dist/chunks/linear-4t7D_ros.js +259 -0
- package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
- package/dist/chunks/mermaid-importer-Cgx1IhmR.js +478 -0
- package/dist/chunks/mermaid.core-DXv6D2Sm.js +19244 -0
- package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +837 -0
- package/dist/chunks/mount-C1Xk_GQz.js +22131 -0
- package/dist/chunks/ordinal-DfAQgscy.js +61 -0
- package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +95 -0
- package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +208 -0
- package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +1029 -0
- package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +77 -0
- package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +889 -0
- package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +859 -0
- package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +2972 -0
- package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +46 -0
- package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +1520 -0
- package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +4991 -0
- package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +13 -0
- package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +1058 -0
- package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +7945 -0
- package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +1578 -0
- package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +678 -0
- package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +1536 -0
- package/dist/element.js +36 -0
- package/dist/index.js +4 -0
- package/dist/types/src/cli/links.d.ts +4 -0
- package/dist/types/src/cli/pdf.d.ts +29 -0
- package/dist/types/src/cli/png.d.ts +23 -0
- package/dist/types/src/cli/svg.d.ts +4 -0
- package/dist/types/src/components/Icon.d.ts +14 -0
- package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
- package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
- package/dist/types/src/components/canvas/Frame.d.ts +22 -0
- package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
- package/dist/types/src/components/canvas/Notes.d.ts +5 -0
- package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
- package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
- package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
- package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
- package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
- package/dist/types/src/components/controls.d.ts +88 -0
- package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
- package/dist/types/src/components/scene/GroupView.d.ts +22 -0
- package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
- package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
- package/dist/types/src/components/scene/NodeView.d.ts +18 -0
- package/dist/types/src/components/scene/parts.d.ts +50 -0
- package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
- package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
- package/dist/types/src/components/session-context.d.ts +486 -0
- package/dist/types/src/dsl/cells.d.ts +91 -0
- package/dist/types/src/dsl/channels.d.ts +53 -0
- package/dist/types/src/dsl/compile.d.ts +162 -0
- package/dist/types/src/dsl/frame.d.ts +38 -0
- package/dist/types/src/dsl/lanes.d.ts +23 -0
- package/dist/types/src/dsl/layout-edits.d.ts +58 -0
- package/dist/types/src/dsl/legend-notes.d.ts +3 -0
- package/dist/types/src/dsl/project.d.ts +39 -0
- package/dist/types/src/dsl/source-edits.d.ts +37 -0
- package/dist/types/src/dsl/syntax.d.ts +317 -0
- package/dist/types/src/dsl/translate.d.ts +69 -0
- package/dist/types/src/editor/Editor.d.ts +6 -0
- package/dist/types/src/editor/element.d.ts +15 -0
- package/dist/types/src/editor/mount.d.ts +23 -0
- package/dist/types/src/import/browser.d.ts +3 -0
- package/dist/types/src/import/detect.d.ts +31 -0
- package/dist/types/src/import/dot-importer.d.ts +3 -0
- package/dist/types/src/import/import-core.d.ts +105 -0
- package/dist/types/src/import/mermaid-facade.d.ts +120 -0
- package/dist/types/src/import/mermaid-importer.d.ts +4 -0
- package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
- package/dist/types/src/import/scratch.d.ts +3 -0
- package/dist/types/src/lib/engine-tasks.d.ts +88 -0
- package/dist/types/src/lib/font-data.d.ts +9 -0
- package/dist/types/src/lib/saved-diagram.d.ts +4 -0
- package/dist/types/src/lib/scene-cache.d.ts +4 -0
- package/dist/types/src/lib/source-hash.d.ts +7 -0
- package/dist/types/src/lib/svg-export.d.ts +15 -0
- package/dist/types/src/model/appearance.d.ts +209 -0
- package/dist/types/src/model/bounds.d.ts +19 -0
- package/dist/types/src/model/camera.d.ts +21 -0
- package/dist/types/src/model/candidates.d.ts +53 -0
- package/dist/types/src/model/colors.d.ts +22 -0
- package/dist/types/src/model/document.d.ts +24 -0
- package/dist/types/src/model/edits.d.ts +133 -0
- package/dist/types/src/model/embed.d.ts +17 -0
- package/dist/types/src/model/examples.d.ts +15 -0
- package/dist/types/src/model/font-faces.d.ts +24 -0
- package/dist/types/src/model/fonts.d.ts +47 -0
- package/dist/types/src/model/footnote.d.ts +34 -0
- package/dist/types/src/model/frame.d.ts +71 -0
- package/dist/types/src/model/geometry.d.ts +29 -0
- package/dist/types/src/model/graph.d.ts +53 -0
- package/dist/types/src/model/heading.d.ts +38 -0
- package/dist/types/src/model/icons.d.ts +2 -0
- package/dist/types/src/model/label-hits.d.ts +27 -0
- package/dist/types/src/model/labels.d.ts +88 -0
- package/dist/types/src/model/legend.d.ts +25 -0
- package/dist/types/src/model/link.d.ts +63 -0
- package/dist/types/src/model/markers.d.ts +47 -0
- package/dist/types/src/model/note.d.ts +75 -0
- package/dist/types/src/model/panels.d.ts +11 -0
- package/dist/types/src/model/rich-text.d.ts +24 -0
- package/dist/types/src/model/routes.d.ts +170 -0
- package/dist/types/src/model/samples.d.ts +11 -0
- package/dist/types/src/model/stack.d.ts +8 -0
- package/dist/types/src/model/static-scene.d.ts +15 -0
- package/dist/types/src/model/status.d.ts +84 -0
- package/dist/types/src/model/styles.d.ts +13 -0
- package/dist/types/src/model/surface.d.ts +31 -0
- package/dist/types/src/model/types.d.ts +277 -0
- package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
- package/dist/types/src/server/file-session.d.ts +19 -0
- package/dist/types/src/server/workspace.d.ts +21 -0
- package/dist/types/src/state/active-session.d.ts +479 -0
- package/dist/types/src/state/commands.d.ts +529 -0
- package/dist/types/src/state/comparison.d.ts +151 -0
- package/dist/types/src/state/files.d.ts +61 -0
- package/dist/types/src/state/keyboard.d.ts +6 -0
- package/dist/types/src/state/keys.d.ts +5 -0
- package/dist/types/src/state/launch.d.ts +61 -0
- package/dist/types/src/state/links.d.ts +11 -0
- package/dist/types/src/state/session/actions.d.ts +77 -0
- package/dist/types/src/state/session/canvas-text.d.ts +24 -0
- package/dist/types/src/state/session/document.d.ts +84 -0
- package/dist/types/src/state/session/editor.d.ts +81 -0
- package/dist/types/src/state/session/emphasis.d.ts +11 -0
- package/dist/types/src/state/session/file-session.d.ts +98 -0
- package/dist/types/src/state/session/index.d.ts +496 -0
- package/dist/types/src/state/session/layout.d.ts +79 -0
- package/dist/types/src/state/session/pointer.d.ts +19 -0
- package/dist/types/src/state/session/routing.d.ts +20 -0
- package/dist/types/src/state/session/scene.d.ts +144 -0
- package/dist/types/src/state/session/sculpt.d.ts +70 -0
- package/dist/types/src/state/toast.d.ts +14 -0
- package/dist/types/src/state/ui.d.ts +39 -0
- package/package.json +41 -3
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { _ as u, l as o, av as Z, am as I, aw as ee, ax as te, ay as ne, an as x, al as se, az as re, aA as D, aB as S, aC as k, c as ie, L as ae, aD as oe, aE as ce, aF as le, aG as ue, u as de } from "./mermaid.core-DXv6D2Sm.js";
|
|
2
|
+
import { G as R } from "./graph-CKJmgLki.js";
|
|
3
|
+
function T(e, { edgePathsClass: n = "edges edgePaths" } = {}) {
|
|
4
|
+
const t = e.insert("g").attr("class", "root"), r = t.insert("g").attr("class", "clusters"), s = t.insert("g").attr("class", n), i = t.insert("g").attr("class", "edgeLabels"), c = t.insert("g").attr("class", "nodes");
|
|
5
|
+
return { clusters: r, edgePaths: s, edgeLabels: i, nodes: c, rootGroups: t };
|
|
6
|
+
}
|
|
7
|
+
u(T, "createLayoutElementGroups");
|
|
8
|
+
async function P(e, n, t) {
|
|
9
|
+
if (n.label) {
|
|
10
|
+
const { shapeSvg: r, bbox: s } = await ue(
|
|
11
|
+
e,
|
|
12
|
+
t === void 0 ? n : { ...n, width: t }
|
|
13
|
+
);
|
|
14
|
+
n.labelBBox = { width: s.width, height: s.height }, r.remove();
|
|
15
|
+
} else
|
|
16
|
+
n.labelBBox = { width: 0, height: 0 };
|
|
17
|
+
}
|
|
18
|
+
u(P, "measureGroupLabel");
|
|
19
|
+
async function B(e, n, t) {
|
|
20
|
+
const r = await I(e, n, t), s = r.node()?.getBBox() ?? { width: 0, height: 0 };
|
|
21
|
+
return n.width = s.width, n.height = s.height, r;
|
|
22
|
+
}
|
|
23
|
+
u(B, "insertMeasuredNode");
|
|
24
|
+
function M(e, n, t) {
|
|
25
|
+
let r = e;
|
|
26
|
+
const s = /* @__PURE__ */ new Set();
|
|
27
|
+
for (; r; ) {
|
|
28
|
+
if (r.dir)
|
|
29
|
+
return r.dir;
|
|
30
|
+
if (!r.parentId || s.has(r.parentId))
|
|
31
|
+
break;
|
|
32
|
+
s.add(r.parentId), r = n.get(r.parentId);
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
u(M, "resolveNodeDir");
|
|
37
|
+
async function A(e, n, t = {}) {
|
|
38
|
+
const r = new R({
|
|
39
|
+
multigraph: !0,
|
|
40
|
+
compound: !0
|
|
41
|
+
}), s = [...n.edges], i = ie(), c = T(e), { edgeLabels: f, nodes: a } = c, g = /* @__PURE__ */ new Map(), h = new Map(n.nodes.map((d) => [d.id, d])), N = n.direction, w = e.node() != null;
|
|
42
|
+
await Promise.all(
|
|
43
|
+
n.nodes.map(async (d) => {
|
|
44
|
+
if (d.isGroup) {
|
|
45
|
+
if (w) {
|
|
46
|
+
const m = t.unwrapGroupLabels && d.labelType !== "markdown";
|
|
47
|
+
await P(a, d, m ? Number.POSITIVE_INFINITY : void 0);
|
|
48
|
+
}
|
|
49
|
+
r.setNode(d.id, { ...d });
|
|
50
|
+
} else {
|
|
51
|
+
if (w) {
|
|
52
|
+
const m = await B(a, d, {
|
|
53
|
+
config: i,
|
|
54
|
+
dir: M(d, h, N)
|
|
55
|
+
});
|
|
56
|
+
g.set(d.id, m);
|
|
57
|
+
}
|
|
58
|
+
r.setNode(d.id, { ...d });
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
for (const d of s)
|
|
63
|
+
w && D(d) && await k(f, d), r.setEdge(d.start, d.end, { ...d }, d.id), n.edges.some((E) => E.id === d.id) || n.edges.push(d);
|
|
64
|
+
if (globalThis.mermaidCaptureSizes) {
|
|
65
|
+
const { captureNodeSizes: d } = await import("./sizeCapture-INFHLROL-CToN3JSu.js");
|
|
66
|
+
d(e, n);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
graph: r,
|
|
70
|
+
groups: c,
|
|
71
|
+
nodeElements: g
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
u(A, "createGraphWithElements");
|
|
75
|
+
var l = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), fe = /* @__PURE__ */ u(() => {
|
|
76
|
+
b.clear(), _.clear(), l.clear();
|
|
77
|
+
}, "clear"), v = /* @__PURE__ */ u((e, n) => {
|
|
78
|
+
const t = b.get(n) || [];
|
|
79
|
+
return o.trace("In isDescendant", n, " ", e, " = ", t.includes(e)), t.includes(e);
|
|
80
|
+
}, "isDescendant"), ge = /* @__PURE__ */ u((e, n) => {
|
|
81
|
+
const t = b.get(n) || [];
|
|
82
|
+
return o.info("Descendants of ", n, " is ", t), o.info("Edge is ", e), e.v === n || e.w === n ? !1 : t ? t.includes(e.v) || v(e.v, n) || v(e.w, n) || t.includes(e.w) : (o.debug("Tilt, ", n, ",not in descendants"), !1);
|
|
83
|
+
}, "edgeInCluster"), G = /* @__PURE__ */ u((e, n, t, r) => {
|
|
84
|
+
o.debug(
|
|
85
|
+
"Copying children of ",
|
|
86
|
+
e,
|
|
87
|
+
"root",
|
|
88
|
+
r,
|
|
89
|
+
"data",
|
|
90
|
+
n.node(e),
|
|
91
|
+
r
|
|
92
|
+
);
|
|
93
|
+
const s = n.children(e) || [];
|
|
94
|
+
e !== r && s.push(e), o.debug("Copying (nodes) clusterId", e, "nodes", s), s.forEach((i) => {
|
|
95
|
+
if (n.children(i).length > 0)
|
|
96
|
+
G(i, n, t, r);
|
|
97
|
+
else {
|
|
98
|
+
const c = n.node(i);
|
|
99
|
+
o.info("cp ", i, " to ", r, " with parent ", e), t.setNode(i, c), r !== n.parent(i) && (o.debug("Setting parent", i, n.parent(i)), t.setParent(i, n.parent(i))), e !== r && i !== e ? (o.debug("Setting parent", i, e), t.setParent(i, e)) : (o.info("In copy ", e, "root", r, "data", n.node(e), r), o.debug(
|
|
100
|
+
"Not Setting parent for node=",
|
|
101
|
+
i,
|
|
102
|
+
"cluster!==rootId",
|
|
103
|
+
e !== r,
|
|
104
|
+
"node!==clusterId",
|
|
105
|
+
i !== e
|
|
106
|
+
));
|
|
107
|
+
const f = n.edges(i);
|
|
108
|
+
o.debug("Copying Edges", f), f.forEach((a) => {
|
|
109
|
+
o.info("Edge", a);
|
|
110
|
+
const g = n.edge(a.v, a.w, a.name);
|
|
111
|
+
o.info("Edge data", g, r);
|
|
112
|
+
try {
|
|
113
|
+
ge(a, r) ? (o.info("Copying as ", a.v, a.w, g, a.name), t.setEdge(a.v, a.w, g, a.name), o.info("newGraph edges ", t.edges(), t.edge(t.edges()[0]))) : o.info(
|
|
114
|
+
"Skipping copy of edge ",
|
|
115
|
+
a.v,
|
|
116
|
+
"-->",
|
|
117
|
+
a.w,
|
|
118
|
+
" rootId: ",
|
|
119
|
+
r,
|
|
120
|
+
" clusterId:",
|
|
121
|
+
e
|
|
122
|
+
);
|
|
123
|
+
} catch (h) {
|
|
124
|
+
o.error(h);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
o.debug("Removing node", i), n.removeNode(i);
|
|
129
|
+
});
|
|
130
|
+
}, "copy"), X = /* @__PURE__ */ u((e, n) => {
|
|
131
|
+
const t = n.children(e);
|
|
132
|
+
let r = [...t];
|
|
133
|
+
for (const s of t)
|
|
134
|
+
_.set(s, e), r = [...r, ...X(s, n)];
|
|
135
|
+
return r;
|
|
136
|
+
}, "extractDescendants"), be = /* @__PURE__ */ u((e, n, t) => {
|
|
137
|
+
const r = e.edges().filter((a) => a.v === n || a.w === n), s = e.edges().filter((a) => a.v === t || a.w === t), i = r.map((a) => ({ v: a.v === n ? t : a.v, w: a.w === n ? n : a.w })), c = s.map((a) => ({ v: a.v, w: a.w }));
|
|
138
|
+
return i.filter((a) => c.some((g) => a.v === g.v && a.w === g.w));
|
|
139
|
+
}, "findCommonEdges"), C = /* @__PURE__ */ u((e, n, t) => {
|
|
140
|
+
const r = n.children(e);
|
|
141
|
+
if (o.trace("Searching children of id ", e, r), r.length < 1)
|
|
142
|
+
return e;
|
|
143
|
+
let s;
|
|
144
|
+
for (const i of r) {
|
|
145
|
+
const c = C(i, n, t), f = be(n, t, c);
|
|
146
|
+
if (c)
|
|
147
|
+
if (f.length > 0)
|
|
148
|
+
s = c;
|
|
149
|
+
else
|
|
150
|
+
return c;
|
|
151
|
+
}
|
|
152
|
+
return s;
|
|
153
|
+
}, "findNonClusterChild"), L = /* @__PURE__ */ u((e) => !l.has(e) || !l.get(e).externalConnections ? e : l.has(e) ? l.get(e).id : e, "getAnchorId"), Ce = /* @__PURE__ */ u((e, n) => {
|
|
154
|
+
if (!e || n > 10) {
|
|
155
|
+
o.debug("Opting out, no graph ");
|
|
156
|
+
return;
|
|
157
|
+
} else
|
|
158
|
+
o.debug("Opting in, graph ");
|
|
159
|
+
e.nodes().forEach(function(t) {
|
|
160
|
+
e.children(t).length > 0 && (o.debug(
|
|
161
|
+
"Cluster identified",
|
|
162
|
+
t,
|
|
163
|
+
" Replacement id in edges: ",
|
|
164
|
+
C(t, e, t)
|
|
165
|
+
), b.set(t, X(t, e)), l.set(t, { id: C(t, e, t), clusterData: e.node(t) }));
|
|
166
|
+
}), e.nodes().forEach(function(t) {
|
|
167
|
+
const r = e.children(t), s = e.edges();
|
|
168
|
+
r.length > 0 ? (o.debug("Cluster identified", t, b), s.forEach((i) => {
|
|
169
|
+
const c = v(i.v, t), f = v(i.w, t);
|
|
170
|
+
c ^ f && (o.debug("Edge: ", i, " leaves cluster ", t), o.debug("Descendants of XXX ", t, ": ", b.get(t)), l.get(t).externalConnections = !0);
|
|
171
|
+
})) : o.debug("Not a cluster ", t, b);
|
|
172
|
+
});
|
|
173
|
+
for (let t of l.keys()) {
|
|
174
|
+
const r = l.get(t).id, s = e.parent(r);
|
|
175
|
+
s !== t && l.has(s) && !l.get(s).externalConnections && (l.get(t).id = s);
|
|
176
|
+
const i = e.edges().some((c) => c.v === t);
|
|
177
|
+
if (r && l.get(t)?.externalConnections && i && $(e, r, t)) {
|
|
178
|
+
const c = he(e, t, e.parent(r));
|
|
179
|
+
c && (l.get(t).id = c);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
e.edges().forEach(function(t) {
|
|
183
|
+
const r = e.edge(t);
|
|
184
|
+
o.debug("Edge " + t.v + " -> " + t.w + ": " + JSON.stringify(t)), o.debug("Edge " + t.v + " -> " + t.w + ": " + JSON.stringify(e.edge(t)));
|
|
185
|
+
let s = t.v, i = t.w;
|
|
186
|
+
if (o.debug(
|
|
187
|
+
"Fix XXX",
|
|
188
|
+
l,
|
|
189
|
+
"ids:",
|
|
190
|
+
t.v,
|
|
191
|
+
t.w,
|
|
192
|
+
"Translating: ",
|
|
193
|
+
l.get(t.v),
|
|
194
|
+
" --- ",
|
|
195
|
+
l.get(t.w)
|
|
196
|
+
), l.get(t.v) || l.get(t.w)) {
|
|
197
|
+
if (o.debug("Fixing and trying - removing XXX", t.v, t.w, t.name), s = L(t.v), i = L(t.w), e.removeEdge(t.v, t.w, t.name), s !== t.v) {
|
|
198
|
+
const c = e.parent(s);
|
|
199
|
+
l.get(c).externalConnections = !0, r.fromCluster = t.v;
|
|
200
|
+
}
|
|
201
|
+
if (i !== t.w) {
|
|
202
|
+
const c = e.parent(i);
|
|
203
|
+
l.get(c).externalConnections = !0, r.toCluster = t.w;
|
|
204
|
+
}
|
|
205
|
+
o.debug("Fix Replacing with XXX", s, i, t.name), e.setEdge(s, i, r, t.name);
|
|
206
|
+
}
|
|
207
|
+
}), O(e, 0), o.trace(l);
|
|
208
|
+
}, "adjustClustersAndEdges"), O = /* @__PURE__ */ u((e, n) => {
|
|
209
|
+
if (n > 10) {
|
|
210
|
+
o.error("Bailing out");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
let t = e.nodes(), r = !1;
|
|
214
|
+
for (const s of t) {
|
|
215
|
+
const i = e.children(s);
|
|
216
|
+
r = r || i.length > 0;
|
|
217
|
+
}
|
|
218
|
+
if (!r) {
|
|
219
|
+
o.debug("Done, no node has children", e.nodes());
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
o.debug("Nodes = ", t, n);
|
|
223
|
+
for (const s of t)
|
|
224
|
+
if (o.debug(
|
|
225
|
+
"Extracting node",
|
|
226
|
+
s,
|
|
227
|
+
l,
|
|
228
|
+
l.has(s) && !l.get(s).externalConnections,
|
|
229
|
+
!e.parent(s),
|
|
230
|
+
e.node(s),
|
|
231
|
+
e.children("D"),
|
|
232
|
+
" Depth ",
|
|
233
|
+
n
|
|
234
|
+
), !l.has(s))
|
|
235
|
+
o.debug("Not a cluster", s, n);
|
|
236
|
+
else if (!l.get(s).externalConnections && e.children(s) && e.children(s).length > 0) {
|
|
237
|
+
o.debug(
|
|
238
|
+
"Cluster without external connections, without a parent and with children",
|
|
239
|
+
s,
|
|
240
|
+
n
|
|
241
|
+
);
|
|
242
|
+
let c = e.graph().rankdir === "TB" ? "LR" : "TB";
|
|
243
|
+
l.get(s)?.clusterData?.dir && (c = l.get(s).clusterData.dir, o.debug("Fixing dir", l.get(s).clusterData.dir, c));
|
|
244
|
+
const f = new R({
|
|
245
|
+
multigraph: !0,
|
|
246
|
+
compound: !0
|
|
247
|
+
}).setGraph({
|
|
248
|
+
rankdir: c,
|
|
249
|
+
nodesep: 50,
|
|
250
|
+
ranksep: 50,
|
|
251
|
+
marginx: 8,
|
|
252
|
+
marginy: 8
|
|
253
|
+
}).setDefaultEdgeLabel(function() {
|
|
254
|
+
return {};
|
|
255
|
+
});
|
|
256
|
+
G(s, e, f, s), e.setNode(s, {
|
|
257
|
+
clusterNode: !0,
|
|
258
|
+
id: s,
|
|
259
|
+
clusterData: l.get(s).clusterData,
|
|
260
|
+
label: l.get(s).label,
|
|
261
|
+
graph: f
|
|
262
|
+
});
|
|
263
|
+
} else
|
|
264
|
+
o.debug(
|
|
265
|
+
"Cluster ** ",
|
|
266
|
+
s,
|
|
267
|
+
" **not meeting the criteria !externalConnections:",
|
|
268
|
+
!l.get(s).externalConnections,
|
|
269
|
+
" no parent: ",
|
|
270
|
+
!e.parent(s),
|
|
271
|
+
" children ",
|
|
272
|
+
e.children(s) && e.children(s).length > 0,
|
|
273
|
+
e.children("D"),
|
|
274
|
+
n
|
|
275
|
+
), o.debug(l);
|
|
276
|
+
t = e.nodes(), o.debug("New list of nodes", t);
|
|
277
|
+
for (const s of t) {
|
|
278
|
+
const i = e.node(s);
|
|
279
|
+
o.debug(" Now next level", s, i), i?.clusterNode && O(i.graph, n + 1);
|
|
280
|
+
}
|
|
281
|
+
}, "extractor"), F = /* @__PURE__ */ u((e, n) => {
|
|
282
|
+
if (n.length === 0)
|
|
283
|
+
return [];
|
|
284
|
+
let t = Object.assign([], n);
|
|
285
|
+
return n.forEach((r) => {
|
|
286
|
+
const s = e.children(r), i = F(e, s);
|
|
287
|
+
t = [...t, ...i];
|
|
288
|
+
}), t;
|
|
289
|
+
}, "sorter"), Ne = /* @__PURE__ */ u((e) => F(e, e.children()), "sortNodesByHierarchy"), $ = /* @__PURE__ */ u((e, n, t) => {
|
|
290
|
+
let r = e.parent(n);
|
|
291
|
+
for (; r && r !== t; ) {
|
|
292
|
+
const s = l.get(r);
|
|
293
|
+
if (s && !s.externalConnections)
|
|
294
|
+
return !0;
|
|
295
|
+
r = e.parent(r);
|
|
296
|
+
}
|
|
297
|
+
return !1;
|
|
298
|
+
}, "isNodeInExtractableCluster"), he = /* @__PURE__ */ u((e, n, t) => {
|
|
299
|
+
const r = e.children(n) ?? [];
|
|
300
|
+
for (const s of r) {
|
|
301
|
+
if (s === t || v(s, t))
|
|
302
|
+
continue;
|
|
303
|
+
const i = C(s, e, n);
|
|
304
|
+
if (i && !$(e, i, n))
|
|
305
|
+
return i;
|
|
306
|
+
}
|
|
307
|
+
return null;
|
|
308
|
+
}, "findSafeAnchorNode");
|
|
309
|
+
function we({
|
|
310
|
+
prepareLayout: e,
|
|
311
|
+
measureLayout: n,
|
|
312
|
+
runLayoutCore: t,
|
|
313
|
+
paintLayout: r,
|
|
314
|
+
afterPaint: s,
|
|
315
|
+
paintOptions: i
|
|
316
|
+
}) {
|
|
317
|
+
const c = n ?? z;
|
|
318
|
+
return /* @__PURE__ */ u(async function(a, g, h, N) {
|
|
319
|
+
const w = g.select("g");
|
|
320
|
+
(h?.insertMarkers ?? Z)(
|
|
321
|
+
w,
|
|
322
|
+
a.markers,
|
|
323
|
+
a.type,
|
|
324
|
+
a.diagramId
|
|
325
|
+
), j();
|
|
326
|
+
const d = {
|
|
327
|
+
element: w,
|
|
328
|
+
// root SVG <g>
|
|
329
|
+
helpers: h,
|
|
330
|
+
// Mermaid helper functions
|
|
331
|
+
options: N
|
|
332
|
+
// { algorithm: "elk.layered" }
|
|
333
|
+
};
|
|
334
|
+
d.preparedLayout = await e?.(a, d);
|
|
335
|
+
const m = await c(a, d), E = await t(a, d), p = {
|
|
336
|
+
...d,
|
|
337
|
+
measure: m
|
|
338
|
+
};
|
|
339
|
+
r ? await r(a, p, E) : await H(
|
|
340
|
+
a,
|
|
341
|
+
p,
|
|
342
|
+
i
|
|
343
|
+
), await s?.(a, p, E);
|
|
344
|
+
}, "render");
|
|
345
|
+
}
|
|
346
|
+
u(we, "createCommonLayoutRenderer");
|
|
347
|
+
function j() {
|
|
348
|
+
ee(), te(), ne(), fe();
|
|
349
|
+
}
|
|
350
|
+
u(j, "clearLayoutRenderState");
|
|
351
|
+
async function z(e, { element: n }, t) {
|
|
352
|
+
return await A(n, e, t);
|
|
353
|
+
}
|
|
354
|
+
u(z, "defaultMeasureLayout");
|
|
355
|
+
async function H(e, n, t = {}) {
|
|
356
|
+
const { measure: r } = n, { groups: s } = r;
|
|
357
|
+
for (const c of t.getNodes?.(e, n) ?? e.nodes)
|
|
358
|
+
t.skipNode?.(c, n) || await J(s, c, n, t);
|
|
359
|
+
const i = V(e.nodes);
|
|
360
|
+
for (const c of e.edges)
|
|
361
|
+
Y(c, t) || await q(s, c, i, e, t, n);
|
|
362
|
+
}
|
|
363
|
+
u(H, "paintLayoutData");
|
|
364
|
+
async function J(e, n, t, r) {
|
|
365
|
+
n.clusterNode ? x(n) : W(n, t, r) ? await se(e.clusters, n) : x(n);
|
|
366
|
+
}
|
|
367
|
+
u(J, "paintLayoutNode");
|
|
368
|
+
function W(e, n, t) {
|
|
369
|
+
return e.isGroup === !0 && (t.isCluster?.(e, n) ?? !0);
|
|
370
|
+
}
|
|
371
|
+
u(W, "shouldPaintAsCluster");
|
|
372
|
+
function V(e) {
|
|
373
|
+
const n = /* @__PURE__ */ new Map();
|
|
374
|
+
for (const t of e)
|
|
375
|
+
t?.id && n.set(t.id, t);
|
|
376
|
+
return n;
|
|
377
|
+
}
|
|
378
|
+
u(V, "buildNodeLookup");
|
|
379
|
+
function Y(e, n) {
|
|
380
|
+
return e.isLayoutOnly || !!n.skipEdge?.(e);
|
|
381
|
+
}
|
|
382
|
+
u(Y, "shouldSkipPaintEdge");
|
|
383
|
+
async function q(e, n, t, r, s, i) {
|
|
384
|
+
const c = re(
|
|
385
|
+
e.edgePaths,
|
|
386
|
+
{ ...n },
|
|
387
|
+
s.clusterDb ?? /* @__PURE__ */ new Map(),
|
|
388
|
+
r.type,
|
|
389
|
+
y(n.start, n, t, i, s),
|
|
390
|
+
y(n.end, n, t, i, s),
|
|
391
|
+
r.diagramId,
|
|
392
|
+
K(n, s),
|
|
393
|
+
r.layoutAlgorithm
|
|
394
|
+
);
|
|
395
|
+
D(n) && (S.has(n.id) || await k(e.edgeLabels, n), Q(n, c));
|
|
396
|
+
}
|
|
397
|
+
u(q, "paintLayoutEdge");
|
|
398
|
+
function y(e, n, t, r, s) {
|
|
399
|
+
return s.getEdgeNode?.(e, n, r) ?? (e ? t.get(e) ?? {} : {});
|
|
400
|
+
}
|
|
401
|
+
u(y, "getRenderedNode");
|
|
402
|
+
function K(e, n) {
|
|
403
|
+
return typeof n.skipIntersect == "function" ? n.skipIntersect(e) : n.skipIntersect ?? !1;
|
|
404
|
+
}
|
|
405
|
+
u(K, "shouldSkipIntersect");
|
|
406
|
+
function Q(e, n) {
|
|
407
|
+
const t = n?.updatedPath ?? n?.originalPath, r = ae(), { subGraphTitleTotalMargin: s } = oe({
|
|
408
|
+
flowchart: r.flowchart ?? {}
|
|
409
|
+
});
|
|
410
|
+
if (e.label) {
|
|
411
|
+
const i = S.get(e.id), { x: c, y: f } = ce(e, n);
|
|
412
|
+
i.attr("transform", `translate(${c}, ${f + s / 2})`);
|
|
413
|
+
}
|
|
414
|
+
for (const [i, c] of [
|
|
415
|
+
["startLeft", e.startLabelLeft],
|
|
416
|
+
["startRight", e.startLabelRight],
|
|
417
|
+
["endLeft", e.endLabelLeft],
|
|
418
|
+
["endRight", e.endLabelRight]
|
|
419
|
+
])
|
|
420
|
+
if (c) {
|
|
421
|
+
const { x: f, y: a } = U(e, i, t);
|
|
422
|
+
le.get(e.id)[i].attr("transform", `translate(${f}, ${a})`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
u(Q, "positionRenderedEdgeLabel");
|
|
426
|
+
var me = {
|
|
427
|
+
startLeft: "start_left",
|
|
428
|
+
startRight: "start_right",
|
|
429
|
+
endLeft: "end_left",
|
|
430
|
+
endRight: "end_right"
|
|
431
|
+
};
|
|
432
|
+
function U(e, n, t) {
|
|
433
|
+
const r = e.terminalLabelCenters?.[n];
|
|
434
|
+
if (r)
|
|
435
|
+
return { ...r };
|
|
436
|
+
if (!t)
|
|
437
|
+
return { x: e.x, y: e.y };
|
|
438
|
+
const s = n.startsWith("start") ? e.arrowTypeStart : e.arrowTypeEnd;
|
|
439
|
+
return de.calcTerminalLabelPosition(s ? 10 : 0, me[n], t);
|
|
440
|
+
}
|
|
441
|
+
u(U, "terminalLabelTranslate");
|
|
442
|
+
export {
|
|
443
|
+
Ce as a,
|
|
444
|
+
T as b,
|
|
445
|
+
we as c,
|
|
446
|
+
z as d,
|
|
447
|
+
l as e,
|
|
448
|
+
C as f,
|
|
449
|
+
B as i,
|
|
450
|
+
Ne as s
|
|
451
|
+
};
|