camunda-bpmn-js 3.11.0 → 3.12.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.
@@ -27,6 +27,10 @@
27
27
  return obj !== undefined;
28
28
  }
29
29
 
30
+ function isNil(obj) {
31
+ return obj == null;
32
+ }
33
+
30
34
  function isArray$2(obj) {
31
35
  return nativeToString$1.call(obj) === '[object Array]';
32
36
  }
@@ -475,6 +479,58 @@
475
479
  return Object.assign(target, ...others);
476
480
  }
477
481
 
482
+ /**
483
+ * Sets a nested property of a given object to the specified value.
484
+ *
485
+ * This mutates the object and returns it.
486
+ *
487
+ * @template T
488
+ *
489
+ * @param {T} target The target of the set operation.
490
+ * @param {(string|number)[]} path The path to the nested value.
491
+ * @param {any} value The value to set.
492
+ *
493
+ * @return {T}
494
+ */
495
+ function set$2(target, path, value) {
496
+
497
+ let currentTarget = target;
498
+
499
+ forEach$1(path, function(key, idx) {
500
+
501
+ if (typeof key !== 'number' && typeof key !== 'string') {
502
+ throw new Error('illegal key type: ' + typeof key + '. Key should be of type number or string.');
503
+ }
504
+
505
+ if (key === 'constructor') {
506
+ throw new Error('illegal key: constructor');
507
+ }
508
+
509
+ if (key === '__proto__') {
510
+ throw new Error('illegal key: __proto__');
511
+ }
512
+
513
+ let nextKey = path[idx + 1];
514
+ let nextTarget = currentTarget[key];
515
+
516
+ if (isDefined(nextKey) && isNil(nextTarget)) {
517
+ nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
518
+ }
519
+
520
+ if (isUndefined$2(nextKey)) {
521
+ if (isUndefined$2(value)) {
522
+ delete currentTarget[key];
523
+ } else {
524
+ currentTarget[key] = value;
525
+ }
526
+ } else {
527
+ currentTarget = nextTarget;
528
+ }
529
+ });
530
+
531
+ return target;
532
+ }
533
+
478
534
  /**
479
535
  * Pick properties from the given target.
480
536
  *
@@ -12355,36 +12411,17 @@
12355
12411
  }
12356
12412
  };
12357
12413
 
12358
- function getDefaultExportFromCjs (x) {
12359
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
12360
- }
12361
-
12362
- var objectRefs = {exports: {}};
12363
-
12364
- var collection = {};
12365
-
12366
- /**
12367
- * An empty collection stub. Use {@link RefsCollection.extend} to extend a
12368
- * collection with ref semantics.
12369
- *
12370
- * @class RefsCollection
12371
- */
12372
-
12373
12414
  /**
12374
12415
  * Extends a collection with {@link Refs} aware methods
12375
12416
  *
12376
- * @memberof RefsCollection
12377
- * @static
12378
- *
12379
- * @param {Array<Object>} collection
12380
- * @param {Refs} refs instance
12381
- * @param {Object} property represented by the collection
12382
- * @param {Object} target object the collection is attached to
12417
+ * @param {Array<Object>} collection
12418
+ * @param {Refs} refs instance
12419
+ * @param {Object} property represented by the collection
12420
+ * @param {Object} target object the collection is attached to
12383
12421
  *
12384
12422
  * @return {RefsCollection<Object>} the extended array
12385
12423
  */
12386
12424
  function extend(collection, refs, property, target) {
12387
-
12388
12425
  var inverseProperty = property.inverse;
12389
12426
 
12390
12427
  /**
@@ -12395,7 +12432,7 @@
12395
12432
  * @param {Object} element the element to remove
12396
12433
  */
12397
12434
  Object.defineProperty(collection, 'remove', {
12398
- value: function(element) {
12435
+ value: function (element) {
12399
12436
  var idx = this.indexOf(element);
12400
12437
  if (idx !== -1) {
12401
12438
  this.splice(idx, 1);
@@ -12403,7 +12440,6 @@
12403
12440
  // unset inverse
12404
12441
  refs.unset(element, inverseProperty, target);
12405
12442
  }
12406
-
12407
12443
  return element;
12408
12444
  }
12409
12445
  });
@@ -12416,7 +12452,7 @@
12416
12452
  * @param {Object} element the element to check for
12417
12453
  */
12418
12454
  Object.defineProperty(collection, 'contains', {
12419
- value: function(element) {
12455
+ value: function (element) {
12420
12456
  return this.indexOf(element) !== -1;
12421
12457
  }
12422
12458
  });
@@ -12431,12 +12467,9 @@
12431
12467
  * (possibly moving other elements around)
12432
12468
  */
12433
12469
  Object.defineProperty(collection, 'add', {
12434
- value: function(element, idx) {
12435
-
12470
+ value: function (element, idx) {
12436
12471
  var currentIdx = this.indexOf(element);
12437
-
12438
12472
  if (typeof idx === 'undefined') {
12439
-
12440
12473
  if (currentIdx !== -1) {
12441
12474
  // element already in collection (!)
12442
12475
  return;
@@ -12448,14 +12481,12 @@
12448
12481
 
12449
12482
  // handle already in collection
12450
12483
  if (currentIdx !== -1) {
12451
-
12452
12484
  // remove element from currentIdx
12453
12485
  this.splice(currentIdx, 1);
12454
12486
  }
12455
12487
 
12456
12488
  // add element at idx
12457
12489
  this.splice(idx, 0, element);
12458
-
12459
12490
  if (currentIdx === -1) {
12460
12491
  // set inverse, unless element was
12461
12492
  // in collection already
@@ -12469,69 +12500,53 @@
12469
12500
  Object.defineProperty(collection, '__refs_collection', {
12470
12501
  value: true
12471
12502
  });
12472
-
12473
12503
  return collection;
12474
12504
  }
12475
12505
 
12476
-
12506
+ /**
12507
+ * Checks if a given collection is extended
12508
+ *
12509
+ * @param {Array<Object>} collection
12510
+ *
12511
+ * @return {boolean}
12512
+ */
12477
12513
  function isExtended(collection) {
12478
12514
  return collection.__refs_collection === true;
12479
12515
  }
12480
12516
 
12481
- collection.extend = extend;
12482
-
12483
- collection.isExtended = isExtended;
12484
-
12485
- var Collection = collection;
12486
-
12487
12517
  function hasOwnProperty$1(e, property) {
12488
12518
  return Object.prototype.hasOwnProperty.call(e, property.name || property);
12489
12519
  }
12490
-
12491
12520
  function defineCollectionProperty(ref, property, target) {
12492
-
12493
- var collection = Collection.extend(target[property.name] || [], ref, property, target);
12494
-
12521
+ var collection = extend(target[property.name] || [], ref, property, target);
12495
12522
  Object.defineProperty(target, property.name, {
12496
12523
  enumerable: property.enumerable,
12497
12524
  value: collection
12498
12525
  });
12499
-
12500
12526
  if (collection.length) {
12501
-
12502
- collection.forEach(function(o) {
12527
+ collection.forEach(function (o) {
12503
12528
  ref.set(o, property.inverse, target);
12504
12529
  });
12505
12530
  }
12506
12531
  }
12507
-
12508
-
12509
12532
  function defineProperty$1(ref, property, target) {
12510
-
12511
12533
  var inverseProperty = property.inverse;
12512
-
12513
12534
  var _value = target[property.name];
12514
-
12515
12535
  Object.defineProperty(target, property.name, {
12516
12536
  configurable: property.configurable,
12517
12537
  enumerable: property.enumerable,
12518
-
12519
- get: function() {
12538
+ get: function () {
12520
12539
  return _value;
12521
12540
  },
12522
-
12523
- set: function(value) {
12524
-
12541
+ set: function (value) {
12525
12542
  // return if we already performed all changes
12526
12543
  if (value === _value) {
12527
12544
  return;
12528
12545
  }
12529
-
12530
12546
  var old = _value;
12531
12547
 
12532
12548
  // temporary set null
12533
12549
  _value = null;
12534
-
12535
12550
  if (old) {
12536
12551
  ref.unset(old, inverseProperty, target);
12537
12552
  }
@@ -12543,7 +12558,6 @@
12543
12558
  ref.set(_value, inverseProperty, target);
12544
12559
  }
12545
12560
  });
12546
-
12547
12561
  }
12548
12562
 
12549
12563
  /**
@@ -12589,16 +12603,14 @@
12589
12603
  *
12590
12604
  * wheels[0].car // undefined
12591
12605
  */
12592
- function Refs$1(a, b) {
12593
-
12594
- if (!(this instanceof Refs$1)) {
12595
- return new Refs$1(a, b);
12606
+ function Refs(a, b) {
12607
+ if (!(this instanceof Refs)) {
12608
+ return new Refs(a, b);
12596
12609
  }
12597
12610
 
12598
12611
  // link
12599
12612
  a.inverse = b;
12600
12613
  b.inverse = a;
12601
-
12602
12614
  this.props = {};
12603
12615
  this.props[a.name] = a;
12604
12616
  this.props[b.name] = b;
@@ -12613,43 +12625,34 @@
12613
12625
  * @param {Object} target
12614
12626
  * @param {String} property
12615
12627
  */
12616
- Refs$1.prototype.bind = function(target, property) {
12628
+ Refs.prototype.bind = function (target, property) {
12617
12629
  if (typeof property === 'string') {
12618
12630
  if (!this.props[property]) {
12619
12631
  throw new Error('no property <' + property + '> in ref');
12620
12632
  }
12621
12633
  property = this.props[property];
12622
12634
  }
12623
-
12624
12635
  if (property.collection) {
12625
12636
  defineCollectionProperty(this, property, target);
12626
12637
  } else {
12627
12638
  defineProperty$1(this, property, target);
12628
12639
  }
12629
12640
  };
12630
-
12631
- Refs$1.prototype.ensureRefsCollection = function(target, property) {
12632
-
12641
+ Refs.prototype.ensureRefsCollection = function (target, property) {
12633
12642
  var collection = target[property.name];
12634
-
12635
- if (!Collection.isExtended(collection)) {
12643
+ if (!isExtended(collection)) {
12636
12644
  defineCollectionProperty(this, property, target);
12637
12645
  }
12638
-
12639
12646
  return collection;
12640
12647
  };
12641
-
12642
- Refs$1.prototype.ensureBound = function(target, property) {
12648
+ Refs.prototype.ensureBound = function (target, property) {
12643
12649
  if (!hasOwnProperty$1(target, property)) {
12644
12650
  this.bind(target, property);
12645
12651
  }
12646
12652
  };
12647
-
12648
- Refs$1.prototype.unset = function(target, property, value) {
12649
-
12653
+ Refs.prototype.unset = function (target, property, value) {
12650
12654
  if (target) {
12651
12655
  this.ensureBound(target, property);
12652
-
12653
12656
  if (property.collection) {
12654
12657
  this.ensureRefsCollection(target, property).remove(value);
12655
12658
  } else {
@@ -12657,12 +12660,9 @@
12657
12660
  }
12658
12661
  }
12659
12662
  };
12660
-
12661
- Refs$1.prototype.set = function(target, property, value) {
12662
-
12663
+ Refs.prototype.set = function (target, property, value) {
12663
12664
  if (target) {
12664
12665
  this.ensureBound(target, property);
12665
-
12666
12666
  if (property.collection) {
12667
12667
  this.ensureRefsCollection(target, property).add(value);
12668
12668
  } else {
@@ -12671,15 +12671,6 @@
12671
12671
  }
12672
12672
  };
12673
12673
 
12674
- var refs = Refs$1;
12675
-
12676
- objectRefs.exports = refs;
12677
-
12678
- objectRefs.exports.Collection = collection;
12679
-
12680
- var objectRefsExports = objectRefs.exports;
12681
- var Refs = /*@__PURE__*/getDefaultExportFromCjs(objectRefsExports);
12682
-
12683
12674
  var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
12684
12675
  labelRefs = new Refs({ name: 'labels', enumerable: true, collection: true }, { name: 'labelTarget' }),
12685
12676
  attacherRefs = new Refs({ name: 'attachers', collection: true }, { name: 'host' }),
@@ -14496,6 +14487,17 @@
14496
14487
  this.idProperty = p;
14497
14488
  };
14498
14489
 
14490
+ DescriptorBuilder.prototype.assertNotTrait = function(typeDescriptor) {
14491
+
14492
+ const _extends = typeDescriptor.extends || [];
14493
+
14494
+ if (_extends.length) {
14495
+ throw new Error(
14496
+ `cannot create <${ typeDescriptor.name }> extending <${ typeDescriptor.extends }>`
14497
+ );
14498
+ }
14499
+ };
14500
+
14499
14501
  DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
14500
14502
  var propertyName = p.name,
14501
14503
  definedProperty = this.propertiesByName[propertyName];
@@ -14514,6 +14516,10 @@
14514
14516
 
14515
14517
  DescriptorBuilder.prototype.addTrait = function(t, inherited) {
14516
14518
 
14519
+ if (inherited) {
14520
+ this.assertNotTrait(t);
14521
+ }
14522
+
14517
14523
  var typesByName = this.allTypesByName,
14518
14524
  types = this.allTypes;
14519
14525
 
@@ -14647,7 +14653,9 @@
14647
14653
  });
14648
14654
 
14649
14655
  forEach$1(type.extends, bind$2(function(extendsName) {
14650
- var extended = this.typeMap[extendsName];
14656
+ var extendsNameNs = parseName(extendsName, ns.prefix);
14657
+
14658
+ var extended = this.typeMap[extendsNameNs.name];
14651
14659
 
14652
14660
  extended.traits = extended.traits || [];
14653
14661
  extended.traits.push(name);
@@ -14676,24 +14684,33 @@
14676
14684
 
14677
14685
  var self = this;
14678
14686
 
14687
+ /**
14688
+ * Traverse the selected super type or trait
14689
+ *
14690
+ * @param {String} cls
14691
+ * @param {Boolean} [trait=false]
14692
+ */
14693
+ function traverse(cls, trait) {
14694
+ var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
14695
+ self.mapTypes(parentNs, iterator, trait);
14696
+ }
14697
+
14679
14698
  /**
14680
14699
  * Traverse the selected trait.
14681
14700
  *
14682
14701
  * @param {String} cls
14683
14702
  */
14684
14703
  function traverseTrait(cls) {
14685
- return traverseSuper(cls, true);
14704
+ return traverse(cls, true);
14686
14705
  }
14687
14706
 
14688
14707
  /**
14689
- * Traverse the selected super type or trait
14708
+ * Traverse the selected super type
14690
14709
  *
14691
14710
  * @param {String} cls
14692
- * @param {Boolean} [trait=false]
14693
14711
  */
14694
- function traverseSuper(cls, trait) {
14695
- var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
14696
- self.mapTypes(parentNs, iterator, trait);
14712
+ function traverseSuper(cls) {
14713
+ return traverse(cls, false);
14697
14714
  }
14698
14715
 
14699
14716
  if (!type) {
@@ -14776,7 +14793,7 @@
14776
14793
  throw new TypeError('property name must be a non-empty string');
14777
14794
  }
14778
14795
 
14779
- var property = this.model.getPropertyDescriptor(target, name);
14796
+ var property = this.getProperty(target, name);
14780
14797
 
14781
14798
  var propertyName = property && property.name;
14782
14799
 
@@ -14787,7 +14804,7 @@
14787
14804
  if (property) {
14788
14805
  delete target[propertyName];
14789
14806
  } else {
14790
- delete target.$attrs[name];
14807
+ delete target.$attrs[stripGlobal(name)];
14791
14808
  }
14792
14809
  } else {
14793
14810
 
@@ -14800,7 +14817,7 @@
14800
14817
  defineProperty(target, property, value);
14801
14818
  }
14802
14819
  } else {
14803
- target.$attrs[name] = value;
14820
+ target.$attrs[stripGlobal(name)] = value;
14804
14821
  }
14805
14822
  }
14806
14823
  };
@@ -14815,10 +14832,10 @@
14815
14832
  */
14816
14833
  Properties.prototype.get = function(target, name) {
14817
14834
 
14818
- var property = this.model.getPropertyDescriptor(target, name);
14835
+ var property = this.getProperty(target, name);
14819
14836
 
14820
14837
  if (!property) {
14821
- return target.$attrs[name];
14838
+ return target.$attrs[stripGlobal(name)];
14822
14839
  }
14823
14840
 
14824
14841
  var propertyName = property.name;
@@ -14872,6 +14889,44 @@
14872
14889
  this.define(target, '$model', { value: model });
14873
14890
  };
14874
14891
 
14892
+ /**
14893
+ * Return property with the given name on the element.
14894
+ *
14895
+ * @param {any} target
14896
+ * @param {string} name
14897
+ *
14898
+ * @return {object | null} property
14899
+ */
14900
+ Properties.prototype.getProperty = function(target, name) {
14901
+
14902
+ var model = this.model;
14903
+
14904
+ var property = model.getPropertyDescriptor(target, name);
14905
+
14906
+ if (property) {
14907
+ return property;
14908
+ }
14909
+
14910
+ if (name.includes(':')) {
14911
+ return null;
14912
+ }
14913
+
14914
+ const strict = model.config.strict;
14915
+
14916
+ if (typeof strict !== 'undefined') {
14917
+ const error = new TypeError(`unknown property <${ name }> on <${ target.$type }>`);
14918
+
14919
+ if (strict) {
14920
+ throw error;
14921
+ } else {
14922
+
14923
+ // eslint-disable-next-line no-undef
14924
+ typeof console !== 'undefined' && console.warn(error);
14925
+ }
14926
+ }
14927
+
14928
+ return null;
14929
+ };
14875
14930
 
14876
14931
  function isUndefined(val) {
14877
14932
  return typeof val === 'undefined';
@@ -14886,6 +14941,10 @@
14886
14941
  });
14887
14942
  }
14888
14943
 
14944
+ function stripGlobal(name) {
14945
+ return name.replace(/^:/, '');
14946
+ }
14947
+
14889
14948
  // Moddle implementation /////////////////////////////////////////////////
14890
14949
 
14891
14950
  /**
@@ -14908,8 +14967,10 @@
14908
14967
  * var moddle = new Moddle([pkg]);
14909
14968
  *
14910
14969
  * @param {Array<Package>} packages the packages to contain
14970
+ *
14971
+ * @param { { strict?: boolean } } [config] moddle configuration
14911
14972
  */
14912
- function Moddle(packages) {
14973
+ function Moddle(packages, config = {}) {
14913
14974
 
14914
14975
  this.properties = new Properties(this);
14915
14976
 
@@ -14917,6 +14978,8 @@
14917
14978
  this.registry = new Registry(packages, this.properties);
14918
14979
 
14919
14980
  this.typeCache = {};
14981
+
14982
+ this.config = config;
14920
14983
  }
14921
14984
 
14922
14985
 
@@ -15010,6 +15073,12 @@
15010
15073
  $type: name,
15011
15074
  $instanceOf: function(type) {
15012
15075
  return type === this.$type;
15076
+ },
15077
+ get: function(key) {
15078
+ return this[key];
15079
+ },
15080
+ set: function(key, value) {
15081
+ set$2(this, [ key ], value);
15013
15082
  }
15014
15083
  };
15015
15084
 
@@ -15025,6 +15094,8 @@
15025
15094
 
15026
15095
  this.properties.defineDescriptor(element, descriptor);
15027
15096
  this.properties.defineModel(element, this);
15097
+ this.properties.define(element, 'get', { enumerable: false, writable: true });
15098
+ this.properties.define(element, 'set', { enumerable: false, writable: true });
15028
15099
  this.properties.define(element, '$parent', { enumerable: false, writable: true });
15029
15100
  this.properties.define(element, '$instanceOf', { enumerable: false, writable: true });
15030
15101