@draftably/runtime 0.3.0 → 0.5.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 +2 -1
- package/dist/assets/render.worker-D11vTqoO.js +8548 -0
- package/dist/compile-BAIrdu-8.js +7405 -0
- package/dist/element.js +275 -125
- package/dist/{font-data-DLXJur0j.js → font-data-DME3E71S.js} +1 -1
- package/dist/geometry-DfUVE8b2.js +79 -0
- package/dist/graph.js +336 -373
- package/dist/host.css +37 -0
- package/dist/host.js +24 -0
- package/dist/index.js +3 -3
- package/dist/render-CsJYFD3o.js +1188 -0
- package/dist/types/src/dsl/cells.d.ts +1 -0
- package/dist/types/src/dsl/compile.d.ts +2 -1
- package/dist/types/src/dsl/legend-notes.d.ts +14 -0
- package/dist/types/src/dsl/syntax.d.ts +2 -0
- package/dist/types/src/model/appearance.d.ts +27 -1
- package/dist/types/src/model/colors.d.ts +10 -2
- package/dist/types/src/model/labels.d.ts +22 -6
- package/dist/types/src/runtime/anchors.d.ts +46 -0
- package/dist/types/src/runtime/camera.d.ts +41 -0
- package/dist/types/src/runtime/color-scheme.d.ts +15 -0
- package/dist/types/src/runtime/element-base.d.ts +40 -0
- package/dist/types/src/runtime/element.d.ts +7 -0
- package/dist/types/src/runtime/geometry.d.ts +72 -0
- package/dist/types/src/runtime/host.d.ts +78 -0
- package/dist/types/src/runtime/index.d.ts +1 -0
- package/dist/types/src/runtime/page-shared.d.ts +24 -0
- package/dist/types/src/runtime/schemes.d.ts +2 -0
- package/dist/types/src/runtime/svg-renderer.d.ts +12 -0
- package/dist/types/src/runtime/types.d.ts +13 -0
- package/dist/types/src/runtime/viewer.d.ts +41 -7
- package/dist/version-CO7i33cq.js +4 -0
- package/dist/viewer.css +72 -9
- package/dist/viewer.js +713 -346
- package/package.json +6 -1
- package/dist/assets/render.worker-dvseyGmC.js +0 -8310
- package/dist/compile-Csfz4rk4.js +0 -7267
- package/dist/render-Dgo42PR4.js +0 -1146
package/dist/graph.js
CHANGED
|
@@ -1,153 +1,116 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as ne, a as re, b as m, q as F, p as se, d as ae, e as de, f as le, v as ce, g as N, r as ue } from "./compile-BAIrdu-8.js";
|
|
2
|
+
import { p as pe } from "./geometry-DfUVE8b2.js";
|
|
2
3
|
const _ = /^[A-Za-z_][A-Za-z0-9_.-]*$/;
|
|
3
4
|
function H(e, t) {
|
|
4
|
-
const
|
|
5
|
-
let
|
|
6
|
-
for (const
|
|
7
|
-
if (typeof
|
|
8
|
-
if (
|
|
9
|
-
let
|
|
10
|
-
if (!_.test(
|
|
5
|
+
const r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), n = new Set(e.filter((s) => _.test(s)));
|
|
6
|
+
let a = 0;
|
|
7
|
+
for (const s of e) {
|
|
8
|
+
if (typeof s != "string" || !s) throw Error(`Every ${t} needs a string id.`);
|
|
9
|
+
if (r.has(s)) throw Error(`Duplicate ${t} id "${s}".`);
|
|
10
|
+
let u = s;
|
|
11
|
+
if (!_.test(s)) {
|
|
11
12
|
do
|
|
12
|
-
|
|
13
|
-
while (
|
|
14
|
-
|
|
13
|
+
u = `_${a++}`;
|
|
14
|
+
while (n.has(u));
|
|
15
|
+
n.add(u);
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
r.set(s, u), o.set(u, s);
|
|
17
18
|
}
|
|
18
19
|
return {
|
|
19
|
-
of: (
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
22
|
-
return
|
|
20
|
+
of: (s, u) => {
|
|
21
|
+
const l = r.get(s);
|
|
22
|
+
if (!l) throw Error(`${u} refers to unknown id "${s}".`);
|
|
23
|
+
return l;
|
|
23
24
|
},
|
|
24
|
-
back: (
|
|
25
|
+
back: (s) => o.get(s) ?? s
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function C(e) {
|
|
28
29
|
const t = new Set(e.flatMap((o) => o.id ? [o.id] : []));
|
|
29
|
-
let
|
|
30
|
+
let r = 0;
|
|
30
31
|
return e.map((o) => {
|
|
31
32
|
if (o.id) return o.id;
|
|
32
|
-
let
|
|
33
|
+
let n;
|
|
33
34
|
do
|
|
34
|
-
|
|
35
|
-
while (t.has(
|
|
36
|
-
return
|
|
35
|
+
n = `e${++r}`;
|
|
36
|
+
while (t.has(n));
|
|
37
|
+
return n;
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
const he = (e) => e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
|
|
40
|
-
function M(e, t,
|
|
41
|
+
function M(e, t, r = {}) {
|
|
41
42
|
return {
|
|
42
43
|
kind: "statement",
|
|
43
44
|
command: e,
|
|
44
45
|
args: t,
|
|
45
|
-
attrs: Object.entries(
|
|
46
|
+
attrs: Object.entries(r).filter(([, o]) => o !== void 0 && o !== "").map(([o, n]) => [
|
|
46
47
|
o,
|
|
47
|
-
typeof
|
|
48
|
+
typeof n == "string" && !/^[\w.-]+$/.test(n) ? F(n) : m(String(n))
|
|
48
49
|
]),
|
|
49
50
|
line: 0
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
function A(e, t,
|
|
53
|
+
function A(e, t, r) {
|
|
53
54
|
const o = t.startsWith("engine:") ? t.slice(7) : void 0;
|
|
54
|
-
return M("layout", o ? [
|
|
55
|
+
return M("layout", o ? [m(e)] : [m(e), m(t)], {
|
|
55
56
|
...o ? { engine: o } : {},
|
|
56
|
-
...
|
|
57
|
+
...r
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
|
-
function U(e) {
|
|
60
|
-
if (!e.length) return { x: 0, y: 0, width: 0, height: 0 };
|
|
61
|
-
const t = Math.min(...e.map((o) => o.x)), n = Math.min(...e.map((o) => o.y));
|
|
62
|
-
return {
|
|
63
|
-
x: t,
|
|
64
|
-
y: n,
|
|
65
|
-
width: Math.max(...e.map((o) => o.x + o.width)) - t,
|
|
66
|
-
height: Math.max(...e.map((o) => o.y + o.height)) - n
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
60
|
const ge = 1200;
|
|
70
|
-
function fe(e, t,
|
|
61
|
+
function fe(e, t, r, o = "auto") {
|
|
71
62
|
if (o === "full")
|
|
72
|
-
return { ...N(e, t,
|
|
73
|
-
const
|
|
74
|
-
return o === "quick" ||
|
|
63
|
+
return { ...N(e, t, r, { previous: [] }), quality: "full" };
|
|
64
|
+
const n = N(e, t, r, { previous: [], quick: !0 }), { edges: a, crossings: s, lanePairs: u, shared: l } = n.result.report, f = a * (1 + s + u + (l ? 1 : 0));
|
|
65
|
+
return o === "quick" || f > ge ? { ...n, quality: "quick" } : { ...N(e, t, r, { previous: [] }), quality: "full" };
|
|
75
66
|
}
|
|
76
|
-
function
|
|
77
|
-
const { vg:
|
|
78
|
-
const w = d.get(u), m = p.get(u);
|
|
79
|
-
return { x: w.x, y: w.y, width: w.w, height: w.h, ...m ? { parent: n(m) } : {} };
|
|
80
|
-
}, f = Object.fromEntries(s.nodes.map((u) => [n(u.id), y(u.id)])), i = Object.fromEntries(s.groups.map((u) => [n(u.id), y(u.id)])), l = Object.fromEntries(
|
|
81
|
-
r.routes.map((u) => [
|
|
82
|
-
o(u.id),
|
|
83
|
-
{
|
|
84
|
-
source: n(c.get(u.id)?.from ?? u.from),
|
|
85
|
-
target: n(c.get(u.id)?.to ?? u.to),
|
|
86
|
-
sourceSide: u.fromSide,
|
|
87
|
-
targetSide: u.toSide,
|
|
88
|
-
points: u.points,
|
|
89
|
-
path: u.path,
|
|
90
|
-
label: u.label ? {
|
|
91
|
-
x: u.label.x - u.label.w / 2,
|
|
92
|
-
y: u.label.y - u.label.h / 2,
|
|
93
|
-
width: u.label.w,
|
|
94
|
-
height: u.label.h
|
|
95
|
-
} : null,
|
|
96
|
-
blocked: u.blocked
|
|
97
|
-
}
|
|
98
|
-
])
|
|
99
|
-
), a = [...Object.values(f), ...Object.values(i)];
|
|
100
|
-
for (const u of Object.values(l))
|
|
101
|
-
u.label && a.push(u.label), a.push(U(u.points.map((w) => ({ ...w, width: 0, height: 0 }))));
|
|
102
|
-
const g = Object.values(l).filter((u) => u.blocked).length;
|
|
67
|
+
function G(e, t, r, o) {
|
|
68
|
+
const { vg: n, rects: a } = ce(e), s = fe(e, n, a, t), u = pe(e, a, s.routes, r, o), l = Object.values(u.edges).filter((f) => f.blocked).length;
|
|
103
69
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
bounds: U(a),
|
|
108
|
-
quality: r.quality,
|
|
109
|
-
warnings: g ? [`${g} line${g > 1 ? "s" : ""} found no clear way.`] : []
|
|
70
|
+
...u,
|
|
71
|
+
quality: s.quality,
|
|
72
|
+
warnings: l ? [`${l} line${l > 1 ? "s" : ""} found no clear way.`] : []
|
|
110
73
|
};
|
|
111
74
|
}
|
|
112
|
-
function ye(e, t,
|
|
75
|
+
function ye(e, t, r) {
|
|
113
76
|
let o = e;
|
|
114
|
-
for (const
|
|
115
|
-
n
|
|
77
|
+
for (const n of t)
|
|
78
|
+
r(n) !== n && (o = o.replace(new RegExp(`\\b${n}\\b`, "g"), `"${r(n)}"`));
|
|
116
79
|
return o;
|
|
117
80
|
}
|
|
118
81
|
function be(e, t) {
|
|
119
|
-
const
|
|
82
|
+
const r = (o, n, a, s) => {
|
|
120
83
|
if (o === void 0 || !Number.isFinite(o)) return;
|
|
121
|
-
const
|
|
122
|
-
return
|
|
84
|
+
const u = Math.round(Math.min(a, Math.max(n, o)));
|
|
85
|
+
return u !== Math.round(o) && t.push(`Node "${e.id}" ${s} ${o} is outside ${n}–${a}; drawn at ${u}.`), u;
|
|
123
86
|
};
|
|
124
|
-
return { width:
|
|
87
|
+
return { width: r(e.width, 40, 1200, "width"), height: r(e.height, 24, 1200, "height") };
|
|
125
88
|
}
|
|
126
|
-
function
|
|
127
|
-
const t = e.groups ?? [],
|
|
89
|
+
function K(e) {
|
|
90
|
+
const t = e.groups ?? [], r = e.nodes ?? [], o = e.edges ?? [], n = C(o), a = H([...t.map((d) => d.id), ...r.map((d) => d.id)], "node or group"), s = H(n, "edge"), u = a.of, { quality: l, ...f } = e.routing ?? {}, h = [], i = [
|
|
128
91
|
...t.map(
|
|
129
|
-
(
|
|
130
|
-
in:
|
|
92
|
+
(d) => M("group", [m(u(d.id, "group")), F(d.label ?? d.id)], {
|
|
93
|
+
in: d.parent && u(d.parent, `Group "${d.id}"`),
|
|
131
94
|
fold: e.fold === "never" ? "never" : void 0
|
|
132
95
|
})
|
|
133
96
|
),
|
|
134
|
-
...
|
|
135
|
-
(
|
|
136
|
-
in:
|
|
137
|
-
shape:
|
|
97
|
+
...r.map(
|
|
98
|
+
(d) => M("node", [m(u(d.id, "node")), F(d.label ?? d.id)], {
|
|
99
|
+
in: d.parent && u(d.parent, `Node "${d.id}"`),
|
|
100
|
+
shape: d.shape
|
|
138
101
|
})
|
|
139
102
|
),
|
|
140
103
|
...o.map(
|
|
141
|
-
(
|
|
104
|
+
(d, g) => M(
|
|
142
105
|
"edge",
|
|
143
106
|
[
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...
|
|
107
|
+
m(s.of(n[g], "edge")),
|
|
108
|
+
m(u(d.source, `Edge "${n[g]}"`)),
|
|
109
|
+
m("->"),
|
|
110
|
+
m(u(d.target, `Edge "${n[g]}"`)),
|
|
111
|
+
...d.label ? [F(d.label)] : []
|
|
149
112
|
],
|
|
150
|
-
{ kind:
|
|
113
|
+
{ kind: d.dashed ? "async" : void 0, from: d.sourceSide, to: d.targetSide }
|
|
151
114
|
)
|
|
152
115
|
),
|
|
153
116
|
// A file with no layout line spaces its root flow 48px apart; a layout line without `gap=`
|
|
@@ -158,141 +121,141 @@ function Z(e) {
|
|
|
158
121
|
fit: e.fit,
|
|
159
122
|
fold: e.fold === "never" ? "never" : void 0
|
|
160
123
|
}),
|
|
161
|
-
...t.filter((
|
|
162
|
-
(
|
|
163
|
-
gap:
|
|
164
|
-
direction:
|
|
124
|
+
...t.filter((d) => d.arrange || d.direction || d.gap).map(
|
|
125
|
+
(d) => A(u(d.id, "group"), d.arrange ?? "column", {
|
|
126
|
+
gap: d.gap,
|
|
127
|
+
direction: d.direction
|
|
165
128
|
})
|
|
166
129
|
),
|
|
167
|
-
...
|
|
168
|
-
const { width: g, height:
|
|
169
|
-
return g ||
|
|
170
|
-
M("size", [
|
|
130
|
+
...r.flatMap((d) => {
|
|
131
|
+
const { width: g, height: y } = be(d, h);
|
|
132
|
+
return g || y ? [
|
|
133
|
+
M("size", [m(u(d.id, "node"))], {
|
|
171
134
|
width: g ?? 176,
|
|
172
|
-
height:
|
|
135
|
+
height: y ?? "auto"
|
|
173
136
|
})
|
|
174
137
|
] : [];
|
|
175
138
|
}),
|
|
176
|
-
...Object.keys(
|
|
139
|
+
...Object.keys(f).length ? [
|
|
177
140
|
M(
|
|
178
141
|
"routing",
|
|
179
142
|
[],
|
|
180
|
-
Object.fromEntries(Object.entries(
|
|
143
|
+
Object.fromEntries(Object.entries(f).map(([d, g]) => [he(d), g]))
|
|
181
144
|
)
|
|
182
145
|
] : []
|
|
183
146
|
];
|
|
184
|
-
return { draft:
|
|
147
|
+
return { draft: se({ lines: i }), model: ae({ lines: i }), quality: l, objects: a, lines: s, warnings: h };
|
|
185
148
|
}
|
|
186
|
-
function
|
|
187
|
-
const
|
|
149
|
+
function Z({ draft: e, model: t, quality: r, objects: o, lines: n, warnings: a }, s) {
|
|
150
|
+
const u = G(de(s), r, o.back, n.back);
|
|
188
151
|
return {
|
|
189
|
-
...
|
|
152
|
+
...u,
|
|
190
153
|
draft: e,
|
|
191
154
|
warnings: [
|
|
192
|
-
...
|
|
193
|
-
...t.warnings.map((
|
|
155
|
+
...a,
|
|
156
|
+
...t.warnings.map((l) => l.message),
|
|
194
157
|
// A caller's size is the host's to fill: whether draftably's text fits it says nothing.
|
|
195
|
-
...
|
|
196
|
-
...
|
|
158
|
+
...s.diagnostics.filter((l) => l.level !== "info" && l.code !== "text-overflow").map((l) => ye(l.message, l.ids, o.back)),
|
|
159
|
+
...u.warnings
|
|
197
160
|
]
|
|
198
161
|
};
|
|
199
162
|
}
|
|
200
163
|
async function T(e) {
|
|
201
|
-
const t =
|
|
202
|
-
return
|
|
164
|
+
const t = K(e);
|
|
165
|
+
return Z(t, await re(t.draft));
|
|
203
166
|
}
|
|
204
|
-
function
|
|
205
|
-
const t =
|
|
206
|
-
if (t.model.layouts.some((
|
|
167
|
+
function J(e) {
|
|
168
|
+
const t = K(e);
|
|
169
|
+
if (t.model.layouts.some((r) => r.engine || r.fit))
|
|
207
170
|
throw Error("layoutSync cannot run layout engines or fit; use layout().");
|
|
208
|
-
return
|
|
171
|
+
return Z(t, ne(t.draft));
|
|
209
172
|
}
|
|
210
|
-
function
|
|
211
|
-
const t =
|
|
212
|
-
t.settings.routing = { ...t.settings.routing, ...
|
|
213
|
-
for (const i of [...
|
|
173
|
+
function U(e) {
|
|
174
|
+
const t = le(), r = e.groups ?? [], o = /* @__PURE__ */ new Set(), { quality: n, ...a } = e.routing ?? {}, s = C(e.edges);
|
|
175
|
+
t.settings.routing = { ...t.settings.routing, ...a };
|
|
176
|
+
for (const i of [...r, ...e.nodes]) {
|
|
214
177
|
if (o.has(i.id)) throw Error(`Duplicate node or group id "${i.id}".`);
|
|
215
178
|
o.add(i.id);
|
|
216
179
|
}
|
|
217
|
-
const
|
|
218
|
-
if (i !== void 0 && !o.has(i)) throw Error(`${
|
|
180
|
+
const u = (i, c) => {
|
|
181
|
+
if (i !== void 0 && !o.has(i)) throw Error(`${c} refers to unknown id "${i}".`);
|
|
219
182
|
};
|
|
220
|
-
for (const i of
|
|
221
|
-
|
|
183
|
+
for (const i of r)
|
|
184
|
+
u(i.parent, `Group "${i.id}"`), t.graph.groups.push({
|
|
222
185
|
id: i.id,
|
|
223
186
|
title: i.label ?? "",
|
|
224
187
|
...i.parent ? { parentId: i.parent } : {}
|
|
225
188
|
}), t.layout.containers[i.id] = { direction: "inherit", padding: 0, manualSize: !0 };
|
|
226
189
|
for (const i of e.nodes)
|
|
227
|
-
|
|
228
|
-
for (const i of [...
|
|
190
|
+
u(i.parent, `Node "${i.id}"`), t.graph.nodes.push({ id: i.id, title: "", ...i.parent ? { parentId: i.parent } : {} }), t.styles[i.id] = { shape: i.shape ?? "box", color: "auto", icon: "" };
|
|
191
|
+
for (const i of [...r, ...e.nodes])
|
|
229
192
|
t.layout.nodes[i.id] = { x: i.x, y: i.y, w: i.width, h: i.height };
|
|
230
|
-
e.edges.forEach((i,
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
id:
|
|
193
|
+
e.edges.forEach((i, c) => {
|
|
194
|
+
const d = s[c];
|
|
195
|
+
u(i.source, `Edge "${d}"`), u(i.target, `Edge "${d}"`), t.graph.edges.push({
|
|
196
|
+
id: d,
|
|
234
197
|
from: i.source,
|
|
235
198
|
to: i.target,
|
|
236
199
|
label: i.label ?? "",
|
|
237
200
|
directed: !0,
|
|
238
201
|
emphasis: !1,
|
|
239
202
|
dashed: !!i.dashed
|
|
240
|
-
}), t.layout.edges[
|
|
203
|
+
}), t.layout.edges[d] = {
|
|
241
204
|
...i.sourceSide ? { fromSide: i.sourceSide } : {},
|
|
242
205
|
...i.targetSide ? { toSide: i.targetSide } : {}
|
|
243
206
|
};
|
|
244
207
|
});
|
|
245
208
|
const {
|
|
246
|
-
edges:
|
|
247
|
-
quality:
|
|
248
|
-
warnings:
|
|
249
|
-
} =
|
|
209
|
+
edges: l,
|
|
210
|
+
quality: f,
|
|
211
|
+
warnings: h
|
|
212
|
+
} = G(
|
|
250
213
|
t,
|
|
251
|
-
|
|
214
|
+
n,
|
|
252
215
|
(i) => i,
|
|
253
216
|
(i) => i
|
|
254
217
|
);
|
|
255
|
-
return { edges:
|
|
218
|
+
return { edges: l, quality: f, warnings: h };
|
|
256
219
|
}
|
|
257
|
-
const we = /* @__PURE__ */ new Set(["left", "right", "top", "bottom"]),
|
|
220
|
+
const we = /* @__PURE__ */ new Set(["left", "right", "top", "bottom"]), W = (e) => e && we.has(e) ? e : void 0, E = (e) => typeof e == "number" && e > 0 ? e : void 0, k = (e) => e.parentId ?? e.parentNode, I = (e) => typeof e.data?.label == "string" ? e.data.label : e.id, Q = (e) => {
|
|
258
221
|
const t = typeof e.style == "object" ? e.style : void 0;
|
|
259
222
|
return {
|
|
260
223
|
width: E(e.measured?.width) ?? E(e.width) ?? E(t?.width),
|
|
261
224
|
height: E(e.measured?.height) ?? E(e.height) ?? E(t?.height)
|
|
262
225
|
};
|
|
263
|
-
},
|
|
226
|
+
}, V = (e) => /* @__PURE__ */ new Set([
|
|
264
227
|
...e.flatMap((t) => k(t) ? [k(t)] : []),
|
|
265
228
|
...e.filter((t) => t.type === "group").map((t) => t.id)
|
|
266
229
|
]);
|
|
267
|
-
function
|
|
268
|
-
const o =
|
|
230
|
+
function X({ nodes: e, edges: t }, r = {}) {
|
|
231
|
+
const o = V(e);
|
|
269
232
|
return {
|
|
270
|
-
groups: e.filter((
|
|
271
|
-
nodes: e.filter((
|
|
272
|
-
const { width:
|
|
233
|
+
groups: e.filter((n) => o.has(n.id)).map((n) => ({ id: n.id, label: I(n), parent: k(n) })),
|
|
234
|
+
nodes: e.filter((n) => !o.has(n.id)).map((n) => {
|
|
235
|
+
const { width: a, height: s } = Q(n);
|
|
273
236
|
return {
|
|
274
|
-
id:
|
|
275
|
-
label:
|
|
276
|
-
parent: k(
|
|
277
|
-
shape:
|
|
278
|
-
...
|
|
279
|
-
...
|
|
237
|
+
id: n.id,
|
|
238
|
+
label: I(n),
|
|
239
|
+
parent: k(n),
|
|
240
|
+
shape: r.shape?.(n),
|
|
241
|
+
...a ? { width: a } : {},
|
|
242
|
+
...s ? { height: s } : {}
|
|
280
243
|
};
|
|
281
244
|
}),
|
|
282
|
-
edges: t.map((
|
|
283
|
-
id:
|
|
284
|
-
source:
|
|
285
|
-
target:
|
|
286
|
-
label: typeof
|
|
287
|
-
dashed:
|
|
288
|
-
sourceSide:
|
|
289
|
-
targetSide:
|
|
245
|
+
edges: t.map((n) => ({
|
|
246
|
+
id: n.id,
|
|
247
|
+
source: n.source,
|
|
248
|
+
target: n.target,
|
|
249
|
+
label: typeof n.label == "string" ? n.label : void 0,
|
|
250
|
+
dashed: n.animated,
|
|
251
|
+
sourceSide: W(n.sourceHandle),
|
|
252
|
+
targetSide: W(n.targetHandle)
|
|
290
253
|
}))
|
|
291
254
|
};
|
|
292
255
|
}
|
|
293
|
-
function
|
|
294
|
-
return e.map((
|
|
295
|
-
const o = t[
|
|
256
|
+
function Y(e, t) {
|
|
257
|
+
return e.map((r) => {
|
|
258
|
+
const o = t[r.id], n = o ? {
|
|
296
259
|
path: o.path,
|
|
297
260
|
points: o.points,
|
|
298
261
|
label: o.label,
|
|
@@ -307,96 +270,96 @@ function ee(e, t) {
|
|
|
307
270
|
targetSide: "left",
|
|
308
271
|
blocked: !0
|
|
309
272
|
};
|
|
310
|
-
return { ...
|
|
273
|
+
return { ...r, type: r.type ?? "draftably", data: { ...r.data, draftably: n } };
|
|
311
274
|
});
|
|
312
275
|
}
|
|
313
|
-
function me({ nodes: e, edges: t },
|
|
314
|
-
const
|
|
276
|
+
function me({ nodes: e, edges: t }, r, o = !1) {
|
|
277
|
+
const n = (a) => r.nodes[a] ?? r.groups[a];
|
|
315
278
|
return {
|
|
316
|
-
nodes: e.map((
|
|
317
|
-
const
|
|
318
|
-
if (!
|
|
319
|
-
const
|
|
279
|
+
nodes: e.map((a) => {
|
|
280
|
+
const s = n(a.id), u = k(a) ? n(k(a)) : void 0;
|
|
281
|
+
if (!s) return a;
|
|
282
|
+
const l = { width: s.width, height: s.height };
|
|
320
283
|
return {
|
|
321
|
-
...
|
|
322
|
-
position: { x:
|
|
323
|
-
...
|
|
324
|
-
...o || typeof
|
|
284
|
+
...a,
|
|
285
|
+
position: { x: s.x - (u?.x ?? 0), y: s.y - (u?.y ?? 0) },
|
|
286
|
+
...l,
|
|
287
|
+
...o || typeof a.style == "string" ? {} : { style: { ...a.style, ...l } }
|
|
325
288
|
};
|
|
326
289
|
}),
|
|
327
|
-
edges:
|
|
290
|
+
edges: Y(t, r.edges)
|
|
328
291
|
};
|
|
329
292
|
}
|
|
330
|
-
function
|
|
331
|
-
const o = new Map(e.map((
|
|
332
|
-
const
|
|
333
|
-
return { x:
|
|
334
|
-
},
|
|
335
|
-
const { width:
|
|
336
|
-
return
|
|
337
|
-
}),
|
|
293
|
+
function Se({ nodes: e, edges: t }, r = {}) {
|
|
294
|
+
const o = new Map(e.map((l) => [l.id, l])), n = V(e), a = (l) => {
|
|
295
|
+
const f = k(l) ? o.get(k(l)) : void 0, h = f ? a(f) : { x: 0, y: 0 };
|
|
296
|
+
return { x: h.x + (l.position?.x ?? 0), y: h.y + (l.position?.y ?? 0) };
|
|
297
|
+
}, s = e.flatMap((l) => {
|
|
298
|
+
const { width: f, height: h } = Q(l);
|
|
299
|
+
return f && h ? [{ n: l, box: { ...a(l), width: f, height: h } }] : [];
|
|
300
|
+
}), u = new Set(s.map((l) => l.n.id));
|
|
338
301
|
return {
|
|
339
|
-
groups:
|
|
340
|
-
nodes:
|
|
341
|
-
id:
|
|
342
|
-
parent: k(
|
|
343
|
-
shape:
|
|
344
|
-
...
|
|
302
|
+
groups: s.filter(({ n: l }) => n.has(l.id)).map(({ n: l, box: f }) => ({ id: l.id, label: I(l), parent: k(l), ...f })),
|
|
303
|
+
nodes: s.filter(({ n: l }) => !n.has(l.id)).map(({ n: l, box: f }) => ({
|
|
304
|
+
id: l.id,
|
|
305
|
+
parent: k(l),
|
|
306
|
+
shape: r.shape?.(l),
|
|
307
|
+
...f
|
|
345
308
|
})),
|
|
346
|
-
edges:
|
|
347
|
-
(
|
|
309
|
+
edges: X({ nodes: [], edges: t }).edges.filter(
|
|
310
|
+
(l) => u.has(l.source) && u.has(l.target)
|
|
348
311
|
)
|
|
349
312
|
};
|
|
350
313
|
}
|
|
351
|
-
function
|
|
352
|
-
return
|
|
353
|
-
(
|
|
314
|
+
function ke(e, t) {
|
|
315
|
+
return Y(e, t.edges).map(
|
|
316
|
+
(r, o) => t.edges[r.id] || !e[o].data?.draftably ? r : e[o]
|
|
354
317
|
);
|
|
355
318
|
}
|
|
356
|
-
const P = (e, t) => Object.fromEntries(Object.entries(e).map(([
|
|
357
|
-
function
|
|
319
|
+
const P = (e, t) => Object.fromEntries(Object.entries(e).map(([r, o]) => [r, t(o)]));
|
|
320
|
+
function ee(e, t, r, o, n = e.bounds) {
|
|
358
321
|
return {
|
|
359
322
|
...e,
|
|
360
|
-
bounds:
|
|
323
|
+
bounds: n,
|
|
361
324
|
nodes: P(e.nodes, t),
|
|
362
325
|
groups: P(e.groups, t),
|
|
363
|
-
edges: P(e.edges, (
|
|
364
|
-
const
|
|
326
|
+
edges: P(e.edges, (a) => {
|
|
327
|
+
const s = a.points.map(r);
|
|
365
328
|
return {
|
|
366
|
-
...
|
|
367
|
-
points:
|
|
368
|
-
path:
|
|
369
|
-
label:
|
|
370
|
-
sourceSide: o(
|
|
371
|
-
targetSide: o(
|
|
329
|
+
...a,
|
|
330
|
+
points: s,
|
|
331
|
+
path: ue(s, 6),
|
|
332
|
+
label: a.label && t(a.label),
|
|
333
|
+
sourceSide: o(a.sourceSide),
|
|
334
|
+
targetSide: o(a.targetSide)
|
|
372
335
|
};
|
|
373
336
|
})
|
|
374
337
|
};
|
|
375
338
|
}
|
|
376
|
-
function
|
|
377
|
-
const t = -e.bounds.x,
|
|
378
|
-
return !t && !
|
|
339
|
+
function te(e) {
|
|
340
|
+
const t = -e.bounds.x, r = -e.bounds.y;
|
|
341
|
+
return !t && !r ? e : ee(
|
|
379
342
|
e,
|
|
380
|
-
(o) => ({ ...o, x: o.x + t, y: o.y +
|
|
381
|
-
(o) => ({ x: o.x + t, y: o.y +
|
|
343
|
+
(o) => ({ ...o, x: o.x + t, y: o.y + r }),
|
|
344
|
+
(o) => ({ x: o.x + t, y: o.y + r }),
|
|
382
345
|
(o) => o,
|
|
383
346
|
{ ...e.bounds, x: 0, y: 0 }
|
|
384
347
|
);
|
|
385
348
|
}
|
|
386
|
-
const
|
|
387
|
-
function
|
|
388
|
-
const
|
|
389
|
-
return
|
|
349
|
+
const xe = { left: "right", right: "left", top: "bottom", bottom: "top" };
|
|
350
|
+
function R(e, t) {
|
|
351
|
+
const r = t === "x" ? "width" : "height", o = 2 * e.bounds[t] + e.bounds[r], n = t === "x" ? ["left", "right"] : ["top", "bottom"];
|
|
352
|
+
return ee(
|
|
390
353
|
e,
|
|
391
|
-
(
|
|
392
|
-
(
|
|
393
|
-
(
|
|
354
|
+
(a) => ({ ...a, [t]: o - a[t] - a[r] }),
|
|
355
|
+
(a) => ({ ...a, [t]: o - a[t] }),
|
|
356
|
+
(a) => n.includes(a) ? xe[a] : a
|
|
394
357
|
);
|
|
395
358
|
}
|
|
396
359
|
function j(e, t) {
|
|
397
360
|
return e?.[`elk.${t}`] ?? e?.[`org.eclipse.elk.${t}`] ?? e?.[t];
|
|
398
361
|
}
|
|
399
|
-
const
|
|
362
|
+
const B = (e) => e.replace(/^(org\.eclipse\.)?elk\./, ""), $e = /* @__PURE__ */ new Set([
|
|
400
363
|
"algorithm",
|
|
401
364
|
"direction",
|
|
402
365
|
"spacing.nodeNode",
|
|
@@ -414,43 +377,43 @@ const C = (e) => e.replace(/^(org\.eclipse\.)?elk\./, ""), $e = /* @__PURE__ */
|
|
|
414
377
|
WEST: "left"
|
|
415
378
|
};
|
|
416
379
|
function Ee(e, t) {
|
|
417
|
-
const
|
|
418
|
-
for (const b of Object.keys(
|
|
380
|
+
const r = [], o = [], n = [], a = [], s = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = { ...t, ...e.layoutOptions }, h = (p) => {
|
|
381
|
+
for (const b of Object.keys(p ?? {})) $e.has(B(b)) || s.add(B(b));
|
|
419
382
|
};
|
|
420
|
-
f
|
|
421
|
-
const i = { nodes:
|
|
422
|
-
let
|
|
423
|
-
|
|
383
|
+
h(f);
|
|
384
|
+
const i = { nodes: r, groups: o, edges: n, fold: "never" }, c = j(f, "direction");
|
|
385
|
+
let d;
|
|
386
|
+
c === "DOWN" || c === "UP" ? i.direction = "down" : (c === "RIGHT" || c === "LEFT") && (i.direction = "right"), c === "LEFT" && (d = "x"), c === "UP" && (d = "y");
|
|
424
387
|
const g = Number(
|
|
425
|
-
j(
|
|
388
|
+
j(f, "layered.spacing.nodeNodeBetweenLayers") ?? j(f, "spacing.nodeNode")
|
|
426
389
|
);
|
|
427
390
|
g > 0 && (i.gap = Math.min(300, Math.max(8, g)));
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
for (const
|
|
432
|
-
|
|
433
|
-
if (
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
id:
|
|
438
|
-
label:
|
|
391
|
+
const y = j(f, "algorithm");
|
|
392
|
+
y && /force|stress/.test(y) ? i.arrange = "engine:stress" : y && /mrtree/.test(y) ? i.arrange = "engine:tree" : y && /rectpacking|box/.test(y) && (i.arrange = "engine:grid");
|
|
393
|
+
const S = (p, b) => {
|
|
394
|
+
for (const w of p.ports ?? [])
|
|
395
|
+
h(w.layoutOptions), u.set(w.id, { node: p.id, side: Oe[j(w.layoutOptions, "port.side") ?? ""] });
|
|
396
|
+
if (p !== e) {
|
|
397
|
+
h(p.layoutOptions);
|
|
398
|
+
const w = p.labels?.[0]?.text ?? p.id;
|
|
399
|
+
p.children?.length ? o.push({ id: p.id, label: w, parent: b, arrange: "flow" }) : r.push({
|
|
400
|
+
id: p.id,
|
|
401
|
+
label: w,
|
|
439
402
|
parent: b,
|
|
440
|
-
...
|
|
441
|
-
...
|
|
403
|
+
...p.width ? { width: p.width } : {},
|
|
404
|
+
...p.height ? { height: p.height } : {}
|
|
442
405
|
});
|
|
443
406
|
}
|
|
444
|
-
for (const
|
|
407
|
+
for (const w of p.children ?? []) S(w, p === e ? void 0 : p.id);
|
|
445
408
|
};
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
for (const b of
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
([L, O],
|
|
453
|
-
id:
|
|
409
|
+
S(e);
|
|
410
|
+
const x = (p) => u.get(p) ?? { node: p, side: void 0 }, $ = (p) => {
|
|
411
|
+
for (const b of p.edges ?? []) {
|
|
412
|
+
h(b.layoutOptions);
|
|
413
|
+
const w = b.sources.flatMap((L) => b.targets.map((O) => [x(L), x(O)])), z = w.map((L, O) => w.length > 1 ? `${b.id}#${O}` : b.id);
|
|
414
|
+
l.set(b.id, z), w.forEach(
|
|
415
|
+
([L, O], ie) => n.push({
|
|
416
|
+
id: z[ie],
|
|
454
417
|
source: L.node,
|
|
455
418
|
target: O.node,
|
|
456
419
|
label: b.labels?.[0]?.text,
|
|
@@ -459,82 +422,82 @@ function Ee(e, t) {
|
|
|
459
422
|
})
|
|
460
423
|
);
|
|
461
424
|
}
|
|
462
|
-
for (const b of
|
|
425
|
+
for (const b of p.children ?? []) $(b);
|
|
463
426
|
};
|
|
464
|
-
return $(e),
|
|
465
|
-
}
|
|
466
|
-
function ve(e, t, { pieces:
|
|
467
|
-
const o = /* @__PURE__ */ new Map([[e.id, { x: 0, y: 0 }]]),
|
|
468
|
-
const g =
|
|
469
|
-
o.set(
|
|
470
|
-
for (const
|
|
471
|
-
const
|
|
427
|
+
return $(e), s.size && a.push(`These ELK options are not used: ${[...s].sort().join(", ")}.`), { graph: i, warnings: a, pieces: l, mirror: d };
|
|
428
|
+
}
|
|
429
|
+
function ve(e, t, { pieces: r }) {
|
|
430
|
+
const o = /* @__PURE__ */ new Map([[e.id, { x: 0, y: 0 }]]), n = /* @__PURE__ */ new Map(), a = (c, d) => {
|
|
431
|
+
const g = c === e ? void 0 : t.nodes[c.id] ?? t.groups[c.id], y = g ? { x: g.x, y: g.y } : d;
|
|
432
|
+
o.set(c.id, y);
|
|
433
|
+
for (const x of c.children ?? []) n.set(x.id, c.id);
|
|
434
|
+
const S = c.children?.map((x) => a(x, y));
|
|
472
435
|
return {
|
|
473
|
-
...
|
|
474
|
-
...
|
|
436
|
+
...c,
|
|
437
|
+
...c === e ? {
|
|
475
438
|
x: 0,
|
|
476
439
|
y: 0,
|
|
477
440
|
width: t.bounds.x + t.bounds.width,
|
|
478
441
|
height: t.bounds.y + t.bounds.height
|
|
479
|
-
} : { x:
|
|
480
|
-
...
|
|
442
|
+
} : { x: y.x - d.x, y: y.y - d.y, width: g?.width, height: g?.height },
|
|
443
|
+
...S ? { children: S } : {}
|
|
481
444
|
};
|
|
482
|
-
},
|
|
483
|
-
for (const
|
|
484
|
-
|
|
445
|
+
}, s = a(e, { x: 0, y: 0 }), u = /* @__PURE__ */ new Map(), l = (c) => {
|
|
446
|
+
for (const d of c.ports ?? []) u.set(d.id, c.id);
|
|
447
|
+
c.children?.forEach(l);
|
|
485
448
|
};
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
const
|
|
489
|
-
for (let g =
|
|
490
|
-
return
|
|
491
|
-
},
|
|
492
|
-
const
|
|
493
|
-
return
|
|
494
|
-
}, i = (
|
|
495
|
-
...
|
|
496
|
-
...
|
|
497
|
-
edges:
|
|
498
|
-
const g =
|
|
449
|
+
l(e);
|
|
450
|
+
const f = (c) => {
|
|
451
|
+
const d = [];
|
|
452
|
+
for (let g = n.get(u.get(c) ?? c); g; g = n.get(g)) d.push(g);
|
|
453
|
+
return d;
|
|
454
|
+
}, h = (c) => {
|
|
455
|
+
const d = f(c.sources[0]), g = new Set(f(c.targets[0]));
|
|
456
|
+
return d.find((y) => g.has(y)) ?? e.id;
|
|
457
|
+
}, i = (c) => ({
|
|
458
|
+
...c,
|
|
459
|
+
...c.edges ? {
|
|
460
|
+
edges: c.edges.map((d) => {
|
|
461
|
+
const g = h(d), y = o.get(g) ?? { x: 0, y: 0 }, S = (p) => ({ x: p.x - y.x, y: p.y - y.y }), x = (r.get(d.id) ?? [d.id]).map((p) => t.edges[p]).filter(Boolean), $ = x[0]?.label;
|
|
499
462
|
return {
|
|
500
|
-
...
|
|
463
|
+
...d,
|
|
501
464
|
container: g,
|
|
502
|
-
sections:
|
|
503
|
-
id: `${
|
|
504
|
-
startPoint:
|
|
505
|
-
endPoint:
|
|
506
|
-
bendPoints:
|
|
507
|
-
incomingShape:
|
|
508
|
-
outgoingShape:
|
|
465
|
+
sections: x.map((p, b) => ({
|
|
466
|
+
id: `${d.id}_s${b}`,
|
|
467
|
+
startPoint: S(p.points[0]),
|
|
468
|
+
endPoint: S(p.points.at(-1)),
|
|
469
|
+
bendPoints: p.points.slice(1, -1).map(S),
|
|
470
|
+
incomingShape: p.source,
|
|
471
|
+
outgoingShape: p.target
|
|
509
472
|
})),
|
|
510
|
-
...
|
|
511
|
-
labels:
|
|
512
|
-
(
|
|
473
|
+
...d.labels?.length && $ ? {
|
|
474
|
+
labels: d.labels.map(
|
|
475
|
+
(p, b) => b ? p : { ...p, ...S($), width: $.width, height: $.height }
|
|
513
476
|
)
|
|
514
477
|
} : {}
|
|
515
478
|
};
|
|
516
479
|
})
|
|
517
480
|
} : {},
|
|
518
|
-
...
|
|
481
|
+
...c.children ? { children: c.children.map(i) } : {}
|
|
519
482
|
});
|
|
520
|
-
return i(
|
|
483
|
+
return i(s);
|
|
521
484
|
}
|
|
522
|
-
async function
|
|
523
|
-
const o = Ee(e, t),
|
|
524
|
-
return
|
|
485
|
+
async function oe(e, t, r) {
|
|
486
|
+
const o = Ee(e, t), n = await T({ ...o.graph, ...r }), a = te(o.mirror ? R(n, o.mirror) : n);
|
|
487
|
+
return a.warnings.unshift(...o.warnings), { elk: ve(e, a, o), result: a };
|
|
525
488
|
}
|
|
526
|
-
class
|
|
489
|
+
class je {
|
|
527
490
|
constructor(t = {}) {
|
|
528
491
|
this.options = t;
|
|
529
492
|
}
|
|
530
493
|
/** Warnings from the last `layout` call, such as ELK options that were not used. */
|
|
531
494
|
warnings = [];
|
|
532
|
-
async layout(t,
|
|
533
|
-
const { elk: o, result:
|
|
495
|
+
async layout(t, r = {}) {
|
|
496
|
+
const { elk: o, result: n } = await oe(t, {
|
|
534
497
|
...this.options.defaultLayoutOptions,
|
|
535
|
-
...
|
|
498
|
+
...r.layoutOptions
|
|
536
499
|
});
|
|
537
|
-
return this.warnings =
|
|
500
|
+
return this.warnings = n.warnings, o;
|
|
538
501
|
}
|
|
539
502
|
knownLayoutAlgorithms() {
|
|
540
503
|
return Promise.resolve([{ id: "draftably.flow", name: "Draftably flow" }]);
|
|
@@ -543,127 +506,127 @@ class Le {
|
|
|
543
506
|
}
|
|
544
507
|
}
|
|
545
508
|
const v = (e) => typeof e == "number" && e > 0 ? e : void 0, q = (e) => typeof e == "string" ? e : void 0;
|
|
546
|
-
function
|
|
547
|
-
const
|
|
509
|
+
function qe(e, t = {}) {
|
|
510
|
+
const r = e.nodes(), o = (i) => e.parent?.(i) || void 0, n = new Set(r.filter((i) => e.children?.(i)?.length)), a = e.graph() ?? {}, s = q(a.rankdir)?.toUpperCase() ?? "TB", u = e.edges(), l = (i) => `${i.v}->${i.w}${i.name ? `:${i.name}` : ""}`, f = {
|
|
548
511
|
// dagre never folds a long drawing into rows, and its clusters flow like the rest.
|
|
549
512
|
fold: "never",
|
|
550
|
-
direction:
|
|
551
|
-
...v(
|
|
552
|
-
groups:
|
|
513
|
+
direction: s === "LR" || s === "RL" ? "right" : "down",
|
|
514
|
+
...v(a.ranksep) ? { gap: Math.min(300, Math.max(8, v(a.ranksep))) } : {},
|
|
515
|
+
groups: r.filter((i) => n.has(i)).map((i) => ({
|
|
553
516
|
id: i,
|
|
554
517
|
label: q(e.node(i)?.label) ?? i,
|
|
555
518
|
parent: o(i),
|
|
556
519
|
arrange: "flow"
|
|
557
520
|
})),
|
|
558
|
-
nodes:
|
|
559
|
-
const
|
|
521
|
+
nodes: r.filter((i) => !n.has(i)).map((i) => {
|
|
522
|
+
const c = e.node(i) ?? {};
|
|
560
523
|
return {
|
|
561
524
|
id: i,
|
|
562
|
-
label: q(
|
|
525
|
+
label: q(c.label) ?? i,
|
|
563
526
|
parent: o(i),
|
|
564
|
-
...v(
|
|
565
|
-
...v(
|
|
527
|
+
...v(c.width) ? { width: v(c.width) } : {},
|
|
528
|
+
...v(c.height) ? { height: v(c.height) } : {}
|
|
566
529
|
};
|
|
567
530
|
}),
|
|
568
|
-
edges:
|
|
569
|
-
id:
|
|
531
|
+
edges: u.map((i) => ({
|
|
532
|
+
id: l(i),
|
|
570
533
|
source: i.v,
|
|
571
534
|
target: i.w,
|
|
572
535
|
label: q(e.edge(i)?.label)
|
|
573
536
|
})),
|
|
574
537
|
routing: t.routing
|
|
575
538
|
};
|
|
576
|
-
let
|
|
577
|
-
|
|
578
|
-
for (const i of
|
|
579
|
-
const
|
|
580
|
-
!
|
|
581
|
-
x:
|
|
582
|
-
y:
|
|
583
|
-
width:
|
|
584
|
-
height:
|
|
539
|
+
let h = J(f);
|
|
540
|
+
s === "BT" && (h = R(h, "y")), s === "RL" && (h = R(h, "x")), h = te(h);
|
|
541
|
+
for (const i of r) {
|
|
542
|
+
const c = h.nodes[i] ?? h.groups[i], d = e.node(i);
|
|
543
|
+
!c || !d || Object.assign(d, {
|
|
544
|
+
x: c.x + c.width / 2,
|
|
545
|
+
y: c.y + c.height / 2,
|
|
546
|
+
width: c.width,
|
|
547
|
+
height: c.height
|
|
585
548
|
});
|
|
586
549
|
}
|
|
587
|
-
for (const i of
|
|
588
|
-
const
|
|
589
|
-
!
|
|
590
|
-
points:
|
|
591
|
-
...
|
|
550
|
+
for (const i of u) {
|
|
551
|
+
const c = h.edges[l(i)], d = e.edge(i);
|
|
552
|
+
!c || !d || Object.assign(d, {
|
|
553
|
+
points: c.points.map((g) => ({ x: g.x, y: g.y })),
|
|
554
|
+
...c.label ? { x: c.label.x + c.label.width / 2, y: c.label.y + c.label.height / 2 } : {}
|
|
592
555
|
});
|
|
593
556
|
}
|
|
594
|
-
return Object.assign(
|
|
557
|
+
return Object.assign(a, { width: h.bounds.width, height: h.bounds.height }), h;
|
|
595
558
|
}
|
|
596
|
-
function
|
|
559
|
+
function D(e) {
|
|
597
560
|
this.options = e;
|
|
598
561
|
}
|
|
599
|
-
|
|
600
|
-
const e = this.options, t = e.eles.nodes(),
|
|
601
|
-
const
|
|
602
|
-
return typeof
|
|
603
|
-
}, o = (
|
|
562
|
+
D.prototype.run = function() {
|
|
563
|
+
const e = this.options, t = e.eles.nodes(), r = (s) => {
|
|
564
|
+
const u = s.data("label");
|
|
565
|
+
return typeof u == "string" ? u : s.id();
|
|
566
|
+
}, o = (s) => s.parent().length ? s.parent().id() : void 0, n = {
|
|
604
567
|
direction: e.direction,
|
|
605
568
|
gap: e.gap,
|
|
606
569
|
routing: e.routing,
|
|
607
|
-
groups: t.filter((
|
|
608
|
-
nodes: t.filter((
|
|
609
|
-
id:
|
|
610
|
-
label:
|
|
611
|
-
parent: o(
|
|
612
|
-
width:
|
|
613
|
-
height:
|
|
570
|
+
groups: t.filter((s) => s.isParent()).map((s) => ({ id: s.id(), label: r(s), parent: o(s) })),
|
|
571
|
+
nodes: t.filter((s) => !s.isParent()).map((s) => ({
|
|
572
|
+
id: s.id(),
|
|
573
|
+
label: r(s),
|
|
574
|
+
parent: o(s),
|
|
575
|
+
width: s.outerWidth(),
|
|
576
|
+
height: s.outerHeight()
|
|
614
577
|
})),
|
|
615
|
-
edges: e.eles.edges().map((
|
|
616
|
-
id:
|
|
617
|
-
source:
|
|
618
|
-
target:
|
|
619
|
-
label: typeof
|
|
578
|
+
edges: e.eles.edges().map((s) => ({
|
|
579
|
+
id: s.id(),
|
|
580
|
+
source: s.source().id(),
|
|
581
|
+
target: s.target().id(),
|
|
582
|
+
label: typeof s.data("label") == "string" ? s.data("label") : void 0
|
|
620
583
|
}))
|
|
621
|
-
},
|
|
622
|
-
return this.result =
|
|
623
|
-
const
|
|
624
|
-
return
|
|
584
|
+
}, a = J(n);
|
|
585
|
+
return this.result = a, t.layoutPositions(this, { fit: !0, padding: 30, animate: !1, ...e }, (s) => {
|
|
586
|
+
const u = a.nodes[s.id()] ?? a.groups[s.id()];
|
|
587
|
+
return u ? { x: u.x + u.width / 2, y: u.y + u.height / 2 } : { x: 0, y: 0 };
|
|
625
588
|
}), this;
|
|
626
589
|
};
|
|
627
|
-
|
|
590
|
+
D.prototype.stop = function() {
|
|
628
591
|
return this;
|
|
629
592
|
};
|
|
630
|
-
function
|
|
631
|
-
e("layout", "draftably",
|
|
593
|
+
function Fe(e) {
|
|
594
|
+
e("layout", "draftably", D);
|
|
632
595
|
}
|
|
633
|
-
async function
|
|
596
|
+
async function Ne(e) {
|
|
634
597
|
if ("elk" in e) {
|
|
635
|
-
const { elk: t, ...
|
|
636
|
-
return
|
|
598
|
+
const { elk: t, ...r } = e;
|
|
599
|
+
return oe(t, void 0, r);
|
|
637
600
|
}
|
|
638
601
|
for (const t of ["reactFlow", "svelteFlow"])
|
|
639
602
|
if (t in e) {
|
|
640
603
|
const {
|
|
641
|
-
[t]:
|
|
604
|
+
[t]: r,
|
|
642
605
|
shape: o,
|
|
643
|
-
...
|
|
644
|
-
} = e,
|
|
645
|
-
return { [t]: me(
|
|
606
|
+
...n
|
|
607
|
+
} = e, a = await T({ ...X(r, { shape: o }), ...n });
|
|
608
|
+
return { [t]: me(r, a, t === "svelteFlow"), result: a };
|
|
646
609
|
}
|
|
647
610
|
return T(e);
|
|
648
611
|
}
|
|
649
|
-
function
|
|
612
|
+
function Pe(e) {
|
|
650
613
|
for (const t of ["reactFlow", "svelteFlow"])
|
|
651
614
|
if (t in e) {
|
|
652
615
|
const {
|
|
653
|
-
[t]:
|
|
616
|
+
[t]: r,
|
|
654
617
|
shape: o,
|
|
655
|
-
routing:
|
|
656
|
-
} = e,
|
|
657
|
-
return { [t]: { nodes:
|
|
618
|
+
routing: n
|
|
619
|
+
} = e, a = U({ ...Se(r, { shape: o }), routing: n });
|
|
620
|
+
return { [t]: { nodes: r.nodes, edges: ke(r.edges, a) }, result: a };
|
|
658
621
|
}
|
|
659
|
-
return
|
|
622
|
+
return U(e);
|
|
660
623
|
}
|
|
661
624
|
export {
|
|
662
625
|
ge as AUTO_FULL_LIMIT,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
626
|
+
je as DraftablyELK,
|
|
627
|
+
qe as dagreLayout,
|
|
628
|
+
Fe as draftablyLayout,
|
|
629
|
+
Ne as layout,
|
|
630
|
+
J as layoutSync,
|
|
631
|
+
Pe as route
|
|
669
632
|
};
|