@bpmnkit/core 1.16.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bpmn/auto-layout.d.ts +0 -8
- package/dist/bpmn/auto-layout.js +432 -59
- package/dist/bpmn/make-room.js +114 -0
- package/dist/bpmn/place-new-shapes.js +4 -2
- package/dist/layout/collaboration/crossings.d.ts +13 -0
- package/dist/layout/collaboration/crossings.js +37 -0
- package/dist/layout/collaboration/docked-labels.d.ts +21 -0
- package/dist/layout/collaboration/docked-labels.js +65 -0
- package/dist/layout/collaboration/message-tracks.d.ts +20 -0
- package/dist/layout/collaboration/message-tracks.js +78 -0
- package/dist/layout/collaboration/stack-crossings.d.ts +38 -0
- package/dist/layout/collaboration/stack-crossings.js +155 -0
- package/dist/layout/grid/edge-labels.js +21 -10
- package/dist/layout/layered/coords.d.ts +13 -0
- package/dist/layout/layered/coords.js +211 -0
- package/dist/layout/layered/index.d.ts +21 -0
- package/dist/layout/layered/index.js +288 -0
- package/dist/layout/layered/layers.d.ts +60 -0
- package/dist/layout/layered/layers.js +374 -0
- package/dist/layout/layered/route.d.ts +66 -0
- package/dist/layout/layered/route.js +369 -0
- package/dist/layout/layout-engine.d.ts +6 -2
- package/dist/layout/layout-engine.js +4 -2
- package/dist/layout/semantic/bands.js +8 -2
- package/dist/layout/semantic/graph.d.ts +33 -1
- package/dist/layout/semantic/graph.js +200 -4
- package/dist/layout/semantic/index.d.ts +8 -2
- package/dist/layout/semantic/index.js +114 -14
- package/dist/layout/semantic/lanes.d.ts +40 -0
- package/dist/layout/semantic/lanes.js +198 -0
- package/dist/layout/semantic/place.d.ts +44 -2
- package/dist/layout/semantic/place.js +220 -21
- package/dist/layout/semantic/route.js +35 -2
- package/dist/layout/types.d.ts +0 -8
- package/package.json +1 -1
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/** Dummy ids cannot clash with element ids: XML ids never hold a NUL. */
|
|
2
|
+
const DUMMY = "\u0000";
|
|
3
|
+
/** Ordering sweeps: alternating down/up passes; stop early once crossing-free. */
|
|
4
|
+
const SWEEPS = 24;
|
|
5
|
+
const TRANSPOSE_PASSES = 8;
|
|
6
|
+
/** Forward flows out of `id` within the component (back edges and self-loops excluded). */
|
|
7
|
+
function forward(graph, inSet, id) {
|
|
8
|
+
return (graph.outgoing.get(id) ?? []).filter((f) => !graph.backEdges.has(f.id) && inSet.has(f.targetRef) && f.targetRef !== id);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Flows that stay inside one column (the P2 rules, as layering constraints):
|
|
12
|
+
* - a one-node detour of a split that feeds the split's other target stacks
|
|
13
|
+
* under that target and flows up into it;
|
|
14
|
+
* - the first boundary event of a host whose handler has no other way in drops
|
|
15
|
+
* its handler straight under (or over) the host.
|
|
16
|
+
*/
|
|
17
|
+
export function stackedFlows(graph, members, sideOf) {
|
|
18
|
+
const inSet = new Set(members);
|
|
19
|
+
const stacks = new Map();
|
|
20
|
+
const moved = new Set();
|
|
21
|
+
const anchored = new Set();
|
|
22
|
+
const take = (stack) => {
|
|
23
|
+
const key = `${stack.anchor}\u0001${stack.side}`;
|
|
24
|
+
if (moved.has(stack.mover) || moved.has(stack.anchor) || anchored.has(key))
|
|
25
|
+
return;
|
|
26
|
+
if (anchored.has(`${stack.mover}\u00011`) || anchored.has(`${stack.mover}\u0001-1`))
|
|
27
|
+
return;
|
|
28
|
+
stacks.set(stack.flow, stack);
|
|
29
|
+
moved.add(stack.mover);
|
|
30
|
+
anchored.add(key);
|
|
31
|
+
};
|
|
32
|
+
for (const id of members) {
|
|
33
|
+
for (const f of forward(graph, inSet, id)) {
|
|
34
|
+
const source = graph.byId.get(f.sourceRef);
|
|
35
|
+
if (source?.type === "boundaryEvent") {
|
|
36
|
+
const into = graph.incoming.get(f.targetRef) ?? [];
|
|
37
|
+
const target = graph.byId.get(f.targetRef);
|
|
38
|
+
const host = id;
|
|
39
|
+
const first = (graph.attachers.get(host) ?? [])[0];
|
|
40
|
+
if (into.length === 1 &&
|
|
41
|
+
first?.id === f.sourceRef &&
|
|
42
|
+
target &&
|
|
43
|
+
!GATEWAYS.has(target.type)) {
|
|
44
|
+
take({ flow: f.id, mover: f.targetRef, anchor: host, side: sideOf(f.sourceRef) });
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const into = graph.incoming.get(id) ?? [];
|
|
49
|
+
const out = graph.outgoing.get(id) ?? [];
|
|
50
|
+
if (into.length !== 1 || out.length !== 1)
|
|
51
|
+
continue;
|
|
52
|
+
const split = into[0];
|
|
53
|
+
if (graph.backEdges.has(split.id))
|
|
54
|
+
continue;
|
|
55
|
+
if (graph.byId.get(split.sourceRef)?.type === "boundaryEvent")
|
|
56
|
+
continue;
|
|
57
|
+
const sibling = (graph.outgoing.get(split.sourceRef) ?? []).some((g) => g.targetRef === f.targetRef && g !== split && !graph.backEdges.has(g.id));
|
|
58
|
+
if (sibling)
|
|
59
|
+
take({ flow: f.id, mover: id, anchor: f.targetRef, side: 1 });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return stacks;
|
|
63
|
+
}
|
|
64
|
+
const GATEWAYS = new Set([
|
|
65
|
+
"exclusiveGateway",
|
|
66
|
+
"parallelGateway",
|
|
67
|
+
"inclusiveGateway",
|
|
68
|
+
"eventBasedGateway",
|
|
69
|
+
"complexGateway",
|
|
70
|
+
]);
|
|
71
|
+
/** Kahn order over forward flows; ties keep declaration order. */
|
|
72
|
+
function topoOrder(graph, members, inSet) {
|
|
73
|
+
const indeg = new Map();
|
|
74
|
+
for (const id of members)
|
|
75
|
+
indeg.set(id, 0);
|
|
76
|
+
for (const id of members) {
|
|
77
|
+
for (const f of forward(graph, inSet, id))
|
|
78
|
+
indeg.set(f.targetRef, (indeg.get(f.targetRef) ?? 0) + 1);
|
|
79
|
+
}
|
|
80
|
+
const queue = members.filter((id) => indeg.get(id) === 0);
|
|
81
|
+
const order = [];
|
|
82
|
+
for (let i = 0; i < queue.length; i++) {
|
|
83
|
+
const id = queue[i];
|
|
84
|
+
order.push(id);
|
|
85
|
+
for (const f of forward(graph, inSet, id)) {
|
|
86
|
+
const left = (indeg.get(f.targetRef) ?? 0) - 1;
|
|
87
|
+
indeg.set(f.targetRef, left);
|
|
88
|
+
if (left === 0)
|
|
89
|
+
queue.push(f.targetRef);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return order;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Longest-path columns, then a local network-simplex move: a node with more
|
|
96
|
+
* flows out than in slides right up to its nearest successor (a second start
|
|
97
|
+
* event, a split feeding a far join), one with more in than out slides left.
|
|
98
|
+
* Total flow length only shrinks, which keeps long dummy chains rare.
|
|
99
|
+
*/
|
|
100
|
+
export function assignLayers(graph, members, stacks) {
|
|
101
|
+
const inSet = new Set(members);
|
|
102
|
+
const order = topoOrder(graph, members, inSet);
|
|
103
|
+
const step = (f) => (stacks.has(f.id) ? 0 : 1);
|
|
104
|
+
const preds = new Map();
|
|
105
|
+
for (const id of members)
|
|
106
|
+
preds.set(id, []);
|
|
107
|
+
for (const id of members) {
|
|
108
|
+
for (const f of forward(graph, inSet, id))
|
|
109
|
+
preds.get(f.targetRef)?.push(f);
|
|
110
|
+
}
|
|
111
|
+
const sourceOf = (f) => {
|
|
112
|
+
const s = graph.byId.get(f.sourceRef);
|
|
113
|
+
return s?.type === "boundaryEvent" ? s.attachedToRef : f.sourceRef;
|
|
114
|
+
};
|
|
115
|
+
const rank = new Map();
|
|
116
|
+
for (const id of members)
|
|
117
|
+
rank.set(id, 0);
|
|
118
|
+
for (const id of order) {
|
|
119
|
+
const r = rank.get(id) ?? 0;
|
|
120
|
+
for (const f of forward(graph, inSet, id)) {
|
|
121
|
+
if ((rank.get(f.targetRef) ?? 0) < r + step(f))
|
|
122
|
+
rank.set(f.targetRef, r + step(f));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (let pass = 0; pass < 8; pass++) {
|
|
126
|
+
let changed = false;
|
|
127
|
+
for (const id of order) {
|
|
128
|
+
const ins = preds.get(id) ?? [];
|
|
129
|
+
const outs = forward(graph, inSet, id);
|
|
130
|
+
const r = rank.get(id) ?? 0;
|
|
131
|
+
if (outs.length > ins.length) {
|
|
132
|
+
let hi = Number.POSITIVE_INFINITY;
|
|
133
|
+
for (const f of outs)
|
|
134
|
+
hi = Math.min(hi, (rank.get(f.targetRef) ?? 0) - step(f));
|
|
135
|
+
if (hi > r) {
|
|
136
|
+
rank.set(id, hi);
|
|
137
|
+
changed = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (ins.length > outs.length && ins.length > 0) {
|
|
141
|
+
let lo = 0;
|
|
142
|
+
for (const f of ins)
|
|
143
|
+
lo = Math.max(lo, (rank.get(sourceOf(f)) ?? 0) + step(f));
|
|
144
|
+
if (lo < r) {
|
|
145
|
+
rank.set(id, lo);
|
|
146
|
+
changed = true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (!changed)
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
let min = Number.POSITIVE_INFINITY;
|
|
154
|
+
for (const id of members)
|
|
155
|
+
min = Math.min(min, rank.get(id) ?? 0);
|
|
156
|
+
if (Number.isFinite(min) && min !== 0) {
|
|
157
|
+
for (const id of members)
|
|
158
|
+
rank.set(id, (rank.get(id) ?? 0) - min);
|
|
159
|
+
}
|
|
160
|
+
return rank;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Build the columns with dummy nodes, seeded in depth-first discovery order
|
|
164
|
+
* from the component's start so the first branch starts on top.
|
|
165
|
+
*/
|
|
166
|
+
export function buildLayering(graph, members, start, rank, biasOf) {
|
|
167
|
+
const inSet = new Set(members);
|
|
168
|
+
let maxRank = 0;
|
|
169
|
+
for (const id of members)
|
|
170
|
+
maxRank = Math.max(maxRank, rank.get(id) ?? 0);
|
|
171
|
+
const layers = [];
|
|
172
|
+
for (let r = 0; r <= maxRank; r++)
|
|
173
|
+
layers.push([]);
|
|
174
|
+
const lg = {
|
|
175
|
+
layers,
|
|
176
|
+
rank: new Map(rank),
|
|
177
|
+
dummies: new Map(),
|
|
178
|
+
succ: new Map(),
|
|
179
|
+
pred: new Map(),
|
|
180
|
+
chains: new Map(),
|
|
181
|
+
};
|
|
182
|
+
const seen = new Set();
|
|
183
|
+
const put = (id) => {
|
|
184
|
+
layers[lg.rank.get(id) ?? 0]?.push(id);
|
|
185
|
+
lg.succ.set(id, []);
|
|
186
|
+
lg.pred.set(id, []);
|
|
187
|
+
};
|
|
188
|
+
const link = (from, to, flow, bias) => {
|
|
189
|
+
const seg = { from, to, flow, bias };
|
|
190
|
+
lg.succ.get(from)?.push(seg);
|
|
191
|
+
lg.pred.get(to)?.push(seg);
|
|
192
|
+
};
|
|
193
|
+
const visit = (id) => {
|
|
194
|
+
seen.add(id);
|
|
195
|
+
put(id);
|
|
196
|
+
for (const f of forward(graph, inSet, id)) {
|
|
197
|
+
const r0 = lg.rank.get(id) ?? 0;
|
|
198
|
+
const r1 = lg.rank.get(f.targetRef) ?? 0;
|
|
199
|
+
const chain = [id];
|
|
200
|
+
for (let r = r0 + 1; r < r1; r++) {
|
|
201
|
+
const d = `${DUMMY}${f.id}${DUMMY}${r}`;
|
|
202
|
+
lg.rank.set(d, r);
|
|
203
|
+
lg.dummies.set(d, f.id);
|
|
204
|
+
put(d);
|
|
205
|
+
chain.push(d);
|
|
206
|
+
}
|
|
207
|
+
chain.push(f.targetRef);
|
|
208
|
+
lg.chains.set(f.id, chain);
|
|
209
|
+
if (!seen.has(f.targetRef))
|
|
210
|
+
visit(f.targetRef);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const roots = [
|
|
214
|
+
start,
|
|
215
|
+
...members.filter((id) => (graph.incoming.get(id) ?? []).length === 0),
|
|
216
|
+
...members,
|
|
217
|
+
];
|
|
218
|
+
for (const id of roots)
|
|
219
|
+
if (inSet.has(id) && !seen.has(id))
|
|
220
|
+
visit(id);
|
|
221
|
+
// Link after discovery so every endpoint has its lists.
|
|
222
|
+
for (const id of members) {
|
|
223
|
+
for (const f of forward(graph, inSet, id)) {
|
|
224
|
+
const chain = lg.chains.get(f.id) ?? [];
|
|
225
|
+
if (chain.length === 2 &&
|
|
226
|
+
lg.rank.get(chain[0]) === lg.rank.get(chain[1])) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
for (let i = 0; i + 1 < chain.length; i++) {
|
|
230
|
+
link(chain[i], chain[i + 1], f.id, i === 0 ? biasOf(f) : 0);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return lg;
|
|
235
|
+
}
|
|
236
|
+
function positions(layers) {
|
|
237
|
+
const pos = new Map();
|
|
238
|
+
for (const layer of layers)
|
|
239
|
+
layer.forEach((id, i) => pos.set(id, i));
|
|
240
|
+
return pos;
|
|
241
|
+
}
|
|
242
|
+
/** Crossings between column `r` and `r + 1`, straight-line model. */
|
|
243
|
+
function crossingsAt(lg, pos, r) {
|
|
244
|
+
const pairs = [];
|
|
245
|
+
for (const id of lg.layers[r] ?? []) {
|
|
246
|
+
for (const s of lg.succ.get(id) ?? [])
|
|
247
|
+
pairs.push([pos.get(s.from) ?? 0, pos.get(s.to) ?? 0]);
|
|
248
|
+
}
|
|
249
|
+
let n = 0;
|
|
250
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
251
|
+
const [a1, b1] = pairs[i];
|
|
252
|
+
for (let j = i + 1; j < pairs.length; j++) {
|
|
253
|
+
const [a2, b2] = pairs[j];
|
|
254
|
+
if ((a1 < a2 && b1 > b2) || (a1 > a2 && b1 < b2))
|
|
255
|
+
n++;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return n;
|
|
259
|
+
}
|
|
260
|
+
export function totalCrossings(lg) {
|
|
261
|
+
const pos = positions(lg.layers);
|
|
262
|
+
let n = 0;
|
|
263
|
+
for (let r = 0; r + 1 < lg.layers.length; r++)
|
|
264
|
+
n += crossingsAt(lg, pos, r);
|
|
265
|
+
return n;
|
|
266
|
+
}
|
|
267
|
+
/** Gansner's weighted median of neighbour positions; -1 when there are none. */
|
|
268
|
+
function medianValue(values) {
|
|
269
|
+
const p = [...values].sort((a, b) => a - b);
|
|
270
|
+
const n = p.length;
|
|
271
|
+
if (n === 0)
|
|
272
|
+
return -1;
|
|
273
|
+
const m = Math.floor(n / 2);
|
|
274
|
+
if (n % 2 === 1)
|
|
275
|
+
return p[m];
|
|
276
|
+
if (n === 2)
|
|
277
|
+
return (p[0] + p[1]) / 2;
|
|
278
|
+
const left = p[m - 1] - p[0];
|
|
279
|
+
const right = p[n - 1] - p[m];
|
|
280
|
+
if (left + right === 0)
|
|
281
|
+
return (p[m - 1] + p[m]) / 2;
|
|
282
|
+
return (p[m - 1] * right + p[m] * left) / (left + right);
|
|
283
|
+
}
|
|
284
|
+
/** Sort one column by the median of its neighbours in the fixed column; isolated nodes keep their slot. */
|
|
285
|
+
function reorder(lg, r, down, pos) {
|
|
286
|
+
const layer = lg.layers[r] ?? [];
|
|
287
|
+
const value = new Map();
|
|
288
|
+
for (const id of layer) {
|
|
289
|
+
const segs = (down ? lg.pred.get(id) : lg.succ.get(id)) ?? [];
|
|
290
|
+
const vals = segs.map((s) => down ? (pos.get(s.from) ?? 0) + s.bias : (pos.get(s.to) ?? 0) - s.bias);
|
|
291
|
+
value.set(id, medianValue(vals));
|
|
292
|
+
}
|
|
293
|
+
const movable = layer
|
|
294
|
+
.filter((id) => (value.get(id) ?? -1) >= 0)
|
|
295
|
+
.sort((a, b) => (value.get(a) ?? 0) - (value.get(b) ?? 0));
|
|
296
|
+
let k = 0;
|
|
297
|
+
const next = layer.map((id) => ((value.get(id) ?? -1) >= 0 ? movable[k++] : id));
|
|
298
|
+
lg.layers[r] = next;
|
|
299
|
+
next.forEach((id, i) => pos.set(id, i));
|
|
300
|
+
}
|
|
301
|
+
/** Crossings among the flows of `u` and `v` (in that order) toward both neighbouring columns. */
|
|
302
|
+
function pairCrossings(lg, pos, u, v) {
|
|
303
|
+
let n = 0;
|
|
304
|
+
const count = (a, b) => {
|
|
305
|
+
for (const pu of a)
|
|
306
|
+
for (const pv of b)
|
|
307
|
+
if (pu > pv)
|
|
308
|
+
n++;
|
|
309
|
+
};
|
|
310
|
+
const from = (id) => (lg.pred.get(id) ?? []).map((s) => pos.get(s.from) ?? 0);
|
|
311
|
+
const to = (id) => (lg.succ.get(id) ?? []).map((s) => pos.get(s.to) ?? 0);
|
|
312
|
+
count(from(u), from(v));
|
|
313
|
+
count(to(u), to(v));
|
|
314
|
+
return n;
|
|
315
|
+
}
|
|
316
|
+
/** Swap neighbours while that removes crossings. */
|
|
317
|
+
function transpose(lg, pos) {
|
|
318
|
+
for (let pass = 0; pass < TRANSPOSE_PASSES; pass++) {
|
|
319
|
+
let improved = false;
|
|
320
|
+
for (const layer of lg.layers) {
|
|
321
|
+
for (let i = 0; i + 1 < layer.length; i++) {
|
|
322
|
+
const u = layer[i];
|
|
323
|
+
const v = layer[i + 1];
|
|
324
|
+
if (pairCrossings(lg, pos, v, u) < pairCrossings(lg, pos, u, v)) {
|
|
325
|
+
layer[i] = v;
|
|
326
|
+
layer[i + 1] = u;
|
|
327
|
+
pos.set(v, i);
|
|
328
|
+
pos.set(u, i + 1);
|
|
329
|
+
improved = true;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (!improved)
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/** Put every stacked mover right under (or over) its anchor again. */
|
|
338
|
+
function glue(lg, stacks, pos) {
|
|
339
|
+
for (const stack of stacks.values()) {
|
|
340
|
+
const layer = lg.layers[lg.rank.get(stack.anchor) ?? -1];
|
|
341
|
+
if (!layer || lg.rank.get(stack.mover) !== lg.rank.get(stack.anchor))
|
|
342
|
+
continue;
|
|
343
|
+
layer.splice(layer.indexOf(stack.mover), 1);
|
|
344
|
+
const at = layer.indexOf(stack.anchor);
|
|
345
|
+
layer.splice(stack.side > 0 ? at + 1 : at, 0, stack.mover);
|
|
346
|
+
layer.forEach((id, i) => pos.set(id, i));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/** Median sweeps with transpose; keeps the order with the fewest crossings seen. */
|
|
350
|
+
export function orderLayers(lg, stacks) {
|
|
351
|
+
const pos = positions(lg.layers);
|
|
352
|
+
glue(lg, stacks, pos);
|
|
353
|
+
let best = lg.layers.map((l) => [...l]);
|
|
354
|
+
let bestCount = totalCrossings(lg);
|
|
355
|
+
for (let iter = 0; iter < SWEEPS && bestCount > 0; iter++) {
|
|
356
|
+
if (iter % 2 === 0) {
|
|
357
|
+
for (let r = 1; r < lg.layers.length; r++)
|
|
358
|
+
reorder(lg, r, true, pos);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
for (let r = lg.layers.length - 2; r >= 0; r--)
|
|
362
|
+
reorder(lg, r, false, pos);
|
|
363
|
+
}
|
|
364
|
+
transpose(lg, pos);
|
|
365
|
+
glue(lg, stacks, pos);
|
|
366
|
+
const count = totalCrossings(lg);
|
|
367
|
+
if (count < bestCount) {
|
|
368
|
+
bestCount = count;
|
|
369
|
+
best = lg.layers.map((l) => [...l]);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
lg.layers = best;
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=layers.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { BpmnSequenceFlow } from "../../bpmn/bpmn-model.js";
|
|
2
|
+
import type { SemanticGraph } from "../semantic/graph.js";
|
|
3
|
+
import type { Bounds, LayoutEdge, Waypoint } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* How one forward flow runs, decided on centre lines before any x exists:
|
|
6
|
+
* `ys[i]` is the line it follows through chain element `i`, and every change
|
|
7
|
+
* of line between two columns is a jog on a track in the gutter between them.
|
|
8
|
+
*/
|
|
9
|
+
export interface Plan {
|
|
10
|
+
flow: BpmnSequenceFlow;
|
|
11
|
+
chain: string[];
|
|
12
|
+
ranks: number[];
|
|
13
|
+
ys: number[];
|
|
14
|
+
/** right: out of the source's right side; side: a split's top or bottom; event / stem: out of a boundary event. */
|
|
15
|
+
exit: "right" | "side" | "event" | "stem" | "stack";
|
|
16
|
+
/** left: into the target's left side; side: into a join's top or bottom. */
|
|
17
|
+
entry: "left" | "side";
|
|
18
|
+
}
|
|
19
|
+
/** A vertical run in the gutter in front of column `gutter`. */
|
|
20
|
+
export interface Jog {
|
|
21
|
+
flow: string;
|
|
22
|
+
gutter: number;
|
|
23
|
+
from: number;
|
|
24
|
+
to: number;
|
|
25
|
+
}
|
|
26
|
+
export interface PlanInput {
|
|
27
|
+
graph: SemanticGraph;
|
|
28
|
+
/** Centre y of every chain element (nodes and dummies). */
|
|
29
|
+
y: Map<string, number>;
|
|
30
|
+
rank: Map<string, number>;
|
|
31
|
+
/** Real nodes per column, for clear-column checks. */
|
|
32
|
+
columns: Map<number, string[]>;
|
|
33
|
+
height: (id: string) => number;
|
|
34
|
+
/** +1 when the boundary event docks below its host, -1 above. */
|
|
35
|
+
sideOf: (eventId: string) => number;
|
|
36
|
+
}
|
|
37
|
+
export declare function planFlow(input: PlanInput, flow: BpmnSequenceFlow, chain: string[]): Plan;
|
|
38
|
+
export declare function jogsOf(plan: Plan): Jog[];
|
|
39
|
+
/**
|
|
40
|
+
* Order one gutter's jogs left to right: from top-down sorted entry lines,
|
|
41
|
+
* swap neighbours while that saves crossings.
|
|
42
|
+
*/
|
|
43
|
+
export declare function orderTracks(jogs: Jog[]): Jog[];
|
|
44
|
+
/** The polyline of a planned flow, once columns and tracks have x positions. */
|
|
45
|
+
export declare function drawPlan(plan: Plan, bounds: Map<string, Bounds>, trackX: (flow: string, gutter: number) => number): Waypoint[];
|
|
46
|
+
export declare class Router {
|
|
47
|
+
private readonly graph;
|
|
48
|
+
private readonly bounds;
|
|
49
|
+
private readonly segments;
|
|
50
|
+
private readonly loops;
|
|
51
|
+
constructor(graph: SemanticGraph, bounds: Map<string, Bounds>);
|
|
52
|
+
commit(points: Waypoint[]): void;
|
|
53
|
+
private hits;
|
|
54
|
+
private crossings;
|
|
55
|
+
/** Keep a clear route; replace one through a shape with an obstacle-aware search. */
|
|
56
|
+
settle(flow: BpmnSequenceFlow, points: Waypoint[]): Waypoint[];
|
|
57
|
+
private search;
|
|
58
|
+
/**
|
|
59
|
+
* A flow back to an earlier column: out of the source's bottom (or top),
|
|
60
|
+
* along the nearest clear corridor past both ends, into the target's
|
|
61
|
+
* bottom (or top). The side with fewer crossings wins, then the shorter.
|
|
62
|
+
*/
|
|
63
|
+
loop(flow: BpmnSequenceFlow): Waypoint[] | null;
|
|
64
|
+
}
|
|
65
|
+
export declare function edgeOf(flow: BpmnSequenceFlow, waypoints: Waypoint[]): LayoutEdge;
|
|
66
|
+
//# sourceMappingURL=route.d.ts.map
|