bpmn-moddle 7.0.3 → 7.1.1

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,24 @@ 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.1
10
+
11
+ * `FIX`: properly inline BPMN in Color schema ([#88](https://github.com/bpmn-io/bpmn-moddle/pull/88))
12
+
13
+ ## 7.1.0
14
+
15
+ * `FEAT`: add BPMN in Color schema ([#87](https://github.com/bpmn-io/bpmn-moddle/pull/87))
16
+ * `CHORE`: update dependencies
17
+
18
+ ## 7.0.5
19
+
20
+ * `FIX`: correct serialization of `xml` prefixed attributes on `Any` elements
21
+ * `CHORE`: update to `moddle-xml@9.0.5`
22
+
23
+ ## 7.0.4
24
+
25
+ * `CHORE`: update to `moddle-xml@9.0.4`
26
+
9
27
  ## 7.0.3
10
28
 
11
29
  * `CHORE`: update to `moddle-xml@9.0.3`
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # bpmn-moddle
2
2
 
3
- [![Build Status](https://travis-ci.org/bpmn-io/bpmn-moddle.svg?branch=master)](https://travis-ci.org/bpmn-io/bpmn-moddle)
3
+ [![CI](https://github.com/bpmn-io/bpmn-moddle/workflows/CI/badge.svg)](https://github.com/bpmn-io/bpmn-moddle/actions?query=workflow%3ACI)
4
4
 
5
5
  Read and write BPMN 2.0 diagram files in NodeJS and the browser.
6
6
 
@@ -37,7 +37,7 @@ definitions.get('rootElements').push(bpmnProcess);
37
37
 
38
38
  // xmlStrUpdated contains new id and the added process
39
39
  const {
40
- xml: xmlStrUpdated
40
+ xml: xmlStrUpdated
41
41
  } = await moddle.toXML(definitions);
42
42
  ```
43
43
 
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = global || self, global.BpmnModdle = factory());
5
- }(this, function () { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BpmnModdle = factory());
5
+ }(this, (function () { 'use strict';
6
6
 
7
7
  /**
8
8
  * Flatten array, one level deep.
@@ -111,23 +111,6 @@
111
111
  }
112
112
  }
113
113
  }
114
- /**
115
- * Transform a collection into another collection
116
- * by piping each member through the given fn.
117
- *
118
- * @param {Object|Array} collection
119
- * @param {Function} fn
120
- *
121
- * @return {Array} transformed collection
122
- */
123
-
124
- function map(collection, fn) {
125
- var result = [];
126
- forEach(collection, function (val, key) {
127
- result.push(fn(val, key));
128
- });
129
- return result;
130
- }
131
114
 
132
115
  function toMatcher(matcher) {
133
116
  return isFunction(matcher) ? matcher : function (e) {
@@ -295,7 +278,7 @@
295
278
  String: function(s) { return s; },
296
279
  Boolean: function(s) { return s === 'true'; },
297
280
  Integer: function(s) { return parseInt(s, 10); },
298
- Real: function(s) { return parseFloat(s, 10); }
281
+ Real: function(s) { return parseFloat(s); }
299
282
  };
300
283
 
301
284
  /**
@@ -1033,6 +1016,7 @@
1033
1016
  this.properties.defineDescriptor(element, descriptor);
1034
1017
  this.properties.defineModel(element, this);
1035
1018
  this.properties.define(element, '$parent', { enumerable: false, writable: true });
1019
+ this.properties.define(element, '$instanceOf', { enumerable: false, writable: true });
1036
1020
 
1037
1021
  forEach(properties, function(a, key) {
1038
1022
  if (isObject(a) && a.value !== undefined) {
@@ -2312,6 +2296,7 @@
2312
2296
  id = element.get(idProperty.name);
2313
2297
 
2314
2298
  if (id) {
2299
+
2315
2300
  // for QName validation as per http://www.w3.org/TR/REC-xml/#NT-NameChar
2316
2301
  if (!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(id)) {
2317
2302
  throw new Error('illegal ID <' + id + '>');
@@ -2509,6 +2494,7 @@
2509
2494
  id: value
2510
2495
  });
2511
2496
  } else {
2497
+
2512
2498
  // IDREFS: parse references as whitespace-separated list
2513
2499
  values = value.split(' ');
2514
2500
 
@@ -2606,6 +2592,7 @@
2606
2592
  });
2607
2593
  }
2608
2594
  } else {
2595
+
2609
2596
  // parse unknown element (maybe extension)
2610
2597
  property = find(descriptor.properties, function(p) {
2611
2598
  return !p.isReference && !p.isAttribute && p.type === 'Element';
@@ -2681,6 +2668,7 @@
2681
2668
 
2682
2669
  this.context.addReference(newElement);
2683
2670
  } else {
2671
+
2684
2672
  // establish child -> parent relationship
2685
2673
  newElement.$parent = element;
2686
2674
  }
@@ -2818,15 +2806,18 @@
2818
2806
  var rootHandler = options.rootHandler;
2819
2807
 
2820
2808
  if (options instanceof ElementHandler) {
2809
+
2821
2810
  // root handler passed via (xml, { rootHandler: ElementHandler }, ...)
2822
2811
  rootHandler = options;
2823
2812
  options = {};
2824
2813
  } else {
2825
2814
  if (typeof options === 'string') {
2815
+
2826
2816
  // rootHandler passed via (xml, 'someString', ...)
2827
2817
  rootHandler = this.handler(options);
2828
2818
  options = {};
2829
2819
  } else if (typeof rootHandler === 'string') {
2820
+
2830
2821
  // rootHandler passed via (xml, { rootHandler: 'someString' }, ...)
2831
2822
  rootHandler = this.handler(rootHandler);
2832
2823
  }
@@ -2888,6 +2879,7 @@
2888
2879
  }
2889
2880
 
2890
2881
  function handleWarning(err, getContext) {
2882
+
2891
2883
  // just like handling errors in <lax=true> mode
2892
2884
  return handleError(err, getContext, true);
2893
2885
  }
@@ -2927,9 +2919,11 @@
2927
2919
  }
2928
2920
 
2929
2921
  if (!reference) {
2922
+
2930
2923
  // remove unresolvable reference
2931
2924
  collection.splice(idx, 1);
2932
2925
  } else {
2926
+
2933
2927
  // add or update reference in collection
2934
2928
  collection[idx] = reference;
2935
2929
  }
@@ -2992,11 +2986,11 @@
2992
2986
  }
2993
2987
 
2994
2988
  function handleText(text, getContext) {
2989
+
2995
2990
  // strip whitespace only nodes, i.e. before
2996
2991
  // <!CDATA[ ... ]> sections and in between tags
2997
- text = text.trim();
2998
2992
 
2999
- if (!text) {
2993
+ if (!text.trim()) {
3000
2994
  return;
3001
2995
  }
3002
2996
 
@@ -3214,7 +3208,11 @@
3214
3208
 
3215
3209
  function getNsAttrs(namespaces) {
3216
3210
 
3217
- return map(namespaces.getUsed(), function(ns) {
3211
+ return namespaces.getUsed().filter(function(ns) {
3212
+
3213
+ // do not serialize built in <xml> namespace
3214
+ return ns.prefix !== 'xml';
3215
+ }).map(function(ns) {
3218
3216
  var name = 'xmlns' + (ns.prefix ? ':' + ns.prefix : '');
3219
3217
  return { name: name, value: ns.uri };
3220
3218
  });
@@ -3244,7 +3242,7 @@
3244
3242
  }
3245
3243
 
3246
3244
  // do not serialize defaults
3247
- if (!element.hasOwnProperty(name)) {
3245
+ if (!has(element, name)) {
3248
3246
  return false;
3249
3247
  }
3250
3248
 
@@ -3522,9 +3520,11 @@
3522
3520
  }
3523
3521
 
3524
3522
  if (model && model.getPackage(value)) {
3523
+
3525
3524
  // register well known namespace
3526
3525
  this.logNamespace(ns, true, true);
3527
3526
  } else {
3527
+
3528
3528
  // log custom namespace directly as used
3529
3529
  var actualNs = this.logNamespaceUsed(ns, true);
3530
3530
 
@@ -3612,6 +3612,7 @@
3612
3612
  body.push(new ReferenceSerializer(self.addTagName(self.nsPropertyTagName(p))).build(v));
3613
3613
  });
3614
3614
  } else {
3615
+
3615
3616
  // allow serialization via type
3616
3617
  // rather than element name
3617
3618
  var asType = serializeAsType(p),
@@ -3662,7 +3663,7 @@
3662
3663
 
3663
3664
  var existing = namespaces.byUri(nsUri);
3664
3665
 
3665
- if (nsPrefix !== 'xml' && (!existing || local)) {
3666
+ if (!existing || local) {
3666
3667
  namespaces.add(ns, wellknown);
3667
3668
  }
3668
3669
 
@@ -3739,6 +3740,7 @@
3739
3740
  forEach(value, function(v) {
3740
3741
  values.push(v.id);
3741
3742
  });
3743
+
3742
3744
  // IDREFS is a whitespace-separated list of references.
3743
3745
  value = values.join(' ');
3744
3746
  }
@@ -7598,12 +7600,75 @@
7598
7600
  associations: associations$4
7599
7601
  };
7600
7602
 
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 = [
7607
+ {
7608
+ name: "ColoredLabel",
7609
+ "extends": [
7610
+ "bpmndi:BPMNLabel"
7611
+ ],
7612
+ properties: [
7613
+ {
7614
+ name: "color",
7615
+ isAttr: true,
7616
+ type: "String"
7617
+ }
7618
+ ]
7619
+ },
7620
+ {
7621
+ name: "ColoredShape",
7622
+ "extends": [
7623
+ "bpmndi:BPMNShape"
7624
+ ],
7625
+ properties: [
7626
+ {
7627
+ name: "background-color",
7628
+ isAttr: true,
7629
+ type: "String"
7630
+ },
7631
+ {
7632
+ name: "border-color",
7633
+ isAttr: true,
7634
+ type: "String"
7635
+ }
7636
+ ]
7637
+ },
7638
+ {
7639
+ name: "ColoredEdge",
7640
+ "extends": [
7641
+ "bpmndi:BPMNEdge"
7642
+ ],
7643
+ properties: [
7644
+ {
7645
+ name: "border-color",
7646
+ isAttr: true,
7647
+ type: "String"
7648
+ }
7649
+ ]
7650
+ }
7651
+ ];
7652
+ var enumerations$3 = [
7653
+ ];
7654
+ var associations$5 = [
7655
+ ];
7656
+ 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
7663
+ };
7664
+
7601
7665
  var packages = {
7602
7666
  bpmn: BpmnPackage,
7603
7667
  bpmndi: BpmnDiPackage,
7604
7668
  dc: DcPackage,
7605
7669
  di: DiPackage,
7606
- bioc: BiocPackage
7670
+ bioc: BiocPackage,
7671
+ color: BpmnInColorPackage
7607
7672
  };
7608
7673
 
7609
7674
  function simple(additionalPackages, options) {
@@ -7614,4 +7679,4 @@
7614
7679
 
7615
7680
  return simple;
7616
7681
 
7617
- }));
7682
+ })));