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-navigated-viewer v3.4.3
2
+ * bpmn-js - bpmn-navigated-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() :
@@ -56,28 +56,35 @@
56
56
 
57
57
  var nativeToString = Object.prototype.toString;
58
58
  var nativeHasOwnProperty = Object.prototype.hasOwnProperty;
59
+
59
60
  function isUndefined(obj) {
60
61
  return obj === undefined;
61
62
  }
63
+
62
64
  function isDefined(obj) {
63
65
  return obj !== undefined;
64
66
  }
67
+
65
68
  function isArray(obj) {
66
69
  return nativeToString.call(obj) === '[object Array]';
67
70
  }
71
+
68
72
  function isObject(obj) {
69
73
  return nativeToString.call(obj) === '[object Object]';
70
74
  }
75
+
71
76
  function isNumber(obj) {
72
77
  return nativeToString.call(obj) === '[object Number]';
73
78
  }
79
+
74
80
  function isFunction(obj) {
75
- var tag = nativeToString.call(obj);
76
- return tag === '[object Function]' || tag === '[object AsyncFunction]' || tag === '[object GeneratorFunction]' || tag === '[object AsyncGeneratorFunction]' || tag === '[object Proxy]';
81
+ return nativeToString.call(obj) === '[object Function]';
77
82
  }
83
+
78
84
  function isString(obj) {
79
85
  return nativeToString.call(obj) === '[object String]';
80
86
  }
87
+
81
88
  /**
82
89
  * Return true, if target owns a property with the given key.
83
90
  *
@@ -86,7 +93,6 @@
86
93
  *
87
94
  * @return {Boolean}
88
95
  */
89
-
90
96
  function has(target, key) {
91
97
  return nativeHasOwnProperty.call(target, key);
92
98
  }
@@ -99,18 +105,23 @@
99
105
  *
100
106
  * @return {Object}
101
107
  */
102
-
103
108
  function find(collection, matcher) {
109
+
104
110
  matcher = toMatcher(matcher);
111
+
105
112
  var match;
113
+
106
114
  forEach(collection, function (val, key) {
107
115
  if (matcher(val, key)) {
108
116
  match = val;
117
+
109
118
  return false;
110
119
  }
111
120
  });
121
+
112
122
  return match;
113
123
  }
124
+
114
125
  /**
115
126
  * Find element in collection.
116
127
  *
@@ -119,16 +130,19 @@
119
130
  *
120
131
  * @return {Array} result
121
132
  */
122
-
123
133
  function filter(collection, matcher) {
134
+
124
135
  var result = [];
136
+
125
137
  forEach(collection, function (val, key) {
126
138
  if (matcher(val, key)) {
127
139
  result.push(val);
128
140
  }
129
141
  });
142
+
130
143
  return result;
131
144
  }
145
+
132
146
  /**
133
147
  * Iterate over collection; returning something
134
148
  * (non-undefined) will stop iteration.
@@ -138,9 +152,7 @@
138
152
  *
139
153
  * @return {Object} return result that stopped the iteration
140
154
  */
141
-
142
155
  function forEach(collection, iterator) {
143
- var val, result;
144
156
 
145
157
  if (isUndefined(collection)) {
146
158
  return;
@@ -149,16 +161,19 @@
149
161
  var convertKey = isArray(collection) ? toNum : identity;
150
162
 
151
163
  for (var key in collection) {
164
+
152
165
  if (has(collection, key)) {
153
- val = collection[key];
154
- result = iterator(val, convertKey(key));
166
+ var val = collection[key];
167
+
168
+ var result = iterator(val, convertKey(key));
155
169
 
156
170
  if (result === false) {
157
- return val;
171
+ return;
158
172
  }
159
173
  }
160
174
  }
161
175
  }
176
+
162
177
  /**
163
178
  * Reduce collection, returning a single result.
164
179
  *
@@ -168,13 +183,15 @@
168
183
  *
169
184
  * @return {Any} result returned from last iterator
170
185
  */
171
-
172
186
  function reduce(collection, iterator, result) {
187
+
173
188
  forEach(collection, function (value, idx) {
174
189
  result = iterator(result, value, idx);
175
190
  });
191
+
176
192
  return result;
177
193
  }
194
+
178
195
  /**
179
196
  * Return true if every element in the collection
180
197
  * matches the criteria.
@@ -184,12 +201,13 @@
184
201
  *
185
202
  * @return {Boolean}
186
203
  */
187
-
188
204
  function every(collection, matcher) {
205
+
189
206
  return reduce(collection, function (matches, val, key) {
190
207
  return matches && matcher(val, key);
191
208
  }, true);
192
209
  }
210
+
193
211
  /**
194
212
  * Return true if some elements in the collection
195
213
  * match the criteria.
@@ -199,10 +217,11 @@
199
217
  *
200
218
  * @return {Boolean}
201
219
  */
202
-
203
220
  function some(collection, matcher) {
221
+
204
222
  return !!find(collection, matcher);
205
223
  }
224
+
206
225
  /**
207
226
  * Transform a collection into another collection
208
227
  * by piping each member through the given fn.
@@ -212,14 +231,17 @@
212
231
  *
213
232
  * @return {Array} transformed collection
214
233
  */
215
-
216
234
  function map(collection, fn) {
235
+
217
236
  var result = [];
237
+
218
238
  forEach(collection, function (val, key) {
219
239
  result.push(fn(val, key));
220
240
  });
241
+
221
242
  return result;
222
243
  }
244
+
223
245
  /**
224
246
  * Create an object pattern matcher.
225
247
  *
@@ -233,9 +255,10 @@
233
255
  *
234
256
  * @return {Function} matcherFn
235
257
  */
236
-
237
258
  function matchPattern(pattern) {
259
+
238
260
  return function (el) {
261
+
239
262
  return every(pattern, function (val, key) {
240
263
  return el[key] === val;
241
264
  });
@@ -266,13 +289,18 @@
266
289
  * @return {Function} debounced function
267
290
  */
268
291
  function debounce(fn, timeout) {
292
+
269
293
  var timer;
294
+
270
295
  var lastArgs;
271
296
  var lastThis;
297
+
272
298
  var lastNow;
273
299
 
274
300
  function fire() {
301
+
275
302
  var now = Date.now();
303
+
276
304
  var scheduledDiff = lastNow + timeout - now;
277
305
 
278
306
  if (scheduledDiff > 0) {
@@ -280,6 +308,7 @@
280
308
  }
281
309
 
282
310
  fn.apply(lastThis, lastArgs);
311
+
283
312
  timer = lastNow = lastArgs = lastThis = undefined;
284
313
  }
285
314
 
@@ -288,20 +317,23 @@
288
317
  }
289
318
 
290
319
  return function () {
320
+
291
321
  lastNow = Date.now();
292
322
 
293
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
323
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
294
324
  args[_key] = arguments[_key];
295
325
  }
296
326
 
297
327
  lastArgs = args;
298
- lastThis = this; // ensure an execution is scheduled
328
+ lastThis = this;
299
329
 
330
+ // ensure an execution is scheduled
300
331
  if (!timer) {
301
332
  schedule(timeout);
302
333
  }
303
334
  };
304
335
  }
336
+
305
337
  /**
306
338
  * Bind function against target <this>.
307
339
  *
@@ -310,28 +342,11 @@
310
342
  *
311
343
  * @return {Function} bound function
312
344
  */
313
-
314
345
  function bind(fn, target) {
315
346
  return fn.bind(target);
316
347
  }
317
348
 
318
- function _extends() {
319
- _extends = Object.assign || function (target) {
320
- for (var i = 1; i < arguments.length; i++) {
321
- var source = arguments[i];
322
-
323
- for (var key in source) {
324
- if (Object.prototype.hasOwnProperty.call(source, key)) {
325
- target[key] = source[key];
326
- }
327
- }
328
- }
329
-
330
- return target;
331
- };
332
-
333
- return _extends.apply(this, arguments);
334
- }
349
+ 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; };
335
350
 
336
351
  /**
337
352
  * Convenience wrapper for `Object.assign`.
@@ -341,14 +356,14 @@
341
356
  *
342
357
  * @return {Object} the target
343
358
  */
344
-
345
359
  function assign(target) {
346
- for (var _len = arguments.length, others = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
360
+ for (var _len = arguments.length, others = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
347
361
  others[_key - 1] = arguments[_key];
348
362
  }
349
363
 
350
- return _extends.apply(void 0, [target].concat(others));
364
+ return _extends.apply(undefined, [target].concat(others));
351
365
  }
366
+
352
367
  /**
353
368
  * Pick given properties from the target object.
354
369
  *
@@ -357,17 +372,22 @@
357
372
  *
358
373
  * @return {Object} target
359
374
  */
360
-
361
375
  function pick(target, properties) {
376
+
362
377
  var result = {};
378
+
363
379
  var obj = Object(target);
380
+
364
381
  forEach(properties, function (prop) {
382
+
365
383
  if (prop in obj) {
366
384
  result[prop] = target[prop];
367
385
  }
368
386
  });
387
+
369
388
  return result;
370
389
  }
390
+
371
391
  /**
372
392
  * Pick all target properties, excluding the given ones.
373
393
  *
@@ -376,15 +396,19 @@
376
396
  *
377
397
  * @return {Object} target
378
398
  */
379
-
380
399
  function omit(target, properties) {
400
+
381
401
  var result = {};
402
+
382
403
  var obj = Object(target);
404
+
383
405
  forEach(obj, function (prop, key) {
406
+
384
407
  if (properties.indexOf(key) === -1) {
385
408
  result[key] = prop;
386
409
  }
387
410
  });
411
+
388
412
  return result;
389
413
  }
390
414
 
@@ -18354,9 +18378,7 @@
18354
18378
  return done(err, parseWarnings);
18355
18379
  }
18356
18380
 
18357
- self._setDefinitions(definitions);
18358
-
18359
- self.open(bpmnDiagram, function(err, importWarnings) {
18381
+ self.importDefinitions(definitions, bpmnDiagram, function(err, importWarnings) {
18360
18382
  var allWarnings = [].concat(parseWarnings, importWarnings || []);
18361
18383
 
18362
18384
  self._emit('import.done', { error: err, warnings: allWarnings });
@@ -18366,6 +18388,40 @@
18366
18388
  });
18367
18389
  };
18368
18390
 
18391
+ /**
18392
+ * Import parsed definitions and render a BPMN 2.0 diagram.
18393
+ *
18394
+ * Once finished the viewer reports back the result to the
18395
+ * provided callback function with (err, warnings).
18396
+ *
18397
+ * ## Life-Cycle Events
18398
+ *
18399
+ * During import the viewer will fire life-cycle events:
18400
+ *
18401
+ * * import.render.start (graphical import start)
18402
+ * * import.render.complete (graphical import finished)
18403
+ *
18404
+ * You can use these events to hook into the life-cycle.
18405
+ *
18406
+ * @param {ModdleElement<Definitions>} definitions parsed BPMN 2.0 definitions
18407
+ * @param {ModdleElement<BPMNDiagram>|String} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
18408
+ * @param {Function} [done] invoked with (err, warnings=[])
18409
+ */
18410
+ Viewer.prototype.importDefinitions = function(definitions, bpmnDiagram, done) {
18411
+
18412
+ if (isFunction(bpmnDiagram)) {
18413
+ done = bpmnDiagram;
18414
+ bpmnDiagram = null;
18415
+ }
18416
+
18417
+ // done is optional
18418
+ done = done || function() {};
18419
+
18420
+ this._setDefinitions(definitions);
18421
+
18422
+ return this.open(bpmnDiagram, done);
18423
+ };
18424
+
18369
18425
  /**
18370
18426
  * Open diagram of previously imported XML.
18371
18427
  *