@aranzatech/diagrams-bpmn 0.1.2 → 0.2.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/CHANGELOG.md +20 -0
- package/README.md +121 -0
- package/dist/{chunk-MLUJKUTG.js → chunk-5GRCJ5X6.js} +3 -3
- package/dist/{chunk-MLUJKUTG.js.map → chunk-5GRCJ5X6.js.map} +1 -1
- package/dist/{chunk-6TUC5QX5.js → chunk-DNR5WBQH.js} +83 -2
- package/dist/chunk-DNR5WBQH.js.map +1 -0
- package/dist/chunk-G5S4ASP3.js +277 -0
- package/dist/chunk-G5S4ASP3.js.map +1 -0
- package/dist/{chunk-4OAEWYYU.js → chunk-MF2WE3OM.js} +146 -37
- package/dist/chunk-MF2WE3OM.js.map +1 -0
- package/dist/chunk-OZKTOILD.js +3 -0
- package/dist/chunk-OZKTOILD.js.map +1 -0
- package/dist/{chunk-NXMUX67A.js → chunk-S3GGEEA5.js} +31 -8
- package/dist/chunk-S3GGEEA5.js.map +1 -0
- package/dist/elements/index.cjs +81 -0
- package/dist/elements/index.cjs.map +1 -1
- package/dist/elements/index.d.cts +2 -2
- package/dist/elements/index.d.ts +2 -2
- package/dist/elements/index.js +3 -2
- package/dist/index.cjs +535 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -62
- package/dist/index.d.ts +7 -62
- package/dist/index.js +6 -40
- package/dist/index.js.map +1 -1
- package/dist/modeling/index.cjs +894 -0
- package/dist/modeling/index.cjs.map +1 -0
- package/dist/modeling/index.d.cts +88 -0
- package/dist/modeling/index.d.ts +88 -0
- package/dist/modeling/index.js +5 -0
- package/dist/modeling/index.js.map +1 -0
- package/dist/nodes/index.cjs +29 -6
- package/dist/nodes/index.cjs.map +1 -1
- package/dist/nodes/index.js +1 -1
- package/dist/{types-CxzazgBX.d.cts → types-BKA0GZz5.d.cts} +9 -19
- package/dist/{types-CxzazgBX.d.ts → types-BKA0GZz5.d.ts} +9 -19
- package/dist/types-CCkHqtC_.d.cts +20 -0
- package/dist/types-hj621ZRJ.d.ts +20 -0
- package/dist/xml/index.cjs +224 -34
- package/dist/xml/index.cjs.map +1 -1
- package/dist/xml/index.d.cts +4 -19
- package/dist/xml/index.d.ts +4 -19
- package/dist/xml/index.js +2 -2
- package/package.json +12 -4
- package/dist/chunk-4OAEWYYU.js.map +0 -1
- package/dist/chunk-6TUC5QX5.js.map +0 -1
- package/dist/chunk-NXMUX67A.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -4,12 +4,15 @@ var react = require('@xyflow/react');
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var routing = require('@aranzatech/diagrams-core/routing');
|
|
6
6
|
var bpmnModdle = require('bpmn-moddle');
|
|
7
|
+
var diagramsCore = require('@aranzatech/diagrams-core');
|
|
8
|
+
var serialization = require('@aranzatech/diagrams-core/serialization');
|
|
7
9
|
|
|
8
10
|
// src/elements/catalog.ts
|
|
9
11
|
var BPMN_ELEMENT_CATALOG = {
|
|
10
12
|
// ─── Events ──────────────────────────────────────────────────────────────────
|
|
11
13
|
StartEvent: {
|
|
12
14
|
label: "Start Event",
|
|
15
|
+
icon: "Circle",
|
|
13
16
|
category: "event",
|
|
14
17
|
defaultWidth: 36,
|
|
15
18
|
defaultHeight: 36,
|
|
@@ -25,6 +28,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
25
28
|
},
|
|
26
29
|
EndEvent: {
|
|
27
30
|
label: "End Event",
|
|
31
|
+
icon: "CircleDot",
|
|
28
32
|
category: "event",
|
|
29
33
|
defaultWidth: 36,
|
|
30
34
|
defaultHeight: 36,
|
|
@@ -39,6 +43,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
39
43
|
},
|
|
40
44
|
IntermediateCatchEvent: {
|
|
41
45
|
label: "Intermediate Catch Event",
|
|
46
|
+
icon: "Clock",
|
|
42
47
|
category: "event",
|
|
43
48
|
defaultWidth: 36,
|
|
44
49
|
defaultHeight: 36,
|
|
@@ -52,6 +57,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
52
57
|
},
|
|
53
58
|
IntermediateThrowEvent: {
|
|
54
59
|
label: "Intermediate Throw Event",
|
|
60
|
+
icon: "Zap",
|
|
55
61
|
category: "event",
|
|
56
62
|
defaultWidth: 36,
|
|
57
63
|
defaultHeight: 36,
|
|
@@ -65,6 +71,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
65
71
|
},
|
|
66
72
|
BoundaryEvent: {
|
|
67
73
|
label: "Boundary Event",
|
|
74
|
+
icon: "AlertCircle",
|
|
68
75
|
category: "event",
|
|
69
76
|
defaultWidth: 36,
|
|
70
77
|
defaultHeight: 36,
|
|
@@ -80,6 +87,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
80
87
|
// ─── Tasks ───────────────────────────────────────────────────────────────────
|
|
81
88
|
Task: {
|
|
82
89
|
label: "Task",
|
|
90
|
+
icon: "Square",
|
|
83
91
|
category: "task",
|
|
84
92
|
defaultWidth: 120,
|
|
85
93
|
defaultHeight: 60,
|
|
@@ -93,6 +101,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
93
101
|
},
|
|
94
102
|
UserTask: {
|
|
95
103
|
label: "User Task",
|
|
104
|
+
icon: "User",
|
|
96
105
|
category: "task",
|
|
97
106
|
defaultWidth: 120,
|
|
98
107
|
defaultHeight: 60,
|
|
@@ -106,6 +115,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
106
115
|
},
|
|
107
116
|
ServiceTask: {
|
|
108
117
|
label: "Service Task",
|
|
118
|
+
icon: "Settings",
|
|
109
119
|
category: "task",
|
|
110
120
|
defaultWidth: 120,
|
|
111
121
|
defaultHeight: 60,
|
|
@@ -119,6 +129,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
119
129
|
},
|
|
120
130
|
ScriptTask: {
|
|
121
131
|
label: "Script Task",
|
|
132
|
+
icon: "FileCode",
|
|
122
133
|
category: "task",
|
|
123
134
|
defaultWidth: 120,
|
|
124
135
|
defaultHeight: 60,
|
|
@@ -132,6 +143,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
132
143
|
},
|
|
133
144
|
ManualTask: {
|
|
134
145
|
label: "Manual Task",
|
|
146
|
+
icon: "Hand",
|
|
135
147
|
category: "task",
|
|
136
148
|
defaultWidth: 120,
|
|
137
149
|
defaultHeight: 60,
|
|
@@ -145,6 +157,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
145
157
|
},
|
|
146
158
|
BusinessRuleTask: {
|
|
147
159
|
label: "Business Rule Task",
|
|
160
|
+
icon: "Scale",
|
|
148
161
|
category: "task",
|
|
149
162
|
defaultWidth: 120,
|
|
150
163
|
defaultHeight: 60,
|
|
@@ -158,6 +171,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
158
171
|
},
|
|
159
172
|
ReceiveTask: {
|
|
160
173
|
label: "Receive Task",
|
|
174
|
+
icon: "Mail",
|
|
161
175
|
category: "task",
|
|
162
176
|
defaultWidth: 120,
|
|
163
177
|
defaultHeight: 60,
|
|
@@ -171,6 +185,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
171
185
|
},
|
|
172
186
|
SendTask: {
|
|
173
187
|
label: "Send Task",
|
|
188
|
+
icon: "Send",
|
|
174
189
|
category: "task",
|
|
175
190
|
defaultWidth: 120,
|
|
176
191
|
defaultHeight: 60,
|
|
@@ -184,6 +199,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
184
199
|
},
|
|
185
200
|
CallActivity: {
|
|
186
201
|
label: "Call Activity",
|
|
202
|
+
icon: "ExternalLink",
|
|
187
203
|
category: "task",
|
|
188
204
|
defaultWidth: 120,
|
|
189
205
|
defaultHeight: 60,
|
|
@@ -198,6 +214,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
198
214
|
// ─── Gateways ────────────────────────────────────────────────────────────────
|
|
199
215
|
ExclusiveGateway: {
|
|
200
216
|
label: "Exclusive Gateway",
|
|
217
|
+
icon: "GitBranch",
|
|
201
218
|
category: "gateway",
|
|
202
219
|
defaultWidth: 50,
|
|
203
220
|
defaultHeight: 50,
|
|
@@ -210,6 +227,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
210
227
|
},
|
|
211
228
|
InclusiveGateway: {
|
|
212
229
|
label: "Inclusive Gateway",
|
|
230
|
+
icon: "GitMerge",
|
|
213
231
|
category: "gateway",
|
|
214
232
|
defaultWidth: 50,
|
|
215
233
|
defaultHeight: 50,
|
|
@@ -222,6 +240,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
222
240
|
},
|
|
223
241
|
ParallelGateway: {
|
|
224
242
|
label: "Parallel Gateway",
|
|
243
|
+
icon: "GitFork",
|
|
225
244
|
category: "gateway",
|
|
226
245
|
defaultWidth: 50,
|
|
227
246
|
defaultHeight: 50,
|
|
@@ -234,6 +253,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
234
253
|
},
|
|
235
254
|
EventBasedGateway: {
|
|
236
255
|
label: "Event-Based Gateway",
|
|
256
|
+
icon: "Radio",
|
|
237
257
|
category: "gateway",
|
|
238
258
|
defaultWidth: 50,
|
|
239
259
|
defaultHeight: 50,
|
|
@@ -247,6 +267,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
247
267
|
},
|
|
248
268
|
ComplexGateway: {
|
|
249
269
|
label: "Complex Gateway",
|
|
270
|
+
icon: "Asterisk",
|
|
250
271
|
category: "gateway",
|
|
251
272
|
defaultWidth: 50,
|
|
252
273
|
defaultHeight: 50,
|
|
@@ -260,6 +281,52 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
260
281
|
// ─── Containers ───────────────────────────────────────────────────────────────
|
|
261
282
|
SubProcess: {
|
|
262
283
|
label: "Sub-Process",
|
|
284
|
+
icon: "Layout",
|
|
285
|
+
category: "container",
|
|
286
|
+
defaultWidth: 350,
|
|
287
|
+
defaultHeight: 200,
|
|
288
|
+
handlePolicy: "all",
|
|
289
|
+
orientation: "horizontal",
|
|
290
|
+
isContainer: true,
|
|
291
|
+
acceptsBoundaryEvents: true,
|
|
292
|
+
supportsCollapse: true,
|
|
293
|
+
supportsMarkers: true,
|
|
294
|
+
canBeStart: false,
|
|
295
|
+
canBeEnd: false
|
|
296
|
+
},
|
|
297
|
+
Transaction: {
|
|
298
|
+
label: "Transaction",
|
|
299
|
+
icon: "CreditCard",
|
|
300
|
+
category: "container",
|
|
301
|
+
defaultWidth: 350,
|
|
302
|
+
defaultHeight: 200,
|
|
303
|
+
handlePolicy: "all",
|
|
304
|
+
orientation: "horizontal",
|
|
305
|
+
isContainer: true,
|
|
306
|
+
acceptsBoundaryEvents: true,
|
|
307
|
+
supportsCollapse: true,
|
|
308
|
+
supportsMarkers: true,
|
|
309
|
+
canBeStart: false,
|
|
310
|
+
canBeEnd: false
|
|
311
|
+
},
|
|
312
|
+
EventSubProcess: {
|
|
313
|
+
label: "Event Sub-Process",
|
|
314
|
+
icon: "Workflow",
|
|
315
|
+
category: "container",
|
|
316
|
+
defaultWidth: 350,
|
|
317
|
+
defaultHeight: 200,
|
|
318
|
+
handlePolicy: "all",
|
|
319
|
+
orientation: "horizontal",
|
|
320
|
+
isContainer: true,
|
|
321
|
+
acceptsBoundaryEvents: false,
|
|
322
|
+
supportsCollapse: true,
|
|
323
|
+
supportsMarkers: true,
|
|
324
|
+
canBeStart: false,
|
|
325
|
+
canBeEnd: false
|
|
326
|
+
},
|
|
327
|
+
AdHocSubProcess: {
|
|
328
|
+
label: "Ad-Hoc Sub-Process",
|
|
329
|
+
icon: "Shuffle",
|
|
263
330
|
category: "container",
|
|
264
331
|
defaultWidth: 350,
|
|
265
332
|
defaultHeight: 200,
|
|
@@ -274,6 +341,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
274
341
|
},
|
|
275
342
|
Pool: {
|
|
276
343
|
label: "Pool",
|
|
344
|
+
icon: "Columns",
|
|
277
345
|
category: "container",
|
|
278
346
|
defaultWidth: 600,
|
|
279
347
|
defaultHeight: 200,
|
|
@@ -288,6 +356,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
288
356
|
},
|
|
289
357
|
Lane: {
|
|
290
358
|
label: "Lane",
|
|
359
|
+
icon: "AlignJustify",
|
|
291
360
|
category: "container",
|
|
292
361
|
defaultWidth: 600,
|
|
293
362
|
defaultHeight: 120,
|
|
@@ -303,6 +372,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
303
372
|
// ─── Artifacts ────────────────────────────────────────────────────────────────
|
|
304
373
|
Annotation: {
|
|
305
374
|
label: "Text Annotation",
|
|
375
|
+
icon: "StickyNote",
|
|
306
376
|
category: "artifact",
|
|
307
377
|
defaultWidth: 100,
|
|
308
378
|
defaultHeight: 60,
|
|
@@ -317,6 +387,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
317
387
|
},
|
|
318
388
|
Group: {
|
|
319
389
|
label: "Group",
|
|
390
|
+
icon: "Group",
|
|
320
391
|
category: "artifact",
|
|
321
392
|
defaultWidth: 300,
|
|
322
393
|
defaultHeight: 200,
|
|
@@ -332,6 +403,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
332
403
|
// ─── Data (BPMN 2.0 §10.3) ───────────────────────────────────────────────────
|
|
333
404
|
DataObject: {
|
|
334
405
|
label: "Data Object",
|
|
406
|
+
icon: "File",
|
|
335
407
|
category: "data",
|
|
336
408
|
defaultWidth: 36,
|
|
337
409
|
defaultHeight: 50,
|
|
@@ -346,6 +418,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
346
418
|
},
|
|
347
419
|
DataObjectReference: {
|
|
348
420
|
label: "Data Object Reference",
|
|
421
|
+
icon: "FileSymlink",
|
|
349
422
|
category: "data",
|
|
350
423
|
defaultWidth: 36,
|
|
351
424
|
defaultHeight: 50,
|
|
@@ -360,6 +433,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
360
433
|
},
|
|
361
434
|
DataInput: {
|
|
362
435
|
label: "Data Input",
|
|
436
|
+
icon: "FileInput",
|
|
363
437
|
category: "data",
|
|
364
438
|
defaultWidth: 36,
|
|
365
439
|
defaultHeight: 50,
|
|
@@ -373,6 +447,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
373
447
|
},
|
|
374
448
|
DataOutput: {
|
|
375
449
|
label: "Data Output",
|
|
450
|
+
icon: "FileOutput",
|
|
376
451
|
category: "data",
|
|
377
452
|
defaultWidth: 36,
|
|
378
453
|
defaultHeight: 50,
|
|
@@ -386,6 +461,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
386
461
|
},
|
|
387
462
|
DataStore: {
|
|
388
463
|
label: "Data Store",
|
|
464
|
+
icon: "Database",
|
|
389
465
|
category: "data",
|
|
390
466
|
defaultWidth: 50,
|
|
391
467
|
defaultHeight: 50,
|
|
@@ -400,6 +476,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
400
476
|
},
|
|
401
477
|
DataStoreReference: {
|
|
402
478
|
label: "Data Store Reference",
|
|
479
|
+
icon: "DatabaseZap",
|
|
403
480
|
category: "data",
|
|
404
481
|
defaultWidth: 50,
|
|
405
482
|
defaultHeight: 50,
|
|
@@ -415,6 +492,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
415
492
|
// ─── Conversation (BPMN 2.0 §12) ─────────────────────────────────────────────
|
|
416
493
|
Conversation: {
|
|
417
494
|
label: "Conversation",
|
|
495
|
+
icon: "MessageCircle",
|
|
418
496
|
category: "conversation",
|
|
419
497
|
defaultWidth: 60,
|
|
420
498
|
defaultHeight: 52,
|
|
@@ -427,6 +505,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
427
505
|
},
|
|
428
506
|
SubConversation: {
|
|
429
507
|
label: "Sub-Conversation",
|
|
508
|
+
icon: "MessagesSquare",
|
|
430
509
|
category: "conversation",
|
|
431
510
|
defaultWidth: 60,
|
|
432
511
|
defaultHeight: 52,
|
|
@@ -440,6 +519,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
440
519
|
},
|
|
441
520
|
CallConversation: {
|
|
442
521
|
label: "Call Conversation",
|
|
522
|
+
icon: "PhoneCall",
|
|
443
523
|
category: "conversation",
|
|
444
524
|
defaultWidth: 60,
|
|
445
525
|
defaultHeight: 52,
|
|
@@ -453,6 +533,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
453
533
|
// ─── Choreography (BPMN 2.0 §11) ─────────────────────────────────────────────
|
|
454
534
|
ChoreographyTask: {
|
|
455
535
|
label: "Choreography Task",
|
|
536
|
+
icon: "ArrowLeftRight",
|
|
456
537
|
category: "choreography",
|
|
457
538
|
defaultWidth: 120,
|
|
458
539
|
defaultHeight: 80,
|
|
@@ -465,6 +546,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
465
546
|
},
|
|
466
547
|
SubChoreography: {
|
|
467
548
|
label: "Sub-Choreography",
|
|
549
|
+
icon: "BoxSelect",
|
|
468
550
|
category: "choreography",
|
|
469
551
|
defaultWidth: 120,
|
|
470
552
|
defaultHeight: 80,
|
|
@@ -478,6 +560,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
478
560
|
},
|
|
479
561
|
CallChoreography: {
|
|
480
562
|
label: "Call Choreography",
|
|
563
|
+
icon: "Phone",
|
|
481
564
|
category: "choreography",
|
|
482
565
|
defaultWidth: 120,
|
|
483
566
|
defaultHeight: 80,
|
|
@@ -1157,11 +1240,24 @@ function GatewayNode({ data, selected }) {
|
|
|
1157
1240
|
/* @__PURE__ */ jsxRuntime.jsx(BpmnLabel, { external: true, children: d.label })
|
|
1158
1241
|
] });
|
|
1159
1242
|
}
|
|
1243
|
+
function resolveVariant(d) {
|
|
1244
|
+
if (d.subProcessVariant) return d.subProcessVariant;
|
|
1245
|
+
switch (d.elementType) {
|
|
1246
|
+
case "Transaction":
|
|
1247
|
+
return "transaction";
|
|
1248
|
+
case "EventSubProcess":
|
|
1249
|
+
return "event";
|
|
1250
|
+
case "AdHocSubProcess":
|
|
1251
|
+
return "adhoc";
|
|
1252
|
+
default:
|
|
1253
|
+
return "embedded";
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1160
1256
|
function SubProcessNode({ data, selected }) {
|
|
1161
1257
|
const d = data;
|
|
1162
1258
|
const stroke = resolveStroke(selected, d.color?.stroke);
|
|
1163
1259
|
const sw = resolveStrokeWidth(selected);
|
|
1164
|
-
const variant = d
|
|
1260
|
+
const variant = resolveVariant(d);
|
|
1165
1261
|
const isExpanded = d.isExpanded ?? true;
|
|
1166
1262
|
const hasMarkers = d.markers && d.markers.length > 0;
|
|
1167
1263
|
const borderStyle = variant === "event" ? "dashed" : "solid";
|
|
@@ -1253,6 +1349,7 @@ function PoolNode({ data, selected }) {
|
|
|
1253
1349
|
"div",
|
|
1254
1350
|
{
|
|
1255
1351
|
"aria-label": "pool-header",
|
|
1352
|
+
className: "pool-drag-handle",
|
|
1256
1353
|
style: {
|
|
1257
1354
|
height: HEADER_HEIGHT,
|
|
1258
1355
|
minHeight: HEADER_HEIGHT,
|
|
@@ -1261,7 +1358,8 @@ function PoolNode({ data, selected }) {
|
|
|
1261
1358
|
alignItems: "center",
|
|
1262
1359
|
justifyContent: "center",
|
|
1263
1360
|
background: headerFill,
|
|
1264
|
-
padding: "0 8px"
|
|
1361
|
+
padding: "0 8px",
|
|
1362
|
+
cursor: "grab"
|
|
1265
1363
|
},
|
|
1266
1364
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1267
1365
|
"span",
|
|
@@ -1310,7 +1408,8 @@ function PoolNode({ data, selected }) {
|
|
|
1310
1408
|
display: "flex",
|
|
1311
1409
|
alignItems: "center",
|
|
1312
1410
|
justifyContent: "center",
|
|
1313
|
-
background: headerFill
|
|
1411
|
+
background: headerFill,
|
|
1412
|
+
cursor: "grab"
|
|
1314
1413
|
},
|
|
1315
1414
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1316
1415
|
"span",
|
|
@@ -1365,6 +1464,7 @@ function LaneNode({ data, selected }) {
|
|
|
1365
1464
|
"div",
|
|
1366
1465
|
{
|
|
1367
1466
|
"aria-label": "lane-header",
|
|
1467
|
+
className: "lane-drag-handle",
|
|
1368
1468
|
style: {
|
|
1369
1469
|
width: HEADER_WIDTH2,
|
|
1370
1470
|
minWidth: HEADER_WIDTH2,
|
|
@@ -1373,7 +1473,8 @@ function LaneNode({ data, selected }) {
|
|
|
1373
1473
|
alignItems: "center",
|
|
1374
1474
|
justifyContent: "center",
|
|
1375
1475
|
background: headerFill,
|
|
1376
|
-
padding: "6px 0"
|
|
1476
|
+
padding: "6px 0",
|
|
1477
|
+
cursor: "grab"
|
|
1377
1478
|
},
|
|
1378
1479
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1379
1480
|
"span",
|
|
@@ -1419,6 +1520,7 @@ function LaneNode({ data, selected }) {
|
|
|
1419
1520
|
"div",
|
|
1420
1521
|
{
|
|
1421
1522
|
"aria-label": "lane-header",
|
|
1523
|
+
className: "lane-drag-handle",
|
|
1422
1524
|
style: {
|
|
1423
1525
|
height: HEADER_HEIGHT2,
|
|
1424
1526
|
minHeight: HEADER_HEIGHT2,
|
|
@@ -1429,7 +1531,8 @@ function LaneNode({ data, selected }) {
|
|
|
1429
1531
|
background: headerFill,
|
|
1430
1532
|
fontSize: BPMN_THEME.fontSize,
|
|
1431
1533
|
fontWeight: 500,
|
|
1432
|
-
color: BPMN_THEME.labelColor
|
|
1534
|
+
color: BPMN_THEME.labelColor,
|
|
1535
|
+
cursor: "grab"
|
|
1433
1536
|
},
|
|
1434
1537
|
children: d.label
|
|
1435
1538
|
}
|
|
@@ -2003,8 +2106,11 @@ var BPMN_NODE_TYPES = {
|
|
|
2003
2106
|
ParallelGateway: GatewayNode,
|
|
2004
2107
|
EventBasedGateway: GatewayNode,
|
|
2005
2108
|
ComplexGateway: GatewayNode,
|
|
2006
|
-
// Containers
|
|
2109
|
+
// Containers — Transaction, EventSubProcess, AdHocSubProcess derive their visual variant from elementType
|
|
2007
2110
|
SubProcess: SubProcessNode,
|
|
2111
|
+
Transaction: SubProcessNode,
|
|
2112
|
+
EventSubProcess: SubProcessNode,
|
|
2113
|
+
AdHocSubProcess: SubProcessNode,
|
|
2008
2114
|
Pool: PoolNode,
|
|
2009
2115
|
Lane: LaneNode,
|
|
2010
2116
|
// Artifacts
|
|
@@ -2327,8 +2433,8 @@ var MODDLE_TO_ELEMENT_TYPE = {
|
|
|
2327
2433
|
"bpmn:EventBasedGateway": "EventBasedGateway",
|
|
2328
2434
|
"bpmn:ComplexGateway": "ComplexGateway",
|
|
2329
2435
|
"bpmn:SubProcess": "SubProcess",
|
|
2330
|
-
"bpmn:AdHocSubProcess": "
|
|
2331
|
-
"bpmn:Transaction": "
|
|
2436
|
+
"bpmn:AdHocSubProcess": "AdHocSubProcess",
|
|
2437
|
+
"bpmn:Transaction": "Transaction",
|
|
2332
2438
|
"bpmn:TextAnnotation": "Annotation",
|
|
2333
2439
|
"bpmn:Group": "Group",
|
|
2334
2440
|
"bpmn:DataObject": "DataObject",
|
|
@@ -2366,6 +2472,9 @@ var ELEMENT_TYPE_TO_MODDLE = {
|
|
|
2366
2472
|
EventBasedGateway: "bpmn:EventBasedGateway",
|
|
2367
2473
|
ComplexGateway: "bpmn:ComplexGateway",
|
|
2368
2474
|
SubProcess: "bpmn:SubProcess",
|
|
2475
|
+
Transaction: "bpmn:Transaction",
|
|
2476
|
+
EventSubProcess: "bpmn:SubProcess",
|
|
2477
|
+
AdHocSubProcess: "bpmn:AdHocSubProcess",
|
|
2369
2478
|
Pool: "bpmn:Participant",
|
|
2370
2479
|
Lane: "bpmn:Lane",
|
|
2371
2480
|
Annotation: "bpmn:TextAnnotation",
|
|
@@ -2430,6 +2539,10 @@ function asElements(v) {
|
|
|
2430
2539
|
function asString(v) {
|
|
2431
2540
|
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
2432
2541
|
}
|
|
2542
|
+
function extractDocumentation(el) {
|
|
2543
|
+
const [doc] = asElements(el.documentation);
|
|
2544
|
+
return asString(doc?.text);
|
|
2545
|
+
}
|
|
2433
2546
|
function extractDiagramInfo(definitions) {
|
|
2434
2547
|
const shapes = /* @__PURE__ */ new Map();
|
|
2435
2548
|
const waypoints = /* @__PURE__ */ new Map();
|
|
@@ -2485,6 +2598,7 @@ function extractTrigger(el) {
|
|
|
2485
2598
|
function extractSubProcessVariant(el) {
|
|
2486
2599
|
if (el.$type === "bpmn:Transaction") return "transaction";
|
|
2487
2600
|
if (el.$type === "bpmn:AdHocSubProcess") return "adhoc";
|
|
2601
|
+
if (el.$type === "bpmn:SubProcess" && el.triggeredByEvent === true) return "event";
|
|
2488
2602
|
if (el.triggeredByEvent === true) return "event";
|
|
2489
2603
|
return "embedded";
|
|
2490
2604
|
}
|
|
@@ -2498,7 +2612,7 @@ function walkFlowElements(elements, parentId, ctx, nodes, edges) {
|
|
|
2498
2612
|
continue;
|
|
2499
2613
|
}
|
|
2500
2614
|
if ($type === "bpmn:LaneSet") continue;
|
|
2501
|
-
const elementType = MODDLE_TO_ELEMENT_TYPE[$type];
|
|
2615
|
+
const elementType = $type === "bpmn:SubProcess" && el.triggeredByEvent === true ? "EventSubProcess" : MODDLE_TO_ELEMENT_TYPE[$type];
|
|
2502
2616
|
if (!elementType) {
|
|
2503
2617
|
ctx.warnings.push(`Unknown element type "${$type}" (id=${id}) \u2014 skipped.`);
|
|
2504
2618
|
continue;
|
|
@@ -2519,22 +2633,26 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
|
|
|
2519
2633
|
const y = shape?.y ?? 100;
|
|
2520
2634
|
if (!shape) ctx.autoX.value += (meta?.defaultWidth ?? 120) + 20;
|
|
2521
2635
|
const label = asString(el.name);
|
|
2636
|
+
const documentation = extractDocumentation(el);
|
|
2522
2637
|
const trigger = extractTrigger(el);
|
|
2523
2638
|
const isNonInterrupting = el.cancelActivity === false;
|
|
2639
|
+
const attachedToRef = el.attachedToRef?.id;
|
|
2524
2640
|
const data = {
|
|
2525
2641
|
elementType,
|
|
2526
2642
|
...label ? { label } : {},
|
|
2643
|
+
...documentation ? { documentation } : {},
|
|
2527
2644
|
...trigger ? { trigger } : {},
|
|
2528
|
-
...isNonInterrupting ? { isNonInterrupting: true } : {}
|
|
2645
|
+
...isNonInterrupting ? { isNonInterrupting: true } : {},
|
|
2646
|
+
...attachedToRef ? { attachedToRef } : {}
|
|
2529
2647
|
};
|
|
2530
|
-
if (elementType === "SubProcess") {
|
|
2648
|
+
if (elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess") {
|
|
2531
2649
|
const variant = extractSubProcessVariant(el);
|
|
2532
2650
|
if (variant) data.subProcessVariant = variant;
|
|
2533
2651
|
const isExpanded = shape?.isExpanded ?? true;
|
|
2534
2652
|
data.isExpanded = isExpanded;
|
|
2535
2653
|
}
|
|
2536
2654
|
const laneId = ctx.laneMembership.get(id);
|
|
2537
|
-
const effectiveParentId = laneId ?? parentId;
|
|
2655
|
+
const effectiveParentId = attachedToRef ?? laneId ?? parentId;
|
|
2538
2656
|
const node = {
|
|
2539
2657
|
id,
|
|
2540
2658
|
type: elementType,
|
|
@@ -2555,10 +2673,12 @@ function buildEdge(el, edgeType, ctx, edges) {
|
|
|
2555
2673
|
return;
|
|
2556
2674
|
}
|
|
2557
2675
|
const label = asString(el.name);
|
|
2676
|
+
const documentation = extractDocumentation(el);
|
|
2558
2677
|
const condExpr = el.conditionExpression;
|
|
2559
2678
|
const data = {
|
|
2560
2679
|
edgeType,
|
|
2561
2680
|
...label ? { label } : {},
|
|
2681
|
+
...documentation ? { documentation } : {},
|
|
2562
2682
|
...condExpr?.body ? { conditionExpression: condExpr.body } : {}
|
|
2563
2683
|
};
|
|
2564
2684
|
const waypoints = ctx.waypoints.get(id);
|
|
@@ -2659,7 +2779,46 @@ async function parseBpmnXml(xml) {
|
|
|
2659
2779
|
);
|
|
2660
2780
|
}
|
|
2661
2781
|
}
|
|
2662
|
-
|
|
2782
|
+
const defaultFlowById = /* @__PURE__ */ new Set();
|
|
2783
|
+
const nodeIds = new Set(nodes.map((node) => node.id));
|
|
2784
|
+
for (const rootEl of asElements(rootElement.rootElements)) {
|
|
2785
|
+
collectDefaultFlows(rootEl, defaultFlowById);
|
|
2786
|
+
}
|
|
2787
|
+
const normalizedEdges = edges.map((edge) => {
|
|
2788
|
+
if (!defaultFlowById.has(edge.id)) return edge;
|
|
2789
|
+
const data = {
|
|
2790
|
+
edgeType: edge.data?.edgeType ?? edge.type,
|
|
2791
|
+
...edge.data ?? {},
|
|
2792
|
+
isDefault: true
|
|
2793
|
+
};
|
|
2794
|
+
return { ...edge, data };
|
|
2795
|
+
});
|
|
2796
|
+
return {
|
|
2797
|
+
nodes: normalizeChildPositions(nodes, nodeIds),
|
|
2798
|
+
edges: normalizedEdges,
|
|
2799
|
+
warnings
|
|
2800
|
+
};
|
|
2801
|
+
}
|
|
2802
|
+
function collectDefaultFlows(el, defaultFlowById) {
|
|
2803
|
+
const defaultRef = el.default;
|
|
2804
|
+
if (defaultRef?.id) defaultFlowById.add(defaultRef.id);
|
|
2805
|
+
for (const child of asElements(el.rootElements)) collectDefaultFlows(child, defaultFlowById);
|
|
2806
|
+
for (const child of asElements(el.flowElements)) collectDefaultFlows(child, defaultFlowById);
|
|
2807
|
+
}
|
|
2808
|
+
function normalizeChildPositions(nodes, nodeIds) {
|
|
2809
|
+
const absoluteById = new Map(nodes.map((node) => [node.id, node.position]));
|
|
2810
|
+
return nodes.map((node) => {
|
|
2811
|
+
if (!node.parentId || !nodeIds.has(node.parentId)) return node;
|
|
2812
|
+
const parentPosition = absoluteById.get(node.parentId);
|
|
2813
|
+
if (!parentPosition) return node;
|
|
2814
|
+
return {
|
|
2815
|
+
...node,
|
|
2816
|
+
position: {
|
|
2817
|
+
x: node.position.x - parentPosition.x,
|
|
2818
|
+
y: node.position.y - parentPosition.y
|
|
2819
|
+
}
|
|
2820
|
+
};
|
|
2821
|
+
});
|
|
2663
2822
|
}
|
|
2664
2823
|
function uid(prefix, id) {
|
|
2665
2824
|
return `${prefix}_${id}`;
|
|
@@ -2667,19 +2826,6 @@ function uid(prefix, id) {
|
|
|
2667
2826
|
function asNodes(nodes, types) {
|
|
2668
2827
|
return nodes.filter((n) => types.includes(n.data.elementType));
|
|
2669
2828
|
}
|
|
2670
|
-
function buildFlowableAttrs(data) {
|
|
2671
|
-
const attrs = {};
|
|
2672
|
-
if (data.flowableAssignee) attrs["flowable:assignee"] = data.flowableAssignee;
|
|
2673
|
-
if (data.flowableCandidateGroups) attrs["flowable:candidateGroups"] = data.flowableCandidateGroups;
|
|
2674
|
-
if (data.flowableCandidateUsers) attrs["flowable:candidateUsers"] = data.flowableCandidateUsers;
|
|
2675
|
-
if (data.flowableFormKey) attrs["flowable:formKey"] = data.flowableFormKey;
|
|
2676
|
-
if (data.flowableDueDate) attrs["flowable:dueDate"] = data.flowableDueDate;
|
|
2677
|
-
if (data.flowableType) attrs["flowable:type"] = data.flowableType;
|
|
2678
|
-
if (data.flowableExpression) attrs["flowable:expression"] = data.flowableExpression;
|
|
2679
|
-
if (data.flowableClass) attrs["flowable:class"] = data.flowableClass;
|
|
2680
|
-
if (data.flowableDelegateExpression) attrs["flowable:delegateExpression"] = data.flowableDelegateExpression;
|
|
2681
|
-
return attrs;
|
|
2682
|
-
}
|
|
2683
2829
|
function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
2684
2830
|
const defId = opts.id ?? "Definitions_1";
|
|
2685
2831
|
const defName = opts.name;
|
|
@@ -2738,13 +2884,26 @@ function buildSemanticModel(moddle, nodes, edges, opts) {
|
|
|
2738
2884
|
return definitions;
|
|
2739
2885
|
}
|
|
2740
2886
|
function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId) {
|
|
2741
|
-
const
|
|
2887
|
+
const subProcessIds = new Set(
|
|
2888
|
+
allNodes.filter(
|
|
2889
|
+
(n) => n.data.elementType === "SubProcess" || n.data.elementType === "Transaction" || n.data.elementType === "EventSubProcess" || n.data.elementType === "AdHocSubProcess"
|
|
2890
|
+
).map((n) => n.id)
|
|
2891
|
+
);
|
|
2892
|
+
const isInsideSubProcess = (node) => {
|
|
2893
|
+
let parentId = node.parentId;
|
|
2894
|
+
while (parentId) {
|
|
2895
|
+
if (subProcessIds.has(parentId)) return true;
|
|
2896
|
+
parentId = allNodes.find((candidate) => candidate.id === parentId)?.parentId;
|
|
2897
|
+
}
|
|
2898
|
+
return false;
|
|
2899
|
+
};
|
|
2900
|
+
const myNodes = (poolId ? allNodes.filter(
|
|
2742
2901
|
(n) => n.parentId === poolId || laneNodes.some((l) => l.id === n.parentId && l.parentId === poolId)
|
|
2743
|
-
) : allNodes.filter((n) => n.data.elementType !== "Pool" && n.data.elementType !== "Lane");
|
|
2902
|
+
) : allNodes.filter((n) => n.data.elementType !== "Pool" && n.data.elementType !== "Lane")).filter((n) => !isInsideSubProcess(n));
|
|
2744
2903
|
const myLanes = laneNodes.filter((l) => poolId ? l.parentId === poolId : true);
|
|
2745
2904
|
const flowElements = [];
|
|
2746
2905
|
for (const node of myNodes) {
|
|
2747
|
-
const el = buildFlowElement(moddle, node);
|
|
2906
|
+
const el = buildFlowElement(moddle, node, allNodes, allEdges);
|
|
2748
2907
|
if (el) flowElements.push(el);
|
|
2749
2908
|
}
|
|
2750
2909
|
const myNodeIds = new Set(myNodes.map((n) => n.id));
|
|
@@ -2755,6 +2914,17 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId)
|
|
|
2755
2914
|
const edgeMeta = buildEdgeElement(moddle, edge);
|
|
2756
2915
|
if (edgeMeta) flowElements.push(edgeMeta);
|
|
2757
2916
|
}
|
|
2917
|
+
const elementById = new Map(
|
|
2918
|
+
flowElements.filter((element) => typeof element.id === "string").map((element) => [element.id, element])
|
|
2919
|
+
);
|
|
2920
|
+
for (const edge of myEdges) {
|
|
2921
|
+
if (!edge.data?.isDefault) continue;
|
|
2922
|
+
const sourceElement = elementById.get(edge.source);
|
|
2923
|
+
const edgeElement = elementById.get(edge.id);
|
|
2924
|
+
if (sourceElement && edgeElement) {
|
|
2925
|
+
sourceElement.default = edgeElement;
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2758
2928
|
const process = moddle.create("bpmn:Process", {
|
|
2759
2929
|
id: processId,
|
|
2760
2930
|
isExecutable: true,
|
|
@@ -2775,7 +2945,7 @@ function buildProcess(moddle, allNodes, allEdges, poolId, laneNodes, processId)
|
|
|
2775
2945
|
}
|
|
2776
2946
|
return process;
|
|
2777
2947
|
}
|
|
2778
|
-
function buildFlowElement(moddle, node,
|
|
2948
|
+
function buildFlowElement(moddle, node, allNodes, allEdges) {
|
|
2779
2949
|
const { elementType, label, trigger } = node.data;
|
|
2780
2950
|
if (elementType === "Pool" || elementType === "Lane") return null;
|
|
2781
2951
|
const moddleType = ELEMENT_TYPE_TO_MODDLE[elementType];
|
|
@@ -2784,25 +2954,46 @@ function buildFlowElement(moddle, node, _allNodes, _allEdges) {
|
|
|
2784
2954
|
id: node.id,
|
|
2785
2955
|
name: label ?? ""
|
|
2786
2956
|
};
|
|
2957
|
+
if (node.data.documentation) {
|
|
2958
|
+
attrs.documentation = [
|
|
2959
|
+
moddle.create("bpmn:Documentation", { text: node.data.documentation })
|
|
2960
|
+
];
|
|
2961
|
+
}
|
|
2787
2962
|
if (trigger && trigger !== "none") {
|
|
2788
2963
|
const defType = TRIGGER_TO_EVENT_DEF[trigger];
|
|
2789
2964
|
if (defType) {
|
|
2790
2965
|
attrs.eventDefinitions = [moddle.create(defType, { id: uid("EventDef", node.id) })];
|
|
2791
2966
|
}
|
|
2792
2967
|
}
|
|
2793
|
-
if (elementType === "
|
|
2794
|
-
|
|
2968
|
+
if (elementType === "BoundaryEvent") {
|
|
2969
|
+
attrs.attachedToRef = { id: node.data.attachedToRef ?? node.parentId };
|
|
2970
|
+
attrs.cancelActivity = node.data.isNonInterrupting ? false : true;
|
|
2795
2971
|
}
|
|
2796
|
-
|
|
2797
|
-
|
|
2972
|
+
const isSubProcess2 = elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess";
|
|
2973
|
+
if (isSubProcess2) {
|
|
2974
|
+
attrs.flowElements = buildNestedFlowElements(moddle, node, allNodes, allEdges);
|
|
2975
|
+
if (elementType === "EventSubProcess" || node.data.subProcessVariant === "event") {
|
|
2976
|
+
attrs.triggeredByEvent = true;
|
|
2977
|
+
}
|
|
2798
2978
|
}
|
|
2799
2979
|
const element = moddle.create(moddleType, attrs);
|
|
2800
|
-
const flowableAttrs = buildFlowableAttrs(node.data);
|
|
2801
|
-
if (Object.keys(flowableAttrs).length > 0) {
|
|
2802
|
-
element.$attrs = flowableAttrs;
|
|
2803
|
-
}
|
|
2804
2980
|
return element;
|
|
2805
2981
|
}
|
|
2982
|
+
function buildNestedFlowElements(moddle, parent, allNodes, allEdges) {
|
|
2983
|
+
const childNodes = allNodes.filter((node) => node.parentId === parent.id);
|
|
2984
|
+
const childNodeIds = new Set(childNodes.map((node) => node.id));
|
|
2985
|
+
const flowElements = [];
|
|
2986
|
+
for (const child of childNodes) {
|
|
2987
|
+
const element = buildFlowElement(moddle, child, allNodes, allEdges);
|
|
2988
|
+
if (element) flowElements.push(element);
|
|
2989
|
+
}
|
|
2990
|
+
for (const edge of allEdges) {
|
|
2991
|
+
if (!childNodeIds.has(edge.source) || !childNodeIds.has(edge.target)) continue;
|
|
2992
|
+
const element = buildEdgeElement(moddle, edge);
|
|
2993
|
+
if (element) flowElements.push(element);
|
|
2994
|
+
}
|
|
2995
|
+
return flowElements;
|
|
2996
|
+
}
|
|
2806
2997
|
function buildEdgeElement(moddle, edge) {
|
|
2807
2998
|
if (!edge.data) return null;
|
|
2808
2999
|
const moddleType = EDGE_TYPE_TO_MODDLE[edge.data.edgeType];
|
|
@@ -2813,6 +3004,11 @@ function buildEdgeElement(moddle, edge) {
|
|
|
2813
3004
|
sourceRef: { id: edge.source },
|
|
2814
3005
|
targetRef: { id: edge.target }
|
|
2815
3006
|
};
|
|
3007
|
+
if (edge.data.documentation) {
|
|
3008
|
+
attrs.documentation = [
|
|
3009
|
+
moddle.create("bpmn:Documentation", { text: edge.data.documentation })
|
|
3010
|
+
];
|
|
3011
|
+
}
|
|
2816
3012
|
if (edge.data.conditionExpression) {
|
|
2817
3013
|
attrs.conditionExpression = moddle.create("bpmn:FormalExpression", {
|
|
2818
3014
|
body: edge.data.conditionExpression
|
|
@@ -2823,13 +3019,14 @@ function buildEdgeElement(moddle, edge) {
|
|
|
2823
3019
|
function buildBpmnDI(moddle, definitions, nodes, edges) {
|
|
2824
3020
|
const shapes = [];
|
|
2825
3021
|
const edgeShapes = [];
|
|
3022
|
+
const absolutePositionById = buildAbsolutePositionMap(nodes);
|
|
2826
3023
|
for (const node of nodes) {
|
|
2827
3024
|
const meta = BPMN_ELEMENT_CATALOG[node.data.elementType];
|
|
2828
3025
|
const w = node.width ?? meta?.defaultWidth ?? 120;
|
|
2829
3026
|
const h = node.height ?? meta?.defaultHeight ?? 60;
|
|
2830
3027
|
const bounds = moddle.create("dc:Bounds", {
|
|
2831
|
-
x: node.position.x,
|
|
2832
|
-
y: node.position.y,
|
|
3028
|
+
x: absolutePositionById.get(node.id)?.x ?? node.position.x,
|
|
3029
|
+
y: absolutePositionById.get(node.id)?.y ?? node.position.y,
|
|
2833
3030
|
width: w,
|
|
2834
3031
|
height: h
|
|
2835
3032
|
});
|
|
@@ -2868,6 +3065,24 @@ function buildBpmnDI(moddle, definitions, nodes, edges) {
|
|
|
2868
3065
|
});
|
|
2869
3066
|
definitions.diagrams = [diagram];
|
|
2870
3067
|
}
|
|
3068
|
+
function buildAbsolutePositionMap(nodes) {
|
|
3069
|
+
const nodeById2 = new Map(nodes.map((node) => [node.id, node]));
|
|
3070
|
+
const absoluteById = /* @__PURE__ */ new Map();
|
|
3071
|
+
function resolve(node) {
|
|
3072
|
+
const cached = absoluteById.get(node.id);
|
|
3073
|
+
if (cached) return cached;
|
|
3074
|
+
const parent = node.parentId ? nodeById2.get(node.parentId) : void 0;
|
|
3075
|
+
const parentPosition = parent ? resolve(parent) : { x: 0, y: 0 };
|
|
3076
|
+
const absolute = {
|
|
3077
|
+
x: parentPosition.x + node.position.x,
|
|
3078
|
+
y: parentPosition.y + node.position.y
|
|
3079
|
+
};
|
|
3080
|
+
absoluteById.set(node.id, absolute);
|
|
3081
|
+
return absolute;
|
|
3082
|
+
}
|
|
3083
|
+
for (const node of nodes) resolve(node);
|
|
3084
|
+
return absoluteById;
|
|
3085
|
+
}
|
|
2871
3086
|
async function serializeBpmnXml(nodes, edges, opts = {}) {
|
|
2872
3087
|
const moddle = new bpmnModdle.BpmnModdle();
|
|
2873
3088
|
const definitions = buildSemanticModel(moddle, nodes, edges, opts);
|
|
@@ -3350,44 +3565,280 @@ function isCompleted(state) {
|
|
|
3350
3565
|
function setVariable(state, key, value) {
|
|
3351
3566
|
return { ...state, variables: { ...state.variables, [key]: value } };
|
|
3352
3567
|
}
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3568
|
+
function createBpmnNode(options) {
|
|
3569
|
+
const meta = BPMN_ELEMENT_CATALOG[options.elementType];
|
|
3570
|
+
return {
|
|
3571
|
+
id: options.id,
|
|
3572
|
+
type: options.elementType,
|
|
3573
|
+
position: options.position,
|
|
3574
|
+
data: {
|
|
3575
|
+
elementType: options.elementType,
|
|
3576
|
+
...options.label ? { label: options.label } : {},
|
|
3577
|
+
...options.data ?? {}
|
|
3578
|
+
},
|
|
3579
|
+
width: options.width ?? meta.defaultWidth,
|
|
3580
|
+
height: options.height ?? meta.defaultHeight,
|
|
3581
|
+
...options.parentId ? { parentId: options.parentId } : {}
|
|
3582
|
+
};
|
|
3583
|
+
}
|
|
3584
|
+
function inferBpmnEdgeType(state, sourceId, targetId) {
|
|
3585
|
+
const source = diagramsCore.getNode(state, sourceId);
|
|
3586
|
+
const target = diagramsCore.getNode(state, targetId);
|
|
3587
|
+
if (!source || !target) return "sequenceFlow";
|
|
3588
|
+
if (isDataType(source.data.elementType) || isDataType(target.data.elementType)) {
|
|
3589
|
+
return "dataAssociation";
|
|
3360
3590
|
}
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
return this.state;
|
|
3591
|
+
if (source.data.elementType === "Annotation" || target.data.elementType === "Annotation" || source.data.elementType === "Group" || target.data.elementType === "Group") {
|
|
3592
|
+
return "association";
|
|
3364
3593
|
}
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
return this.state;
|
|
3594
|
+
if (source.data.elementType === "Conversation" || source.data.elementType === "SubConversation" || source.data.elementType === "CallConversation" || target.data.elementType === "Conversation" || target.data.elementType === "SubConversation" || target.data.elementType === "CallConversation") {
|
|
3595
|
+
return "conversationLink";
|
|
3368
3596
|
}
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
return this.state;
|
|
3597
|
+
if (source.parentId && target.parentId && source.parentId !== target.parentId) {
|
|
3598
|
+
return "messageFlow";
|
|
3372
3599
|
}
|
|
3373
|
-
|
|
3374
|
-
|
|
3600
|
+
return "sequenceFlow";
|
|
3601
|
+
}
|
|
3602
|
+
function canUseSequenceFlow(type) {
|
|
3603
|
+
const meta = BPMN_ELEMENT_CATALOG[type];
|
|
3604
|
+
return meta.handlePolicy !== "none" && !isDataType(type) && type !== "Annotation" && type !== "Group" && meta.category !== "conversation";
|
|
3605
|
+
}
|
|
3606
|
+
function validateEdgeCardinality(state, edgeType, source, target) {
|
|
3607
|
+
if (edgeType !== "sequenceFlow") return true;
|
|
3608
|
+
const sourceMax = BPMN_ELEMENT_CATALOG[source.data.elementType].maxOutgoing;
|
|
3609
|
+
const targetMax = BPMN_ELEMENT_CATALOG[target.data.elementType].maxIncoming;
|
|
3610
|
+
const outgoing = diagramsCore.getOutgoingEdges(state, source.id).filter(
|
|
3611
|
+
(edge) => edge.data?.edgeType === "sequenceFlow"
|
|
3612
|
+
);
|
|
3613
|
+
const incoming = diagramsCore.getIncomingEdges(state, target.id).filter(
|
|
3614
|
+
(edge) => edge.data?.edgeType === "sequenceFlow"
|
|
3615
|
+
);
|
|
3616
|
+
if (sourceMax !== void 0 && outgoing.length >= sourceMax) {
|
|
3617
|
+
return `${source.data.elementType} cannot have more than ${sourceMax} outgoing sequence flow(s).`;
|
|
3375
3618
|
}
|
|
3376
|
-
|
|
3377
|
-
return
|
|
3619
|
+
if (targetMax !== void 0 && incoming.length >= targetMax) {
|
|
3620
|
+
return `${target.data.elementType} cannot have more than ${targetMax} incoming sequence flow(s).`;
|
|
3378
3621
|
}
|
|
3379
|
-
|
|
3380
|
-
|
|
3622
|
+
return true;
|
|
3623
|
+
}
|
|
3624
|
+
var bpmnConnectionValidators = [
|
|
3625
|
+
({ state, source, target }) => {
|
|
3626
|
+
if (source.id === target.id) return "BPMN self-connections are not allowed.";
|
|
3627
|
+
const edgeType = inferBpmnEdgeType(state, source.id, target.id);
|
|
3628
|
+
if (getHandlePolicy(source.data.elementType) === "none" || getHandlePolicy(target.data.elementType) === "none") {
|
|
3629
|
+
return "Elements without BPMN connection handles cannot be directly connected.";
|
|
3630
|
+
}
|
|
3631
|
+
if (edgeType === "sequenceFlow") {
|
|
3632
|
+
if (!canUseSequenceFlow(source.data.elementType) || !canUseSequenceFlow(target.data.elementType)) {
|
|
3633
|
+
return "Sequence flows can only connect BPMN flow nodes.";
|
|
3634
|
+
}
|
|
3635
|
+
if (source.data.elementType === "EndEvent") return "End events cannot have outgoing sequence flows.";
|
|
3636
|
+
if (target.data.elementType === "StartEvent") return "Start events cannot have incoming sequence flows.";
|
|
3637
|
+
return validateEdgeCardinality(state, edgeType, source, target);
|
|
3638
|
+
}
|
|
3639
|
+
return true;
|
|
3381
3640
|
}
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3641
|
+
];
|
|
3642
|
+
var BPMN_MODELING_RULES = diagramsCore.createModelingRules({
|
|
3643
|
+
connect: [
|
|
3644
|
+
({ state, source, target }) => {
|
|
3645
|
+
if (!source || !target) return false;
|
|
3646
|
+
for (const validator of bpmnConnectionValidators) {
|
|
3647
|
+
const result = validator({
|
|
3648
|
+
state,
|
|
3649
|
+
source,
|
|
3650
|
+
target,
|
|
3651
|
+
existingEdges: state.edges
|
|
3652
|
+
});
|
|
3653
|
+
if (result !== true) return result;
|
|
3654
|
+
}
|
|
3655
|
+
return true;
|
|
3656
|
+
}
|
|
3657
|
+
],
|
|
3658
|
+
drop: [
|
|
3659
|
+
({ node, parent }) => {
|
|
3660
|
+
if (!node || !parent) return true;
|
|
3661
|
+
if (node.data.elementType === "BoundaryEvent") {
|
|
3662
|
+
return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be attached to tasks or subprocesses.";
|
|
3663
|
+
}
|
|
3664
|
+
if (parent.data.elementType === "Pool" || parent.data.elementType === "Lane") {
|
|
3665
|
+
return isEventType(node.data.elementType) || node.data.elementType.includes("Task") || node.data.elementType.includes("Gateway") || node.data.elementType.includes("SubProcess") ? true : "Only flow nodes can be dropped into pools or lanes.";
|
|
3666
|
+
}
|
|
3667
|
+
return true;
|
|
3668
|
+
}
|
|
3669
|
+
],
|
|
3670
|
+
reparent: [
|
|
3671
|
+
({ node, parent }) => {
|
|
3672
|
+
if (!node || !parent) return true;
|
|
3673
|
+
if (node.data.elementType === "BoundaryEvent") {
|
|
3674
|
+
return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be reparented to tasks or subprocesses.";
|
|
3675
|
+
}
|
|
3676
|
+
return true;
|
|
3677
|
+
}
|
|
3678
|
+
],
|
|
3679
|
+
delete: [() => true],
|
|
3680
|
+
resize: [() => true]
|
|
3681
|
+
});
|
|
3682
|
+
function createBpmnNodeCommand(options) {
|
|
3683
|
+
return {
|
|
3684
|
+
id: `bpmn.createNode.${options.id}`,
|
|
3685
|
+
label: `Create ${options.elementType}`,
|
|
3686
|
+
execute: (state) => diagramsCore.addNode(state, createBpmnNode(options))
|
|
3687
|
+
};
|
|
3688
|
+
}
|
|
3689
|
+
function connectBpmnCommand(options) {
|
|
3690
|
+
return {
|
|
3691
|
+
id: `bpmn.connect.${options.id ?? `${options.source}-${options.target}`}`,
|
|
3692
|
+
label: "Connect BPMN elements",
|
|
3693
|
+
execute: (state) => {
|
|
3694
|
+
const edgeType = options.edgeType ?? inferBpmnEdgeType(state, options.source, options.target);
|
|
3695
|
+
return diagramsCore.connectNodes(
|
|
3696
|
+
state,
|
|
3697
|
+
{
|
|
3698
|
+
source: options.source,
|
|
3699
|
+
target: options.target,
|
|
3700
|
+
type: edgeType,
|
|
3701
|
+
...options.sourceHandle !== void 0 ? { sourceHandle: options.sourceHandle } : {},
|
|
3702
|
+
...options.targetHandle !== void 0 ? { targetHandle: options.targetHandle } : {},
|
|
3703
|
+
...options.id ? { id: options.id } : {},
|
|
3704
|
+
data: {
|
|
3705
|
+
edgeType,
|
|
3706
|
+
...options.label ? { label: options.label } : {},
|
|
3707
|
+
...options.data ?? {}
|
|
3708
|
+
}
|
|
3709
|
+
},
|
|
3710
|
+
bpmnConnectionValidators
|
|
3711
|
+
);
|
|
3712
|
+
}
|
|
3713
|
+
};
|
|
3714
|
+
}
|
|
3715
|
+
function attachBoundaryEventCommand(boundaryId, hostId) {
|
|
3716
|
+
return {
|
|
3717
|
+
id: `bpmn.attachBoundary.${boundaryId}.${hostId}`,
|
|
3718
|
+
label: "Attach boundary event",
|
|
3719
|
+
execute: (state) => {
|
|
3720
|
+
const host = diagramsCore.getNode(state, hostId);
|
|
3721
|
+
if (!host || !acceptsBoundaryEvents(host.data.elementType)) {
|
|
3722
|
+
throw new Error(`Element "${hostId}" cannot host boundary events.`);
|
|
3723
|
+
}
|
|
3724
|
+
const boundary = diagramsCore.getNode(state, boundaryId);
|
|
3725
|
+
if (!boundary || boundary.data.elementType !== "BoundaryEvent") {
|
|
3726
|
+
throw new Error(`Element "${boundaryId}" is not a boundary event.`);
|
|
3727
|
+
}
|
|
3728
|
+
const reparented = diagramsCore.reparentNode(state, boundaryId, { parentId: hostId });
|
|
3729
|
+
return diagramsCore.patchNode(reparented, boundaryId, {
|
|
3730
|
+
data: { attachedToRef: hostId }
|
|
3731
|
+
});
|
|
3732
|
+
}
|
|
3733
|
+
};
|
|
3734
|
+
}
|
|
3735
|
+
function replaceBpmnNodeCommand(options) {
|
|
3736
|
+
return {
|
|
3737
|
+
id: `bpmn.replaceNode.${options.id}.${options.elementType}`,
|
|
3738
|
+
label: `Replace with ${options.elementType}`,
|
|
3739
|
+
execute: (state) => {
|
|
3740
|
+
const current = diagramsCore.getNode(state, options.id);
|
|
3741
|
+
if (!current) throw new Error(`Element "${options.id}" does not exist.`);
|
|
3742
|
+
const meta = BPMN_ELEMENT_CATALOG[options.elementType];
|
|
3743
|
+
return diagramsCore.replaceNode(state, options.id, {
|
|
3744
|
+
...current,
|
|
3745
|
+
type: options.elementType,
|
|
3746
|
+
width: options.width ?? current.width ?? meta.defaultWidth,
|
|
3747
|
+
height: options.height ?? current.height ?? meta.defaultHeight,
|
|
3748
|
+
data: {
|
|
3749
|
+
...current.data,
|
|
3750
|
+
elementType: options.elementType,
|
|
3751
|
+
...options.label ? { label: options.label } : {},
|
|
3752
|
+
...options.data ?? {}
|
|
3753
|
+
}
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
};
|
|
3757
|
+
}
|
|
3758
|
+
function reparentBpmnNodeCommand(options) {
|
|
3759
|
+
return {
|
|
3760
|
+
id: `bpmn.reparent.${options.id}.${options.parentId ?? "root"}`,
|
|
3761
|
+
label: "Reparent BPMN element",
|
|
3762
|
+
execute: (state) => {
|
|
3763
|
+
const node = diagramsCore.getNode(state, options.id);
|
|
3764
|
+
const parent = options.parentId ? diagramsCore.getNode(state, options.parentId) : void 0;
|
|
3765
|
+
if (!node) throw new Error(`Element "${options.id}" does not exist.`);
|
|
3766
|
+
if (parent && node.data.elementType === "BoundaryEvent" && !acceptsBoundaryEvents(parent.data.elementType)) {
|
|
3767
|
+
throw new Error("Boundary events can only be reparented to tasks or subprocesses.");
|
|
3768
|
+
}
|
|
3769
|
+
return diagramsCore.reparentNode(state, options.id, {
|
|
3770
|
+
...options.parentId !== void 0 ? { parentId: options.parentId } : {},
|
|
3771
|
+
...options.position ? { position: options.position } : {}
|
|
3772
|
+
});
|
|
3773
|
+
}
|
|
3774
|
+
};
|
|
3775
|
+
}
|
|
3776
|
+
function resizeBpmnNodeCommand(options) {
|
|
3777
|
+
return {
|
|
3778
|
+
id: `bpmn.resize.${options.id}`,
|
|
3779
|
+
label: "Resize BPMN element",
|
|
3780
|
+
execute: (state) => diagramsCore.resizeNode(state, options.id, options)
|
|
3781
|
+
};
|
|
3782
|
+
}
|
|
3783
|
+
function deleteBpmnElementsCommand(ids) {
|
|
3784
|
+
return {
|
|
3785
|
+
id: `bpmn.delete.${ids.join(".")}`,
|
|
3786
|
+
label: "Delete BPMN elements",
|
|
3787
|
+
execute: (state) => diagramsCore.removeElements(state, ids)
|
|
3788
|
+
};
|
|
3789
|
+
}
|
|
3790
|
+
function copyBpmnElements(state, selection) {
|
|
3791
|
+
return diagramsCore.copyElements(state, selection);
|
|
3792
|
+
}
|
|
3793
|
+
function pasteBpmnElementsCommand(clipboard, options = {}) {
|
|
3794
|
+
return {
|
|
3795
|
+
id: "bpmn.paste",
|
|
3796
|
+
label: "Paste BPMN elements",
|
|
3797
|
+
execute: (state) => diagramsCore.pasteElements(state, clipboard, options)
|
|
3798
|
+
};
|
|
3799
|
+
}
|
|
3800
|
+
function selectBpmnElementsCommand(selection) {
|
|
3801
|
+
return {
|
|
3802
|
+
id: "bpmn.select",
|
|
3803
|
+
label: "Select BPMN elements",
|
|
3804
|
+
execute: (state) => diagramsCore.setSelection(state, diagramsCore.createSelectionState(selection.nodeIds, selection.edgeIds))
|
|
3805
|
+
};
|
|
3806
|
+
}
|
|
3807
|
+
function createBpmnDiagramDocument(state, options = {}) {
|
|
3808
|
+
return serialization.createDiagramDocument(diagramsCore.normalizeDiagramState(state), {
|
|
3809
|
+
...options,
|
|
3810
|
+
diagramType: "bpmn"
|
|
3811
|
+
});
|
|
3812
|
+
}
|
|
3813
|
+
function serializeBpmnDiagram(state, options = {}) {
|
|
3814
|
+
return serialization.serializeDiagram(diagramsCore.normalizeDiagramState(state), {
|
|
3815
|
+
...options,
|
|
3816
|
+
diagramType: "bpmn"
|
|
3817
|
+
});
|
|
3818
|
+
}
|
|
3819
|
+
function parseBpmnDiagramDocument(json) {
|
|
3820
|
+
const document = serialization.parseDiagramDocument(json);
|
|
3821
|
+
if (document.diagramType && document.diagramType !== "bpmn") {
|
|
3822
|
+
throw new Error(`Expected a BPMN diagram document, received "${document.diagramType}".`);
|
|
3823
|
+
}
|
|
3824
|
+
return document;
|
|
3825
|
+
}
|
|
3826
|
+
function deserializeBpmnDiagram(json) {
|
|
3827
|
+
const document = parseBpmnDiagramDocument(json);
|
|
3828
|
+
return serialization.deserializeDiagram(JSON.stringify(document));
|
|
3829
|
+
}
|
|
3830
|
+
function runBpmnCommand(stack, command) {
|
|
3831
|
+
return diagramsCore.executeCommand(stack, command);
|
|
3832
|
+
}
|
|
3833
|
+
function runBpmnCommands(stack, commands, options = {}) {
|
|
3834
|
+
return diagramsCore.executeCommands(stack, commands, options);
|
|
3385
3835
|
}
|
|
3386
3836
|
|
|
3387
3837
|
exports.AnnotationNode = AnnotationNode;
|
|
3388
3838
|
exports.AssociationEdge = AssociationEdge;
|
|
3389
3839
|
exports.BPMN_EDGE_TYPES = BPMN_EDGE_TYPES;
|
|
3390
3840
|
exports.BPMN_ELEMENT_CATALOG = BPMN_ELEMENT_CATALOG;
|
|
3841
|
+
exports.BPMN_MODELING_RULES = BPMN_MODELING_RULES;
|
|
3391
3842
|
exports.BPMN_NODE_TYPES = BPMN_NODE_TYPES;
|
|
3392
3843
|
exports.BoundaryEventNode = BoundaryEventNode;
|
|
3393
3844
|
exports.CallChoreographyNode = CallChoreographyNode;
|
|
@@ -3417,13 +3868,22 @@ exports.SubConversationNode = SubConversationNode;
|
|
|
3417
3868
|
exports.SubProcessNode = SubProcessNode;
|
|
3418
3869
|
exports.TaskNode = TaskNode;
|
|
3419
3870
|
exports.acceptsBoundaryEvents = acceptsBoundaryEvents;
|
|
3420
|
-
exports.
|
|
3871
|
+
exports.attachBoundaryEventCommand = attachBoundaryEventCommand;
|
|
3872
|
+
exports.bpmnConnectionValidators = bpmnConnectionValidators;
|
|
3873
|
+
exports.connectBpmnCommand = connectBpmnCommand;
|
|
3874
|
+
exports.copyBpmnElements = copyBpmnElements;
|
|
3875
|
+
exports.createBpmnDiagramDocument = createBpmnDiagramDocument;
|
|
3876
|
+
exports.createBpmnNode = createBpmnNode;
|
|
3877
|
+
exports.createBpmnNodeCommand = createBpmnNodeCommand;
|
|
3421
3878
|
exports.createSimulation = createSimulation;
|
|
3879
|
+
exports.deleteBpmnElementsCommand = deleteBpmnElementsCommand;
|
|
3880
|
+
exports.deserializeBpmnDiagram = deserializeBpmnDiagram;
|
|
3422
3881
|
exports.fire = fire;
|
|
3423
3882
|
exports.getElementMeta = getElementMeta;
|
|
3424
3883
|
exports.getFireable = getFireable;
|
|
3425
3884
|
exports.getHandlePolicy = getHandlePolicy;
|
|
3426
3885
|
exports.getOrientation = getOrientation;
|
|
3886
|
+
exports.inferBpmnEdgeType = inferBpmnEdgeType;
|
|
3427
3887
|
exports.isChoreographyType = isChoreographyType;
|
|
3428
3888
|
exports.isCompleted = isCompleted;
|
|
3429
3889
|
exports.isContainerType = isContainerType;
|
|
@@ -3432,7 +3892,16 @@ exports.isDataType = isDataType;
|
|
|
3432
3892
|
exports.isEventType = isEventType;
|
|
3433
3893
|
exports.isGatewayType = isGatewayType;
|
|
3434
3894
|
exports.isTaskType = isTaskType;
|
|
3895
|
+
exports.parseBpmnDiagramDocument = parseBpmnDiagramDocument;
|
|
3435
3896
|
exports.parseBpmnXml = parseBpmnXml;
|
|
3897
|
+
exports.pasteBpmnElementsCommand = pasteBpmnElementsCommand;
|
|
3898
|
+
exports.reparentBpmnNodeCommand = reparentBpmnNodeCommand;
|
|
3899
|
+
exports.replaceBpmnNodeCommand = replaceBpmnNodeCommand;
|
|
3900
|
+
exports.resizeBpmnNodeCommand = resizeBpmnNodeCommand;
|
|
3901
|
+
exports.runBpmnCommand = runBpmnCommand;
|
|
3902
|
+
exports.runBpmnCommands = runBpmnCommands;
|
|
3903
|
+
exports.selectBpmnElementsCommand = selectBpmnElementsCommand;
|
|
3904
|
+
exports.serializeBpmnDiagram = serializeBpmnDiagram;
|
|
3436
3905
|
exports.serializeBpmnXml = serializeBpmnXml;
|
|
3437
3906
|
exports.setVariable = setVariable;
|
|
3438
3907
|
exports.supportsCollapse = supportsCollapse;
|