bpmn-js 3.4.3 → 3.5.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 v3.4.3
2
+ * bpmn-js - bpmn-viewer v3.5.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: 2019-06-13
11
+ * Date: 2019-06-28
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -26,28 +26,35 @@
26
26
 
27
27
  var nativeToString = Object.prototype.toString;
28
28
  var nativeHasOwnProperty = Object.prototype.hasOwnProperty;
29
+
29
30
  function isUndefined(obj) {
30
31
  return obj === undefined;
31
32
  }
33
+
32
34
  function isDefined(obj) {
33
35
  return obj !== undefined;
34
36
  }
37
+
35
38
  function isArray(obj) {
36
39
  return nativeToString.call(obj) === '[object Array]';
37
40
  }
41
+
38
42
  function isObject(obj) {
39
43
  return nativeToString.call(obj) === '[object Object]';
40
44
  }
45
+
41
46
  function isNumber(obj) {
42
47
  return nativeToString.call(obj) === '[object Number]';
43
48
  }
49
+
44
50
  function isFunction(obj) {
45
- var tag = nativeToString.call(obj);
46
- return tag === '[object Function]' || tag === '[object AsyncFunction]' || tag === '[object GeneratorFunction]' || tag === '[object AsyncGeneratorFunction]' || tag === '[object Proxy]';
51
+ return nativeToString.call(obj) === '[object Function]';
47
52
  }
53
+
48
54
  function isString(obj) {
49
55
  return nativeToString.call(obj) === '[object String]';
50
56
  }
57
+
51
58
  /**
52
59
  * Return true, if target owns a property with the given key.
53
60
  *
@@ -56,7 +63,6 @@
56
63
  *
57
64
  * @return {Boolean}
58
65
  */
59
-
60
66
  function has(target, key) {
61
67
  return nativeHasOwnProperty.call(target, key);
62
68
  }
@@ -69,18 +75,23 @@
69
75
  *
70
76
  * @return {Object}
71
77
  */
72
-
73
78
  function find(collection, matcher) {
79
+
74
80
  matcher = toMatcher(matcher);
81
+
75
82
  var match;
83
+
76
84
  forEach(collection, function (val, key) {
77
85
  if (matcher(val, key)) {
78
86
  match = val;
87
+
79
88
  return false;
80
89
  }
81
90
  });
91
+
82
92
  return match;
83
93
  }
94
+
84
95
  /**
85
96
  * Find element in collection.
86
97
  *
@@ -89,16 +100,19 @@
89
100
  *
90
101
  * @return {Array} result
91
102
  */
92
-
93
103
  function filter(collection, matcher) {
104
+
94
105
  var result = [];
106
+
95
107
  forEach(collection, function (val, key) {
96
108
  if (matcher(val, key)) {
97
109
  result.push(val);
98
110
  }
99
111
  });
112
+
100
113
  return result;
101
114
  }
115
+
102
116
  /**
103
117
  * Iterate over collection; returning something
104
118
  * (non-undefined) will stop iteration.
@@ -108,9 +122,7 @@
108
122
  *
109
123
  * @return {Object} return result that stopped the iteration
110
124
  */
111
-
112
125
  function forEach(collection, iterator) {
113
- var val, result;
114
126
 
115
127
  if (isUndefined(collection)) {
116
128
  return;
@@ -119,16 +131,19 @@
119
131
  var convertKey = isArray(collection) ? toNum : identity;
120
132
 
121
133
  for (var key in collection) {
134
+
122
135
  if (has(collection, key)) {
123
- val = collection[key];
124
- result = iterator(val, convertKey(key));
136
+ var val = collection[key];
137
+
138
+ var result = iterator(val, convertKey(key));
125
139
 
126
140
  if (result === false) {
127
- return val;
141
+ return;
128
142
  }
129
143
  }
130
144
  }
131
145
  }
146
+
132
147
  /**
133
148
  * Reduce collection, returning a single result.
134
149
  *
@@ -138,13 +153,15 @@
138
153
  *
139
154
  * @return {Any} result returned from last iterator
140
155
  */
141
-
142
156
  function reduce(collection, iterator, result) {
157
+
143
158
  forEach(collection, function (value, idx) {
144
159
  result = iterator(result, value, idx);
145
160
  });
161
+
146
162
  return result;
147
163
  }
164
+
148
165
  /**
149
166
  * Return true if every element in the collection
150
167
  * matches the criteria.
@@ -154,12 +171,13 @@
154
171
  *
155
172
  * @return {Boolean}
156
173
  */
157
-
158
174
  function every(collection, matcher) {
175
+
159
176
  return reduce(collection, function (matches, val, key) {
160
177
  return matches && matcher(val, key);
161
178
  }, true);
162
179
  }
180
+
163
181
  /**
164
182
  * Return true if some elements in the collection
165
183
  * match the criteria.
@@ -169,10 +187,11 @@
169
187
  *
170
188
  * @return {Boolean}
171
189
  */
172
-
173
190
  function some(collection, matcher) {
191
+
174
192
  return !!find(collection, matcher);
175
193
  }
194
+
176
195
  /**
177
196
  * Transform a collection into another collection
178
197
  * by piping each member through the given fn.
@@ -182,14 +201,17 @@
182
201
  *
183
202
  * @return {Array} transformed collection
184
203
  */
185
-
186
204
  function map(collection, fn) {
205
+
187
206
  var result = [];
207
+
188
208
  forEach(collection, function (val, key) {
189
209
  result.push(fn(val, key));
190
210
  });
211
+
191
212
  return result;
192
213
  }
214
+
193
215
  /**
194
216
  * Create an object pattern matcher.
195
217
  *
@@ -203,9 +225,10 @@
203
225
  *
204
226
  * @return {Function} matcherFn
205
227
  */
206
-
207
228
  function matchPattern(pattern) {
229
+
208
230
  return function (el) {
231
+
209
232
  return every(pattern, function (val, key) {
210
233
  return el[key] === val;
211
234
  });
@@ -236,13 +259,18 @@
236
259
  * @return {Function} debounced function
237
260
  */
238
261
  function debounce(fn, timeout) {
262
+
239
263
  var timer;
264
+
240
265
  var lastArgs;
241
266
  var lastThis;
267
+
242
268
  var lastNow;
243
269
 
244
270
  function fire() {
271
+
245
272
  var now = Date.now();
273
+
246
274
  var scheduledDiff = lastNow + timeout - now;
247
275
 
248
276
  if (scheduledDiff > 0) {
@@ -250,6 +278,7 @@
250
278
  }
251
279
 
252
280
  fn.apply(lastThis, lastArgs);
281
+
253
282
  timer = lastNow = lastArgs = lastThis = undefined;
254
283
  }
255
284
 
@@ -258,20 +287,23 @@
258
287
  }
259
288
 
260
289
  return function () {
290
+
261
291
  lastNow = Date.now();
262
292
 
263
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
293
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
264
294
  args[_key] = arguments[_key];
265
295
  }
266
296
 
267
297
  lastArgs = args;
268
- lastThis = this; // ensure an execution is scheduled
298
+ lastThis = this;
269
299
 
300
+ // ensure an execution is scheduled
270
301
  if (!timer) {
271
302
  schedule(timeout);
272
303
  }
273
304
  };
274
305
  }
306
+
275
307
  /**
276
308
  * Bind function against target <this>.
277
309
  *
@@ -280,28 +312,11 @@
280
312
  *
281
313
  * @return {Function} bound function
282
314
  */
283
-
284
315
  function bind(fn, target) {
285
316
  return fn.bind(target);
286
317
  }
287
318
 
288
- function _extends() {
289
- _extends = Object.assign || function (target) {
290
- for (var i = 1; i < arguments.length; i++) {
291
- var source = arguments[i];
292
-
293
- for (var key in source) {
294
- if (Object.prototype.hasOwnProperty.call(source, key)) {
295
- target[key] = source[key];
296
- }
297
- }
298
- }
299
-
300
- return target;
301
- };
302
-
303
- return _extends.apply(this, arguments);
304
- }
319
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
305
320
 
306
321
  /**
307
322
  * Convenience wrapper for `Object.assign`.
@@ -311,14 +326,14 @@
311
326
  *
312
327
  * @return {Object} the target
313
328
  */
314
-
315
329
  function assign(target) {
316
- for (var _len = arguments.length, others = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
330
+ for (var _len = arguments.length, others = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
317
331
  others[_key - 1] = arguments[_key];
318
332
  }
319
333
 
320
- return _extends.apply(void 0, [target].concat(others));
334
+ return _extends.apply(undefined, [target].concat(others));
321
335
  }
336
+
322
337
  /**
323
338
  * Pick given properties from the target object.
324
339
  *
@@ -327,17 +342,22 @@
327
342
  *
328
343
  * @return {Object} target
329
344
  */
330
-
331
345
  function pick(target, properties) {
346
+
332
347
  var result = {};
348
+
333
349
  var obj = Object(target);
350
+
334
351
  forEach(properties, function (prop) {
352
+
335
353
  if (prop in obj) {
336
354
  result[prop] = target[prop];
337
355
  }
338
356
  });
357
+
339
358
  return result;
340
359
  }
360
+
341
361
  /**
342
362
  * Pick all target properties, excluding the given ones.
343
363
  *
@@ -346,15 +366,19 @@
346
366
  *
347
367
  * @return {Object} target
348
368
  */
349
-
350
369
  function omit(target, properties) {
370
+
351
371
  var result = {};
372
+
352
373
  var obj = Object(target);
374
+
353
375
  forEach(obj, function (prop, key) {
376
+
354
377
  if (properties.indexOf(key) === -1) {
355
378
  result[key] = prop;
356
379
  }
357
380
  });
381
+
358
382
  return result;
359
383
  }
360
384
 
@@ -18316,9 +18340,7 @@
18316
18340
  return done(err, parseWarnings);
18317
18341
  }
18318
18342
 
18319
- self._setDefinitions(definitions);
18320
-
18321
- self.open(bpmnDiagram, function(err, importWarnings) {
18343
+ self.importDefinitions(definitions, bpmnDiagram, function(err, importWarnings) {
18322
18344
  var allWarnings = [].concat(parseWarnings, importWarnings || []);
18323
18345
 
18324
18346
  self._emit('import.done', { error: err, warnings: allWarnings });
@@ -18328,6 +18350,40 @@
18328
18350
  });
18329
18351
  };
18330
18352
 
18353
+ /**
18354
+ * Import parsed definitions and render a BPMN 2.0 diagram.
18355
+ *
18356
+ * Once finished the viewer reports back the result to the
18357
+ * provided callback function with (err, warnings).
18358
+ *
18359
+ * ## Life-Cycle Events
18360
+ *
18361
+ * During import the viewer will fire life-cycle events:
18362
+ *
18363
+ * * import.render.start (graphical import start)
18364
+ * * import.render.complete (graphical import finished)
18365
+ *
18366
+ * You can use these events to hook into the life-cycle.
18367
+ *
18368
+ * @param {ModdleElement<Definitions>} definitions parsed BPMN 2.0 definitions
18369
+ * @param {ModdleElement<BPMNDiagram>|String} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
18370
+ * @param {Function} [done] invoked with (err, warnings=[])
18371
+ */
18372
+ Viewer.prototype.importDefinitions = function(definitions, bpmnDiagram, done) {
18373
+
18374
+ if (isFunction(bpmnDiagram)) {
18375
+ done = bpmnDiagram;
18376
+ bpmnDiagram = null;
18377
+ }
18378
+
18379
+ // done is optional
18380
+ done = done || function() {};
18381
+
18382
+ this._setDefinitions(definitions);
18383
+
18384
+ return this.open(bpmnDiagram, done);
18385
+ };
18386
+
18331
18387
  /**
18332
18388
  * Open diagram of previously imported XML.
18333
18389
  *