bpmn-js 13.2.2 → 14.0.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 v13.2.2
2
+ * bpmn-js - bpmn-viewer v14.0.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: 2023-07-07
11
+ * Date: 2023-08-30
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2587,8 +2587,9 @@
2587
2587
  transform$1(gfx, rotate);
2588
2588
  }
2589
2589
 
2590
- function createCommonjsModule(fn, module) {
2591
- return module = { exports: {} }, fn(module, module.exports), module.exports;
2590
+ function createCommonjsModule(fn) {
2591
+ var module = { exports: {} };
2592
+ return fn(module, module.exports), module.exports;
2592
2593
  }
2593
2594
 
2594
2595
  var hat_1 = createCommonjsModule(function (module) {
@@ -2656,22 +2657,25 @@
2656
2657
  };
2657
2658
  });
2658
2659
 
2660
+ /**
2661
+ * @typedef { [ number, number ] | [ number, number, number ] } Seed
2662
+ */
2663
+
2659
2664
  /**
2660
2665
  * Create a new id generator / cache instance.
2661
2666
  *
2662
2667
  * You may optionally provide a seed that is used internally.
2663
2668
  *
2664
- * @param {Seed} seed
2669
+ * @param {Seed} [seed]
2665
2670
  */
2666
-
2667
2671
  function Ids(seed) {
2668
2672
  if (!(this instanceof Ids)) {
2669
2673
  return new Ids(seed);
2670
2674
  }
2671
-
2672
2675
  seed = seed || [128, 36, 1];
2673
2676
  this._seed = seed.length ? hat_1.rack(seed[0], seed[1], seed[2]) : seed;
2674
2677
  }
2678
+
2675
2679
  /**
2676
2680
  * Generate a next id.
2677
2681
  *
@@ -2679,10 +2683,10 @@
2679
2683
  *
2680
2684
  * @return {String} id
2681
2685
  */
2682
-
2683
2686
  Ids.prototype.next = function (element) {
2684
2687
  return this._seed(element || true);
2685
2688
  };
2689
+
2686
2690
  /**
2687
2691
  * Generate a next id with a given prefix.
2688
2692
  *
@@ -2690,61 +2694,54 @@
2690
2694
  *
2691
2695
  * @return {String} id
2692
2696
  */
2693
-
2694
-
2695
2697
  Ids.prototype.nextPrefixed = function (prefix, element) {
2696
2698
  var id;
2697
-
2698
2699
  do {
2699
2700
  id = prefix + this.next(true);
2700
- } while (this.assigned(id)); // claim {prefix}{random}
2701
-
2701
+ } while (this.assigned(id));
2702
2702
 
2703
- this.claim(id, element); // return
2703
+ // claim {prefix}{random}
2704
+ this.claim(id, element);
2704
2705
 
2706
+ // return
2705
2707
  return id;
2706
2708
  };
2709
+
2707
2710
  /**
2708
2711
  * Manually claim an existing id.
2709
2712
  *
2710
2713
  * @param {String} id
2711
2714
  * @param {String} [element] element the id is claimed by
2712
2715
  */
2713
-
2714
-
2715
2716
  Ids.prototype.claim = function (id, element) {
2716
2717
  this._seed.set(id, element || true);
2717
2718
  };
2719
+
2718
2720
  /**
2719
2721
  * Returns true if the given id has already been assigned.
2720
2722
  *
2721
2723
  * @param {String} id
2722
2724
  * @return {Boolean}
2723
2725
  */
2724
-
2725
-
2726
2726
  Ids.prototype.assigned = function (id) {
2727
2727
  return this._seed.get(id) || false;
2728
2728
  };
2729
+
2729
2730
  /**
2730
2731
  * Unclaim an id.
2731
2732
  *
2732
2733
  * @param {String} id the id to unclaim
2733
2734
  */
2734
-
2735
-
2736
2735
  Ids.prototype.unclaim = function (id) {
2737
2736
  delete this._seed.hats[id];
2738
2737
  };
2738
+
2739
2739
  /**
2740
2740
  * Clear all claimed ids.
2741
2741
  */
2742
-
2743
-
2744
2742
  Ids.prototype.clear = function () {
2745
2743
  var hats = this._seed.hats,
2746
- id;
2747
-
2744
+ id;
2748
2745
  for (id in hats) {
2749
2746
  this.unclaim(id);
2750
2747
  }
@@ -10292,9 +10289,9 @@
10292
10289
 
10293
10290
  const viewport = this._viewport = createGroup(svg, 'viewport');
10294
10291
 
10295
- // debounce canvas.viewbox.changed events
10296
- // for smoother diagram interaction
10297
- if (config.deferUpdate !== false) {
10292
+ // debounce canvas.viewbox.changed events when deferUpdate is set
10293
+ // to help with potential performance issues
10294
+ if (config.deferUpdate) {
10298
10295
  this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
10299
10296
  }
10300
10297
 
@@ -11318,6 +11315,11 @@
11318
11315
  this.setRootElement(rootElement);
11319
11316
  }
11320
11317
 
11318
+ // element is rootElement, do not change viewport
11319
+ if (rootElement === element) {
11320
+ return;
11321
+ }
11322
+
11321
11323
  if (!padding) {
11322
11324
  padding = {};
11323
11325
  }
@@ -18363,7 +18365,6 @@
18363
18365
  {
18364
18366
  name: "target",
18365
18367
  type: "LinkEventDefinition",
18366
- isAttr: true,
18367
18368
  isReference: true
18368
18369
  },
18369
18370
  {
@@ -21194,62 +21195,6 @@
21194
21195
  * @typedef {import('../model/Types').ModdleElement} ModdleElement
21195
21196
  */
21196
21197
 
21197
- // TODO(nikku): remove with future bpmn-js version
21198
-
21199
- /**
21200
- * Wraps APIs to check:
21201
- *
21202
- * 1) If a callback is passed -> Warn users about callback deprecation.
21203
- * 2) If Promise class is implemented in current environment.
21204
- *
21205
- * @private
21206
- *
21207
- * @param {Function} api
21208
- *
21209
- * @return {Function}
21210
- */
21211
- function wrapForCompatibility(api) {
21212
-
21213
- return function() {
21214
-
21215
- if (!window.Promise) {
21216
- throw new Error('Promises is not supported in this environment. Please polyfill Promise.');
21217
- }
21218
-
21219
- var argLen = arguments.length;
21220
- if (argLen >= 1 && isFunction(arguments[argLen - 1])) {
21221
-
21222
- var callback = arguments[argLen - 1];
21223
-
21224
- console.warn(new Error(
21225
- 'Passing callbacks to ' + api.name + ' is deprecated and will be removed in a future major release. ' +
21226
- 'Please switch to promises: https://bpmn.io/l/moving-to-promises.html'
21227
- ));
21228
-
21229
- var argsWithoutCallback = Array.prototype.slice.call(arguments, 0, -1);
21230
-
21231
- api.apply(this, argsWithoutCallback).then(function(result) {
21232
-
21233
- var firstKey = Object.keys(result)[0];
21234
-
21235
- // The APIs we are wrapping all resolve a single item depending on the API.
21236
- // For instance, importXML resolves { warnings } and saveXML returns { xml }.
21237
- // That's why we can call the callback with the first item of result.
21238
- return callback(null, result[firstKey]);
21239
-
21240
- // Passing a second paramter instead of catch because we don't want to
21241
- // catch errors thrown by callback().
21242
- }, function(err) {
21243
-
21244
- return callback(err, err.warnings);
21245
- });
21246
- } else {
21247
-
21248
- return api.apply(this, arguments);
21249
- }
21250
- };
21251
- }
21252
-
21253
21198
 
21254
21199
  // TODO(nikku): remove with future bpmn-js version
21255
21200
 
@@ -22191,28 +22136,7 @@
22191
22136
  const self = this;
22192
22137
 
22193
22138
  function ParseCompleteEvent(data) {
22194
-
22195
- const event = self.get('eventBus').createEvent(data);
22196
-
22197
- // TODO(nikku): remove with future bpmn-js version
22198
- Object.defineProperty(event, 'context', {
22199
- enumerable: true,
22200
- get: function() {
22201
-
22202
- console.warn(new Error(
22203
- 'import.parse.complete <context> is deprecated ' +
22204
- 'and will be removed in future library versions'
22205
- ));
22206
-
22207
- return {
22208
- warnings: data.warnings,
22209
- references: data.references,
22210
- elementsById: data.elementsById
22211
- };
22212
- }
22213
- });
22214
-
22215
- return event;
22139
+ return self.get('eventBus').createEvent(data);
22216
22140
  }
22217
22141
 
22218
22142
  let aggregatedWarnings = [];
@@ -22290,8 +22214,6 @@
22290
22214
  }
22291
22215
  };
22292
22216
 
22293
- BaseViewer.prototype.importXML = wrapForCompatibility(BaseViewer.prototype.importXML);
22294
-
22295
22217
 
22296
22218
  /**
22297
22219
  * Import parsed definitions and render a BPMN 2.0 diagram.
@@ -22322,8 +22244,6 @@
22322
22244
  return { warnings: result.warnings };
22323
22245
  };
22324
22246
 
22325
- BaseViewer.prototype.importDefinitions = wrapForCompatibility(BaseViewer.prototype.importDefinitions);
22326
-
22327
22247
 
22328
22248
  /**
22329
22249
  * Open diagram of previously imported XML.
@@ -22385,8 +22305,6 @@
22385
22305
  return { warnings };
22386
22306
  };
22387
22307
 
22388
- BaseViewer.prototype.open = wrapForCompatibility(BaseViewer.prototype.open);
22389
-
22390
22308
  /**
22391
22309
  * Export the currently displayed BPMN 2.0 diagram as
22392
22310
  * a BPMN 2.0 XML document.
@@ -22461,8 +22379,6 @@
22461
22379
  return result;
22462
22380
  };
22463
22381
 
22464
- BaseViewer.prototype.saveXML = wrapForCompatibility(BaseViewer.prototype.saveXML);
22465
-
22466
22382
 
22467
22383
  /**
22468
22384
  * Export the currently displayed BPMN 2.0 diagram as
@@ -22530,40 +22446,6 @@
22530
22446
  return { svg };
22531
22447
  };
22532
22448
 
22533
- BaseViewer.prototype.saveSVG = wrapForCompatibility(BaseViewer.prototype.saveSVG);
22534
-
22535
- /**
22536
- * Get a named diagram service.
22537
- *
22538
- * @example
22539
- *
22540
- * const elementRegistry = viewer.get('elementRegistry');
22541
- * const startEventShape = elementRegistry.get('StartEvent_1');
22542
- *
22543
- * @param {string} name
22544
- *
22545
- * @return {Object} diagram service instance
22546
- *
22547
- * @method BaseViewer#get
22548
- */
22549
-
22550
- /**
22551
- * Invoke a function in the context of this viewer.
22552
- *
22553
- * @example
22554
- *
22555
- * viewer.invoke(function(elementRegistry) {
22556
- * const startEventShape = elementRegistry.get('StartEvent_1');
22557
- * });
22558
- *
22559
- * @param {Function} fn to be invoked
22560
- *
22561
- * @return {Object} the functions return value
22562
- *
22563
- * @method BaseViewer#invoke
22564
- */
22565
-
22566
-
22567
22449
  BaseViewer.prototype._setDefinitions = function(definitions) {
22568
22450
  this._definitions = definitions;
22569
22451
  };