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.
- package/dist/bpmn-modeler.development.js +154 -186
- package/dist/bpmn-modeler.production.min.js +3 -3
- package/dist/bpmn-navigated-viewer.development.js +154 -186
- package/dist/bpmn-navigated-viewer.production.min.js +3 -3
- package/dist/bpmn-viewer.development.js +154 -186
- package/dist/bpmn-viewer.production.min.js +3 -3
- package/lib/BaseViewer.js +150 -184
- package/package.json +2 -2
- package/CHANGELOG.md +0 -817
package/lib/BaseViewer.js
CHANGED
|
@@ -107,13 +107,13 @@ inherits(BaseViewer, Diagram);
|
|
|
107
107
|
*
|
|
108
108
|
* Returns {Promise<ImportXMLResult, ImportXMLError>}
|
|
109
109
|
*/
|
|
110
|
-
BaseViewer.prototype.importXML = wrapForCompatibility(function importXML(xml, bpmnDiagram) {
|
|
110
|
+
BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(xml, bpmnDiagram) {
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
const self = this;
|
|
113
113
|
|
|
114
114
|
function ParseCompleteEvent(data) {
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
const event = self.get('eventBus').createEvent(data);
|
|
117
117
|
|
|
118
118
|
// TODO(nikku): remove with future bpmn-js version
|
|
119
119
|
Object.defineProperty(event, 'context', {
|
|
@@ -136,54 +136,59 @@ BaseViewer.prototype.importXML = wrapForCompatibility(function importXML(xml, bp
|
|
|
136
136
|
return event;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
let aggregatedWarnings = [];
|
|
140
|
+
try {
|
|
140
141
|
|
|
141
142
|
// hook in pre-parse listeners +
|
|
142
143
|
// allow xml manipulation
|
|
143
|
-
xml =
|
|
144
|
+
xml = this._emit('import.parse.start', { xml: xml }) || xml;
|
|
144
145
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
let parseResult;
|
|
147
|
+
try {
|
|
148
|
+
parseResult = await this._moddle.fromXML(xml, 'bpmn:Definitions');
|
|
149
|
+
} catch (error) {
|
|
150
|
+
this._emit('import.parse.complete', {
|
|
151
|
+
error
|
|
152
|
+
});
|
|
150
153
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
definitions = self._emit('import.parse.complete', ParseCompleteEvent({
|
|
154
|
-
error: null,
|
|
155
|
-
definitions: definitions,
|
|
156
|
-
elementsById: elementsById,
|
|
157
|
-
references: references,
|
|
158
|
-
warnings: parseWarnings
|
|
159
|
-
})) || definitions;
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
160
156
|
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
let definitions = parseResult.rootElement;
|
|
158
|
+
const references = parseResult.references;
|
|
159
|
+
const parseWarnings = parseResult.warnings;
|
|
160
|
+
const elementsById = parseResult.elementsById;
|
|
163
161
|
|
|
164
|
-
|
|
162
|
+
aggregatedWarnings = aggregatedWarnings.concat(parseWarnings);
|
|
165
163
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
// hook in post parse listeners +
|
|
165
|
+
// allow definitions manipulation
|
|
166
|
+
definitions = this._emit('import.parse.complete', ParseCompleteEvent({
|
|
167
|
+
error: null,
|
|
168
|
+
definitions: definitions,
|
|
169
|
+
elementsById: elementsById,
|
|
170
|
+
references: references,
|
|
171
|
+
warnings: aggregatedWarnings
|
|
172
|
+
})) || definitions;
|
|
169
173
|
|
|
170
|
-
|
|
174
|
+
const importResult = await this.importDefinitions(definitions, bpmnDiagram);
|
|
171
175
|
|
|
172
|
-
|
|
173
|
-
});
|
|
174
|
-
}).catch(function(err) {
|
|
176
|
+
aggregatedWarnings = aggregatedWarnings.concat(importResult.warnings);
|
|
175
177
|
|
|
176
|
-
|
|
177
|
-
error: err
|
|
178
|
-
});
|
|
178
|
+
this._emit('import.done', { error: null, warnings: aggregatedWarnings });
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
return { warnings: aggregatedWarnings };
|
|
181
|
+
} catch (err) {
|
|
182
|
+
let error = err;
|
|
183
|
+
aggregatedWarnings = aggregatedWarnings.concat(error.warnings || []);
|
|
184
|
+
addWarningsToError(error, aggregatedWarnings);
|
|
181
185
|
|
|
182
|
-
|
|
186
|
+
error = checkValidationError(error);
|
|
183
187
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
188
|
+
this._emit('import.done', { error, warnings: error.warnings });
|
|
189
|
+
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
187
192
|
});
|
|
188
193
|
|
|
189
194
|
/**
|
|
@@ -222,24 +227,11 @@ BaseViewer.prototype.importXML = wrapForCompatibility(function importXML(xml, bp
|
|
|
222
227
|
*
|
|
223
228
|
* Returns {Promise<ImportDefinitionsResult, ImportDefinitionsError>}
|
|
224
229
|
*/
|
|
225
|
-
BaseViewer.prototype.importDefinitions = wrapForCompatibility(function importDefinitions(definitions, bpmnDiagram) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return new Promise(function(resolve, reject) {
|
|
230
|
-
|
|
231
|
-
self._setDefinitions(definitions);
|
|
232
|
-
|
|
233
|
-
self.open(bpmnDiagram).then(function(result) {
|
|
230
|
+
BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
|
|
231
|
+
this._setDefinitions(definitions);
|
|
232
|
+
const result = await this.open(bpmnDiagram);
|
|
234
233
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return resolve({ warnings: warnings });
|
|
238
|
-
}).catch(function(err) {
|
|
239
|
-
|
|
240
|
-
return reject(err);
|
|
241
|
-
});
|
|
242
|
-
});
|
|
234
|
+
return { warnings: result.warnings };
|
|
243
235
|
});
|
|
244
236
|
|
|
245
237
|
/**
|
|
@@ -277,50 +269,43 @@ BaseViewer.prototype.importDefinitions = wrapForCompatibility(function importDef
|
|
|
277
269
|
*
|
|
278
270
|
* Returns {Promise<OpenResult, OpenError>}
|
|
279
271
|
*/
|
|
280
|
-
BaseViewer.prototype.open = wrapForCompatibility(function open(bpmnDiagramOrId) {
|
|
281
|
-
|
|
282
|
-
var definitions = this._definitions;
|
|
283
|
-
var bpmnDiagram = bpmnDiagramOrId;
|
|
284
|
-
|
|
285
|
-
var self = this;
|
|
286
|
-
|
|
287
|
-
return new Promise(function(resolve, reject) {
|
|
288
|
-
if (!definitions) {
|
|
289
|
-
var err1 = new Error('no XML imported');
|
|
272
|
+
BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
|
|
290
273
|
|
|
291
|
-
|
|
292
|
-
|
|
274
|
+
const definitions = this._definitions;
|
|
275
|
+
let bpmnDiagram = bpmnDiagramOrId;
|
|
293
276
|
|
|
294
|
-
|
|
295
|
-
|
|
277
|
+
if (!definitions) {
|
|
278
|
+
const error = new Error('no XML imported');
|
|
279
|
+
addWarningsToError(error, []);
|
|
296
280
|
|
|
297
|
-
|
|
298
|
-
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
299
283
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
284
|
+
if (typeof bpmnDiagramOrId === 'string') {
|
|
285
|
+
bpmnDiagram = findBPMNDiagram(definitions, bpmnDiagramOrId);
|
|
303
286
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
self.clear();
|
|
308
|
-
} catch (error) {
|
|
287
|
+
if (!bpmnDiagram) {
|
|
288
|
+
const error = new Error('BPMNDiagram <' + bpmnDiagramOrId + '> not found');
|
|
289
|
+
addWarningsToError(error, []);
|
|
309
290
|
|
|
310
|
-
|
|
291
|
+
throw error;
|
|
311
292
|
}
|
|
293
|
+
}
|
|
312
294
|
|
|
313
|
-
|
|
314
|
-
|
|
295
|
+
// clear existing rendered diagram
|
|
296
|
+
// catch synchronous exceptions during #clear()
|
|
297
|
+
try {
|
|
298
|
+
this.clear();
|
|
299
|
+
} catch (error) {
|
|
300
|
+
addWarningsToError(error, []);
|
|
315
301
|
|
|
316
|
-
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
317
304
|
|
|
318
|
-
|
|
319
|
-
|
|
305
|
+
// perform graphical import
|
|
306
|
+
const { warnings } = await importBpmnDiagram(this, definitions, bpmnDiagram);
|
|
320
307
|
|
|
321
|
-
|
|
322
|
-
});
|
|
323
|
-
});
|
|
308
|
+
return { warnings };
|
|
324
309
|
});
|
|
325
310
|
|
|
326
311
|
/**
|
|
@@ -351,53 +336,42 @@ BaseViewer.prototype.open = wrapForCompatibility(function open(bpmnDiagramOrId)
|
|
|
351
336
|
*
|
|
352
337
|
* Returns {Promise<SaveXMLResult, Error>}
|
|
353
338
|
*/
|
|
354
|
-
BaseViewer.prototype.saveXML = wrapForCompatibility(function saveXML(options) {
|
|
339
|
+
BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
|
|
355
340
|
|
|
356
341
|
options = options || {};
|
|
357
342
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
var definitions = this._definitions;
|
|
361
|
-
|
|
362
|
-
return new Promise(function(resolve) {
|
|
343
|
+
let definitions = this._definitions,
|
|
344
|
+
error, xml;
|
|
363
345
|
|
|
346
|
+
try {
|
|
364
347
|
if (!definitions) {
|
|
365
|
-
|
|
366
|
-
error: new Error('no definitions loaded')
|
|
367
|
-
});
|
|
348
|
+
throw new Error('no definitions loaded');
|
|
368
349
|
}
|
|
369
350
|
|
|
370
351
|
// allow to fiddle around with definitions
|
|
371
|
-
definitions =
|
|
372
|
-
definitions
|
|
352
|
+
definitions = this._emit('saveXML.start', {
|
|
353
|
+
definitions
|
|
373
354
|
}) || definitions;
|
|
374
355
|
|
|
375
|
-
|
|
356
|
+
const result = await this._moddle.toXML(definitions, options);
|
|
357
|
+
xml = result.xml;
|
|
376
358
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
return resolve({
|
|
384
|
-
xml: xml
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
}).catch(function(error) {
|
|
388
|
-
return { error: error };
|
|
389
|
-
}).then(function(result) {
|
|
359
|
+
xml = this._emit('saveXML.serialized', {
|
|
360
|
+
xml
|
|
361
|
+
}) || xml;
|
|
362
|
+
} catch (err) {
|
|
363
|
+
error = err;
|
|
364
|
+
}
|
|
390
365
|
|
|
391
|
-
|
|
366
|
+
const result = error ? { error } : { xml };
|
|
392
367
|
|
|
393
|
-
|
|
368
|
+
this._emit('saveXML.done', result);
|
|
394
369
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
370
|
+
if (error) {
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
398
373
|
|
|
399
|
-
|
|
400
|
-
});
|
|
374
|
+
return result;
|
|
401
375
|
});
|
|
402
376
|
|
|
403
377
|
/**
|
|
@@ -425,53 +399,45 @@ BaseViewer.prototype.saveXML = wrapForCompatibility(function saveXML(options) {
|
|
|
425
399
|
*
|
|
426
400
|
* Returns {Promise<SaveSVGResult, Error>}
|
|
427
401
|
*/
|
|
428
|
-
BaseViewer.prototype.saveSVG = wrapForCompatibility(function saveSVG(options) {
|
|
429
|
-
|
|
430
|
-
options = options || {};
|
|
431
|
-
|
|
432
|
-
var self = this;
|
|
402
|
+
BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG(options = {}) {
|
|
403
|
+
this._emit('saveSVG.start');
|
|
433
404
|
|
|
434
|
-
|
|
405
|
+
let svg, err;
|
|
435
406
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
var svg, err;
|
|
439
|
-
|
|
440
|
-
try {
|
|
441
|
-
var canvas = self.get('canvas');
|
|
407
|
+
try {
|
|
408
|
+
const canvas = this.get('canvas');
|
|
442
409
|
|
|
443
|
-
|
|
410
|
+
const contentNode = canvas.getActiveLayer(),
|
|
444
411
|
defsNode = domQuery('defs', canvas._svg);
|
|
445
412
|
|
|
446
|
-
|
|
413
|
+
const contents = innerSVG(contentNode),
|
|
447
414
|
defs = defsNode ? '<defs>' + innerSVG(defsNode) + '</defs>' : '';
|
|
448
415
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
416
|
+
const bbox = contentNode.getBBox();
|
|
417
|
+
|
|
418
|
+
svg =
|
|
419
|
+
'<?xml version="1.0" encoding="utf-8"?>\n' +
|
|
420
|
+
'<!-- created with bpmn-js / http://bpmn.io -->\n' +
|
|
421
|
+
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
|
|
422
|
+
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
|
|
423
|
+
'width="' + bbox.width + '" height="' + bbox.height + '" ' +
|
|
424
|
+
'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
|
|
425
|
+
defs + contents +
|
|
426
|
+
'</svg>';
|
|
427
|
+
} catch (e) {
|
|
428
|
+
err = e;
|
|
429
|
+
}
|
|
463
430
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
431
|
+
this._emit('saveSVG.done', {
|
|
432
|
+
error: err,
|
|
433
|
+
svg: svg
|
|
434
|
+
});
|
|
468
435
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
436
|
+
if (err) {
|
|
437
|
+
throw err;
|
|
438
|
+
}
|
|
472
439
|
|
|
473
|
-
|
|
474
|
-
});
|
|
440
|
+
return { svg };
|
|
475
441
|
});
|
|
476
442
|
|
|
477
443
|
/**
|
|
@@ -479,8 +445,8 @@ BaseViewer.prototype.saveSVG = wrapForCompatibility(function saveSVG(options) {
|
|
|
479
445
|
*
|
|
480
446
|
* @example
|
|
481
447
|
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
448
|
+
* const elementRegistry = viewer.get('elementRegistry');
|
|
449
|
+
* const startEventShape = elementRegistry.get('StartEvent_1');
|
|
484
450
|
*
|
|
485
451
|
* @param {string} name
|
|
486
452
|
*
|
|
@@ -495,7 +461,7 @@ BaseViewer.prototype.saveSVG = wrapForCompatibility(function saveSVG(options) {
|
|
|
495
461
|
* @example
|
|
496
462
|
*
|
|
497
463
|
* viewer.invoke(function(elementRegistry) {
|
|
498
|
-
*
|
|
464
|
+
* const startEventShape = elementRegistry.get('StartEvent_1');
|
|
499
465
|
* });
|
|
500
466
|
*
|
|
501
467
|
* @param {Function} fn to be invoked
|
|
@@ -602,8 +568,8 @@ BaseViewer.prototype.getDefinitions = function() {
|
|
|
602
568
|
|
|
603
569
|
BaseViewer.prototype.detach = function() {
|
|
604
570
|
|
|
605
|
-
|
|
606
|
-
|
|
571
|
+
const container = this._container,
|
|
572
|
+
parentNode = container.parentNode;
|
|
607
573
|
|
|
608
574
|
if (!parentNode) {
|
|
609
575
|
return;
|
|
@@ -616,18 +582,18 @@ BaseViewer.prototype.detach = function() {
|
|
|
616
582
|
|
|
617
583
|
BaseViewer.prototype._init = function(container, moddle, options) {
|
|
618
584
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
585
|
+
const baseModules = options.modules || this.getModules(),
|
|
586
|
+
additionalModules = options.additionalModules || [],
|
|
587
|
+
staticModules = [
|
|
588
|
+
{
|
|
589
|
+
bpmnjs: [ 'value', this ],
|
|
590
|
+
moddle: [ 'value', moddle ]
|
|
591
|
+
}
|
|
592
|
+
];
|
|
627
593
|
|
|
628
|
-
|
|
594
|
+
const diagramModules = [].concat(staticModules, baseModules, additionalModules);
|
|
629
595
|
|
|
630
|
-
|
|
596
|
+
const diagramOptions = assign(omit(options, [ 'additionalModules' ]), {
|
|
631
597
|
canvas: assign({}, options.canvas, { container: container }),
|
|
632
598
|
modules: diagramModules
|
|
633
599
|
});
|
|
@@ -654,7 +620,7 @@ BaseViewer.prototype._emit = function(type, event) {
|
|
|
654
620
|
|
|
655
621
|
BaseViewer.prototype._createContainer = function(options) {
|
|
656
622
|
|
|
657
|
-
|
|
623
|
+
const container = domify('<div class="bjs-container"></div>');
|
|
658
624
|
|
|
659
625
|
assignStyle(container, {
|
|
660
626
|
width: ensureUnit(options.width),
|
|
@@ -666,7 +632,7 @@ BaseViewer.prototype._createContainer = function(options) {
|
|
|
666
632
|
};
|
|
667
633
|
|
|
668
634
|
BaseViewer.prototype._createModdle = function(options) {
|
|
669
|
-
|
|
635
|
+
const moddleOptions = assign({}, this._moddleExtensions, options.moddleExtensions);
|
|
670
636
|
|
|
671
637
|
return new BpmnModdle(moddleOptions);
|
|
672
638
|
};
|
|
@@ -685,8 +651,8 @@ function checkValidationError(err) {
|
|
|
685
651
|
// check if we can help the user by indicating wrong BPMN 2.0 xml
|
|
686
652
|
// (in case he or the exporting tool did not get that right)
|
|
687
653
|
|
|
688
|
-
|
|
689
|
-
|
|
654
|
+
const pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
|
|
655
|
+
const match = pattern.exec(err.message);
|
|
690
656
|
|
|
691
657
|
if (match) {
|
|
692
658
|
err.message =
|
|
@@ -697,7 +663,7 @@ function checkValidationError(err) {
|
|
|
697
663
|
return err;
|
|
698
664
|
}
|
|
699
665
|
|
|
700
|
-
|
|
666
|
+
const DEFAULT_OPTIONS = {
|
|
701
667
|
width: '100%',
|
|
702
668
|
height: '100%',
|
|
703
669
|
position: 'relative'
|
|
@@ -753,18 +719,18 @@ import {
|
|
|
753
719
|
* @param {Element} container
|
|
754
720
|
*/
|
|
755
721
|
function addProjectLogo(container) {
|
|
756
|
-
|
|
722
|
+
const img = BPMNIO_IMG;
|
|
757
723
|
|
|
758
|
-
|
|
724
|
+
const linkMarkup =
|
|
759
725
|
'<a href="http://bpmn.io" ' +
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
726
|
+
'target="_blank" ' +
|
|
727
|
+
'class="bjs-powered-by" ' +
|
|
728
|
+
'title="Powered by bpmn.io" ' +
|
|
729
|
+
'>' +
|
|
730
|
+
img +
|
|
765
731
|
'</a>';
|
|
766
732
|
|
|
767
|
-
|
|
733
|
+
const linkElement = domify(linkMarkup);
|
|
768
734
|
|
|
769
735
|
assignStyle(domQuery('svg', linkElement), LOGO_STYLES);
|
|
770
736
|
assignStyle(linkElement, LINK_STYLES, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bpmn-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "A bpmn 2.0 toolkit and web modeler",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"cross-env": "^7.0.3",
|
|
67
67
|
"del": "^6.0.0",
|
|
68
68
|
"eslint": "^8.22.0",
|
|
69
|
-
"eslint-plugin-bpmn-io": "^0.
|
|
69
|
+
"eslint-plugin-bpmn-io": "^0.15.1",
|
|
70
70
|
"eslint-plugin-import": "^2.26.0",
|
|
71
71
|
"execa": "^5.1.1",
|
|
72
72
|
"karma": "^6.4.0",
|