bpmn-js 18.31.0 → 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.
package/README.md CHANGED
@@ -71,7 +71,7 @@ building the latest development snapshot.
71
71
 
72
72
  bpmn-js builds on top of a few powerful tools:
73
73
 
74
- * [bpmn-moddle](https://github.com/bpmn-io/bpmn-moddle): Read / write support for BPMN 2.0 XML in the browsers
74
+ * [bpmn-moddle](https://github.com/bpmn-io/bpmn-moddle): Read / write support for BPMN 2.0 XML in the browser
75
75
  * [diagram-js](https://github.com/bpmn-io/diagram-js): Diagram rendering and editing toolkit
76
76
 
77
77
  It is an extensible toolkit, complemented by many [additional utilities](https://github.com/bpmn-io/awesome-bpmn-io).
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v18.31.0
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-01
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.
@@ -19184,7 +19202,7 @@
19184
19202
  bounds = label.bounds;
19185
19203
 
19186
19204
  size = {
19187
- width: Math.max(DEFAULT_LABEL_SIZE$1.width, bounds.width),
19205
+ width: bounds.width,
19188
19206
  height: bounds.height
19189
19207
  };
19190
19208
 
@@ -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 {
@@ -23327,7 +23345,18 @@
23327
23345
 
23328
23346
  text = getLabel(element);
23329
23347
 
23330
- if (text) {
23348
+ if (text && di.label && di.label.bounds && bounds.width > 0) {
23349
+
23350
+ // keep the persisted width, it may have been set by the user
23351
+ var dimensions = this._textRenderer.getDimensions(text, {
23352
+ box: bounds,
23353
+ style: this._textRenderer.getExternalStyle()
23354
+ });
23355
+
23356
+ bounds = assign$1({}, bounds, {
23357
+ height: Math.ceil(dimensions.height)
23358
+ });
23359
+ } else if (text) {
23331
23360
 
23332
23361
  // get corrected bounds from actual layouted text
23333
23362
  bounds = this._textRenderer.getExternalLabelBounds(bounds, text);
@@ -23462,7 +23491,7 @@
23462
23491
  // document wide unique overlay ids
23463
23492
  var ids$2 = new IdGenerator('ov');
23464
23493
 
23465
- var LOW_PRIORITY$s = 500;
23494
+ var LOW_PRIORITY$t = 500;
23466
23495
 
23467
23496
  /**
23468
23497
  * @typedef {import('../../core/Canvas.js').default} Canvas
@@ -24092,7 +24121,7 @@
24092
24121
 
24093
24122
  // move integration
24094
24123
 
24095
- eventBus.on('element.changed', LOW_PRIORITY$s, function(e) {
24124
+ eventBus.on('element.changed', LOW_PRIORITY$t, function(e) {
24096
24125
  var element = e.element;
24097
24126
 
24098
24127
  var container = self._getOverlayContainer(element, true);
@@ -25198,7 +25227,7 @@
25198
25227
  * @typedef {import('../../model/Types').Shape} Shape
25199
25228
  */
25200
25229
 
25201
- var LOW_PRIORITY$r = 250;
25230
+ var LOW_PRIORITY$s = 250;
25202
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>';
25203
25232
 
25204
25233
  var EMPTY_MARKER = 'bjs-drilldown-empty';
@@ -25223,7 +25252,7 @@
25223
25252
 
25224
25253
  var self = this;
25225
25254
 
25226
- this.executed('shape.toggleCollapse', LOW_PRIORITY$r, function(context) {
25255
+ this.executed('shape.toggleCollapse', LOW_PRIORITY$s, function(context) {
25227
25256
  var shape = context.shape;
25228
25257
 
25229
25258
  // Add overlay to the collapsed shape
@@ -25235,7 +25264,7 @@
25235
25264
  }, true);
25236
25265
 
25237
25266
 
25238
- this.reverted('shape.toggleCollapse', LOW_PRIORITY$r, function(context) {
25267
+ this.reverted('shape.toggleCollapse', LOW_PRIORITY$s, function(context) {
25239
25268
  var shape = context.shape;
25240
25269
 
25241
25270
  // Add overlay to the collapsed shape
@@ -25247,7 +25276,7 @@
25247
25276
  }, true);
25248
25277
 
25249
25278
 
25250
- this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$r,
25279
+ this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$s,
25251
25280
  function(context) {
25252
25281
  var oldParent = context.oldParent,
25253
25282
  newParent = context.newParent || context.parent,
@@ -25264,7 +25293,7 @@
25264
25293
  }, true);
25265
25294
 
25266
25295
 
25267
- this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$r,
25296
+ this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$s,
25268
25297
  function(context) {
25269
25298
  var oldParent = context.oldParent,
25270
25299
  newParent = context.newParent || context.parent,
@@ -25541,7 +25570,7 @@
25541
25570
  return isPrimaryButton(event) || isAuxiliaryButton(event);
25542
25571
  }
25543
25572
 
25544
- var LOW_PRIORITY$q = 500;
25573
+ var LOW_PRIORITY$r = 500;
25545
25574
 
25546
25575
 
25547
25576
  /**
@@ -25738,7 +25767,7 @@
25738
25767
  eventBus.on([
25739
25768
  'shape.changed',
25740
25769
  'connection.changed'
25741
- ], LOW_PRIORITY$q, function(event) {
25770
+ ], LOW_PRIORITY$r, function(event) {
25742
25771
 
25743
25772
  var element = event.element,
25744
25773
  gfx = event.gfx;
@@ -25746,7 +25775,7 @@
25746
25775
  eventBus.fire('interactionEvents.updateHit', { element: element, gfx: gfx });
25747
25776
  });
25748
25777
 
25749
- eventBus.on('interactionEvents.createHit', LOW_PRIORITY$q, function(event) {
25778
+ eventBus.on('interactionEvents.createHit', LOW_PRIORITY$r, function(event) {
25750
25779
  var element = event.element,
25751
25780
  gfx = event.gfx;
25752
25781
 
@@ -26853,7 +26882,7 @@
26853
26882
  Keyboard.prototype.isShift = isShift;
26854
26883
  Keyboard.prototype.isKey = isKey;
26855
26884
 
26856
- var LOW_PRIORITY$p = 500;
26885
+ var LOW_PRIORITY$q = 500;
26857
26886
 
26858
26887
 
26859
26888
  /**
@@ -26869,7 +26898,7 @@
26869
26898
 
26870
26899
  var self = this;
26871
26900
 
26872
- eventBus.on('editorActions.init', LOW_PRIORITY$p, function(event) {
26901
+ eventBus.on('editorActions.init', LOW_PRIORITY$q, function(event) {
26873
26902
 
26874
26903
  var editorActions = event.editorActions;
26875
26904
 
@@ -31207,7 +31236,7 @@
31207
31236
  * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').default<Element>} ContextPadProvider
31208
31237
  */
31209
31238
 
31210
- var LOW_PRIORITY$o = 900;
31239
+ var LOW_PRIORITY$p = 900;
31211
31240
 
31212
31241
  /**
31213
31242
  * A provider for the `Align elements` context pad entry.
@@ -31221,7 +31250,7 @@
31221
31250
  */
31222
31251
  function AlignElementsContextPadProvider(contextPad, popupMenu, translate, canvas) {
31223
31252
 
31224
- contextPad.registerProvider(LOW_PRIORITY$o, this);
31253
+ contextPad.registerProvider(LOW_PRIORITY$p, this);
31225
31254
 
31226
31255
  this._contextPad = contextPad;
31227
31256
  this._popupMenu = popupMenu;
@@ -31851,7 +31880,7 @@
31851
31880
  * @typedef {import('../modeling/Modeling.js').default} Modeling
31852
31881
  */
31853
31882
 
31854
- var LOW_PRIORITY$n = 100;
31883
+ var LOW_PRIORITY$o = 100;
31855
31884
 
31856
31885
 
31857
31886
  /**
@@ -31864,7 +31893,7 @@
31864
31893
  */
31865
31894
  function AutoPlace$1(eventBus, modeling, canvas) {
31866
31895
 
31867
- eventBus.on('autoPlace', LOW_PRIORITY$n, function(context) {
31896
+ eventBus.on('autoPlace', LOW_PRIORITY$o, function(context) {
31868
31897
  var shape = context.shape,
31869
31898
  source = context.source;
31870
31899
 
@@ -32903,6 +32932,9 @@
32903
32932
 
32904
32933
  var DRAG_ACTIVE_CLS = 'djs-drag-active';
32905
32934
 
32935
+ // run after default listeners, i.e. only if the error is not handled
32936
+ var LOW_PRIORITY$n = 500;
32937
+
32906
32938
 
32907
32939
  function preventDefault$1(event) {
32908
32940
  event.preventDefault();
@@ -33160,6 +33192,12 @@
33160
33192
  }
33161
33193
 
33162
33194
 
33195
+ // cancel on unhandled errors, to not report them on every move
33196
+
33197
+ function cancelOnError() {
33198
+ cancel();
33199
+ }
33200
+
33163
33201
  // cancel active drag operation if the user presses
33164
33202
  // the ESC key on the keyboard
33165
33203
 
@@ -33235,11 +33273,17 @@
33235
33273
 
33236
33274
  var wasActive = context.active;
33237
33275
 
33238
- if (wasActive) {
33239
- fire('cancel');
33240
- }
33276
+ // detach, so that errors thrown by cancel listeners
33277
+ // do not re-enter
33278
+ eventBus.off('error', cancelOnError);
33241
33279
 
33242
- previousContext = cleanup(restore);
33280
+ try {
33281
+ if (wasActive) {
33282
+ fire('cancel');
33283
+ }
33284
+ } finally {
33285
+ previousContext = cleanup(restore);
33286
+ }
33243
33287
 
33244
33288
  if (wasActive) {
33245
33289
 
@@ -33250,11 +33294,25 @@
33250
33294
  }
33251
33295
 
33252
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) {
33253
33313
  var previousContext,
33254
33314
  endDrag;
33255
33315
 
33256
- fire('cleanup');
33257
-
33258
33316
  // reset cursor
33259
33317
  unset();
33260
33318
 
@@ -33289,14 +33347,13 @@
33289
33347
  // restore selection, unless it has changed
33290
33348
  var previousSelection = context.payload.previousSelection;
33291
33349
 
33350
+ previousContext = context;
33351
+ context = null;
33352
+
33292
33353
  if (restore !== false && previousSelection && !selection.get().length) {
33293
33354
  restoreSelection(previousSelection);
33294
33355
  }
33295
33356
 
33296
- previousContext = context;
33297
-
33298
- context = null;
33299
-
33300
33357
  return previousContext;
33301
33358
  }
33302
33359
 
@@ -33372,6 +33429,8 @@
33372
33429
  isTouch: isTouch
33373
33430
  }, options);
33374
33431
 
33432
+ eventBus.once('error', LOW_PRIORITY$n, cancelOnError);
33433
+
33375
33434
  // skip dom registration if trigger
33376
33435
  // is set to manual (during testing)
33377
33436
  if (!options.manual) {
@@ -40958,6 +41017,26 @@
40958
41017
  return getLabelAdjustment(label, newWaypoints, oldWaypoints, hints);
40959
41018
  }
40960
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
+
40961
41040
  this.postExecute([
40962
41041
  'connection.layout',
40963
41042
  'connection.updateWaypoints'
@@ -68926,12 +69005,21 @@
68926
69005
  * @return {Shape[]}
68927
69006
  */
68928
69007
  BpmnCreateMoveSnapping.prototype.getSnapTargets = function(shape, target) {
68929
- return CreateMoveSnapping.prototype.getSnapTargets.call(this, shape, target)
68930
- .filter(function(snapTarget) {
69008
+ var snapTargets = CreateMoveSnapping.prototype.getSnapTargets.call(this, shape, target);
68931
69009
 
68932
- // do not snap to lanes
68933
- return !is(snapTarget, 'bpmn:Lane');
68934
- });
69010
+ if (shape.labelTarget && shape.labelTarget.parent && shape.labelTarget.parent !== target) {
69011
+
69012
+ // labels stay at root, so include their target's peers
69013
+ snapTargets = snapTargets.concat(
69014
+ CreateMoveSnapping.prototype.getSnapTargets.call(this, shape, shape.labelTarget.parent)
69015
+ );
69016
+ }
69017
+
69018
+ return snapTargets.filter(function(snapTarget, index) {
69019
+
69020
+ // do not snap to lanes
69021
+ return !is(snapTarget, 'bpmn:Lane') && snapTargets.indexOf(snapTarget) === index;
69022
+ });
68935
69023
  };
68936
69024
 
68937
69025
  // helpers //////////