bpmn-js 16.1.0 → 16.2.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-viewer v16.1.0
2
+ * bpmn-js - bpmn-viewer v16.2.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2023-12-14
11
+ * Date: 2023-12-20
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -39,6 +39,10 @@
39
39
  return obj !== undefined;
40
40
  }
41
41
 
42
+ function isNil(obj) {
43
+ return obj == null;
44
+ }
45
+
42
46
  function isArray$2(obj) {
43
47
  return nativeToString$1.call(obj) === '[object Array]';
44
48
  }
@@ -487,6 +491,58 @@
487
491
  return Object.assign(target, ...others);
488
492
  }
489
493
 
494
+ /**
495
+ * Sets a nested property of a given object to the specified value.
496
+ *
497
+ * This mutates the object and returns it.
498
+ *
499
+ * @template T
500
+ *
501
+ * @param {T} target The target of the set operation.
502
+ * @param {(string|number)[]} path The path to the nested value.
503
+ * @param {any} value The value to set.
504
+ *
505
+ * @return {T}
506
+ */
507
+ function set$1(target, path, value) {
508
+
509
+ let currentTarget = target;
510
+
511
+ forEach$1(path, function(key, idx) {
512
+
513
+ if (typeof key !== 'number' && typeof key !== 'string') {
514
+ throw new Error('illegal key type: ' + typeof key + '. Key should be of type number or string.');
515
+ }
516
+
517
+ if (key === 'constructor') {
518
+ throw new Error('illegal key: constructor');
519
+ }
520
+
521
+ if (key === '__proto__') {
522
+ throw new Error('illegal key: __proto__');
523
+ }
524
+
525
+ let nextKey = path[idx + 1];
526
+ let nextTarget = currentTarget[key];
527
+
528
+ if (isDefined(nextKey) && isNil(nextTarget)) {
529
+ nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
530
+ }
531
+
532
+ if (isUndefined$2(nextKey)) {
533
+ if (isUndefined$2(value)) {
534
+ delete currentTarget[key];
535
+ } else {
536
+ currentTarget[key] = value;
537
+ }
538
+ } else {
539
+ currentTarget = nextTarget;
540
+ }
541
+ });
542
+
543
+ return target;
544
+ }
545
+
490
546
  /**
491
547
  * Pick properties from the given target.
492
548
  *
@@ -14410,6 +14466,17 @@
14410
14466
  this.idProperty = p;
14411
14467
  };
14412
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
+
14413
14480
  DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
14414
14481
  var propertyName = p.name,
14415
14482
  definedProperty = this.propertiesByName[propertyName];
@@ -14428,6 +14495,10 @@
14428
14495
 
14429
14496
  DescriptorBuilder.prototype.addTrait = function(t, inherited) {
14430
14497
 
14498
+ if (inherited) {
14499
+ this.assertNotTrait(t);
14500
+ }
14501
+
14431
14502
  var typesByName = this.allTypesByName,
14432
14503
  types = this.allTypes;
14433
14504
 
@@ -14561,7 +14632,9 @@
14561
14632
  });
14562
14633
 
14563
14634
  forEach$1(type.extends, bind$2(function(extendsName) {
14564
- var extended = this.typeMap[extendsName];
14635
+ var extendsNameNs = parseName(extendsName, ns.prefix);
14636
+
14637
+ var extended = this.typeMap[extendsNameNs.name];
14565
14638
 
14566
14639
  extended.traits = extended.traits || [];
14567
14640
  extended.traits.push(name);
@@ -14590,24 +14663,33 @@
14590
14663
 
14591
14664
  var self = this;
14592
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
+
14593
14677
  /**
14594
14678
  * Traverse the selected trait.
14595
14679
  *
14596
14680
  * @param {String} cls
14597
14681
  */
14598
14682
  function traverseTrait(cls) {
14599
- return traverseSuper(cls, true);
14683
+ return traverse(cls, true);
14600
14684
  }
14601
14685
 
14602
14686
  /**
14603
- * Traverse the selected super type or trait
14687
+ * Traverse the selected super type
14604
14688
  *
14605
14689
  * @param {String} cls
14606
- * @param {Boolean} [trait=false]
14607
14690
  */
14608
- function traverseSuper(cls, trait) {
14609
- var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
14610
- self.mapTypes(parentNs, iterator, trait);
14691
+ function traverseSuper(cls) {
14692
+ return traverse(cls, false);
14611
14693
  }
14612
14694
 
14613
14695
  if (!type) {
@@ -14690,7 +14772,7 @@
14690
14772
  throw new TypeError('property name must be a non-empty string');
14691
14773
  }
14692
14774
 
14693
- var property = this.model.getPropertyDescriptor(target, name);
14775
+ var property = this.getProperty(target, name);
14694
14776
 
14695
14777
  var propertyName = property && property.name;
14696
14778
 
@@ -14701,7 +14783,7 @@
14701
14783
  if (property) {
14702
14784
  delete target[propertyName];
14703
14785
  } else {
14704
- delete target.$attrs[name];
14786
+ delete target.$attrs[stripGlobal(name)];
14705
14787
  }
14706
14788
  } else {
14707
14789
 
@@ -14714,7 +14796,7 @@
14714
14796
  defineProperty(target, property, value);
14715
14797
  }
14716
14798
  } else {
14717
- target.$attrs[name] = value;
14799
+ target.$attrs[stripGlobal(name)] = value;
14718
14800
  }
14719
14801
  }
14720
14802
  };
@@ -14729,10 +14811,10 @@
14729
14811
  */
14730
14812
  Properties.prototype.get = function(target, name) {
14731
14813
 
14732
- var property = this.model.getPropertyDescriptor(target, name);
14814
+ var property = this.getProperty(target, name);
14733
14815
 
14734
14816
  if (!property) {
14735
- return target.$attrs[name];
14817
+ return target.$attrs[stripGlobal(name)];
14736
14818
  }
14737
14819
 
14738
14820
  var propertyName = property.name;
@@ -14786,6 +14868,44 @@
14786
14868
  this.define(target, '$model', { value: model });
14787
14869
  };
14788
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
+ };
14789
14909
 
14790
14910
  function isUndefined(val) {
14791
14911
  return typeof val === 'undefined';
@@ -14800,6 +14920,10 @@
14800
14920
  });
14801
14921
  }
14802
14922
 
14923
+ function stripGlobal(name) {
14924
+ return name.replace(/^:/, '');
14925
+ }
14926
+
14803
14927
  // Moddle implementation /////////////////////////////////////////////////
14804
14928
 
14805
14929
  /**
@@ -14822,8 +14946,10 @@
14822
14946
  * var moddle = new Moddle([pkg]);
14823
14947
  *
14824
14948
  * @param {Array<Package>} packages the packages to contain
14949
+ *
14950
+ * @param { { strict?: boolean } } [config] moddle configuration
14825
14951
  */
14826
- function Moddle(packages) {
14952
+ function Moddle(packages, config = {}) {
14827
14953
 
14828
14954
  this.properties = new Properties(this);
14829
14955
 
@@ -14831,6 +14957,8 @@
14831
14957
  this.registry = new Registry(packages, this.properties);
14832
14958
 
14833
14959
  this.typeCache = {};
14960
+
14961
+ this.config = config;
14834
14962
  }
14835
14963
 
14836
14964
 
@@ -14924,6 +15052,12 @@
14924
15052
  $type: name,
14925
15053
  $instanceOf: function(type) {
14926
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);
14927
15061
  }
14928
15062
  };
14929
15063
 
@@ -14939,6 +15073,8 @@
14939
15073
 
14940
15074
  this.properties.defineDescriptor(element, descriptor);
14941
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 });
14942
15078
  this.properties.define(element, '$parent', { enumerable: false, writable: true });
14943
15079
  this.properties.define(element, '$instanceOf', { enumerable: false, writable: true });
14944
15080