bpmn-js 18.31.1 → 18.32.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v18.31.1
2
+ * bpmn-js - bpmn-modeler v18.32.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2026-10-21
11
+ * Date: 2026-11-16
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2130,6 +2130,8 @@
2130
2130
  // - can't reliably auto-annotate constructor; we'll match the
2131
2131
  // first constructor(...) pattern found which may be the one
2132
2132
  // of a nested class, too.
2133
+ //
2134
+ // - can't parse default values containing "," or ")"
2133
2135
 
2134
2136
  const CONSTRUCTOR_ARGS = /constructor\s*[^(]*\(\s*([^)]*)\)/m;
2135
2137
  const FN_ARGS = /^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m;
@@ -2157,7 +2159,11 @@
2157
2159
 
2158
2160
  return args && args.split(',').map(arg => {
2159
2161
  const argMatch = arg.match(FN_ARG);
2160
- return (argMatch && argMatch[1] || arg).trim();
2162
+ const [ argName, defaultValue ] = arg.replace(FN_ARG, '').split('=');
2163
+ const name = (argMatch && argMatch[1] || argName).trim();
2164
+
2165
+ // arguments with default values are optional, i.e. `a.b = 1` => `a.b?`
2166
+ return defaultValue !== undefined && !name.endsWith('?') ? name + '?' : name;
2161
2167
  }) || [];
2162
2168
  }
2163
2169
 
@@ -2179,13 +2185,13 @@
2179
2185
 
2180
2186
  const parent = _parent || /** @type InjectorContext */ ({
2181
2187
  get: function(name, strict) {
2182
- currentlyResolving.push(name);
2183
-
2184
2188
  if (strict === false) {
2185
- return null;
2186
- } else {
2187
- throw error(`No provider for "${ name }"!`);
2189
+ return undefined;
2188
2190
  }
2191
+
2192
+ currentlyResolving.push(name);
2193
+
2194
+ throw error(`No provider for "${ name }"!`);
2189
2195
  }
2190
2196
  });
2191
2197
 
@@ -2205,18 +2211,34 @@
2205
2211
  * Return a named service.
2206
2212
  *
2207
2213
  * @param {string} name
2208
- * @param {boolean} [strict=true] if false, resolve missing services to null
2214
+ * @param {boolean} [strict=true] if false, resolve missing services to undefined
2209
2215
  *
2210
2216
  * @return {any}
2211
2217
  */
2212
2218
  function get(name, strict) {
2219
+ const optionalIdx = name.lastIndexOf('?');
2220
+
2221
+ // optional chaining, i.e. `a.b?.c`
2222
+ if (optionalIdx !== -1) {
2223
+ const pivot = get(name.slice(0, optionalIdx), false);
2224
+ const path = name.slice(optionalIdx + 2);
2225
+
2226
+ if (path && pivot == null) {
2227
+ return undefined;
2228
+ }
2229
+
2230
+ return path ? path.split('.').reduce((pivot, key) => pivot[key], pivot) : pivot;
2231
+ }
2232
+
2213
2233
  if (!providers[name] && name.includes('.')) {
2214
2234
 
2215
2235
  const parts = name.split('.');
2216
- let pivot = get(/** @type { string } */ (parts.shift()));
2236
+ let pivot = get(/** @type { string } */ (parts.shift()), strict);
2217
2237
 
2218
2238
  while (parts.length) {
2219
- pivot = pivot[/** @type { string } */ (parts.shift())];
2239
+ const key = /** @type { string } */ (parts.shift());
2240
+
2241
+ pivot = strict === false ? pivot?.[key] : pivot[key];
2220
2242
  }
2221
2243
 
2222
2244
  return pivot;
@@ -2261,11 +2283,9 @@
2261
2283
  */
2262
2284
  const inject = fn.$inject || parseAnnotations(fn);
2263
2285
  const dependencies = inject.map(dep => {
2264
- if (hasOwnProp(locals, dep)) {
2265
- return locals[dep];
2266
- } else {
2267
- return get(dep);
2268
- }
2286
+ const local = dep.replace(/\?$/, '');
2287
+
2288
+ return hasOwnProp(locals, local) ? locals[local] : get(dep);
2269
2289
  });
2270
2290
 
2271
2291
  return {
@@ -2977,16 +2997,14 @@
2977
2997
 
2978
2998
  function handleElement(element) {
2979
2999
 
2980
- enclosedElements[element.id] = element;
2981
-
2982
3000
  if (element.waypoints) {
2983
3001
 
2984
3002
  // remember connection
2985
- enclosedConnections[element.id] = allConnections[element.id] = element;
3003
+ allConnections[element.id] = element;
2986
3004
  } else {
2987
3005
 
2988
3006
  // remember shape
2989
- allShapes[element.id] = element;
3007
+ enclosedElements[element.id] = allShapes[element.id] = element;
2990
3008
 
2991
3009
  // remember all connections
2992
3010
  forEach(element.incoming, handleConnection);
@@ -8592,7 +8610,7 @@
8592
8610
  * @template T
8593
8611
  *
8594
8612
  * @param {string} name The name of the service to get.
8595
- * @param {true} strict If false, resolve missing services to null.
8613
+ * @param {true} strict If true, throw if the service is missing.
8596
8614
  *
8597
8615
  * @return {T}
8598
8616
  */
@@ -8604,9 +8622,9 @@
8604
8622
  * @template T
8605
8623
  *
8606
8624
  * @param {string} name The name of the service to get.
8607
- * @param {boolean} strict If false, resolve missing services to null.
8625
+ * @param {boolean} strict If false, resolve missing services to undefined.
8608
8626
  *
8609
- * @return {T|null}
8627
+ * @return {T|undefined}
8610
8628
  */
8611
8629
  /**
8612
8630
  * Resolves a diagram service.
@@ -20274,7 +20292,7 @@
20274
20292
 
20275
20293
  if (semantic.get('eventDefinitions') && semantic.get('eventDefinitions').length > 1) {
20276
20294
  if (semantic.get('parallelMultiple')) {
20277
- return eventIconRenderers[ 'bpmn:ParallelMultipleEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
20295
+ return eventIconRenderers[ 'bpmn:ParallelMultipleEventDefinition' ](parentGfx, nodeElement, attrs);
20278
20296
  }
20279
20297
  else {
20280
20298
  return eventIconRenderers[ 'bpmn:MultipleEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
@@ -20286,11 +20304,11 @@
20286
20304
  }
20287
20305
 
20288
20306
  if (isTypedEvent(semantic, 'bpmn:TimerEventDefinition')) {
20289
- return eventIconRenderers[ 'bpmn:TimerEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
20307
+ return eventIconRenderers[ 'bpmn:TimerEventDefinition' ](parentGfx, nodeElement, attrs);
20290
20308
  }
20291
20309
 
20292
20310
  if (isTypedEvent(semantic, 'bpmn:ConditionalEventDefinition')) {
20293
- return eventIconRenderers[ 'bpmn:ConditionalEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
20311
+ return eventIconRenderers[ 'bpmn:ConditionalEventDefinition' ](parentGfx, nodeElement, attrs);
20294
20312
  }
20295
20313
 
20296
20314
  if (isTypedEvent(semantic, 'bpmn:SignalEventDefinition')) {
@@ -20318,7 +20336,7 @@
20318
20336
  }
20319
20337
 
20320
20338
  if (isTypedEvent(semantic, 'bpmn:TerminateEventDefinition')) {
20321
- return eventIconRenderers[ 'bpmn:TerminateEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
20339
+ return eventIconRenderers[ 'bpmn:TerminateEventDefinition' ](parentGfx, nodeElement, attrs);
20322
20340
  }
20323
20341
 
20324
20342
  return null;
@@ -22108,7 +22126,7 @@
22108
22126
 
22109
22127
  // strip trailing whitespace so measurement matches the browser's
22110
22128
  // native rendering used by direct editing
22111
- var measurable = emptyLine ? 'dummy' : text.replace(/\s+$/, '');
22129
+ var measurable = emptyLine ? 'dummy' : text.trimEnd();
22112
22130
  var metrics = ctx.measureText(measurable);
22113
22131
 
22114
22132
  return {
@@ -23473,7 +23491,7 @@
23473
23491
  // document wide unique overlay ids
23474
23492
  var ids$2 = new IdGenerator('ov');
23475
23493
 
23476
- var LOW_PRIORITY$s = 500;
23494
+ var LOW_PRIORITY$t = 500;
23477
23495
 
23478
23496
  /**
23479
23497
  * @typedef {import('../../core/Canvas.js').default} Canvas
@@ -24103,7 +24121,7 @@
24103
24121
 
24104
24122
  // move integration
24105
24123
 
24106
- eventBus.on('element.changed', LOW_PRIORITY$s, function(e) {
24124
+ eventBus.on('element.changed', LOW_PRIORITY$t, function(e) {
24107
24125
  var element = e.element;
24108
24126
 
24109
24127
  var container = self._getOverlayContainer(element, true);
@@ -25209,7 +25227,7 @@
25209
25227
  * @typedef {import('../../model/Types').Shape} Shape
25210
25228
  */
25211
25229
 
25212
- var LOW_PRIORITY$r = 250;
25230
+ var LOW_PRIORITY$s = 250;
25213
25231
  var ARROW_DOWN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>';
25214
25232
 
25215
25233
  var EMPTY_MARKER = 'bjs-drilldown-empty';
@@ -25234,7 +25252,7 @@
25234
25252
 
25235
25253
  var self = this;
25236
25254
 
25237
- this.executed('shape.toggleCollapse', LOW_PRIORITY$r, function(context) {
25255
+ this.executed('shape.toggleCollapse', LOW_PRIORITY$s, function(context) {
25238
25256
  var shape = context.shape;
25239
25257
 
25240
25258
  // Add overlay to the collapsed shape
@@ -25246,7 +25264,7 @@
25246
25264
  }, true);
25247
25265
 
25248
25266
 
25249
- this.reverted('shape.toggleCollapse', LOW_PRIORITY$r, function(context) {
25267
+ this.reverted('shape.toggleCollapse', LOW_PRIORITY$s, function(context) {
25250
25268
  var shape = context.shape;
25251
25269
 
25252
25270
  // Add overlay to the collapsed shape
@@ -25258,7 +25276,7 @@
25258
25276
  }, true);
25259
25277
 
25260
25278
 
25261
- this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$r,
25279
+ this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$s,
25262
25280
  function(context) {
25263
25281
  var oldParent = context.oldParent,
25264
25282
  newParent = context.newParent || context.parent,
@@ -25275,7 +25293,7 @@
25275
25293
  }, true);
25276
25294
 
25277
25295
 
25278
- this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$r,
25296
+ this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$s,
25279
25297
  function(context) {
25280
25298
  var oldParent = context.oldParent,
25281
25299
  newParent = context.newParent || context.parent,
@@ -25552,7 +25570,7 @@
25552
25570
  return isPrimaryButton(event) || isAuxiliaryButton(event);
25553
25571
  }
25554
25572
 
25555
- var LOW_PRIORITY$q = 500;
25573
+ var LOW_PRIORITY$r = 500;
25556
25574
 
25557
25575
 
25558
25576
  /**
@@ -25749,7 +25767,7 @@
25749
25767
  eventBus.on([
25750
25768
  'shape.changed',
25751
25769
  'connection.changed'
25752
- ], LOW_PRIORITY$q, function(event) {
25770
+ ], LOW_PRIORITY$r, function(event) {
25753
25771
 
25754
25772
  var element = event.element,
25755
25773
  gfx = event.gfx;
@@ -25757,7 +25775,7 @@
25757
25775
  eventBus.fire('interactionEvents.updateHit', { element: element, gfx: gfx });
25758
25776
  });
25759
25777
 
25760
- eventBus.on('interactionEvents.createHit', LOW_PRIORITY$q, function(event) {
25778
+ eventBus.on('interactionEvents.createHit', LOW_PRIORITY$r, function(event) {
25761
25779
  var element = event.element,
25762
25780
  gfx = event.gfx;
25763
25781
 
@@ -26864,7 +26882,7 @@
26864
26882
  Keyboard.prototype.isShift = isShift;
26865
26883
  Keyboard.prototype.isKey = isKey;
26866
26884
 
26867
- var LOW_PRIORITY$p = 500;
26885
+ var LOW_PRIORITY$q = 500;
26868
26886
 
26869
26887
 
26870
26888
  /**
@@ -26880,7 +26898,7 @@
26880
26898
 
26881
26899
  var self = this;
26882
26900
 
26883
- eventBus.on('editorActions.init', LOW_PRIORITY$p, function(event) {
26901
+ eventBus.on('editorActions.init', LOW_PRIORITY$q, function(event) {
26884
26902
 
26885
26903
  var editorActions = event.editorActions;
26886
26904
 
@@ -31218,7 +31236,7 @@
31218
31236
  * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').default<Element>} ContextPadProvider
31219
31237
  */
31220
31238
 
31221
- var LOW_PRIORITY$o = 900;
31239
+ var LOW_PRIORITY$p = 900;
31222
31240
 
31223
31241
  /**
31224
31242
  * A provider for the `Align elements` context pad entry.
@@ -31232,7 +31250,7 @@
31232
31250
  */
31233
31251
  function AlignElementsContextPadProvider(contextPad, popupMenu, translate, canvas) {
31234
31252
 
31235
- contextPad.registerProvider(LOW_PRIORITY$o, this);
31253
+ contextPad.registerProvider(LOW_PRIORITY$p, this);
31236
31254
 
31237
31255
  this._contextPad = contextPad;
31238
31256
  this._popupMenu = popupMenu;
@@ -31862,7 +31880,7 @@
31862
31880
  * @typedef {import('../modeling/Modeling.js').default} Modeling
31863
31881
  */
31864
31882
 
31865
- var LOW_PRIORITY$n = 100;
31883
+ var LOW_PRIORITY$o = 100;
31866
31884
 
31867
31885
 
31868
31886
  /**
@@ -31875,7 +31893,7 @@
31875
31893
  */
31876
31894
  function AutoPlace$1(eventBus, modeling, canvas) {
31877
31895
 
31878
- eventBus.on('autoPlace', LOW_PRIORITY$n, function(context) {
31896
+ eventBus.on('autoPlace', LOW_PRIORITY$o, function(context) {
31879
31897
  var shape = context.shape,
31880
31898
  source = context.source;
31881
31899
 
@@ -32914,6 +32932,9 @@
32914
32932
 
32915
32933
  var DRAG_ACTIVE_CLS = 'djs-drag-active';
32916
32934
 
32935
+ // run after default listeners, i.e. only if the error is not handled
32936
+ var LOW_PRIORITY$n = 500;
32937
+
32917
32938
 
32918
32939
  function preventDefault$1(event) {
32919
32940
  event.preventDefault();
@@ -33171,6 +33192,12 @@
33171
33192
  }
33172
33193
 
33173
33194
 
33195
+ // cancel on unhandled errors, to not report them on every move
33196
+
33197
+ function cancelOnError() {
33198
+ cancel();
33199
+ }
33200
+
33174
33201
  // cancel active drag operation if the user presses
33175
33202
  // the ESC key on the keyboard
33176
33203
 
@@ -33246,11 +33273,17 @@
33246
33273
 
33247
33274
  var wasActive = context.active;
33248
33275
 
33249
- if (wasActive) {
33250
- fire('cancel');
33251
- }
33276
+ // detach, so that errors thrown by cancel listeners
33277
+ // do not re-enter
33278
+ eventBus.off('error', cancelOnError);
33252
33279
 
33253
- previousContext = cleanup(restore);
33280
+ try {
33281
+ if (wasActive) {
33282
+ fire('cancel');
33283
+ }
33284
+ } finally {
33285
+ previousContext = cleanup(restore);
33286
+ }
33254
33287
 
33255
33288
  if (wasActive) {
33256
33289
 
@@ -33261,11 +33294,25 @@
33261
33294
  }
33262
33295
 
33263
33296
  function cleanup(restore) {
33297
+ var previousContext;
33298
+
33299
+ // detach before firing, so that a failing cleanup listener
33300
+ // does not re-enter cancel via cancelOnError
33301
+ eventBus.off('error', cancelOnError);
33302
+
33303
+ try {
33304
+ fire('cleanup');
33305
+ } finally {
33306
+ previousContext = finishCleanup(restore);
33307
+ }
33308
+
33309
+ return previousContext;
33310
+ }
33311
+
33312
+ function finishCleanup(restore) {
33264
33313
  var previousContext,
33265
33314
  endDrag;
33266
33315
 
33267
- fire('cleanup');
33268
-
33269
33316
  // reset cursor
33270
33317
  unset();
33271
33318
 
@@ -33300,14 +33347,13 @@
33300
33347
  // restore selection, unless it has changed
33301
33348
  var previousSelection = context.payload.previousSelection;
33302
33349
 
33350
+ previousContext = context;
33351
+ context = null;
33352
+
33303
33353
  if (restore !== false && previousSelection && !selection.get().length) {
33304
33354
  restoreSelection(previousSelection);
33305
33355
  }
33306
33356
 
33307
- previousContext = context;
33308
-
33309
- context = null;
33310
-
33311
33357
  return previousContext;
33312
33358
  }
33313
33359
 
@@ -33383,6 +33429,8 @@
33383
33429
  isTouch: isTouch
33384
33430
  }, options);
33385
33431
 
33432
+ eventBus.once('error', LOW_PRIORITY$n, cancelOnError);
33433
+
33386
33434
  // skip dom registration if trigger
33387
33435
  // is set to manual (during testing)
33388
33436
  if (!options.manual) {
@@ -40969,6 +41017,26 @@
40969
41017
  return getLabelAdjustment(label, newWaypoints, oldWaypoints, hints);
40970
41018
  }
40971
41019
 
41020
+ // connection labels follow their connection if only one end moves
41021
+ this.preExecute('elements.move', function(event) {
41022
+ var context = event.context,
41023
+ movedShapes = getClosure(context.shapes).allShapes;
41024
+
41025
+ function isMoved(shape) {
41026
+ return !!(movedShapes[shape.id] || (shape.host && movedShapes[shape.host.id]));
41027
+ }
41028
+
41029
+ context.shapes = context.shapes.filter(function(shape) {
41030
+ var connection = shape.labelTarget;
41031
+
41032
+ return !(
41033
+ connection &&
41034
+ connection.waypoints &&
41035
+ isMoved(connection.source) !== isMoved(connection.target)
41036
+ );
41037
+ });
41038
+ });
41039
+
40972
41040
  this.postExecute([
40973
41041
  'connection.layout',
40974
41042
  'connection.updateWaypoints'