bpmn-js 9.4.1 → 10.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-modeler v9.4.1
2
+ * bpmn-js - bpmn-modeler v10.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: 2022-09-05
11
+ * Date: 2022-09-20
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -16344,13 +16344,13 @@
16344
16344
  *
16345
16345
  * Returns {Promise<ImportXMLResult, ImportXMLError>}
16346
16346
  */
16347
- BaseViewer.prototype.importXML = wrapForCompatibility(function importXML(xml, bpmnDiagram) {
16347
+ BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(xml, bpmnDiagram) {
16348
16348
 
16349
- var self = this;
16349
+ const self = this;
16350
16350
 
16351
16351
  function ParseCompleteEvent(data) {
16352
16352
 
16353
- var event = self.get('eventBus').createEvent(data);
16353
+ const event = self.get('eventBus').createEvent(data);
16354
16354
 
16355
16355
  // TODO(nikku): remove with future bpmn-js version
16356
16356
  Object.defineProperty(event, 'context', {
@@ -16373,54 +16373,59 @@
16373
16373
  return event;
16374
16374
  }
16375
16375
 
16376
- return new Promise(function(resolve, reject) {
16376
+ let aggregatedWarnings = [];
16377
+ try {
16377
16378
 
16378
16379
  // hook in pre-parse listeners +
16379
16380
  // allow xml manipulation
16380
- xml = self._emit('import.parse.start', { xml: xml }) || xml;
16381
-
16382
- self._moddle.fromXML(xml, 'bpmn:Definitions').then(function(result) {
16383
- var definitions = result.rootElement;
16384
- var references = result.references;
16385
- var parseWarnings = result.warnings;
16386
- var elementsById = result.elementsById;
16387
-
16388
- // hook in post parse listeners +
16389
- // allow definitions manipulation
16390
- definitions = self._emit('import.parse.complete', ParseCompleteEvent({
16391
- error: null,
16392
- definitions: definitions,
16393
- elementsById: elementsById,
16394
- references: references,
16395
- warnings: parseWarnings
16396
- })) || definitions;
16381
+ xml = this._emit('import.parse.start', { xml: xml }) || xml;
16397
16382
 
16398
- self.importDefinitions(definitions, bpmnDiagram).then(function(result) {
16399
- var allWarnings = [].concat(parseWarnings, result.warnings || []);
16383
+ let parseResult;
16384
+ try {
16385
+ parseResult = await this._moddle.fromXML(xml, 'bpmn:Definitions');
16386
+ } catch (error) {
16387
+ this._emit('import.parse.complete', {
16388
+ error
16389
+ });
16400
16390
 
16401
- self._emit('import.done', { error: null, warnings: allWarnings });
16391
+ throw error;
16392
+ }
16402
16393
 
16403
- return resolve({ warnings: allWarnings });
16404
- }).catch(function(err) {
16405
- var allWarnings = [].concat(parseWarnings, err.warnings || []);
16394
+ let definitions = parseResult.rootElement;
16395
+ const references = parseResult.references;
16396
+ const parseWarnings = parseResult.warnings;
16397
+ const elementsById = parseResult.elementsById;
16406
16398
 
16407
- self._emit('import.done', { error: err, warnings: allWarnings });
16399
+ aggregatedWarnings = aggregatedWarnings.concat(parseWarnings);
16408
16400
 
16409
- return reject(addWarningsToError(err, allWarnings));
16410
- });
16411
- }).catch(function(err) {
16401
+ // hook in post parse listeners +
16402
+ // allow definitions manipulation
16403
+ definitions = this._emit('import.parse.complete', ParseCompleteEvent({
16404
+ error: null,
16405
+ definitions: definitions,
16406
+ elementsById: elementsById,
16407
+ references: references,
16408
+ warnings: aggregatedWarnings
16409
+ })) || definitions;
16412
16410
 
16413
- self._emit('import.parse.complete', {
16414
- error: err
16415
- });
16411
+ const importResult = await this.importDefinitions(definitions, bpmnDiagram);
16416
16412
 
16417
- err = checkValidationError(err);
16413
+ aggregatedWarnings = aggregatedWarnings.concat(importResult.warnings);
16418
16414
 
16419
- self._emit('import.done', { error: err, warnings: err.warnings });
16415
+ this._emit('import.done', { error: null, warnings: aggregatedWarnings });
16420
16416
 
16421
- return reject(err);
16422
- });
16423
- });
16417
+ return { warnings: aggregatedWarnings };
16418
+ } catch (err) {
16419
+ let error = err;
16420
+ aggregatedWarnings = aggregatedWarnings.concat(error.warnings || []);
16421
+ addWarningsToError(error, aggregatedWarnings);
16422
+
16423
+ error = checkValidationError(error);
16424
+
16425
+ this._emit('import.done', { error, warnings: error.warnings });
16426
+
16427
+ throw error;
16428
+ }
16424
16429
  });
16425
16430
 
16426
16431
  /**
@@ -16459,24 +16464,11 @@
16459
16464
  *
16460
16465
  * Returns {Promise<ImportDefinitionsResult, ImportDefinitionsError>}
16461
16466
  */
16462
- BaseViewer.prototype.importDefinitions = wrapForCompatibility(function importDefinitions(definitions, bpmnDiagram) {
16467
+ BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
16468
+ this._setDefinitions(definitions);
16469
+ const result = await this.open(bpmnDiagram);
16463
16470
 
16464
- var self = this;
16465
-
16466
- return new Promise(function(resolve, reject) {
16467
-
16468
- self._setDefinitions(definitions);
16469
-
16470
- self.open(bpmnDiagram).then(function(result) {
16471
-
16472
- var warnings = result.warnings;
16473
-
16474
- return resolve({ warnings: warnings });
16475
- }).catch(function(err) {
16476
-
16477
- return reject(err);
16478
- });
16479
- });
16471
+ return { warnings: result.warnings };
16480
16472
  });
16481
16473
 
16482
16474
  /**
@@ -16514,50 +16506,43 @@
16514
16506
  *
16515
16507
  * Returns {Promise<OpenResult, OpenError>}
16516
16508
  */
16517
- BaseViewer.prototype.open = wrapForCompatibility(function open(bpmnDiagramOrId) {
16518
-
16519
- var definitions = this._definitions;
16520
- var bpmnDiagram = bpmnDiagramOrId;
16521
-
16522
- var self = this;
16509
+ BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
16523
16510
 
16524
- return new Promise(function(resolve, reject) {
16525
- if (!definitions) {
16526
- var err1 = new Error('no XML imported');
16511
+ const definitions = this._definitions;
16512
+ let bpmnDiagram = bpmnDiagramOrId;
16527
16513
 
16528
- return reject(addWarningsToError(err1, []));
16529
- }
16514
+ if (!definitions) {
16515
+ const error = new Error('no XML imported');
16516
+ addWarningsToError(error, []);
16530
16517
 
16531
- if (typeof bpmnDiagramOrId === 'string') {
16532
- bpmnDiagram = findBPMNDiagram(definitions, bpmnDiagramOrId);
16518
+ throw error;
16519
+ }
16533
16520
 
16534
- if (!bpmnDiagram) {
16535
- var err2 = new Error('BPMNDiagram <' + bpmnDiagramOrId + '> not found');
16521
+ if (typeof bpmnDiagramOrId === 'string') {
16522
+ bpmnDiagram = findBPMNDiagram(definitions, bpmnDiagramOrId);
16536
16523
 
16537
- return reject(addWarningsToError(err2, []));
16538
- }
16539
- }
16524
+ if (!bpmnDiagram) {
16525
+ const error = new Error('BPMNDiagram <' + bpmnDiagramOrId + '> not found');
16526
+ addWarningsToError(error, []);
16540
16527
 
16541
- // clear existing rendered diagram
16542
- // catch synchronous exceptions during #clear()
16543
- try {
16544
- self.clear();
16545
- } catch (error) {
16546
-
16547
- return reject(addWarningsToError(error, []));
16528
+ throw error;
16548
16529
  }
16530
+ }
16549
16531
 
16550
- // perform graphical import
16551
- importBpmnDiagram(self, definitions, bpmnDiagram).then(function(result) {
16532
+ // clear existing rendered diagram
16533
+ // catch synchronous exceptions during #clear()
16534
+ try {
16535
+ this.clear();
16536
+ } catch (error) {
16537
+ addWarningsToError(error, []);
16552
16538
 
16553
- var warnings = result.warnings;
16539
+ throw error;
16540
+ }
16554
16541
 
16555
- return resolve({ warnings: warnings });
16556
- }).catch(function(err) {
16542
+ // perform graphical import
16543
+ const { warnings } = await importBpmnDiagram(this, definitions, bpmnDiagram);
16557
16544
 
16558
- return reject(err);
16559
- });
16560
- });
16545
+ return { warnings };
16561
16546
  });
16562
16547
 
16563
16548
  /**
@@ -16588,53 +16573,42 @@
16588
16573
  *
16589
16574
  * Returns {Promise<SaveXMLResult, Error>}
16590
16575
  */
16591
- BaseViewer.prototype.saveXML = wrapForCompatibility(function saveXML(options) {
16576
+ BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
16592
16577
 
16593
16578
  options = options || {};
16594
16579
 
16595
- var self = this;
16596
-
16597
- var definitions = this._definitions;
16598
-
16599
- return new Promise(function(resolve) {
16580
+ let definitions = this._definitions,
16581
+ error, xml;
16600
16582
 
16583
+ try {
16601
16584
  if (!definitions) {
16602
- return resolve({
16603
- error: new Error('no definitions loaded')
16604
- });
16585
+ throw new Error('no definitions loaded');
16605
16586
  }
16606
16587
 
16607
16588
  // allow to fiddle around with definitions
16608
- definitions = self._emit('saveXML.start', {
16609
- definitions: definitions
16589
+ definitions = this._emit('saveXML.start', {
16590
+ definitions
16610
16591
  }) || definitions;
16611
16592
 
16612
- self._moddle.toXML(definitions, options).then(function(result) {
16613
-
16614
- var xml = result.xml;
16593
+ const result = await this._moddle.toXML(definitions, options);
16594
+ xml = result.xml;
16615
16595
 
16616
- xml = self._emit('saveXML.serialized', {
16617
- xml: xml
16618
- }) || xml;
16619
-
16620
- return resolve({
16621
- xml: xml
16622
- });
16623
- });
16624
- }).catch(function(error) {
16625
- return { error: error };
16626
- }).then(function(result) {
16596
+ xml = this._emit('saveXML.serialized', {
16597
+ xml
16598
+ }) || xml;
16599
+ } catch (err) {
16600
+ error = err;
16601
+ }
16627
16602
 
16628
- self._emit('saveXML.done', result);
16603
+ const result = error ? { error } : { xml };
16629
16604
 
16630
- var error = result.error;
16605
+ this._emit('saveXML.done', result);
16631
16606
 
16632
- if (error) {
16633
- return Promise.reject(error);
16634
- }
16607
+ if (error) {
16608
+ throw error;
16609
+ }
16635
16610
 
16636
- return result;
16637
- });
16611
+ return result;
16638
16612
  });
16639
16613
 
16640
16614
  /**
@@ -16662,51 +16636,45 @@
16662
16636
  *
16663
16637
  * Returns {Promise<SaveSVGResult, Error>}
16664
16638
  */
16665
- BaseViewer.prototype.saveSVG = wrapForCompatibility(function saveSVG(options) {
16666
-
16667
- var self = this;
16668
-
16669
- return new Promise(function(resolve, reject) {
16639
+ BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG(options = {}) {
16640
+ this._emit('saveSVG.start');
16670
16641
 
16671
- self._emit('saveSVG.start');
16642
+ let svg, err;
16672
16643
 
16673
- var svg, err;
16674
-
16675
- try {
16676
- var canvas = self.get('canvas');
16644
+ try {
16645
+ const canvas = this.get('canvas');
16677
16646
 
16678
- var contentNode = canvas.getActiveLayer(),
16647
+ const contentNode = canvas.getActiveLayer(),
16679
16648
  defsNode = query('defs', canvas._svg);
16680
16649
 
16681
- var contents = innerSVG(contentNode),
16650
+ const contents = innerSVG(contentNode),
16682
16651
  defs = defsNode ? '<defs>' + innerSVG(defsNode) + '</defs>' : '';
16683
16652
 
16684
- var bbox = contentNode.getBBox();
16685
-
16686
- svg =
16687
- '<?xml version="1.0" encoding="utf-8"?>\n' +
16688
- '<!-- created with bpmn-js / http://bpmn.io -->\n' +
16689
- '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
16690
- '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
16691
- 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
16692
- 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
16693
- defs + contents +
16694
- '</svg>';
16695
- } catch (e) {
16696
- err = e;
16697
- }
16653
+ const bbox = contentNode.getBBox();
16654
+
16655
+ svg =
16656
+ '<?xml version="1.0" encoding="utf-8"?>\n' +
16657
+ '<!-- created with bpmn-js / http://bpmn.io -->\n' +
16658
+ '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
16659
+ '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
16660
+ 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
16661
+ 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
16662
+ defs + contents +
16663
+ '</svg>';
16664
+ } catch (e) {
16665
+ err = e;
16666
+ }
16698
16667
 
16699
- self._emit('saveSVG.done', {
16700
- error: err,
16701
- svg: svg
16702
- });
16668
+ this._emit('saveSVG.done', {
16669
+ error: err,
16670
+ svg: svg
16671
+ });
16703
16672
 
16704
- if (!err) {
16705
- return resolve({ svg: svg });
16706
- }
16673
+ if (err) {
16674
+ throw err;
16675
+ }
16707
16676
 
16708
- return reject(err);
16709
- });
16677
+ return { svg };
16710
16678
  });
16711
16679
 
16712
16680
  /**
@@ -16714,8 +16682,8 @@
16714
16682
  *
16715
16683
  * @example
16716
16684
  *
16717
- * var elementRegistry = viewer.get('elementRegistry');
16718
- * var startEventShape = elementRegistry.get('StartEvent_1');
16685
+ * const elementRegistry = viewer.get('elementRegistry');
16686
+ * const startEventShape = elementRegistry.get('StartEvent_1');
16719
16687
  *
16720
16688
  * @param {string} name
16721
16689
  *
@@ -16730,7 +16698,7 @@
16730
16698
  * @example
16731
16699
  *
16732
16700
  * viewer.invoke(function(elementRegistry) {
16733
- * var startEventShape = elementRegistry.get('StartEvent_1');
16701
+ * const startEventShape = elementRegistry.get('StartEvent_1');
16734
16702
  * });
16735
16703
  *
16736
16704
  * @param {Function} fn to be invoked
@@ -16837,8 +16805,8 @@
16837
16805
 
16838
16806
  BaseViewer.prototype.detach = function() {
16839
16807
 
16840
- var container = this._container,
16841
- parentNode = container.parentNode;
16808
+ const container = this._container,
16809
+ parentNode = container.parentNode;
16842
16810
 
16843
16811
  if (!parentNode) {
16844
16812
  return;
@@ -16851,18 +16819,18 @@
16851
16819
 
16852
16820
  BaseViewer.prototype._init = function(container, moddle, options) {
16853
16821
 
16854
- var baseModules = options.modules || this.getModules(),
16855
- additionalModules = options.additionalModules || [],
16856
- staticModules = [
16857
- {
16858
- bpmnjs: [ 'value', this ],
16859
- moddle: [ 'value', moddle ]
16860
- }
16861
- ];
16822
+ const baseModules = options.modules || this.getModules(),
16823
+ additionalModules = options.additionalModules || [],
16824
+ staticModules = [
16825
+ {
16826
+ bpmnjs: [ 'value', this ],
16827
+ moddle: [ 'value', moddle ]
16828
+ }
16829
+ ];
16862
16830
 
16863
- var diagramModules = [].concat(staticModules, baseModules, additionalModules);
16831
+ const diagramModules = [].concat(staticModules, baseModules, additionalModules);
16864
16832
 
16865
- var diagramOptions = assign(omit(options, [ 'additionalModules' ]), {
16833
+ const diagramOptions = assign(omit(options, [ 'additionalModules' ]), {
16866
16834
  canvas: assign({}, options.canvas, { container: container }),
16867
16835
  modules: diagramModules
16868
16836
  });
@@ -16889,7 +16857,7 @@
16889
16857
 
16890
16858
  BaseViewer.prototype._createContainer = function(options) {
16891
16859
 
16892
- var container = domify('<div class="bjs-container"></div>');
16860
+ const container = domify('<div class="bjs-container"></div>');
16893
16861
 
16894
16862
  assign$1(container, {
16895
16863
  width: ensureUnit(options.width),
@@ -16901,7 +16869,7 @@
16901
16869
  };
16902
16870
 
16903
16871
  BaseViewer.prototype._createModdle = function(options) {
16904
- var moddleOptions = assign({}, this._moddleExtensions, options.moddleExtensions);
16872
+ const moddleOptions = assign({}, this._moddleExtensions, options.moddleExtensions);
16905
16873
 
16906
16874
  return new simple(moddleOptions);
16907
16875
  };
@@ -16920,8 +16888,8 @@
16920
16888
  // check if we can help the user by indicating wrong BPMN 2.0 xml
16921
16889
  // (in case he or the exporting tool did not get that right)
16922
16890
 
16923
- var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
16924
- var match = pattern.exec(err.message);
16891
+ const pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
16892
+ const match = pattern.exec(err.message);
16925
16893
 
16926
16894
  if (match) {
16927
16895
  err.message =
@@ -16932,7 +16900,7 @@
16932
16900
  return err;
16933
16901
  }
16934
16902
 
16935
- var DEFAULT_OPTIONS = {
16903
+ const DEFAULT_OPTIONS = {
16936
16904
  width: '100%',
16937
16905
  height: '100%',
16938
16906
  position: 'relative'
@@ -16974,18 +16942,18 @@
16974
16942
  * @param {Element} container
16975
16943
  */
16976
16944
  function addProjectLogo(container) {
16977
- var img = BPMNIO_IMG;
16945
+ const img = BPMNIO_IMG;
16978
16946
 
16979
- var linkMarkup =
16947
+ const linkMarkup =
16980
16948
  '<a href="http://bpmn.io" ' +
16981
- 'target="_blank" ' +
16982
- 'class="bjs-powered-by" ' +
16983
- 'title="Powered by bpmn.io" ' +
16984
- '>' +
16985
- img +
16949
+ 'target="_blank" ' +
16950
+ 'class="bjs-powered-by" ' +
16951
+ 'title="Powered by bpmn.io" ' +
16952
+ '>' +
16953
+ img +
16986
16954
  '</a>';
16987
16955
 
16988
- var linkElement = domify(linkMarkup);
16956
+ const linkElement = domify(linkMarkup);
16989
16957
 
16990
16958
  assign$1(query('svg', linkElement), LOGO_STYLES);
16991
16959
  assign$1(linkElement, LINK_STYLES, {