camunda-bpmn-js 2.0.2 → 2.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.
Files changed (30) hide show
  1. package/dist/base-modeler.development.js +14001 -10194
  2. package/dist/base-modeler.production.min.js +41 -38
  3. package/dist/base-navigated-viewer.development.js +161 -121
  4. package/dist/base-navigated-viewer.production.min.js +1 -1
  5. package/dist/base-viewer.development.js +155 -119
  6. package/dist/base-viewer.production.min.js +1 -1
  7. package/dist/camunda-cloud-modeler.development.js +45602 -38158
  8. package/dist/camunda-cloud-modeler.production.min.js +35 -32
  9. package/dist/camunda-cloud-navigated-viewer.development.js +191 -141
  10. package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
  11. package/dist/camunda-cloud-viewer.development.js +185 -139
  12. package/dist/camunda-cloud-viewer.production.min.js +1 -1
  13. package/dist/camunda-platform-modeler.development.js +52130 -46628
  14. package/dist/camunda-platform-modeler.production.min.js +35 -32
  15. package/dist/camunda-platform-navigated-viewer.development.js +161 -121
  16. package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
  17. package/dist/camunda-platform-viewer.development.js +155 -119
  18. package/dist/camunda-platform-viewer.production.min.js +1 -1
  19. package/lib/base/Modeler.js +13 -8
  20. package/lib/camunda-cloud/Modeler.js +9 -7
  21. package/lib/camunda-platform/Modeler.js +8 -3
  22. package/package.json +17 -15
  23. package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesAppendProvider.js +0 -162
  24. package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesCreateProvider.js +0 -114
  25. package/lib/camunda-cloud/features/create-append-anything/index.js +0 -11
  26. package/lib/camunda-cloud/features/replace/ElementTemplatesReplaceProvider.js +0 -118
  27. package/lib/camunda-cloud/features/replace/index.js +0 -6
  28. package/lib/shared/features/replace/UnlinkTemplateReplaceProvider.js +0 -178
  29. package/lib/shared/features/replace/index.js +0 -8
  30. package/lib/shared/features/replace/util/ReplaceOptionsUtil.js +0 -7
@@ -11021,7 +11021,11 @@
11021
11021
  }
11022
11022
  };
11023
11023
 
11024
- var objectRefs = {exports: {}};
11024
+ var objectRefsExports = {};
11025
+ var objectRefs = {
11026
+ get exports(){ return objectRefsExports; },
11027
+ set exports(v){ objectRefsExports = v; },
11028
+ };
11025
11029
 
11026
11030
  var collection = {};
11027
11031
 
@@ -11341,7 +11345,7 @@
11341
11345
  module.exports.Collection = collection;
11342
11346
  } (objectRefs));
11343
11347
 
11344
- var Refs = /*@__PURE__*/getDefaultExportFromCjs(objectRefs.exports);
11348
+ var Refs = /*@__PURE__*/getDefaultExportFromCjs(objectRefsExports);
11345
11349
 
11346
11350
  var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
11347
11351
  labelRefs = new Refs({ name: 'labels', enumerable: true, collection: true }, { name: 'labelTarget' }),
@@ -21055,7 +21059,20 @@
21055
21059
 
21056
21060
 
21057
21061
  /**
21058
- * @typedef { import('didi').ModuleDeclaration } Module
21062
+ * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
21063
+ *
21064
+ * @typedef {import('./BaseViewer').BaseModelerOptions} BaseModelerOptions
21065
+ * @typedef {import('./BaseViewer').ModdleElement} ModdleElement
21066
+ * @typedef {import('./BaseViewer').ImportXMLResult} ImportXMLResult
21067
+ * @typedef {import('./BaseViewer').ImportXMLError} ImportXMLError
21068
+ * @typedef {import('./BaseViewer').ImportDefinitionsResult} ImportDefinitionsResult
21069
+ * @typedef {import('./BaseViewer').ImportDefinitionsError} ImportDefinitionsError
21070
+ * @typedef {import('./BaseViewer').ModdleElement} ModdleElement
21071
+ * @typedef {import('./BaseViewer').ModdleElementsById} ModdleElementsById
21072
+ * @typedef {import('./BaseViewer').OpenResult} OpenResult
21073
+ * @typedef {import('./BaseViewer').OpenError} OpenError
21074
+ * @typedef {import('./BaseViewer').SaveXMLOptions} SaveXMLOptions
21075
+ * @typedef {import('./BaseViewer').SaveXMLResult} SaveXMLResult
21059
21076
  */
21060
21077
 
21061
21078
  /**
@@ -21064,20 +21081,20 @@
21064
21081
  * Have a look at {@link Viewer}, {@link NavigatedViewer} or {@link Modeler} for
21065
21082
  * bundles that include actual features.
21066
21083
  *
21067
- * @param {Object} [options] configuration options to pass to the viewer
21068
- * @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
21069
- * @param {string|number} [options.width] the width of the viewer
21070
- * @param {string|number} [options.height] the height of the viewer
21071
- * @param {Object} [options.moddleExtensions] extension packages to provide
21072
- * @param {Module[]} [options.modules] a list of modules to override the default modules
21073
- * @param {Module[]} [options.additionalModules] a list of modules to use with the default modules
21084
+ * @param {BaseModelerOptions} [options] The options to configure the viewer.
21074
21085
  */
21075
21086
  function BaseViewer(options) {
21076
21087
 
21088
+ /**
21089
+ * @type {BaseModelerOptions}
21090
+ */
21077
21091
  options = assign$1({}, DEFAULT_OPTIONS, options);
21078
21092
 
21079
21093
  this._moddle = this._createModdle(options);
21080
21094
 
21095
+ /**
21096
+ * @type {HTMLElement}
21097
+ */
21081
21098
  this._container = this._createContainer(options);
21082
21099
 
21083
21100
  /* <project-logo> */
@@ -21091,22 +21108,6 @@
21091
21108
 
21092
21109
  e(BaseViewer, Diagram);
21093
21110
 
21094
- /**
21095
- * The importXML result.
21096
- *
21097
- * @typedef {Object} ImportXMLResult
21098
- *
21099
- * @property {Array<string>} warnings
21100
- */
21101
-
21102
- /**
21103
- * The importXML error.
21104
- *
21105
- * @typedef {Error} ImportXMLError
21106
- *
21107
- * @property {Array<string>} warnings
21108
- */
21109
-
21110
21111
  /**
21111
21112
  * Parse and render a BPMN 2.0 diagram.
21112
21113
  *
@@ -21117,7 +21118,7 @@
21117
21118
  *
21118
21119
  * During import the viewer will fire life-cycle events:
21119
21120
  *
21120
- * * import.parse.start (about to read model from xml)
21121
+ * * import.parse.start (about to read model from XML)
21121
21122
  * * import.parse.complete (model read; may have worked or not)
21122
21123
  * * import.render.start (graphical import start)
21123
21124
  * * import.render.complete (graphical import finished)
@@ -21125,10 +21126,18 @@
21125
21126
  *
21126
21127
  * You can use these events to hook into the life-cycle.
21127
21128
  *
21128
- * @param {string} xml the BPMN 2.0 xml
21129
- * @param {ModdleElement<BPMNDiagram>|string} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
21129
+ * @throws {ImportXMLError} An error thrown during the import of the XML.
21130
+ *
21131
+ * @fires BaseViewer#ImportParseStart
21132
+ * @fires BaseViewer#ImportParseComplete
21133
+ * @fires Importer#ImportRenderStart
21134
+ * @fires Importer#ImportRenderComplete
21135
+ * @fires BaseViewer#ImportDone
21130
21136
  *
21131
- * Returns {Promise<ImportXMLResult, ImportXMLError>}
21137
+ * @param {string} xml The BPMN 2.0 XML to be imported.
21138
+ * @param {ModdleElement|string} [bpmnDiagram] The optional diagram or Id of the BPMN diagram to open.
21139
+ *
21140
+ * @return {Promise<ImportXMLResult>} A promise resolving with warnings that were produced during the import.
21132
21141
  */
21133
21142
  BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(xml, bpmnDiagram) {
21134
21143
 
@@ -21164,6 +21173,14 @@
21164
21173
 
21165
21174
  // hook in pre-parse listeners +
21166
21175
  // allow xml manipulation
21176
+
21177
+ /**
21178
+ * A `import.parse.start` event.
21179
+ *
21180
+ * @event BaseViewer#ImportParseStart
21181
+ * @type {Object}
21182
+ * @property {string} xml The XML that is to be parsed.
21183
+ */
21167
21184
  xml = this._emit('import.parse.start', { xml: xml }) || xml;
21168
21185
 
21169
21186
  let parseResult;
@@ -21186,6 +21203,18 @@
21186
21203
 
21187
21204
  // hook in post parse listeners +
21188
21205
  // allow definitions manipulation
21206
+
21207
+ /**
21208
+ * A `import.parse.complete` event.
21209
+ *
21210
+ * @event BaseViewer#ImportParseComplete
21211
+ * @type {Object}
21212
+ * @property {Error|null} error An error thrown when parsing the XML.
21213
+ * @property {ModdleElement} definitions The definitions model element.
21214
+ * @property {ModdleElementsById} elementsById The model elements by ID.
21215
+ * @property {ModdleElement[]} references The referenced model elements.
21216
+ * @property {string[]} warnings The warnings produced when parsing the XML.
21217
+ */
21189
21218
  definitions = this._emit('import.parse.complete', ParseCompleteEvent({
21190
21219
  error: null,
21191
21220
  definitions: definitions,
@@ -21198,6 +21227,14 @@
21198
21227
 
21199
21228
  aggregatedWarnings = aggregatedWarnings.concat(importResult.warnings);
21200
21229
 
21230
+ /**
21231
+ * A `import.parse.complete` event.
21232
+ *
21233
+ * @event BaseViewer#ImportDone
21234
+ * @type {Object}
21235
+ * @property {ImportXMLError|null} error An error thrown during import.
21236
+ * @property {string[]} warnings The warnings.
21237
+ */
21201
21238
  this._emit('import.done', { error: null, warnings: aggregatedWarnings });
21202
21239
 
21203
21240
  return { warnings: aggregatedWarnings };
@@ -21214,21 +21251,6 @@
21214
21251
  }
21215
21252
  });
21216
21253
 
21217
- /**
21218
- * The importDefinitions result.
21219
- *
21220
- * @typedef {Object} ImportDefinitionsResult
21221
- *
21222
- * @property {Array<string>} warnings
21223
- */
21224
-
21225
- /**
21226
- * The importDefinitions error.
21227
- *
21228
- * @typedef {Error} ImportDefinitionsError
21229
- *
21230
- * @property {Array<string>} warnings
21231
- */
21232
21254
 
21233
21255
  /**
21234
21256
  * Import parsed definitions and render a BPMN 2.0 diagram.
@@ -21245,10 +21267,12 @@
21245
21267
  *
21246
21268
  * You can use these events to hook into the life-cycle.
21247
21269
  *
21248
- * @param {ModdleElement<Definitions>} definitions parsed BPMN 2.0 definitions
21249
- * @param {ModdleElement<BPMNDiagram>|string} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
21270
+ * @throws {ImportDefinitionsError} An error thrown during the import of the definitions.
21250
21271
  *
21251
- * Returns {Promise<ImportDefinitionsResult, ImportDefinitionsError>}
21272
+ * @param {ModdleElement} definitions The definitions.
21273
+ * @param {ModdleElement|string} [bpmnDiagram] The optional diagram or ID of the BPMN diagram to open.
21274
+ *
21275
+ * @return {Promise<ImportDefinitionsResult>} A promise resolving with warnings that were produced during the import.
21252
21276
  */
21253
21277
  BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
21254
21278
  this._setDefinitions(definitions);
@@ -21257,21 +21281,6 @@
21257
21281
  return { warnings: result.warnings };
21258
21282
  });
21259
21283
 
21260
- /**
21261
- * The open result.
21262
- *
21263
- * @typedef {Object} OpenResult
21264
- *
21265
- * @property {Array<string>} warnings
21266
- */
21267
-
21268
- /**
21269
- * The open error.
21270
- *
21271
- * @typedef {Error} OpenError
21272
- *
21273
- * @property {Array<string>} warnings
21274
- */
21275
21284
 
21276
21285
  /**
21277
21286
  * Open diagram of previously imported XML.
@@ -21288,9 +21297,11 @@
21288
21297
  *
21289
21298
  * You can use these events to hook into the life-cycle.
21290
21299
  *
21291
- * @param {string|ModdleElement<BPMNDiagram>} [bpmnDiagramOrId] id or the diagram to open
21300
+ * @throws {OpenError} An error thrown during opening.
21301
+ *
21302
+ * @param {ModdleElement|string} bpmnDiagramOrId The diagram or Id of the BPMN diagram to open.
21292
21303
  *
21293
- * Returns {Promise<OpenResult, OpenError>}
21304
+ * @return {Promise<OpenResult>} A promise resolving with warnings that were produced during opening.
21294
21305
  */
21295
21306
  BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
21296
21307
 
@@ -21331,14 +21342,6 @@
21331
21342
  return { warnings };
21332
21343
  });
21333
21344
 
21334
- /**
21335
- * The saveXML result.
21336
- *
21337
- * @typedef {Object} SaveXMLResult
21338
- *
21339
- * @property {string} xml
21340
- */
21341
-
21342
21345
  /**
21343
21346
  * Export the currently displayed BPMN 2.0 diagram as
21344
21347
  * a BPMN 2.0 XML document.
@@ -21353,11 +21356,14 @@
21353
21356
  *
21354
21357
  * You can use these events to hook into the life-cycle.
21355
21358
  *
21356
- * @param {Object} [options] export options
21357
- * @param {boolean} [options.format=false] output formatted XML
21358
- * @param {boolean} [options.preamble=true] output preamble
21359
+ * @throws {Error} An error thrown during export.
21360
+ *
21361
+ * @fires BaseViewer#SaveXMLStart
21362
+ * @fires BaseViewer#SaveXMLDone
21359
21363
  *
21360
- * Returns {Promise<SaveXMLResult, Error>}
21364
+ * @param {SaveXMLOptions} [options] The options.
21365
+ *
21366
+ * @return {Promise<SaveXMLResult>} A promise resolving with the XML.
21361
21367
  */
21362
21368
  BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
21363
21369
 
@@ -21372,6 +21378,14 @@
21372
21378
  }
21373
21379
 
21374
21380
  // allow to fiddle around with definitions
21381
+
21382
+ /**
21383
+ * A `saveXML.start` event.
21384
+ *
21385
+ * @event BaseViewer#SaveXMLStart
21386
+ * @type {Object}
21387
+ * @property {ModdleElement} definitions The definitions model element.
21388
+ */
21375
21389
  definitions = this._emit('saveXML.start', {
21376
21390
  definitions
21377
21391
  }) || definitions;
@@ -21388,6 +21402,14 @@
21388
21402
 
21389
21403
  const result = error ? { error } : { xml };
21390
21404
 
21405
+ /**
21406
+ * A `saveXML.done` event.
21407
+ *
21408
+ * @event BaseViewer#SaveXMLDone
21409
+ * @type {Object}
21410
+ * @property {Error} [error] An error thrown when saving the XML.
21411
+ * @property {string} [xml] The saved XML.
21412
+ */
21391
21413
  this._emit('saveXML.done', result);
21392
21414
 
21393
21415
  if (error) {
@@ -21397,13 +21419,6 @@
21397
21419
  return result;
21398
21420
  });
21399
21421
 
21400
- /**
21401
- * The saveSVG result.
21402
- *
21403
- * @typedef {Object} SaveSVGResult
21404
- *
21405
- * @property {string} svg
21406
- */
21407
21422
 
21408
21423
  /**
21409
21424
  * Export the currently displayed BPMN 2.0 diagram as
@@ -21418,11 +21433,13 @@
21418
21433
  *
21419
21434
  * You can use these events to hook into the life-cycle.
21420
21435
  *
21421
- * @param {Object} [options]
21436
+ * @throws {Error} An error thrown during export.
21437
+ *
21438
+ * @fires BaseViewer#SaveSVGDone
21422
21439
  *
21423
- * Returns {Promise<SaveSVGResult, Error>}
21440
+ * @return {Promise<SaveSVGResult>} A promise resolving with the SVG.
21424
21441
  */
21425
- BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG(options = {}) {
21442
+ BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG() {
21426
21443
  this._emit('saveSVG.start');
21427
21444
 
21428
21445
  let svg, err;
@@ -21451,6 +21468,14 @@
21451
21468
  err = e;
21452
21469
  }
21453
21470
 
21471
+ /**
21472
+ * A `saveSVG.done` event.
21473
+ *
21474
+ * @event BaseViewer#SaveSVGDone
21475
+ * @type {Object}
21476
+ * @property {Error} [error] An error thrown when saving the SVG.
21477
+ * @property {string} [svg] The saved SVG.
21478
+ */
21454
21479
  this._emit('saveSVG.done', {
21455
21480
  error: err,
21456
21481
  svg: svg
@@ -21502,21 +21527,17 @@
21502
21527
  /**
21503
21528
  * Return modules to instantiate with.
21504
21529
  *
21505
- * @param {any} options the instance got created with
21506
- *
21507
- * @return {Module[]}
21530
+ * @return {ModuleDeclaration[]} The modules.
21508
21531
  */
21509
- BaseViewer.prototype.getModules = function(options) {
21532
+ BaseViewer.prototype.getModules = function() {
21510
21533
  return this._modules;
21511
21534
  };
21512
21535
 
21513
21536
  /**
21514
21537
  * Remove all drawn elements from the viewer.
21515
21538
  *
21516
- * After calling this method the viewer can still
21517
- * be reused for opening another diagram.
21518
- *
21519
- * @method BaseViewer#clear
21539
+ * After calling this method the viewer can still be reused for opening another
21540
+ * diagram.
21520
21541
  */
21521
21542
  BaseViewer.prototype.clear = function() {
21522
21543
  if (!this.getDefinitions()) {
@@ -21530,8 +21551,8 @@
21530
21551
  };
21531
21552
 
21532
21553
  /**
21533
- * Destroy the viewer instance and remove all its
21534
- * remainders from the document tree.
21554
+ * Destroy the viewer instance and remove all its remainders from the document
21555
+ * tree.
21535
21556
  */
21536
21557
  BaseViewer.prototype.destroy = function() {
21537
21558
 
@@ -21543,29 +21564,34 @@
21543
21564
  };
21544
21565
 
21545
21566
  /**
21546
- * Register an event listener
21567
+ * Register an event listener.
21547
21568
  *
21548
- * Remove a previously added listener via {@link #off(event, callback)}.
21569
+ * Remove an event listener via {@link BaseViewer#off}.
21549
21570
  *
21550
- * @param {string} event
21551
- * @param {number} [priority]
21552
- * @param {Function} callback
21553
- * @param {Object} [that]
21571
+ * @param {string|string[]} events The event(s) to listen to.
21572
+ * @param {number} [priority] The priority with which to listen.
21573
+ * @param {EventCallback} callback The callback.
21574
+ * @param {*} [that] Value of `this` the callback will be called with.
21554
21575
  */
21555
- BaseViewer.prototype.on = function(event, priority, callback, target) {
21556
- return this.get('eventBus').on(event, priority, callback, target);
21576
+ BaseViewer.prototype.on = function(events, priority, callback, that) {
21577
+ return this.get('eventBus').on(events, priority, callback, that);
21557
21578
  };
21558
21579
 
21559
21580
  /**
21560
- * De-register an event listener
21581
+ * Remove an event listener.
21561
21582
  *
21562
- * @param {string} event
21563
- * @param {Function} callback
21583
+ * @param {string|string[]} events The event(s).
21584
+ * @param {Function} [callback] The callback.
21564
21585
  */
21565
- BaseViewer.prototype.off = function(event, callback) {
21566
- this.get('eventBus').off(event, callback);
21586
+ BaseViewer.prototype.off = function(events, callback) {
21587
+ this.get('eventBus').off(events, callback);
21567
21588
  };
21568
21589
 
21590
+ /**
21591
+ * Attach the viewer to an HTML element.
21592
+ *
21593
+ * @param {HTMLElement} parentNode The parent node to attach to.
21594
+ */
21569
21595
  BaseViewer.prototype.attachTo = function(parentNode) {
21570
21596
 
21571
21597
  if (!parentNode) {
@@ -21592,10 +21618,20 @@
21592
21618
  this.get('canvas').resized();
21593
21619
  };
21594
21620
 
21621
+ /**
21622
+ * Get the definitions model element.
21623
+ *
21624
+ * @returns {ModdleElement} The definitions model element.
21625
+ */
21595
21626
  BaseViewer.prototype.getDefinitions = function() {
21596
21627
  return this._definitions;
21597
21628
  };
21598
21629
 
21630
+ /**
21631
+ * Detach the viewer.
21632
+ *
21633
+ * @fires BaseViewer#DetachEvent
21634
+ */
21599
21635
  BaseViewer.prototype.detach = function() {
21600
21636
 
21601
21637
  const container = this._container,
@@ -21605,6 +21641,12 @@
21605
21641
  return;
21606
21642
  }
21607
21643
 
21644
+ /**
21645
+ * A `detach` event.
21646
+ *
21647
+ * @event BaseViewer#DetachEvent
21648
+ * @type {Object}
21649
+ */
21608
21650
  this._emit('detach', {});
21609
21651
 
21610
21652
  parentNode.removeChild(container);
@@ -21642,7 +21684,7 @@
21642
21684
  * @param {string} type
21643
21685
  * @param {Object} event
21644
21686
  *
21645
- * @return {Object} event processing result (if any)
21687
+ * @return {Object} The return value after calling all event listeners.
21646
21688
  */
21647
21689
  BaseViewer.prototype._emit = function(type, event) {
21648
21690
  return this.get('eventBus').fire(type, event);
@@ -21768,7 +21810,7 @@
21768
21810
  /* </project-logo> */
21769
21811
 
21770
21812
  /**
21771
- * @typedef { import('didi').ModuleDeclaration } Module
21813
+ * @typedef { import('./BaseViewer').BaseViewerOptions } BaseViewerOptions
21772
21814
  */
21773
21815
 
21774
21816
  /**
@@ -21810,13 +21852,7 @@
21810
21852
  * bpmnViewer.importXML(...);
21811
21853
  * ```
21812
21854
  *
21813
- * @param {Object} [options] configuration options to pass to the viewer
21814
- * @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
21815
- * @param {string|number} [options.width] the width of the viewer
21816
- * @param {string|number} [options.height] the height of the viewer
21817
- * @param {Object} [options.moddleExtensions] extension packages to provide
21818
- * @param {Module[]} [options.modules] a list of modules to override the default modules
21819
- * @param {Module[]} [options.additionalModules] a list of modules to use with the default modules
21855
+ * @param {BaseViewerOptions} [options] The options to configure the viewer.
21820
21856
  */
21821
21857
  function Viewer(options) {
21822
21858
  BaseViewer.call(this, options);