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$1(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
  *
@@ -12334,36 +12390,17 @@
12334
12390
  }
12335
12391
  };
12336
12392
 
12337
- function getDefaultExportFromCjs (x) {
12338
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
12339
- }
12340
-
12341
- var objectRefs = {exports: {}};
12342
-
12343
- var collection = {};
12344
-
12345
- /**
12346
- * An empty collection stub. Use {@link RefsCollection.extend} to extend a
12347
- * collection with ref semantics.
12348
- *
12349
- * @class RefsCollection
12350
- */
12351
-
12352
12393
  /**
12353
12394
  * Extends a collection with {@link Refs} aware methods
12354
12395
  *
12355
- * @memberof RefsCollection
12356
- * @static
12357
- *
12358
- * @param {Array<Object>} collection
12359
- * @param {Refs} refs instance
12360
- * @param {Object} property represented by the collection
12361
- * @param {Object} target object the collection is attached to
12396
+ * @param {Array<Object>} collection
12397
+ * @param {Refs} refs instance
12398
+ * @param {Object} property represented by the collection
12399
+ * @param {Object} target object the collection is attached to
12362
12400
  *
12363
12401
  * @return {RefsCollection<Object>} the extended array
12364
12402
  */
12365
12403
  function extend(collection, refs, property, target) {
12366
-
12367
12404
  var inverseProperty = property.inverse;
12368
12405
 
12369
12406
  /**
@@ -12374,7 +12411,7 @@
12374
12411
  * @param {Object} element the element to remove
12375
12412
  */
12376
12413
  Object.defineProperty(collection, 'remove', {
12377
- value: function(element) {
12414
+ value: function (element) {
12378
12415
  var idx = this.indexOf(element);
12379
12416
  if (idx !== -1) {
12380
12417
  this.splice(idx, 1);
@@ -12382,7 +12419,6 @@
12382
12419
  // unset inverse
12383
12420
  refs.unset(element, inverseProperty, target);
12384
12421
  }
12385
-
12386
12422
  return element;
12387
12423
  }
12388
12424
  });
@@ -12395,7 +12431,7 @@
12395
12431
  * @param {Object} element the element to check for
12396
12432
  */
12397
12433
  Object.defineProperty(collection, 'contains', {
12398
- value: function(element) {
12434
+ value: function (element) {
12399
12435
  return this.indexOf(element) !== -1;
12400
12436
  }
12401
12437
  });
@@ -12410,12 +12446,9 @@
12410
12446
  * (possibly moving other elements around)
12411
12447
  */
12412
12448
  Object.defineProperty(collection, 'add', {
12413
- value: function(element, idx) {
12414
-
12449
+ value: function (element, idx) {
12415
12450
  var currentIdx = this.indexOf(element);
12416
-
12417
12451
  if (typeof idx === 'undefined') {
12418
-
12419
12452
  if (currentIdx !== -1) {
12420
12453
  // element already in collection (!)
12421
12454
  return;
@@ -12427,14 +12460,12 @@
12427
12460
 
12428
12461
  // handle already in collection
12429
12462
  if (currentIdx !== -1) {
12430
-
12431
12463
  // remove element from currentIdx
12432
12464
  this.splice(currentIdx, 1);
12433
12465
  }
12434
12466
 
12435
12467
  // add element at idx
12436
12468
  this.splice(idx, 0, element);
12437
-
12438
12469
  if (currentIdx === -1) {
12439
12470
  // set inverse, unless element was
12440
12471
  // in collection already
@@ -12448,69 +12479,53 @@
12448
12479
  Object.defineProperty(collection, '__refs_collection', {
12449
12480
  value: true
12450
12481
  });
12451
-
12452
12482
  return collection;
12453
12483
  }
12454
12484
 
12455
-
12485
+ /**
12486
+ * Checks if a given collection is extended
12487
+ *
12488
+ * @param {Array<Object>} collection
12489
+ *
12490
+ * @return {boolean}
12491
+ */
12456
12492
  function isExtended(collection) {
12457
12493
  return collection.__refs_collection === true;
12458
12494
  }
12459
12495
 
12460
- collection.extend = extend;
12461
-
12462
- collection.isExtended = isExtended;
12463
-
12464
- var Collection = collection;
12465
-
12466
12496
  function hasOwnProperty$1(e, property) {
12467
12497
  return Object.prototype.hasOwnProperty.call(e, property.name || property);
12468
12498
  }
12469
-
12470
12499
  function defineCollectionProperty(ref, property, target) {
12471
-
12472
- var collection = Collection.extend(target[property.name] || [], ref, property, target);
12473
-
12500
+ var collection = extend(target[property.name] || [], ref, property, target);
12474
12501
  Object.defineProperty(target, property.name, {
12475
12502
  enumerable: property.enumerable,
12476
12503
  value: collection
12477
12504
  });
12478
-
12479
12505
  if (collection.length) {
12480
-
12481
- collection.forEach(function(o) {
12506
+ collection.forEach(function (o) {
12482
12507
  ref.set(o, property.inverse, target);
12483
12508
  });
12484
12509
  }
12485
12510
  }
12486
-
12487
-
12488
12511
  function defineProperty$1(ref, property, target) {
12489
-
12490
12512
  var inverseProperty = property.inverse;
12491
-
12492
12513
  var _value = target[property.name];
12493
-
12494
12514
  Object.defineProperty(target, property.name, {
12495
12515
  configurable: property.configurable,
12496
12516
  enumerable: property.enumerable,
12497
-
12498
- get: function() {
12517
+ get: function () {
12499
12518
  return _value;
12500
12519
  },
12501
-
12502
- set: function(value) {
12503
-
12520
+ set: function (value) {
12504
12521
  // return if we already performed all changes
12505
12522
  if (value === _value) {
12506
12523
  return;
12507
12524
  }
12508
-
12509
12525
  var old = _value;
12510
12526
 
12511
12527
  // temporary set null
12512
12528
  _value = null;
12513
-
12514
12529
  if (old) {
12515
12530
  ref.unset(old, inverseProperty, target);
12516
12531
  }
@@ -12522,7 +12537,6 @@
12522
12537
  ref.set(_value, inverseProperty, target);
12523
12538
  }
12524
12539
  });
12525
-
12526
12540
  }
12527
12541
 
12528
12542
  /**
@@ -12568,16 +12582,14 @@
12568
12582
  *
12569
12583
  * wheels[0].car // undefined
12570
12584
  */
12571
- function Refs$1(a, b) {
12572
-
12573
- if (!(this instanceof Refs$1)) {
12574
- return new Refs$1(a, b);
12585
+ function Refs(a, b) {
12586
+ if (!(this instanceof Refs)) {
12587
+ return new Refs(a, b);
12575
12588
  }
12576
12589
 
12577
12590
  // link
12578
12591
  a.inverse = b;
12579
12592
  b.inverse = a;
12580
-
12581
12593
  this.props = {};
12582
12594
  this.props[a.name] = a;
12583
12595
  this.props[b.name] = b;
@@ -12592,43 +12604,34 @@
12592
12604
  * @param {Object} target
12593
12605
  * @param {String} property
12594
12606
  */
12595
- Refs$1.prototype.bind = function(target, property) {
12607
+ Refs.prototype.bind = function (target, property) {
12596
12608
  if (typeof property === 'string') {
12597
12609
  if (!this.props[property]) {
12598
12610
  throw new Error('no property <' + property + '> in ref');
12599
12611
  }
12600
12612
  property = this.props[property];
12601
12613
  }
12602
-
12603
12614
  if (property.collection) {
12604
12615
  defineCollectionProperty(this, property, target);
12605
12616
  } else {
12606
12617
  defineProperty$1(this, property, target);
12607
12618
  }
12608
12619
  };
12609
-
12610
- Refs$1.prototype.ensureRefsCollection = function(target, property) {
12611
-
12620
+ Refs.prototype.ensureRefsCollection = function (target, property) {
12612
12621
  var collection = target[property.name];
12613
-
12614
- if (!Collection.isExtended(collection)) {
12622
+ if (!isExtended(collection)) {
12615
12623
  defineCollectionProperty(this, property, target);
12616
12624
  }
12617
-
12618
12625
  return collection;
12619
12626
  };
12620
-
12621
- Refs$1.prototype.ensureBound = function(target, property) {
12627
+ Refs.prototype.ensureBound = function (target, property) {
12622
12628
  if (!hasOwnProperty$1(target, property)) {
12623
12629
  this.bind(target, property);
12624
12630
  }
12625
12631
  };
12626
-
12627
- Refs$1.prototype.unset = function(target, property, value) {
12628
-
12632
+ Refs.prototype.unset = function (target, property, value) {
12629
12633
  if (target) {
12630
12634
  this.ensureBound(target, property);
12631
-
12632
12635
  if (property.collection) {
12633
12636
  this.ensureRefsCollection(target, property).remove(value);
12634
12637
  } else {
@@ -12636,12 +12639,9 @@
12636
12639
  }
12637
12640
  }
12638
12641
  };
12639
-
12640
- Refs$1.prototype.set = function(target, property, value) {
12641
-
12642
+ Refs.prototype.set = function (target, property, value) {
12642
12643
  if (target) {
12643
12644
  this.ensureBound(target, property);
12644
-
12645
12645
  if (property.collection) {
12646
12646
  this.ensureRefsCollection(target, property).add(value);
12647
12647
  } else {
@@ -12650,15 +12650,6 @@
12650
12650
  }
12651
12651
  };
12652
12652
 
12653
- var refs = Refs$1;
12654
-
12655
- objectRefs.exports = refs;
12656
-
12657
- objectRefs.exports.Collection = collection;
12658
-
12659
- var objectRefsExports = objectRefs.exports;
12660
- var Refs = /*@__PURE__*/getDefaultExportFromCjs(objectRefsExports);
12661
-
12662
12653
  var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
12663
12654
  labelRefs = new Refs({ name: 'labels', enumerable: true, collection: true }, { name: 'labelTarget' }),
12664
12655
  attacherRefs = new Refs({ name: 'attachers', collection: true }, { name: 'host' }),
@@ -14475,6 +14466,17 @@
14475
14466
  this.idProperty = p;
14476
14467
  };
14477
14468
 
14469
+ DescriptorBuilder.prototype.assertNotTrait = function(typeDescriptor) {
14470
+
14471
+ const _extends = typeDescriptor.extends || [];
14472
+
14473
+ if (_extends.length) {
14474
+ throw new Error(
14475
+ `cannot create <${ typeDescriptor.name }> extending <${ typeDescriptor.extends }>`
14476
+ );
14477
+ }
14478
+ };
14479
+
14478
14480
  DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
14479
14481
  var propertyName = p.name,
14480
14482
  definedProperty = this.propertiesByName[propertyName];
@@ -14493,6 +14495,10 @@
14493
14495
 
14494
14496
  DescriptorBuilder.prototype.addTrait = function(t, inherited) {
14495
14497
 
14498
+ if (inherited) {
14499
+ this.assertNotTrait(t);
14500
+ }
14501
+
14496
14502
  var typesByName = this.allTypesByName,
14497
14503
  types = this.allTypes;
14498
14504
 
@@ -14626,7 +14632,9 @@
14626
14632
  });
14627
14633
 
14628
14634
  forEach$1(type.extends, bind$2(function(extendsName) {
14629
- var extended = this.typeMap[extendsName];
14635
+ var extendsNameNs = parseName(extendsName, ns.prefix);
14636
+
14637
+ var extended = this.typeMap[extendsNameNs.name];
14630
14638
 
14631
14639
  extended.traits = extended.traits || [];
14632
14640
  extended.traits.push(name);
@@ -14655,24 +14663,33 @@
14655
14663
 
14656
14664
  var self = this;
14657
14665
 
14666
+ /**
14667
+ * Traverse the selected super type or trait
14668
+ *
14669
+ * @param {String} cls
14670
+ * @param {Boolean} [trait=false]
14671
+ */
14672
+ function traverse(cls, trait) {
14673
+ var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
14674
+ self.mapTypes(parentNs, iterator, trait);
14675
+ }
14676
+
14658
14677
  /**
14659
14678
  * Traverse the selected trait.
14660
14679
  *
14661
14680
  * @param {String} cls
14662
14681
  */
14663
14682
  function traverseTrait(cls) {
14664
- return traverseSuper(cls, true);
14683
+ return traverse(cls, true);
14665
14684
  }
14666
14685
 
14667
14686
  /**
14668
- * Traverse the selected super type or trait
14687
+ * Traverse the selected super type
14669
14688
  *
14670
14689
  * @param {String} cls
14671
- * @param {Boolean} [trait=false]
14672
14690
  */
14673
- function traverseSuper(cls, trait) {
14674
- var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
14675
- self.mapTypes(parentNs, iterator, trait);
14691
+ function traverseSuper(cls) {
14692
+ return traverse(cls, false);
14676
14693
  }
14677
14694
 
14678
14695
  if (!type) {
@@ -14755,7 +14772,7 @@
14755
14772
  throw new TypeError('property name must be a non-empty string');
14756
14773
  }
14757
14774
 
14758
- var property = this.model.getPropertyDescriptor(target, name);
14775
+ var property = this.getProperty(target, name);
14759
14776
 
14760
14777
  var propertyName = property && property.name;
14761
14778
 
@@ -14766,7 +14783,7 @@
14766
14783
  if (property) {
14767
14784
  delete target[propertyName];
14768
14785
  } else {
14769
- delete target.$attrs[name];
14786
+ delete target.$attrs[stripGlobal(name)];
14770
14787
  }
14771
14788
  } else {
14772
14789
 
@@ -14779,7 +14796,7 @@
14779
14796
  defineProperty(target, property, value);
14780
14797
  }
14781
14798
  } else {
14782
- target.$attrs[name] = value;
14799
+ target.$attrs[stripGlobal(name)] = value;
14783
14800
  }
14784
14801
  }
14785
14802
  };
@@ -14794,10 +14811,10 @@
14794
14811
  */
14795
14812
  Properties.prototype.get = function(target, name) {
14796
14813
 
14797
- var property = this.model.getPropertyDescriptor(target, name);
14814
+ var property = this.getProperty(target, name);
14798
14815
 
14799
14816
  if (!property) {
14800
- return target.$attrs[name];
14817
+ return target.$attrs[stripGlobal(name)];
14801
14818
  }
14802
14819
 
14803
14820
  var propertyName = property.name;
@@ -14851,6 +14868,44 @@
14851
14868
  this.define(target, '$model', { value: model });
14852
14869
  };
14853
14870
 
14871
+ /**
14872
+ * Return property with the given name on the element.
14873
+ *
14874
+ * @param {any} target
14875
+ * @param {string} name
14876
+ *
14877
+ * @return {object | null} property
14878
+ */
14879
+ Properties.prototype.getProperty = function(target, name) {
14880
+
14881
+ var model = this.model;
14882
+
14883
+ var property = model.getPropertyDescriptor(target, name);
14884
+
14885
+ if (property) {
14886
+ return property;
14887
+ }
14888
+
14889
+ if (name.includes(':')) {
14890
+ return null;
14891
+ }
14892
+
14893
+ const strict = model.config.strict;
14894
+
14895
+ if (typeof strict !== 'undefined') {
14896
+ const error = new TypeError(`unknown property <${ name }> on <${ target.$type }>`);
14897
+
14898
+ if (strict) {
14899
+ throw error;
14900
+ } else {
14901
+
14902
+ // eslint-disable-next-line no-undef
14903
+ typeof console !== 'undefined' && console.warn(error);
14904
+ }
14905
+ }
14906
+
14907
+ return null;
14908
+ };
14854
14909
 
14855
14910
  function isUndefined(val) {
14856
14911
  return typeof val === 'undefined';
@@ -14865,6 +14920,10 @@
14865
14920
  });
14866
14921
  }
14867
14922
 
14923
+ function stripGlobal(name) {
14924
+ return name.replace(/^:/, '');
14925
+ }
14926
+
14868
14927
  // Moddle implementation /////////////////////////////////////////////////
14869
14928
 
14870
14929
  /**
@@ -14887,8 +14946,10 @@
14887
14946
  * var moddle = new Moddle([pkg]);
14888
14947
  *
14889
14948
  * @param {Array<Package>} packages the packages to contain
14949
+ *
14950
+ * @param { { strict?: boolean } } [config] moddle configuration
14890
14951
  */
14891
- function Moddle(packages) {
14952
+ function Moddle(packages, config = {}) {
14892
14953
 
14893
14954
  this.properties = new Properties(this);
14894
14955
 
@@ -14896,6 +14957,8 @@
14896
14957
  this.registry = new Registry(packages, this.properties);
14897
14958
 
14898
14959
  this.typeCache = {};
14960
+
14961
+ this.config = config;
14899
14962
  }
14900
14963
 
14901
14964
 
@@ -14989,6 +15052,12 @@
14989
15052
  $type: name,
14990
15053
  $instanceOf: function(type) {
14991
15054
  return type === this.$type;
15055
+ },
15056
+ get: function(key) {
15057
+ return this[key];
15058
+ },
15059
+ set: function(key, value) {
15060
+ set$1(this, [ key ], value);
14992
15061
  }
14993
15062
  };
14994
15063
 
@@ -15004,6 +15073,8 @@
15004
15073
 
15005
15074
  this.properties.defineDescriptor(element, descriptor);
15006
15075
  this.properties.defineModel(element, this);
15076
+ this.properties.define(element, 'get', { enumerable: false, writable: true });
15077
+ this.properties.define(element, 'set', { enumerable: false, writable: true });
15007
15078
  this.properties.define(element, '$parent', { enumerable: false, writable: true });
15008
15079
  this.properties.define(element, '$instanceOf', { enumerable: false, writable: true });
15009
15080