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-navigated-viewer v9.4.1
2
+ * bpmn-js - bpmn-navigated-viewer 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() :
@@ -20939,13 +20939,13 @@
20939
20939
  *
20940
20940
  * Returns {Promise<ImportXMLResult, ImportXMLError>}
20941
20941
  */
20942
- BaseViewer.prototype.importXML = wrapForCompatibility(function importXML(xml, bpmnDiagram) {
20942
+ BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(xml, bpmnDiagram) {
20943
20943
 
20944
- var self = this;
20944
+ const self = this;
20945
20945
 
20946
20946
  function ParseCompleteEvent(data) {
20947
20947
 
20948
- var event = self.get('eventBus').createEvent(data);
20948
+ const event = self.get('eventBus').createEvent(data);
20949
20949
 
20950
20950
  // TODO(nikku): remove with future bpmn-js version
20951
20951
  Object.defineProperty(event, 'context', {
@@ -20968,54 +20968,59 @@
20968
20968
  return event;
20969
20969
  }
20970
20970
 
20971
- return new Promise(function(resolve, reject) {
20971
+ let aggregatedWarnings = [];
20972
+ try {
20972
20973
 
20973
20974
  // hook in pre-parse listeners +
20974
20975
  // allow xml manipulation
20975
- xml = self._emit('import.parse.start', { xml: xml }) || xml;
20976
-
20977
- self._moddle.fromXML(xml, 'bpmn:Definitions').then(function(result) {
20978
- var definitions = result.rootElement;
20979
- var references = result.references;
20980
- var parseWarnings = result.warnings;
20981
- var elementsById = result.elementsById;
20982
-
20983
- // hook in post parse listeners +
20984
- // allow definitions manipulation
20985
- definitions = self._emit('import.parse.complete', ParseCompleteEvent({
20986
- error: null,
20987
- definitions: definitions,
20988
- elementsById: elementsById,
20989
- references: references,
20990
- warnings: parseWarnings
20991
- })) || definitions;
20976
+ xml = this._emit('import.parse.start', { xml: xml }) || xml;
20992
20977
 
20993
- self.importDefinitions(definitions, bpmnDiagram).then(function(result) {
20994
- var allWarnings = [].concat(parseWarnings, result.warnings || []);
20978
+ let parseResult;
20979
+ try {
20980
+ parseResult = await this._moddle.fromXML(xml, 'bpmn:Definitions');
20981
+ } catch (error) {
20982
+ this._emit('import.parse.complete', {
20983
+ error
20984
+ });
20995
20985
 
20996
- self._emit('import.done', { error: null, warnings: allWarnings });
20986
+ throw error;
20987
+ }
20997
20988
 
20998
- return resolve({ warnings: allWarnings });
20999
- }).catch(function(err) {
21000
- var allWarnings = [].concat(parseWarnings, err.warnings || []);
20989
+ let definitions = parseResult.rootElement;
20990
+ const references = parseResult.references;
20991
+ const parseWarnings = parseResult.warnings;
20992
+ const elementsById = parseResult.elementsById;
21001
20993
 
21002
- self._emit('import.done', { error: err, warnings: allWarnings });
20994
+ aggregatedWarnings = aggregatedWarnings.concat(parseWarnings);
21003
20995
 
21004
- return reject(addWarningsToError(err, allWarnings));
21005
- });
21006
- }).catch(function(err) {
20996
+ // hook in post parse listeners +
20997
+ // allow definitions manipulation
20998
+ definitions = this._emit('import.parse.complete', ParseCompleteEvent({
20999
+ error: null,
21000
+ definitions: definitions,
21001
+ elementsById: elementsById,
21002
+ references: references,
21003
+ warnings: aggregatedWarnings
21004
+ })) || definitions;
21007
21005
 
21008
- self._emit('import.parse.complete', {
21009
- error: err
21010
- });
21006
+ const importResult = await this.importDefinitions(definitions, bpmnDiagram);
21011
21007
 
21012
- err = checkValidationError(err);
21008
+ aggregatedWarnings = aggregatedWarnings.concat(importResult.warnings);
21013
21009
 
21014
- self._emit('import.done', { error: err, warnings: err.warnings });
21010
+ this._emit('import.done', { error: null, warnings: aggregatedWarnings });
21015
21011
 
21016
- return reject(err);
21017
- });
21018
- });
21012
+ return { warnings: aggregatedWarnings };
21013
+ } catch (err) {
21014
+ let error = err;
21015
+ aggregatedWarnings = aggregatedWarnings.concat(error.warnings || []);
21016
+ addWarningsToError(error, aggregatedWarnings);
21017
+
21018
+ error = checkValidationError(error);
21019
+
21020
+ this._emit('import.done', { error, warnings: error.warnings });
21021
+
21022
+ throw error;
21023
+ }
21019
21024
  });
21020
21025
 
21021
21026
  /**
@@ -21054,24 +21059,11 @@
21054
21059
  *
21055
21060
  * Returns {Promise<ImportDefinitionsResult, ImportDefinitionsError>}
21056
21061
  */
21057
- BaseViewer.prototype.importDefinitions = wrapForCompatibility(function importDefinitions(definitions, bpmnDiagram) {
21062
+ BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
21063
+ this._setDefinitions(definitions);
21064
+ const result = await this.open(bpmnDiagram);
21058
21065
 
21059
- var self = this;
21060
-
21061
- return new Promise(function(resolve, reject) {
21062
-
21063
- self._setDefinitions(definitions);
21064
-
21065
- self.open(bpmnDiagram).then(function(result) {
21066
-
21067
- var warnings = result.warnings;
21068
-
21069
- return resolve({ warnings: warnings });
21070
- }).catch(function(err) {
21071
-
21072
- return reject(err);
21073
- });
21074
- });
21066
+ return { warnings: result.warnings };
21075
21067
  });
21076
21068
 
21077
21069
  /**
@@ -21109,50 +21101,43 @@
21109
21101
  *
21110
21102
  * Returns {Promise<OpenResult, OpenError>}
21111
21103
  */
21112
- BaseViewer.prototype.open = wrapForCompatibility(function open(bpmnDiagramOrId) {
21113
-
21114
- var definitions = this._definitions;
21115
- var bpmnDiagram = bpmnDiagramOrId;
21116
-
21117
- var self = this;
21104
+ BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
21118
21105
 
21119
- return new Promise(function(resolve, reject) {
21120
- if (!definitions) {
21121
- var err1 = new Error('no XML imported');
21106
+ const definitions = this._definitions;
21107
+ let bpmnDiagram = bpmnDiagramOrId;
21122
21108
 
21123
- return reject(addWarningsToError(err1, []));
21124
- }
21109
+ if (!definitions) {
21110
+ const error = new Error('no XML imported');
21111
+ addWarningsToError(error, []);
21125
21112
 
21126
- if (typeof bpmnDiagramOrId === 'string') {
21127
- bpmnDiagram = findBPMNDiagram(definitions, bpmnDiagramOrId);
21113
+ throw error;
21114
+ }
21128
21115
 
21129
- if (!bpmnDiagram) {
21130
- var err2 = new Error('BPMNDiagram <' + bpmnDiagramOrId + '> not found');
21116
+ if (typeof bpmnDiagramOrId === 'string') {
21117
+ bpmnDiagram = findBPMNDiagram(definitions, bpmnDiagramOrId);
21131
21118
 
21132
- return reject(addWarningsToError(err2, []));
21133
- }
21134
- }
21119
+ if (!bpmnDiagram) {
21120
+ const error = new Error('BPMNDiagram <' + bpmnDiagramOrId + '> not found');
21121
+ addWarningsToError(error, []);
21135
21122
 
21136
- // clear existing rendered diagram
21137
- // catch synchronous exceptions during #clear()
21138
- try {
21139
- self.clear();
21140
- } catch (error) {
21141
-
21142
- return reject(addWarningsToError(error, []));
21123
+ throw error;
21143
21124
  }
21125
+ }
21144
21126
 
21145
- // perform graphical import
21146
- importBpmnDiagram(self, definitions, bpmnDiagram).then(function(result) {
21127
+ // clear existing rendered diagram
21128
+ // catch synchronous exceptions during #clear()
21129
+ try {
21130
+ this.clear();
21131
+ } catch (error) {
21132
+ addWarningsToError(error, []);
21147
21133
 
21148
- var warnings = result.warnings;
21134
+ throw error;
21135
+ }
21149
21136
 
21150
- return resolve({ warnings: warnings });
21151
- }).catch(function(err) {
21137
+ // perform graphical import
21138
+ const { warnings } = await importBpmnDiagram(this, definitions, bpmnDiagram);
21152
21139
 
21153
- return reject(err);
21154
- });
21155
- });
21140
+ return { warnings };
21156
21141
  });
21157
21142
 
21158
21143
  /**
@@ -21183,53 +21168,42 @@
21183
21168
  *
21184
21169
  * Returns {Promise<SaveXMLResult, Error>}
21185
21170
  */
21186
- BaseViewer.prototype.saveXML = wrapForCompatibility(function saveXML(options) {
21171
+ BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
21187
21172
 
21188
21173
  options = options || {};
21189
21174
 
21190
- var self = this;
21191
-
21192
- var definitions = this._definitions;
21193
-
21194
- return new Promise(function(resolve) {
21175
+ let definitions = this._definitions,
21176
+ error, xml;
21195
21177
 
21178
+ try {
21196
21179
  if (!definitions) {
21197
- return resolve({
21198
- error: new Error('no definitions loaded')
21199
- });
21180
+ throw new Error('no definitions loaded');
21200
21181
  }
21201
21182
 
21202
21183
  // allow to fiddle around with definitions
21203
- definitions = self._emit('saveXML.start', {
21204
- definitions: definitions
21184
+ definitions = this._emit('saveXML.start', {
21185
+ definitions
21205
21186
  }) || definitions;
21206
21187
 
21207
- self._moddle.toXML(definitions, options).then(function(result) {
21208
-
21209
- var xml = result.xml;
21188
+ const result = await this._moddle.toXML(definitions, options);
21189
+ xml = result.xml;
21210
21190
 
21211
- xml = self._emit('saveXML.serialized', {
21212
- xml: xml
21213
- }) || xml;
21214
-
21215
- return resolve({
21216
- xml: xml
21217
- });
21218
- });
21219
- }).catch(function(error) {
21220
- return { error: error };
21221
- }).then(function(result) {
21191
+ xml = this._emit('saveXML.serialized', {
21192
+ xml
21193
+ }) || xml;
21194
+ } catch (err) {
21195
+ error = err;
21196
+ }
21222
21197
 
21223
- self._emit('saveXML.done', result);
21198
+ const result = error ? { error } : { xml };
21224
21199
 
21225
- var error = result.error;
21200
+ this._emit('saveXML.done', result);
21226
21201
 
21227
- if (error) {
21228
- return Promise.reject(error);
21229
- }
21202
+ if (error) {
21203
+ throw error;
21204
+ }
21230
21205
 
21231
- return result;
21232
- });
21206
+ return result;
21233
21207
  });
21234
21208
 
21235
21209
  /**
@@ -21257,51 +21231,45 @@
21257
21231
  *
21258
21232
  * Returns {Promise<SaveSVGResult, Error>}
21259
21233
  */
21260
- BaseViewer.prototype.saveSVG = wrapForCompatibility(function saveSVG(options) {
21261
-
21262
- var self = this;
21263
-
21264
- return new Promise(function(resolve, reject) {
21234
+ BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG(options = {}) {
21235
+ this._emit('saveSVG.start');
21265
21236
 
21266
- self._emit('saveSVG.start');
21237
+ let svg, err;
21267
21238
 
21268
- var svg, err;
21269
-
21270
- try {
21271
- var canvas = self.get('canvas');
21239
+ try {
21240
+ const canvas = this.get('canvas');
21272
21241
 
21273
- var contentNode = canvas.getActiveLayer(),
21242
+ const contentNode = canvas.getActiveLayer(),
21274
21243
  defsNode = query('defs', canvas._svg);
21275
21244
 
21276
- var contents = innerSVG(contentNode),
21245
+ const contents = innerSVG(contentNode),
21277
21246
  defs = defsNode ? '<defs>' + innerSVG(defsNode) + '</defs>' : '';
21278
21247
 
21279
- var bbox = contentNode.getBBox();
21280
-
21281
- svg =
21282
- '<?xml version="1.0" encoding="utf-8"?>\n' +
21283
- '<!-- created with bpmn-js / http://bpmn.io -->\n' +
21284
- '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
21285
- '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
21286
- 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
21287
- 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
21288
- defs + contents +
21289
- '</svg>';
21290
- } catch (e) {
21291
- err = e;
21292
- }
21248
+ const bbox = contentNode.getBBox();
21249
+
21250
+ svg =
21251
+ '<?xml version="1.0" encoding="utf-8"?>\n' +
21252
+ '<!-- created with bpmn-js / http://bpmn.io -->\n' +
21253
+ '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
21254
+ '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
21255
+ 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
21256
+ 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
21257
+ defs + contents +
21258
+ '</svg>';
21259
+ } catch (e) {
21260
+ err = e;
21261
+ }
21293
21262
 
21294
- self._emit('saveSVG.done', {
21295
- error: err,
21296
- svg: svg
21297
- });
21263
+ this._emit('saveSVG.done', {
21264
+ error: err,
21265
+ svg: svg
21266
+ });
21298
21267
 
21299
- if (!err) {
21300
- return resolve({ svg: svg });
21301
- }
21268
+ if (err) {
21269
+ throw err;
21270
+ }
21302
21271
 
21303
- return reject(err);
21304
- });
21272
+ return { svg };
21305
21273
  });
21306
21274
 
21307
21275
  /**
@@ -21309,8 +21277,8 @@
21309
21277
  *
21310
21278
  * @example
21311
21279
  *
21312
- * var elementRegistry = viewer.get('elementRegistry');
21313
- * var startEventShape = elementRegistry.get('StartEvent_1');
21280
+ * const elementRegistry = viewer.get('elementRegistry');
21281
+ * const startEventShape = elementRegistry.get('StartEvent_1');
21314
21282
  *
21315
21283
  * @param {string} name
21316
21284
  *
@@ -21325,7 +21293,7 @@
21325
21293
  * @example
21326
21294
  *
21327
21295
  * viewer.invoke(function(elementRegistry) {
21328
- * var startEventShape = elementRegistry.get('StartEvent_1');
21296
+ * const startEventShape = elementRegistry.get('StartEvent_1');
21329
21297
  * });
21330
21298
  *
21331
21299
  * @param {Function} fn to be invoked
@@ -21432,8 +21400,8 @@
21432
21400
 
21433
21401
  BaseViewer.prototype.detach = function() {
21434
21402
 
21435
- var container = this._container,
21436
- parentNode = container.parentNode;
21403
+ const container = this._container,
21404
+ parentNode = container.parentNode;
21437
21405
 
21438
21406
  if (!parentNode) {
21439
21407
  return;
@@ -21446,18 +21414,18 @@
21446
21414
 
21447
21415
  BaseViewer.prototype._init = function(container, moddle, options) {
21448
21416
 
21449
- var baseModules = options.modules || this.getModules(),
21450
- additionalModules = options.additionalModules || [],
21451
- staticModules = [
21452
- {
21453
- bpmnjs: [ 'value', this ],
21454
- moddle: [ 'value', moddle ]
21455
- }
21456
- ];
21417
+ const baseModules = options.modules || this.getModules(),
21418
+ additionalModules = options.additionalModules || [],
21419
+ staticModules = [
21420
+ {
21421
+ bpmnjs: [ 'value', this ],
21422
+ moddle: [ 'value', moddle ]
21423
+ }
21424
+ ];
21457
21425
 
21458
- var diagramModules = [].concat(staticModules, baseModules, additionalModules);
21426
+ const diagramModules = [].concat(staticModules, baseModules, additionalModules);
21459
21427
 
21460
- var diagramOptions = assign(omit(options, [ 'additionalModules' ]), {
21428
+ const diagramOptions = assign(omit(options, [ 'additionalModules' ]), {
21461
21429
  canvas: assign({}, options.canvas, { container: container }),
21462
21430
  modules: diagramModules
21463
21431
  });
@@ -21484,7 +21452,7 @@
21484
21452
 
21485
21453
  BaseViewer.prototype._createContainer = function(options) {
21486
21454
 
21487
- var container = domify('<div class="bjs-container"></div>');
21455
+ const container = domify('<div class="bjs-container"></div>');
21488
21456
 
21489
21457
  assign$1(container, {
21490
21458
  width: ensureUnit(options.width),
@@ -21496,7 +21464,7 @@
21496
21464
  };
21497
21465
 
21498
21466
  BaseViewer.prototype._createModdle = function(options) {
21499
- var moddleOptions = assign({}, this._moddleExtensions, options.moddleExtensions);
21467
+ const moddleOptions = assign({}, this._moddleExtensions, options.moddleExtensions);
21500
21468
 
21501
21469
  return new simple(moddleOptions);
21502
21470
  };
@@ -21515,8 +21483,8 @@
21515
21483
  // check if we can help the user by indicating wrong BPMN 2.0 xml
21516
21484
  // (in case he or the exporting tool did not get that right)
21517
21485
 
21518
- var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
21519
- var match = pattern.exec(err.message);
21486
+ const pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
21487
+ const match = pattern.exec(err.message);
21520
21488
 
21521
21489
  if (match) {
21522
21490
  err.message =
@@ -21527,7 +21495,7 @@
21527
21495
  return err;
21528
21496
  }
21529
21497
 
21530
- var DEFAULT_OPTIONS = {
21498
+ const DEFAULT_OPTIONS = {
21531
21499
  width: '100%',
21532
21500
  height: '100%',
21533
21501
  position: 'relative'
@@ -21569,18 +21537,18 @@
21569
21537
  * @param {Element} container
21570
21538
  */
21571
21539
  function addProjectLogo(container) {
21572
- var img = BPMNIO_IMG;
21540
+ const img = BPMNIO_IMG;
21573
21541
 
21574
- var linkMarkup =
21542
+ const linkMarkup =
21575
21543
  '<a href="http://bpmn.io" ' +
21576
- 'target="_blank" ' +
21577
- 'class="bjs-powered-by" ' +
21578
- 'title="Powered by bpmn.io" ' +
21579
- '>' +
21580
- img +
21544
+ 'target="_blank" ' +
21545
+ 'class="bjs-powered-by" ' +
21546
+ 'title="Powered by bpmn.io" ' +
21547
+ '>' +
21548
+ img +
21581
21549
  '</a>';
21582
21550
 
21583
- var linkElement = domify(linkMarkup);
21551
+ const linkElement = domify(linkMarkup);
21584
21552
 
21585
21553
  assign$1(query('svg', linkElement), LOGO_STYLES);
21586
21554
  assign$1(linkElement, LINK_STYLES, {