camunda-bpmn-js 1.4.0 → 1.5.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.
@@ -435,6 +435,14 @@
435
435
 
436
436
  var DEFAULT_RENDER_PRIORITY$1 = 1000;
437
437
 
438
+ /**
439
+ * @typedef {import('../model').Base} Base
440
+ * @typedef {import('../model').Connection} Connection
441
+ * @typedef {import('../model').Shape} Shape
442
+ *
443
+ * @typedef {import('../core/EventBus').default} EventBus
444
+ */
445
+
438
446
  /**
439
447
  * The base implementation of shape and connection renderers.
440
448
  *
@@ -473,52 +481,51 @@
473
481
  }
474
482
 
475
483
  /**
476
- * Should check whether *this* renderer can render
477
- * the element/connection.
484
+ * Checks whether an element can be rendered.
478
485
  *
479
- * @param {element} element
486
+ * @param {Base} element The element to be rendered.
480
487
  *
481
- * @returns {boolean}
488
+ * @returns {boolean} Whether the element can be rendered.
482
489
  */
483
- BaseRenderer.prototype.canRender = function() {};
490
+ BaseRenderer.prototype.canRender = function(element) {};
484
491
 
485
492
  /**
486
- * Provides the shape's snap svg element to be drawn on the `canvas`.
493
+ * Draws a shape.
487
494
  *
488
- * @param {djs.Graphics} visuals
489
- * @param {Shape} shape
495
+ * @param {SVGElement} visuals The SVG element to draw the shape into.
496
+ * @param {Shape} shape The shape to be drawn.
490
497
  *
491
- * @returns {Snap.svg} [returns a Snap.svg paper element ]
498
+ * @returns {SVGElement} The SVG element of the shape drawn.
492
499
  */
493
- BaseRenderer.prototype.drawShape = function() {};
500
+ BaseRenderer.prototype.drawShape = function(visuals, shape) {};
494
501
 
495
502
  /**
496
- * Provides the shape's snap svg element to be drawn on the `canvas`.
503
+ * Draws a connection.
497
504
  *
498
- * @param {djs.Graphics} visuals
499
- * @param {Connection} connection
505
+ * @param {SVGElement} visuals The SVG element to draw the connection into.
506
+ * @param {Connection} connection The connection to be drawn.
500
507
  *
501
- * @returns {Snap.svg} [returns a Snap.svg paper element ]
508
+ * @returns {SVGElement} The SVG element of the connection drawn.
502
509
  */
503
- BaseRenderer.prototype.drawConnection = function() {};
510
+ BaseRenderer.prototype.drawConnection = function(visuals, connection) {};
504
511
 
505
512
  /**
506
- * Gets the SVG path of a shape that represents it's visual bounds.
513
+ * Gets the SVG path of the graphical representation of a shape.
507
514
  *
508
- * @param {Shape} shape
515
+ * @param {Shape} shape The shape.
509
516
  *
510
- * @return {string} svg path
517
+ * @return {string} The SVG path of the shape.
511
518
  */
512
- BaseRenderer.prototype.getShapePath = function() {};
519
+ BaseRenderer.prototype.getShapePath = function(shape) {};
513
520
 
514
521
  /**
515
- * Gets the SVG path of a connection that represents it's visual bounds.
522
+ * Gets the SVG path of the graphical representation of a connection.
516
523
  *
517
- * @param {Connection} connection
524
+ * @param {Connection} connection The connection.
518
525
  *
519
- * @return {string} svg path
526
+ * @return {string} The SVG path of the connection.
520
527
  */
521
- BaseRenderer.prototype.getConnectionPath = function() {};
528
+ BaseRenderer.prototype.getConnectionPath = function(connection) {};
522
529
 
523
530
  /**
524
531
  * Is an element of the given BPMN type?
@@ -1325,9 +1332,15 @@
1325
1332
  }
1326
1333
 
1327
1334
  /**
1328
- * @param { [ string, ...any[] ][] } elements
1335
+ * @typedef {(string|number)[]} Component
1336
+ *
1337
+ * @typedef {import('../util/Types').Point} Point
1338
+ */
1339
+
1340
+ /**
1341
+ * @param {Component[]} elements
1329
1342
  *
1330
- * @return { string }
1343
+ * @return {string}
1331
1344
  */
1332
1345
  function componentsToPath(elements) {
1333
1346
  return elements.flat().join(',').replace(/,?([A-z]),?/g, '$1');
@@ -1407,9 +1420,9 @@
1407
1420
  }
1408
1421
 
1409
1422
  /**
1410
- * @param { { x: number, y: number }[] } points
1411
- * @param { any } [attrs]
1412
- * @param { number } [radius]
1423
+ * @param {Point[]} points
1424
+ * @param {*} [attrs]
1425
+ * @param {number} [radius]
1413
1426
  *
1414
1427
  * @return {SVGElement}
1415
1428
  */
@@ -1434,8 +1447,8 @@
1434
1447
  }
1435
1448
 
1436
1449
  /**
1437
- * @param { SVGElement } gfx
1438
- * @param { { x: number, y: number }[]} points
1450
+ * @param {SVGElement} gfx
1451
+ * @param {Point[]} points
1439
1452
  *
1440
1453
  * @return {SVGElement}
1441
1454
  */
@@ -2156,7 +2169,7 @@
2156
2169
  }
2157
2170
 
2158
2171
  /**
2159
- * @param {<SVGElement>} element
2172
+ * @param {SVGElement} element
2160
2173
  * @param {number} x
2161
2174
  * @param {number} y
2162
2175
  * @param {number} angle
@@ -4236,6 +4249,10 @@
4236
4249
  return getRectPath(element);
4237
4250
  };
4238
4251
 
4252
+ /**
4253
+ * @typedef {import('../util/Types').Dimensions} Dimensions
4254
+ */
4255
+
4239
4256
  var DEFAULT_BOX_PADDING = 0;
4240
4257
 
4241
4258
  var DEFAULT_LABEL_SIZE$1 = {
@@ -4309,7 +4326,8 @@
4309
4326
  *
4310
4327
  * Alters the lines passed.
4311
4328
  *
4312
- * @param {Array<string>} lines
4329
+ * @param {string[]} lines
4330
+ *
4313
4331
  * @return {Object} the line descriptor, an object { width, height, text }
4314
4332
  */
4315
4333
  function layoutNext(lines, maxWidth, fakeText) {
@@ -4354,8 +4372,9 @@
4354
4372
  * Shortens a line based on spacing and hyphens.
4355
4373
  * Returns the shortened result on success.
4356
4374
  *
4357
- * @param {string} line
4358
- * @param {number} maxLength the maximum characters of the string
4375
+ * @param {string} line
4376
+ * @param {number} maxLength the maximum characters of the string
4377
+ *
4359
4378
  * @return {string} the shortened string
4360
4379
  */
4361
4380
  function semanticShorten(line, maxLength) {
@@ -5195,6 +5214,10 @@
5195
5214
  pathMap: [ 'type', PathMap ]
5196
5215
  };
5197
5216
 
5217
+ /**
5218
+ * @typedef {import('./').Replacements} Replacements
5219
+ */
5220
+
5198
5221
  /**
5199
5222
  * A simple translation stub to be used for multi-language support
5200
5223
  * in diagrams. Can be easily replaced with a more sophisticated
@@ -5209,7 +5232,7 @@
5209
5232
  * }
5210
5233
  *
5211
5234
  * @param {string} template to interpolate
5212
- * @param {Object} [replacements] a map with substitutes
5235
+ * @param {Replacements} [replacements] a map with substitutes
5213
5236
  *
5214
5237
  * @return {string} the translated string
5215
5238
  */
@@ -5366,8 +5389,6 @@
5366
5389
  return element && !!element.labelTarget;
5367
5390
  }
5368
5391
 
5369
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5370
-
5371
5392
  function getDefaultExportFromCjs (x) {
5372
5393
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5373
5394
  }
@@ -5384,9 +5405,9 @@
5384
5405
  /**
5385
5406
  * Convert the given bounds to a { top, left, bottom, right } descriptor.
5386
5407
  *
5387
- * @param {Bounds|Point} bounds
5408
+ * @param {Point|Rect} bounds
5388
5409
  *
5389
- * @return {Object}
5410
+ * @return {RectTRBL}
5390
5411
  */
5391
5412
  function asTRBL(bounds) {
5392
5413
  return {
@@ -5401,9 +5422,9 @@
5401
5422
  /**
5402
5423
  * Convert a { top, left, bottom, right } to an objects bounds.
5403
5424
  *
5404
- * @param {Object} trbl
5425
+ * @param {RectTRBL} trbl
5405
5426
  *
5406
- * @return {Bounds}
5427
+ * @return {Rect}
5407
5428
  */
5408
5429
  function asBounds(trbl) {
5409
5430
  return {
@@ -5418,7 +5439,7 @@
5418
5439
  /**
5419
5440
  * Get the mid of the given bounds or point.
5420
5441
  *
5421
- * @param {Bounds|Point} bounds
5442
+ * @param {Point|Rect} bounds
5422
5443
  *
5423
5444
  * @return {Point}
5424
5445
  */
@@ -5433,7 +5454,7 @@
5433
5454
  /**
5434
5455
  * Get the mid of the given Connection.
5435
5456
  *
5436
- * @param {djs.Base.Connection} connection
5457
+ * @param {Connection} connection
5437
5458
  *
5438
5459
  * @return {Point}
5439
5460
  */
@@ -5492,7 +5513,7 @@
5492
5513
  /**
5493
5514
  * Get the mid of the given Element.
5494
5515
  *
5495
- * @param {djs.Base.Connection} connection
5516
+ * @param {Connection} connection
5496
5517
  *
5497
5518
  * @return {Point}
5498
5519
  */
@@ -5919,6 +5940,14 @@
5919
5940
  return isPrimaryButton(event) && originalEvent.shiftKey;
5920
5941
  }
5921
5942
 
5943
+ /**
5944
+ * @typedef {import('../../model').Base} Base
5945
+ *
5946
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
5947
+ * @typedef {import('../../core/EventBus').default} EventBus
5948
+ * @typedef {import('../../draw/Styles').default} Styles
5949
+ */
5950
+
5922
5951
  function allowAll(event) { return true; }
5923
5952
 
5924
5953
  function allowPrimaryAndAuxiliary(event) {
@@ -5948,6 +5977,8 @@
5948
5977
  * prevents the original DOM operation.
5949
5978
  *
5950
5979
  * @param {EventBus} eventBus
5980
+ * @param {ElementRegistry} elementRegistry
5981
+ * @param {Styles} styles
5951
5982
  */
5952
5983
  function InteractionEvents(eventBus, elementRegistry, styles) {
5953
5984
 
@@ -5957,8 +5988,8 @@
5957
5988
  * Fire an interaction event.
5958
5989
  *
5959
5990
  * @param {string} type local event name, e.g. element.click.
5960
- * @param {DOMEvent} event native event
5961
- * @param {djs.model.Base} [element] the diagram element to emit the event on;
5991
+ * @param {MouseEvent|TouchEvent} event native event
5992
+ * @param {Base} [element] the diagram element to emit the event on;
5962
5993
  * defaults to the event target
5963
5994
  */
5964
5995
  function fire(type, event, element) {
@@ -6040,8 +6071,8 @@
6040
6071
  * on the target shape or connection.
6041
6072
  *
6042
6073
  * @param {string} eventName the name of the triggered DOM event
6043
- * @param {MouseEvent} event
6044
- * @param {djs.model.Base} targetElement
6074
+ * @param {MouseEvent|TouchEvent} event
6075
+ * @param {Base} targetElement
6045
6076
  */
6046
6077
  function triggerMouseEvent(eventName, event, targetElement) {
6047
6078
 
@@ -6207,7 +6238,7 @@
6207
6238
  /**
6208
6239
  * Create default hit for the given element.
6209
6240
  *
6210
- * @param {djs.model.Base} element
6241
+ * @param {Base} element
6211
6242
  * @param {SVGElement} gfx
6212
6243
  *
6213
6244
  * @return {SVGElement} created hit
@@ -6279,8 +6310,8 @@
6279
6310
  /**
6280
6311
  * Update default hit of the element.
6281
6312
  *
6282
- * @param {djs.model.Base} element
6283
- * @param {SVGElement} gfx
6313
+ * @param {Base} element
6314
+ * @param {SVGElement} gfx
6284
6315
  *
6285
6316
  * @return {SVGElement} updated hit
6286
6317
  */
@@ -6328,7 +6359,7 @@
6328
6359
  * @event element.hover
6329
6360
  *
6330
6361
  * @type {Object}
6331
- * @property {djs.model.Base} element
6362
+ * @property {Base} element
6332
6363
  * @property {SVGElement} gfx
6333
6364
  * @property {Event} originalEvent
6334
6365
  */
@@ -6339,7 +6370,7 @@
6339
6370
  * @event element.out
6340
6371
  *
6341
6372
  * @type {Object}
6342
- * @property {djs.model.Base} element
6373
+ * @property {Base} element
6343
6374
  * @property {SVGElement} gfx
6344
6375
  * @property {Event} originalEvent
6345
6376
  */
@@ -6350,7 +6381,7 @@
6350
6381
  * @event element.click
6351
6382
  *
6352
6383
  * @type {Object}
6353
- * @property {djs.model.Base} element
6384
+ * @property {Base} element
6354
6385
  * @property {SVGElement} gfx
6355
6386
  * @property {Event} originalEvent
6356
6387
  */
@@ -6361,7 +6392,7 @@
6361
6392
  * @event element.dblclick
6362
6393
  *
6363
6394
  * @type {Object}
6364
- * @property {djs.model.Base} element
6395
+ * @property {Base} element
6365
6396
  * @property {SVGElement} gfx
6366
6397
  * @property {Event} originalEvent
6367
6398
  */
@@ -6372,7 +6403,7 @@
6372
6403
  * @event element.mousedown
6373
6404
  *
6374
6405
  * @type {Object}
6375
- * @property {djs.model.Base} element
6406
+ * @property {Base} element
6376
6407
  * @property {SVGElement} gfx
6377
6408
  * @property {Event} originalEvent
6378
6409
  */
@@ -6383,7 +6414,7 @@
6383
6414
  * @event element.mouseup
6384
6415
  *
6385
6416
  * @type {Object}
6386
- * @property {djs.model.Base} element
6417
+ * @property {Base} element
6387
6418
  * @property {SVGElement} gfx
6388
6419
  * @property {Event} originalEvent
6389
6420
  */
@@ -6395,7 +6426,7 @@
6395
6426
  * @event element.contextmenu
6396
6427
  *
6397
6428
  * @type {Object}
6398
- * @property {djs.model.Base} element
6429
+ * @property {Base} element
6399
6430
  * @property {SVGElement} gfx
6400
6431
  * @property {Event} originalEvent
6401
6432
  */
@@ -6409,10 +6440,10 @@
6409
6440
  * Returns the surrounding bbox for all elements in
6410
6441
  * the array or the element primitive.
6411
6442
  *
6412
- * @param {Array<djs.model.Shape>|djs.model.Shape} elements
6443
+ * @param {Base|Base[]} elements
6413
6444
  * @param {boolean} [stopRecursion=false]
6414
6445
  *
6415
- * @return {Bounds}
6446
+ * @return {Rect}
6416
6447
  */
6417
6448
  function getBBox(elements, stopRecursion) {
6418
6449
 
@@ -6483,6 +6514,12 @@
6483
6514
 
6484
6515
  var LOW_PRIORITY$3 = 500;
6485
6516
 
6517
+ /**
6518
+ * @typedef {import('../../model').Base} Base
6519
+ *
6520
+ * @typedef {import('../../core/EventBus').default} EventBus
6521
+ * @typedef {import('../../draw/Styles').default} Styles
6522
+ */
6486
6523
 
6487
6524
  /**
6488
6525
  * @class
@@ -6492,9 +6529,8 @@
6492
6529
  *
6493
6530
  * @param {EventBus} eventBus
6494
6531
  * @param {Styles} styles
6495
- * @param {ElementRegistry} elementRegistry
6496
6532
  */
6497
- function Outline(eventBus, styles, elementRegistry) {
6533
+ function Outline(eventBus, styles) {
6498
6534
 
6499
6535
  this.offset = 6;
6500
6536
 
@@ -6552,8 +6588,8 @@
6552
6588
  * Updates the outline of a shape respecting the dimension of the
6553
6589
  * element and an outline offset.
6554
6590
  *
6555
- * @param {SVGElement} outline
6556
- * @param {djs.model.Base} element
6591
+ * @param {SVGElement} outline
6592
+ * @param {Base} element
6557
6593
  */
6558
6594
  Outline.prototype.updateShapeOutline = function(outline, element) {
6559
6595
 
@@ -6571,8 +6607,8 @@
6571
6607
  * Updates the outline of a connection respecting the bounding box of
6572
6608
  * the connection and an outline offset.
6573
6609
  *
6574
- * @param {SVGElement} outline
6575
- * @param {djs.model.Base} element
6610
+ * @param {SVGElement} outline
6611
+ * @param {Base} element
6576
6612
  */
6577
6613
  Outline.prototype.updateConnectionOutline = function(outline, connection) {
6578
6614
 
@@ -6595,13 +6631,17 @@
6595
6631
  outline: [ 'type', Outline ]
6596
6632
  };
6597
6633
 
6634
+ /**
6635
+ * @typedef {import('../../core/EventBus').default} EventBus
6636
+ */
6637
+
6598
6638
  /**
6599
6639
  * A service that offers the current selection in a diagram.
6600
6640
  * Offers the api to control the selection, too.
6601
6641
  *
6602
6642
  * @class
6603
6643
  *
6604
- * @param {EventBus} eventBus the event bus
6644
+ * @param {EventBus} eventBus
6605
6645
  */
6606
6646
  function Selection(eventBus, canvas) {
6607
6647
 
@@ -6657,8 +6697,8 @@
6657
6697
  *
6658
6698
  * @method Selection#select
6659
6699
  *
6660
- * @param {Object|Object[]} elements element or array of elements to be selected
6661
- * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
6700
+ * @param {Object|Object[]} elements element or array of elements to be selected
6701
+ * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
6662
6702
  */
6663
6703
  Selection.prototype.select = function(elements, add) {
6664
6704
  var selectedElements = this._selectedElements,
@@ -6697,6 +6737,12 @@
6697
6737
  this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
6698
6738
  };
6699
6739
 
6740
+ /**
6741
+ * @typedef {import('../../core/Canvas').default} Canvas
6742
+ * @typedef {import('../../core/EventBus').default} EventBus
6743
+ * @typedef {import('./Selection').default} Selection
6744
+ */
6745
+
6700
6746
  var MARKER_HOVER = 'hover',
6701
6747
  MARKER_SELECTED = 'selected';
6702
6748
 
@@ -6713,6 +6759,7 @@
6713
6759
  *
6714
6760
  * @param {Canvas} canvas
6715
6761
  * @param {EventBus} eventBus
6762
+ * @param {Selection} selection
6716
6763
  */
6717
6764
  function SelectionVisuals(canvas, eventBus, selection) {
6718
6765
  this._canvas = canvas;
@@ -6818,6 +6865,19 @@
6818
6865
  };
6819
6866
  }
6820
6867
 
6868
+ /**
6869
+ * @typedef {import('../../core/Canvas').default} Canvas
6870
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
6871
+ * @typedef {import('../../core/EventBus').default} EventBus
6872
+ * @typedef {import('./Selection').default} Selection
6873
+ */
6874
+
6875
+ /**
6876
+ * @param {EventBus} eventBus
6877
+ * @param {Selection} selection
6878
+ * @param {Canvas} canvas
6879
+ * @param {ElementRegistry} elementRegistry
6880
+ */
6821
6881
  function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
6822
6882
 
6823
6883
  // Select elements on create
@@ -6938,9 +6998,8 @@
6938
6998
  /**
6939
6999
  * Util that provides unique IDs.
6940
7000
  *
6941
- * @class djs.util.IdGenerator
7001
+ * @class
6942
7002
  * @constructor
6943
- * @memberOf djs.util
6944
7003
  *
6945
7004
  * The ids can be customized via a given prefix and contain a random value to avoid collisions.
6946
7005
  *
@@ -6955,8 +7014,6 @@
6955
7014
  /**
6956
7015
  * Returns a next unique ID.
6957
7016
  *
6958
- * @method djs.util.IdGenerator#next
6959
- *
6960
7017
  * @returns {string} the id
6961
7018
  */
6962
7019
  IdGenerator.prototype.next = function() {
@@ -6968,6 +7025,18 @@
6968
7025
 
6969
7026
  var LOW_PRIORITY$2 = 500;
6970
7027
 
7028
+ /**
7029
+ * @typedef {import('../../core/Canvas').default} Canvas
7030
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
7031
+ * @typedef {import('../../core/EventBus').default} EventBus
7032
+ *
7033
+ * @typedef {import('./Overlays').Overlay} Overlay
7034
+ * @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
7035
+ * @typedef {import('./Overlays').OverlayContainer} OverlayContainer
7036
+ * @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
7037
+ * @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
7038
+ * @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
7039
+ */
6971
7040
 
6972
7041
  /**
6973
7042
  * A service that allows users to attach overlays to diagram elements.
@@ -6977,6 +7046,7 @@
6977
7046
  * @example
6978
7047
  *
6979
7048
  * // add a pink badge on the top left of the shape
7049
+ *
6980
7050
  * overlays.add(someShape, {
6981
7051
  * position: {
6982
7052
  * top: -5,
@@ -7028,19 +7098,21 @@
7028
7098
  * }
7029
7099
  * }
7030
7100
  *
7031
- * @param {Object} config
7101
+ * @param {OverlaysConfig} config
7032
7102
  * @param {EventBus} eventBus
7033
7103
  * @param {Canvas} canvas
7034
7104
  * @param {ElementRegistry} elementRegistry
7035
7105
  */
7036
7106
  function Overlays(config, eventBus, canvas, elementRegistry) {
7037
-
7038
7107
  this._eventBus = eventBus;
7039
7108
  this._canvas = canvas;
7040
7109
  this._elementRegistry = elementRegistry;
7041
7110
 
7042
7111
  this._ids = ids;
7043
7112
 
7113
+ /**
7114
+ * @type {OverlaysConfigDefault}
7115
+ */
7044
7116
  this._overlayDefaults = assign$1({
7045
7117
 
7046
7118
  // no show constraints
@@ -7051,16 +7123,18 @@
7051
7123
  }, config && config.defaults);
7052
7124
 
7053
7125
  /**
7054
- * Mapping overlayId -> overlay
7126
+ * @type {Map<string, Overlay>}
7055
7127
  */
7056
7128
  this._overlays = {};
7057
7129
 
7058
7130
  /**
7059
- * Mapping elementId -> overlay container
7131
+ * @type {OverlayContainer[]}
7060
7132
  */
7061
7133
  this._overlayContainers = [];
7062
7134
 
7063
- // root html element for all overlays
7135
+ /**
7136
+ * @type {HTMLElement}
7137
+ */
7064
7138
  this._overlayRoot = createRoot(canvas.getContainer());
7065
7139
 
7066
7140
  this._init();
@@ -7076,12 +7150,12 @@
7076
7150
 
7077
7151
 
7078
7152
  /**
7079
- * Returns the overlay with the specified id or a list of overlays
7153
+ * Returns the overlay with the specified ID or a list of overlays
7080
7154
  * for an element with a given type.
7081
7155
  *
7082
7156
  * @example
7083
7157
  *
7084
- * // return the single overlay with the given id
7158
+ * // return the single overlay with the given ID
7085
7159
  * overlays.get('some-id');
7086
7160
  *
7087
7161
  * // return all overlays for the shape
@@ -7090,16 +7164,12 @@
7090
7164
  * // return all overlays on shape with type 'badge'
7091
7165
  * overlays.get({ element: someShape, type: 'badge' });
7092
7166
  *
7093
- * // shape can also be specified as id
7167
+ * // shape can also be specified as ID
7094
7168
  * overlays.get({ element: 'element-id', type: 'badge' });
7095
7169
  *
7170
+ * @param {OverlaysFilter} search The filter to be used to find the overlay(s).
7096
7171
  *
7097
- * @param {Object} search
7098
- * @param {string} [search.id]
7099
- * @param {string|djs.model.Base} [search.element]
7100
- * @param {string} [search.type]
7101
- *
7102
- * @return {Object|Array<Object>} the overlay(s)
7172
+ * @return {Overlay|Overlay[]} The overlay(s).
7103
7173
  */
7104
7174
  Overlays.prototype.get = function(search) {
7105
7175
 
@@ -7131,27 +7201,13 @@
7131
7201
  };
7132
7202
 
7133
7203
  /**
7134
- * Adds a HTML overlay to an element.
7204
+ * Adds an HTML overlay to an element.
7135
7205
  *
7136
- * @param {string|djs.model.Base} element attach overlay to this shape
7137
- * @param {string} [type] optional type to assign to the overlay
7138
- * @param {Object} overlay the overlay configuration
7206
+ * @param {Base|string} element The element to add the overlay to.
7207
+ * @param {string} [type] An optional type that can be used to filter.
7208
+ * @param {OverlayAttrs} overlay The overlay.
7139
7209
  *
7140
- * @param {string|DOMElement} overlay.html html element to use as an overlay
7141
- * @param {Object} [overlay.show] show configuration
7142
- * @param {number} [overlay.show.minZoom] minimal zoom level to show the overlay
7143
- * @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
7144
- * @param {Object} overlay.position where to attach the overlay
7145
- * @param {number} [overlay.position.left] relative to element bbox left attachment
7146
- * @param {number} [overlay.position.top] relative to element bbox top attachment
7147
- * @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
7148
- * @param {number} [overlay.position.right] relative to element bbox right attachment
7149
- * @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
7150
- * diagram zoom
7151
- * @param {number} [overlay.scale.min]
7152
- * @param {number} [overlay.scale.max]
7153
- *
7154
- * @return {string} id that may be used to reference the overlay for update or removal
7210
+ * @return {string} The overlay's ID that can be used to get or remove it.
7155
7211
  */
7156
7212
  Overlays.prototype.add = function(element, type, overlay) {
7157
7213
 
@@ -7192,11 +7248,11 @@
7192
7248
 
7193
7249
 
7194
7250
  /**
7195
- * Remove an overlay with the given id or all overlays matching the given filter.
7251
+ * Remove an overlay with the given ID or all overlays matching the given filter.
7196
7252
  *
7197
7253
  * @see Overlays#get for filter options.
7198
7254
  *
7199
- * @param {string|object} [filter]
7255
+ * @param {OverlaysFilter} filter The filter to be used to find the overlay.
7200
7256
  */
7201
7257
  Overlays.prototype.remove = function(filter) {
7202
7258
 
@@ -7232,19 +7288,32 @@
7232
7288
 
7233
7289
  };
7234
7290
 
7291
+ /**
7292
+ * Checks whether overlays are shown.
7293
+ *
7294
+ * @returns {boolean} Whether overlays are shown.
7295
+ */
7235
7296
  Overlays.prototype.isShown = function() {
7236
7297
  return this._overlayRoot.style.display !== 'none';
7237
7298
  };
7238
7299
 
7300
+ /**
7301
+ * Show all overlays.
7302
+ */
7239
7303
  Overlays.prototype.show = function() {
7240
7304
  setVisible(this._overlayRoot);
7241
7305
  };
7242
7306
 
7243
-
7307
+ /**
7308
+ * Hide all overlays.
7309
+ */
7244
7310
  Overlays.prototype.hide = function() {
7245
7311
  setVisible(this._overlayRoot, false);
7246
7312
  };
7247
7313
 
7314
+ /**
7315
+ * Remove all overlays and their container.
7316
+ */
7248
7317
  Overlays.prototype.clear = function() {
7249
7318
  this._overlays = {};
7250
7319
 
@@ -7620,6 +7689,13 @@
7620
7689
  overlays: [ 'type', Overlays ]
7621
7690
  };
7622
7691
 
7692
+ /**
7693
+ * @typedef {import('../../core/Canvas').default} Canvas
7694
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
7695
+ * @typedef {import('../../core/EventBus').default} EventBus
7696
+ * @typedef {import('../../core/GraphicsFactory').default} GraphicsFactory
7697
+ */
7698
+
7623
7699
  /**
7624
7700
  * Adds change support to the diagram, including
7625
7701
  *
@@ -7689,32 +7765,41 @@
7689
7765
  changeSupport: [ 'type', ChangeSupport ]
7690
7766
  };
7691
7767
 
7768
+ /**
7769
+ * @typedef {import('../core/EventBus').default} EventBus
7770
+ * @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
7771
+ * @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
7772
+ */
7773
+
7692
7774
  var DEFAULT_PRIORITY$2 = 1000;
7693
7775
 
7694
7776
  /**
7695
- * A utility that can be used to plug-in into the command execution for
7777
+ * A utility that can be used to plug into the command execution for
7696
7778
  * extension and/or validation.
7697
7779
  *
7780
+ * @class
7781
+ * @constructor
7782
+ *
7698
7783
  * @param {EventBus} eventBus
7699
7784
  *
7700
7785
  * @example
7701
7786
  *
7702
- * import inherits from 'inherits-browser';
7703
- *
7704
7787
  * import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
7705
7788
  *
7706
- * function CommandLogger(eventBus) {
7707
- * CommandInterceptor.call(this, eventBus);
7789
+ * class CommandLogger extends CommandInterceptor {
7790
+ * constructor(eventBus) {
7791
+ * super(eventBus);
7708
7792
  *
7709
- * this.preExecute(function(event) {
7710
- * console.log('command pre-execute', event);
7793
+ * this.preExecute('shape.create', (event) => {
7794
+ * console.log('commandStack.shape-create.preExecute', event);
7711
7795
  * });
7712
7796
  * }
7713
- *
7714
- * inherits(CommandLogger, CommandInterceptor);
7715
- *
7716
7797
  */
7717
7798
  function CommandInterceptor(eventBus) {
7799
+
7800
+ /**
7801
+ * @type {EventBus}
7802
+ */
7718
7803
  this._eventBus = eventBus;
7719
7804
  }
7720
7805
 
@@ -7727,16 +7812,15 @@
7727
7812
  }
7728
7813
 
7729
7814
  /**
7730
- * Register an interceptor for a command execution
7731
- *
7732
- * @param {string|Array<string>} [events] list of commands to register on
7733
- * @param {string} [hook] command hook, i.e. preExecute, executed to listen on
7734
- * @param {number} [priority] the priority on which to hook into the execution
7735
- * @param {Function} handlerFn interceptor to be invoked with (event)
7736
- * @param {boolean} unwrap if true, unwrap the event and pass (context, command, event) to the
7737
- * listener instead
7738
- * @param {Object} [that] Pass context (`this`) to the handler function
7739
- */
7815
+ * Intercept a command during one of the phases.
7816
+ *
7817
+ * @param {string|string[]} [events] One or more commands to intercept.
7818
+ * @param {string} [hook] Phase during which to intercept command.
7819
+ * @param {number} [priority] Priority with which command will be intercepted.
7820
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7821
+ * @param {boolean} [unwrap] Whether the event should be unwrapped.
7822
+ * @param {*} [that] `this` value the callback will be called with.
7823
+ */
7740
7824
  CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
7741
7825
 
7742
7826
  if (isFunction(hook) || isNumber(hook)) {
@@ -7792,24 +7876,19 @@
7792
7876
  ];
7793
7877
 
7794
7878
  /*
7795
- * Install hook shortcuts
7796
- *
7797
- * This will generate the CommandInterceptor#(preExecute|...|reverted) methods
7798
- * which will in term forward to CommandInterceptor#on.
7879
+ * Add prototype methods for each phase of command execution (e.g. execute,
7880
+ * revert).
7799
7881
  */
7800
7882
  forEach$1(hooks, function(hook) {
7801
7883
 
7802
7884
  /**
7803
- * {canExecute|preExecute|preExecuted|execute|executed|postExecute|postExecuted|revert|reverted}
7804
- *
7805
- * A named hook for plugging into the command execution
7885
+ * Add prototype method for a specific phase of command execution.
7806
7886
  *
7807
- * @param {string|Array<string>} [events] list of commands to register on
7808
- * @param {number} [priority] the priority on which to hook into the execution
7809
- * @param {Function} handlerFn interceptor to be invoked with (event)
7810
- * @param {boolean} [unwrap=false] if true, unwrap the event and pass (context, command, event) to the
7811
- * listener instead
7812
- * @param {Object} [that] Pass context (`this`) to the handler function
7887
+ * @param {string|string[]} [events] One or more commands to intercept.
7888
+ * @param {number} [priority] Priority with which command will be intercepted.
7889
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7890
+ * @param {boolean} [unwrap] Whether the event should be unwrapped.
7891
+ * @param {*} [that] `this` value the callback will be called with.
7813
7892
  */
7814
7893
  CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
7815
7894
 
@@ -7825,12 +7904,18 @@
7825
7904
  };
7826
7905
  });
7827
7906
 
7907
+ /**
7908
+ * @typedef {import('didi').Injector} Injector
7909
+ *
7910
+ * @typedef {import('../../core/Canvas').default} Canvas
7911
+ */
7912
+
7828
7913
  /**
7829
7914
  * A modeling behavior that ensures we set the correct root element
7830
7915
  * as we undo and redo commands.
7831
7916
  *
7832
7917
  * @param {Canvas} canvas
7833
- * @param {didi.Injector} injector
7918
+ * @param {Injector} injector
7834
7919
  */
7835
7920
  function RootElementsBehavior(canvas, injector) {
7836
7921
 
@@ -7864,111 +7949,10 @@
7864
7949
  rootElementsBehavior: [ 'type', RootElementsBehavior ]
7865
7950
  };
7866
7951
 
7867
- var css_escape = {exports: {}};
7868
-
7869
- /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
7870
-
7871
- (function (module, exports) {
7872
- (function(root, factory) {
7873
- // https://github.com/umdjs/umd/blob/master/returnExports.js
7874
- {
7875
- // For Node.js.
7876
- module.exports = factory(root);
7877
- }
7878
- }(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
7879
-
7880
- if (root.CSS && root.CSS.escape) {
7881
- return root.CSS.escape;
7882
- }
7883
-
7884
- // https://drafts.csswg.org/cssom/#serialize-an-identifier
7885
- var cssEscape = function(value) {
7886
- if (arguments.length == 0) {
7887
- throw new TypeError('`CSS.escape` requires an argument.');
7888
- }
7889
- var string = String(value);
7890
- var length = string.length;
7891
- var index = -1;
7892
- var codeUnit;
7893
- var result = '';
7894
- var firstCodeUnit = string.charCodeAt(0);
7895
- while (++index < length) {
7896
- codeUnit = string.charCodeAt(index);
7897
- // Note: there’s no need to special-case astral symbols, surrogate
7898
- // pairs, or lone surrogates.
7899
-
7900
- // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
7901
- // (U+FFFD).
7902
- if (codeUnit == 0x0000) {
7903
- result += '\uFFFD';
7904
- continue;
7905
- }
7906
-
7907
- if (
7908
- // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
7909
- // U+007F, […]
7910
- (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
7911
- // If the character is the first character and is in the range [0-9]
7912
- // (U+0030 to U+0039), […]
7913
- (index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
7914
- // If the character is the second character and is in the range [0-9]
7915
- // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
7916
- (
7917
- index == 1 &&
7918
- codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
7919
- firstCodeUnit == 0x002D
7920
- )
7921
- ) {
7922
- // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
7923
- result += '\\' + codeUnit.toString(16) + ' ';
7924
- continue;
7925
- }
7926
-
7927
- if (
7928
- // If the character is the first character and is a `-` (U+002D), and
7929
- // there is no second character, […]
7930
- index == 0 &&
7931
- length == 1 &&
7932
- codeUnit == 0x002D
7933
- ) {
7934
- result += '\\' + string.charAt(index);
7935
- continue;
7936
- }
7937
-
7938
- // If the character is not handled by one of the above rules and is
7939
- // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
7940
- // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
7941
- // U+005A), or [a-z] (U+0061 to U+007A), […]
7942
- if (
7943
- codeUnit >= 0x0080 ||
7944
- codeUnit == 0x002D ||
7945
- codeUnit == 0x005F ||
7946
- codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
7947
- codeUnit >= 0x0041 && codeUnit <= 0x005A ||
7948
- codeUnit >= 0x0061 && codeUnit <= 0x007A
7949
- ) {
7950
- // the character itself
7951
- result += string.charAt(index);
7952
- continue;
7953
- }
7954
-
7955
- // Otherwise, the escaped character.
7956
- // https://drafts.csswg.org/cssom/#escape-a-character
7957
- result += '\\' + string.charAt(index);
7958
-
7959
- }
7960
- return result;
7961
- };
7962
-
7963
- if (!root.CSS) {
7964
- root.CSS = {};
7965
- }
7966
-
7967
- root.CSS.escape = cssEscape;
7968
- return cssEscape;
7969
-
7970
- }));
7971
- } (css_escape));
7952
+ /**
7953
+ * @param {string} str
7954
+ * @returns {string}
7955
+ */
7972
7956
 
7973
7957
  var HTML_ESCAPE_MAP = {
7974
7958
  '&': '&amp;',
@@ -9103,6 +9087,11 @@
9103
9087
  return value;
9104
9088
  }
9105
9089
 
9090
+ /**
9091
+ * @typedef {import('../core/EventBus').default} EventBus
9092
+ * @typedef {import('./Styles').default} Styles
9093
+ */
9094
+
9106
9095
  // apply default renderer with lowest possible priority
9107
9096
  // so that it only kicks in if noone else could render
9108
9097
  var DEFAULT_RENDER_PRIORITY = 1;
@@ -9220,9 +9209,9 @@
9220
9209
  /**
9221
9210
  * Builds a style definition from a className, a list of traits and an object of additional attributes.
9222
9211
  *
9223
- * @param {string} className
9224
- * @param {Array<string>} traits
9225
- * @param {Object} additionalAttrs
9212
+ * @param {string} className
9213
+ * @param {Array<string>} traits
9214
+ * @param {Object} additionalAttrs
9226
9215
  *
9227
9216
  * @return {Object} the style defintion
9228
9217
  */
@@ -9235,8 +9224,8 @@
9235
9224
  /**
9236
9225
  * Builds a style definition from a list of traits and an object of additional attributes.
9237
9226
  *
9238
- * @param {Array<string>} traits
9239
- * @param {Object} additionalAttrs
9227
+ * @param {Array<string>} traits
9228
+ * @param {Object} additionalAttrs
9240
9229
  *
9241
9230
  * @return {Object} the style defintion
9242
9231
  */
@@ -9273,8 +9262,8 @@
9273
9262
  /**
9274
9263
  * Failsafe remove an element from a collection
9275
9264
  *
9276
- * @param {Array<Object>} [collection]
9277
- * @param {Object} [element]
9265
+ * @param {Array<Object>} [collection]
9266
+ * @param {Object} [element]
9278
9267
  *
9279
9268
  * @return {number} the previous index of the element
9280
9269
  */
@@ -9344,6 +9333,27 @@
9344
9333
  }
9345
9334
  }
9346
9335
 
9336
+ /**
9337
+ * @typedef {import('.').ConnectionLike} ConnectionLike
9338
+ * @typedef {import('.').RootLike} RootLike
9339
+ * @typedef {import('.').ShapeLike} ShapeLike
9340
+ *
9341
+ * @typedef {import('./Canvas').CanvasConfig} CanvasConfig
9342
+ * @typedef {import('./Canvas').CanvasLayer} CanvasLayer
9343
+ * @typedef {import('./Canvas').CanvasLayers} CanvasLayers
9344
+ * @typedef {import('./Canvas').CanvasPlane} CanvasPlane
9345
+ * @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
9346
+ *
9347
+ * @typedef {import('./ElementRegistry').default} ElementRegistry
9348
+ * @typedef {import('./EventBus').default} EventBus
9349
+ * @typedef {import('./GraphicsFactory').default} GraphicsFactory
9350
+ *
9351
+ * @typedef {import('../util/Types').Dimensions} Dimensions
9352
+ * @typedef {import('../util/Types').Point} Point
9353
+ * @typedef {import('../util/Types').Rect} Rect
9354
+ * @typedef {import('../util/Types').RectTRBL} RectTRBL
9355
+ */
9356
+
9347
9357
  function round(number, resolution) {
9348
9358
  return Math.round(number * resolution) / resolution;
9349
9359
  }
@@ -9364,7 +9374,8 @@
9364
9374
  * Creates a HTML container element for a SVG element with
9365
9375
  * the given configuration
9366
9376
  *
9367
- * @param {Object} options
9377
+ * @param {CanvasConfig} options
9378
+ *
9368
9379
  * @return {HTMLElement} the container element
9369
9380
  */
9370
9381
  function createContainer(options) {
@@ -9424,21 +9435,34 @@
9424
9435
  *
9425
9436
  * @emits Canvas#canvas.init
9426
9437
  *
9427
- * @param {Object} config
9438
+ * @param {CanvasConfig|null} config
9428
9439
  * @param {EventBus} eventBus
9429
9440
  * @param {GraphicsFactory} graphicsFactory
9430
9441
  * @param {ElementRegistry} elementRegistry
9431
9442
  */
9432
9443
  function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
9433
-
9434
9444
  this._eventBus = eventBus;
9435
9445
  this._elementRegistry = elementRegistry;
9436
9446
  this._graphicsFactory = graphicsFactory;
9437
9447
 
9448
+ /**
9449
+ * @type {number}
9450
+ */
9438
9451
  this._rootsIdx = 0;
9439
9452
 
9453
+ /**
9454
+ * @type {CanvasLayers}
9455
+ */
9440
9456
  this._layers = {};
9457
+
9458
+ /**
9459
+ * @type {CanvasPlane[]}
9460
+ */
9441
9461
  this._planes = [];
9462
+
9463
+ /**
9464
+ * @type {RootLike|null}
9465
+ */
9442
9466
  this._rootElement = null;
9443
9467
 
9444
9468
  this._init(config || {});
@@ -9463,6 +9487,8 @@
9463
9487
  * ...
9464
9488
  * </svg>
9465
9489
  * </div>
9490
+ *
9491
+ * @param {CanvasConfig} config
9466
9492
  */
9467
9493
  Canvas.prototype._init = function(config) {
9468
9494
 
@@ -9484,7 +9510,7 @@
9484
9510
  this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
9485
9511
  }
9486
9512
 
9487
- eventBus.on('diagram.init', function() {
9513
+ eventBus.on('diagram.init', () => {
9488
9514
 
9489
9515
  /**
9490
9516
  * An event indicating that the canvas is ready to be drawn on.
@@ -9502,7 +9528,7 @@
9502
9528
  viewport: viewport
9503
9529
  });
9504
9530
 
9505
- }, this);
9531
+ });
9506
9532
 
9507
9533
  // reset viewbox on shape changes to
9508
9534
  // recompute the viewbox
@@ -9513,15 +9539,15 @@
9513
9539
  'connection.removed',
9514
9540
  'elements.changed',
9515
9541
  'root.set'
9516
- ], function() {
9542
+ ], () => {
9517
9543
  delete this._cachedViewbox;
9518
- }, this);
9544
+ });
9519
9545
 
9520
9546
  eventBus.on('diagram.destroy', 500, this._destroy, this);
9521
9547
  eventBus.on('diagram.clear', 500, this._clear, this);
9522
9548
  };
9523
9549
 
9524
- Canvas.prototype._destroy = function(emit) {
9550
+ Canvas.prototype._destroy = function() {
9525
9551
  this._eventBus.fire('canvas.destroy', {
9526
9552
  svg: this._svg,
9527
9553
  viewport: this._viewport
@@ -9568,7 +9594,7 @@
9568
9594
  * Returns the default layer on which
9569
9595
  * all elements are drawn.
9570
9596
  *
9571
- * @returns {SVGElement}
9597
+ * @return {SVGElement} The SVG element of the layer.
9572
9598
  */
9573
9599
  Canvas.prototype.getDefaultLayer = function() {
9574
9600
  return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
@@ -9584,10 +9610,10 @@
9584
9610
  * A layer with a certain index is always created above all
9585
9611
  * existing layers with the same index.
9586
9612
  *
9587
- * @param {string} name
9588
- * @param {number} index
9613
+ * @param {string} name The name of the layer.
9614
+ * @param {number} [index] The index of the layer.
9589
9615
  *
9590
- * @returns {SVGElement}
9616
+ * @return {SVGElement} The SVG element of the layer.
9591
9617
  */
9592
9618
  Canvas.prototype.getLayer = function(name, index) {
9593
9619
 
@@ -9616,8 +9642,9 @@
9616
9642
  *
9617
9643
  * This is used to determine the node a layer should be inserted at.
9618
9644
  *
9619
- * @param {Number} index
9620
- * @returns {Number}
9645
+ * @param {number} index
9646
+ *
9647
+ * @return {number}
9621
9648
  */
9622
9649
  Canvas.prototype._getChildIndex = function(index) {
9623
9650
  return reduce(this._layers, function(childIndex, layer) {
@@ -9635,7 +9662,7 @@
9635
9662
  * @param {string} name
9636
9663
  * @param {number} [index=0]
9637
9664
  *
9638
- * @return {Object} layer descriptor with { index, group: SVGGroup }
9665
+ * @return {CanvasLayer}
9639
9666
  */
9640
9667
  Canvas.prototype._createLayer = function(name, index) {
9641
9668
 
@@ -9656,8 +9683,9 @@
9656
9683
  /**
9657
9684
  * Shows a given layer.
9658
9685
  *
9659
- * @param {String} layer
9660
- * @returns {SVGElement}
9686
+ * @param {string} layer The name of the layer.
9687
+ *
9688
+ * @return {SVGElement} The SVG element of the layer.
9661
9689
  */
9662
9690
  Canvas.prototype.showLayer = function(name) {
9663
9691
 
@@ -9691,8 +9719,9 @@
9691
9719
  /**
9692
9720
  * Hides a given layer.
9693
9721
  *
9694
- * @param {String} layer
9695
- * @returns {SVGElement}
9722
+ * @param {string} layer The name of the layer.
9723
+ *
9724
+ * @return {SVGElement} The SVG element of the layer.
9696
9725
  */
9697
9726
  Canvas.prototype.hideLayer = function(name) {
9698
9727
 
@@ -9734,7 +9763,7 @@
9734
9763
  /**
9735
9764
  * Returns the currently active layer. Can be null.
9736
9765
  *
9737
- * @returns {SVGElement|null}
9766
+ * @return {CanvasLayer|null} The active layer of `null`.
9738
9767
  */
9739
9768
  Canvas.prototype.getActiveLayer = function() {
9740
9769
  const plane = this._findPlaneForRoot(this.getRootElement());
@@ -9750,9 +9779,9 @@
9750
9779
  /**
9751
9780
  * Returns the plane which contains the given element.
9752
9781
  *
9753
- * @param {string|djs.model.Base} element
9782
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9754
9783
  *
9755
- * @return {djs.model.Base} root for element
9784
+ * @return {RootLike|undefined} The root of the element.
9756
9785
  */
9757
9786
  Canvas.prototype.findRoot = function(element) {
9758
9787
  if (typeof element === 'string') {
@@ -9773,7 +9802,7 @@
9773
9802
  /**
9774
9803
  * Return a list of all root elements on the diagram.
9775
9804
  *
9776
- * @return {djs.model.Root[]}
9805
+ * @return {(RootLike)[]} The list of root elements.
9777
9806
  */
9778
9807
  Canvas.prototype.getRootElements = function() {
9779
9808
  return this._planes.map(function(plane) {
@@ -9792,7 +9821,7 @@
9792
9821
  * Returns the html element that encloses the
9793
9822
  * drawing canvas.
9794
9823
  *
9795
- * @return {DOMNode}
9824
+ * @return {HTMLElement} The HTML element of the container.
9796
9825
  */
9797
9826
  Canvas.prototype.getContainer = function() {
9798
9827
  return this._container;
@@ -9832,8 +9861,8 @@
9832
9861
  *
9833
9862
  * @event element.marker.update
9834
9863
  * @type {Object}
9835
- * @property {djs.model.Element} element the shape
9836
- * @property {Object} gfx the graphical representation of the shape
9864
+ * @property {Base} element the shape
9865
+ * @property {SVGElement} gfx the graphical representation of the shape
9837
9866
  * @property {string} marker
9838
9867
  * @property {boolean} add true if the marker was added, false if it got removed
9839
9868
  */
@@ -9848,14 +9877,15 @@
9848
9877
  * integrate extension into the marker life-cycle, too.
9849
9878
  *
9850
9879
  * @example
9880
+ *
9851
9881
  * canvas.addMarker('foo', 'some-marker');
9852
9882
  *
9853
9883
  * const fooGfx = canvas.getGraphics('foo');
9854
9884
  *
9855
9885
  * fooGfx; // <g class="... some-marker"> ... </g>
9856
9886
  *
9857
- * @param {string|djs.model.Base} element
9858
- * @param {string} marker
9887
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9888
+ * @param {string} marker The marker.
9859
9889
  */
9860
9890
  Canvas.prototype.addMarker = function(element, marker) {
9861
9891
  this._updateMarker(element, marker, true);
@@ -9868,18 +9898,18 @@
9868
9898
  * Fires the element.marker.update event, making it possible to
9869
9899
  * integrate extension into the marker life-cycle, too.
9870
9900
  *
9871
- * @param {string|djs.model.Base} element
9872
- * @param {string} marker
9901
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9902
+ * @param {string} marker The marker.
9873
9903
  */
9874
9904
  Canvas.prototype.removeMarker = function(element, marker) {
9875
9905
  this._updateMarker(element, marker, false);
9876
9906
  };
9877
9907
 
9878
9908
  /**
9879
- * Check the existence of a marker on element.
9909
+ * Check whether an element has a given marker.
9880
9910
  *
9881
- * @param {string|djs.model.Base} element
9882
- * @param {string} marker
9911
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9912
+ * @param {string} marker The marker.
9883
9913
  */
9884
9914
  Canvas.prototype.hasMarker = function(element, marker) {
9885
9915
  if (!element.id) {
@@ -9897,8 +9927,8 @@
9897
9927
  * Fires the element.marker.update event, making it possible to
9898
9928
  * integrate extension into the marker life-cycle, too.
9899
9929
  *
9900
- * @param {string|djs.model.Base} element
9901
- * @param {string} marker
9930
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9931
+ * @param {string} marker The marker.
9902
9932
  */
9903
9933
  Canvas.prototype.toggleMarker = function(element, marker) {
9904
9934
  if (this.hasMarker(element, marker)) {
@@ -9921,7 +9951,7 @@
9921
9951
  * root elements can be null. This is used for applications that want to manage
9922
9952
  * root elements themselves.
9923
9953
  *
9924
- * @returns {Object|djs.model.Root|null} rootElement.
9954
+ * @return {RootLike} The current root element.
9925
9955
  */
9926
9956
  Canvas.prototype.getRootElement = function() {
9927
9957
  const rootElement = this._rootElement;
@@ -9937,11 +9967,10 @@
9937
9967
  /**
9938
9968
  * Adds a given root element and returns it.
9939
9969
  *
9940
- * @param {Object|djs.model.Root} rootElement
9970
+ * @param {ShapeLike} [rootElement] The root element to be added.
9941
9971
  *
9942
- * @return {Object|djs.model.Root} rootElement
9972
+ * @return {RootLike} The added root element or an implicit root element.
9943
9973
  */
9944
-
9945
9974
  Canvas.prototype.addRootElement = function(rootElement) {
9946
9975
  const idx = this._rootsIdx++;
9947
9976
 
@@ -9972,11 +10001,11 @@
9972
10001
  };
9973
10002
 
9974
10003
  /**
9975
- * Removes a given rootElement and returns it.
10004
+ * Removes a given root element and returns it.
9976
10005
  *
9977
- * @param {djs.model.Root|String} rootElement
10006
+ * @param {ShapeLike|string} rootElement The root element or its ID.
9978
10007
  *
9979
- * @return {Object|djs.model.Root} rootElement
10008
+ * @return {ShapeLike|undefined} The removed root element.
9980
10009
  */
9981
10010
  Canvas.prototype.removeRootElement = function(rootElement) {
9982
10011
 
@@ -10010,15 +10039,13 @@
10010
10039
  };
10011
10040
 
10012
10041
 
10013
- // root element handling //////////////////////
10014
-
10015
10042
  /**
10016
10043
  * Sets a given element as the new root element for the canvas
10017
10044
  * and returns the new root element.
10018
10045
  *
10019
- * @param {Object|djs.model.Root} rootElement
10046
+ * @param {RootLike} rootElement The root element to be set.
10020
10047
  *
10021
- * @return {Object|djs.model.Root} new root element
10048
+ * @return {RootLike} The set root element.
10022
10049
  */
10023
10050
  Canvas.prototype.setRootElement = function(rootElement, override) {
10024
10051
 
@@ -10105,8 +10132,6 @@
10105
10132
  this._eventBus.fire('root.set', { element: rootElement });
10106
10133
  };
10107
10134
 
10108
- // add functionality //////////////////////
10109
-
10110
10135
  Canvas.prototype._ensureValid = function(type, element) {
10111
10136
  if (!element.id) {
10112
10137
  throw new Error('element must have an id');
@@ -10147,11 +10172,11 @@
10147
10172
  * Extensions may hook into these events to perform their magic.
10148
10173
  *
10149
10174
  * @param {string} type
10150
- * @param {Object|djs.model.Base} element
10151
- * @param {Object|djs.model.Base} [parent]
10175
+ * @param {ConnectionLike|ShapeLike} element
10176
+ * @param {ShapeLike} [parent]
10152
10177
  * @param {number} [parentIndex]
10153
10178
  *
10154
- * @return {Object|djs.model.Base} the added element
10179
+ * @return {ConnectionLike|ShapeLike} The added element.
10155
10180
  */
10156
10181
  Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
10157
10182
 
@@ -10180,26 +10205,26 @@
10180
10205
  };
10181
10206
 
10182
10207
  /**
10183
- * Adds a shape to the canvas
10208
+ * Adds a shape to the canvas.
10184
10209
  *
10185
- * @param {Object|djs.model.Shape} shape to add to the diagram
10186
- * @param {djs.model.Base} [parent]
10187
- * @param {number} [parentIndex]
10210
+ * @param {ShapeLike} shape The shape to be added
10211
+ * @param {ShapeLike} [parent] The shape's parent.
10212
+ * @param {number} [parentIndex] The index at which to add the shape to the parent's children.
10188
10213
  *
10189
- * @return {djs.model.Shape} the added shape
10214
+ * @return {ShapeLike} The added shape.
10190
10215
  */
10191
10216
  Canvas.prototype.addShape = function(shape, parent, parentIndex) {
10192
10217
  return this._addElement('shape', shape, parent, parentIndex);
10193
10218
  };
10194
10219
 
10195
10220
  /**
10196
- * Adds a connection to the canvas
10221
+ * Adds a connection to the canvas.
10197
10222
  *
10198
- * @param {Object|djs.model.Connection} connection to add to the diagram
10199
- * @param {djs.model.Base} [parent]
10200
- * @param {number} [parentIndex]
10223
+ * @param {ConnectionLike} connection The connection to be added.
10224
+ * @param {ShapeLike} [parent] The connection's parent.
10225
+ * @param {number} [parentIndex] The index at which to add the connection to the parent's children.
10201
10226
  *
10202
- * @return {djs.model.Connection} the added connection
10227
+ * @return {ConnectionLike} The added connection.
10203
10228
  */
10204
10229
  Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
10205
10230
  return this._addElement('connection', connection, parent, parentIndex);
@@ -10240,11 +10265,14 @@
10240
10265
 
10241
10266
 
10242
10267
  /**
10243
- * Removes a shape from the canvas
10268
+ * Removes a shape from the canvas.
10269
+ *
10270
+ * @fires ShapeRemoveEvent
10271
+ * @fires ShapeRemovedEvent
10244
10272
  *
10245
- * @param {string|djs.model.Shape} shape or shape id to be removed
10273
+ * @param {ShapeLike|string} shape The shape or its ID.
10246
10274
  *
10247
- * @return {djs.model.Shape} the removed shape
10275
+ * @return {ShapeLike} The removed shape.
10248
10276
  */
10249
10277
  Canvas.prototype.removeShape = function(shape) {
10250
10278
 
@@ -10253,10 +10281,10 @@
10253
10281
  *
10254
10282
  * @memberOf Canvas
10255
10283
  *
10256
- * @event shape.remove
10284
+ * @event ShapeRemoveEvent
10257
10285
  * @type {Object}
10258
- * @property {djs.model.Shape} element the shape descriptor
10259
- * @property {Object} gfx the graphical representation of the shape
10286
+ * @property {ShapeLike} element The shape.
10287
+ * @property {SVGElement} gfx The graphical element.
10260
10288
  */
10261
10289
 
10262
10290
  /**
@@ -10264,21 +10292,24 @@
10264
10292
  *
10265
10293
  * @memberOf Canvas
10266
10294
  *
10267
- * @event shape.removed
10295
+ * @event ShapeRemoved
10268
10296
  * @type {Object}
10269
- * @property {djs.model.Shape} element the shape descriptor
10270
- * @property {Object} gfx the graphical representation of the shape
10297
+ * @property {ShapeLike} element The shape.
10298
+ * @property {SVGElement} gfx The graphical element.
10271
10299
  */
10272
10300
  return this._removeElement(shape, 'shape');
10273
10301
  };
10274
10302
 
10275
10303
 
10276
10304
  /**
10277
- * Removes a connection from the canvas
10305
+ * Removes a connection from the canvas.
10278
10306
  *
10279
- * @param {string|djs.model.Connection} connection or connection id to be removed
10307
+ * @fires ConnectionRemoveEvent
10308
+ * @fires ConnectionRemovedEvent
10280
10309
  *
10281
- * @return {djs.model.Connection} the removed connection
10310
+ * @param {ConnectionLike|string} connection The connection or its ID.
10311
+ *
10312
+ * @return {ConnectionLike} The removed connection.
10282
10313
  */
10283
10314
  Canvas.prototype.removeConnection = function(connection) {
10284
10315
 
@@ -10287,10 +10318,10 @@
10287
10318
  *
10288
10319
  * @memberOf Canvas
10289
10320
  *
10290
- * @event connection.remove
10321
+ * @event ConnectionRemoveEvent
10291
10322
  * @type {Object}
10292
- * @property {djs.model.Connection} element the connection descriptor
10293
- * @property {Object} gfx the graphical representation of the connection
10323
+ * @property {ConnectionLike} element The connection.
10324
+ * @property {SVGElement} gfx The graphical element.
10294
10325
  */
10295
10326
 
10296
10327
  /**
@@ -10300,20 +10331,20 @@
10300
10331
  *
10301
10332
  * @event connection.removed
10302
10333
  * @type {Object}
10303
- * @property {djs.model.Connection} element the connection descriptor
10304
- * @property {Object} gfx the graphical representation of the connection
10334
+ * @property {ConnectionLike} element The connection.
10335
+ * @property {SVGElement} gfx The graphical element.
10305
10336
  */
10306
10337
  return this._removeElement(connection, 'connection');
10307
10338
  };
10308
10339
 
10309
10340
 
10310
10341
  /**
10311
- * Return the graphical object underlaying a certain diagram element
10342
+ * Returns the graphical element of an element.
10312
10343
  *
10313
- * @param {string|djs.model.Base} element descriptor of the element
10314
- * @param {boolean} [secondary=false] whether to return the secondary connected element
10344
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
10345
+ * @param {boolean} [secondary=false] Whether to return the secondary graphical element.
10315
10346
  *
10316
- * @return {SVGElement}
10347
+ * @return {SVGElement} The graphical element.
10317
10348
  */
10318
10349
  Canvas.prototype.getGraphics = function(element, secondary) {
10319
10350
  return this._elementRegistry.getGraphics(element, secondary);
@@ -10385,13 +10416,9 @@
10385
10416
  * height: zoomedAndScrolledViewbox.outer.height
10386
10417
  * });
10387
10418
  *
10388
- * @param {Object} [box] the new view box to set
10389
- * @param {number} box.x the top left X coordinate of the canvas visible in view box
10390
- * @param {number} box.y the top left Y coordinate of the canvas visible in view box
10391
- * @param {number} box.width the visible width
10392
- * @param {number} box.height
10419
+ * @param {Rect} [box] The viewbox to be set.
10393
10420
  *
10394
- * @return {Object} the current view box
10421
+ * @return {CanvasViewbox} The set viewbox.
10395
10422
  */
10396
10423
  Canvas.prototype.viewbox = function(box) {
10397
10424
 
@@ -10460,10 +10487,9 @@
10460
10487
  /**
10461
10488
  * Gets or sets the scroll of the canvas.
10462
10489
  *
10463
- * @param {Object} [delta] the new scroll to apply.
10490
+ * @param {Point} [delta] The scroll to be set.
10464
10491
  *
10465
- * @param {number} [delta.dx]
10466
- * @param {number} [delta.dy]
10492
+ * @return {Point}
10467
10493
  */
10468
10494
  Canvas.prototype.scroll = function(delta) {
10469
10495
 
@@ -10487,9 +10513,8 @@
10487
10513
  * Scrolls the viewbox to contain the given element.
10488
10514
  * Optionally specify a padding to be applied to the edges.
10489
10515
  *
10490
- * @param {Object|String} [element] the element to scroll to.
10491
- * @param {Object|Number} [padding=100] the padding to be applied. Can also specify top, bottom, left and right.
10492
- *
10516
+ * @param {ShapeLike|ConnectionLike|string} element The element to scroll to or its ID.
10517
+ * @param {RectTRBL|number} [padding=100] The padding to be applied. Can also specify top, bottom, left and right.
10493
10518
  */
10494
10519
  Canvas.prototype.scrollToElement = function(element, padding) {
10495
10520
  let defaultPadding = 100;
@@ -10557,17 +10582,17 @@
10557
10582
  };
10558
10583
 
10559
10584
  /**
10560
- * Gets or sets the current zoom of the canvas, optionally zooming
10561
- * to the specified position.
10585
+ * Gets or sets the current zoom of the canvas, optionally zooming to the
10586
+ * specified position.
10562
10587
  *
10563
- * The getter may return a cached zoom level. Call it with `false` as
10564
- * the first argument to force recomputation of the current level.
10588
+ * The getter may return a cached zoom level. Call it with `false` as the first
10589
+ * argument to force recomputation of the current level.
10565
10590
  *
10566
- * @param {string|number} [newScale] the new zoom level, either a number, i.e. 0.9,
10567
- * or `fit-viewport` to adjust the size to fit the current viewport
10568
- * @param {string|Point} [center] the reference point { x: .., y: ..} to zoom to, 'auto' to zoom into mid or null
10591
+ * @param {number|string} [newScale] The new zoom level, either a number,
10592
+ * i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
10593
+ * @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
10569
10594
  *
10570
- * @return {number} the current scale
10595
+ * @return {number} The set zoom level.
10571
10596
  */
10572
10597
  Canvas.prototype.zoom = function(newScale, center) {
10573
10598
 
@@ -10690,9 +10715,9 @@
10690
10715
 
10691
10716
 
10692
10717
  /**
10693
- * Returns the size of the canvas
10718
+ * Returns the size of the canvas.
10694
10719
  *
10695
- * @return {Dimensions}
10720
+ * @return {Dimensions} The size of the canvas.
10696
10721
  */
10697
10722
  Canvas.prototype.getSize = function() {
10698
10723
  return {
@@ -10703,14 +10728,14 @@
10703
10728
 
10704
10729
 
10705
10730
  /**
10706
- * Return the absolute bounding box for the given element
10731
+ * Returns the absolute bounding box of an element.
10707
10732
  *
10708
- * The absolute bounding box may be used to display overlays in the
10709
- * callers (browser) coordinate system rather than the zoomed in/out
10710
- * canvas coordinates.
10733
+ * The absolute bounding box may be used to display overlays in the callers
10734
+ * (browser) coordinate system rather than the zoomed in/out canvas coordinates.
10711
10735
  *
10712
- * @param {ElementDescriptor} element
10713
- * @return {Bounds} the absolute bounding box
10736
+ * @param {ShapeLike|ConnectionLike} element The element.
10737
+ *
10738
+ * @return {Rect} The element's absolute bounding box.
10714
10739
  */
10715
10740
  Canvas.prototype.getAbsoluteBBox = function(element) {
10716
10741
  const vbox = this.viewbox();
@@ -10745,8 +10770,7 @@
10745
10770
  };
10746
10771
 
10747
10772
  /**
10748
- * Fires an event in order other modules can react to the
10749
- * canvas resizing
10773
+ * Fires an event so other modules can react to the canvas resizing.
10750
10774
  */
10751
10775
  Canvas.prototype.resized = function() {
10752
10776
 
@@ -10758,11 +10782,21 @@
10758
10782
 
10759
10783
  var ELEMENT_ID = 'data-element-id';
10760
10784
 
10785
+ /**
10786
+ * @typedef {import('.').ElementLike} ElementLike
10787
+ *
10788
+ * @typedef {import('./EventBus').default} EventBus
10789
+ *
10790
+ * @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
10791
+ */
10761
10792
 
10762
10793
  /**
10794
+ * A registry that keeps track of all shapes in the diagram.
10795
+ *
10763
10796
  * @class
10797
+ * @constructor
10764
10798
  *
10765
- * A registry that keeps track of all shapes in the diagram.
10799
+ * @param {EventBus} eventBus
10766
10800
  */
10767
10801
  function ElementRegistry(eventBus) {
10768
10802
  this._elements = {};
@@ -10773,11 +10807,11 @@
10773
10807
  ElementRegistry.$inject = [ 'eventBus' ];
10774
10808
 
10775
10809
  /**
10776
- * Register a pair of (element, gfx, (secondaryGfx)).
10810
+ * Add an element and its graphical representation(s) to the registry.
10777
10811
  *
10778
- * @param {djs.model.Base} element
10779
- * @param {SVGElement} gfx
10780
- * @param {SVGElement} [secondaryGfx] optional other element to register, too
10812
+ * @param {ElementLike} element The element to be added.
10813
+ * @param {SVGElement} gfx The primary graphical representation.
10814
+ * @param {SVGElement} [secondaryGfx] The secondary graphical representation.
10781
10815
  */
10782
10816
  ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
10783
10817
 
@@ -10796,9 +10830,9 @@
10796
10830
  };
10797
10831
 
10798
10832
  /**
10799
- * Removes an element from the registry.
10833
+ * Remove an element from the registry.
10800
10834
  *
10801
- * @param {string|djs.model.Base} element
10835
+ * @param {ElementLike|string} element
10802
10836
  */
10803
10837
  ElementRegistry.prototype.remove = function(element) {
10804
10838
  var elements = this._elements,
@@ -10819,10 +10853,10 @@
10819
10853
  };
10820
10854
 
10821
10855
  /**
10822
- * Update the id of an element
10856
+ * Update an elements ID.
10823
10857
  *
10824
- * @param {string|djs.model.Base} element
10825
- * @param {string} newId
10858
+ * @param {ElementLike|string} element The element or its ID.
10859
+ * @param {string} newId The new ID.
10826
10860
  */
10827
10861
  ElementRegistry.prototype.updateId = function(element, newId) {
10828
10862
 
@@ -10848,11 +10882,11 @@
10848
10882
  };
10849
10883
 
10850
10884
  /**
10851
- * Update the graphics of an element
10885
+ * Update the graphical representation of an element.
10852
10886
  *
10853
- * @param {string|djs.model.Base} element
10854
- * @param {SVGElement} gfx
10855
- * @param {boolean} [secondary=false] whether to update the secondary connected element
10887
+ * @param {ElementLike|string} element The element or its ID.
10888
+ * @param {SVGElement} gfx The new graphical representation.
10889
+ * @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
10856
10890
  */
10857
10891
  ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
10858
10892
  var id = filter.id || filter;
@@ -10873,17 +10907,17 @@
10873
10907
  };
10874
10908
 
10875
10909
  /**
10876
- * Return the model element for a given id or graphics.
10910
+ * Get the element with the given ID or graphical representation.
10877
10911
  *
10878
10912
  * @example
10879
10913
  *
10880
10914
  * elementRegistry.get('SomeElementId_1');
10881
- * elementRegistry.get(gfx);
10882
10915
  *
10916
+ * elementRegistry.get(gfx);
10883
10917
  *
10884
- * @param {string|SVGElement} filter for selecting the element
10918
+ * @param {string|SVGElement} filter The elements ID or graphical representation.
10885
10919
  *
10886
- * @return {djs.model.Base}
10920
+ * @return {ElementLike|undefined} The element.
10887
10921
  */
10888
10922
  ElementRegistry.prototype.get = function(filter) {
10889
10923
  var id;
@@ -10901,9 +10935,9 @@
10901
10935
  /**
10902
10936
  * Return all elements that match a given filter function.
10903
10937
  *
10904
- * @param {Function} fn
10938
+ * @param {ElementRegistryCallback} fn The filter function.
10905
10939
  *
10906
- * @return {Array<djs.model.Base>}
10940
+ * @return {ElementLike[]} The matching elements.
10907
10941
  */
10908
10942
  ElementRegistry.prototype.filter = function(fn) {
10909
10943
 
@@ -10919,11 +10953,11 @@
10919
10953
  };
10920
10954
 
10921
10955
  /**
10922
- * Return the first element that satisfies the provided testing function.
10956
+ * Return the first element that matches the given filter function.
10923
10957
  *
10924
- * @param {Function} fn
10958
+ * @param {Function} fn The filter function.
10925
10959
  *
10926
- * @return {djs.model.Base}
10960
+ * @return {ElementLike|undefined} The matching element.
10927
10961
  */
10928
10962
  ElementRegistry.prototype.find = function(fn) {
10929
10963
  var map = this._elements,
@@ -10942,18 +10976,18 @@
10942
10976
  };
10943
10977
 
10944
10978
  /**
10945
- * Return all rendered model elements.
10979
+ * Get all elements.
10946
10980
  *
10947
- * @return {Array<djs.model.Base>}
10981
+ * @return {ElementLike[]} All elements.
10948
10982
  */
10949
10983
  ElementRegistry.prototype.getAll = function() {
10950
10984
  return this.filter(function(e) { return e; });
10951
10985
  };
10952
10986
 
10953
10987
  /**
10954
- * Iterate over all diagram elements.
10988
+ * Execute a given function for each element.
10955
10989
  *
10956
- * @param {Function} fn
10990
+ * @param {Function} fn The function to execute.
10957
10991
  */
10958
10992
  ElementRegistry.prototype.forEach = function(fn) {
10959
10993
 
@@ -10969,19 +11003,20 @@
10969
11003
  };
10970
11004
 
10971
11005
  /**
10972
- * Return the graphical representation of an element or its id.
11006
+ * Return the graphical representation of an element.
10973
11007
  *
10974
11008
  * @example
11009
+ *
10975
11010
  * elementRegistry.getGraphics('SomeElementId_1');
11011
+ *
10976
11012
  * elementRegistry.getGraphics(rootElement); // <g ...>
10977
11013
  *
10978
11014
  * elementRegistry.getGraphics(rootElement, true); // <svg ...>
10979
11015
  *
11016
+ * @param {ElementLike|string} filter The element or its ID.
11017
+ * @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
10980
11018
  *
10981
- * @param {string|djs.model.Base} filter
10982
- * @param {boolean} [secondary=false] whether to return the secondary connected element
10983
- *
10984
- * @return {SVGElement}
11019
+ * @return {SVGElement} The graphical representation.
10985
11020
  */
10986
11021
  ElementRegistry.prototype.getGraphics = function(filter, secondary) {
10987
11022
  var id = filter.id || filter;
@@ -10991,12 +11026,11 @@
10991
11026
  };
10992
11027
 
10993
11028
  /**
10994
- * Validate the suitability of the given id and signals a problem
10995
- * with an exception.
11029
+ * Validate an ID and throw an error if invalid.
10996
11030
  *
10997
11031
  * @param {string} id
10998
11032
  *
10999
- * @throws {Error} if id is empty or already assigned
11033
+ * @throws {Error} Error indicating that the ID is invalid or already assigned.
11000
11034
  */
11001
11035
  ElementRegistry.prototype._validateId = function(id) {
11002
11036
  if (!id) {
@@ -11336,14 +11370,6 @@
11336
11370
  outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
11337
11371
  incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
11338
11372
 
11339
- /**
11340
- * @namespace djs.model
11341
- */
11342
-
11343
- /**
11344
- * @memberOf djs.model
11345
- */
11346
-
11347
11373
  /**
11348
11374
  * The basic graphical representation
11349
11375
  *
@@ -11540,21 +11566,47 @@
11540
11566
  };
11541
11567
 
11542
11568
  /**
11543
- * Creates a new model element of the specified type
11569
+ * Creates a model element of the given type.
11544
11570
  *
11545
11571
  * @method create
11546
11572
  *
11547
11573
  * @example
11548
11574
  *
11549
- * var shape1 = Model.create('shape', { x: 10, y: 10, width: 100, height: 100 });
11550
- * var shape2 = Model.create('shape', { x: 210, y: 210, width: 100, height: 100 });
11575
+ * import * as Model from 'diagram-js/lib/model';
11576
+ *
11577
+ * const connection = Model.create('connection', {
11578
+ * waypoints: [
11579
+ * { x: 100, y: 100 },
11580
+ * { x: 200, y: 100 }
11581
+ * ]
11582
+ * });
11583
+ *
11584
+ * const label = Model.create('label', {
11585
+ * x: 100,
11586
+ * y: 100,
11587
+ * width: 100,
11588
+ * height: 100,
11589
+ * labelTarget: shape
11590
+ * });
11591
+ *
11592
+ * const root = Model.create('root', {
11593
+ * x: 100,
11594
+ * y: 100,
11595
+ * width: 100,
11596
+ * height: 100
11597
+ * });
11551
11598
  *
11552
- * var connection = Model.create('connection', { waypoints: [ { x: 110, y: 55 }, {x: 210, y: 55 } ] });
11599
+ * const shape = Model.create('shape', {
11600
+ * x: 100,
11601
+ * y: 100,
11602
+ * width: 100,
11603
+ * height: 100
11604
+ * });
11553
11605
  *
11554
- * @param {string} type lower-cased model name
11555
- * @param {Object} attrs attributes to initialize the new model instance with
11606
+ * @param {string} type The type of model element to be created.
11607
+ * @param {Object} attrs Attributes to create the model element with.
11556
11608
  *
11557
- * @return {Base} the new model instance
11609
+ * @return {Connection|Label|Root|Shape} The created model element.
11558
11610
  */
11559
11611
  function create(type, attrs) {
11560
11612
  var Type = types$7[type];
@@ -11565,36 +11617,78 @@
11565
11617
  }
11566
11618
 
11567
11619
  /**
11568
- * A factory for diagram-js shapes
11620
+ * @typedef {import('../model/index').Base} Base
11621
+ * @typedef {import('../model/index').Connection} Connection
11622
+ * @typedef {import('../model/index').Label} Label
11623
+ * @typedef {import('../model/index').Root} Root
11624
+ * @typedef {import('../model/index').Shape} Shape
11625
+ * @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
11626
+ * @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
11627
+ * @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
11628
+ * @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
11629
+ */
11630
+
11631
+ /**
11632
+ * A factory for model elements.
11633
+ *
11634
+ * @class
11635
+ * @constructor
11569
11636
  */
11570
11637
  function ElementFactory() {
11571
11638
  this._uid = 12;
11572
11639
  }
11573
11640
 
11574
-
11641
+ /**
11642
+ * Create a root element.
11643
+ *
11644
+ * @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
11645
+ *
11646
+ * @return {Root} The created root element.
11647
+ */
11575
11648
  ElementFactory.prototype.createRoot = function(attrs) {
11576
11649
  return this.create('root', attrs);
11577
11650
  };
11578
11651
 
11652
+ /**
11653
+ * Create a label.
11654
+ *
11655
+ * @param {ModelAttrsLabel} attrs The attributes of the label to be created.
11656
+ *
11657
+ * @return {Label} The created label.
11658
+ */
11579
11659
  ElementFactory.prototype.createLabel = function(attrs) {
11580
11660
  return this.create('label', attrs);
11581
11661
  };
11582
11662
 
11663
+ /**
11664
+ * Create a shape.
11665
+ *
11666
+ * @param {ModelAttrsShape} attrs The attributes of the shape to be created.
11667
+ *
11668
+ * @return {Shape} The created shape.
11669
+ */
11583
11670
  ElementFactory.prototype.createShape = function(attrs) {
11584
11671
  return this.create('shape', attrs);
11585
11672
  };
11586
11673
 
11674
+ /**
11675
+ * Create a connection.
11676
+ *
11677
+ * @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
11678
+ *
11679
+ * @return {Connection} The created connection.
11680
+ */
11587
11681
  ElementFactory.prototype.createConnection = function(attrs) {
11588
11682
  return this.create('connection', attrs);
11589
11683
  };
11590
11684
 
11591
11685
  /**
11592
- * Create a model element with the given type and
11593
- * a number of pre-set attributes.
11686
+ * Create a model element of the given type with the given attributes.
11594
11687
  *
11595
- * @param {string} type
11596
- * @param {Object} attrs
11597
- * @return {djs.model.Base} the newly created model instance
11688
+ * @param {string} type The type of the model element.
11689
+ * @param {Object} attrs The attributes of the model element.
11690
+ *
11691
+ * @return {Connection|Label|Root|Shape} The created model element.
11598
11692
  */
11599
11693
  ElementFactory.prototype.create = function(type, attrs) {
11600
11694
 
@@ -11613,6 +11707,16 @@
11613
11707
 
11614
11708
  var slice = Array.prototype.slice;
11615
11709
 
11710
+ /**
11711
+ * @typedef {import('./EventBus').Event} Event
11712
+ * @typedef {import('./EventBus').EventCallback} EventCallback
11713
+ *
11714
+ * @typedef {Object} EventListener
11715
+ * @property {Function} callback
11716
+ * @property {EventListener|null} next
11717
+ * @property {number} priority
11718
+ */
11719
+
11616
11720
  /**
11617
11721
  * A general purpose event bus.
11618
11722
  *
@@ -11717,10 +11821,10 @@
11717
11821
  *
11718
11822
  * Returning anything but `undefined` from a listener will stop the listener propagation.
11719
11823
  *
11720
- * @param {string|Array<string>} events
11721
- * @param {number} [priority=1000] the priority in which this listener is called, larger is higher
11722
- * @param {Function} callback
11723
- * @param {Object} [that] Pass context (`this`) to the callback
11824
+ * @param {string|string[]} events The event(s) to listen to.
11825
+ * @param {number} [priority=1000] The priority with which to listen.
11826
+ * @param {EventCallback} callback The callback.
11827
+ * @param {*} [that] Value of `this` the callback will be called with.
11724
11828
  */
11725
11829
  EventBus.prototype.on = function(events, priority, callback, that) {
11726
11830
 
@@ -11760,12 +11864,12 @@
11760
11864
 
11761
11865
 
11762
11866
  /**
11763
- * Register an event listener that is executed only once.
11867
+ * Register an event listener that is called only once.
11764
11868
  *
11765
- * @param {string} event the event name to register for
11766
- * @param {number} [priority=1000] the priority in which this listener is called, larger is higher
11767
- * @param {Function} callback the callback to execute
11768
- * @param {Object} [that] Pass context (`this`) to the callback
11869
+ * @param {string} event The event to listen to.
11870
+ * @param {number} [priority=1000] The priority with which to listen.
11871
+ * @param {EventCallback} callback The callback.
11872
+ * @param {*} [that] Value of `this` the callback will be called with.
11769
11873
  */
11770
11874
  EventBus.prototype.once = function(event, priority, callback, that) {
11771
11875
  var self = this;
@@ -11804,8 +11908,8 @@
11804
11908
  *
11805
11909
  * If no callback is given, all listeners for a given event name are being removed.
11806
11910
  *
11807
- * @param {string|Array<string>} events
11808
- * @param {Function} [callback]
11911
+ * @param {string|string[]} events The events.
11912
+ * @param {EventCallback} [callback] The callback.
11809
11913
  */
11810
11914
  EventBus.prototype.off = function(events, callback) {
11811
11915
 
@@ -11821,11 +11925,11 @@
11821
11925
 
11822
11926
 
11823
11927
  /**
11824
- * Create an EventBus event.
11928
+ * Create an event recognized be the event bus.
11825
11929
  *
11826
- * @param {Object} data
11930
+ * @param {Object} data Event data.
11827
11931
  *
11828
- * @return {Object} event, recognized by the eventBus
11932
+ * @return {Event} An event that will be recognized by the event bus.
11829
11933
  */
11830
11934
  EventBus.prototype.createEvent = function(data) {
11831
11935
  var event = new InternalEvent();
@@ -11837,7 +11941,7 @@
11837
11941
 
11838
11942
 
11839
11943
  /**
11840
- * Fires a named event.
11944
+ * Fires an event.
11841
11945
  *
11842
11946
  * @example
11843
11947
  *
@@ -11859,12 +11963,11 @@
11859
11963
  *
11860
11964
  * events.fire({ type: 'foo' }, 'I am bar!');
11861
11965
  *
11862
- * @param {string} [name] the optional event name
11863
- * @param {Object} [event] the event object
11864
- * @param {...Object} additional arguments to be passed to the callback functions
11966
+ * @param {string} [type] The event type.
11967
+ * @param {Object} [data] The event or event data.
11968
+ * @param {...*} additional Additional arguments the callback will be called with.
11865
11969
  *
11866
- * @return {boolean} the events return value, if specified or false if the
11867
- * default action was prevented by listeners
11970
+ * @return {*} The return value. Will be set to `false` if the default was prevented.
11868
11971
  */
11869
11972
  EventBus.prototype.fire = function(type, data) {
11870
11973
  var event,
@@ -11929,7 +12032,13 @@
11929
12032
  return returnValue;
11930
12033
  };
11931
12034
 
11932
-
12035
+ /**
12036
+ * Handle an error by firing an event.
12037
+ *
12038
+ * @param {Error} error The error to be handled.
12039
+ *
12040
+ * @return {boolean} Whether the error was handled.
12041
+ */
11933
12042
  EventBus.prototype.handleError = function(error) {
11934
12043
  return this.fire('error', { error: error }) === false;
11935
12044
  };
@@ -11992,7 +12101,7 @@
11992
12101
  return returnValue;
11993
12102
  };
11994
12103
 
11995
- /*
12104
+ /**
11996
12105
  * Add new listener with a certain priority to the list
11997
12106
  * of listeners (for the given event).
11998
12107
  *
@@ -12006,7 +12115,7 @@
12006
12115
  * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
12007
12116
  *
12008
12117
  * @param {string} event
12009
- * @param {Object} listener { priority, callback }
12118
+ * @param {EventListener} listener
12010
12119
  */
12011
12120
  EventBus.prototype._addListener = function(event, newListener) {
12012
12121
 
@@ -12112,9 +12221,9 @@
12112
12221
  * Invoke function. Be fast...
12113
12222
  *
12114
12223
  * @param {Function} fn
12115
- * @param {Array<Object>} args
12224
+ * @param {*[]} args
12116
12225
  *
12117
- * @return {Any}
12226
+ * @return {*}
12118
12227
  */
12119
12228
  function invokeFunction(fn, args) {
12120
12229
  return fn.apply(null, args);
@@ -12128,11 +12237,11 @@
12128
12237
  */
12129
12238
 
12130
12239
  /**
12131
- * Returns the visual part of a diagram element
12240
+ * Returns the visual part of a diagram element.
12132
12241
  *
12133
- * @param {Snap<SVGElement>} gfx
12242
+ * @param {SVGElement} gfx
12134
12243
  *
12135
- * @return {Snap<SVGElement>}
12244
+ * @return {SVGElement}
12136
12245
  */
12137
12246
  function getVisual(gfx) {
12138
12247
  return gfx.childNodes[0];
@@ -12141,15 +12250,28 @@
12141
12250
  /**
12142
12251
  * Returns the children for a given diagram element.
12143
12252
  *
12144
- * @param {Snap<SVGElement>} gfx
12145
- * @return {Snap<SVGElement>}
12253
+ * @param {SVGElement} gfx
12254
+ * @return {SVGElement}
12146
12255
  */
12147
12256
  function getChildren(gfx) {
12148
12257
  return gfx.parentNode.childNodes[1];
12149
12258
  }
12150
12259
 
12151
12260
  /**
12152
- * A factory that creates graphical elements
12261
+ * @typedef {import('../model').ModelType} ModelType
12262
+ * @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
12263
+ * @typedef {import('../model').ModelTypeShape} ModelTypeShape
12264
+ *
12265
+ * @typedef {import('.').ConnectionLike} ConnectionLike
12266
+ * @typedef {import('.').ElementLike} ElementLike
12267
+ * @typedef {import('.').ShapeLike} ShapeLike
12268
+ *
12269
+ * @typedef {import('./ElementRegistry').default} ElementRegistry
12270
+ * @typedef {import('./EventBus').default} EventBus
12271
+ */
12272
+
12273
+ /**
12274
+ * A factory that creates graphical elements.
12153
12275
  *
12154
12276
  * @param {EventBus} eventBus
12155
12277
  * @param {ElementRegistry} elementRegistry
@@ -12217,7 +12339,7 @@
12217
12339
  * </g>
12218
12340
  *
12219
12341
  * @param {string} type the type of the element, i.e. shape | connection
12220
- * @param {SVGElement} [childrenGfx]
12342
+ * @param {SVGElement} childrenGfx
12221
12343
  * @param {number} [parentIndex] position to create container in parent
12222
12344
  * @param {boolean} [isFrame] is frame element
12223
12345
  *
@@ -12255,11 +12377,25 @@
12255
12377
  return gfx;
12256
12378
  };
12257
12379
 
12380
+ /**
12381
+ * Create a graphical element.
12382
+ *
12383
+ * @param {ModelType} type The type of the element.
12384
+ * @param {ElementLike} element The element.
12385
+ * @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
12386
+ *
12387
+ * @return {SVGElement} The graphical element.
12388
+ */
12258
12389
  GraphicsFactory.prototype.create = function(type, element, parentIndex) {
12259
12390
  var childrenGfx = this._getChildrenContainer(element.parent);
12260
12391
  return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
12261
12392
  };
12262
12393
 
12394
+ /**
12395
+ * Update the containments of the given elements.
12396
+ *
12397
+ * @param {ElementLike[]} elements The elements.
12398
+ */
12263
12399
  GraphicsFactory.prototype.updateContainments = function(elements) {
12264
12400
 
12265
12401
  var self = this,
@@ -12295,30 +12431,63 @@
12295
12431
  });
12296
12432
  };
12297
12433
 
12434
+ /**
12435
+ * Draw a shape.
12436
+ *
12437
+ * @param {SVGElement} visual The graphical element.
12438
+ * @param {ShapeLike} element The shape.
12439
+ */
12298
12440
  GraphicsFactory.prototype.drawShape = function(visual, element) {
12299
12441
  var eventBus = this._eventBus;
12300
12442
 
12301
12443
  return eventBus.fire('render.shape', { gfx: visual, element: element });
12302
12444
  };
12303
12445
 
12446
+ /**
12447
+ * Get the path of a shape.
12448
+ *
12449
+ * @param {ShapeLike} element The shape.
12450
+ *
12451
+ * @return {string} The path of the shape.
12452
+ */
12304
12453
  GraphicsFactory.prototype.getShapePath = function(element) {
12305
12454
  var eventBus = this._eventBus;
12306
12455
 
12307
12456
  return eventBus.fire('render.getShapePath', element);
12308
12457
  };
12309
12458
 
12459
+ /**
12460
+ * Draw a connection.
12461
+ *
12462
+ * @param {SVGElement} visual The graphical element.
12463
+ * @param {ConnectionLike} element The connection.
12464
+ */
12310
12465
  GraphicsFactory.prototype.drawConnection = function(visual, element) {
12311
12466
  var eventBus = this._eventBus;
12312
12467
 
12313
12468
  return eventBus.fire('render.connection', { gfx: visual, element: element });
12314
12469
  };
12315
12470
 
12316
- GraphicsFactory.prototype.getConnectionPath = function(waypoints) {
12471
+ /**
12472
+ * Get the path of a connection.
12473
+ *
12474
+ * @param {ConnectionLike} element The connection.
12475
+ *
12476
+ * @return {string} The path of the connection.
12477
+ */
12478
+ GraphicsFactory.prototype.getConnectionPath = function(connection) {
12317
12479
  var eventBus = this._eventBus;
12318
12480
 
12319
- return eventBus.fire('render.getConnectionPath', waypoints);
12481
+ return eventBus.fire('render.getConnectionPath', connection);
12320
12482
  };
12321
12483
 
12484
+ /**
12485
+ * Update an elements graphical representation.
12486
+ *
12487
+ * @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
12488
+ * @param {ElementLike} element The element.
12489
+ * @param {SVGElement} gfx The graphical representation.
12490
+ */
12322
12491
  GraphicsFactory.prototype.update = function(type, element, gfx) {
12323
12492
 
12324
12493
  // do NOT update root element
@@ -12348,6 +12517,11 @@
12348
12517
  }
12349
12518
  };
12350
12519
 
12520
+ /**
12521
+ * Remove a graphical element.
12522
+ *
12523
+ * @param {ElementLike} element The element.
12524
+ */
12351
12525
  GraphicsFactory.prototype.remove = function(element) {
12352
12526
  var gfx = this._elementRegistry.getGraphics(element);
12353
12527
 
@@ -12381,13 +12555,17 @@
12381
12555
  };
12382
12556
 
12383
12557
  /**
12384
- * @typedef { import('didi').ModuleDeclaration } Module
12558
+ * @typedef {import('didi').InjectionContext} InjectionContext
12559
+ * @typedef {import('didi').LocalsMap} LocalsMap
12560
+ * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
12561
+ *
12562
+ * @typedef {import('./Diagram').DiagramOptions} DiagramOptions
12385
12563
  */
12386
12564
 
12387
12565
  /**
12388
12566
  * Bootstrap an injector from a list of modules, instantiating a number of default components
12389
12567
  *
12390
- * @param {Array<Module>} modules
12568
+ * @param {ModuleDeclaration[]} modules
12391
12569
  *
12392
12570
  * @return {Injector} a injector to use to access the components
12393
12571
  */
@@ -12402,7 +12580,8 @@
12402
12580
  /**
12403
12581
  * Creates an injector from passed options.
12404
12582
  *
12405
- * @param {Object} options
12583
+ * @param {DiagramOptions} [options]
12584
+ *
12406
12585
  * @return {Injector}
12407
12586
  */
12408
12587
  function createInjector(options) {
@@ -12425,8 +12604,7 @@
12425
12604
  *
12426
12605
  * To register extensions with the diagram, pass them as Array<Module> to the constructor.
12427
12606
  *
12428
- * @class djs.Diagram
12429
- * @memberOf djs
12607
+ * @class
12430
12608
  * @constructor
12431
12609
  *
12432
12610
  * @example
@@ -12464,9 +12642,9 @@
12464
12642
  *
12465
12643
  * // 'shape ... was added to the diagram' logged to console
12466
12644
  *
12467
- * @param {Object} options
12468
- * @param {Array<Module>} [options.modules] external modules to instantiate with the diagram
12469
- * @param {Injector} [injector] an (optional) injector to bootstrap the diagram with
12645
+ * @param {DiagramOptions} [options]
12646
+ * @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
12647
+ * @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
12470
12648
  */
12471
12649
  function Diagram(options, injector) {
12472
12650
 
@@ -12476,22 +12654,23 @@
12476
12654
  // API
12477
12655
 
12478
12656
  /**
12479
- * Resolves a diagram service
12657
+ * Resolves a diagram service.
12480
12658
  *
12481
12659
  * @method Diagram#get
12482
12660
  *
12483
- * @param {string} name the name of the diagram service to be retrieved
12484
- * @param {boolean} [strict=true] if false, resolve missing services to null
12661
+ * @param {string} name The name of the service to get.
12662
+ * @param {boolean} [strict=true] If false, resolve missing services to null.
12485
12663
  */
12486
12664
  this.get = injector.get;
12487
12665
 
12488
12666
  /**
12489
- * Executes a function into which diagram services are injected
12667
+ * Executes a function with its dependencies injected.
12490
12668
  *
12491
12669
  * @method Diagram#invoke
12492
12670
  *
12493
- * @param {Function|Object[]} fn the function to resolve
12494
- * @param {Object} locals a number of locals to use to resolve certain dependencies
12671
+ * @param {Function} fn The function to be executed.
12672
+ * @param {InjectionContext} [context] The context.
12673
+ * @param {LocalsMap} [locals] The locals.
12495
12674
  */
12496
12675
  this.invoke = injector.invoke;
12497
12676
 
@@ -21678,10 +21857,10 @@
21678
21857
  // default moddle extensions the viewer is composed of
21679
21858
  Viewer.prototype._moddleExtensions = {};
21680
21859
 
21681
- var KEYS_COPY = [ 'c', 'C', 'KeyC' ];
21682
- var KEYS_PASTE = [ 'v', 'V', 'KeyV' ];
21683
- var KEYS_REDO = [ 'y', 'Y', 'KeyY' ];
21684
- var KEYS_UNDO = [ 'z', 'Z', 'KeyZ' ];
21860
+ var KEYS_COPY = [ 'c', 'C' ];
21861
+ var KEYS_PASTE = [ 'v', 'V' ];
21862
+ var KEYS_REDO = [ 'y', 'Y' ];
21863
+ var KEYS_UNDO = [ 'z', 'Z' ];
21685
21864
 
21686
21865
  /**
21687
21866
  * Returns true if event was triggered with any modifier
@@ -21744,6 +21923,10 @@
21744
21923
  );
21745
21924
  }
21746
21925
 
21926
+ /**
21927
+ * @typedef {import('../../core/EventBus').default} EventBus
21928
+ */
21929
+
21747
21930
  var KEYDOWN_EVENT = 'keyboard.keydown',
21748
21931
  KEYUP_EVENT = 'keyboard.keyup';
21749
21932
 
@@ -21772,7 +21955,7 @@
21772
21955
  * A default binding for the keyboard may be specified via the
21773
21956
  * `keyboard.bindTo` configuration option.
21774
21957
  *
21775
- * @param {Config} config
21958
+ * @param {Object} config
21776
21959
  * @param {EventBus} eventBus
21777
21960
  */
21778
21961
  function Keyboard(config, eventBus) {
@@ -22103,6 +22286,11 @@
22103
22286
  keyboardBindings: [ 'type', KeyboardBindings ]
22104
22287
  };
22105
22288
 
22289
+ /**
22290
+ * @typedef {import('../../core/Canvas').default} Canvas
22291
+ * @typedef {import('../../features/keyboard/Keyboard').default} Keyboard
22292
+ */
22293
+
22106
22294
  var DEFAULT_CONFIG = {
22107
22295
  moveSpeed: 50,
22108
22296
  moveSpeedAccelerated: 200
@@ -22275,6 +22463,11 @@
22275
22463
  };
22276
22464
  }
22277
22465
 
22466
+ /**
22467
+ * @typedef {import('../../core/Canvas').default} Canvas
22468
+ * @typedef {import('../../core/EventBus').default} EventBus
22469
+ */
22470
+
22278
22471
  var THRESHOLD = 15;
22279
22472
 
22280
22473
 
@@ -22394,8 +22587,9 @@
22394
22587
  };
22395
22588
 
22396
22589
  /**
22397
- * Get the logarithm of x with base 10
22398
- * @param {Integer} value
22590
+ * Get the logarithm of x with base 10.
22591
+ *
22592
+ * @param {number} x
22399
22593
  */
22400
22594
  function log10(x) {
22401
22595
  return Math.log(x) / Math.log(10);
@@ -22422,6 +22616,11 @@
22422
22616
  return Math.max(range.min, Math.min(range.max, scale));
22423
22617
  }
22424
22618
 
22619
+ /**
22620
+ * @typedef {import('../../core/Canvas').default} Canvas
22621
+ * @typedef {import('../../core/EventBus').default} EventBus
22622
+ */
22623
+
22425
22624
  var sign = Math.sign || function(n) {
22426
22625
  return n >= 0 ? 1 : -1;
22427
22626
  };
@@ -22612,7 +22811,7 @@
22612
22811
  /**
22613
22812
  * Toggle the zoom scroll ability via mouse wheel.
22614
22813
  *
22615
- * @param {boolean} [newEnabled] new enabled state
22814
+ * @param {boolean} [newEnabled] new enabled state
22616
22815
  */
22617
22816
  ZoomScroll.prototype.toggle = function toggle(newEnabled) {
22618
22817