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
  *
@@ -12323,36 +12379,17 @@
12323
12379
  }
12324
12380
  };
12325
12381
 
12326
- function getDefaultExportFromCjs (x) {
12327
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
12328
- }
12329
-
12330
- var objectRefs = {exports: {}};
12331
-
12332
- var collection = {};
12333
-
12334
- /**
12335
- * An empty collection stub. Use {@link RefsCollection.extend} to extend a
12336
- * collection with ref semantics.
12337
- *
12338
- * @class RefsCollection
12339
- */
12340
-
12341
12382
  /**
12342
12383
  * Extends a collection with {@link Refs} aware methods
12343
12384
  *
12344
- * @memberof RefsCollection
12345
- * @static
12346
- *
12347
- * @param {Array<Object>} collection
12348
- * @param {Refs} refs instance
12349
- * @param {Object} property represented by the collection
12350
- * @param {Object} target object the collection is attached to
12385
+ * @param {Array<Object>} collection
12386
+ * @param {Refs} refs instance
12387
+ * @param {Object} property represented by the collection
12388
+ * @param {Object} target object the collection is attached to
12351
12389
  *
12352
12390
  * @return {RefsCollection<Object>} the extended array
12353
12391
  */
12354
12392
  function extend(collection, refs, property, target) {
12355
-
12356
12393
  var inverseProperty = property.inverse;
12357
12394
 
12358
12395
  /**
@@ -12363,7 +12400,7 @@
12363
12400
  * @param {Object} element the element to remove
12364
12401
  */
12365
12402
  Object.defineProperty(collection, 'remove', {
12366
- value: function(element) {
12403
+ value: function (element) {
12367
12404
  var idx = this.indexOf(element);
12368
12405
  if (idx !== -1) {
12369
12406
  this.splice(idx, 1);
@@ -12371,7 +12408,6 @@
12371
12408
  // unset inverse
12372
12409
  refs.unset(element, inverseProperty, target);
12373
12410
  }
12374
-
12375
12411
  return element;
12376
12412
  }
12377
12413
  });
@@ -12384,7 +12420,7 @@
12384
12420
  * @param {Object} element the element to check for
12385
12421
  */
12386
12422
  Object.defineProperty(collection, 'contains', {
12387
- value: function(element) {
12423
+ value: function (element) {
12388
12424
  return this.indexOf(element) !== -1;
12389
12425
  }
12390
12426
  });
@@ -12399,12 +12435,9 @@
12399
12435
  * (possibly moving other elements around)
12400
12436
  */
12401
12437
  Object.defineProperty(collection, 'add', {
12402
- value: function(element, idx) {
12403
-
12438
+ value: function (element, idx) {
12404
12439
  var currentIdx = this.indexOf(element);
12405
-
12406
12440
  if (typeof idx === 'undefined') {
12407
-
12408
12441
  if (currentIdx !== -1) {
12409
12442
  // element already in collection (!)
12410
12443
  return;
@@ -12416,14 +12449,12 @@
12416
12449
 
12417
12450
  // handle already in collection
12418
12451
  if (currentIdx !== -1) {
12419
-
12420
12452
  // remove element from currentIdx
12421
12453
  this.splice(currentIdx, 1);
12422
12454
  }
12423
12455
 
12424
12456
  // add element at idx
12425
12457
  this.splice(idx, 0, element);
12426
-
12427
12458
  if (currentIdx === -1) {
12428
12459
  // set inverse, unless element was
12429
12460
  // in collection already
@@ -12437,69 +12468,53 @@
12437
12468
  Object.defineProperty(collection, '__refs_collection', {
12438
12469
  value: true
12439
12470
  });
12440
-
12441
12471
  return collection;
12442
12472
  }
12443
12473
 
12444
-
12474
+ /**
12475
+ * Checks if a given collection is extended
12476
+ *
12477
+ * @param {Array<Object>} collection
12478
+ *
12479
+ * @return {boolean}
12480
+ */
12445
12481
  function isExtended(collection) {
12446
12482
  return collection.__refs_collection === true;
12447
12483
  }
12448
12484
 
12449
- collection.extend = extend;
12450
-
12451
- collection.isExtended = isExtended;
12452
-
12453
- var Collection = collection;
12454
-
12455
12485
  function hasOwnProperty$1(e, property) {
12456
12486
  return Object.prototype.hasOwnProperty.call(e, property.name || property);
12457
12487
  }
12458
-
12459
12488
  function defineCollectionProperty(ref, property, target) {
12460
-
12461
- var collection = Collection.extend(target[property.name] || [], ref, property, target);
12462
-
12489
+ var collection = extend(target[property.name] || [], ref, property, target);
12463
12490
  Object.defineProperty(target, property.name, {
12464
12491
  enumerable: property.enumerable,
12465
12492
  value: collection
12466
12493
  });
12467
-
12468
12494
  if (collection.length) {
12469
-
12470
- collection.forEach(function(o) {
12495
+ collection.forEach(function (o) {
12471
12496
  ref.set(o, property.inverse, target);
12472
12497
  });
12473
12498
  }
12474
12499
  }
12475
-
12476
-
12477
12500
  function defineProperty$1(ref, property, target) {
12478
-
12479
12501
  var inverseProperty = property.inverse;
12480
-
12481
12502
  var _value = target[property.name];
12482
-
12483
12503
  Object.defineProperty(target, property.name, {
12484
12504
  configurable: property.configurable,
12485
12505
  enumerable: property.enumerable,
12486
-
12487
- get: function() {
12506
+ get: function () {
12488
12507
  return _value;
12489
12508
  },
12490
-
12491
- set: function(value) {
12492
-
12509
+ set: function (value) {
12493
12510
  // return if we already performed all changes
12494
12511
  if (value === _value) {
12495
12512
  return;
12496
12513
  }
12497
-
12498
12514
  var old = _value;
12499
12515
 
12500
12516
  // temporary set null
12501
12517
  _value = null;
12502
-
12503
12518
  if (old) {
12504
12519
  ref.unset(old, inverseProperty, target);
12505
12520
  }
@@ -12511,7 +12526,6 @@
12511
12526
  ref.set(_value, inverseProperty, target);
12512
12527
  }
12513
12528
  });
12514
-
12515
12529
  }
12516
12530
 
12517
12531
  /**
@@ -12557,16 +12571,14 @@
12557
12571
  *
12558
12572
  * wheels[0].car // undefined
12559
12573
  */
12560
- function Refs$1(a, b) {
12561
-
12562
- if (!(this instanceof Refs$1)) {
12563
- return new Refs$1(a, b);
12574
+ function Refs(a, b) {
12575
+ if (!(this instanceof Refs)) {
12576
+ return new Refs(a, b);
12564
12577
  }
12565
12578
 
12566
12579
  // link
12567
12580
  a.inverse = b;
12568
12581
  b.inverse = a;
12569
-
12570
12582
  this.props = {};
12571
12583
  this.props[a.name] = a;
12572
12584
  this.props[b.name] = b;
@@ -12581,43 +12593,34 @@
12581
12593
  * @param {Object} target
12582
12594
  * @param {String} property
12583
12595
  */
12584
- Refs$1.prototype.bind = function(target, property) {
12596
+ Refs.prototype.bind = function (target, property) {
12585
12597
  if (typeof property === 'string') {
12586
12598
  if (!this.props[property]) {
12587
12599
  throw new Error('no property <' + property + '> in ref');
12588
12600
  }
12589
12601
  property = this.props[property];
12590
12602
  }
12591
-
12592
12603
  if (property.collection) {
12593
12604
  defineCollectionProperty(this, property, target);
12594
12605
  } else {
12595
12606
  defineProperty$1(this, property, target);
12596
12607
  }
12597
12608
  };
12598
-
12599
- Refs$1.prototype.ensureRefsCollection = function(target, property) {
12600
-
12609
+ Refs.prototype.ensureRefsCollection = function (target, property) {
12601
12610
  var collection = target[property.name];
12602
-
12603
- if (!Collection.isExtended(collection)) {
12611
+ if (!isExtended(collection)) {
12604
12612
  defineCollectionProperty(this, property, target);
12605
12613
  }
12606
-
12607
12614
  return collection;
12608
12615
  };
12609
-
12610
- Refs$1.prototype.ensureBound = function(target, property) {
12616
+ Refs.prototype.ensureBound = function (target, property) {
12611
12617
  if (!hasOwnProperty$1(target, property)) {
12612
12618
  this.bind(target, property);
12613
12619
  }
12614
12620
  };
12615
-
12616
- Refs$1.prototype.unset = function(target, property, value) {
12617
-
12621
+ Refs.prototype.unset = function (target, property, value) {
12618
12622
  if (target) {
12619
12623
  this.ensureBound(target, property);
12620
-
12621
12624
  if (property.collection) {
12622
12625
  this.ensureRefsCollection(target, property).remove(value);
12623
12626
  } else {
@@ -12625,12 +12628,9 @@
12625
12628
  }
12626
12629
  }
12627
12630
  };
12628
-
12629
- Refs$1.prototype.set = function(target, property, value) {
12630
-
12631
+ Refs.prototype.set = function (target, property, value) {
12631
12632
  if (target) {
12632
12633
  this.ensureBound(target, property);
12633
-
12634
12634
  if (property.collection) {
12635
12635
  this.ensureRefsCollection(target, property).add(value);
12636
12636
  } else {
@@ -12639,15 +12639,6 @@
12639
12639
  }
12640
12640
  };
12641
12641
 
12642
- var refs = Refs$1;
12643
-
12644
- objectRefs.exports = refs;
12645
-
12646
- objectRefs.exports.Collection = collection;
12647
-
12648
- var objectRefsExports = objectRefs.exports;
12649
- var Refs = /*@__PURE__*/getDefaultExportFromCjs(objectRefsExports);
12650
-
12651
12642
  var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
12652
12643
  labelRefs = new Refs({ name: 'labels', enumerable: true, collection: true }, { name: 'labelTarget' }),
12653
12644
  attacherRefs = new Refs({ name: 'attachers', collection: true }, { name: 'host' }),
@@ -14464,6 +14455,17 @@
14464
14455
  this.idProperty = p;
14465
14456
  };
14466
14457
 
14458
+ DescriptorBuilder.prototype.assertNotTrait = function(typeDescriptor) {
14459
+
14460
+ const _extends = typeDescriptor.extends || [];
14461
+
14462
+ if (_extends.length) {
14463
+ throw new Error(
14464
+ `cannot create <${ typeDescriptor.name }> extending <${ typeDescriptor.extends }>`
14465
+ );
14466
+ }
14467
+ };
14468
+
14467
14469
  DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
14468
14470
  var propertyName = p.name,
14469
14471
  definedProperty = this.propertiesByName[propertyName];
@@ -14482,6 +14484,10 @@
14482
14484
 
14483
14485
  DescriptorBuilder.prototype.addTrait = function(t, inherited) {
14484
14486
 
14487
+ if (inherited) {
14488
+ this.assertNotTrait(t);
14489
+ }
14490
+
14485
14491
  var typesByName = this.allTypesByName,
14486
14492
  types = this.allTypes;
14487
14493
 
@@ -14615,7 +14621,9 @@
14615
14621
  });
14616
14622
 
14617
14623
  forEach$1(type.extends, bind$2(function(extendsName) {
14618
- var extended = this.typeMap[extendsName];
14624
+ var extendsNameNs = parseName(extendsName, ns.prefix);
14625
+
14626
+ var extended = this.typeMap[extendsNameNs.name];
14619
14627
 
14620
14628
  extended.traits = extended.traits || [];
14621
14629
  extended.traits.push(name);
@@ -14644,24 +14652,33 @@
14644
14652
 
14645
14653
  var self = this;
14646
14654
 
14655
+ /**
14656
+ * Traverse the selected super type or trait
14657
+ *
14658
+ * @param {String} cls
14659
+ * @param {Boolean} [trait=false]
14660
+ */
14661
+ function traverse(cls, trait) {
14662
+ var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
14663
+ self.mapTypes(parentNs, iterator, trait);
14664
+ }
14665
+
14647
14666
  /**
14648
14667
  * Traverse the selected trait.
14649
14668
  *
14650
14669
  * @param {String} cls
14651
14670
  */
14652
14671
  function traverseTrait(cls) {
14653
- return traverseSuper(cls, true);
14672
+ return traverse(cls, true);
14654
14673
  }
14655
14674
 
14656
14675
  /**
14657
- * Traverse the selected super type or trait
14676
+ * Traverse the selected super type
14658
14677
  *
14659
14678
  * @param {String} cls
14660
- * @param {Boolean} [trait=false]
14661
14679
  */
14662
- function traverseSuper(cls, trait) {
14663
- var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
14664
- self.mapTypes(parentNs, iterator, trait);
14680
+ function traverseSuper(cls) {
14681
+ return traverse(cls, false);
14665
14682
  }
14666
14683
 
14667
14684
  if (!type) {
@@ -14744,7 +14761,7 @@
14744
14761
  throw new TypeError('property name must be a non-empty string');
14745
14762
  }
14746
14763
 
14747
- var property = this.model.getPropertyDescriptor(target, name);
14764
+ var property = this.getProperty(target, name);
14748
14765
 
14749
14766
  var propertyName = property && property.name;
14750
14767
 
@@ -14755,7 +14772,7 @@
14755
14772
  if (property) {
14756
14773
  delete target[propertyName];
14757
14774
  } else {
14758
- delete target.$attrs[name];
14775
+ delete target.$attrs[stripGlobal(name)];
14759
14776
  }
14760
14777
  } else {
14761
14778
 
@@ -14768,7 +14785,7 @@
14768
14785
  defineProperty(target, property, value);
14769
14786
  }
14770
14787
  } else {
14771
- target.$attrs[name] = value;
14788
+ target.$attrs[stripGlobal(name)] = value;
14772
14789
  }
14773
14790
  }
14774
14791
  };
@@ -14783,10 +14800,10 @@
14783
14800
  */
14784
14801
  Properties.prototype.get = function(target, name) {
14785
14802
 
14786
- var property = this.model.getPropertyDescriptor(target, name);
14803
+ var property = this.getProperty(target, name);
14787
14804
 
14788
14805
  if (!property) {
14789
- return target.$attrs[name];
14806
+ return target.$attrs[stripGlobal(name)];
14790
14807
  }
14791
14808
 
14792
14809
  var propertyName = property.name;
@@ -14840,6 +14857,44 @@
14840
14857
  this.define(target, '$model', { value: model });
14841
14858
  };
14842
14859
 
14860
+ /**
14861
+ * Return property with the given name on the element.
14862
+ *
14863
+ * @param {any} target
14864
+ * @param {string} name
14865
+ *
14866
+ * @return {object | null} property
14867
+ */
14868
+ Properties.prototype.getProperty = function(target, name) {
14869
+
14870
+ var model = this.model;
14871
+
14872
+ var property = model.getPropertyDescriptor(target, name);
14873
+
14874
+ if (property) {
14875
+ return property;
14876
+ }
14877
+
14878
+ if (name.includes(':')) {
14879
+ return null;
14880
+ }
14881
+
14882
+ const strict = model.config.strict;
14883
+
14884
+ if (typeof strict !== 'undefined') {
14885
+ const error = new TypeError(`unknown property <${ name }> on <${ target.$type }>`);
14886
+
14887
+ if (strict) {
14888
+ throw error;
14889
+ } else {
14890
+
14891
+ // eslint-disable-next-line no-undef
14892
+ typeof console !== 'undefined' && console.warn(error);
14893
+ }
14894
+ }
14895
+
14896
+ return null;
14897
+ };
14843
14898
 
14844
14899
  function isUndefined(val) {
14845
14900
  return typeof val === 'undefined';
@@ -14854,6 +14909,10 @@
14854
14909
  });
14855
14910
  }
14856
14911
 
14912
+ function stripGlobal(name) {
14913
+ return name.replace(/^:/, '');
14914
+ }
14915
+
14857
14916
  // Moddle implementation /////////////////////////////////////////////////
14858
14917
 
14859
14918
  /**
@@ -14876,8 +14935,10 @@
14876
14935
  * var moddle = new Moddle([pkg]);
14877
14936
  *
14878
14937
  * @param {Array<Package>} packages the packages to contain
14938
+ *
14939
+ * @param { { strict?: boolean } } [config] moddle configuration
14879
14940
  */
14880
- function Moddle(packages) {
14941
+ function Moddle(packages, config = {}) {
14881
14942
 
14882
14943
  this.properties = new Properties(this);
14883
14944
 
@@ -14885,6 +14946,8 @@
14885
14946
  this.registry = new Registry(packages, this.properties);
14886
14947
 
14887
14948
  this.typeCache = {};
14949
+
14950
+ this.config = config;
14888
14951
  }
14889
14952
 
14890
14953
 
@@ -14978,6 +15041,12 @@
14978
15041
  $type: name,
14979
15042
  $instanceOf: function(type) {
14980
15043
  return type === this.$type;
15044
+ },
15045
+ get: function(key) {
15046
+ return this[key];
15047
+ },
15048
+ set: function(key, value) {
15049
+ set$1(this, [ key ], value);
14981
15050
  }
14982
15051
  };
14983
15052
 
@@ -14993,6 +15062,8 @@
14993
15062
 
14994
15063
  this.properties.defineDescriptor(element, descriptor);
14995
15064
  this.properties.defineModel(element, this);
15065
+ this.properties.define(element, 'get', { enumerable: false, writable: true });
15066
+ this.properties.define(element, 'set', { enumerable: false, writable: true });
14996
15067
  this.properties.define(element, '$parent', { enumerable: false, writable: true });
14997
15068
  this.properties.define(element, '$instanceOf', { enumerable: false, writable: true });
14998
15069