@bpmnkit/core 1.15.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/builder-reference.md +2 -1
- package/dist/bpmn/auto-layout.d.ts +0 -8
- package/dist/bpmn/auto-layout.js +605 -98
- package/dist/bpmn/bpmn-builder.d.ts +120 -14
- package/dist/bpmn/bpmn-builder.js +411 -152
- package/dist/bpmn/bpmn-model.d.ts +15 -0
- package/dist/bpmn/bpmn-parser.js +32 -6
- package/dist/bpmn/bpmn-serializer.js +9 -2
- package/dist/bpmn/compact-stream.d.ts +7 -0
- package/dist/bpmn/compact-stream.js +7 -0
- package/dist/bpmn/compact.d.ts +124 -9
- package/dist/bpmn/compact.js +295 -27
- package/dist/bpmn/full-operations.d.ts +19 -0
- package/dist/bpmn/full-operations.js +191 -7
- package/dist/bpmn/make-room.js +114 -0
- package/dist/bpmn/place-new-shapes.js +4 -2
- package/dist/bpmn/preserving-writer.d.ts +1 -1
- package/dist/bpmn/preserving-writer.js +1 -1
- package/dist/bpmn/process-delta.d.ts +32 -1
- package/dist/bpmn/process-delta.js +62 -1
- package/dist/bpmn/process-text-writer.d.ts +18 -7
- package/dist/bpmn/process-text-writer.js +105 -22
- package/dist/bpmn/process-text.d.ts +27 -1
- package/dist/bpmn/process-text.js +350 -2
- package/dist/bpmn/swimlanes.d.ts +178 -0
- package/dist/bpmn/swimlanes.js +774 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -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 +46 -2
- package/dist/layout/semantic/place.js +248 -30
- package/dist/layout/semantic/route.js +35 -2
- package/dist/layout/types.d.ts +0 -8
- package/dist/xml/xml-patch.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { routeOrthogonal, sidePorts } from "../orthogonal.js";
|
|
2
|
+
/** Clearance of a boundary handler's stem and of a loop corridor from the shapes it passes. */
|
|
3
|
+
const STEM = 20;
|
|
4
|
+
/** Spacing between parallel loop corridors. */
|
|
5
|
+
const LOOP_STEP = 10;
|
|
6
|
+
const GATEWAYS = new Set([
|
|
7
|
+
"exclusiveGateway",
|
|
8
|
+
"parallelGateway",
|
|
9
|
+
"inclusiveGateway",
|
|
10
|
+
"eventBasedGateway",
|
|
11
|
+
"complexGateway",
|
|
12
|
+
]);
|
|
13
|
+
function forwardCount(graph, id, out) {
|
|
14
|
+
const flows = (out ? graph.outgoing.get(id) : graph.incoming.get(id)) ?? [];
|
|
15
|
+
return flows.filter((f) => !graph.backEdges.has(f.id)).length;
|
|
16
|
+
}
|
|
17
|
+
/** No other node of column `rank` sits between the two lines. */
|
|
18
|
+
function columnClear(input, rank, self, y1, y2) {
|
|
19
|
+
const lo = Math.min(y1, y2);
|
|
20
|
+
const hi = Math.max(y1, y2);
|
|
21
|
+
for (const id of input.columns.get(rank) ?? []) {
|
|
22
|
+
if (id === self)
|
|
23
|
+
continue;
|
|
24
|
+
const y = input.y.get(id) ?? 0;
|
|
25
|
+
const h = input.height(id) / 2;
|
|
26
|
+
if (y + h > lo && y - h < hi)
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
export function planFlow(input, flow, chain) {
|
|
32
|
+
const { graph } = input;
|
|
33
|
+
const ranks = chain.map((id) => input.rank.get(id) ?? 0);
|
|
34
|
+
const ys = chain.map((id) => input.y.get(id) ?? 0);
|
|
35
|
+
const n = chain.length;
|
|
36
|
+
const src = chain[0];
|
|
37
|
+
const tgt = chain[n - 1];
|
|
38
|
+
let exit = "right";
|
|
39
|
+
const event = graph.byId.get(flow.sourceRef);
|
|
40
|
+
if (n === 2 && ranks[0] === ranks[1]) {
|
|
41
|
+
return { flow, chain, ranks, ys, exit: "stack", entry: "side" };
|
|
42
|
+
}
|
|
43
|
+
if (event?.type === "boundaryEvent") {
|
|
44
|
+
const side = input.sideOf(flow.sourceRef);
|
|
45
|
+
const port = ys[0] + side * (input.height(src) / 2 + 18);
|
|
46
|
+
const next = ys[1];
|
|
47
|
+
if (side * (next - port) >= STEM && columnClear(input, ranks[0], src, port, next)) {
|
|
48
|
+
exit = "event";
|
|
49
|
+
ys[0] = next;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
exit = "stem";
|
|
53
|
+
ys[0] = port + side * STEM;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (GATEWAYS.has(graph.byId.get(src)?.type ?? "") &&
|
|
57
|
+
forwardCount(graph, src, true) > 1 &&
|
|
58
|
+
ys[1] !== ys[0] &&
|
|
59
|
+
columnClear(input, ranks[0], src, ys[0], ys[1])) {
|
|
60
|
+
exit = "side";
|
|
61
|
+
ys[0] = ys[1];
|
|
62
|
+
}
|
|
63
|
+
let entry = "left";
|
|
64
|
+
if (n > 1 &&
|
|
65
|
+
GATEWAYS.has(graph.byId.get(tgt)?.type ?? "") &&
|
|
66
|
+
forwardCount(graph, tgt, false) > 1 &&
|
|
67
|
+
ys[n - 2] !== ys[n - 1] &&
|
|
68
|
+
columnClear(input, ranks[n - 1], tgt, ys[n - 2], ys[n - 1])) {
|
|
69
|
+
entry = "side";
|
|
70
|
+
ys[n - 1] = ys[n - 2];
|
|
71
|
+
}
|
|
72
|
+
return { flow, chain, ranks, ys, exit, entry };
|
|
73
|
+
}
|
|
74
|
+
export function jogsOf(plan) {
|
|
75
|
+
const jogs = [];
|
|
76
|
+
for (let i = 0; i + 1 < plan.ys.length; i++) {
|
|
77
|
+
const from = plan.ys[i];
|
|
78
|
+
const to = plan.ys[i + 1];
|
|
79
|
+
if (from !== to && plan.ranks[i] !== plan.ranks[i + 1])
|
|
80
|
+
jogs.push({ flow: plan.flow.id, gutter: plan.ranks[i + 1], from, to });
|
|
81
|
+
}
|
|
82
|
+
return jogs;
|
|
83
|
+
}
|
|
84
|
+
const within = (y, a, b) => y > Math.min(a, b) && y < Math.max(a, b);
|
|
85
|
+
/** Crossings when `a` takes the track left of `b`. */
|
|
86
|
+
function cost(a, b) {
|
|
87
|
+
return (within(a.to, b.from, b.to) ? 1 : 0) + (within(b.from, a.from, a.to) ? 1 : 0);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Order one gutter's jogs left to right: from top-down sorted entry lines,
|
|
91
|
+
* swap neighbours while that saves crossings.
|
|
92
|
+
*/
|
|
93
|
+
export function orderTracks(jogs) {
|
|
94
|
+
const out = [...jogs].sort((a, b) => a.from - b.from || a.to - b.to);
|
|
95
|
+
for (let pass = 0; pass < out.length; pass++) {
|
|
96
|
+
let swapped = false;
|
|
97
|
+
for (let i = 0; i + 1 < out.length; i++) {
|
|
98
|
+
const a = out[i];
|
|
99
|
+
const b = out[i + 1];
|
|
100
|
+
if (cost(b, a) < cost(a, b)) {
|
|
101
|
+
out[i] = b;
|
|
102
|
+
out[i + 1] = a;
|
|
103
|
+
swapped = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!swapped)
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
/** The polyline of a planned flow, once columns and tracks have x positions. */
|
|
112
|
+
export function drawPlan(plan, bounds, trackX) {
|
|
113
|
+
const src = bounds.get(plan.chain[0]);
|
|
114
|
+
const tgt = bounds.get(plan.chain[plan.chain.length - 1]);
|
|
115
|
+
const ys = plan.ys;
|
|
116
|
+
const n = ys.length;
|
|
117
|
+
const pts = [];
|
|
118
|
+
const cx = (b) => b.x + b.width / 2;
|
|
119
|
+
const cy = (b) => b.y + b.height / 2;
|
|
120
|
+
if (plan.exit === "stack") {
|
|
121
|
+
const from = bounds.get(plan.flow.sourceRef) ?? src;
|
|
122
|
+
const down = cy(tgt) > cy(from);
|
|
123
|
+
const a = { x: cx(from), y: down ? from.y + from.height : from.y };
|
|
124
|
+
const b = { x: cx(tgt), y: down ? tgt.y : tgt.y + tgt.height };
|
|
125
|
+
if (a.x === b.x)
|
|
126
|
+
return [a, b];
|
|
127
|
+
const mid = (a.y + b.y) / 2;
|
|
128
|
+
return [a, { x: a.x, y: mid }, { x: b.x, y: mid }, b];
|
|
129
|
+
}
|
|
130
|
+
if (plan.exit === "right") {
|
|
131
|
+
pts.push({ x: src.x + src.width, y: ys[0] });
|
|
132
|
+
}
|
|
133
|
+
else if (plan.exit === "side") {
|
|
134
|
+
pts.push({ x: cx(src), y: ys[0] > cy(src) ? src.y + src.height : src.y });
|
|
135
|
+
pts.push({ x: cx(src), y: ys[0] });
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const ev = bounds.get(plan.flow.sourceRef);
|
|
139
|
+
pts.push({ x: cx(ev), y: ys[0] > cy(ev) ? ev.y + ev.height : ev.y });
|
|
140
|
+
pts.push({ x: cx(ev), y: ys[0] });
|
|
141
|
+
}
|
|
142
|
+
for (let i = 0; i + 1 < n; i++) {
|
|
143
|
+
if (ys[i] === ys[i + 1])
|
|
144
|
+
continue;
|
|
145
|
+
const x = trackX(plan.flow.id, plan.ranks[i + 1]);
|
|
146
|
+
pts.push({ x, y: ys[i] }, { x, y: ys[i + 1] });
|
|
147
|
+
}
|
|
148
|
+
if (plan.entry === "left") {
|
|
149
|
+
pts.push({ x: tgt.x, y: ys[n - 1] });
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
pts.push({ x: cx(tgt), y: ys[n - 1] });
|
|
153
|
+
pts.push({ x: cx(tgt), y: ys[n - 1] > cy(tgt) ? tgt.y + tgt.height : tgt.y });
|
|
154
|
+
}
|
|
155
|
+
return collapse(pts);
|
|
156
|
+
}
|
|
157
|
+
function collapse(points) {
|
|
158
|
+
const out = [];
|
|
159
|
+
for (const p of points) {
|
|
160
|
+
const last = out[out.length - 1];
|
|
161
|
+
if (last && last.x === p.x && last.y === p.y)
|
|
162
|
+
continue;
|
|
163
|
+
const prev = out[out.length - 2];
|
|
164
|
+
if (last &&
|
|
165
|
+
prev &&
|
|
166
|
+
((prev.x === last.x && last.x === p.x) || (prev.y === last.y && last.y === p.y))) {
|
|
167
|
+
out[out.length - 1] = p;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
out.push(p);
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
function segHits(a, b, o) {
|
|
175
|
+
const x1 = Math.min(a.x, b.x);
|
|
176
|
+
const x2 = Math.max(a.x, b.x);
|
|
177
|
+
const y1 = Math.min(a.y, b.y);
|
|
178
|
+
const y2 = Math.max(a.y, b.y);
|
|
179
|
+
return x2 > o.x + 1 && x1 < o.x + o.width - 1 && y2 > o.y + 1 && y1 < o.y + o.height - 1;
|
|
180
|
+
}
|
|
181
|
+
function crosses(a, b, c, d) {
|
|
182
|
+
const h1 = a.y === b.y;
|
|
183
|
+
const h2 = c.y === d.y;
|
|
184
|
+
if (h1 === h2)
|
|
185
|
+
return false;
|
|
186
|
+
const [h, v] = h1
|
|
187
|
+
? [
|
|
188
|
+
[a, b],
|
|
189
|
+
[c, d],
|
|
190
|
+
]
|
|
191
|
+
: [
|
|
192
|
+
[c, d],
|
|
193
|
+
[a, b],
|
|
194
|
+
];
|
|
195
|
+
const [p, q] = h;
|
|
196
|
+
const [r, s] = v;
|
|
197
|
+
return (r.x > Math.min(p.x, q.x) &&
|
|
198
|
+
r.x < Math.max(p.x, q.x) &&
|
|
199
|
+
p.y > Math.min(r.y, s.y) &&
|
|
200
|
+
p.y < Math.max(r.y, s.y));
|
|
201
|
+
}
|
|
202
|
+
/** Shapes a flow may touch: its ends, and the host of a boundary source. */
|
|
203
|
+
function endsOf(graph, flow) {
|
|
204
|
+
const ends = new Set([flow.sourceRef, flow.targetRef]);
|
|
205
|
+
const source = graph.byId.get(flow.sourceRef);
|
|
206
|
+
if (source?.type === "boundaryEvent")
|
|
207
|
+
ends.add(source.attachedToRef);
|
|
208
|
+
return ends;
|
|
209
|
+
}
|
|
210
|
+
export class Router {
|
|
211
|
+
graph;
|
|
212
|
+
bounds;
|
|
213
|
+
segments = [];
|
|
214
|
+
loops = [];
|
|
215
|
+
constructor(graph, bounds) {
|
|
216
|
+
this.graph = graph;
|
|
217
|
+
this.bounds = bounds;
|
|
218
|
+
}
|
|
219
|
+
commit(points) {
|
|
220
|
+
for (let i = 0; i + 1 < points.length; i++) {
|
|
221
|
+
this.segments.push([points[i], points[i + 1]]);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
hits(points, ends) {
|
|
225
|
+
for (const [id, b] of this.bounds) {
|
|
226
|
+
if (ends.has(id))
|
|
227
|
+
continue;
|
|
228
|
+
for (let i = 0; i + 1 < points.length; i++) {
|
|
229
|
+
if (segHits(points[i], points[i + 1], b))
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
crossings(points) {
|
|
236
|
+
let n = 0;
|
|
237
|
+
for (let i = 0; i + 1 < points.length; i++) {
|
|
238
|
+
for (const [c, d] of this.segments) {
|
|
239
|
+
if (crosses(points[i], points[i + 1], c, d))
|
|
240
|
+
n++;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return n;
|
|
244
|
+
}
|
|
245
|
+
/** Keep a clear route; replace one through a shape with an obstacle-aware search. */
|
|
246
|
+
settle(flow, points) {
|
|
247
|
+
const ends = endsOf(this.graph, flow);
|
|
248
|
+
if (!this.hits(points, ends))
|
|
249
|
+
return points;
|
|
250
|
+
const found = this.search(flow, ends);
|
|
251
|
+
return found ?? points;
|
|
252
|
+
}
|
|
253
|
+
search(flow, ends) {
|
|
254
|
+
const source = this.bounds.get(flow.sourceRef);
|
|
255
|
+
const target = this.bounds.get(flow.targetRef);
|
|
256
|
+
if (!source || !target)
|
|
257
|
+
return null;
|
|
258
|
+
const event = this.graph.byId.get(flow.sourceRef);
|
|
259
|
+
let from = sidePorts(source, { right: 0, top: 20, bottom: 20, left: 80 });
|
|
260
|
+
if (event?.type === "boundaryEvent") {
|
|
261
|
+
const host = this.bounds.get(event.attachedToRef);
|
|
262
|
+
const onTop = host !== undefined && source.y + source.height / 2 <= host.y + 1;
|
|
263
|
+
from = sidePorts(source, {
|
|
264
|
+
top: onTop ? 0 : Number.POSITIVE_INFINITY,
|
|
265
|
+
bottom: onTop ? Number.POSITIVE_INFINITY : 0,
|
|
266
|
+
left: Number.POSITIVE_INFINITY,
|
|
267
|
+
right: Number.POSITIVE_INFINITY,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const obstacles = [];
|
|
271
|
+
for (const [id, b] of this.bounds)
|
|
272
|
+
if (!ends.has(id))
|
|
273
|
+
obstacles.push(b);
|
|
274
|
+
return routeOrthogonal({
|
|
275
|
+
from,
|
|
276
|
+
to: sidePorts(target, { left: 0, top: 20, bottom: 20, right: 80 }),
|
|
277
|
+
obstacles,
|
|
278
|
+
crossings: (a, b) => this.crossings([a, b]),
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* A flow back to an earlier column: out of the source's bottom (or top),
|
|
283
|
+
* along the nearest clear corridor past both ends, into the target's
|
|
284
|
+
* bottom (or top). The side with fewer crossings wins, then the shorter.
|
|
285
|
+
*/
|
|
286
|
+
loop(flow) {
|
|
287
|
+
const source = this.bounds.get(flow.sourceRef);
|
|
288
|
+
const target = this.bounds.get(flow.targetRef);
|
|
289
|
+
if (!source || !target)
|
|
290
|
+
return null;
|
|
291
|
+
const ends = endsOf(this.graph, flow);
|
|
292
|
+
const sx = source.x + source.width / 2;
|
|
293
|
+
const tx = target.x + target.width / 2;
|
|
294
|
+
if (flow.sourceRef === flow.targetRef) {
|
|
295
|
+
const right = source.x + source.width;
|
|
296
|
+
const y = source.y + source.height + STEM;
|
|
297
|
+
return [
|
|
298
|
+
{ x: right, y: source.y + source.height / 2 },
|
|
299
|
+
{ x: right + STEM, y: source.y + source.height / 2 },
|
|
300
|
+
{ x: right + STEM, y },
|
|
301
|
+
{ x: sx, y },
|
|
302
|
+
{ x: sx, y: source.y + source.height },
|
|
303
|
+
];
|
|
304
|
+
}
|
|
305
|
+
const event = this.graph.byId.get(flow.sourceRef);
|
|
306
|
+
let sides = [1, -1];
|
|
307
|
+
if (event?.type === "boundaryEvent") {
|
|
308
|
+
const host = this.bounds.get(event.attachedToRef);
|
|
309
|
+
const onTop = host !== undefined && source.y + source.height / 2 <= host.y + 1;
|
|
310
|
+
sides = [onTop ? -1 : 1];
|
|
311
|
+
}
|
|
312
|
+
const left = Math.min(sx, tx);
|
|
313
|
+
const right = Math.max(sx, tx);
|
|
314
|
+
let best = null;
|
|
315
|
+
for (const side of sides) {
|
|
316
|
+
const edgeOf = (b) => (side > 0 ? b.y + b.height : b.y);
|
|
317
|
+
const start = side > 0
|
|
318
|
+
? Math.max(edgeOf(source), edgeOf(target))
|
|
319
|
+
: Math.min(edgeOf(source), edgeOf(target));
|
|
320
|
+
const candidates = [start + side * STEM];
|
|
321
|
+
for (const [id, b] of this.bounds) {
|
|
322
|
+
if (ends.has(id) || b.x > right || b.x + b.width < left)
|
|
323
|
+
continue;
|
|
324
|
+
const e = edgeOf(b) + side * STEM;
|
|
325
|
+
if (side * (e - start) > 0)
|
|
326
|
+
candidates.push(e);
|
|
327
|
+
}
|
|
328
|
+
candidates.sort((a, b) => side * (a - b));
|
|
329
|
+
for (const c of candidates) {
|
|
330
|
+
let y = c;
|
|
331
|
+
while (this.loops.some((l) => Math.abs(l.y - y) < LOOP_STEP && l.left < right && left < l.right)) {
|
|
332
|
+
y += side * LOOP_STEP;
|
|
333
|
+
}
|
|
334
|
+
const points = [
|
|
335
|
+
{ x: sx, y: edgeOf(source) },
|
|
336
|
+
{ x: sx, y },
|
|
337
|
+
{ x: tx, y },
|
|
338
|
+
{ x: tx, y: edgeOf(target) },
|
|
339
|
+
];
|
|
340
|
+
if (this.hits(points, ends))
|
|
341
|
+
continue;
|
|
342
|
+
const crossings = this.crossings(points);
|
|
343
|
+
const length = Math.abs(y - edgeOf(source)) + Math.abs(y - edgeOf(target));
|
|
344
|
+
if (!best ||
|
|
345
|
+
crossings < best.crossings ||
|
|
346
|
+
(crossings === best.crossings && length < best.length)) {
|
|
347
|
+
best = { points, crossings, length, y };
|
|
348
|
+
}
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (!best)
|
|
353
|
+
return this.search(flow, ends);
|
|
354
|
+
this.loops.push({ left, right, y: best.y });
|
|
355
|
+
return best.points;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
export function edgeOf(flow, waypoints) {
|
|
359
|
+
const edge = {
|
|
360
|
+
id: flow.id,
|
|
361
|
+
sourceRef: flow.sourceRef,
|
|
362
|
+
targetRef: flow.targetRef,
|
|
363
|
+
waypoints: collapse(waypoints),
|
|
364
|
+
};
|
|
365
|
+
if (flow.name)
|
|
366
|
+
edge.label = flow.name;
|
|
367
|
+
return edge;
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -6,8 +6,10 @@ import type { LayoutHints, LayoutResult } from "./types.js";
|
|
|
6
6
|
* `semantic` places nodes by rank and narrative band and honours lane
|
|
7
7
|
* membership. `grid` is the older cell-grid walk, kept for collaborations,
|
|
8
8
|
* where pool and message-flow geometry is still decided by the caller.
|
|
9
|
+
* `layered` keeps the semantic graph, sizes and labels but places and routes
|
|
10
|
+
* lane-free scopes Sugiyama-style (see `layered/index.ts`); experimental.
|
|
9
11
|
*/
|
|
10
|
-
export type LayoutEngine = "semantic" | "grid";
|
|
12
|
+
export type LayoutEngine = "semantic" | "grid" | "layered";
|
|
11
13
|
/**
|
|
12
14
|
* Layout a full process. Boundary events, expanded subprocesses and edge
|
|
13
15
|
* labels are handled inside the engine.
|
|
@@ -18,7 +20,9 @@ export declare function layoutProcess(process: BpmnProcess, engine?: LayoutEngin
|
|
|
18
20
|
/** Sub-processes the diagram draws collapsed; their contents get their own plane. */
|
|
19
21
|
collapsed?: ReadonlySet<string>,
|
|
20
22
|
/** Tool-grid hints; only the `semantic` engine packs tools into a grid, so `grid` ignores them. */
|
|
21
|
-
grids?: LayoutHints["grids"]
|
|
23
|
+
grids?: LayoutHints["grids"],
|
|
24
|
+
/** The process is a pool's: its artifacts keep the stacked placement (pool sizes drive message routing). */
|
|
25
|
+
inPool?: boolean): LayoutResult;
|
|
22
26
|
/** Layout a set of flow nodes and sequence flows (used by ascii, proxy, compact). */
|
|
23
27
|
export declare function layoutFlowNodes(flowNodes: BpmnFlowElement[], sequenceFlows: BpmnSequenceFlow[]): LayoutResult;
|
|
24
28
|
//# sourceMappingURL=layout-engine.d.ts.map
|
|
@@ -10,10 +10,12 @@ export function layoutProcess(process, engine = "semantic",
|
|
|
10
10
|
/** Sub-processes the diagram draws collapsed; their contents get their own plane. */
|
|
11
11
|
collapsed,
|
|
12
12
|
/** Tool-grid hints; only the `semantic` engine packs tools into a grid, so `grid` ignores them. */
|
|
13
|
-
grids
|
|
13
|
+
grids,
|
|
14
|
+
/** The process is a pool's: its artifacts keep the stacked placement (pool sizes drive message routing). */
|
|
15
|
+
inPool = false) {
|
|
14
16
|
if (engine === "grid")
|
|
15
17
|
return gridLayoutFlowNodes(process.flowElements, process.sequenceFlows);
|
|
16
|
-
return semanticLayoutProcess(process, collapsed, grids);
|
|
18
|
+
return semanticLayoutProcess(process, collapsed, grids, inPool, engine === "layered");
|
|
17
19
|
}
|
|
18
20
|
/** Layout a set of flow nodes and sequence flows (used by ascii, proxy, compact). */
|
|
19
21
|
export function layoutFlowNodes(flowNodes, sequenceFlows) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reachesEnd } from "./graph.js";
|
|
1
|
+
import { entersDetour, reachesEnd } from "./graph.js";
|
|
2
2
|
function isDefaultFlow(source, flow) {
|
|
3
3
|
if (!source)
|
|
4
4
|
return false;
|
|
@@ -208,9 +208,15 @@ function traceSpine(graph, start, spine, straightFlows) {
|
|
|
208
208
|
// narrative — it only continues the spine if nothing else can.
|
|
209
209
|
handler: flow.sourceRef === current ? 0 : 1,
|
|
210
210
|
ends: reachesEnd(graph, flow.targetRef) ? 0 : 1,
|
|
211
|
+
// A detour stacked under its sibling target is a side trip, not the narrative.
|
|
212
|
+
detour: entersDetour(graph, flow) ? 1 : 0,
|
|
211
213
|
isDefault: isDefaultFlow(source, flow) ? 0 : 1,
|
|
212
214
|
}));
|
|
213
|
-
scored.sort((a, b) => a.handler - b.handler ||
|
|
215
|
+
scored.sort((a, b) => a.handler - b.handler ||
|
|
216
|
+
a.ends - b.ends ||
|
|
217
|
+
a.detour - b.detour ||
|
|
218
|
+
a.isDefault - b.isDefault ||
|
|
219
|
+
a.index - b.index);
|
|
214
220
|
const next = scored[0];
|
|
215
221
|
if (!next)
|
|
216
222
|
return;
|
|
@@ -24,8 +24,40 @@ export interface SemanticGraph {
|
|
|
24
24
|
ranks: Map<string, number>;
|
|
25
25
|
/** Lazily built: ids from which an end (or terminal) node is reachable. See {@link reachesEnd}. */
|
|
26
26
|
endReach?: Set<string>;
|
|
27
|
+
/** Nodes of the handlers placed on an exception row by `placeExceptionRow`. */
|
|
28
|
+
exceptionRow: Set<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Stack one-node detours under their sibling target. Off inside pools, where
|
|
31
|
+
* message routing depends on the pool's shape, and inside containers.
|
|
32
|
+
*/
|
|
33
|
+
stackDetours: boolean;
|
|
34
|
+
/** Ids of flows between adjacent lanes that share their source's column; see `laneHandoffs`. */
|
|
35
|
+
handoffs: Set<string>;
|
|
27
36
|
}
|
|
28
|
-
export declare function buildSemanticGraph(flowElements: BpmnFlowElement[], sequenceFlows: BpmnSequenceFlow[]
|
|
37
|
+
export declare function buildSemanticGraph(flowElements: BpmnFlowElement[], sequenceFlows: BpmnSequenceFlow[],
|
|
38
|
+
/** Stack one-node detours under their sibling target; see {@link feedsSibling}. */
|
|
39
|
+
stackDetours?: boolean): SemanticGraph;
|
|
40
|
+
/** True when `id` is a detour stacked under its sibling target (see {@link feedsSibling}). */
|
|
41
|
+
export declare function isDetour(graph: SemanticGraph, id: string): boolean;
|
|
42
|
+
/** True when `flow` enters a detour that {@link feedsSibling}: the spine takes the sibling instead. */
|
|
43
|
+
export declare function entersDetour(graph: SemanticGraph, flow: BpmnSequenceFlow): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Longest-path ranks over the acyclic remainder, then a bounded fixed point so
|
|
46
|
+
* a boundary handler never precedes the activity it is attached to. `steps`
|
|
47
|
+
* overrides the one-rank step of individual flows.
|
|
48
|
+
*/
|
|
49
|
+
export declare function assignRanks(graph: SemanticGraph, steps?: ReadonlyMap<string, number>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Exception row: re-rank so a boundary handler starts in its host's own column
|
|
52
|
+
* and its flow drops straight down (or up) from the event, onto a row the
|
|
53
|
+
* handlers of the spine share. A second event on one host fans out one column
|
|
54
|
+
* right. A handler whose column is taken (a sibling branch on that side, or an
|
|
55
|
+
* earlier handler's tail) keeps its step to the right, as before.
|
|
56
|
+
*
|
|
57
|
+
* Needs the hosts' bands, so it runs after a first band assignment; returns
|
|
58
|
+
* true when ranks changed and bands must be assigned again.
|
|
59
|
+
*/
|
|
60
|
+
export declare function placeExceptionRow(graph: SemanticGraph, bands: ReadonlyMap<string, number>, sideOf: (event: BpmnBoundaryEvent, host: string) => 1 | -1): boolean;
|
|
29
61
|
/**
|
|
30
62
|
* True when an end event is reachable from `id` without traversing a back edge.
|
|
31
63
|
* A node other than `id` itself that has no outgoing flow also ends the path.
|