@bpmnkit/core 1.12.0 → 1.14.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 +1 -0
- package/dist/bpmn/svg-render.d.ts +155 -0
- package/dist/bpmn/svg-render.js +782 -0
- package/dist/bpmn/svg.d.ts +5 -131
- package/dist/bpmn/svg.js +8 -766
- package/package.json +5 -1
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import { readDiColor } from "./di-color.js";
|
|
2
|
+
import { labelFontCss, resolveLabelFont, } from "./label-style.js";
|
|
3
|
+
const LIGHT = {
|
|
4
|
+
bg: "#f8f9fa",
|
|
5
|
+
shapeFill: "#ffffff",
|
|
6
|
+
shapeStroke: "#404040",
|
|
7
|
+
flowStroke: "#404040",
|
|
8
|
+
text: "#333333",
|
|
9
|
+
poolHeader: "rgba(0,0,0,0.04)",
|
|
10
|
+
textHalo: "#f8f9fa",
|
|
11
|
+
};
|
|
12
|
+
const DARK = {
|
|
13
|
+
bg: "#1e1e2e",
|
|
14
|
+
shapeFill: "#2a2a3e",
|
|
15
|
+
shapeStroke: "#8888bb",
|
|
16
|
+
flowStroke: "#7777aa",
|
|
17
|
+
text: "#cdd6f4",
|
|
18
|
+
poolHeader: "rgba(255,255,255,0.06)",
|
|
19
|
+
textHalo: "#1e1e2e",
|
|
20
|
+
};
|
|
21
|
+
/** The built-in palettes, so a custom theme can start from one. */
|
|
22
|
+
export const SVG_THEMES = {
|
|
23
|
+
light: LIGHT,
|
|
24
|
+
dark: DARK,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* {@link exportSvgDetailed}`.svg`. Unlike the `@bpmnkit/core` export, `autoLayout`
|
|
28
|
+
* needs an explicit `layout` here.
|
|
29
|
+
*/
|
|
30
|
+
export function exportSvg(defs, options) {
|
|
31
|
+
return exportSvgDetailed(defs, options).svg;
|
|
32
|
+
}
|
|
33
|
+
/** Like {@link exportSvg}, plus the drawn size, viewBox, element geometry and warnings. */
|
|
34
|
+
export function exportSvgDetailed(input, options) {
|
|
35
|
+
const t = resolveCtx(options);
|
|
36
|
+
const padding = options?.padding ?? 20;
|
|
37
|
+
const useDiColors = options?.colors === "di";
|
|
38
|
+
const withIds = options?.elementIds === true;
|
|
39
|
+
const withBg = options?.background !== false;
|
|
40
|
+
const warnings = [];
|
|
41
|
+
const elements = [];
|
|
42
|
+
const idAttr = (id) => (withIds ? ` data-element-id="${esc(id)}"` : "");
|
|
43
|
+
let defs = input;
|
|
44
|
+
let plane = selectPlane(defs, options?.plane);
|
|
45
|
+
if (options?.autoLayout === true &&
|
|
46
|
+
options.layout &&
|
|
47
|
+
options.plane === undefined &&
|
|
48
|
+
!plane?.shapes.length) {
|
|
49
|
+
defs = options.layout(defs);
|
|
50
|
+
warnings.push({ type: "autoLayoutApplied" });
|
|
51
|
+
plane = selectPlane(defs, undefined);
|
|
52
|
+
}
|
|
53
|
+
if (!plane)
|
|
54
|
+
return emptyResult(t, withBg, warnings);
|
|
55
|
+
// Build model index for name/type lookups
|
|
56
|
+
const idx = buildIndex(defs);
|
|
57
|
+
const labelStyles = options?.labelStyles?.(defs) ?? new Map();
|
|
58
|
+
const fontOf = (label) => {
|
|
59
|
+
const font = resolveLabelFont(label, labelStyles);
|
|
60
|
+
return font ? labelFontCss(font, t.fontFamily, t.fontSize) : undefined;
|
|
61
|
+
};
|
|
62
|
+
// ── Bounding box ──────────────────────────────────────────────────────────
|
|
63
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
64
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
65
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
66
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
67
|
+
for (const shape of plane.shapes) {
|
|
68
|
+
const { x, y, width, height } = shape.bounds;
|
|
69
|
+
minX = Math.min(minX, x);
|
|
70
|
+
minY = Math.min(minY, y);
|
|
71
|
+
maxX = Math.max(maxX, x + width);
|
|
72
|
+
maxY = Math.max(maxY, y + height);
|
|
73
|
+
}
|
|
74
|
+
for (const edge of plane.edges) {
|
|
75
|
+
for (const wp of edge.waypoints) {
|
|
76
|
+
minX = Math.min(minX, wp.x);
|
|
77
|
+
minY = Math.min(minY, wp.y);
|
|
78
|
+
maxX = Math.max(maxX, wp.x);
|
|
79
|
+
maxY = Math.max(maxY, wp.y);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!Number.isFinite(minX))
|
|
83
|
+
return emptyResult(t, withBg, warnings);
|
|
84
|
+
const ox = minX - padding;
|
|
85
|
+
const oy = minY - padding;
|
|
86
|
+
const vw = maxX - minX + padding * 2;
|
|
87
|
+
const vh = maxY - minY + padding * 2;
|
|
88
|
+
const { width, height } = fitSize(vw, vh, options);
|
|
89
|
+
// ── Edges ─────────────────────────────────────────────────────────────────
|
|
90
|
+
const edgeParts = [];
|
|
91
|
+
for (const edge of plane.edges) {
|
|
92
|
+
if (edge.waypoints.length < 2)
|
|
93
|
+
continue;
|
|
94
|
+
const flow = idx.flows.get(edge.bpmnElement);
|
|
95
|
+
const isMsg = idx.messageFlowIds.has(edge.bpmnElement);
|
|
96
|
+
const isAssoc = !flow && !isMsg;
|
|
97
|
+
const d = waypointsToPath(edge.waypoints);
|
|
98
|
+
const strokeColor = useDiColors
|
|
99
|
+
? (readDiColor(edge.unknownAttributes).stroke ?? t.flowStroke)
|
|
100
|
+
: t.flowStroke;
|
|
101
|
+
const sw = 1.5;
|
|
102
|
+
elements.push({
|
|
103
|
+
id: edge.bpmnElement,
|
|
104
|
+
kind: isMsg ? "messageFlow" : isAssoc ? "association" : "sequenceFlow",
|
|
105
|
+
geometry: { kind: "edge", waypoints: edge.waypoints.map((w) => [w.x, w.y]) },
|
|
106
|
+
});
|
|
107
|
+
if (isAssoc) {
|
|
108
|
+
edgeParts.push(`<path d="${d}"${idAttr(edge.bpmnElement)} fill="none" stroke="${strokeColor}" stroke-width="${sw}" stroke-dasharray="5 3"/>`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const dashArray = isMsg ? ' stroke-dasharray="6 3"' : "";
|
|
112
|
+
edgeParts.push(`<path d="${d}"${idAttr(edge.bpmnElement)} fill="none" stroke="${strokeColor}" stroke-width="${sw}"${dashArray} marker-end="url(#arr)"/>`);
|
|
113
|
+
// Default-flow slash
|
|
114
|
+
if (flow && idx.defaultFlowIds.has(edge.bpmnElement)) {
|
|
115
|
+
const wp0 = edge.waypoints[0];
|
|
116
|
+
const wp1 = edge.waypoints[1];
|
|
117
|
+
if (wp0 && wp1) {
|
|
118
|
+
const dx = wp1.x - wp0.x;
|
|
119
|
+
const dy = wp1.y - wp0.y;
|
|
120
|
+
const len = Math.sqrt(dx * dx + dy * dy);
|
|
121
|
+
if (len > 0) {
|
|
122
|
+
const nx = dx / len;
|
|
123
|
+
const ny = dy / len;
|
|
124
|
+
const tDist = Math.min(10, len * 0.25);
|
|
125
|
+
const cx = wp0.x + nx * tDist;
|
|
126
|
+
const cy = wp0.y + ny * tDist;
|
|
127
|
+
const s = 5;
|
|
128
|
+
edgeParts.push(`<line x1="${cx - ny * s}" y1="${cy + nx * s}" x2="${cx + ny * s}" y2="${cy - nx * s}" stroke="${strokeColor}" stroke-width="${sw}"/>`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Edge label
|
|
133
|
+
if (flow?.name && edge.label?.bounds) {
|
|
134
|
+
const { x, y, width, height } = edge.label.bounds;
|
|
135
|
+
edgeParts.push(labelSvg(flow.name, x + width / 2, y + height / 2, width, t, false, fontOf(edge.label)));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// ── Shapes ────────────────────────────────────────────────────────────────
|
|
139
|
+
// Pool/lane backgrounds are opaque and must render first, or they paint over
|
|
140
|
+
// the flow-node shapes and edges nested inside them.
|
|
141
|
+
const containerParts = [];
|
|
142
|
+
const shapeParts = [];
|
|
143
|
+
const labelParts = [];
|
|
144
|
+
const drawn = new Set();
|
|
145
|
+
for (const shape of plane.shapes) {
|
|
146
|
+
const { x, y, width, height } = shape.bounds;
|
|
147
|
+
const el = idx.elements.get(shape.bpmnElement);
|
|
148
|
+
const type = el?.type ?? "";
|
|
149
|
+
const font = fontOf(shape.label);
|
|
150
|
+
// Per-shape palette: DI colours replace fill/stroke for body and markers.
|
|
151
|
+
const c = useDiColors ? readDiColor(shape.unknownAttributes) : undefined;
|
|
152
|
+
const ts = c
|
|
153
|
+
? { ...t, shapeFill: c.fill ?? t.shapeFill, shapeStroke: c.stroke ?? t.shapeStroke }
|
|
154
|
+
: t;
|
|
155
|
+
let inner;
|
|
156
|
+
let isContainer = false;
|
|
157
|
+
let kind = el?.type;
|
|
158
|
+
if (isEvent(type)) {
|
|
159
|
+
inner = renderEvent(el, width, height, ts);
|
|
160
|
+
}
|
|
161
|
+
else if (isGateway(type)) {
|
|
162
|
+
inner = renderGateway(el, width, height, ts);
|
|
163
|
+
}
|
|
164
|
+
else if (type === "dataObjectReference") {
|
|
165
|
+
inner = renderDataObject(el, width, height, ts);
|
|
166
|
+
}
|
|
167
|
+
else if (type === "dataStoreReference") {
|
|
168
|
+
inner = renderDataStore(width, height, ts);
|
|
169
|
+
}
|
|
170
|
+
else if (type === "" && !el) {
|
|
171
|
+
// Pool, lane, annotation or group
|
|
172
|
+
const annotation = idx.annotations.get(shape.bpmnElement);
|
|
173
|
+
const group = idx.groups.get(shape.bpmnElement);
|
|
174
|
+
if (annotation !== undefined) {
|
|
175
|
+
inner = renderAnnotation(annotation.text, width, height, ts, font);
|
|
176
|
+
kind = "textAnnotation";
|
|
177
|
+
}
|
|
178
|
+
else if (group !== undefined) {
|
|
179
|
+
inner = renderGroup(idx.groupLabel(group), width, height, ts, font);
|
|
180
|
+
kind = "group";
|
|
181
|
+
isContainer = true;
|
|
182
|
+
}
|
|
183
|
+
else if (idx.participants.has(shape.bpmnElement)) {
|
|
184
|
+
inner = renderPool(idx.participants.get(shape.bpmnElement), width, height, ts, font);
|
|
185
|
+
kind = "participant";
|
|
186
|
+
isContainer = true;
|
|
187
|
+
}
|
|
188
|
+
else if (idx.lanes.has(shape.bpmnElement)) {
|
|
189
|
+
inner = renderLane(idx.lanes.get(shape.bpmnElement), width, height, ts, font);
|
|
190
|
+
kind = "lane";
|
|
191
|
+
isContainer = true;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
inner = "";
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// An expanded sub-process/transaction draws an opaque body rect that must
|
|
199
|
+
// render before (under) its own internal edges and child shapes, the same
|
|
200
|
+
// reason pools/lanes are treated as containers above — otherwise the body
|
|
201
|
+
// paints over everything nested inside it.
|
|
202
|
+
const isExpandedContainer = (type === "subProcess" ||
|
|
203
|
+
type === "adHocSubProcess" ||
|
|
204
|
+
type === "eventSubProcess" ||
|
|
205
|
+
type === "transaction") &&
|
|
206
|
+
shape.isExpanded === true;
|
|
207
|
+
inner = renderTask(el, width, height, ts, { expanded: isExpandedContainer, font });
|
|
208
|
+
if (isExpandedContainer)
|
|
209
|
+
isContainer = true;
|
|
210
|
+
}
|
|
211
|
+
if (inner) {
|
|
212
|
+
const g = `<g transform="translate(${x} ${y})"${idAttr(shape.bpmnElement)}>${inner}</g>`;
|
|
213
|
+
if (isContainer) {
|
|
214
|
+
containerParts.push(g);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
shapeParts.push(g);
|
|
218
|
+
}
|
|
219
|
+
if (kind) {
|
|
220
|
+
elements.push({
|
|
221
|
+
id: shape.bpmnElement,
|
|
222
|
+
kind,
|
|
223
|
+
geometry: { kind: "shape", bounds: shape.bounds },
|
|
224
|
+
});
|
|
225
|
+
drawn.add(shape.bpmnElement);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// External labels for events, gateways and data elements
|
|
229
|
+
const isExtLabel = isEvent(type) ||
|
|
230
|
+
isGateway(type) ||
|
|
231
|
+
type === "dataObjectReference" ||
|
|
232
|
+
type === "dataStoreReference";
|
|
233
|
+
if (el?.name && isExtLabel) {
|
|
234
|
+
const lb = shape.label?.bounds ?? {
|
|
235
|
+
x: shape.bounds.x + shape.bounds.width / 2 - 40,
|
|
236
|
+
y: shape.bounds.y + shape.bounds.height + 6,
|
|
237
|
+
width: 80,
|
|
238
|
+
height: 20,
|
|
239
|
+
};
|
|
240
|
+
labelParts.push(labelSvg(el.name, lb.x + lb.width / 2, lb.y + lb.height / 2, lb.width, t, true, font));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
for (const id of idx.elements.keys()) {
|
|
244
|
+
if (!drawn.has(id))
|
|
245
|
+
warnings.push({ type: "elementWithoutDi", id });
|
|
246
|
+
}
|
|
247
|
+
// ── Assemble SVG ──────────────────────────────────────────────────────────
|
|
248
|
+
const arrowFill = t.flowStroke;
|
|
249
|
+
const svg = [
|
|
250
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${ox} ${oy} ${vw} ${vh}" width="${width}" height="${height}">`,
|
|
251
|
+
...(withBg ? [`<rect x="${ox}" y="${oy}" width="${vw}" height="${vh}" fill="${t.bg}"/>`] : []),
|
|
252
|
+
"<defs>",
|
|
253
|
+
` <marker id="arr" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto" markerUnits="strokeWidth">`,
|
|
254
|
+
` <path d="M0,0 L8,3 L0,6 Z" fill="${arrowFill}"/>`,
|
|
255
|
+
" </marker>",
|
|
256
|
+
"</defs>",
|
|
257
|
+
...containerParts,
|
|
258
|
+
...edgeParts,
|
|
259
|
+
...shapeParts,
|
|
260
|
+
...labelParts,
|
|
261
|
+
"</svg>",
|
|
262
|
+
].join("\n");
|
|
263
|
+
return { svg, viewBox: { x: ox, y: oy, w: vw, h: vh }, width, height, elements, warnings };
|
|
264
|
+
}
|
|
265
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
266
|
+
/** @internal Theme colours and font settings from the shared export options. */
|
|
267
|
+
export function resolveCtx(options) {
|
|
268
|
+
const theme = options?.theme;
|
|
269
|
+
const base = theme === "dark" ? DARK : typeof theme === "object" ? theme : LIGHT;
|
|
270
|
+
return {
|
|
271
|
+
...base,
|
|
272
|
+
fontFamily: options?.font?.family ?? DEFAULT_FAMILY,
|
|
273
|
+
fontSize: options?.font?.size ?? DEFAULT_SIZE,
|
|
274
|
+
lineH: options?.font?.lineHeight ?? DEFAULT_LINE_H,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
/** @internal `width`/`height` after `scale` and `maxSize` (the viewBox never changes). */
|
|
278
|
+
export function fitSize(vw, vh, options) {
|
|
279
|
+
let width = vw * (options?.scale ?? 1);
|
|
280
|
+
let height = vh * (options?.scale ?? 1);
|
|
281
|
+
if (options?.maxSize) {
|
|
282
|
+
const [mw, mh] = options.maxSize;
|
|
283
|
+
const f = Math.min(1, mw / width, mh / height);
|
|
284
|
+
width = width * f;
|
|
285
|
+
height = height * f;
|
|
286
|
+
}
|
|
287
|
+
return { width, height };
|
|
288
|
+
}
|
|
289
|
+
function emptyResult(t, withBg, warnings) {
|
|
290
|
+
const rect = withBg ? `<rect width="1" height="1" fill="${t.bg}"/>` : "";
|
|
291
|
+
return {
|
|
292
|
+
svg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1" width="1" height="1">${rect}</svg>`,
|
|
293
|
+
viewBox: { x: 0, y: 0, w: 1, h: 1 },
|
|
294
|
+
width: 1,
|
|
295
|
+
height: 1,
|
|
296
|
+
elements: [],
|
|
297
|
+
warnings,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/** Picks the plane to draw; undefined when the model has none. */
|
|
301
|
+
function selectPlane(defs, sel) {
|
|
302
|
+
if (!sel)
|
|
303
|
+
return defs.diagrams[0]?.plane;
|
|
304
|
+
const hit = "id" in sel
|
|
305
|
+
? defs.diagrams.find((d) => d.id === sel.id || d.plane.id === sel.id)
|
|
306
|
+
: defs.diagrams.find((d) => d.plane.bpmnElement === sel.process);
|
|
307
|
+
if (!hit)
|
|
308
|
+
throw new Error(`Plane not found: ${"id" in sel ? sel.id : sel.process}`);
|
|
309
|
+
return hit.plane;
|
|
310
|
+
}
|
|
311
|
+
function isEvent(type) {
|
|
312
|
+
return (type === "startEvent" ||
|
|
313
|
+
type === "endEvent" ||
|
|
314
|
+
type === "intermediateCatchEvent" ||
|
|
315
|
+
type === "intermediateThrowEvent" ||
|
|
316
|
+
type === "boundaryEvent");
|
|
317
|
+
}
|
|
318
|
+
function isGateway(type) {
|
|
319
|
+
return (type === "exclusiveGateway" ||
|
|
320
|
+
type === "parallelGateway" ||
|
|
321
|
+
type === "inclusiveGateway" ||
|
|
322
|
+
type === "eventBasedGateway" ||
|
|
323
|
+
type === "complexGateway");
|
|
324
|
+
}
|
|
325
|
+
// ── Text ──────────────────────────────────────────────────────────────────────
|
|
326
|
+
const AVG_CHAR_PX = 6.5;
|
|
327
|
+
const DEFAULT_FAMILY = "system-ui,-apple-system,sans-serif";
|
|
328
|
+
const DEFAULT_SIZE = 11;
|
|
329
|
+
const DEFAULT_LINE_H = 14;
|
|
330
|
+
/** Estimated glyph width for a label font — scaled from the 11px default. */
|
|
331
|
+
/** @internal */
|
|
332
|
+
export function charPx(font, t) {
|
|
333
|
+
if (!font)
|
|
334
|
+
return AVG_CHAR_PX * (t.fontSize / DEFAULT_SIZE);
|
|
335
|
+
return AVG_CHAR_PX * (font.fontSize / DEFAULT_SIZE) * (font.fontWeight === "bold" ? 1.1 : 1);
|
|
336
|
+
}
|
|
337
|
+
/** @internal */
|
|
338
|
+
export function wrapText(text, maxPx, charW = AVG_CHAR_PX) {
|
|
339
|
+
if (!text.trim())
|
|
340
|
+
return [];
|
|
341
|
+
const words = text.split(/\s+/);
|
|
342
|
+
const lines = [];
|
|
343
|
+
let line = "";
|
|
344
|
+
for (const word of words) {
|
|
345
|
+
const candidate = line ? `${line} ${word}` : word;
|
|
346
|
+
if (candidate.length * charW <= maxPx) {
|
|
347
|
+
line = candidate;
|
|
348
|
+
}
|
|
349
|
+
else if (line) {
|
|
350
|
+
lines.push(line);
|
|
351
|
+
line = word;
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
line = word;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (line)
|
|
358
|
+
lines.push(line);
|
|
359
|
+
return lines.length > 0 ? lines : [text];
|
|
360
|
+
}
|
|
361
|
+
/** @internal */
|
|
362
|
+
export function esc(s) {
|
|
363
|
+
return s
|
|
364
|
+
.replace(/&/g, "&")
|
|
365
|
+
.replace(/</g, "<")
|
|
366
|
+
.replace(/>/g, ">")
|
|
367
|
+
.replace(/"/g, """);
|
|
368
|
+
}
|
|
369
|
+
/** @internal */
|
|
370
|
+
export function fontStyle(font, t) {
|
|
371
|
+
if (!font)
|
|
372
|
+
return `font-family:${t.fontFamily};font-size:${t.fontSize}px`;
|
|
373
|
+
let out = `font-family:${font.fontFamily};font-size:${font.fontSize}px`;
|
|
374
|
+
if (font.fontWeight !== "normal")
|
|
375
|
+
out += `;font-weight:${font.fontWeight}`;
|
|
376
|
+
if (font.fontStyle !== "normal")
|
|
377
|
+
out += `;font-style:${font.fontStyle}`;
|
|
378
|
+
if (font.textDecoration !== "none")
|
|
379
|
+
out += `;text-decoration:${font.textDecoration}`;
|
|
380
|
+
return out;
|
|
381
|
+
}
|
|
382
|
+
/** A label's inline style, XML-escaped for a double-quoted attribute. */
|
|
383
|
+
function textStyle(t, font) {
|
|
384
|
+
return esc(`fill:${t.text};${fontStyle(font, t)};text-anchor:middle;dominant-baseline:central;paint-order:stroke;stroke:${t.textHalo};stroke-width:4px;stroke-linejoin:round`);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Generates SVG text element(s) for a label centred at (cx, cy).
|
|
388
|
+
* topAlign=true makes multi-line text flow downward from cy rather than
|
|
389
|
+
* being centred around it — prevents long labels from overlapping the shape above.
|
|
390
|
+
*/
|
|
391
|
+
/** @internal */
|
|
392
|
+
export function labelSvg(text, cx, cy, maxWidth, t, topAlign = false, font) {
|
|
393
|
+
const lines = wrapText(text, maxWidth, charPx(font, t));
|
|
394
|
+
const lineH = font ? (font.fontSize * t.lineH) / t.fontSize : t.lineH;
|
|
395
|
+
const style = textStyle(t, font);
|
|
396
|
+
if (lines.length === 1) {
|
|
397
|
+
return `<text style="${style}" x="${cx}" y="${cy}">${esc(lines[0] ?? text)}</text>`;
|
|
398
|
+
}
|
|
399
|
+
const totalH = lines.length * lineH;
|
|
400
|
+
const startY = topAlign ? cy + lineH / 2 : cy - totalH / 2 + lineH / 2;
|
|
401
|
+
return lines
|
|
402
|
+
.map((l, i) => `<text style="${style}" x="${cx}" y="${startY + i * lineH}">${esc(l)}</text>`)
|
|
403
|
+
.join("");
|
|
404
|
+
}
|
|
405
|
+
// ── Path ──────────────────────────────────────────────────────────────────────
|
|
406
|
+
function waypointsToPath(wps) {
|
|
407
|
+
if (wps.length < 2)
|
|
408
|
+
return "";
|
|
409
|
+
const r = 4;
|
|
410
|
+
const parts = [];
|
|
411
|
+
for (let i = 0; i < wps.length; i++) {
|
|
412
|
+
const wp = wps[i];
|
|
413
|
+
if (!wp)
|
|
414
|
+
continue;
|
|
415
|
+
if (i === 0) {
|
|
416
|
+
parts.push(`M${wp.x},${wp.y}`);
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (i === wps.length - 1) {
|
|
420
|
+
parts.push(`L${wp.x},${wp.y}`);
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
const prev = wps[i - 1];
|
|
424
|
+
const next = wps[i + 1];
|
|
425
|
+
if (!prev || !next)
|
|
426
|
+
continue;
|
|
427
|
+
const dx1 = wp.x - prev.x;
|
|
428
|
+
const dy1 = wp.y - prev.y;
|
|
429
|
+
const d1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
|
430
|
+
const dx2 = next.x - wp.x;
|
|
431
|
+
const dy2 = next.y - wp.y;
|
|
432
|
+
const d2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
433
|
+
if (d1 < 0.01 || d2 < 0.01) {
|
|
434
|
+
parts.push(`L${wp.x},${wp.y}`);
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
const radius = Math.min(r, d1 / 2, d2 / 2);
|
|
438
|
+
const ax = wp.x - (dx1 / d1) * radius;
|
|
439
|
+
const ay = wp.y - (dy1 / d1) * radius;
|
|
440
|
+
const bx = wp.x + (dx2 / d2) * radius;
|
|
441
|
+
const by = wp.y + (dy2 / d2) * radius;
|
|
442
|
+
parts.push(`L${ax},${ay}`);
|
|
443
|
+
parts.push(`Q${wp.x},${wp.y} ${bx},${by}`);
|
|
444
|
+
}
|
|
445
|
+
return parts.join(" ");
|
|
446
|
+
}
|
|
447
|
+
// ── Task icons (14×14, origin at 0,0) ────────────────────────────────────────
|
|
448
|
+
function taskIcon(type) {
|
|
449
|
+
switch (type) {
|
|
450
|
+
case "manualTask":
|
|
451
|
+
return `<path d="M3 8V4.5a1 1 0 012 0V8M5 7V3a1 1 0 012 0v4M7 6a1 1 0 012 0v1.5M9 7.5a1 1 0 012 0V9c0 2.5-1.5 4-4.5 4H5c-2.5 0-4-1.5-4-4V8" class="bi"/>`;
|
|
452
|
+
case "serviceTask":
|
|
453
|
+
return `<circle cx="7" cy="7" r="5.5" class="bi"/><circle cx="7" cy="7" r="2" class="bi"/><path d="M7 1v2.5M7 10.5v2.5M1 7h2.5M10.5 7h2.5M2.8 2.8l1.7 1.7M9.5 9.5l1.7 1.7M11.2 2.8l-1.7 1.7M4.5 9.5l-1.7 1.7" class="bi"/>`;
|
|
454
|
+
case "userTask":
|
|
455
|
+
return `<circle cx="7" cy="4.5" r="2.5" class="bi"/><path d="M1.5 14Q1.5 9 7 9Q12.5 9 12.5 14" class="bi"/>`;
|
|
456
|
+
case "scriptTask":
|
|
457
|
+
return `<rect x="2" y="0.5" width="10" height="13" rx="1" class="bi"/><path d="M4 4h6M4 7h6M4 10h4" class="bi"/>`;
|
|
458
|
+
case "sendTask":
|
|
459
|
+
return `<path d="M1.5 3.5h11v8h-11z" class="bis"/><path d="M1.5 3.5l5.5 4.5 5.5-4.5M1.5 11.5l4-3.5M12.5 11.5l-4-3.5" fill="none" stroke="var(--_sf)" stroke-width="1.5"/>`;
|
|
460
|
+
case "receiveTask":
|
|
461
|
+
return `<rect x="1.5" y="3.5" width="11" height="8" class="bi"/><path d="M1.5 3.5l5.5 4.5 5.5-4.5" class="bi"/>`;
|
|
462
|
+
case "businessRuleTask":
|
|
463
|
+
return `<rect x="1" y="1" width="12" height="12" class="bi"/><path d="M1 4.5h12M4 1v12" class="bi"/>`;
|
|
464
|
+
default:
|
|
465
|
+
return "";
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
// ── Event markers (centred at 0,0) ────────────────────────────────────────────
|
|
469
|
+
function eventMarker(defType, filled) {
|
|
470
|
+
const c = filled ? "bis" : "bi";
|
|
471
|
+
switch (defType) {
|
|
472
|
+
case "timer":
|
|
473
|
+
return `<circle cx="0" cy="0" r="5" class="${c}"/><path d="M0 -3.5v3.5l2 2" class="bi"/>`;
|
|
474
|
+
case "message":
|
|
475
|
+
return `<rect x="-5" y="-3.5" width="10" height="7" class="${c}"/><path d="M-5 -3.5l5 4 5-4" class="${c}" ${filled ? 'fill="none" stroke="var(--_sf)"' : ""}/>`;
|
|
476
|
+
case "signal":
|
|
477
|
+
return `<path d="M0 -5.5l5.5 10h-11z" class="${c}"/>`;
|
|
478
|
+
case "error":
|
|
479
|
+
return `<path d="M-2 -5l2.5 4.5-3.5 0.5L2 5l-2.5-4.5 3.5-0.5z" class="${c}"/>`;
|
|
480
|
+
case "escalation":
|
|
481
|
+
return `<path d="M0 -5.5l3.5 9.5-3.5-3.5-3.5 3.5z" class="${c}"/>`;
|
|
482
|
+
case "compensate":
|
|
483
|
+
return `<path d="M1 -3.5l-5 3.5 5 3.5zM6 -3.5l-5 3.5 5 3.5z" class="${c}"/>`;
|
|
484
|
+
case "conditional":
|
|
485
|
+
return `<rect x="-4.5" y="-5.5" width="9" height="11" rx="1" class="${c}"/><path d="M-2.5 -2.5h5M-2.5 0h5M-2.5 2.5h3" class="bi"/>`;
|
|
486
|
+
case "link":
|
|
487
|
+
return `<path d="M-2 -3.5v7l5.5-3.5z" class="${c}"/><path d="M-6 0h4" class="bi"/>`;
|
|
488
|
+
case "cancel":
|
|
489
|
+
return `<path d="M-4 -4l8 8M4 -4l-8 8" class="${c}"/>`;
|
|
490
|
+
case "terminate":
|
|
491
|
+
return `<circle cx="0" cy="0" r="5" class="bis"/>`;
|
|
492
|
+
default:
|
|
493
|
+
return "";
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
// ── Gateway markers ────────────────────────────────────────────────────────────
|
|
497
|
+
function gatewayMarker(type) {
|
|
498
|
+
switch (type) {
|
|
499
|
+
case "exclusiveGateway":
|
|
500
|
+
return `<path d="M-6 -6l12 12M6 -6l-12 12" class="gms"/>`;
|
|
501
|
+
case "parallelGateway":
|
|
502
|
+
return `<path d="M0 -8v16M-8 0h16" class="gms"/>`;
|
|
503
|
+
case "inclusiveGateway":
|
|
504
|
+
return `<circle cx="0" cy="0" r="6" class="gms"/>`;
|
|
505
|
+
case "eventBasedGateway":
|
|
506
|
+
return `<circle cx="0" cy="0" r="7" class="gms"/><circle cx="0" cy="0" r="5" class="gms"/><path d="M0 -4L3.8 1.8H-3.8Z" class="gm"/>`;
|
|
507
|
+
case "complexGateway":
|
|
508
|
+
return `<path d="M0 -8v16M-8 0h16M-5.7 -5.7l11.4 11.4M5.7 -5.7l-11.4 11.4" class="gms"/>`;
|
|
509
|
+
default:
|
|
510
|
+
return "";
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
// ── Activity marker row ───────────────────────────────────────────────────────
|
|
514
|
+
const MARKER_STEP = 16;
|
|
515
|
+
/**
|
|
516
|
+
* Bottom-centre marker row: multi-instance, compensation, ad-hoc tilde and the
|
|
517
|
+
* collapsed `+` box (call activities always, sub-process variants when collapsed).
|
|
518
|
+
*/
|
|
519
|
+
function activityMarkers(el, expanded) {
|
|
520
|
+
const glyphs = [];
|
|
521
|
+
const lc = "loopCharacteristics" in el ? el.loopCharacteristics : undefined;
|
|
522
|
+
if (lc) {
|
|
523
|
+
glyphs.push(lc.isSequential
|
|
524
|
+
? `<path d="M-5 -4h10M-5 0h10M-5 4h10" class="bi"/>`
|
|
525
|
+
: `<path d="M-4 -5v10M0 -5v10M4 -5v10" class="bi"/>`);
|
|
526
|
+
}
|
|
527
|
+
if ("isForCompensation" in el && el.isForCompensation) {
|
|
528
|
+
glyphs.push(`<path d="M1 -3.5l-5 3.5 5 3.5zM6 -3.5l-5 3.5 5 3.5z" class="bi"/>`);
|
|
529
|
+
}
|
|
530
|
+
if (el.type === "adHocSubProcess")
|
|
531
|
+
glyphs.push(`<path d="M-7 0Q-4 -4 0 0Q4 4 7 0" class="bi"/>`);
|
|
532
|
+
const subProcess = el.type === "subProcess" ||
|
|
533
|
+
el.type === "adHocSubProcess" ||
|
|
534
|
+
el.type === "eventSubProcess" ||
|
|
535
|
+
el.type === "transaction";
|
|
536
|
+
if (el.type === "callActivity" || (subProcess && !expanded)) {
|
|
537
|
+
glyphs.push(`<rect x="-7" y="-7" width="14" height="14" rx="1" class="bi"/><path d="M0 -4v8M-4 0h8" class="bi"/>`);
|
|
538
|
+
}
|
|
539
|
+
const start = -((glyphs.length - 1) * MARKER_STEP) / 2;
|
|
540
|
+
return glyphs
|
|
541
|
+
.map((g, i) => `<g transform="translate(${start + i * MARKER_STEP} 0)">${g}</g>`)
|
|
542
|
+
.join("");
|
|
543
|
+
}
|
|
544
|
+
// ── Shape renderers ────────────────────────────────────────────────────────────
|
|
545
|
+
/** @internal */
|
|
546
|
+
export function shapeStyle(t, sw = 1.5, dash) {
|
|
547
|
+
return `fill:${t.shapeFill};stroke:${t.shapeStroke};stroke-width:${sw}${dash ? `;stroke-dasharray:${dash}` : ""}`;
|
|
548
|
+
}
|
|
549
|
+
/** @internal */
|
|
550
|
+
export function iconStyle(t) {
|
|
551
|
+
return `fill:none;stroke:${t.shapeStroke};stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round`;
|
|
552
|
+
}
|
|
553
|
+
function iconSolidStyle(t) {
|
|
554
|
+
return `fill:${t.shapeStroke};stroke:none`;
|
|
555
|
+
}
|
|
556
|
+
function gwMarkerStyle(t) {
|
|
557
|
+
return `fill:none;stroke:${t.shapeStroke};stroke-width:2.5;stroke-linecap:round`;
|
|
558
|
+
}
|
|
559
|
+
function gwMarkerFillStyle(t) {
|
|
560
|
+
return `fill:${t.shapeStroke};stroke:none`;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Wraps raw icon SVG (which uses class="bi", "bis", "gm", "gms")
|
|
564
|
+
* in a `<g>` that provides those class definitions as inline style overrides.
|
|
565
|
+
* CSS classes cannot be used in standalone SVGs, so we map them to inline styles
|
|
566
|
+
* via a local `<style>` element scoped to the enclosing `<g>`.
|
|
567
|
+
*/
|
|
568
|
+
/** @internal */
|
|
569
|
+
export function iconGroup(content, x, y, t) {
|
|
570
|
+
const bi = iconStyle(t);
|
|
571
|
+
const bis = iconSolidStyle(t);
|
|
572
|
+
const gm = gwMarkerFillStyle(t);
|
|
573
|
+
const gms = gwMarkerStyle(t);
|
|
574
|
+
// Inline style for sendTask envelope fill colour (matches shape fill)
|
|
575
|
+
const sf = t.shapeFill;
|
|
576
|
+
return `<g transform="translate(${x} ${y})"><style>.bi{${bi}}.bis{${bis}}.gm{${gm}}.gms{${gms}}</style>${content.replace(/var\(--_sf\)/g, sf)}</g>`;
|
|
577
|
+
}
|
|
578
|
+
function renderEvent(el, width, height, t) {
|
|
579
|
+
const cx = width / 2;
|
|
580
|
+
const cy = height / 2;
|
|
581
|
+
const r = Math.min(cx, cy) - 1;
|
|
582
|
+
const isEnd = el?.type === "endEvent";
|
|
583
|
+
const isIntermediate = el?.type === "intermediateCatchEvent" ||
|
|
584
|
+
el?.type === "intermediateThrowEvent" ||
|
|
585
|
+
el?.type === "boundaryEvent";
|
|
586
|
+
const isThrow = el?.type === "intermediateThrowEvent" ||
|
|
587
|
+
(el?.type === "boundaryEvent" && el.cancelActivity === false);
|
|
588
|
+
const outerSw = isEnd ? 3 : 1.5;
|
|
589
|
+
const outerStyle = `fill:${t.shapeFill};stroke:${t.shapeStroke};stroke-width:${outerSw}`;
|
|
590
|
+
let out = `<circle cx="${cx}" cy="${cy}" r="${r}" style="${outerStyle}"/>`;
|
|
591
|
+
if (isIntermediate) {
|
|
592
|
+
const isNonInt = el?.type === "boundaryEvent" && el.cancelActivity === false;
|
|
593
|
+
const innerStyle = `fill:none;stroke:${t.shapeStroke};stroke-width:1.5${isNonInt ? ";stroke-dasharray:4 2" : ""}`;
|
|
594
|
+
out += `<circle cx="${cx}" cy="${cy}" r="${r - 3}" style="${innerStyle}"/>`;
|
|
595
|
+
}
|
|
596
|
+
const eventDef = el && "eventDefinitions" in el && el.eventDefinitions.length > 0
|
|
597
|
+
? el.eventDefinitions[0]
|
|
598
|
+
: undefined;
|
|
599
|
+
if (eventDef) {
|
|
600
|
+
const marker = eventMarker(eventDef.type, isThrow && !isEnd);
|
|
601
|
+
if (marker) {
|
|
602
|
+
out += iconGroup(marker, cx, cy, t);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return out;
|
|
606
|
+
}
|
|
607
|
+
function renderTask(el, width, height, t, options) {
|
|
608
|
+
const type = el?.type ?? "";
|
|
609
|
+
let sw = 1.5;
|
|
610
|
+
let dash;
|
|
611
|
+
if (type === "callActivity")
|
|
612
|
+
sw = 3;
|
|
613
|
+
else if (type === "eventSubProcess")
|
|
614
|
+
dash = "5 3";
|
|
615
|
+
const bodyStyle = shapeStyle(t, sw, dash);
|
|
616
|
+
let out = `<rect x="0" y="0" width="${width}" height="${height}" rx="10" style="${bodyStyle}"/>`;
|
|
617
|
+
if (type === "transaction") {
|
|
618
|
+
const innerStyle = iconStyle(t);
|
|
619
|
+
out += `<rect x="3" y="3" width="${width - 6}" height="${height - 6}" rx="8" style="${innerStyle}"/>`;
|
|
620
|
+
}
|
|
621
|
+
const icon = taskIcon(type);
|
|
622
|
+
if (icon) {
|
|
623
|
+
out += iconGroup(icon, 4, 4, t);
|
|
624
|
+
}
|
|
625
|
+
if (el?.name) {
|
|
626
|
+
// An expanded container's name sits in a top label, like a modeler's pool/
|
|
627
|
+
// subprocess header, so it doesn't collide with the child shapes drawn
|
|
628
|
+
// inside it (a centered label would land right where children are placed).
|
|
629
|
+
if (options?.expanded) {
|
|
630
|
+
out += labelSvg(el.name, width / 2, 14, width - 16, t, true, options.font);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
out += labelSvg(el.name, width / 2, height / 2, width - 16, t, false, options?.font);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
// The "+" marker means "contents elsewhere"; an expanded body shows them.
|
|
637
|
+
const markers = el ? activityMarkers(el, options?.expanded === true) : "";
|
|
638
|
+
if (markers)
|
|
639
|
+
out += iconGroup(markers, width / 2, height - 10, t);
|
|
640
|
+
return out;
|
|
641
|
+
}
|
|
642
|
+
function renderGateway(el, width, height, t) {
|
|
643
|
+
const cx = width / 2;
|
|
644
|
+
const cy = height / 2;
|
|
645
|
+
const bodyStyle = shapeStyle(t);
|
|
646
|
+
const points = `${cx},0 ${width},${cy} ${cx},${height} 0,${cy}`;
|
|
647
|
+
let out = `<polygon points="${points}" style="${bodyStyle}"/>`;
|
|
648
|
+
const marker = el ? gatewayMarker(el.type) : "";
|
|
649
|
+
if (marker) {
|
|
650
|
+
out += iconGroup(marker, cx, cy, t);
|
|
651
|
+
}
|
|
652
|
+
return out;
|
|
653
|
+
}
|
|
654
|
+
function renderDataObject(el, width, height, t) {
|
|
655
|
+
const fold = Math.min(14, width / 3);
|
|
656
|
+
let out = `<path d="M0 0 H${width - fold} L${width} ${fold} V${height} H0 Z" style="${shapeStyle(t)}"/>` +
|
|
657
|
+
`<path d="M${width - fold} 0 V${fold} H${width}" style="${iconStyle(t)}"/>`;
|
|
658
|
+
if (el?.type === "dataObjectReference" && el.isCollection) {
|
|
659
|
+
out += iconGroup(`<path d="M-3 -5v9M0 -5v9M3 -5v9" class="bi"/>`, width / 2, height - 6, t);
|
|
660
|
+
}
|
|
661
|
+
return out;
|
|
662
|
+
}
|
|
663
|
+
function renderDataStore(width, height, t) {
|
|
664
|
+
const ry = Math.min(8, height / 6);
|
|
665
|
+
const rx = width / 2;
|
|
666
|
+
return (`<path d="M0 ${ry} A ${rx} ${ry} 0 0 0 ${width} ${ry} V ${height - ry} A ${rx} ${ry} 0 0 1 0 ${height - ry} Z" style="${shapeStyle(t)}"/>` +
|
|
667
|
+
`<ellipse cx="${rx}" cy="${ry}" rx="${rx}" ry="${ry}" style="${shapeStyle(t)}"/>` +
|
|
668
|
+
`<path d="M0 ${ry * 2} A ${rx} ${ry} 0 0 0 ${width} ${ry * 2} M0 ${ry * 3.4} A ${rx} ${ry} 0 0 0 ${width} ${ry * 3.4}" style="${iconStyle(t)}"/>`);
|
|
669
|
+
}
|
|
670
|
+
function renderGroup(name, width, height, t, font) {
|
|
671
|
+
const style = `fill:none;stroke:${t.shapeStroke};stroke-width:1.5;stroke-dasharray:6 3`;
|
|
672
|
+
let out = `<rect x="0" y="0" width="${width}" height="${height}" rx="8" style="${style}"/>`;
|
|
673
|
+
if (name)
|
|
674
|
+
out += labelSvg(name, width / 2, 14, width - 16, t, true, font);
|
|
675
|
+
return out;
|
|
676
|
+
}
|
|
677
|
+
function renderPool(participant, width, height, t, font) {
|
|
678
|
+
const bodyStyle = `fill:${t.shapeFill};stroke:${t.shapeStroke};stroke-width:1.5`;
|
|
679
|
+
const headerStyle = `fill:${t.poolHeader};stroke:${t.shapeStroke};stroke-width:1.5`;
|
|
680
|
+
let out = `<rect x="0" y="0" width="${width}" height="${height}" style="${bodyStyle}"/>` +
|
|
681
|
+
`<rect x="0" y="0" width="30" height="${height}" style="${headerStyle}"/>`;
|
|
682
|
+
if (participant?.name) {
|
|
683
|
+
out += `<text style="${textStyle(t, font)}" transform="translate(15 ${height / 2}) rotate(-90)">${esc(participant.name)}</text>`;
|
|
684
|
+
}
|
|
685
|
+
return out;
|
|
686
|
+
}
|
|
687
|
+
function renderLane(lane, width, height, t, font) {
|
|
688
|
+
const bodyStyle = `fill:${t.shapeFill};stroke:${t.shapeStroke};stroke-width:1.5`;
|
|
689
|
+
const headerStyle = `fill:${t.poolHeader};stroke:${t.shapeStroke};stroke-width:1.5`;
|
|
690
|
+
let out = `<rect x="0" y="0" width="${width}" height="${height}" style="${bodyStyle}"/>` +
|
|
691
|
+
`<rect x="0" y="0" width="30" height="${height}" style="${headerStyle}"/>`;
|
|
692
|
+
if (lane?.name) {
|
|
693
|
+
out += `<text style="${textStyle(t, font)}" transform="translate(15 ${height / 2}) rotate(-90)">${esc(lane.name)}</text>`;
|
|
694
|
+
}
|
|
695
|
+
return out;
|
|
696
|
+
}
|
|
697
|
+
function renderAnnotation(text, width, height, t, font) {
|
|
698
|
+
const pathStyle = `fill:none;stroke:${t.shapeStroke};stroke-width:1.5`;
|
|
699
|
+
let out = `<path d="M${width} 0 L0 0 L0 ${height} L${width} ${height}" style="${pathStyle}"/>`;
|
|
700
|
+
if (text) {
|
|
701
|
+
out += labelSvg(text, width / 2, height / 2, width - 8, t, false, font);
|
|
702
|
+
}
|
|
703
|
+
return out;
|
|
704
|
+
}
|
|
705
|
+
function buildIndex(defs) {
|
|
706
|
+
const elements = new Map();
|
|
707
|
+
const flows = new Map();
|
|
708
|
+
const annotations = new Map();
|
|
709
|
+
const participants = new Map();
|
|
710
|
+
const lanes = new Map();
|
|
711
|
+
const groups = new Map();
|
|
712
|
+
const messageFlowIds = new Set();
|
|
713
|
+
const defaultFlowIds = new Set();
|
|
714
|
+
function indexElements(flowElements, seqFlows) {
|
|
715
|
+
for (const el of flowElements) {
|
|
716
|
+
elements.set(el.id, el);
|
|
717
|
+
if (el.type === "subProcess" ||
|
|
718
|
+
el.type === "adHocSubProcess" ||
|
|
719
|
+
el.type === "eventSubProcess" ||
|
|
720
|
+
el.type === "transaction") {
|
|
721
|
+
indexElements(el.flowElements, el.sequenceFlows);
|
|
722
|
+
}
|
|
723
|
+
if ((el.type === "exclusiveGateway" ||
|
|
724
|
+
el.type === "inclusiveGateway" ||
|
|
725
|
+
el.type === "complexGateway") &&
|
|
726
|
+
el.default) {
|
|
727
|
+
defaultFlowIds.add(el.default);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
for (const sf of seqFlows) {
|
|
731
|
+
flows.set(sf.id, sf);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
function indexLaneSet(laneSet) {
|
|
735
|
+
for (const lane of laneSet.lanes) {
|
|
736
|
+
lanes.set(lane.id, lane);
|
|
737
|
+
if (lane.childLaneSet)
|
|
738
|
+
indexLaneSet(lane.childLaneSet);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
for (const proc of defs.processes) {
|
|
742
|
+
indexElements(proc.flowElements, proc.sequenceFlows);
|
|
743
|
+
for (const ta of proc.textAnnotations) {
|
|
744
|
+
annotations.set(ta.id, ta);
|
|
745
|
+
}
|
|
746
|
+
for (const g of proc.groups ?? [])
|
|
747
|
+
groups.set(g.id, g);
|
|
748
|
+
if (proc.laneSet)
|
|
749
|
+
indexLaneSet(proc.laneSet);
|
|
750
|
+
}
|
|
751
|
+
for (const collab of defs.collaborations) {
|
|
752
|
+
for (const p of collab.participants) {
|
|
753
|
+
participants.set(p.id, p);
|
|
754
|
+
}
|
|
755
|
+
for (const ta of collab.textAnnotations) {
|
|
756
|
+
annotations.set(ta.id, ta);
|
|
757
|
+
}
|
|
758
|
+
for (const g of collab.groups ?? [])
|
|
759
|
+
groups.set(g.id, g);
|
|
760
|
+
for (const mf of collab.messageFlows) {
|
|
761
|
+
messageFlowIds.add(mf.id);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
const categoryValues = new Map();
|
|
765
|
+
for (const cat of defs.categories ?? []) {
|
|
766
|
+
for (const v of cat.categoryValues)
|
|
767
|
+
categoryValues.set(v.id, v.value);
|
|
768
|
+
}
|
|
769
|
+
const groupLabel = (g) => g.categoryValueRef ? categoryValues.get(g.categoryValueRef) : undefined;
|
|
770
|
+
return {
|
|
771
|
+
elements,
|
|
772
|
+
flows,
|
|
773
|
+
annotations,
|
|
774
|
+
participants,
|
|
775
|
+
lanes,
|
|
776
|
+
groups,
|
|
777
|
+
groupLabel,
|
|
778
|
+
messageFlowIds,
|
|
779
|
+
defaultFlowIds,
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
//# sourceMappingURL=svg-render.js.map
|