@bpmnkit/core 1.14.0 → 1.16.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/AGENTS.md +5 -4
- package/agent-cards/bpmn.md +86 -80
- package/builder-reference.md +27 -8
- package/dist/bpmn/auto-layout.js +235 -42
- package/dist/bpmn/bpmn-builder.d.ts +171 -17
- package/dist/bpmn/bpmn-builder.js +792 -135
- 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 +126 -9
- package/dist/bpmn/compact.js +305 -30
- package/dist/bpmn/full-operations.d.ts +19 -0
- package/dist/bpmn/full-operations.js +191 -7
- package/dist/bpmn/make-room.d.ts +26 -0
- package/dist/bpmn/make-room.js +151 -0
- package/dist/bpmn/optimize/flow.js +8 -0
- package/dist/bpmn/place-new-shapes.d.ts +6 -1
- package/dist/bpmn/place-new-shapes.js +53 -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 +34 -2
- package/dist/bpmn/process-text.js +410 -7
- package/dist/bpmn/swimlanes.d.ts +178 -0
- package/dist/bpmn/swimlanes.js +774 -0
- package/dist/form/user-task-forms.d.ts +45 -0
- package/dist/form/user-task-forms.js +129 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +5 -2
- package/dist/layout/collaboration/message-labels.d.ts +25 -0
- package/dist/layout/collaboration/message-labels.js +108 -0
- package/dist/layout/collaboration/ordering.d.ts +5 -1
- package/dist/layout/collaboration/ordering.js +24 -9
- package/dist/layout/semantic/graph.js +3 -0
- package/dist/layout/semantic/place.d.ts +2 -0
- package/dist/layout/semantic/place.js +77 -9
- package/dist/xml/xml-patch.d.ts +1 -1
- package/llms.txt +1 -1
- package/package.json +2 -2
package/dist/bpmn/auto-layout.js
CHANGED
|
@@ -1,12 +1,45 @@
|
|
|
1
1
|
import { associationWaypoints, packAnnotations } from "../layout/annotations.js";
|
|
2
2
|
import { alignPools } from "../layout/collaboration/alignment.js";
|
|
3
|
+
import { placeMessageFlowLabels } from "../layout/collaboration/message-labels.js";
|
|
3
4
|
import { orderPools } from "../layout/collaboration/ordering.js";
|
|
4
5
|
import { collapseCollinear } from "../layout/grid/grid-router.js";
|
|
5
6
|
import { layoutProcess } from "../layout/layout-engine.js";
|
|
6
7
|
import { repairRoutes } from "../layout/repair.js";
|
|
8
|
+
import { MIN_LANE_HEIGHT } from "../layout/semantic/place.js";
|
|
7
9
|
const POOL_HEADER = 30;
|
|
8
10
|
const LANE_HEADER = 30;
|
|
9
11
|
const PADDING = 20;
|
|
12
|
+
/**
|
|
13
|
+
* Lane bands grown to hold the annotations the packer put above or below them:
|
|
14
|
+
* the pool takes the bands' height, so an annotation outside them would hang
|
|
15
|
+
* over the pool's edge. The outermost band on that side grows.
|
|
16
|
+
*/
|
|
17
|
+
function stretchBands(bands, annotations) {
|
|
18
|
+
const out = bands.map((b) => ({ ...b, bounds: { ...b.bounds } }));
|
|
19
|
+
if (out.length === 0)
|
|
20
|
+
return out;
|
|
21
|
+
let top = Math.min(...out.map((b) => b.bounds.y));
|
|
22
|
+
let bottom = Math.max(...out.map((b) => b.bounds.y + b.bounds.height));
|
|
23
|
+
for (const a of annotations) {
|
|
24
|
+
const high = a.y - PADDING;
|
|
25
|
+
const low = a.y + a.height + PADDING;
|
|
26
|
+
if (low > bottom) {
|
|
27
|
+
for (const b of out)
|
|
28
|
+
if (b.bounds.y + b.bounds.height === bottom)
|
|
29
|
+
b.bounds.height += low - bottom;
|
|
30
|
+
bottom = low;
|
|
31
|
+
}
|
|
32
|
+
if (high < top) {
|
|
33
|
+
for (const b of out)
|
|
34
|
+
if (b.bounds.y === top) {
|
|
35
|
+
b.bounds.height += top - high;
|
|
36
|
+
b.bounds.y = high;
|
|
37
|
+
}
|
|
38
|
+
top = high;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
10
43
|
const POOL_GAP = 30;
|
|
11
44
|
function contentBbox(nodes, extra) {
|
|
12
45
|
let minX = Number.POSITIVE_INFINITY;
|
|
@@ -35,6 +68,23 @@ function contentBbox(nodes, extra) {
|
|
|
35
68
|
}
|
|
36
69
|
return { minX, minY, maxX, maxY };
|
|
37
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Data elements are never lane members, and the engine stacks them below the
|
|
73
|
+
* bands; growing the pool for them leaves tall empty tails, so only flow nodes
|
|
74
|
+
* count.
|
|
75
|
+
*/
|
|
76
|
+
const NOT_LANE_MEMBERS = new Set(["dataObject", "dataObjectReference", "dataStoreReference"]);
|
|
77
|
+
/**
|
|
78
|
+
* Where a laned pool has to end so the nodes no lane claims stay inside it.
|
|
79
|
+
* The engine stacks those nodes below the lane bands, so they are the ones
|
|
80
|
+
* whose top lies at or under `bandBottom`; with none, `bandBottom` itself.
|
|
81
|
+
*/
|
|
82
|
+
function orphanExtent(nodes, bandBottom) {
|
|
83
|
+
const orphans = nodes.filter((node) => node.bounds.y >= bandBottom && !NOT_LANE_MEMBERS.has(node.type));
|
|
84
|
+
if (orphans.length === 0)
|
|
85
|
+
return bandBottom;
|
|
86
|
+
return contentBbox(orphans).maxY + PADDING;
|
|
87
|
+
}
|
|
38
88
|
function nodeToShape(node, dx, dy) {
|
|
39
89
|
const shape = {
|
|
40
90
|
id: `${node.id}_di`,
|
|
@@ -87,26 +137,6 @@ function edgeToShape(edge, dx, dy) {
|
|
|
87
137
|
}
|
|
88
138
|
return diEdge;
|
|
89
139
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Lane shapes for one process: the engine's bands when it placed nodes by lane,
|
|
92
|
-
* otherwise the top-level lanes tiled proportionally over the content height.
|
|
93
|
-
*/
|
|
94
|
-
function laneShapesFor(lanes, laneBands, nodes, dx, dy, top, x, width, height) {
|
|
95
|
-
if (!laneBands)
|
|
96
|
-
return buildLaneShapes(lanes, nodes, dx, dy, top, x, width, height);
|
|
97
|
-
return laneBands.map((lane) => ({
|
|
98
|
-
id: `${lane.id}_di`,
|
|
99
|
-
bpmnElement: lane.id,
|
|
100
|
-
isHorizontal: true,
|
|
101
|
-
bounds: {
|
|
102
|
-
x: Math.round(x),
|
|
103
|
-
y: Math.round(lane.bounds.y + dy),
|
|
104
|
-
width: Math.round(width),
|
|
105
|
-
height: Math.round(lane.bounds.height),
|
|
106
|
-
},
|
|
107
|
-
unknownAttributes: {},
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
140
|
function buildLaneShapes(lanes, nodes, dx, dy, poolY, poolHeaderWidth, laneContentWidth, poolHeight) {
|
|
111
141
|
const elemToLane = new Map();
|
|
112
142
|
for (const lane of lanes) {
|
|
@@ -168,6 +198,18 @@ function buildLaneShapes(lanes, nodes, dx, dy, poolY, poolHeaderWidth, laneConte
|
|
|
168
198
|
return shape;
|
|
169
199
|
});
|
|
170
200
|
}
|
|
201
|
+
/** Data associations drawn as association edges; only those with an id can have a DI edge. */
|
|
202
|
+
function dataAssociations(el, out) {
|
|
203
|
+
for (const a of el.dataInputAssociations ?? []) {
|
|
204
|
+
const source = a.sourceRefs[0];
|
|
205
|
+
if (a.id !== undefined && source !== undefined)
|
|
206
|
+
out.push({ id: a.id, sourceRef: source, targetRef: el.id, unknownAttributes: {} });
|
|
207
|
+
}
|
|
208
|
+
for (const a of el.dataOutputAssociations ?? []) {
|
|
209
|
+
if (a.id !== undefined && a.targetRef !== undefined)
|
|
210
|
+
out.push({ id: a.id, sourceRef: el.id, targetRef: a.targetRef, unknownAttributes: {} });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
171
213
|
/**
|
|
172
214
|
* A view of `process` whose annotations and associations include those declared
|
|
173
215
|
* inside (nested) sub-processes. The builder stores them on the sub-process
|
|
@@ -180,6 +222,7 @@ function withNestedAnnotations(process) {
|
|
|
180
222
|
const walk = (elements) => {
|
|
181
223
|
for (const el of elements) {
|
|
182
224
|
const scope = el;
|
|
225
|
+
dataAssociations(el, associations);
|
|
183
226
|
if (scope.textAnnotations)
|
|
184
227
|
textAnnotations.push(...scope.textAnnotations);
|
|
185
228
|
if (scope.associations)
|
|
@@ -195,6 +238,36 @@ function withNestedAnnotations(process) {
|
|
|
195
238
|
}
|
|
196
239
|
return { ...process, textAnnotations, associations };
|
|
197
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* The lane shapes of a laid-out process, outermost lanes first: the engine's
|
|
243
|
+
* bands when it placed the nodes by lane, each nesting level one header
|
|
244
|
+
* further in with right edges aligned; else top-level bands tiled in
|
|
245
|
+
* proportion to the nodes each lane holds. The outermost lanes start at
|
|
246
|
+
* `frame.left` and span `frame.width`; `frame.top` and `frame.height` are the
|
|
247
|
+
* extent the proportional bands tile. `dx` and `dy` shift layout space onto
|
|
248
|
+
* the plane.
|
|
249
|
+
*/
|
|
250
|
+
function laneShapesOf(lanes, levels, laneBands, nodes, dx, dy, frame) {
|
|
251
|
+
if (!laneBands) {
|
|
252
|
+
return buildLaneShapes(lanes, nodes, dx, dy, frame.top, frame.left, frame.width, frame.height);
|
|
253
|
+
}
|
|
254
|
+
const depthOf = new Map(levels.map((level) => [level.lane.id, level.depth]));
|
|
255
|
+
return laneBands.map((lane) => {
|
|
256
|
+
const inset = (depthOf.get(lane.id) ?? 0) * LANE_HEADER;
|
|
257
|
+
return {
|
|
258
|
+
id: `${lane.id}_di`,
|
|
259
|
+
bpmnElement: lane.id,
|
|
260
|
+
isHorizontal: true,
|
|
261
|
+
bounds: {
|
|
262
|
+
x: Math.round(frame.left + inset),
|
|
263
|
+
y: Math.round(lane.bounds.y + dy),
|
|
264
|
+
width: Math.round(frame.width - inset),
|
|
265
|
+
height: Math.round(lane.bounds.height),
|
|
266
|
+
},
|
|
267
|
+
unknownAttributes: {},
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
}
|
|
198
271
|
/** Also used by `expand`, which lays out one process without the pool handling above. */
|
|
199
272
|
export function addAnnotationShapes(process, layoutNodes, annLocalBounds, allShapes, allEdges, dx, dy) {
|
|
200
273
|
if (process.textAnnotations.length === 0 && process.associations.length === 0)
|
|
@@ -291,6 +364,96 @@ const MESSAGE_FLOW_STEM_STEP = 8;
|
|
|
291
364
|
const MESSAGE_FLOW_JOG = 20;
|
|
292
365
|
const MESSAGE_FLOW_MAX_JOG = 2400;
|
|
293
366
|
const EMPTY_POOL_WIDTH = 300;
|
|
367
|
+
/**
|
|
368
|
+
* Every lane of a lane set, each parent before its children (pre-order).
|
|
369
|
+
* Empty for an absent lane set.
|
|
370
|
+
*
|
|
371
|
+
* @throws Error when one lane object occurs twice, as a lane set that contains
|
|
372
|
+
* itself does; walking it would never end.
|
|
373
|
+
*/
|
|
374
|
+
function laneLevels(laneSet) {
|
|
375
|
+
const levels = [];
|
|
376
|
+
const seen = new Set();
|
|
377
|
+
const walk = (set, depth, parentId) => {
|
|
378
|
+
for (const lane of set.lanes) {
|
|
379
|
+
if (seen.has(lane))
|
|
380
|
+
throw new Error(`Lane ${lane.id} occurs twice in its lane set`);
|
|
381
|
+
seen.add(lane);
|
|
382
|
+
const leaf = (lane.childLaneSet?.lanes.length ?? 0) === 0;
|
|
383
|
+
levels.push(parentId === undefined ? { lane, depth, leaf } : { lane, depth, parentId, leaf });
|
|
384
|
+
if (lane.childLaneSet)
|
|
385
|
+
walk(lane.childLaneSet, depth + 1, lane.id);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
if (laneSet)
|
|
389
|
+
walk(laneSet, 0);
|
|
390
|
+
return levels;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Width the lane headers take at the left of a pool: one header per nesting
|
|
394
|
+
* level, since each level is inset by one header; 0 without lanes.
|
|
395
|
+
*/
|
|
396
|
+
function laneHeadersWidth(levels) {
|
|
397
|
+
if (levels.length === 0)
|
|
398
|
+
return 0;
|
|
399
|
+
return (Math.max(...levels.map((level) => level.depth)) + 1) * LANE_HEADER;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Pool and lane shapes for a laned process with no flow nodes. Each leaf lane
|
|
403
|
+
* gets a band of {@link MIN_LANE_HEIGHT} and each parent spans its children, so
|
|
404
|
+
* every lane keeps DI to draw and to drop into. Lanes come outermost first.
|
|
405
|
+
*
|
|
406
|
+
* @returns the shapes, pool first, and the pool height.
|
|
407
|
+
*/
|
|
408
|
+
function emptyLanedPool(participantId, levels, poolY) {
|
|
409
|
+
const span = new Map();
|
|
410
|
+
let top = 0;
|
|
411
|
+
for (const level of levels) {
|
|
412
|
+
if (!level.leaf)
|
|
413
|
+
continue;
|
|
414
|
+
span.set(level.lane.id, { top, bottom: top + MIN_LANE_HEIGHT });
|
|
415
|
+
top += MIN_LANE_HEIGHT;
|
|
416
|
+
}
|
|
417
|
+
// Reversed pre-order reaches every child before its parent.
|
|
418
|
+
for (const level of [...levels].reverse()) {
|
|
419
|
+
const own = span.get(level.lane.id);
|
|
420
|
+
if (level.parentId === undefined || !own)
|
|
421
|
+
continue;
|
|
422
|
+
const parent = span.get(level.parentId);
|
|
423
|
+
span.set(level.parentId, parent
|
|
424
|
+
? { top: Math.min(parent.top, own.top), bottom: Math.max(parent.bottom, own.bottom) }
|
|
425
|
+
: own);
|
|
426
|
+
}
|
|
427
|
+
const shapes = [
|
|
428
|
+
{
|
|
429
|
+
id: `${participantId}_di`,
|
|
430
|
+
bpmnElement: participantId,
|
|
431
|
+
isHorizontal: true,
|
|
432
|
+
bounds: { x: 0, y: poolY, width: EMPTY_POOL_WIDTH, height: top },
|
|
433
|
+
unknownAttributes: {},
|
|
434
|
+
},
|
|
435
|
+
];
|
|
436
|
+
const ordered = [...levels].sort((a, b) => a.depth - b.depth || (span.get(a.lane.id)?.top ?? 0) - (span.get(b.lane.id)?.top ?? 0));
|
|
437
|
+
for (const { lane, depth } of ordered) {
|
|
438
|
+
const band = span.get(lane.id);
|
|
439
|
+
if (!band)
|
|
440
|
+
continue;
|
|
441
|
+
const inset = POOL_HEADER + depth * LANE_HEADER;
|
|
442
|
+
shapes.push({
|
|
443
|
+
id: `${lane.id}_di`,
|
|
444
|
+
bpmnElement: lane.id,
|
|
445
|
+
isHorizontal: true,
|
|
446
|
+
bounds: {
|
|
447
|
+
x: inset,
|
|
448
|
+
y: poolY + band.top,
|
|
449
|
+
width: EMPTY_POOL_WIDTH - inset,
|
|
450
|
+
height: band.bottom - band.top,
|
|
451
|
+
},
|
|
452
|
+
unknownAttributes: {},
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
return { shapes, height: top };
|
|
456
|
+
}
|
|
294
457
|
/**
|
|
295
458
|
* Sub-processes the source diagram draws collapsed. A collapsed sub-process
|
|
296
459
|
* keeps its activity shape on the parent plane and carries its contents on a
|
|
@@ -610,8 +773,7 @@ function messageLinks(collab, pools, layouts) {
|
|
|
610
773
|
if (!layout || !pool?.participantId || layout.nodes.length === 0)
|
|
611
774
|
continue;
|
|
612
775
|
const { minX } = contentBbox(layout.nodes);
|
|
613
|
-
const
|
|
614
|
-
const elemX = POOL_HEADER + (hasLanes ? LANE_HEADER : 0) + PADDING;
|
|
776
|
+
const elemX = POOL_HEADER + laneHeadersWidth(laneLevels(pool.process?.laneSet)) + PADDING;
|
|
615
777
|
for (const node of layout.nodes) {
|
|
616
778
|
centres.set(node.id, {
|
|
617
779
|
pool: index,
|
|
@@ -697,7 +859,7 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
697
859
|
}
|
|
698
860
|
}
|
|
699
861
|
const depths = depthIndex(layoutOf.values());
|
|
700
|
-
const order = orderPools(participantPools.length, poolLinks(collab, poolOwners(defs, collab), (id) => depths.get(id)));
|
|
862
|
+
const order = orderPools(participantPools.length, poolLinks(collab, poolOwners(defs, collab), (id) => depths.get(id)), new Set(participantPools.flatMap((pool, i) => (pool.process ? [] : [i]))));
|
|
701
863
|
for (const index of order) {
|
|
702
864
|
const pool = participantPools[index];
|
|
703
865
|
if (pool)
|
|
@@ -730,6 +892,8 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
730
892
|
const { participantId, process } = pool;
|
|
731
893
|
const lanes = process?.laneSet?.lanes ?? [];
|
|
732
894
|
const hasLanes = lanes.length > 0;
|
|
895
|
+
const levels = laneLevels(process?.laneSet);
|
|
896
|
+
const headersWidth = laneHeadersWidth(levels);
|
|
733
897
|
const result = layouts[poolIndex] ?? { nodes: [], edges: [] };
|
|
734
898
|
const alignDx = alignment[poolIndex] ?? 0;
|
|
735
899
|
// A participant with no process, or one whose process has no flow nodes,
|
|
@@ -746,6 +910,13 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
746
910
|
addAnnotationShapes(process, [], annOnly, allShapes, allEdges, PADDING - bbox.minX, PADDING - bbox.minY);
|
|
747
911
|
continue;
|
|
748
912
|
}
|
|
913
|
+
// Lanes with nothing in them still need bands, or they have no DI at all.
|
|
914
|
+
if (participantId && hasLanes) {
|
|
915
|
+
const empty = emptyLanedPool(participantId, levels, poolY);
|
|
916
|
+
allShapes.push(...empty.shapes);
|
|
917
|
+
poolY += empty.height + POOL_GAP;
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
749
920
|
if (participantId) {
|
|
750
921
|
const shape = {
|
|
751
922
|
id: `${participantId}_di`,
|
|
@@ -775,7 +946,7 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
775
946
|
// Engine lane bands already stack the content vertically, so the pool
|
|
776
947
|
// aligns to the band space rather than to the content bounding box —
|
|
777
948
|
// otherwise the shapes drift out of the lanes drawn around them.
|
|
778
|
-
const laneBands = hasLanes ? engineLanes : undefined;
|
|
949
|
+
const laneBands = hasLanes && engineLanes ? stretchBands(engineLanes, annBounds.values()) : undefined;
|
|
779
950
|
// Bands arrive outermost first and nested lanes overlap their parent, so the
|
|
780
951
|
// pool spans their extent rather than the first band or the sum of heights.
|
|
781
952
|
const bandTop = laneBands ? Math.min(...laneBands.map((lane) => lane.bounds.y)) : 0;
|
|
@@ -787,21 +958,26 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
787
958
|
let dx;
|
|
788
959
|
let dy;
|
|
789
960
|
if (participantId) {
|
|
790
|
-
const elemX = POOL_HEADER +
|
|
961
|
+
const elemX = POOL_HEADER + headersWidth + PADDING;
|
|
791
962
|
dx = elemX - minX + alignDx;
|
|
792
963
|
dy = laneBands ? poolY - bandTop : poolY + PADDING - minY;
|
|
793
964
|
}
|
|
794
965
|
else {
|
|
795
966
|
// A process outside any pool draws its lanes on the plane itself (bpmn-js
|
|
796
967
|
// imports lane DI under a process root), header at x 0, so the content
|
|
797
|
-
// clears the lane
|
|
968
|
+
// clears the lane headers the way it does in a pool.
|
|
798
969
|
// A layout pass must not invent a participant to hold them.
|
|
799
|
-
dx =
|
|
970
|
+
dx = headersWidth + PADDING - minX;
|
|
800
971
|
dy = laneBands ? processTop - bandTop : processTop + PADDING - minY;
|
|
801
972
|
}
|
|
802
973
|
/** Lanes of a process outside any pool, drawn straight on its plane. */
|
|
803
974
|
const bareLanes = !participantId && hasLanes
|
|
804
|
-
?
|
|
975
|
+
? laneShapesOf(lanes, levels, laneBands, result.nodes, dx, dy, {
|
|
976
|
+
left: 0,
|
|
977
|
+
top: processTop,
|
|
978
|
+
width: headersWidth + contentW + 2 * PADDING,
|
|
979
|
+
height: laneBands ? bandHeight : contentH + 2 * PADDING,
|
|
980
|
+
})
|
|
805
981
|
: [];
|
|
806
982
|
// Only the primary process shares the root plane; any other root process
|
|
807
983
|
// owns one, instead of being stacked on top of the first at the origin.
|
|
@@ -826,19 +1002,27 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
826
1002
|
}
|
|
827
1003
|
allShapes.push(...bareLanes);
|
|
828
1004
|
if (participantId) {
|
|
829
|
-
const innerW =
|
|
830
|
-
// Lanes must tile the pool exactly, so the pool takes their height
|
|
831
|
-
|
|
832
|
-
|
|
1005
|
+
const innerW = headersWidth + contentW + 2 * PADDING + alignDx;
|
|
1006
|
+
// Lanes must tile the pool exactly, so the pool takes their height, and
|
|
1007
|
+
// grows past them only for nodes no lane claims, which the engine
|
|
1008
|
+
// places below the bands.
|
|
1009
|
+
const innerH = laneBands
|
|
1010
|
+
? Math.max(bandHeight, orphanExtent(result.nodes, bandTop + bandHeight) - bandTop)
|
|
1011
|
+
: contentH + 2 * PADDING;
|
|
833
1012
|
allShapes.push({
|
|
834
1013
|
id: `${participantId}_di`,
|
|
835
1014
|
bpmnElement: participantId,
|
|
836
1015
|
isHorizontal: true,
|
|
837
|
-
bounds: { x: 0, y: poolY, width:
|
|
1016
|
+
bounds: { x: 0, y: poolY, width: POOL_HEADER + innerW, height: innerH },
|
|
838
1017
|
unknownAttributes: {},
|
|
839
1018
|
});
|
|
840
1019
|
if (hasLanes) {
|
|
841
|
-
allShapes.push(...
|
|
1020
|
+
allShapes.push(...laneShapesOf(lanes, levels, laneBands, result.nodes, dx, dy, {
|
|
1021
|
+
left: POOL_HEADER,
|
|
1022
|
+
top: poolY,
|
|
1023
|
+
width: innerW,
|
|
1024
|
+
height: innerH,
|
|
1025
|
+
}));
|
|
842
1026
|
}
|
|
843
1027
|
poolY += innerH + POOL_GAP;
|
|
844
1028
|
}
|
|
@@ -866,7 +1050,7 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
866
1050
|
return current ?? id;
|
|
867
1051
|
};
|
|
868
1052
|
const participantIds = new Set(collab.participants.map((p) => p.id));
|
|
869
|
-
const laneIds = new Set(defs.processes.flatMap((p) => (p.laneSet
|
|
1053
|
+
const laneIds = new Set(defs.processes.flatMap((p) => laneLevels(p.laneSet).map((level) => level.lane.id)));
|
|
870
1054
|
// Pools and lanes are containers; message flows cross them by design. It is
|
|
871
1055
|
// the elements inside that a route has to miss.
|
|
872
1056
|
const obstacles = allShapes
|
|
@@ -939,6 +1123,20 @@ export function applyAutoLayout(defs, engine = "semantic", hints) {
|
|
|
939
1123
|
}
|
|
940
1124
|
const repair = routeRepair(defs);
|
|
941
1125
|
repair(allShapes, allEdges);
|
|
1126
|
+
if (collab && collab.messageFlows.length > 0) {
|
|
1127
|
+
const pools = new Set(collab.participants.map((p) => p.id));
|
|
1128
|
+
placeMessageFlowLabels({
|
|
1129
|
+
shapes: allShapes,
|
|
1130
|
+
edges: allEdges,
|
|
1131
|
+
names: new Map(collab.messageFlows.flatMap((f) => f.name?.trim() ? [[f.id, f.name.trim()]] : [])),
|
|
1132
|
+
containers: new Set([
|
|
1133
|
+
...pools,
|
|
1134
|
+
...defs.processes.flatMap((p) => (p.laneSet?.lanes ?? []).map((lane) => lane.id)),
|
|
1135
|
+
...allShapes.filter((s) => s.isExpanded === true).map((s) => s.bpmnElement),
|
|
1136
|
+
]),
|
|
1137
|
+
pools,
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
942
1140
|
for (const plane of rootPlanes)
|
|
943
1141
|
repair(plane.shapes, plane.edges);
|
|
944
1142
|
const planeBpmnElement = collab?.id ?? defs.processes[0]?.id ?? "plane";
|
|
@@ -1151,13 +1349,8 @@ function routeRepair(defs) {
|
|
|
1151
1349
|
}
|
|
1152
1350
|
for (const group of process.groups ?? [])
|
|
1153
1351
|
containers.add(group.id);
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
containers.add(lane.id);
|
|
1157
|
-
lanes(lane.childLaneSet);
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
lanes(process.laneSet);
|
|
1352
|
+
for (const level of laneLevels(process.laneSet))
|
|
1353
|
+
containers.add(level.lane.id);
|
|
1161
1354
|
}
|
|
1162
1355
|
const related = (id) => {
|
|
1163
1356
|
const out = [...(attachers.get(id) ?? [])];
|