bpmn-js 12.0.0 → 12.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-navigated-viewer v12.0.0
2
+ * bpmn-js - bpmn-navigated-viewer v12.1.1
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-03-29
11
+ * Date: 2023-04-12
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -21,9 +21,11 @@
21
21
  /**
22
22
  * Flatten array, one level deep.
23
23
  *
24
- * @param {Array<?>} arr
24
+ * @template T
25
25
  *
26
- * @return {Array<?>}
26
+ * @param {T[][]} arr
27
+ *
28
+ * @return {T[]}
27
29
  */
28
30
 
29
31
  const nativeToString$1 = Object.prototype.toString;
@@ -49,6 +51,11 @@
49
51
  return nativeToString$1.call(obj) === '[object Number]';
50
52
  }
51
53
 
54
+ /**
55
+ * @param {any} obj
56
+ *
57
+ * @return {boolean}
58
+ */
52
59
  function isFunction(obj) {
53
60
  const tag = nativeToString$1.call(obj);
54
61
 
@@ -77,22 +84,74 @@
77
84
  return nativeHasOwnProperty$1.call(target, key);
78
85
  }
79
86
 
87
+ /**
88
+ * @template T
89
+ * @typedef { (
90
+ * ((e: T) => boolean) |
91
+ * ((e: T, idx: number) => boolean) |
92
+ * ((e: T, key: string) => boolean) |
93
+ * string |
94
+ * number
95
+ * ) } Matcher
96
+ */
97
+
98
+ /**
99
+ * @template T
100
+ * @template U
101
+ *
102
+ * @typedef { (
103
+ * ((e: T) => U) | string | number
104
+ * ) } Extractor
105
+ */
106
+
107
+
108
+ /**
109
+ * @template T
110
+ * @typedef { (val: T, key: any) => boolean } MatchFn
111
+ */
112
+
113
+ /**
114
+ * @template T
115
+ * @typedef { T[] } ArrayCollection
116
+ */
117
+
118
+ /**
119
+ * @template T
120
+ * @typedef { { [key: string]: T } } StringKeyValueCollection
121
+ */
122
+
123
+ /**
124
+ * @template T
125
+ * @typedef { { [key: number]: T } } NumberKeyValueCollection
126
+ */
127
+
128
+ /**
129
+ * @template T
130
+ * @typedef { StringKeyValueCollection<T> | NumberKeyValueCollection<T> } KeyValueCollection
131
+ */
132
+
133
+ /**
134
+ * @template T
135
+ * @typedef { KeyValueCollection<T> | ArrayCollection<T> } Collection
136
+ */
137
+
80
138
  /**
81
139
  * Find element in collection.
82
140
  *
83
- * @param {Array|Object} collection
84
- * @param {Function|Object} matcher
141
+ * @template T
142
+ * @param {Collection<T>} collection
143
+ * @param {Matcher<T>} matcher
85
144
  *
86
145
  * @return {Object}
87
146
  */
88
147
  function find(collection, matcher) {
89
148
 
90
- matcher = toMatcher(matcher);
149
+ const matchFn = toMatcher(matcher);
91
150
 
92
151
  let match;
93
152
 
94
153
  forEach$1(collection, function(val, key) {
95
- if (matcher(val, key)) {
154
+ if (matchFn(val, key)) {
96
155
  match = val;
97
156
 
98
157
  return false;
@@ -107,19 +166,20 @@
107
166
  /**
108
167
  * Find element index in collection.
109
168
  *
110
- * @param {Array|Object} collection
111
- * @param {Function} matcher
169
+ * @template T
170
+ * @param {Collection<T>} collection
171
+ * @param {Matcher<T>} matcher
112
172
  *
113
- * @return {Object}
173
+ * @return {number}
114
174
  */
115
175
  function findIndex(collection, matcher) {
116
176
 
117
- matcher = toMatcher(matcher);
177
+ const matchFn = toMatcher(matcher);
118
178
 
119
179
  let idx = isArray$2(collection) ? -1 : undefined;
120
180
 
121
181
  forEach$1(collection, function(val, key) {
122
- if (matcher(val, key)) {
182
+ if (matchFn(val, key)) {
123
183
  idx = key;
124
184
 
125
185
  return false;
@@ -131,19 +191,22 @@
131
191
 
132
192
 
133
193
  /**
134
- * Find element in collection.
194
+ * Filter elements in collection.
135
195
  *
136
- * @param {Array|Object} collection
137
- * @param {Function} matcher
196
+ * @template T
197
+ * @param {Collection<T>} collection
198
+ * @param {Matcher<T>} matcher
138
199
  *
139
- * @return {Array} result
200
+ * @return {T[]} result
140
201
  */
141
202
  function filter(collection, matcher) {
142
203
 
204
+ const matchFn = toMatcher(matcher);
205
+
143
206
  let result = [];
144
207
 
145
208
  forEach$1(collection, function(val, key) {
146
- if (matcher(val, key)) {
209
+ if (matchFn(val, key)) {
147
210
  result.push(val);
148
211
  }
149
212
  });
@@ -156,10 +219,11 @@
156
219
  * Iterate over collection; returning something
157
220
  * (non-undefined) will stop iteration.
158
221
  *
159
- * @param {Array|Object} collection
160
- * @param {Function} iterator
222
+ * @template T
223
+ * @param {Collection<T>} collection
224
+ * @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator
161
225
  *
162
- * @return {Object} return result that stopped the iteration
226
+ * @return {T} return result that stopped the iteration
163
227
  */
164
228
  function forEach$1(collection, iterator) {
165
229
 
@@ -190,11 +254,14 @@
190
254
  /**
191
255
  * Reduce collection, returning a single result.
192
256
  *
193
- * @param {Object|Array} collection
194
- * @param {Function} iterator
195
- * @param {Any} result
257
+ * @template T
258
+ * @template V
196
259
  *
197
- * @return {Any} result returned from last iterator
260
+ * @param {Collection<T>} collection
261
+ * @param {(result: V, entry: T, index: any) => V} iterator
262
+ * @param {V} result
263
+ *
264
+ * @return {V} result returned from last iterator
198
265
  */
199
266
  function reduce(collection, iterator, result) {
200
267
 
@@ -264,13 +331,17 @@
264
331
  *
265
332
  * @example
266
333
  *
334
+ * ```javascript
267
335
  * const matcher = matchPattern({ id: 1 });
268
336
  *
269
337
  * let element = find(elements, matcher);
338
+ * ```
339
+ *
340
+ * @template T
270
341
  *
271
- * @param {Object} pattern
342
+ * @param {T} pattern
272
343
  *
273
- * @return {Function} matcherFn
344
+ * @return { (el: any) => boolean } matcherFn
274
345
  */
275
346
  function matchPattern(pattern) {
276
347
 
@@ -284,6 +355,12 @@
284
355
  }
285
356
 
286
357
 
358
+ /**
359
+ * @template T
360
+ * @param {Matcher<T>} matcher
361
+ *
362
+ * @return {MatchFn<T>}
363
+ */
287
364
  function toMatcher(matcher) {
288
365
  return isFunction(matcher) ? matcher : (e) => {
289
366
  return e === matcher;
@@ -299,6 +376,16 @@
299
376
  return Number(arg);
300
377
  }
301
378
 
379
+ /* global setTimeout clearTimeout */
380
+
381
+ /**
382
+ * @typedef { {
383
+ * (...args: any[]): any;
384
+ * flush: () => void;
385
+ * cancel: () => void;
386
+ * } } DebouncedFunction
387
+ */
388
+
302
389
  /**
303
390
  * Debounce fn, calling it only once if the given time
304
391
  * elapsed between calls.
@@ -309,7 +396,7 @@
309
396
  * @param {Function} fn
310
397
  * @param {Number} timeout
311
398
  *
312
- * @return {Function} debounced function
399
+ * @return {DebouncedFunction} debounced function
313
400
  */
314
401
  function debounce(fn, timeout) {
315
402
 
@@ -355,6 +442,9 @@
355
442
  clear();
356
443
  }
357
444
 
445
+ /**
446
+ * @type { DebouncedFunction }
447
+ */
358
448
  function callback(...args) {
359
449
  lastNow = Date.now();
360
450
 
@@ -398,12 +488,15 @@
398
488
  }
399
489
 
400
490
  /**
401
- * Pick given properties from the target object.
491
+ * Pick properties from the given target.
402
492
  *
403
- * @param {Object} target
404
- * @param {Array} properties
493
+ * @template T
494
+ * @template {any[]} V
495
+ *
496
+ * @param {T} target
497
+ * @param {V} properties
405
498
  *
406
- * @return {Object} target
499
+ * @return Pick<T, V>
407
500
  */
408
501
  function pick(target, properties) {
409
502
 
@@ -424,10 +517,13 @@
424
517
  /**
425
518
  * Pick all target properties, excluding the given ones.
426
519
  *
427
- * @param {Object} target
428
- * @param {Array} properties
520
+ * @template T
521
+ * @template {any[]} V
522
+ *
523
+ * @param {T} target
524
+ * @param {V} properties
429
525
  *
430
- * @return {Object} target
526
+ * @return {Omit<T, V>} target
431
527
  */
432
528
  function omit(target, properties) {
433
529
 
@@ -1943,9 +2039,13 @@
1943
2039
 
1944
2040
  var componentEvent = {};
1945
2041
 
1946
- var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent',
1947
- unbind$1 = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
1948
- prefix$6 = bind$1 !== 'addEventListener' ? 'on' : '';
2042
+ var bind$1, unbind$1, prefix$6;
2043
+
2044
+ function detect () {
2045
+ bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent';
2046
+ unbind$1 = window.removeEventListener ? 'removeEventListener' : 'detachEvent';
2047
+ prefix$6 = bind$1 !== 'addEventListener' ? 'on' : '';
2048
+ }
1949
2049
 
1950
2050
  /**
1951
2051
  * Bind `el` event `type` to `fn`.
@@ -1959,6 +2059,7 @@
1959
2059
  */
1960
2060
 
1961
2061
  var bind_1 = componentEvent.bind = function(el, type, fn, capture){
2062
+ if (!bind$1) detect();
1962
2063
  el[bind$1](prefix$6 + type, fn, capture || false);
1963
2064
  return fn;
1964
2065
  };
@@ -1975,6 +2076,7 @@
1975
2076
  */
1976
2077
 
1977
2078
  var unbind_1 = componentEvent.unbind = function(el, type, fn, capture){
2079
+ if (!unbind$1) detect();
1978
2080
  el[unbind$1](prefix$6 + type, fn, capture || false);
1979
2081
  return fn;
1980
2082
  };
@@ -21038,7 +21140,7 @@
21038
21140
  BPMNIO_IMG +
21039
21141
  '</a>' +
21040
21142
  '<span>' +
21041
- 'Web-based tooling for BPMN, DMN and CMMN diagrams ' +
21143
+ 'Web-based tooling for BPMN, DMN and forms ' +
21042
21144
  'powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.' +
21043
21145
  '</span>' +
21044
21146
  '</div>' +