bpmn-js 10.1.0 → 10.2.1

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.
@@ -9,62 +9,75 @@ export default function EventBasedGatewayBehavior(eventBus, modeling) {
9
9
  CommandInterceptor.call(this, eventBus);
10
10
 
11
11
  /**
12
- * Remove existing sequence flows of event-based target before connecting
13
- * from event-based gateway.
12
+ * Remove incoming sequence flows of event-based target when creating
13
+ * sequence flow.
14
+ *
15
+ * 1. If source is event-based gateway remove all incoming sequence flows
16
+ * 2. If source is not event-based gateway remove all incoming sequence flows
17
+ * whose source is event-based gateway
14
18
  */
15
19
  this.preExecuted('connection.create', function(event) {
16
-
17
20
  var context = event.context,
21
+ connection = context.connection,
18
22
  source = context.source,
19
23
  target = context.target,
20
- existingIncomingConnections = target.incoming.slice();
24
+ hints = context.hints;
21
25
 
22
- if (context.hints && context.hints.createElementsBehavior === false) {
26
+ if (hints && hints.createElementsBehavior === false) {
23
27
  return;
24
28
  }
25
29
 
26
- if (
27
- is(source, 'bpmn:EventBasedGateway') &&
28
- target.incoming.length
29
- ) {
30
+ if (!isSequenceFlow(connection)) {
31
+ return;
32
+ }
30
33
 
31
- existingIncomingConnections.filter(isSequenceFlow)
32
- .forEach(function(sequenceFlow) {
33
- modeling.removeConnection(sequenceFlow);
34
- });
34
+ var sequenceFlows = [];
35
+
36
+ if (is(source, 'bpmn:EventBasedGateway')) {
37
+ sequenceFlows = target.incoming.filter(isSequenceFlow);
38
+ } else {
39
+ sequenceFlows = target.incoming.filter(function(connection) {
40
+ return isSequenceFlow(connection)
41
+ && is(connection.source, 'bpmn:EventBasedGateway');
42
+ });
35
43
  }
44
+
45
+ sequenceFlows.forEach(function(sequenceFlow) {
46
+ modeling.removeConnection(sequenceFlow);
47
+ });
36
48
  });
37
49
 
38
50
  /**
39
- * After replacing shape with event-based gateway, remove incoming sequence
40
- * flows of event-based targets which do not belong to event-based gateway
41
- * source.
51
+ * Remove incoming sequence flows of event-based targets when replacing source
52
+ * with event-based gateway.
42
53
  */
43
54
  this.preExecuted('shape.replace', function(event) {
44
-
45
- var newShape = event.context.newShape,
46
- newShapeTargets,
47
- newShapeTargetsIncomingSequenceFlows;
55
+ var context = event.context,
56
+ newShape = context.newShape;
48
57
 
49
58
  if (!is(newShape, 'bpmn:EventBasedGateway')) {
50
59
  return;
51
60
  }
52
61
 
53
- newShapeTargets = newShape.outgoing.filter(isSequenceFlow)
54
- .map(function(sequenceFlow) {
55
- return sequenceFlow.target;
56
- });
62
+ var targets = newShape.outgoing.filter(isSequenceFlow)
63
+ .reduce(function(targets, sequenceFlow) {
64
+ if (!targets.includes(sequenceFlow.target)) {
65
+ return targets.concat(sequenceFlow.target);
66
+ }
57
67
 
58
- newShapeTargetsIncomingSequenceFlows = newShapeTargets.reduce(function(sequenceFlows, target) {
59
- var incomingSequenceFlows = target.incoming.filter(isSequenceFlow);
68
+ return targets;
69
+ }, []);
60
70
 
61
- return sequenceFlows.concat(incomingSequenceFlows);
62
- }, []);
71
+ targets.forEach(function(target) {
72
+ target.incoming.filter(isSequenceFlow).forEach(function(sequenceFlow) {
73
+ const sequenceFlowsFromNewShape = target.incoming.filter(isSequenceFlow).filter(function(sequenceFlow) {
74
+ return sequenceFlow.source === newShape;
75
+ });
63
76
 
64
- newShapeTargetsIncomingSequenceFlows.forEach(function(sequenceFlow) {
65
- if (sequenceFlow.source !== newShape) {
66
- modeling.removeConnection(sequenceFlow);
67
- }
77
+ if (sequenceFlow.source !== newShape || sequenceFlowsFromNewShape.length > 1) {
78
+ modeling.removeConnection(sequenceFlow);
79
+ }
80
+ });
68
81
  });
69
82
  });
70
83
  }
@@ -76,10 +89,8 @@ EventBasedGatewayBehavior.$inject = [
76
89
 
77
90
  inherits(EventBasedGatewayBehavior, CommandInterceptor);
78
91
 
79
-
80
-
81
- // helpers //////////////////////
92
+ // helpers //////////
82
93
 
83
94
  function isSequenceFlow(connection) {
84
95
  return is(connection, 'bpmn:SequenceFlow');
85
- }
96
+ }
@@ -855,16 +855,6 @@ function canConnectMessageFlow(source, target) {
855
855
  }
856
856
 
857
857
  function canConnectSequenceFlow(source, target) {
858
-
859
- if (
860
- isEventBasedTarget(target) &&
861
- target.incoming.length > 0 &&
862
- areOutgoingEventBasedGatewayConnections(target.incoming) &&
863
- !is(source, 'bpmn:EventBasedGateway')
864
- ) {
865
- return false;
866
- }
867
-
868
858
  return isSequenceFlowSource(source) &&
869
859
  isSequenceFlowTarget(target) &&
870
860
  isSameScope(source, target) &&
@@ -936,19 +926,6 @@ function canCopy(elements, element) {
936
926
  return true;
937
927
  }
938
928
 
939
- function isOutgoingEventBasedGatewayConnection(connection) {
940
-
941
- if (connection && connection.source) {
942
- return is(connection.source, 'bpmn:EventBasedGateway');
943
- }
944
- }
945
-
946
- function areOutgoingEventBasedGatewayConnections(connections) {
947
- connections = connections || [];
948
-
949
- return connections.some(isOutgoingEventBasedGatewayConnection);
950
- }
951
-
952
929
  function getRootElement(element) {
953
930
  return getParent(element, 'bpmn:Process') || getParent(element, 'bpmn:Collaboration');
954
931
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "10.1.0",
3
+ "version": "10.2.1",
4
4
  "description": "A bpmn 2.0 toolkit and web modeler",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -69,10 +69,10 @@
69
69
  "eslint-plugin-bpmn-io": "^0.16.0",
70
70
  "eslint-plugin-import": "^2.26.0",
71
71
  "execa": "^5.1.1",
72
- "karma": "^6.4.0",
72
+ "karma": "^6.4.1",
73
73
  "karma-chrome-launcher": "^3.1.1",
74
74
  "karma-coverage": "^2.2.0",
75
- "karma-debug-launcher": "0.0.4",
75
+ "karma-debug-launcher": "^0.0.5",
76
76
  "karma-env-preprocessor": "^0.1.1",
77
77
  "karma-firefox-launcher": "^2.1.2",
78
78
  "karma-mocha": "^2.0.1",
@@ -83,8 +83,7 @@
83
83
  "mocha": "^9.0.0",
84
84
  "mocha-test-container-support": "0.2.0",
85
85
  "npm-run-all": "^4.1.2",
86
- "promise-polyfill": "^8.2.0",
87
- "puppeteer": "^16.1.1",
86
+ "puppeteer": "^18.0.5",
88
87
  "rollup": "^2.78.0",
89
88
  "rollup-plugin-json": "^4.0.0",
90
89
  "rollup-plugin-license": "^2.8.1",
@@ -95,7 +94,7 @@
95
94
  "webpack": "^5.74.0"
96
95
  },
97
96
  "dependencies": {
98
- "bpmn-moddle": "^7.1.3",
97
+ "bpmn-moddle": "^8.0.0",
99
98
  "css.escape": "^1.5.1",
100
99
  "diagram-js": "^9.1.0",
101
100
  "diagram-js-direct-editing": "^2.0.0",