camunda-bpmn-js 4.20.2 → 5.0.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.
@@ -73,7 +73,7 @@
73
73
  * @return {Boolean}
74
74
  */
75
75
  function has$1(target, key) {
76
- return nativeHasOwnProperty$1.call(target, key);
76
+ return !isNil(target) && nativeHasOwnProperty$1.call(target, key);
77
77
  }
78
78
 
79
79
  /**
@@ -162,7 +162,7 @@
162
162
  * @param {Collection<T>} collection
163
163
  * @param {Matcher<T>} matcher
164
164
  *
165
- * @return {number}
165
+ * @return {number | string | undefined}
166
166
  */
167
167
  function findIndex(collection, matcher) {
168
168
 
@@ -1348,26 +1348,6 @@
1348
1348
  return this.list.contains(name);
1349
1349
  };
1350
1350
 
1351
- /**
1352
- * Clear utility
1353
- */
1354
-
1355
- /**
1356
- * Removes all children from the given element
1357
- *
1358
- * @param {SVGElement} element
1359
- * @return {Element} the element (for chaining)
1360
- */
1361
- function clear$1(element) {
1362
- var child;
1363
-
1364
- while ((child = element.firstChild)) {
1365
- element.removeChild(child);
1366
- }
1367
-
1368
- return element;
1369
- }
1370
-
1371
1351
  var ns = {
1372
1352
  svg: 'http://www.w3.org/2000/svg'
1373
1353
  };
@@ -5195,6 +5175,8 @@
5195
5175
 
5196
5176
  return bbox;
5197
5177
  } catch (e) {
5178
+ console.log(e);
5179
+
5198
5180
  return { width: 0, height: 0 };
5199
5181
  }
5200
5182
  }
@@ -6793,7 +6775,7 @@
6793
6775
  // document wide unique overlay ids
6794
6776
  var ids = new IdGenerator('ov');
6795
6777
 
6796
- var LOW_PRIORITY$3 = 500;
6778
+ var LOW_PRIORITY$2 = 500;
6797
6779
 
6798
6780
  /**
6799
6781
  * @typedef {import('../../core/Canvas').default} Canvas
@@ -7423,7 +7405,7 @@
7423
7405
 
7424
7406
  // move integration
7425
7407
 
7426
- eventBus.on('element.changed', LOW_PRIORITY$3, function(e) {
7408
+ eventBus.on('element.changed', LOW_PRIORITY$2, function(e) {
7427
7409
  var element = e.element;
7428
7410
 
7429
7411
  var container = self._getOverlayContainer(element, true);
@@ -7597,7 +7579,7 @@
7597
7579
  * @typedef { (context: CommandContext) => void } ComposeHandlerFunction
7598
7580
  */
7599
7581
 
7600
- var DEFAULT_PRIORITY$2 = 1000;
7582
+ var DEFAULT_PRIORITY$1 = 1000;
7601
7583
 
7602
7584
  /**
7603
7585
  * A utility that can be used to plug into the command execution for
@@ -7664,7 +7646,7 @@
7664
7646
  that = unwrap;
7665
7647
  unwrap = handlerFn;
7666
7648
  handlerFn = priority;
7667
- priority = DEFAULT_PRIORITY$2;
7649
+ priority = DEFAULT_PRIORITY$1;
7668
7650
  }
7669
7651
 
7670
7652
  if (isObject(unwrap)) {
@@ -8461,7 +8443,7 @@
8461
8443
  * @typedef {import('../../model/Types').Shape} Shape
8462
8444
  */
8463
8445
 
8464
- var LOW_PRIORITY$2 = 250;
8446
+ var LOW_PRIORITY$1 = 250;
8465
8447
  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>';
8466
8448
 
8467
8449
  var EMPTY_MARKER = 'bjs-drilldown-empty';
@@ -8486,7 +8468,7 @@
8486
8468
 
8487
8469
  var self = this;
8488
8470
 
8489
- this.executed('shape.toggleCollapse', LOW_PRIORITY$2, function(context) {
8471
+ this.executed('shape.toggleCollapse', LOW_PRIORITY$1, function(context) {
8490
8472
  var shape = context.shape;
8491
8473
 
8492
8474
  // Add overlay to the collapsed shape
@@ -8498,7 +8480,7 @@
8498
8480
  }, true);
8499
8481
 
8500
8482
 
8501
- this.reverted('shape.toggleCollapse', LOW_PRIORITY$2, function(context) {
8483
+ this.reverted('shape.toggleCollapse', LOW_PRIORITY$1, function(context) {
8502
8484
  var shape = context.shape;
8503
8485
 
8504
8486
  // Add overlay to the collapsed shape
@@ -8510,7 +8492,7 @@
8510
8492
  }, true);
8511
8493
 
8512
8494
 
8513
- this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$2,
8495
+ this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$1,
8514
8496
  function(context) {
8515
8497
  var oldParent = context.oldParent,
8516
8498
  newParent = context.newParent || context.parent,
@@ -8527,7 +8509,7 @@
8527
8509
  }, true);
8528
8510
 
8529
8511
 
8530
- this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$2,
8512
+ this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$1,
8531
8513
  function(context) {
8532
8514
  var oldParent = context.oldParent,
8533
8515
  newParent = context.newParent || context.parent,
@@ -8671,409 +8653,6 @@
8671
8653
  subprocessCompatibility: [ 'type', SubprocessCompatibility ]
8672
8654
  };
8673
8655
 
8674
- var LOW_PRIORITY$1 = 500;
8675
-
8676
- var DEFAULT_PRIORITY$1 = 1000;
8677
-
8678
- /**
8679
- * @typedef {import('../../model/Types').Element} Element
8680
- *
8681
- * @typedef {import('./OutlineProvider').default} OutlineProvider
8682
- * @typedef {import('../../core/EventBus').default} EventBus
8683
- * @typedef {import('../../draw/Styles').default} Styles
8684
- */
8685
-
8686
- /**
8687
- * @class
8688
- *
8689
- * A plugin that adds an outline to shapes and connections that may be activated and styled
8690
- * via CSS classes.
8691
- *
8692
- * @param {EventBus} eventBus
8693
- * @param {Styles} styles
8694
- */
8695
- function Outline(eventBus, styles) {
8696
-
8697
- this._eventBus = eventBus;
8698
-
8699
- this.offset = 5;
8700
-
8701
- var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
8702
-
8703
- var self = this;
8704
-
8705
- /**
8706
- * @param {SVGElement} gfx
8707
- *
8708
- * @return {SVGElement} outline
8709
- */
8710
- function createOutline(gfx) {
8711
- var outline = create$1('rect');
8712
-
8713
- attr$1(outline, assign$1({
8714
- x: 0,
8715
- y: 0,
8716
- rx: 4,
8717
- width: 100,
8718
- height: 100
8719
- }, OUTLINE_STYLE));
8720
-
8721
- return outline;
8722
- }
8723
-
8724
- // A low priortity is necessary, because outlines of labels have to be updated
8725
- // after the label bounds have been updated in the renderer.
8726
- eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$1, function(event) {
8727
- var element = event.element,
8728
- gfx = event.gfx;
8729
-
8730
- var outline = query('.djs-outline', gfx);
8731
-
8732
- if (!outline) {
8733
- outline = self.getOutline(element) || createOutline();
8734
- append(gfx, outline);
8735
- }
8736
-
8737
- self.updateShapeOutline(outline, element);
8738
- });
8739
-
8740
- eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
8741
- var element = event.element,
8742
- gfx = event.gfx;
8743
-
8744
- var outline = query('.djs-outline', gfx);
8745
-
8746
- if (!outline) {
8747
- outline = createOutline();
8748
- append(gfx, outline);
8749
- }
8750
-
8751
- self.updateConnectionOutline(outline, element);
8752
- });
8753
- }
8754
-
8755
-
8756
- /**
8757
- * Updates the outline of a shape respecting the dimension of the
8758
- * element and an outline offset.
8759
- *
8760
- * @param {SVGElement} outline
8761
- * @param {Element} element
8762
- */
8763
- Outline.prototype.updateShapeOutline = function(outline, element) {
8764
-
8765
- var updated = false;
8766
- var providers = this._getProviders();
8767
-
8768
- if (providers.length) {
8769
- forEach$1(providers, function(provider) {
8770
- updated = updated || provider.updateOutline(element, outline);
8771
- });
8772
- }
8773
-
8774
- if (!updated) {
8775
- attr$1(outline, {
8776
- x: -this.offset,
8777
- y: -this.offset,
8778
- width: element.width + this.offset * 2,
8779
- height: element.height + this.offset * 2
8780
- });
8781
- }
8782
- };
8783
-
8784
- /**
8785
- * Updates the outline of a connection respecting the bounding box of
8786
- * the connection and an outline offset.
8787
- * Register an outline provider with the given priority.
8788
- *
8789
- * @param {SVGElement} outline
8790
- * @param {Element} connection
8791
- */
8792
- Outline.prototype.updateConnectionOutline = function(outline, connection) {
8793
- var bbox = getBBox(connection);
8794
-
8795
- attr$1(outline, {
8796
- x: bbox.x - this.offset,
8797
- y: bbox.y - this.offset,
8798
- width: bbox.width + this.offset * 2,
8799
- height: bbox.height + this.offset * 2
8800
- });
8801
- };
8802
-
8803
- /**
8804
- * Register an outline provider with the given priority.
8805
- *
8806
- * @param {number} priority
8807
- * @param {OutlineProvider} provider
8808
- */
8809
- Outline.prototype.registerProvider = function(priority, provider) {
8810
- if (!provider) {
8811
- provider = priority;
8812
- priority = DEFAULT_PRIORITY$1;
8813
- }
8814
-
8815
- this._eventBus.on('outline.getProviders', priority, function(event) {
8816
- event.providers.push(provider);
8817
- });
8818
- };
8819
-
8820
- /**
8821
- * Returns the registered outline providers.
8822
- *
8823
- * @returns {OutlineProvider[]}
8824
- */
8825
- Outline.prototype._getProviders = function() {
8826
- var event = this._eventBus.createEvent({
8827
- type: 'outline.getProviders',
8828
- providers: []
8829
- });
8830
-
8831
- this._eventBus.fire(event);
8832
-
8833
- return event.providers;
8834
- };
8835
-
8836
- /**
8837
- * Returns the outline for an element.
8838
- *
8839
- * @param {Element} element
8840
- */
8841
- Outline.prototype.getOutline = function(element) {
8842
- var outline;
8843
- var providers = this._getProviders();
8844
-
8845
- forEach$1(providers, function(provider) {
8846
-
8847
- if (!isFunction(provider.getOutline)) {
8848
- return;
8849
- }
8850
-
8851
- outline = outline || provider.getOutline(element);
8852
- });
8853
-
8854
- return outline;
8855
- };
8856
-
8857
- Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
8858
-
8859
- /**
8860
- * @type { import('didi').ModuleDeclaration }
8861
- */
8862
- var OutlineModule$1 = {
8863
- __init__: [ 'outline' ],
8864
- outline: [ 'type', Outline ]
8865
- };
8866
-
8867
- const DATA_OBJECT_REFERENCE_OUTLINE_PATH = 'M44.7648 11.3263L36.9892 2.64074C36.0451 1.58628 34.5651 0.988708 33.1904 0.988708H5.98667C3.22688 0.988708 0.989624 3.34892 0.989624 6.26039V55.0235C0.989624 57.9349 3.22688 60.2952 5.98667 60.2952H40.966C43.7257 60.2952 45.963 57.9349 45.963 55.0235V14.9459C45.963 13.5998 45.6407 12.3048 44.7648 11.3263Z';
8868
- const DATA_STORE_REFERENCE_OUTLINE_PATH = 'M1.03845 48.1347C1.03845 49.3511 1.07295 50.758 1.38342 52.064C1.69949 53.3938 2.32428 54.7154 3.56383 55.6428C6.02533 57.4841 10.1161 58.7685 14.8212 59.6067C19.5772 60.4538 25.1388 60.8738 30.6831 60.8738C36.2276 60.8738 41.7891 60.4538 46.545 59.6067C51.2504 58.7687 55.3412 57.4842 57.8028 55.6429C59.0424 54.7156 59.6673 53.3938 59.9834 52.064C60.2938 50.7579 60.3285 49.351 60.3285 48.1344V13.8415C60.3285 12.6249 60.2938 11.218 59.9834 9.91171C59.6673 8.58194 59.0423 7.2602 57.8027 6.33294C55.341 4.49168 51.2503 3.20723 46.545 2.36914C41.7891 1.522 36.2276 1.10204 30.6831 1.10205C25.1388 1.10206 19.5772 1.52206 14.8213 2.36923C10.1162 3.20734 6.02543 4.49183 3.5639 6.33314C2.32433 7.26038 1.69951 8.58206 1.38343 9.91181C1.07295 11.2179 1.03845 12.6247 1.03845 13.8411V48.1347Z';
8869
-
8870
- /**
8871
- * @typedef { import('diagram-js/lib/util/Types').Dimensions} Dimensions
8872
- */
8873
-
8874
- /**
8875
- * @type {Dimensions}
8876
- */
8877
- const DATA_OBJECT_REFERENCE_STANDARD_SIZE = { width: 36, height: 50 };
8878
-
8879
- /**
8880
- * @type {Dimensions}
8881
- */
8882
- const DATA_STORE_REFERENCE_STANDARD_SIZE = { width: 50, height: 50 };
8883
-
8884
- /**
8885
- * Create a path element with given attributes.
8886
- * @param {string} path
8887
- * @param {Object} attrs
8888
- * @param {Object} OUTLINE_STYLE
8889
- * @return {SVGElement}
8890
- */
8891
- function createPath(path, attrs, OUTLINE_STYLE) {
8892
- return create$1('path', {
8893
- d: path,
8894
- strokeWidth: 2,
8895
- transform: `translate(${attrs.x}, ${attrs.y})`,
8896
- ...OUTLINE_STYLE
8897
- });
8898
- }
8899
-
8900
- /**
8901
- * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').default } BaseOutlineProvider
8902
- *
8903
- * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').Outline } Outline
8904
- *
8905
- * @typedef { import('diagram-js/lib/draw/Styles').default } Styles
8906
- *
8907
- * @typedef { import('diagram-js/lib/model/Types').Element } Element
8908
- */
8909
-
8910
- const DEFAULT_OFFSET = 5;
8911
-
8912
- /**
8913
- * BPMN-specific outline provider.
8914
- *
8915
- * @implements {BaseOutlineProvider}
8916
- *
8917
- * @param {Outline} outline
8918
- * @param {Styles} styles
8919
- */
8920
- function OutlineProvider(outline, styles) {
8921
-
8922
- this._styles = styles;
8923
- outline.registerProvider(this);
8924
- }
8925
-
8926
- OutlineProvider.$inject = [
8927
- 'outline',
8928
- 'styles'
8929
- ];
8930
-
8931
- /**
8932
- * Returns outline for a given element.
8933
- *
8934
- * @param {Element} element
8935
- *
8936
- * @return {Outline}
8937
- */
8938
- OutlineProvider.prototype.getOutline = function(element) {
8939
-
8940
- const OUTLINE_STYLE = this._styles.cls('djs-outline', [ 'no-fill' ]);
8941
-
8942
- var outline;
8943
-
8944
- if (isLabel(element)) {
8945
- return;
8946
- }
8947
-
8948
- if (is$1(element, 'bpmn:Gateway')) {
8949
- outline = create$1('rect');
8950
-
8951
- assign$1(outline.style, {
8952
- 'transform-box': 'fill-box',
8953
- 'transform': 'rotate(45deg)',
8954
- 'transform-origin': 'center'
8955
- });
8956
-
8957
- attr$1(outline, assign$1({
8958
- x: 2,
8959
- y: 2,
8960
- rx: 4,
8961
- width: element.width - 4,
8962
- height: element.height - 4,
8963
- }, OUTLINE_STYLE));
8964
-
8965
- } else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Group', 'bpmn:CallActivity' ])) {
8966
- outline = create$1('rect');
8967
-
8968
- attr$1(outline, assign$1({
8969
- x: -DEFAULT_OFFSET,
8970
- y: -DEFAULT_OFFSET,
8971
- rx: 14,
8972
- width: element.width + DEFAULT_OFFSET * 2,
8973
- height: element.height + DEFAULT_OFFSET * 2
8974
- }, OUTLINE_STYLE));
8975
-
8976
- } else if (is$1(element, 'bpmn:EndEvent')) {
8977
-
8978
- outline = create$1('circle');
8979
-
8980
- // Extra 1px offset needed due to increased stroke-width of end event
8981
- // which makes it bigger than other events.
8982
-
8983
- attr$1(outline, assign$1({
8984
- cx: element.width / 2,
8985
- cy: element.height / 2,
8986
- r: element.width / 2 + DEFAULT_OFFSET + 1
8987
- }, OUTLINE_STYLE));
8988
-
8989
- } else if (is$1(element, 'bpmn:Event')) {
8990
- outline = create$1('circle');
8991
-
8992
- attr$1(outline, assign$1({
8993
- cx: element.width / 2,
8994
- cy: element.height / 2,
8995
- r: element.width / 2 + DEFAULT_OFFSET
8996
- }, OUTLINE_STYLE));
8997
-
8998
- } else if (is$1(element, 'bpmn:DataObjectReference') && isStandardSize(element, 'bpmn:DataObjectReference')) {
8999
-
9000
- outline = createPath(
9001
- DATA_OBJECT_REFERENCE_OUTLINE_PATH,
9002
- { x: -6, y: -6 },
9003
- OUTLINE_STYLE
9004
- );
9005
-
9006
- } else if (is$1(element, 'bpmn:DataStoreReference') && isStandardSize(element, 'bpmn:DataStoreReference')) {
9007
-
9008
- outline = createPath(
9009
- DATA_STORE_REFERENCE_OUTLINE_PATH,
9010
- { x: -6, y: -6 },
9011
- OUTLINE_STYLE
9012
- );
9013
- }
9014
-
9015
- return outline;
9016
- };
9017
-
9018
- /**
9019
- * Updates the outline for a given element.
9020
- * Returns true if the update for the given element was handled by this provider.
9021
- *
9022
- * @param {Element} element
9023
- * @param {Outline} outline
9024
- * @returns {boolean}
9025
- */
9026
- OutlineProvider.prototype.updateOutline = function(element, outline) {
9027
-
9028
- if (isLabel(element)) {
9029
- return;
9030
- }
9031
-
9032
- if (isAny(element, [ 'bpmn:SubProcess', 'bpmn:Group' ])) {
9033
-
9034
- attr$1(outline, {
9035
- width: element.width + DEFAULT_OFFSET * 2,
9036
- height: element.height + DEFAULT_OFFSET * 2
9037
- });
9038
-
9039
- return true;
9040
-
9041
- } else if (isAny(element, [
9042
- 'bpmn:Event',
9043
- 'bpmn:Gateway',
9044
- 'bpmn:DataStoreReference',
9045
- 'bpmn:DataObjectReference'
9046
- ])) {
9047
- return true;
9048
- }
9049
-
9050
- return false;
9051
- };
9052
-
9053
-
9054
- // helpers //////////
9055
-
9056
- function isStandardSize(element, type) {
9057
- var standardSize;
9058
-
9059
- if (type === 'bpmn:DataObjectReference') {
9060
- standardSize = DATA_OBJECT_REFERENCE_STANDARD_SIZE;
9061
- } else if (type === 'bpmn:DataStoreReference') {
9062
- standardSize = DATA_STORE_REFERENCE_STANDARD_SIZE;
9063
- }
9064
-
9065
- return element.width === standardSize.width
9066
- && element.height === standardSize.height;
9067
- }
9068
-
9069
- var OutlineModule = {
9070
- __depends__: [
9071
- OutlineModule$1
9072
- ],
9073
- __init__: [ 'outlineProvider' ],
9074
- outlineProvider: [ 'type', OutlineProvider ]
9075
- };
9076
-
9077
8656
  /**
9078
8657
  * @typedef {import('../util/Types').Point} Point
9079
8658
  */
@@ -9755,15 +9334,11 @@
9755
9334
  /**
9756
9335
  * @typedef {import('../../core/Canvas').default} Canvas
9757
9336
  * @typedef {import('../../core/EventBus').default} EventBus
9758
- * @typedef {import('./Selection').default} Selection
9759
9337
  */
9760
9338
 
9761
9339
  var MARKER_HOVER = 'hover',
9762
9340
  MARKER_SELECTED = 'selected';
9763
9341
 
9764
- var SELECTION_OUTLINE_PADDING = 6;
9765
-
9766
-
9767
9342
  /**
9768
9343
  * A plugin that adds a visible selection UI to shapes and connections
9769
9344
  * by appending the <code>hover</code> and <code>selected</code> classes to them.
@@ -9774,15 +9349,10 @@
9774
9349
  *
9775
9350
  * @param {Canvas} canvas
9776
9351
  * @param {EventBus} eventBus
9777
- * @param {Selection} selection
9778
9352
  */
9779
- function SelectionVisuals(canvas, eventBus, selection) {
9353
+ function SelectionVisuals(canvas, eventBus) {
9780
9354
  this._canvas = canvas;
9781
9355
 
9782
- var self = this;
9783
-
9784
- this._multiSelectionBox = null;
9785
-
9786
9356
  function addMarker(e, cls) {
9787
9357
  canvas.addMarker(e, cls);
9788
9358
  }
@@ -9823,63 +9393,14 @@
9823
9393
  select(e);
9824
9394
  }
9825
9395
  });
9826
-
9827
- self._updateSelectionOutline(newSelection);
9828
- });
9829
-
9830
-
9831
- eventBus.on('element.changed', function(event) {
9832
- if (selection.isSelected(event.element)) {
9833
- self._updateSelectionOutline(selection.get());
9834
- }
9835
9396
  });
9836
9397
  }
9837
9398
 
9838
9399
  SelectionVisuals.$inject = [
9839
9400
  'canvas',
9840
- 'eventBus',
9841
- 'selection'
9401
+ 'eventBus'
9842
9402
  ];
9843
9403
 
9844
- SelectionVisuals.prototype._updateSelectionOutline = function(selection) {
9845
- var layer = this._canvas.getLayer('selectionOutline');
9846
-
9847
- clear$1(layer);
9848
-
9849
- var enabled = selection.length > 1;
9850
-
9851
- var container = this._canvas.getContainer();
9852
-
9853
- classes$1(container)[enabled ? 'add' : 'remove']('djs-multi-select');
9854
-
9855
- if (!enabled) {
9856
- return;
9857
- }
9858
-
9859
- var bBox = addSelectionOutlinePadding(getBBox(selection));
9860
-
9861
- var rect = create$1('rect');
9862
-
9863
- attr$1(rect, assign$1({
9864
- rx: 3
9865
- }, bBox));
9866
-
9867
- classes$1(rect).add('djs-selection-outline');
9868
-
9869
- append(layer, rect);
9870
- };
9871
-
9872
- // helpers //////////
9873
-
9874
- function addSelectionOutlinePadding(bBox) {
9875
- return {
9876
- x: bBox.x - SELECTION_OUTLINE_PADDING,
9877
- y: bBox.y - SELECTION_OUTLINE_PADDING,
9878
- width: bBox.width + SELECTION_OUTLINE_PADDING * 2,
9879
- height: bBox.height + SELECTION_OUTLINE_PADDING * 2
9880
- };
9881
- }
9882
-
9883
9404
  /**
9884
9405
  * @typedef {import('../../core/Canvas').default} Canvas
9885
9406
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
@@ -10006,7 +9527,6 @@
10006
9527
  __init__: [ 'selectionVisuals', 'selectionBehavior' ],
10007
9528
  __depends__: [
10008
9529
  InteractionEventsModule,
10009
- OutlineModule$1
10010
9530
  ],
10011
9531
  selection: [ 'type', Selection ],
10012
9532
  selectionVisuals: [ 'type', SelectionVisuals ],
@@ -10935,6 +10455,11 @@
10935
10455
  */
10936
10456
  this._rootElement = null;
10937
10457
 
10458
+ /**
10459
+ * @type {boolean}
10460
+ */
10461
+ this._focused = false;
10462
+
10938
10463
  this._init(config || {});
10939
10464
  }
10940
10465
 
@@ -10961,14 +10486,33 @@
10961
10486
  * @param {CanvasConfig} config
10962
10487
  */
10963
10488
  Canvas.prototype._init = function(config) {
10964
-
10965
10489
  const eventBus = this._eventBus;
10966
10490
 
10967
10491
  // html container
10968
10492
  const container = this._container = createContainer(config);
10969
10493
 
10970
10494
  const svg = this._svg = create$1('svg');
10971
- attr$1(svg, { width: '100%', height: '100%' });
10495
+
10496
+ attr$1(svg, {
10497
+ width: '100%',
10498
+ height: '100%'
10499
+ });
10500
+
10501
+ attr(svg, 'tabindex', 0);
10502
+
10503
+ eventBus.on('element.hover', () => {
10504
+ this.restoreFocus();
10505
+ });
10506
+
10507
+ svg.addEventListener('focusin', () => {
10508
+ this._focused = true;
10509
+ eventBus.fire('canvas.focus.changed', { focused: true });
10510
+ });
10511
+
10512
+ svg.addEventListener('focusout', () => {
10513
+ this._focused = false;
10514
+ eventBus.fire('canvas.focus.changed', { focused: false });
10515
+ });
10972
10516
 
10973
10517
  append(container, svg);
10974
10518
 
@@ -11060,6 +10604,31 @@
11060
10604
  delete this._cachedViewbox;
11061
10605
  };
11062
10606
 
10607
+ /**
10608
+ * Sets focus on the canvas SVG element.
10609
+ */
10610
+ Canvas.prototype.focus = function() {
10611
+ this._svg.focus({ preventScroll: true });
10612
+ };
10613
+
10614
+ /**
10615
+ * Sets focus on the canvas SVG element if `document.body` is currently focused.
10616
+ */
10617
+ Canvas.prototype.restoreFocus = function() {
10618
+ if (document.activeElement === document.body) {
10619
+ this.focus();
10620
+ }
10621
+ };
10622
+
10623
+ /**
10624
+ * Returns true if the canvas is focused.
10625
+ *
10626
+ * @return {boolean}
10627
+ */
10628
+ Canvas.prototype.isFocused = function() {
10629
+ return this._focused;
10630
+ };
10631
+
11063
10632
  /**
11064
10633
  * Returns the default layer on which
11065
10634
  * all elements are drawn.
@@ -14527,13 +14096,15 @@
14527
14096
  if (parts.length === 1) {
14528
14097
  localName = name;
14529
14098
  prefix = defaultPrefix;
14530
- } else
14099
+ }
14531
14100
 
14532
14101
  // prefix + local name
14533
- if (parts.length === 2) {
14102
+ else if (parts.length === 2) {
14534
14103
  localName = parts[1];
14535
14104
  prefix = parts[0];
14536
- } else {
14105
+ }
14106
+
14107
+ else {
14537
14108
  throw new Error('expected <prefix:localName> or <localName>, got ' + name);
14538
14109
  }
14539
14110
 
@@ -15435,7 +15006,7 @@
15435
15006
  * sub-set of reserved names (&amp;) as well as
15436
15007
  * hex (&#xaaf;) and decimal (&#1231;) encoded characters.
15437
15008
  *
15438
- * @param {string} str
15009
+ * @param {string} s
15439
15010
  *
15440
15011
  * @return {string} decoded string
15441
15012
  */
@@ -15447,10 +15018,6 @@
15447
15018
  return s;
15448
15019
  }
15449
15020
 
15450
- var XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';
15451
- var XSI_PREFIX = 'xsi';
15452
- var XSI_TYPE$1 = 'xsi:type';
15453
-
15454
15021
  var NON_WHITESPACE_OUTSIDE_ROOT_NODE = 'non-whitespace outside of root node';
15455
15022
 
15456
15023
  function error$1(msg) {
@@ -15495,7 +15062,7 @@
15495
15062
  }
15496
15063
 
15497
15064
  function noopGetContext() {
15498
- return { 'line': 0, 'column': 0 };
15065
+ return { line: 0, column: 0 };
15499
15066
  }
15500
15067
 
15501
15068
  function throwFunc(err) {
@@ -15661,9 +15228,6 @@
15661
15228
  _nsUriToPrefix[k] = nsMap[k];
15662
15229
  }
15663
15230
 
15664
- // FORCE default mapping for schema instance
15665
- _nsUriToPrefix[XSI_URI] = XSI_PREFIX;
15666
-
15667
15231
  isNamespace = true;
15668
15232
  nsUriToPrefix = _nsUriToPrefix;
15669
15233
 
@@ -15987,23 +15551,6 @@
15987
15551
 
15988
15552
  // end: normalize ns attribute name
15989
15553
 
15990
- // normalize xsi:type ns attribute value
15991
- if (name === XSI_TYPE$1) {
15992
- w = value.indexOf(':');
15993
-
15994
- if (w !== -1) {
15995
- nsName = value.substring(0, w);
15996
-
15997
- // handle default prefixes, i.e. xs:String gracefully
15998
- nsName = nsMatrix[nsName] || nsName;
15999
- value = nsName + value.substring(w);
16000
- } else {
16001
- value = defaultAlias + ':' + value;
16002
- }
16003
- }
16004
-
16005
- // end: normalize xsi:type ns attribute value
16006
-
16007
15554
  attrs[name] = value;
16008
15555
  }
16009
15556
 
@@ -16032,23 +15579,6 @@
16032
15579
  : nsName + name.substr(w);
16033
15580
 
16034
15581
  // end: normalize ns attribute name
16035
-
16036
- // normalize xsi:type ns attribute value
16037
- if (name === XSI_TYPE$1) {
16038
- w = value.indexOf(':');
16039
-
16040
- if (w !== -1) {
16041
- nsName = value.substring(0, w);
16042
-
16043
- // handle default prefixes, i.e. xs:String gracefully
16044
- nsName = nsMatrix[nsName] || nsName;
16045
- value = nsName + value.substring(w);
16046
- } else {
16047
- value = defaultAlias + ':' + value;
16048
- }
16049
- }
16050
-
16051
- // end: normalize xsi:type ns attribute value
16052
15582
  }
16053
15583
 
16054
15584
  attrs[name] = value;
@@ -16189,11 +15719,11 @@
16189
15719
  }
16190
15720
  }
16191
15721
 
16192
- w = xml.charCodeAt(i+1);
15722
+ w = xml.charCodeAt(i + 1);
16193
15723
 
16194
15724
  // parse comments + CDATA
16195
15725
  if (w === 33) { // "!"
16196
- q = xml.charCodeAt(i+2);
15726
+ q = xml.charCodeAt(i + 2);
16197
15727
 
16198
15728
  // CDATA section
16199
15729
  if (q === 91 && xml.substr(i + 3, 6) === 'CDATA[') { // 91 == "["
@@ -16477,18 +16007,16 @@
16477
16007
  'xml': 'http://www.w3.org/XML/1998/namespace'
16478
16008
  };
16479
16009
 
16480
- var XSI_TYPE = 'xsi:type';
16010
+ var SERIALIZE_PROPERTY = 'property';
16481
16011
 
16482
- function serializeFormat(element) {
16012
+ function getSerialization(element) {
16483
16013
  return element.xml && element.xml.serialize;
16484
16014
  }
16485
16015
 
16486
- function serializeAsType(element) {
16487
- return serializeFormat(element) === XSI_TYPE;
16488
- }
16016
+ function getSerializationType(element) {
16017
+ const type = getSerialization(element);
16489
16018
 
16490
- function serializeAsProperty(element) {
16491
- return serializeFormat(element) === 'property';
16019
+ return type !== SERIALIZE_PROPERTY && (type || null);
16492
16020
  }
16493
16021
 
16494
16022
  function capitalize(str) {
@@ -16504,12 +16032,20 @@
16504
16032
  return aliasNs.prefix + ':' + capitalize(aliasNs.localName);
16505
16033
  }
16506
16034
 
16035
+ /**
16036
+ * Un-prefix a potentially prefixed type name.
16037
+ *
16038
+ * @param {NsName} nameNs
16039
+ * @param {Object} [pkg]
16040
+ *
16041
+ * @return {string}
16042
+ */
16507
16043
  function prefixedToName(nameNs, pkg) {
16508
16044
 
16509
16045
  var name = nameNs.name,
16510
16046
  localName = nameNs.localName;
16511
16047
 
16512
- var typePrefix = pkg.xml && pkg.xml.typePrefix;
16048
+ var typePrefix = pkg && pkg.xml && pkg.xml.typePrefix;
16513
16049
 
16514
16050
  if (typePrefix && localName.indexOf(typePrefix) === 0) {
16515
16051
  return nameNs.prefix + ':' + localName.slice(typePrefix.length);
@@ -16518,12 +16054,19 @@
16518
16054
  }
16519
16055
  }
16520
16056
 
16521
- function normalizeXsiTypeName(name, model) {
16057
+ function normalizeTypeName(name, nsMap, model) {
16522
16058
 
16523
- var nameNs = parseName(name);
16524
- var pkg = model.getPackage(nameNs.prefix);
16059
+ // normalize against actual NS
16060
+ const nameNs = parseName(name, nsMap.xmlns);
16061
+
16062
+ const normalizedName = `${ nsMap[nameNs.prefix] || nameNs.prefix }:${ nameNs.localName }`;
16063
+
16064
+ const normalizedNameNs = parseName(normalizedName);
16065
+
16066
+ // determine actual type name, based on package-defined prefix
16067
+ var pkg = model.getPackage(normalizedNameNs.prefix);
16525
16068
 
16526
- return prefixedToName(nameNs, pkg);
16069
+ return prefixedToName(normalizedNameNs, pkg);
16527
16070
  }
16528
16071
 
16529
16072
  function error(message) {
@@ -16812,8 +16355,9 @@
16812
16355
  } else {
16813
16356
  if (prop) {
16814
16357
  value = coerceType(prop.type, value);
16815
- } else
16816
- if (name !== 'xmlns') {
16358
+ } else if (name === 'xmlns') {
16359
+ name = ':' + name;
16360
+ } else {
16817
16361
  propNameNs = parseName(name, descriptor.ns.prefix);
16818
16362
 
16819
16363
  // check whether attribute is defined in a well-known namespace
@@ -16846,26 +16390,27 @@
16846
16390
  descriptor = getModdleDescriptor(type);
16847
16391
 
16848
16392
  var propertyName = nameNs.name,
16849
- property = descriptor.propertiesByName[propertyName],
16850
- elementTypeName,
16851
- elementType;
16393
+ property = descriptor.propertiesByName[propertyName];
16852
16394
 
16853
16395
  // search for properties by name first
16854
16396
 
16855
16397
  if (property && !property.isAttr) {
16856
16398
 
16857
- if (serializeAsType(property)) {
16858
- elementTypeName = node.attributes[XSI_TYPE];
16399
+ const serializationType = getSerializationType(property);
16400
+
16401
+ if (serializationType) {
16402
+ const elementTypeName = node.attributes[serializationType];
16859
16403
 
16860
- // xsi type is optional, if it does not exists the
16404
+ // type is optional, if it does not exists the
16861
16405
  // default type is assumed
16862
16406
  if (elementTypeName) {
16863
16407
 
16408
+ // convert the prefix used to the mapped form, but also
16864
16409
  // take possible type prefixes from XML
16865
- // into account, i.e.: xsi:type="t{ActualType}"
16866
- elementTypeName = normalizeXsiTypeName(elementTypeName, model);
16410
+ // into account, i.e.: xsi:type="t{ActualType}",
16411
+ const normalizedTypeName = normalizeTypeName(elementTypeName, node.ns, model);
16867
16412
 
16868
- elementType = model.getType(elementTypeName);
16413
+ const elementType = model.getType(normalizedTypeName);
16869
16414
 
16870
16415
  return assign$1({}, property, {
16871
16416
  effectiveType: getModdleDescriptor(elementType).name
@@ -16880,8 +16425,8 @@
16880
16425
  var pkg = model.getPackage(nameNs.prefix);
16881
16426
 
16882
16427
  if (pkg) {
16883
- elementTypeName = aliasToName(nameNs, pkg);
16884
- elementType = model.getType(elementTypeName);
16428
+ const elementTypeName = aliasToName(nameNs, pkg);
16429
+ const elementType = model.getType(elementTypeName);
16885
16430
 
16886
16431
  // search for collection members later
16887
16432
  property = find(descriptor.properties, function(p) {
@@ -17303,9 +16848,12 @@
17303
16848
  uriMap[p.uri] = p.prefix;
17304
16849
 
17305
16850
  return uriMap;
17306
- }, {
17307
- 'http://www.w3.org/XML/1998/namespace': 'xml' // add default xml ns
17308
- });
16851
+ }, Object.entries(DEFAULT_NS_MAP).reduce(function(map, [ prefix, url ]) {
16852
+ map[url] = prefix;
16853
+
16854
+ return map;
16855
+ }, model.config && model.config.nsMap || {}));
16856
+
17309
16857
  parser
17310
16858
  .ns(uriMap)
17311
16859
  .on('openTag', function(obj, decodeStr, selfClosing, getContext) {
@@ -17406,75 +16954,82 @@
17406
16954
 
17407
16955
  function Namespaces(parent) {
17408
16956
 
17409
- var prefixMap = {};
17410
- var uriMap = {};
17411
- var used = {};
16957
+ this.prefixMap = {};
16958
+ this.uriMap = {};
16959
+ this.used = {};
17412
16960
 
17413
- var wellknown = [];
17414
- var custom = [];
16961
+ this.wellknown = [];
16962
+ this.custom = [];
16963
+ this.parent = parent;
17415
16964
 
17416
- // API
16965
+ this.defaultPrefixMap = parent && parent.defaultPrefixMap || {};
16966
+ }
17417
16967
 
17418
- this.byUri = function(uri) {
17419
- return uriMap[uri] || (
17420
- parent && parent.byUri(uri)
17421
- );
17422
- };
16968
+ Namespaces.prototype.mapDefaultPrefixes = function(defaultPrefixMap) {
16969
+ this.defaultPrefixMap = defaultPrefixMap;
16970
+ };
17423
16971
 
17424
- this.add = function(ns, isWellknown) {
16972
+ Namespaces.prototype.defaultUriByPrefix = function(prefix) {
16973
+ return this.defaultPrefixMap[prefix];
16974
+ };
17425
16975
 
17426
- uriMap[ns.uri] = ns;
16976
+ Namespaces.prototype.byUri = function(uri) {
16977
+ return this.uriMap[uri] || (
16978
+ this.parent && this.parent.byUri(uri)
16979
+ );
16980
+ };
17427
16981
 
17428
- if (isWellknown) {
17429
- wellknown.push(ns);
17430
- } else {
17431
- custom.push(ns);
17432
- }
16982
+ Namespaces.prototype.add = function(ns, isWellknown) {
17433
16983
 
17434
- this.mapPrefix(ns.prefix, ns.uri);
17435
- };
16984
+ this.uriMap[ns.uri] = ns;
17436
16985
 
17437
- this.uriByPrefix = function(prefix) {
17438
- return prefixMap[prefix || 'xmlns'];
17439
- };
16986
+ if (isWellknown) {
16987
+ this.wellknown.push(ns);
16988
+ } else {
16989
+ this.custom.push(ns);
16990
+ }
17440
16991
 
17441
- this.mapPrefix = function(prefix, uri) {
17442
- prefixMap[prefix || 'xmlns'] = uri;
17443
- };
16992
+ this.mapPrefix(ns.prefix, ns.uri);
16993
+ };
17444
16994
 
17445
- this.getNSKey = function(ns) {
17446
- return (ns.prefix !== undefined) ? (ns.uri + '|' + ns.prefix) : ns.uri;
17447
- };
16995
+ Namespaces.prototype.uriByPrefix = function(prefix) {
16996
+ return this.prefixMap[prefix || 'xmlns'] || (
16997
+ this.parent && this.parent.uriByPrefix(prefix)
16998
+ );
16999
+ };
17448
17000
 
17449
- this.logUsed = function(ns) {
17001
+ Namespaces.prototype.mapPrefix = function(prefix, uri) {
17002
+ this.prefixMap[prefix || 'xmlns'] = uri;
17003
+ };
17450
17004
 
17451
- var uri = ns.uri;
17452
- var nsKey = this.getNSKey(ns);
17005
+ Namespaces.prototype.getNSKey = function(ns) {
17006
+ return (ns.prefix !== undefined) ? (ns.uri + '|' + ns.prefix) : ns.uri;
17007
+ };
17453
17008
 
17454
- used[nsKey] = this.byUri(uri);
17009
+ Namespaces.prototype.logUsed = function(ns) {
17455
17010
 
17456
- // Inform parent recursively about the usage of this NS
17457
- if (parent) {
17458
- parent.logUsed(ns);
17459
- }
17460
- };
17011
+ var uri = ns.uri;
17012
+ var nsKey = this.getNSKey(ns);
17461
17013
 
17462
- this.getUsed = function(ns) {
17014
+ this.used[nsKey] = this.byUri(uri);
17463
17015
 
17464
- function isUsed(ns) {
17465
- var nsKey = self.getNSKey(ns);
17016
+ // Inform parent recursively about the usage of this NS
17017
+ if (this.parent) {
17018
+ this.parent.logUsed(ns);
17019
+ }
17020
+ };
17466
17021
 
17467
- return used[nsKey];
17468
- }
17022
+ Namespaces.prototype.getUsed = function(ns) {
17469
17023
 
17470
- var self = this;
17024
+ var allNs = [].concat(this.wellknown, this.custom);
17471
17025
 
17472
- var allNs = [].concat(wellknown, custom);
17026
+ return allNs.filter(ns => {
17027
+ var nsKey = this.getNSKey(ns);
17473
17028
 
17474
- return allNs.filter(isUsed);
17475
- };
17029
+ return this.used[nsKey];
17030
+ });
17031
+ };
17476
17032
 
17477
- }
17478
17033
 
17479
17034
  function lower(string) {
17480
17035
  return string.charAt(0).toLowerCase() + string.slice(1);
@@ -17689,7 +17244,7 @@
17689
17244
  var isGeneric = elementDescriptor.isGeneric;
17690
17245
 
17691
17246
  if (isGeneric) {
17692
- otherAttrs = this.parseGeneric(element);
17247
+ otherAttrs = this.parseGenericNsAttributes(element);
17693
17248
  } else {
17694
17249
  otherAttrs = this.parseNsAttributes(element);
17695
17250
  }
@@ -17703,7 +17258,9 @@
17703
17258
  // compute tag name
17704
17259
  this.tagName = this.addTagName(this.ns);
17705
17260
 
17706
- if (!isGeneric) {
17261
+ if (isGeneric) {
17262
+ this.parseGenericContainments(element);
17263
+ } else {
17707
17264
  properties = getSerializableProperties(element);
17708
17265
 
17709
17266
  this.parseAttributes(filterAttributes(properties));
@@ -17766,35 +17323,29 @@
17766
17323
  }
17767
17324
  };
17768
17325
 
17769
- ElementSerializer.prototype.parseGeneric = function(element) {
17770
-
17771
- var self = this,
17772
- body = this.body;
17773
-
17774
- var attributes = [];
17326
+ ElementSerializer.prototype.parseGenericNsAttributes = function(element) {
17775
17327
 
17776
- forEach$1(element, function(val, key) {
17328
+ return Object.entries(element).filter(
17329
+ ([ key, value ]) => !key.startsWith('$') && this.parseNsAttribute(element, key, value)
17330
+ ).map(
17331
+ ([ key, value ]) => ({ name: key, value: value })
17332
+ );
17333
+ };
17777
17334
 
17778
- var nonNsAttr;
17335
+ ElementSerializer.prototype.parseGenericContainments = function(element) {
17336
+ var body = element.$body;
17779
17337
 
17780
- if (key === '$body') {
17781
- body.push(new BodySerializer().build({ type: 'String' }, val));
17782
- } else
17783
- if (key === '$children') {
17784
- forEach$1(val, function(child) {
17785
- body.push(new ElementSerializer(self).build(child));
17786
- });
17787
- } else
17788
- if (key.indexOf('$') !== 0) {
17789
- nonNsAttr = self.parseNsAttribute(element, key, val);
17338
+ if (body) {
17339
+ this.body.push(new BodySerializer().build({ type: 'String' }, body));
17340
+ }
17790
17341
 
17791
- if (nonNsAttr) {
17792
- attributes.push({ name: key, value: val });
17793
- }
17794
- }
17795
- });
17342
+ var children = element.$children;
17796
17343
 
17797
- return attributes;
17344
+ if (children) {
17345
+ forEach$1(children, child => {
17346
+ this.body.push(new ElementSerializer(this).build(child));
17347
+ });
17348
+ }
17798
17349
  };
17799
17350
 
17800
17351
  ElementSerializer.prototype.parseNsAttribute = function(element, name, value) {
@@ -17841,7 +17392,7 @@
17841
17392
  * @param {Object} element
17842
17393
  * @return {Array<Object>}
17843
17394
  */
17844
- ElementSerializer.prototype.parseNsAttributes = function(element, attrs) {
17395
+ ElementSerializer.prototype.parseNsAttributes = function(element) {
17845
17396
  var self = this;
17846
17397
 
17847
17398
  var genericAttrs = element.$attrs;
@@ -17869,21 +17420,16 @@
17869
17420
 
17870
17421
  forEach$1(attributes, function(attr) {
17871
17422
 
17872
- // do not serialize xsi:type attribute
17873
- // it is set manually based on the actual implementation type
17874
- if (attr.name === XSI_TYPE) {
17875
- return;
17876
- }
17877
-
17878
17423
  try {
17879
17424
  self.addAttribute(self.nsAttributeName(attr.name), attr.value);
17880
17425
  } catch (e) {
17881
- /* global console */
17882
17426
 
17883
- console.warn(
17884
- 'missing namespace information for ',
17885
- attr.name, '=', attr.value, 'on', element,
17886
- e);
17427
+ // eslint-disable-next-line no-undef
17428
+ typeof console !== 'undefined' && console.warn(
17429
+ `missing namespace information for <${
17430
+ attr.name
17431
+ }=${ attr.value }> on`, element, e
17432
+ );
17887
17433
  }
17888
17434
  });
17889
17435
  };
@@ -17905,13 +17451,11 @@
17905
17451
 
17906
17452
  if (p.isBody) {
17907
17453
  body.push(new BodySerializer().build(p, value[0]));
17908
- } else
17909
- if (isSimple(p.type)) {
17454
+ } else if (isSimple(p.type)) {
17910
17455
  forEach$1(value, function(v) {
17911
17456
  body.push(new ValueSerializer(self.addTagName(self.nsPropertyTagName(p))).build(p, v));
17912
17457
  });
17913
- } else
17914
- if (isReference) {
17458
+ } else if (isReference) {
17915
17459
  forEach$1(value, function(v) {
17916
17460
  body.push(new ReferenceSerializer(self.addTagName(self.nsPropertyTagName(p))).build(v));
17917
17461
  });
@@ -17919,17 +17463,17 @@
17919
17463
 
17920
17464
  // allow serialization via type
17921
17465
  // rather than element name
17922
- var asType = serializeAsType(p),
17923
- asProperty = serializeAsProperty(p);
17466
+ var serialization = getSerialization(p);
17924
17467
 
17925
17468
  forEach$1(value, function(v) {
17926
17469
  var serializer;
17927
17470
 
17928
- if (asType) {
17929
- serializer = new TypeSerializer(self, p);
17930
- } else
17931
- if (asProperty) {
17932
- serializer = new ElementSerializer(self, p);
17471
+ if (serialization) {
17472
+ if (serialization === SERIALIZE_PROPERTY) {
17473
+ serializer = new ElementSerializer(self, p);
17474
+ } else {
17475
+ serializer = new TypeSerializer(self, p, serialization);
17476
+ }
17933
17477
  } else {
17934
17478
  serializer = new ElementSerializer(self);
17935
17479
  }
@@ -17977,9 +17521,7 @@
17977
17521
  };
17978
17522
 
17979
17523
  ElementSerializer.prototype.logNamespaceUsed = function(ns, local) {
17980
- var element = this.element,
17981
- model = element.$model,
17982
- namespaces = this.getNamespaces(local);
17524
+ var namespaces = this.getNamespaces(local);
17983
17525
 
17984
17526
  // ns may be
17985
17527
  //
@@ -17997,7 +17539,7 @@
17997
17539
  return { localName: ns.localName };
17998
17540
  }
17999
17541
 
18000
- wellknownUri = DEFAULT_NS_MAP[prefix] || model && (model.getPackage(prefix) || {}).uri;
17542
+ wellknownUri = namespaces.defaultUriByPrefix(prefix);
18001
17543
 
18002
17544
  uri = uri || wellknownUri || namespaces.uriByPrefix(prefix);
18003
17545
 
@@ -18007,6 +17549,11 @@
18007
17549
 
18008
17550
  ns = namespaces.byUri(uri);
18009
17551
 
17552
+ // register new default prefix <xmlns> in local scope
17553
+ if (!ns && !prefix) {
17554
+ ns = this.logNamespace({ uri }, wellknownUri === uri, true);
17555
+ }
17556
+
18010
17557
  if (!ns) {
18011
17558
  newPrefix = prefix;
18012
17559
  idx = 1;
@@ -18038,8 +17585,7 @@
18038
17585
 
18039
17586
  if (!p.isMany) {
18040
17587
  value = value.id;
18041
- }
18042
- else {
17588
+ } else {
18043
17589
  var values = [];
18044
17590
  forEach$1(value, function(v) {
18045
17591
  values.push(v.id);
@@ -18143,20 +17689,25 @@
18143
17689
  /**
18144
17690
  * A serializer for types that handles serialization of data types
18145
17691
  */
18146
- function TypeSerializer(parent, propertyDescriptor) {
17692
+ function TypeSerializer(parent, propertyDescriptor, serialization) {
18147
17693
  ElementSerializer.call(this, parent, propertyDescriptor);
17694
+
17695
+ this.serialization = serialization;
18148
17696
  }
18149
17697
 
18150
17698
  inherits(TypeSerializer, ElementSerializer);
18151
17699
 
18152
17700
  TypeSerializer.prototype.parseNsAttributes = function(element) {
18153
17701
 
18154
- // extracted attributes
18155
- var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element);
17702
+ // extracted attributes with serialization attribute
17703
+ // <type=typeName> stripped; it may be later
17704
+ var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element).filter(
17705
+ attr => attr.name !== this.serialization
17706
+ );
18156
17707
 
18157
17708
  var descriptor = element.$descriptor;
18158
17709
 
18159
- // only serialize xsi:type if necessary
17710
+ // only serialize <type=typeName> if necessary
18160
17711
  if (descriptor.name === this.propertyDescriptor.type) {
18161
17712
  return attributes;
18162
17713
  }
@@ -18171,7 +17722,7 @@
18171
17722
  typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
18172
17723
 
18173
17724
  this.addAttribute(
18174
- this.nsAttributeName(XSI_TYPE),
17725
+ this.nsAttributeName(this.serialization),
18175
17726
  (typeNs.prefix ? typeNs.prefix + ':' : '') + typePrefix + descriptor.ns.localName
18176
17727
  );
18177
17728
 
@@ -18244,7 +17795,13 @@
18244
17795
  formatingWriter.append(XML_PREAMBLE);
18245
17796
  }
18246
17797
 
18247
- new ElementSerializer().build(tree).serializeTo(formatingWriter);
17798
+ var serializer = new ElementSerializer();
17799
+
17800
+ var model = tree.$model;
17801
+
17802
+ serializer.getNamespaces().mapDefaultPrefixes(getDefaultPrefixMappings(model));
17803
+
17804
+ serializer.build(tree).serializeTo(formatingWriter);
18248
17805
 
18249
17806
  if (!writer) {
18250
17807
  return internalWriter.value;
@@ -18256,6 +17813,39 @@
18256
17813
  };
18257
17814
  }
18258
17815
 
17816
+
17817
+ // helpers ///////////
17818
+
17819
+ /**
17820
+ * @param {Moddle} model
17821
+ *
17822
+ * @return { Record<string, string> } map from prefix to URI
17823
+ */
17824
+ function getDefaultPrefixMappings(model) {
17825
+
17826
+ const nsMap = model.config && model.config.nsMap || {};
17827
+
17828
+ const prefixMap = {};
17829
+
17830
+ // { prefix -> uri }
17831
+ for (const prefix in DEFAULT_NS_MAP) {
17832
+ prefixMap[prefix] = DEFAULT_NS_MAP[prefix];
17833
+ }
17834
+
17835
+ // { uri -> prefix }
17836
+ for (const uri in nsMap) {
17837
+ const prefix = nsMap[uri];
17838
+
17839
+ prefixMap[prefix] = uri;
17840
+ }
17841
+
17842
+ for (const pkg of model.getPackages()) {
17843
+ prefixMap[pkg.prefix] = pkg.uri;
17844
+ }
17845
+
17846
+ return prefixMap;
17847
+ }
17848
+
18259
17849
  /**
18260
17850
  * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 xml files.
18261
17851
  *
@@ -21982,7 +21572,7 @@
21982
21572
  associations: associations$6
21983
21573
  };
21984
21574
 
21985
- var packages = {
21575
+ const packages = {
21986
21576
  bpmn: BpmnPackage,
21987
21577
  bpmndi: BpmnDiPackage,
21988
21578
  dc: DcPackage,
@@ -21991,8 +21581,8 @@
21991
21581
  color: BpmnInColorPackage
21992
21582
  };
21993
21583
 
21994
- function simple(additionalPackages, options) {
21995
- var pks = assign$1({}, packages, additionalPackages);
21584
+ function SimpleBpmnModdle(additionalPackages, options) {
21585
+ const pks = assign$1({}, packages, additionalPackages);
21996
21586
 
21997
21587
  return new BpmnModdle(pks, options);
21998
21588
  }
@@ -23483,7 +23073,7 @@
23483
23073
  BaseViewer.prototype._createModdle = function(options) {
23484
23074
  const moddleOptions = assign$1({}, this._moddleExtensions, options.moddleExtensions);
23485
23075
 
23486
- return new simple(moddleOptions);
23076
+ return new SimpleBpmnModdle(moddleOptions);
23487
23077
  };
23488
23078
 
23489
23079
  BaseViewer.prototype._modules = [];
@@ -23645,7 +23235,6 @@
23645
23235
  Viewer$1.prototype._modules = [
23646
23236
  CoreModule$1,
23647
23237
  DrilldownModdule,
23648
- OutlineModule,
23649
23238
  OverlaysModule,
23650
23239
  SelectionModule,
23651
23240
  TranslateModule
@@ -23940,9 +23529,7 @@
23940
23529
  ],
23941
23530
  meta: {
23942
23531
  allowedIn: [
23943
- "zeebe:ZeebeServiceTask",
23944
- "bpmn:ReceiveTask",
23945
- "bpmn:SubProcess"
23532
+ "bpmn:MultiInstanceLoopCharacteristics"
23946
23533
  ]
23947
23534
  },
23948
23535
  properties: [