bpmn-moddle 7.1.0 → 7.1.3

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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,19 @@ All notable changes to [bpmn-moddle](https://github.com/bpmn-io/bpmn-moddle) are
6
6
 
7
7
  ___Note:__ Yet to be released changes appear here._
8
8
 
9
+ ## 7.1.3
10
+
11
+ * `FIX`: de-duplicate attributes
12
+ * `DEPS`: update to `moddle-xml@9.0.6`
13
+
14
+ ## 7.1.2
15
+
16
+ * `FIX`: make `bpmn:InteractionNode` include `bpmn:CallActivity`
17
+
18
+ ## 7.1.1
19
+
20
+ * `FIX`: properly inline BPMN in Color schema ([#88](https://github.com/bpmn-io/bpmn-moddle/pull/88))
21
+
9
22
  ## 7.1.0
10
23
 
11
24
  * `FEAT`: add BPMN in Color schema ([#87](https://github.com/bpmn-io/bpmn-moddle/pull/87))
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BpmnModdle = factory());
5
- }(this, (function () { 'use strict';
5
+ })(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * Flatten array, one level deep.
@@ -14,7 +14,7 @@
14
14
 
15
15
  var nativeToString = Object.prototype.toString;
16
16
  var nativeHasOwnProperty = Object.prototype.hasOwnProperty;
17
- function isUndefined(obj) {
17
+ function isUndefined$1(obj) {
18
18
  return obj === undefined;
19
19
  }
20
20
  function isArray(obj) {
@@ -63,6 +63,26 @@
63
63
  });
64
64
  return match;
65
65
  }
66
+ /**
67
+ * Find element index in collection.
68
+ *
69
+ * @param {Array|Object} collection
70
+ * @param {Function} matcher
71
+ *
72
+ * @return {Object}
73
+ */
74
+
75
+ function findIndex(collection, matcher) {
76
+ matcher = toMatcher(matcher);
77
+ var idx = isArray(collection) ? -1 : undefined;
78
+ forEach(collection, function (val, key) {
79
+ if (matcher(val, key)) {
80
+ idx = key;
81
+ return false;
82
+ }
83
+ });
84
+ return idx;
85
+ }
66
86
  /**
67
87
  * Find element in collection.
68
88
  *
@@ -94,7 +114,7 @@
94
114
  function forEach(collection, iterator) {
95
115
  var val, result;
96
116
 
97
- if (isUndefined(collection)) {
117
+ if (isUndefined$1(collection)) {
98
118
  return;
99
119
  }
100
120
 
@@ -786,7 +806,7 @@
786
806
 
787
807
  var propertyName = property && property.name;
788
808
 
789
- if (isUndefined$1(value)) {
809
+ if (isUndefined(value)) {
790
810
  // unset the property, if the specified value is undefined;
791
811
  // delete from $attrs (for extensions) or the target itself
792
812
  if (property) {
@@ -863,7 +883,7 @@
863
883
  };
864
884
 
865
885
 
866
- function isUndefined$1(val) {
886
+ function isUndefined(val) {
867
887
  return typeof val === 'undefined';
868
888
  }
869
889
 
@@ -1147,11 +1167,11 @@
1147
1167
 
1148
1168
  var XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';
1149
1169
  var XSI_PREFIX = 'xsi';
1150
- var XSI_TYPE = 'xsi:type';
1170
+ var XSI_TYPE$1 = 'xsi:type';
1151
1171
 
1152
1172
  var NON_WHITESPACE_OUTSIDE_ROOT_NODE = 'non-whitespace outside of root node';
1153
1173
 
1154
- function error(msg) {
1174
+ function error$1(msg) {
1155
1175
  return new Error(msg);
1156
1176
  }
1157
1177
 
@@ -1272,7 +1292,7 @@
1272
1292
  */
1273
1293
  function handleError(err) {
1274
1294
  if (!(err instanceof Error)) {
1275
- err = error(err);
1295
+ err = error$1(err);
1276
1296
  }
1277
1297
 
1278
1298
  returnError = err;
@@ -1292,7 +1312,7 @@
1292
1312
  }
1293
1313
 
1294
1314
  if (!(err instanceof Error)) {
1295
- err = error(err);
1315
+ err = error$1(err);
1296
1316
  }
1297
1317
 
1298
1318
  onWarning(err, getContext);
@@ -1309,7 +1329,7 @@
1309
1329
  this['on'] = function(name, cb) {
1310
1330
 
1311
1331
  if (typeof cb !== 'function') {
1312
- throw error('required args <name, cb>');
1332
+ throw error$1('required args <name, cb>');
1313
1333
  }
1314
1334
 
1315
1335
  switch (name) {
@@ -1323,7 +1343,7 @@
1323
1343
  case 'question': onQuestion = cb; break; // <? .... ?>
1324
1344
  case 'comment': onComment = cb; break;
1325
1345
  default:
1326
- throw error('unsupported event: ' + name);
1346
+ throw error$1('unsupported event: ' + name);
1327
1347
  }
1328
1348
 
1329
1349
  return this;
@@ -1350,7 +1370,7 @@
1350
1370
  }
1351
1371
 
1352
1372
  if (typeof nsMap !== 'object') {
1353
- throw error('required args <nsMap={}>');
1373
+ throw error$1('required args <nsMap={}>');
1354
1374
  }
1355
1375
 
1356
1376
  var _nsUriToPrefix = {}, k;
@@ -1377,7 +1397,7 @@
1377
1397
  */
1378
1398
  this['parse'] = function(xml) {
1379
1399
  if (typeof xml !== 'string') {
1380
- throw error('required args <xml=string>');
1400
+ throw error$1('required args <xml=string>');
1381
1401
  }
1382
1402
 
1383
1403
  returnError = null;
@@ -1686,7 +1706,7 @@
1686
1706
  // end: normalize ns attribute name
1687
1707
 
1688
1708
  // normalize xsi:type ns attribute value
1689
- if (name === XSI_TYPE) {
1709
+ if (name === XSI_TYPE$1) {
1690
1710
  w = value.indexOf(':');
1691
1711
 
1692
1712
  if (w !== -1) {
@@ -1732,7 +1752,7 @@
1732
1752
  // end: normalize ns attribute name
1733
1753
 
1734
1754
  // normalize xsi:type ns attribute value
1735
- if (name === XSI_TYPE) {
1755
+ if (name === XSI_TYPE$1) {
1736
1756
  w = value.indexOf(':');
1737
1757
 
1738
1758
  if (w !== -1) {
@@ -2175,14 +2195,14 @@
2175
2195
  'xml': 'http://www.w3.org/XML/1998/namespace'
2176
2196
  };
2177
2197
 
2178
- var XSI_TYPE$1 = 'xsi:type';
2198
+ var XSI_TYPE = 'xsi:type';
2179
2199
 
2180
2200
  function serializeFormat(element) {
2181
2201
  return element.xml && element.xml.serialize;
2182
2202
  }
2183
2203
 
2184
2204
  function serializeAsType(element) {
2185
- return serializeFormat(element) === XSI_TYPE$1;
2205
+ return serializeFormat(element) === XSI_TYPE;
2186
2206
  }
2187
2207
 
2188
2208
  function serializeAsProperty(element) {
@@ -2224,7 +2244,7 @@
2224
2244
  return prefixedToName(nameNs, pkg);
2225
2245
  }
2226
2246
 
2227
- function error$1(message) {
2247
+ function error(message) {
2228
2248
  return new Error(message);
2229
2249
  }
2230
2250
 
@@ -2282,7 +2302,7 @@
2282
2302
  this.addElement = function(element) {
2283
2303
 
2284
2304
  if (!element) {
2285
- throw error$1('expected element');
2305
+ throw error('expected element');
2286
2306
  }
2287
2307
 
2288
2308
  var elementsById = this.elementsById;
@@ -2303,7 +2323,7 @@
2303
2323
  }
2304
2324
 
2305
2325
  if (elementsById[id]) {
2306
- throw error$1('duplicate ID <' + id + '>');
2326
+ throw error('duplicate ID <' + id + '>');
2307
2327
  }
2308
2328
 
2309
2329
  elementsById[id] = element;
@@ -2363,7 +2383,7 @@
2363
2383
  ReferenceHandler.prototype.handleNode = function(node) {
2364
2384
 
2365
2385
  if (this.element) {
2366
- throw error$1('expected no sub nodes');
2386
+ throw error('expected no sub nodes');
2367
2387
  } else {
2368
2388
  this.element = this.createReference(node);
2369
2389
  }
@@ -2447,7 +2467,7 @@
2447
2467
  bodyProperty = descriptor.bodyProperty;
2448
2468
 
2449
2469
  if (!bodyProperty) {
2450
- throw error$1('unexpected body text <' + text + '>');
2470
+ throw error('unexpected body text <' + text + '>');
2451
2471
  }
2452
2472
 
2453
2473
  BodyHandler.prototype.handleText.call(this, text);
@@ -2553,7 +2573,7 @@
2553
2573
  if (property && !property.isAttr) {
2554
2574
 
2555
2575
  if (serializeAsType(property)) {
2556
- elementTypeName = node.attributes[XSI_TYPE$1];
2576
+ elementTypeName = node.attributes[XSI_TYPE];
2557
2577
 
2558
2578
  // xsi type is optional, if it does not exists the
2559
2579
  // default type is assumed
@@ -2603,7 +2623,7 @@
2603
2623
  }
2604
2624
  }
2605
2625
 
2606
- throw error$1('unrecognized element <' + nameNs.name + '>');
2626
+ throw error('unrecognized element <' + nameNs.name + '>');
2607
2627
  };
2608
2628
 
2609
2629
  ElementHandler.prototype.toString = function() {
@@ -2706,7 +2726,7 @@
2706
2726
  //
2707
2727
  // this ensures we don't mistakenly import wrong namespace elements
2708
2728
  if (!type.hasType(typeName)) {
2709
- throw error$1('unexpected element <' + node.originalName + '>');
2729
+ throw error('unexpected element <' + node.originalName + '>');
2710
2730
  }
2711
2731
 
2712
2732
  return ElementHandler.prototype.createElement.call(this, node);
@@ -2874,7 +2894,7 @@
2874
2894
 
2875
2895
  return true;
2876
2896
  } else {
2877
- throw error$1(message);
2897
+ throw error(message);
2878
2898
  }
2879
2899
  }
2880
2900
 
@@ -3055,7 +3075,7 @@
3055
3075
  var rootElement = rootHandler.element;
3056
3076
 
3057
3077
  if (!err && !rootElement) {
3058
- err = error$1('failed to parse document as <' + rootHandler.type.$descriptor.name + '>');
3078
+ err = error('failed to parse document as <' + rootHandler.type.$descriptor.name + '>');
3059
3079
  }
3060
3080
 
3061
3081
  var warnings = context.warnings;
@@ -3569,7 +3589,7 @@
3569
3589
 
3570
3590
  // do not serialize xsi:type attribute
3571
3591
  // it is set manually based on the actual implementation type
3572
- if (attr.name === XSI_TYPE$1) {
3592
+ if (attr.name === XSI_TYPE) {
3573
3593
  return;
3574
3594
  }
3575
3595
 
@@ -3766,7 +3786,23 @@
3766
3786
  value = escapeAttr(value);
3767
3787
  }
3768
3788
 
3769
- attrs.push({ name: name, value: value });
3789
+ // de-duplicate attributes
3790
+ // https://github.com/bpmn-io/moddle-xml/issues/66
3791
+ var idx = findIndex(attrs, function(element) {
3792
+ return (
3793
+ element.name.localName === name.localName &&
3794
+ element.name.uri === name.uri &&
3795
+ element.name.prefix === name.prefix
3796
+ );
3797
+ });
3798
+
3799
+ var attr = { name: name, value: value };
3800
+
3801
+ if (idx !== -1) {
3802
+ attrs.splice(idx, 1, attr);
3803
+ } else {
3804
+ attrs.push(attr);
3805
+ }
3770
3806
  };
3771
3807
 
3772
3808
  ElementSerializer.prototype.serializeAttributes = function(writer) {
@@ -3851,7 +3887,7 @@
3851
3887
  typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
3852
3888
 
3853
3889
  this.addAttribute(
3854
- this.nsAttributeName(XSI_TYPE$1),
3890
+ this.nsAttributeName(XSI_TYPE),
3855
3891
  (typeNs.prefix ? typeNs.prefix + ':' : '') + typePrefix + descriptor.ns.localName
3856
3892
  );
3857
3893
 
@@ -4026,12 +4062,12 @@
4026
4062
  });
4027
4063
  };
4028
4064
 
4029
- var name = "BPMN20";
4030
- var uri = "http://www.omg.org/spec/BPMN/20100524/MODEL";
4031
- var prefix = "bpmn";
4032
- var associations = [
4065
+ var name$5 = "BPMN20";
4066
+ var uri$5 = "http://www.omg.org/spec/BPMN/20100524/MODEL";
4067
+ var prefix$5 = "bpmn";
4068
+ var associations$5 = [
4033
4069
  ];
4034
- var types = [
4070
+ var types$5 = [
4035
4071
  {
4036
4072
  name: "Interface",
4037
4073
  superClass: [
@@ -6505,7 +6541,8 @@
6505
6541
  {
6506
6542
  name: "CallActivity",
6507
6543
  superClass: [
6508
- "Activity"
6544
+ "Activity",
6545
+ "InteractionNode"
6509
6546
  ],
6510
6547
  properties: [
6511
6548
  {
@@ -6848,7 +6885,7 @@
6848
6885
  ]
6849
6886
  }
6850
6887
  ];
6851
- var enumerations = [
6888
+ var enumerations$3 = [
6852
6889
  {
6853
6890
  name: "ProcessType",
6854
6891
  literalValues: [
@@ -6979,24 +7016,24 @@
6979
7016
  ]
6980
7017
  }
6981
7018
  ];
6982
- var xml = {
7019
+ var xml$1 = {
6983
7020
  tagAlias: "lowerCase",
6984
7021
  typePrefix: "t"
6985
7022
  };
6986
7023
  var BpmnPackage = {
6987
- name: name,
6988
- uri: uri,
6989
- prefix: prefix,
6990
- associations: associations,
6991
- types: types,
6992
- enumerations: enumerations,
6993
- xml: xml
7024
+ name: name$5,
7025
+ uri: uri$5,
7026
+ prefix: prefix$5,
7027
+ associations: associations$5,
7028
+ types: types$5,
7029
+ enumerations: enumerations$3,
7030
+ xml: xml$1
6994
7031
  };
6995
7032
 
6996
- var name$1 = "BPMNDI";
6997
- var uri$1 = "http://www.omg.org/spec/BPMN/20100524/DI";
6998
- var prefix$1 = "bpmndi";
6999
- var types$1 = [
7033
+ var name$4 = "BPMNDI";
7034
+ var uri$4 = "http://www.omg.org/spec/BPMN/20100524/DI";
7035
+ var prefix$4 = "bpmndi";
7036
+ var types$4 = [
7000
7037
  {
7001
7038
  name: "BPMNDiagram",
7002
7039
  properties: [
@@ -7147,7 +7184,7 @@
7147
7184
  ]
7148
7185
  }
7149
7186
  ];
7150
- var enumerations$1 = [
7187
+ var enumerations$2 = [
7151
7188
  {
7152
7189
  name: "ParticipantBandKind",
7153
7190
  literalValues: [
@@ -7183,21 +7220,21 @@
7183
7220
  ]
7184
7221
  }
7185
7222
  ];
7186
- var associations$1 = [
7223
+ var associations$4 = [
7187
7224
  ];
7188
7225
  var BpmnDiPackage = {
7189
- name: name$1,
7190
- uri: uri$1,
7191
- prefix: prefix$1,
7192
- types: types$1,
7193
- enumerations: enumerations$1,
7194
- associations: associations$1
7226
+ name: name$4,
7227
+ uri: uri$4,
7228
+ prefix: prefix$4,
7229
+ types: types$4,
7230
+ enumerations: enumerations$2,
7231
+ associations: associations$4
7195
7232
  };
7196
7233
 
7197
- var name$2 = "DC";
7198
- var uri$2 = "http://www.omg.org/spec/DD/20100524/DC";
7199
- var prefix$2 = "dc";
7200
- var types$2 = [
7234
+ var name$3 = "DC";
7235
+ var uri$3 = "http://www.omg.org/spec/DD/20100524/DC";
7236
+ var prefix$3 = "dc";
7237
+ var types$3 = [
7201
7238
  {
7202
7239
  name: "Boolean"
7203
7240
  },
@@ -7290,20 +7327,20 @@
7290
7327
  ]
7291
7328
  }
7292
7329
  ];
7293
- var associations$2 = [
7330
+ var associations$3 = [
7294
7331
  ];
7295
7332
  var DcPackage = {
7296
- name: name$2,
7297
- uri: uri$2,
7298
- prefix: prefix$2,
7299
- types: types$2,
7300
- associations: associations$2
7333
+ name: name$3,
7334
+ uri: uri$3,
7335
+ prefix: prefix$3,
7336
+ types: types$3,
7337
+ associations: associations$3
7301
7338
  };
7302
7339
 
7303
- var name$3 = "DI";
7304
- var uri$3 = "http://www.omg.org/spec/DD/20100524/DI";
7305
- var prefix$3 = "di";
7306
- var types$3 = [
7340
+ var name$2 = "DI";
7341
+ var uri$2 = "http://www.omg.org/spec/DD/20100524/DI";
7342
+ var prefix$2 = "di";
7343
+ var types$2 = [
7307
7344
  {
7308
7345
  name: "DiagramElement",
7309
7346
  isAbstract: true,
@@ -7532,24 +7569,24 @@
7532
7569
  ]
7533
7570
  }
7534
7571
  ];
7535
- var associations$3 = [
7572
+ var associations$2 = [
7536
7573
  ];
7537
- var xml$1 = {
7574
+ var xml = {
7538
7575
  tagAlias: "lowerCase"
7539
7576
  };
7540
7577
  var DiPackage = {
7541
- name: name$3,
7542
- uri: uri$3,
7543
- prefix: prefix$3,
7544
- types: types$3,
7545
- associations: associations$3,
7546
- xml: xml$1
7578
+ name: name$2,
7579
+ uri: uri$2,
7580
+ prefix: prefix$2,
7581
+ types: types$2,
7582
+ associations: associations$2,
7583
+ xml: xml
7547
7584
  };
7548
7585
 
7549
- var name$4 = "bpmn.io colors for BPMN";
7550
- var uri$4 = "http://bpmn.io/schema/bpmn/biocolor/1.0";
7551
- var prefix$4 = "bioc";
7552
- var types$4 = [
7586
+ var name$1 = "bpmn.io colors for BPMN";
7587
+ var uri$1 = "http://bpmn.io/schema/bpmn/biocolor/1.0";
7588
+ var prefix$1 = "bioc";
7589
+ var types$1 = [
7553
7590
  {
7554
7591
  name: "ColoredShape",
7555
7592
  "extends": [
@@ -7587,23 +7624,23 @@
7587
7624
  ]
7588
7625
  }
7589
7626
  ];
7590
- var enumerations$2 = [
7627
+ var enumerations$1 = [
7591
7628
  ];
7592
- var associations$4 = [
7629
+ var associations$1 = [
7593
7630
  ];
7594
7631
  var BiocPackage = {
7595
- name: name$4,
7596
- uri: uri$4,
7597
- prefix: prefix$4,
7598
- types: types$4,
7599
- enumerations: enumerations$2,
7600
- associations: associations$4
7632
+ name: name$1,
7633
+ uri: uri$1,
7634
+ prefix: prefix$1,
7635
+ types: types$1,
7636
+ enumerations: enumerations$1,
7637
+ associations: associations$1
7601
7638
  };
7602
7639
 
7603
- var name$5 = "BPMN in Color";
7604
- var uri$5 = "http://www.omg.org/spec/BPMN/non-normative/color/1.0";
7605
- var prefix$5 = "color";
7606
- var types$5 = [
7640
+ var name = "BPMN in Color";
7641
+ var uri = "http://www.omg.org/spec/BPMN/non-normative/color/1.0";
7642
+ var prefix = "color";
7643
+ var types = [
7607
7644
  {
7608
7645
  name: "ColoredLabel",
7609
7646
  "extends": [
@@ -7649,17 +7686,17 @@
7649
7686
  ]
7650
7687
  }
7651
7688
  ];
7652
- var enumerations$3 = [
7689
+ var enumerations = [
7653
7690
  ];
7654
- var associations$5 = [
7691
+ var associations = [
7655
7692
  ];
7656
7693
  var BpmnInColorPackage = {
7657
- name: name$5,
7658
- uri: uri$5,
7659
- prefix: prefix$5,
7660
- types: types$5,
7661
- enumerations: enumerations$3,
7662
- associations: associations$5
7694
+ name: name,
7695
+ uri: uri,
7696
+ prefix: prefix,
7697
+ types: types,
7698
+ enumerations: enumerations,
7699
+ associations: associations
7663
7700
  };
7664
7701
 
7665
7702
  var packages = {
@@ -7679,4 +7716,4 @@
7679
7716
 
7680
7717
  return simple;
7681
7718
 
7682
- })));
7719
+ }));