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-modeler v16.1.0
2
+ * bpmn-js - bpmn-modeler 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() :
@@ -832,6 +832,58 @@
832
832
  return Object.assign(target, ...others);
833
833
  }
834
834
 
835
+ /**
836
+ * Sets a nested property of a given object to the specified value.
837
+ *
838
+ * This mutates the object and returns it.
839
+ *
840
+ * @template T
841
+ *
842
+ * @param {T} target The target of the set operation.
843
+ * @param {(string|number)[]} path The path to the nested value.
844
+ * @param {any} value The value to set.
845
+ *
846
+ * @return {T}
847
+ */
848
+ function set$2(target, path, value) {
849
+
850
+ let currentTarget = target;
851
+
852
+ forEach$1(path, function(key, idx) {
853
+
854
+ if (typeof key !== 'number' && typeof key !== 'string') {
855
+ throw new Error('illegal key type: ' + typeof key + '. Key should be of type number or string.');
856
+ }
857
+
858
+ if (key === 'constructor') {
859
+ throw new Error('illegal key: constructor');
860
+ }
861
+
862
+ if (key === '__proto__') {
863
+ throw new Error('illegal key: __proto__');
864
+ }
865
+
866
+ let nextKey = path[idx + 1];
867
+ let nextTarget = currentTarget[key];
868
+
869
+ if (isDefined(nextKey) && isNil(nextTarget)) {
870
+ nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
871
+ }
872
+
873
+ if (isUndefined$2(nextKey)) {
874
+ if (isUndefined$2(value)) {
875
+ delete currentTarget[key];
876
+ } else {
877
+ currentTarget[key] = value;
878
+ }
879
+ } else {
880
+ currentTarget = nextTarget;
881
+ }
882
+ });
883
+
884
+ return target;
885
+ }
886
+
835
887
  /**
836
888
  * Pick properties from the given target.
837
889
  *
@@ -8770,6 +8822,17 @@
8770
8822
  this.idProperty = p;
8771
8823
  };
8772
8824
 
8825
+ DescriptorBuilder.prototype.assertNotTrait = function(typeDescriptor) {
8826
+
8827
+ const _extends = typeDescriptor.extends || [];
8828
+
8829
+ if (_extends.length) {
8830
+ throw new Error(
8831
+ `cannot create <${ typeDescriptor.name }> extending <${ typeDescriptor.extends }>`
8832
+ );
8833
+ }
8834
+ };
8835
+
8773
8836
  DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
8774
8837
  var propertyName = p.name,
8775
8838
  definedProperty = this.propertiesByName[propertyName];
@@ -8788,6 +8851,10 @@
8788
8851
 
8789
8852
  DescriptorBuilder.prototype.addTrait = function(t, inherited) {
8790
8853
 
8854
+ if (inherited) {
8855
+ this.assertNotTrait(t);
8856
+ }
8857
+
8791
8858
  var typesByName = this.allTypesByName,
8792
8859
  types = this.allTypes;
8793
8860
 
@@ -8921,7 +8988,9 @@
8921
8988
  });
8922
8989
 
8923
8990
  forEach$1(type.extends, bind$2(function(extendsName) {
8924
- var extended = this.typeMap[extendsName];
8991
+ var extendsNameNs = parseName(extendsName, ns.prefix);
8992
+
8993
+ var extended = this.typeMap[extendsNameNs.name];
8925
8994
 
8926
8995
  extended.traits = extended.traits || [];
8927
8996
  extended.traits.push(name);
@@ -8950,24 +9019,33 @@
8950
9019
 
8951
9020
  var self = this;
8952
9021
 
9022
+ /**
9023
+ * Traverse the selected super type or trait
9024
+ *
9025
+ * @param {String} cls
9026
+ * @param {Boolean} [trait=false]
9027
+ */
9028
+ function traverse(cls, trait) {
9029
+ var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
9030
+ self.mapTypes(parentNs, iterator, trait);
9031
+ }
9032
+
8953
9033
  /**
8954
9034
  * Traverse the selected trait.
8955
9035
  *
8956
9036
  * @param {String} cls
8957
9037
  */
8958
9038
  function traverseTrait(cls) {
8959
- return traverseSuper(cls, true);
9039
+ return traverse(cls, true);
8960
9040
  }
8961
9041
 
8962
9042
  /**
8963
- * Traverse the selected super type or trait
9043
+ * Traverse the selected super type
8964
9044
  *
8965
9045
  * @param {String} cls
8966
- * @param {Boolean} [trait=false]
8967
9046
  */
8968
- function traverseSuper(cls, trait) {
8969
- var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
8970
- self.mapTypes(parentNs, iterator, trait);
9047
+ function traverseSuper(cls) {
9048
+ return traverse(cls, false);
8971
9049
  }
8972
9050
 
8973
9051
  if (!type) {
@@ -9050,7 +9128,7 @@
9050
9128
  throw new TypeError('property name must be a non-empty string');
9051
9129
  }
9052
9130
 
9053
- var property = this.model.getPropertyDescriptor(target, name);
9131
+ var property = this.getProperty(target, name);
9054
9132
 
9055
9133
  var propertyName = property && property.name;
9056
9134
 
@@ -9061,7 +9139,7 @@
9061
9139
  if (property) {
9062
9140
  delete target[propertyName];
9063
9141
  } else {
9064
- delete target.$attrs[name];
9142
+ delete target.$attrs[stripGlobal(name)];
9065
9143
  }
9066
9144
  } else {
9067
9145
 
@@ -9074,7 +9152,7 @@
9074
9152
  defineProperty(target, property, value);
9075
9153
  }
9076
9154
  } else {
9077
- target.$attrs[name] = value;
9155
+ target.$attrs[stripGlobal(name)] = value;
9078
9156
  }
9079
9157
  }
9080
9158
  };
@@ -9089,10 +9167,10 @@
9089
9167
  */
9090
9168
  Properties.prototype.get = function(target, name) {
9091
9169
 
9092
- var property = this.model.getPropertyDescriptor(target, name);
9170
+ var property = this.getProperty(target, name);
9093
9171
 
9094
9172
  if (!property) {
9095
- return target.$attrs[name];
9173
+ return target.$attrs[stripGlobal(name)];
9096
9174
  }
9097
9175
 
9098
9176
  var propertyName = property.name;
@@ -9146,6 +9224,44 @@
9146
9224
  this.define(target, '$model', { value: model });
9147
9225
  };
9148
9226
 
9227
+ /**
9228
+ * Return property with the given name on the element.
9229
+ *
9230
+ * @param {any} target
9231
+ * @param {string} name
9232
+ *
9233
+ * @return {object | null} property
9234
+ */
9235
+ Properties.prototype.getProperty = function(target, name) {
9236
+
9237
+ var model = this.model;
9238
+
9239
+ var property = model.getPropertyDescriptor(target, name);
9240
+
9241
+ if (property) {
9242
+ return property;
9243
+ }
9244
+
9245
+ if (name.includes(':')) {
9246
+ return null;
9247
+ }
9248
+
9249
+ const strict = model.config.strict;
9250
+
9251
+ if (typeof strict !== 'undefined') {
9252
+ const error = new TypeError(`unknown property <${ name }> on <${ target.$type }>`);
9253
+
9254
+ if (strict) {
9255
+ throw error;
9256
+ } else {
9257
+
9258
+ // eslint-disable-next-line no-undef
9259
+ typeof console !== 'undefined' && console.warn(error);
9260
+ }
9261
+ }
9262
+
9263
+ return null;
9264
+ };
9149
9265
 
9150
9266
  function isUndefined(val) {
9151
9267
  return typeof val === 'undefined';
@@ -9160,6 +9276,10 @@
9160
9276
  });
9161
9277
  }
9162
9278
 
9279
+ function stripGlobal(name) {
9280
+ return name.replace(/^:/, '');
9281
+ }
9282
+
9163
9283
  // Moddle implementation /////////////////////////////////////////////////
9164
9284
 
9165
9285
  /**
@@ -9182,8 +9302,10 @@
9182
9302
  * var moddle = new Moddle([pkg]);
9183
9303
  *
9184
9304
  * @param {Array<Package>} packages the packages to contain
9305
+ *
9306
+ * @param { { strict?: boolean } } [config] moddle configuration
9185
9307
  */
9186
- function Moddle(packages) {
9308
+ function Moddle(packages, config = {}) {
9187
9309
 
9188
9310
  this.properties = new Properties(this);
9189
9311
 
@@ -9191,6 +9313,8 @@
9191
9313
  this.registry = new Registry(packages, this.properties);
9192
9314
 
9193
9315
  this.typeCache = {};
9316
+
9317
+ this.config = config;
9194
9318
  }
9195
9319
 
9196
9320
 
@@ -9284,6 +9408,12 @@
9284
9408
  $type: name,
9285
9409
  $instanceOf: function(type) {
9286
9410
  return type === this.$type;
9411
+ },
9412
+ get: function(key) {
9413
+ return this[key];
9414
+ },
9415
+ set: function(key, value) {
9416
+ set$2(this, [ key ], value);
9287
9417
  }
9288
9418
  };
9289
9419
 
@@ -9299,6 +9429,8 @@
9299
9429
 
9300
9430
  this.properties.defineDescriptor(element, descriptor);
9301
9431
  this.properties.defineModel(element, this);
9432
+ this.properties.define(element, 'get', { enumerable: false, writable: true });
9433
+ this.properties.define(element, 'set', { enumerable: false, writable: true });
9302
9434
  this.properties.define(element, '$parent', { enumerable: false, writable: true });
9303
9435
  this.properties.define(element, '$instanceOf', { enumerable: false, writable: true });
9304
9436