bpmn-js 12.1.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/dist/bpmn-modeler.development.js +5172 -2047
  2. package/dist/bpmn-modeler.production.min.js +35 -35
  3. package/dist/bpmn-navigated-viewer.development.js +1547 -589
  4. package/dist/bpmn-navigated-viewer.production.min.js +5 -5
  5. package/dist/bpmn-viewer.development.js +1525 -584
  6. package/dist/bpmn-viewer.production.min.js +5 -5
  7. package/lib/BaseModeler.d.ts +12 -5
  8. package/lib/BaseModeler.js +4 -5
  9. package/lib/BaseViewer.d.ts +160 -366
  10. package/lib/BaseViewer.js +136 -57
  11. package/lib/Modeler.d.ts +76 -15
  12. package/lib/Modeler.js +6 -4
  13. package/lib/NavigatedViewer.d.ts +8 -3
  14. package/lib/Viewer.d.ts +44 -3
  15. package/lib/core/index.d.ts +10 -0
  16. package/lib/draw/BpmnRenderUtil.d.ts +76 -0
  17. package/lib/draw/BpmnRenderUtil.js +73 -21
  18. package/lib/draw/BpmnRenderer.d.ts +124 -0
  19. package/lib/draw/BpmnRenderer.js +51 -0
  20. package/lib/draw/PathMap.d.ts +330 -0
  21. package/lib/draw/PathMap.js +9 -2
  22. package/lib/draw/TextRenderer.d.ts +74 -0
  23. package/lib/draw/TextRenderer.js +32 -11
  24. package/lib/draw/index.d.ts +10 -0
  25. package/lib/features/align-elements/AlignElementsContextPadProvider.d.ts +32 -0
  26. package/lib/features/align-elements/AlignElementsContextPadProvider.js +28 -5
  27. package/lib/features/align-elements/AlignElementsIcons.d.ts +10 -0
  28. package/lib/features/align-elements/AlignElementsMenuProvider.d.ts +32 -0
  29. package/lib/features/align-elements/AlignElementsMenuProvider.js +38 -10
  30. package/lib/features/align-elements/BpmnAlignElements.d.ts +9 -0
  31. package/lib/features/align-elements/BpmnAlignElements.js +7 -1
  32. package/lib/features/align-elements/index.d.ts +11 -0
  33. package/lib/features/auto-place/BpmnAutoPlace.d.ts +13 -0
  34. package/lib/features/auto-place/BpmnAutoPlace.js +3 -0
  35. package/lib/features/auto-place/BpmnAutoPlaceUtil.d.ts +47 -0
  36. package/lib/features/auto-place/BpmnAutoPlaceUtil.js +39 -11
  37. package/lib/features/auto-place/index.d.ts +7 -0
  38. package/lib/features/auto-resize/BpmnAutoResize.d.ts +25 -0
  39. package/lib/features/auto-resize/BpmnAutoResize.js +15 -7
  40. package/lib/features/auto-resize/BpmnAutoResizeProvider.d.ts +26 -0
  41. package/lib/features/auto-resize/BpmnAutoResizeProvider.js +16 -4
  42. package/lib/features/auto-resize/index.d.ts +8 -0
  43. package/lib/features/context-pad/ContextPadProvider.d.ts +60 -0
  44. package/lib/features/context-pad/ContextPadProvider.js +64 -9
  45. package/lib/features/context-pad/index.d.ts +7 -0
  46. package/lib/features/copy-paste/BpmnCopyPaste.d.ts +17 -0
  47. package/lib/features/copy-paste/BpmnCopyPaste.js +15 -7
  48. package/lib/features/copy-paste/ModdleCopy.d.ts +45 -0
  49. package/lib/features/copy-paste/ModdleCopy.js +17 -45
  50. package/lib/features/copy-paste/index.d.ts +9 -0
  51. package/lib/features/di-ordering/BpmnDiOrdering.d.ts +11 -0
  52. package/lib/features/di-ordering/BpmnDiOrdering.js +8 -0
  53. package/lib/features/di-ordering/index.d.ts +6 -0
  54. package/lib/features/distribute-elements/BpmnDistributeElements.d.ts +10 -0
  55. package/lib/features/distribute-elements/BpmnDistributeElements.js +9 -4
  56. package/lib/features/distribute-elements/DistributeElementsIcons.d.ts +5 -0
  57. package/lib/features/distribute-elements/DistributeElementsMenuProvider.d.ts +32 -0
  58. package/lib/features/distribute-elements/DistributeElementsMenuProvider.js +27 -4
  59. package/lib/features/distribute-elements/index.d.ts +9 -0
  60. package/lib/features/drilldown/DrilldownBreadcrumbs.d.ts +19 -0
  61. package/lib/features/drilldown/DrilldownBreadcrumbs.js +34 -24
  62. package/lib/features/drilldown/DrilldownCentering.d.ts +17 -0
  63. package/lib/features/drilldown/DrilldownCentering.js +7 -2
  64. package/lib/features/drilldown/DrilldownOverlayBehavior.d.ts +18 -0
  65. package/lib/features/drilldown/DrilldownOverlayBehavior.js +70 -40
  66. package/lib/features/drilldown/SubprocessCompatibility.d.ts +21 -0
  67. package/lib/features/drilldown/SubprocessCompatibility.js +80 -30
  68. package/lib/features/drilldown/index.d.ts +13 -0
  69. package/lib/features/editor-actions/BpmnEditorActions.d.ts +13 -0
  70. package/lib/features/editor-actions/BpmnEditorActions.js +4 -0
  71. package/lib/features/editor-actions/index.d.ts +6 -0
  72. package/lib/features/grid-snapping/BpmnGridSnapping.d.ts +9 -0
  73. package/lib/features/grid-snapping/BpmnGridSnapping.js +7 -0
  74. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.d.ts +12 -0
  75. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.js +16 -1
  76. package/lib/features/grid-snapping/behavior/GridSnappingLayoutConnectionBehavior.d.ts +27 -0
  77. package/lib/features/grid-snapping/behavior/GridSnappingLayoutConnectionBehavior.js +20 -8
  78. package/lib/features/grid-snapping/behavior/GridSnappingParticipantBehavior.d.ts +13 -0
  79. package/lib/features/grid-snapping/behavior/GridSnappingParticipantBehavior.js +11 -1
  80. package/lib/features/grid-snapping/behavior/index.d.ts +10 -0
  81. package/lib/features/grid-snapping/index.d.ts +11 -0
  82. package/lib/features/interaction-events/BpmnInteractionEvents.d.ts +18 -0
  83. package/lib/features/interaction-events/BpmnInteractionEvents.js +34 -9
  84. package/lib/features/interaction-events/index.d.ts +6 -0
  85. package/lib/features/keyboard/BpmnKeyboardBindings.d.ts +15 -0
  86. package/lib/features/keyboard/BpmnKeyboardBindings.js +5 -0
  87. package/lib/features/keyboard/index.d.ts +7 -0
  88. package/lib/features/label-editing/LabelEditingPreview.d.ts +13 -0
  89. package/lib/features/label-editing/LabelEditingPreview.js +13 -6
  90. package/lib/features/label-editing/LabelEditingProvider.d.ts +62 -0
  91. package/lib/features/label-editing/LabelEditingProvider.js +48 -11
  92. package/lib/features/label-editing/LabelUtil.d.ts +14 -0
  93. package/lib/features/label-editing/LabelUtil.js +16 -1
  94. package/lib/features/label-editing/cmd/UpdateLabelHandler.d.ts +22 -0
  95. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +14 -3
  96. package/lib/features/label-editing/index.d.ts +9 -0
  97. package/lib/features/modeling/BpmnFactory.d.ts +67 -0
  98. package/lib/features/modeling/BpmnFactory.js +57 -8
  99. package/lib/features/modeling/BpmnLayouter.d.ts +26 -0
  100. package/lib/features/modeling/BpmnLayouter.js +25 -2
  101. package/lib/features/modeling/BpmnUpdater.d.ts +92 -0
  102. package/lib/features/modeling/BpmnUpdater.js +90 -29
  103. package/lib/features/modeling/ElementFactory.d.ts +116 -0
  104. package/lib/features/modeling/ElementFactory.js +114 -17
  105. package/lib/features/modeling/ElementFactory.test.ts +133 -0
  106. package/lib/features/modeling/Modeling.d.ts +150 -0
  107. package/lib/features/modeling/Modeling.js +124 -19
  108. package/lib/features/modeling/Modeling.test.ts +148 -0
  109. package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.d.ts +20 -0
  110. package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js +16 -6
  111. package/lib/features/modeling/behavior/AppendBehavior.d.ts +6 -0
  112. package/lib/features/modeling/behavior/AppendBehavior.js +6 -5
  113. package/lib/features/modeling/behavior/AssociationBehavior.d.ts +11 -0
  114. package/lib/features/modeling/behavior/AssociationBehavior.js +9 -1
  115. package/lib/features/modeling/behavior/AttachEventBehavior.d.ts +15 -0
  116. package/lib/features/modeling/behavior/AttachEventBehavior.js +11 -3
  117. package/lib/features/modeling/behavior/BoundaryEventBehavior.d.ts +15 -0
  118. package/lib/features/modeling/behavior/BoundaryEventBehavior.js +8 -1
  119. package/lib/features/modeling/behavior/CreateBehavior.d.ts +9 -0
  120. package/lib/features/modeling/behavior/CreateBehavior.js +6 -0
  121. package/lib/features/modeling/behavior/CreateDataObjectBehavior.d.ts +15 -0
  122. package/lib/features/modeling/behavior/CreateDataObjectBehavior.js +10 -4
  123. package/lib/features/modeling/behavior/CreateParticipantBehavior.d.ts +19 -0
  124. package/lib/features/modeling/behavior/CreateParticipantBehavior.js +10 -0
  125. package/lib/features/modeling/behavior/DataInputAssociationBehavior.d.ts +21 -0
  126. package/lib/features/modeling/behavior/DataInputAssociationBehavior.js +5 -0
  127. package/lib/features/modeling/behavior/DataStoreBehavior.d.ts +19 -0
  128. package/lib/features/modeling/behavior/DataStoreBehavior.js +12 -1
  129. package/lib/features/modeling/behavior/DeleteLaneBehavior.d.ts +15 -0
  130. package/lib/features/modeling/behavior/DeleteLaneBehavior.js +9 -3
  131. package/lib/features/modeling/behavior/DetachEventBehavior.d.ts +15 -0
  132. package/lib/features/modeling/behavior/DetachEventBehavior.js +11 -3
  133. package/lib/features/modeling/behavior/DropOnFlowBehavior.d.ts +13 -0
  134. package/lib/features/modeling/behavior/DropOnFlowBehavior.js +11 -1
  135. package/lib/features/modeling/behavior/EventBasedGatewayBehavior.d.ts +11 -0
  136. package/lib/features/modeling/behavior/EventBasedGatewayBehavior.js +9 -0
  137. package/lib/features/modeling/behavior/FixHoverBehavior.d.ts +17 -0
  138. package/lib/features/modeling/behavior/FixHoverBehavior.js +6 -0
  139. package/lib/features/modeling/behavior/GroupBehavior.d.ts +26 -0
  140. package/lib/features/modeling/behavior/GroupBehavior.js +35 -13
  141. package/lib/features/modeling/behavior/ImportDockingFix.d.ts +13 -0
  142. package/lib/features/modeling/behavior/ImportDockingFix.js +3 -0
  143. package/lib/features/modeling/behavior/IsHorizontalFix.d.ts +10 -0
  144. package/lib/features/modeling/behavior/IsHorizontalFix.js +4 -0
  145. package/lib/features/modeling/behavior/LabelBehavior.d.ts +56 -0
  146. package/lib/features/modeling/behavior/LabelBehavior.js +22 -10
  147. package/lib/features/modeling/behavior/LayoutConnectionBehavior.d.ts +16 -0
  148. package/lib/features/modeling/behavior/LayoutConnectionBehavior.js +6 -2
  149. package/lib/features/modeling/behavior/MessageFlowBehavior.d.ts +15 -0
  150. package/lib/features/modeling/behavior/MessageFlowBehavior.js +8 -0
  151. package/lib/features/modeling/behavior/ModelingFeedback.d.ts +13 -0
  152. package/lib/features/modeling/behavior/ModelingFeedback.js +11 -0
  153. package/lib/features/modeling/behavior/RemoveElementBehavior.d.ts +13 -0
  154. package/lib/features/modeling/behavior/RemoveElementBehavior.js +11 -1
  155. package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.d.ts +16 -0
  156. package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.js +8 -0
  157. package/lib/features/modeling/behavior/RemoveParticipantBehavior.d.ts +15 -0
  158. package/lib/features/modeling/behavior/RemoveParticipantBehavior.js +8 -1
  159. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.d.ts +15 -0
  160. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +13 -1
  161. package/lib/features/modeling/behavior/ReplaceElementBehaviour.d.ts +23 -0
  162. package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +19 -4
  163. package/lib/features/modeling/behavior/ResizeBehavior.d.ts +57 -0
  164. package/lib/features/modeling/behavior/ResizeBehavior.js +35 -0
  165. package/lib/features/modeling/behavior/ResizeLaneBehavior.d.ts +16 -0
  166. package/lib/features/modeling/behavior/ResizeLaneBehavior.js +10 -3
  167. package/lib/features/modeling/behavior/RootElementReferenceBehavior.d.ts +25 -0
  168. package/lib/features/modeling/behavior/RootElementReferenceBehavior.js +19 -0
  169. package/lib/features/modeling/behavior/SpaceToolBehavior.d.ts +10 -0
  170. package/lib/features/modeling/behavior/SpaceToolBehavior.js +14 -4
  171. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.d.ts +28 -0
  172. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +45 -23
  173. package/lib/features/modeling/behavior/SubProcessStartEventBehavior.d.ts +15 -0
  174. package/lib/features/modeling/behavior/SubProcessStartEventBehavior.js +6 -0
  175. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.d.ts +14 -0
  176. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.js +14 -1
  177. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.d.ts +13 -0
  178. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +11 -3
  179. package/lib/features/modeling/behavior/UnclaimIdBehavior.d.ts +19 -0
  180. package/lib/features/modeling/behavior/UnclaimIdBehavior.js +7 -0
  181. package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.d.ts +16 -0
  182. package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.js +6 -3
  183. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.d.ts +17 -0
  184. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +13 -10
  185. package/lib/features/modeling/behavior/index.d.ts +2 -0
  186. package/lib/features/modeling/behavior/index.js +3 -0
  187. package/lib/features/modeling/behavior/util/CategoryUtil.d.ts +49 -0
  188. package/lib/features/modeling/behavior/util/CategoryUtil.js +10 -6
  189. package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.d.ts +19 -0
  190. package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.js +11 -5
  191. package/lib/features/modeling/behavior/util/GeometricUtil.d.ts +1 -0
  192. package/lib/features/modeling/behavior/util/LabelLayoutUtil.d.ts +32 -0
  193. package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +27 -18
  194. package/lib/features/modeling/behavior/util/LayoutUtil.d.ts +48 -0
  195. package/lib/features/modeling/behavior/util/LayoutUtil.js +35 -6
  196. package/lib/features/modeling/behavior/util/LineAttachmentUtil.d.ts +37 -0
  197. package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +17 -5
  198. package/lib/features/modeling/behavior/util/LineIntersect.d.ts +13 -0
  199. package/lib/features/modeling/behavior/util/LineIntersect.js +4 -0
  200. package/lib/features/modeling/behavior/util/ResizeUtil.d.ts +1 -0
  201. package/lib/features/modeling/cmd/AddLaneHandler.d.ts +22 -0
  202. package/lib/features/modeling/cmd/AddLaneHandler.js +8 -0
  203. package/lib/features/modeling/cmd/IdClaimHandler.d.ts +22 -0
  204. package/lib/features/modeling/cmd/IdClaimHandler.js +15 -0
  205. package/lib/features/modeling/cmd/ResizeLaneHandler.d.ts +39 -0
  206. package/lib/features/modeling/cmd/ResizeLaneHandler.js +17 -4
  207. package/lib/features/modeling/cmd/SetColorHandler.d.ts +18 -0
  208. package/lib/features/modeling/cmd/SetColorHandler.js +25 -12
  209. package/lib/features/modeling/cmd/SplitLaneHandler.d.ts +22 -0
  210. package/lib/features/modeling/cmd/SplitLaneHandler.js +9 -0
  211. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.d.ts +20 -0
  212. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +16 -1
  213. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.d.ts +21 -0
  214. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +29 -4
  215. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.d.ts +20 -0
  216. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.js +17 -3
  217. package/lib/features/modeling/cmd/UpdatePropertiesHandler.d.ts +60 -0
  218. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +38 -14
  219. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.d.ts +18 -0
  220. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +15 -0
  221. package/lib/features/modeling/index.d.ts +27 -0
  222. package/lib/features/modeling/util/LaneUtil.d.ts +46 -0
  223. package/lib/features/modeling/util/LaneUtil.js +22 -13
  224. package/lib/features/modeling/util/ModelingUtil.d.ts +12 -0
  225. package/lib/features/modeling/util/ModelingUtil.js +10 -4
  226. package/lib/features/ordering/BpmnOrderingProvider.d.ts +21 -0
  227. package/lib/features/ordering/BpmnOrderingProvider.js +9 -3
  228. package/lib/features/ordering/index.d.ts +7 -0
  229. package/lib/features/palette/PaletteProvider.d.ts +34 -0
  230. package/lib/features/palette/PaletteProvider.js +26 -2
  231. package/lib/features/palette/index.d.ts +9 -0
  232. package/lib/features/popup-menu/ReplaceMenuProvider.d.ts +50 -0
  233. package/lib/features/popup-menu/ReplaceMenuProvider.js +226 -202
  234. package/lib/features/popup-menu/index.d.ts +11 -0
  235. package/lib/features/popup-menu/util/TypeUtil.d.ts +12 -0
  236. package/lib/features/popup-menu/util/TypeUtil.js +4 -1
  237. package/lib/features/replace/BpmnReplace.d.ts +47 -0
  238. package/lib/features/replace/BpmnReplace.js +81 -29
  239. package/lib/features/replace/ReplaceOptions.d.ts +70 -0
  240. package/lib/features/replace/ReplaceOptions.js +58 -0
  241. package/lib/features/replace/index.d.ts +9 -0
  242. package/lib/features/replace-preview/BpmnReplacePreview.d.ts +17 -0
  243. package/lib/features/replace-preview/BpmnReplacePreview.js +15 -1
  244. package/lib/features/replace-preview/index.d.ts +7 -0
  245. package/lib/features/rules/BpmnRules.d.ts +171 -0
  246. package/lib/features/rules/BpmnRules.js +295 -46
  247. package/lib/features/rules/index.d.ts +7 -0
  248. package/lib/features/search/BpmnSearchProvider.d.ts +29 -0
  249. package/lib/features/search/BpmnSearchProvider.js +30 -22
  250. package/lib/features/search/index.d.ts +7 -0
  251. package/lib/features/snapping/BpmnConnectSnapping.d.ts +17 -0
  252. package/lib/features/snapping/BpmnConnectSnapping.js +51 -3
  253. package/lib/features/snapping/BpmnCreateMoveSnapping.d.ts +41 -0
  254. package/lib/features/snapping/BpmnCreateMoveSnapping.js +47 -1
  255. package/lib/features/snapping/BpmnSnappingUtil.d.ts +11 -0
  256. package/lib/features/snapping/BpmnSnappingUtil.js +12 -0
  257. package/lib/features/snapping/index.d.ts +9 -0
  258. package/lib/features/space-tool/BpmnSpaceTool.d.ts +21 -0
  259. package/lib/features/space-tool/BpmnSpaceTool.js +20 -1
  260. package/lib/features/space-tool/index.d.ts +6 -0
  261. package/lib/import/BpmnImporter.d.ts +49 -0
  262. package/lib/import/BpmnImporter.js +37 -10
  263. package/lib/import/BpmnTreeWalker.d.ts +22 -0
  264. package/lib/import/BpmnTreeWalker.js +25 -22
  265. package/lib/import/Importer.d.ts +25 -0
  266. package/lib/import/Importer.js +15 -21
  267. package/lib/import/Util.d.ts +1 -0
  268. package/lib/import/index.d.ts +6 -0
  269. package/lib/model/Types.d.ts +24 -0
  270. package/lib/model/Types.ts +40 -0
  271. package/lib/util/CompatibilityUtil.d.ts +22 -0
  272. package/lib/util/CompatibilityUtil.js +13 -0
  273. package/lib/util/DiUtil.d.ts +53 -0
  274. package/lib/util/DiUtil.js +47 -13
  275. package/lib/util/DrilldownUtil.d.ts +39 -0
  276. package/lib/util/DrilldownUtil.js +12 -8
  277. package/lib/util/LabelUtil.d.ts +73 -0
  278. package/lib/util/LabelUtil.js +40 -16
  279. package/lib/util/ModelUtil.d.ts +40 -0
  280. package/lib/util/ModelUtil.js +9 -5
  281. package/lib/util/PoweredByUtil.d.ts +8 -0
  282. package/lib/util/Types.js +5 -0
  283. package/lib/util/Types.ts +4 -0
  284. package/package.json +10 -5
  285. package/test/matchers/ConnectionMatchers.js +1 -1
  286. package/lib/icons/dist/append.svg +0 -1
  287. package/lib/icons/dist/connect-context-pad.svg +0 -1
  288. package/lib/icons/dist/connect-palette.svg +0 -1
  289. package/lib/icons/dist/create.svg +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-navigated-viewer v12.1.0
2
+ * bpmn-js - bpmn-navigated-viewer v13.0.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2023-04-04
11
+ * Date: 2023-04-19
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -21,9 +21,11 @@
21
21
  /**
22
22
  * Flatten array, one level deep.
23
23
  *
24
- * @param {Array<?>} arr
24
+ * @template T
25
25
  *
26
- * @return {Array<?>}
26
+ * @param {T[][]} arr
27
+ *
28
+ * @return {T[]}
27
29
  */
28
30
 
29
31
  const nativeToString$1 = Object.prototype.toString;
@@ -49,6 +51,11 @@
49
51
  return nativeToString$1.call(obj) === '[object Number]';
50
52
  }
51
53
 
54
+ /**
55
+ * @param {any} obj
56
+ *
57
+ * @return {boolean}
58
+ */
52
59
  function isFunction(obj) {
53
60
  const tag = nativeToString$1.call(obj);
54
61
 
@@ -77,22 +84,74 @@
77
84
  return nativeHasOwnProperty$1.call(target, key);
78
85
  }
79
86
 
87
+ /**
88
+ * @template T
89
+ * @typedef { (
90
+ * ((e: T) => boolean) |
91
+ * ((e: T, idx: number) => boolean) |
92
+ * ((e: T, key: string) => boolean) |
93
+ * string |
94
+ * number
95
+ * ) } Matcher
96
+ */
97
+
98
+ /**
99
+ * @template T
100
+ * @template U
101
+ *
102
+ * @typedef { (
103
+ * ((e: T) => U) | string | number
104
+ * ) } Extractor
105
+ */
106
+
107
+
108
+ /**
109
+ * @template T
110
+ * @typedef { (val: T, key: any) => boolean } MatchFn
111
+ */
112
+
113
+ /**
114
+ * @template T
115
+ * @typedef { T[] } ArrayCollection
116
+ */
117
+
118
+ /**
119
+ * @template T
120
+ * @typedef { { [key: string]: T } } StringKeyValueCollection
121
+ */
122
+
123
+ /**
124
+ * @template T
125
+ * @typedef { { [key: number]: T } } NumberKeyValueCollection
126
+ */
127
+
128
+ /**
129
+ * @template T
130
+ * @typedef { StringKeyValueCollection<T> | NumberKeyValueCollection<T> } KeyValueCollection
131
+ */
132
+
133
+ /**
134
+ * @template T
135
+ * @typedef { KeyValueCollection<T> | ArrayCollection<T> } Collection
136
+ */
137
+
80
138
  /**
81
139
  * Find element in collection.
82
140
  *
83
- * @param {Array|Object} collection
84
- * @param {Function|Object} matcher
141
+ * @template T
142
+ * @param {Collection<T>} collection
143
+ * @param {Matcher<T>} matcher
85
144
  *
86
145
  * @return {Object}
87
146
  */
88
147
  function find(collection, matcher) {
89
148
 
90
- matcher = toMatcher(matcher);
149
+ const matchFn = toMatcher(matcher);
91
150
 
92
151
  let match;
93
152
 
94
153
  forEach$1(collection, function(val, key) {
95
- if (matcher(val, key)) {
154
+ if (matchFn(val, key)) {
96
155
  match = val;
97
156
 
98
157
  return false;
@@ -107,19 +166,20 @@
107
166
  /**
108
167
  * Find element index in collection.
109
168
  *
110
- * @param {Array|Object} collection
111
- * @param {Function} matcher
169
+ * @template T
170
+ * @param {Collection<T>} collection
171
+ * @param {Matcher<T>} matcher
112
172
  *
113
- * @return {Object}
173
+ * @return {number}
114
174
  */
115
175
  function findIndex(collection, matcher) {
116
176
 
117
- matcher = toMatcher(matcher);
177
+ const matchFn = toMatcher(matcher);
118
178
 
119
179
  let idx = isArray$2(collection) ? -1 : undefined;
120
180
 
121
181
  forEach$1(collection, function(val, key) {
122
- if (matcher(val, key)) {
182
+ if (matchFn(val, key)) {
123
183
  idx = key;
124
184
 
125
185
  return false;
@@ -131,19 +191,22 @@
131
191
 
132
192
 
133
193
  /**
134
- * Find element in collection.
194
+ * Filter elements in collection.
135
195
  *
136
- * @param {Array|Object} collection
137
- * @param {Function} matcher
196
+ * @template T
197
+ * @param {Collection<T>} collection
198
+ * @param {Matcher<T>} matcher
138
199
  *
139
- * @return {Array} result
200
+ * @return {T[]} result
140
201
  */
141
202
  function filter(collection, matcher) {
142
203
 
204
+ const matchFn = toMatcher(matcher);
205
+
143
206
  let result = [];
144
207
 
145
208
  forEach$1(collection, function(val, key) {
146
- if (matcher(val, key)) {
209
+ if (matchFn(val, key)) {
147
210
  result.push(val);
148
211
  }
149
212
  });
@@ -156,10 +219,11 @@
156
219
  * Iterate over collection; returning something
157
220
  * (non-undefined) will stop iteration.
158
221
  *
159
- * @param {Array|Object} collection
160
- * @param {Function} iterator
222
+ * @template T
223
+ * @param {Collection<T>} collection
224
+ * @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator
161
225
  *
162
- * @return {Object} return result that stopped the iteration
226
+ * @return {T} return result that stopped the iteration
163
227
  */
164
228
  function forEach$1(collection, iterator) {
165
229
 
@@ -190,11 +254,14 @@
190
254
  /**
191
255
  * Reduce collection, returning a single result.
192
256
  *
193
- * @param {Object|Array} collection
194
- * @param {Function} iterator
195
- * @param {Any} result
257
+ * @template T
258
+ * @template V
259
+ *
260
+ * @param {Collection<T>} collection
261
+ * @param {(result: V, entry: T, index: any) => V} iterator
262
+ * @param {V} result
196
263
  *
197
- * @return {Any} result returned from last iterator
264
+ * @return {V} result returned from last iterator
198
265
  */
199
266
  function reduce(collection, iterator, result) {
200
267
 
@@ -264,13 +331,17 @@
264
331
  *
265
332
  * @example
266
333
  *
334
+ * ```javascript
267
335
  * const matcher = matchPattern({ id: 1 });
268
336
  *
269
337
  * let element = find(elements, matcher);
338
+ * ```
270
339
  *
271
- * @param {Object} pattern
340
+ * @template T
341
+ *
342
+ * @param {T} pattern
272
343
  *
273
- * @return {Function} matcherFn
344
+ * @return { (el: any) => boolean } matcherFn
274
345
  */
275
346
  function matchPattern(pattern) {
276
347
 
@@ -284,6 +355,12 @@
284
355
  }
285
356
 
286
357
 
358
+ /**
359
+ * @template T
360
+ * @param {Matcher<T>} matcher
361
+ *
362
+ * @return {MatchFn<T>}
363
+ */
287
364
  function toMatcher(matcher) {
288
365
  return isFunction(matcher) ? matcher : (e) => {
289
366
  return e === matcher;
@@ -299,6 +376,16 @@
299
376
  return Number(arg);
300
377
  }
301
378
 
379
+ /* global setTimeout clearTimeout */
380
+
381
+ /**
382
+ * @typedef { {
383
+ * (...args: any[]): any;
384
+ * flush: () => void;
385
+ * cancel: () => void;
386
+ * } } DebouncedFunction
387
+ */
388
+
302
389
  /**
303
390
  * Debounce fn, calling it only once if the given time
304
391
  * elapsed between calls.
@@ -309,7 +396,7 @@
309
396
  * @param {Function} fn
310
397
  * @param {Number} timeout
311
398
  *
312
- * @return {Function} debounced function
399
+ * @return {DebouncedFunction} debounced function
313
400
  */
314
401
  function debounce(fn, timeout) {
315
402
 
@@ -355,6 +442,9 @@
355
442
  clear();
356
443
  }
357
444
 
445
+ /**
446
+ * @type { DebouncedFunction }
447
+ */
358
448
  function callback(...args) {
359
449
  lastNow = Date.now();
360
450
 
@@ -398,12 +488,15 @@
398
488
  }
399
489
 
400
490
  /**
401
- * Pick given properties from the target object.
491
+ * Pick properties from the given target.
402
492
  *
403
- * @param {Object} target
404
- * @param {Array} properties
493
+ * @template T
494
+ * @template {any[]} V
405
495
  *
406
- * @return {Object} target
496
+ * @param {T} target
497
+ * @param {V} properties
498
+ *
499
+ * @return Pick<T, V>
407
500
  */
408
501
  function pick(target, properties) {
409
502
 
@@ -424,10 +517,13 @@
424
517
  /**
425
518
  * Pick all target properties, excluding the given ones.
426
519
  *
427
- * @param {Object} target
428
- * @param {Array} properties
520
+ * @template T
521
+ * @template {any[]} V
522
+ *
523
+ * @param {T} target
524
+ * @param {V} properties
429
525
  *
430
- * @return {Object} target
526
+ * @return {Omit<T, V>} target
431
527
  */
432
528
  function omit(target, properties) {
433
529
 
@@ -448,9 +544,9 @@
448
544
  var DEFAULT_RENDER_PRIORITY$1 = 1000;
449
545
 
450
546
  /**
451
- * @typedef {import('../model').Base} Base
452
- * @typedef {import('../model').Connection} Connection
453
- * @typedef {import('../model').Shape} Shape
547
+ * @typedef {import('../core/Types').ElementLike} Element
548
+ * @typedef {import('../core/Types').ConnectionLike} Connection
549
+ * @typedef {import('../core/Types').ShapeLike} Shape
454
550
  *
455
551
  * @typedef {import('../core/EventBus').default} EventBus
456
552
  */
@@ -495,9 +591,9 @@
495
591
  /**
496
592
  * Checks whether an element can be rendered.
497
593
  *
498
- * @param {Base} element The element to be rendered.
594
+ * @param {Element} element The element to be rendered.
499
595
  *
500
- * @returns {boolean} Whether the element can be rendered.
596
+ * @return {boolean} Whether the element can be rendered.
501
597
  */
502
598
  BaseRenderer.prototype.canRender = function(element) {};
503
599
 
@@ -507,7 +603,7 @@
507
603
  * @param {SVGElement} visuals The SVG element to draw the shape into.
508
604
  * @param {Shape} shape The shape to be drawn.
509
605
  *
510
- * @returns {SVGElement} The SVG element of the shape drawn.
606
+ * @return {SVGElement} The SVG element of the shape drawn.
511
607
  */
512
608
  BaseRenderer.prototype.drawShape = function(visuals, shape) {};
513
609
 
@@ -517,7 +613,7 @@
517
613
  * @param {SVGElement} visuals The SVG element to draw the connection into.
518
614
  * @param {Connection} connection The connection to be drawn.
519
615
  *
520
- * @returns {SVGElement} The SVG element of the connection drawn.
616
+ * @return {SVGElement} The SVG element of the connection drawn.
521
617
  */
522
618
  BaseRenderer.prototype.drawConnection = function(visuals, connection) {};
523
619
 
@@ -539,10 +635,15 @@
539
635
  */
540
636
  BaseRenderer.prototype.getConnectionPath = function(connection) {};
541
637
 
638
+ /**
639
+ * @typedef { import('../model/Types').Element } Element
640
+ * @typedef { import('../model/Types').ModdleElement } ModdleElement
641
+ */
642
+
542
643
  /**
543
644
  * Is an element of the given BPMN type?
544
645
  *
545
- * @param {djs.model.Base|ModdleElement} element
646
+ * @param {Element|ModdleElement} element
546
647
  * @param {string} type
547
648
  *
548
649
  * @return {boolean}
@@ -557,8 +658,8 @@
557
658
  /**
558
659
  * Return true if element has any of the given types.
559
660
  *
560
- * @param {djs.model.Base} element
561
- * @param {Array<string>} types
661
+ * @param {Element|ModdleElement} element
662
+ * @param {string[]} types
562
663
  *
563
664
  * @return {boolean}
564
665
  */
@@ -571,7 +672,7 @@
571
672
  /**
572
673
  * Return the business object for a given element.
573
674
  *
574
- * @param {djs.model.Base|ModdleElement} element
675
+ * @param {Element|ModdleElement} element
575
676
  *
576
677
  * @return {ModdleElement}
577
678
  */
@@ -582,7 +683,7 @@
582
683
  /**
583
684
  * Return the di object for a given element.
584
685
  *
585
- * @param {djs.model.Base} element
686
+ * @param {Element} element
586
687
  *
587
688
  * @return {ModdleElement}
588
689
  */
@@ -590,6 +691,17 @@
590
691
  return element && element.di;
591
692
  }
592
693
 
694
+ /**
695
+ * @typedef {import('../model/Types').Element} Element
696
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
697
+ */
698
+
699
+ /**
700
+ * @param {Element} element
701
+ * @param {ModdleElement} di
702
+ *
703
+ * @return {boolean}
704
+ */
593
705
  function isExpanded(element, di) {
594
706
 
595
707
  if (is$1(element, 'bpmn:CallActivity')) {
@@ -613,10 +725,19 @@
613
725
  return true;
614
726
  }
615
727
 
728
+ /**
729
+ * @param {Element} element
730
+ *
731
+ * @return {boolean}
732
+ */
616
733
  function isEventSubProcess(element) {
617
734
  return element && !!getBusinessObject(element).triggeredByEvent;
618
735
  }
619
736
 
737
+ /**
738
+ * @typedef { import('../../model').DiagramElement } DiagramElement
739
+ */
740
+
620
741
  function getLabelAttr(semantic) {
621
742
  if (
622
743
  is$1(semantic, 'bpmn:FlowElement') ||
@@ -650,6 +771,11 @@
650
771
  return categoryValueRef.value || '';
651
772
  }
652
773
 
774
+ /**
775
+ * @param {DiagramElement} element
776
+ *
777
+ * @return {string} label
778
+ */
653
779
  function getLabel(element) {
654
780
  var semantic = element.businessObject,
655
781
  attr = getLabelAttr(semantic);
@@ -1358,14 +1484,31 @@
1358
1484
  return elements.flat().join(',').replace(/,?([A-z]),?/g, '$1');
1359
1485
  }
1360
1486
 
1487
+ /**
1488
+ * @param {Point} point
1489
+ *
1490
+ * @return {Component[]}
1491
+ */
1361
1492
  function move(point) {
1362
1493
  return [ 'M', point.x, point.y ];
1363
1494
  }
1364
1495
 
1496
+ /**
1497
+ * @param {Point} point
1498
+ *
1499
+ * @return {Component[]}
1500
+ */
1365
1501
  function lineTo(point) {
1366
1502
  return [ 'L', point.x, point.y ];
1367
1503
  }
1368
1504
 
1505
+ /**
1506
+ * @param {Point} p1
1507
+ * @param {Point} p2
1508
+ * @param {Point} p3
1509
+ *
1510
+ * @return {Component[]}
1511
+ */
1369
1512
  function curveTo(p1, p2, p3) {
1370
1513
  return [ 'C', p1.x, p1.y, p2.x, p2.y, p3.x, p3.y ];
1371
1514
  }
@@ -1433,7 +1576,7 @@
1433
1576
 
1434
1577
  /**
1435
1578
  * @param {Point[]} points
1436
- * @param {*} [attrs]
1579
+ * @param {any} [attrs]
1437
1580
  * @param {number} [radius]
1438
1581
  *
1439
1582
  * @return {SVGElement}
@@ -1482,54 +1625,75 @@
1482
1625
  /**
1483
1626
  * Checks if eventDefinition of the given element matches with semantic type.
1484
1627
  *
1485
- * @return {boolean} true if element is of the given semantic type
1628
+ * @param {ModdleElement} event
1629
+ * @param {string} eventDefinitionType
1630
+ *
1631
+ * @return {boolean}
1486
1632
  */
1487
- function isTypedEvent(event, eventDefinitionType, filter) {
1488
-
1489
- function matches(definition, filter) {
1490
- return every(filter, function(val, key) {
1491
-
1492
- // we want a == conversion here, to be able to catch
1493
- // undefined == false and friends
1494
- /* jshint -W116 */
1495
- return definition[key] == val;
1496
- });
1497
- }
1498
-
1633
+ function isTypedEvent(event, eventDefinitionType) {
1499
1634
  return some(event.eventDefinitions, function(definition) {
1500
- return definition.$type === eventDefinitionType && matches(event, filter);
1635
+ return definition.$type === eventDefinitionType;
1501
1636
  });
1502
1637
  }
1503
1638
 
1639
+ /**
1640
+ * Check if element is a throw event.
1641
+ *
1642
+ * @param {ModdleElement} event
1643
+ *
1644
+ * @return {boolean}
1645
+ */
1504
1646
  function isThrowEvent(event) {
1505
1647
  return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
1506
1648
  }
1507
1649
 
1650
+ /**
1651
+ * Check if element is a throw event.
1652
+ *
1653
+ * @param {ModdleElement} element
1654
+ *
1655
+ * @return {boolean}
1656
+ */
1508
1657
  function isCollection(element) {
1509
1658
  var dataObject = element.dataObjectRef;
1510
1659
 
1511
1660
  return element.isCollection || (dataObject && dataObject.isCollection);
1512
1661
  }
1513
1662
 
1514
- function getSemantic(element) {
1515
- return element.businessObject;
1516
- }
1517
-
1518
1663
 
1519
1664
  // color access //////////////////////
1520
1665
 
1666
+ /**
1667
+ * @param {DiagramElement} element
1668
+ * @param {string} defaultColor
1669
+ *
1670
+ * @return {string}
1671
+ */
1521
1672
  function getFillColor(element, defaultColor) {
1522
1673
  var di = getDi(element);
1523
1674
 
1524
1675
  return di.get('color:background-color') || di.get('bioc:fill') || defaultColor || 'white';
1525
1676
  }
1526
1677
 
1678
+ /**
1679
+ * @param {DiagramElement} element
1680
+ * @param {string} defaultColor
1681
+ *
1682
+ * @return {string}
1683
+ */
1527
1684
  function getStrokeColor(element, defaultColor) {
1528
1685
  var di = getDi(element);
1529
1686
 
1530
1687
  return di.get('color:border-color') || di.get('bioc:stroke') || defaultColor || black;
1531
1688
  }
1532
1689
 
1690
+ /**
1691
+ * @param {DiagramElement} element
1692
+ * @param {string} defaultColor
1693
+ * @param {string} defaultStrokeColor
1694
+ *
1695
+ * @return {string}
1696
+ */
1533
1697
  function getLabelColor(element, defaultColor, defaultStrokeColor) {
1534
1698
  var di = getDi(element),
1535
1699
  label = di.get('label');
@@ -1540,6 +1704,11 @@
1540
1704
 
1541
1705
  // cropping path customizations //////////////////////
1542
1706
 
1707
+ /**
1708
+ * @param {ShapeLike} shape
1709
+ *
1710
+ * @return {string} path
1711
+ */
1543
1712
  function getCirclePath(shape) {
1544
1713
 
1545
1714
  var cx = shape.x + shape.width / 2,
@@ -1557,6 +1726,11 @@
1557
1726
  return componentsToPath(circlePath);
1558
1727
  }
1559
1728
 
1729
+ /**
1730
+ * @param {ShapeLike} shape
1731
+ *
1732
+ * @return {string} path
1733
+ */
1560
1734
  function getRoundRectPath(shape, borderRadius) {
1561
1735
 
1562
1736
  var x = shape.x,
@@ -1580,6 +1754,11 @@
1580
1754
  return componentsToPath(roundRectPath);
1581
1755
  }
1582
1756
 
1757
+ /**
1758
+ * @param {ShapeLike} shape
1759
+ *
1760
+ * @return {string} path
1761
+ */
1583
1762
  function getDiamondPath(shape) {
1584
1763
 
1585
1764
  var width = shape.width,
@@ -1600,6 +1779,11 @@
1600
1779
  return componentsToPath(diamondPath);
1601
1780
  }
1602
1781
 
1782
+ /**
1783
+ * @param {ShapeLike} shape
1784
+ *
1785
+ * @return {string} path
1786
+ */
1603
1787
  function getRectPath(shape) {
1604
1788
  var x = shape.x,
1605
1789
  y = shape.y,
@@ -1943,9 +2127,13 @@
1943
2127
 
1944
2128
  var componentEvent = {};
1945
2129
 
1946
- var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent',
1947
- unbind$1 = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
1948
- prefix$6 = bind$1 !== 'addEventListener' ? 'on' : '';
2130
+ var bind$1, unbind$1, prefix$6;
2131
+
2132
+ function detect () {
2133
+ bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent';
2134
+ unbind$1 = window.removeEventListener ? 'removeEventListener' : 'detachEvent';
2135
+ prefix$6 = bind$1 !== 'addEventListener' ? 'on' : '';
2136
+ }
1949
2137
 
1950
2138
  /**
1951
2139
  * Bind `el` event `type` to `fn`.
@@ -1959,6 +2147,7 @@
1959
2147
  */
1960
2148
 
1961
2149
  var bind_1 = componentEvent.bind = function(el, type, fn, capture){
2150
+ if (!bind$1) detect();
1962
2151
  el[bind$1](prefix$6 + type, fn, capture || false);
1963
2152
  return fn;
1964
2153
  };
@@ -1975,6 +2164,7 @@
1975
2164
  */
1976
2165
 
1977
2166
  var unbind_1 = componentEvent.unbind = function(el, type, fn, capture){
2167
+ if (!unbind$1) detect();
1978
2168
  el[unbind$1](prefix$6 + type, fn, capture || false);
1979
2169
  return fn;
1980
2170
  };
@@ -2175,7 +2365,7 @@
2175
2365
  }
2176
2366
 
2177
2367
  /**
2178
- * @param {SVGElement} element
2368
+ * @param {SVGElement} gfx
2179
2369
  * @param {number} x
2180
2370
  * @param {number} y
2181
2371
  * @param {number} angle
@@ -2196,7 +2386,7 @@
2196
2386
 
2197
2387
 
2198
2388
  /**
2199
- * @param {SVGElement} element
2389
+ * @param {SVGElement} gfx
2200
2390
  * @param {number} x
2201
2391
  * @param {number} y
2202
2392
  */
@@ -2209,7 +2399,7 @@
2209
2399
 
2210
2400
 
2211
2401
  /**
2212
- * @param {SVGElement} element
2402
+ * @param {SVGElement} gfx
2213
2403
  * @param {number} angle
2214
2404
  */
2215
2405
  function rotate(gfx, angle) {
@@ -2392,6 +2582,29 @@
2392
2582
 
2393
2583
  var ELEMENT_LABEL_DISTANCE = 10;
2394
2584
 
2585
+ /**
2586
+ * @typedef { Partial<{
2587
+ * defaultFillColor: string,
2588
+ * defaultStrokeColor: string,
2589
+ * defaultLabelColor: string
2590
+ * }> } BpmnRendererConfig
2591
+ */
2592
+
2593
+ /**
2594
+ * @typedef { import('../model').DiagramElement } DiagramElement
2595
+ */
2596
+
2597
+ /**
2598
+ * A renderer for BPMN elements
2599
+ *
2600
+ * @param {BpmnRendererConfig} config
2601
+ * @param {import('diagram-js/lib/core/EventBus').default} eventBus
2602
+ * @param {import('diagram-js/lib/draw/Styles').default} styles
2603
+ * @param {import('./PathMap').default} pathMap
2604
+ * @param {import('diagram-js/lib/core/Canvas').default} canvas
2605
+ * @param {import('./TextRenderer').default} textRenderer
2606
+ * @param {number} [priority]
2607
+ */
2395
2608
  function BpmnRenderer(
2396
2609
  config, eventBus, styles, pathMap,
2397
2610
  canvas, textRenderer, priority) {
@@ -2751,7 +2964,7 @@
2751
2964
 
2752
2965
  function renderEventContent(element, parentGfx) {
2753
2966
 
2754
- var event = getSemantic(element);
2967
+ var event = getBusinessObject(element);
2755
2968
  var isThrowing = isThrowEvent(event);
2756
2969
 
2757
2970
  if (event.eventDefinitions && event.eventDefinitions.length > 1) {
@@ -2824,7 +3037,7 @@
2824
3037
  }
2825
3038
 
2826
3039
  function renderEmbeddedLabel(parentGfx, element, align) {
2827
- var semantic = getSemantic(element);
3040
+ var semantic = getBusinessObject(element);
2828
3041
 
2829
3042
  return renderLabel(parentGfx, semantic.name, {
2830
3043
  box: element,
@@ -2890,7 +3103,7 @@
2890
3103
  stroke: getStrokeColor(element, defaultStrokeColor)
2891
3104
  };
2892
3105
 
2893
- var semantic = getSemantic(element);
3106
+ var semantic = getBusinessObject(element);
2894
3107
 
2895
3108
  if (!semantic.isInterrupting) {
2896
3109
  attrs = {
@@ -3351,7 +3564,7 @@
3351
3564
  return task;
3352
3565
  },
3353
3566
  'bpmn:ReceiveTask' : function(parentGfx, element) {
3354
- var semantic = getSemantic(element);
3567
+ var semantic = getBusinessObject(element);
3355
3568
 
3356
3569
  var task = renderer('bpmn:Task')(parentGfx, element);
3357
3570
  var pathData;
@@ -3507,12 +3720,12 @@
3507
3720
  stroke: getStrokeColor(element, defaultStrokeColor),
3508
3721
  strokeWidth
3509
3722
  });
3510
- var text = getSemantic(element).name;
3723
+ var text = getBusinessObject(element).name;
3511
3724
  renderLaneLabel(parentGfx, text, element);
3512
3725
  } else {
3513
3726
 
3514
3727
  // collapsed pool draw text inline
3515
- var text2 = getSemantic(element).name;
3728
+ var text2 = getBusinessObject(element).name;
3516
3729
  renderLabel(parentGfx, text2, {
3517
3730
  box: element, align: 'center-middle',
3518
3731
  style: {
@@ -3521,7 +3734,7 @@
3521
3734
  });
3522
3735
  }
3523
3736
 
3524
- var participantMultiplicity = !!(getSemantic(element).participantMultiplicity);
3737
+ var participantMultiplicity = !!(getBusinessObject(element).participantMultiplicity);
3525
3738
 
3526
3739
  if (participantMultiplicity) {
3527
3740
  renderer('ParticipantMultiplicityMarker')(parentGfx, element);
@@ -3538,7 +3751,7 @@
3538
3751
  ...attrs
3539
3752
  });
3540
3753
 
3541
- var semantic = getSemantic(element);
3754
+ var semantic = getBusinessObject(element);
3542
3755
 
3543
3756
  if (semantic.$type === 'bpmn:Lane') {
3544
3757
  var text = semantic.name;
@@ -3629,7 +3842,7 @@
3629
3842
  },
3630
3843
  'bpmn:EventBasedGateway': function(parentGfx, element) {
3631
3844
 
3632
- var semantic = getSemantic(element);
3845
+ var semantic = getBusinessObject(element);
3633
3846
 
3634
3847
  var diamond = renderer('bpmn:Gateway')(parentGfx, element);
3635
3848
 
@@ -3711,7 +3924,7 @@
3711
3924
  stroke: getStrokeColor(element, defaultStrokeColor)
3712
3925
  });
3713
3926
 
3714
- var sequenceFlow = getSemantic(element);
3927
+ var sequenceFlow = getBusinessObject(element);
3715
3928
 
3716
3929
  var source;
3717
3930
 
@@ -3738,7 +3951,7 @@
3738
3951
  },
3739
3952
  'bpmn:Association': function(parentGfx, element, attrs) {
3740
3953
 
3741
- var semantic = getSemantic(element);
3954
+ var semantic = getBusinessObject(element);
3742
3955
 
3743
3956
  var fill = getFillColor(element, defaultFillColor),
3744
3957
  stroke = getStrokeColor(element, defaultStrokeColor);
@@ -3778,7 +3991,7 @@
3778
3991
  },
3779
3992
  'bpmn:MessageFlow': function(parentGfx, element) {
3780
3993
 
3781
- var semantic = getSemantic(element),
3994
+ var semantic = getBusinessObject(element),
3782
3995
  di = getDi(element);
3783
3996
 
3784
3997
  var fill = getFillColor(element, defaultFillColor),
@@ -3853,7 +4066,7 @@
3853
4066
  stroke: getStrokeColor(element, defaultStrokeColor)
3854
4067
  });
3855
4068
 
3856
- var semantic = getSemantic(element);
4069
+ var semantic = getBusinessObject(element);
3857
4070
 
3858
4071
  if (isCollection(semantic)) {
3859
4072
  renderDataItemCollection(parentGfx, element);
@@ -3909,7 +4122,7 @@
3909
4122
  },
3910
4123
  'bpmn:BoundaryEvent': function(parentGfx, element) {
3911
4124
 
3912
- var semantic = getSemantic(element),
4125
+ var semantic = getBusinessObject(element),
3913
4126
  cancel = semantic.cancelActivity;
3914
4127
 
3915
4128
  var attrs = {
@@ -3975,7 +4188,7 @@
3975
4188
  stroke: getStrokeColor(element, defaultStrokeColor)
3976
4189
  });
3977
4190
 
3978
- var text = getSemantic(element).text || '';
4191
+ var text = getBusinessObject(element).text || '';
3979
4192
  renderLabel(parentGfx, text, {
3980
4193
  box: element,
3981
4194
  align: 'left-top',
@@ -4124,7 +4337,7 @@
4124
4337
  };
4125
4338
 
4126
4339
  function attachTaskMarkers(parentGfx, element, taskMarkers) {
4127
- var obj = getSemantic(element);
4340
+ var obj = getBusinessObject(element);
4128
4341
 
4129
4342
  var subprocess = taskMarkers && taskMarkers.indexOf('SubProcessMarker') !== -1;
4130
4343
  var position;
@@ -4218,10 +4431,23 @@
4218
4431
  ];
4219
4432
 
4220
4433
 
4434
+ /**
4435
+ * @param {DiagramElement} element
4436
+ *
4437
+ * @return {boolean}
4438
+ */
4221
4439
  BpmnRenderer.prototype.canRender = function(element) {
4222
4440
  return is$1(element, 'bpmn:BaseElement');
4223
4441
  };
4224
4442
 
4443
+ /**
4444
+ * Draw shape into parentGfx.
4445
+ *
4446
+ * @param {SVGElement} parentGfx
4447
+ * @param {DiagramElement} element
4448
+ *
4449
+ * @return {SVGElement} mainGfx
4450
+ */
4225
4451
  BpmnRenderer.prototype.drawShape = function(parentGfx, element) {
4226
4452
  var type = element.type;
4227
4453
  var h = this._renderer(type);
@@ -4230,6 +4456,14 @@
4230
4456
  return h(parentGfx, element);
4231
4457
  };
4232
4458
 
4459
+ /**
4460
+ * Draw connection into parentGfx.
4461
+ *
4462
+ * @param {SVGElement} parentGfx
4463
+ * @param {DiagramElement} element
4464
+ *
4465
+ * @return {SVGElement} mainGfx
4466
+ */
4233
4467
  BpmnRenderer.prototype.drawConnection = function(parentGfx, element) {
4234
4468
  var type = element.type;
4235
4469
  var h = this._renderer(type);
@@ -4238,6 +4472,13 @@
4238
4472
  return h(parentGfx, element);
4239
4473
  };
4240
4474
 
4475
+ /**
4476
+ * Get shape path.
4477
+ *
4478
+ * @param {DiagramElement} element
4479
+ *
4480
+ * @return {string} path
4481
+ */
4241
4482
  BpmnRenderer.prototype.getShapePath = function(element) {
4242
4483
 
4243
4484
  if (is$1(element, 'bpmn:Event')) {
@@ -4257,6 +4498,41 @@
4257
4498
 
4258
4499
  /**
4259
4500
  * @typedef {import('../util/Types').Dimensions} Dimensions
4501
+ *
4502
+ * @typedef { {
4503
+ * top: number;
4504
+ * left: number;
4505
+ * right: number;
4506
+ * bottom: number;
4507
+ * } } Padding
4508
+ *
4509
+ * @typedef { number | Partial<Padding> } PaddingConfig
4510
+ *
4511
+ * @typedef { {
4512
+ * horizontal: 'center' | 'left';
4513
+ * vertical: 'top' | 'center';
4514
+ * } } Alignment
4515
+ *
4516
+ * @typedef { 'center-middle' | 'center-top' } AlignmentConfig
4517
+ *
4518
+ * @typedef { Partial<{
4519
+ * align: AlignmentConfig;
4520
+ * style: Record<string, any>;
4521
+ * padding: PaddingConfig;
4522
+ * }> } BaseTextConfig
4523
+ *
4524
+ * @typedef { BaseTextConfig & Partial<{
4525
+ * size: Dimensions;
4526
+ * }> } TextConfig
4527
+ *
4528
+ * @typedef { BaseTextConfig & Partial<{
4529
+ * box: Dimensions;
4530
+ * fitBox: boolean;
4531
+ * }> } TextLayoutConfig
4532
+ *
4533
+ * @typedef { Dimensions & {
4534
+ * text: string;
4535
+ * } } LineDescriptor
4260
4536
  */
4261
4537
 
4262
4538
  var DEFAULT_BOX_PADDING = 0;
@@ -4267,6 +4543,10 @@
4267
4543
  };
4268
4544
 
4269
4545
 
4546
+ /**
4547
+ * @param {AlignmentConfig} align
4548
+ * @return {Alignment}
4549
+ */
4270
4550
  function parseAlign(align) {
4271
4551
 
4272
4552
  var parts = align.split('-');
@@ -4277,6 +4557,11 @@
4277
4557
  };
4278
4558
  }
4279
4559
 
4560
+ /**
4561
+ * @param {PaddingConfig} padding
4562
+ *
4563
+ * @return {Padding}
4564
+ */
4280
4565
  function parsePadding(padding) {
4281
4566
 
4282
4567
  if (isObject(padding)) {
@@ -4291,6 +4576,12 @@
4291
4576
  }
4292
4577
  }
4293
4578
 
4579
+ /**
4580
+ * @param {string} text
4581
+ * @param {SVGTextElement} fakeText
4582
+ *
4583
+ * @return {import('../util/Types').Dimensions}
4584
+ */
4294
4585
  function getTextBBox(text, fakeText) {
4295
4586
 
4296
4587
  fakeText.textContent = text;
@@ -4334,7 +4625,7 @@
4334
4625
  *
4335
4626
  * @param {string[]} lines
4336
4627
  *
4337
- * @return {Object} the line descriptor, an object { width, height, text }
4628
+ * @return {LineDescriptor} the line descriptor
4338
4629
  */
4339
4630
  function layoutNext(lines, maxWidth, fakeText) {
4340
4631
 
@@ -4357,6 +4648,14 @@
4357
4648
  }
4358
4649
  }
4359
4650
 
4651
+ /**
4652
+ * @param {string[]} lines
4653
+ * @param {string} fitLine
4654
+ * @param {string} originalLine
4655
+ * @param {Dimensions} textBBox
4656
+ *
4657
+ * @return {LineDescriptor}
4658
+ */
4360
4659
  function fit(lines, fitLine, originalLine, textBBox) {
4361
4660
  if (fitLine.length < originalLine.length) {
4362
4661
  var remainder = originalLine.slice(fitLine.length).trim();
@@ -4420,6 +4719,13 @@
4420
4719
  }
4421
4720
 
4422
4721
 
4722
+ /**
4723
+ * @param {string} line
4724
+ * @param {number} width
4725
+ * @param {number} maxWidth
4726
+ *
4727
+ * @return {string}
4728
+ */
4423
4729
  function shortenLine(line, width, maxWidth) {
4424
4730
  var length = Math.max(line.length * (maxWidth / width), 1);
4425
4731
 
@@ -4436,6 +4742,9 @@
4436
4742
  }
4437
4743
 
4438
4744
 
4745
+ /**
4746
+ * @return {SVGSVGElement}
4747
+ */
4439
4748
  function getHelperSvg() {
4440
4749
  var helperSvg = document.getElementById('helper-svg');
4441
4750
 
@@ -4463,11 +4772,7 @@
4463
4772
  /**
4464
4773
  * Creates a new label utility
4465
4774
  *
4466
- * @param {Object} config
4467
- * @param {Dimensions} config.size
4468
- * @param {number} config.padding
4469
- * @param {Object} config.style
4470
- * @param {string} config.align
4775
+ * @param {TextConfig} config
4471
4776
  */
4472
4777
  function Text(config) {
4473
4778
 
@@ -4483,7 +4788,7 @@
4483
4788
  * Returns the layouted text as an SVG element.
4484
4789
  *
4485
4790
  * @param {string} text
4486
- * @param {Object} options
4791
+ * @param {TextLayoutConfig} options
4487
4792
  *
4488
4793
  * @return {SVGElement}
4489
4794
  */
@@ -4495,7 +4800,7 @@
4495
4800
  * Returns a labels layouted dimensions.
4496
4801
  *
4497
4802
  * @param {string} text to layout
4498
- * @param {Object} options
4803
+ * @param {TextLayoutConfig} options
4499
4804
  *
4500
4805
  * @return {Dimensions}
4501
4806
  */
@@ -4506,18 +4811,13 @@
4506
4811
  /**
4507
4812
  * Creates and returns a label and its bounding box.
4508
4813
  *
4509
- * @method Text#createText
4510
- *
4511
4814
  * @param {string} text the text to render on the label
4512
- * @param {Object} options
4513
- * @param {string} options.align how to align in the bounding box.
4514
- * Any of { 'center-middle', 'center-top' },
4515
- * defaults to 'center-top'.
4516
- * @param {string} options.style style to be applied to the text
4517
- * @param {boolean} options.fitBox indicates if box will be recalculated to
4518
- * fit text
4815
+ * @param {TextLayoutConfig} options
4519
4816
  *
4520
- * @return {Object} { element, dimensions }
4817
+ * @return { {
4818
+ * element: SVGElement,
4819
+ * dimensions: Dimensions
4820
+ * } }
4521
4821
  */
4522
4822
  Text.prototype.layoutText = function(text, options) {
4523
4823
  var box = assign$1({}, this._config.size, options.box),
@@ -4633,7 +4933,30 @@
4633
4933
 
4634
4934
  var MIN_TEXT_ANNOTATION_HEIGHT = 30;
4635
4935
 
4936
+ /**
4937
+ * @typedef { {
4938
+ * fontFamily: string;
4939
+ * fontSize: number;
4940
+ * fontWeight: string;
4941
+ * lineHeight: number;
4942
+ * } } TextRendererStyle
4943
+ *
4944
+ * @typedef { {
4945
+ * defaultStyle?: Partial<TextRendererStyle>;
4946
+ * externalStyle?: Partial<TextRendererStyle>;
4947
+ * } } TextRendererConfig
4948
+ *
4949
+ * @typedef { import('diagram-js/lib/util/Text').TextLayoutConfig } TextLayoutConfig
4950
+ *
4951
+ * @typedef { import('diagram-js/lib/util/Types').Rect } Rect
4952
+ */
4953
+
4636
4954
 
4955
+ /**
4956
+ * Renders text and computes text bounding boxes.
4957
+ *
4958
+ * @param {TextRendererConfig} [config]
4959
+ */
4637
4960
  function TextRenderer(config) {
4638
4961
 
4639
4962
  var defaultStyle = assign$1({
@@ -4657,19 +4980,17 @@
4657
4980
  * Get the new bounds of an externally rendered,
4658
4981
  * layouted label.
4659
4982
  *
4660
- * @param {Bounds} bounds
4661
- * @param {string} text
4983
+ * @param {Rect} bounds
4984
+ * @param {string} text
4662
4985
  *
4663
- * @return {Bounds}
4986
+ * @return {Rect}
4664
4987
  */
4665
4988
  this.getExternalLabelBounds = function(bounds, text) {
4666
4989
 
4667
4990
  var layoutedDimensions = textUtil.getDimensions(text, {
4668
4991
  box: {
4669
4992
  width: 90,
4670
- height: 30,
4671
- x: bounds.width / 2 + bounds.x,
4672
- y: bounds.height / 2 + bounds.y
4993
+ height: 30
4673
4994
  },
4674
4995
  style: externalStyle
4675
4996
  });
@@ -4687,10 +5008,10 @@
4687
5008
  /**
4688
5009
  * Get the new bounds of text annotation.
4689
5010
  *
4690
- * @param {Bounds} bounds
4691
- * @param {string} text
5011
+ * @param {Rect} bounds
5012
+ * @param {string} text
4692
5013
  *
4693
- * @return {Bounds}
5014
+ * @return {Rect}
4694
5015
  */
4695
5016
  this.getTextAnnotationBounds = function(bounds, text) {
4696
5017
 
@@ -4713,7 +5034,7 @@
4713
5034
  * Create a layouted text element.
4714
5035
  *
4715
5036
  * @param {string} text
4716
- * @param {Object} [options]
5037
+ * @param {TextLayoutConfig} [options]
4717
5038
  *
4718
5039
  * @return {SVGElement} rendered text
4719
5040
  */
@@ -4742,9 +5063,8 @@
4742
5063
  ];
4743
5064
 
4744
5065
  /**
4745
- * Map containing SVG paths needed by BpmnRenderer.
5066
+ * Map containing SVG paths needed by BpmnRenderer
4746
5067
  */
4747
-
4748
5068
  function PathMap() {
4749
5069
 
4750
5070
  /**
@@ -5086,6 +5406,13 @@
5086
5406
  }
5087
5407
  };
5088
5408
 
5409
+ /**
5410
+ * Return raw path for the given ID.
5411
+ *
5412
+ * @param {string} pathId
5413
+ *
5414
+ * @return {string} raw path
5415
+ */
5089
5416
  this.getRawPath = function getRawPath(pathId) {
5090
5417
  return this.pathMap[pathId].d;
5091
5418
  };
@@ -5138,6 +5465,7 @@
5138
5465
  * </ul>
5139
5466
  * </p>
5140
5467
  *
5468
+ * @return {string} scaled path
5141
5469
  */
5142
5470
  this.getScaledPath = function getScaledPath(pathId, param) {
5143
5471
  var rawPath = this.pathMap[pathId];
@@ -5221,7 +5549,9 @@
5221
5549
  };
5222
5550
 
5223
5551
  /**
5224
- * @typedef {import('./').Replacements} Replacements
5552
+ * @typedef { {
5553
+ * [key: string]: string;
5554
+ * } } TranslateReplacements
5225
5555
  */
5226
5556
 
5227
5557
  /**
@@ -5231,14 +5561,16 @@
5231
5561
  *
5232
5562
  * @example
5233
5563
  *
5564
+ * ```javascript
5234
5565
  * // use it inside any diagram component by injecting `translate`.
5235
5566
  *
5236
5567
  * function MyService(translate) {
5237
5568
  * alert(translate('HELLO {you}', { you: 'You!' }));
5238
5569
  * }
5570
+ * ```
5239
5571
  *
5240
5572
  * @param {string} template to interpolate
5241
- * @param {Replacements} [replacements] a map with substitutes
5573
+ * @param {TranslateReplacements} [replacements] a map with substitutes
5242
5574
  *
5243
5575
  * @return {string} the translated string
5244
5576
  */
@@ -5251,10 +5583,21 @@
5251
5583
  });
5252
5584
  }
5253
5585
 
5586
+ /**
5587
+ * @type { import('didi').ModuleDeclaration }
5588
+ */
5254
5589
  var TranslateModule = {
5255
5590
  translate: [ 'value', translate ]
5256
5591
  };
5257
5592
 
5593
+ /**
5594
+ * @typedef {import('diagram-js/lib/util/Types').Point} Point
5595
+ * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
5596
+ *
5597
+ * @typedef {import('../model/Types').Element} Element
5598
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
5599
+ */
5600
+
5258
5601
  var DEFAULT_LABEL_SIZE = {
5259
5602
  width: 90,
5260
5603
  height: 20
@@ -5264,10 +5607,11 @@
5264
5607
 
5265
5608
 
5266
5609
  /**
5267
- * Returns true if the given semantic has an external label
5610
+ * Return true if the given semantic has an external label.
5611
+ *
5612
+ * @param {Element} semantic
5268
5613
  *
5269
- * @param {BpmnElement} semantic
5270
- * @return {boolean} true if has label
5614
+ * @return {boolean}
5271
5615
  */
5272
5616
  function isLabelExternal(semantic) {
5273
5617
  return is$1(semantic, 'bpmn:Event') ||
@@ -5282,10 +5626,11 @@
5282
5626
  }
5283
5627
 
5284
5628
  /**
5285
- * Get the position for sequence flow labels
5629
+ * Get the position of a sequence flow label.
5630
+ *
5631
+ * @param {Point[]} waypoints
5286
5632
  *
5287
- * @param {Array<Point>} waypoints
5288
- * @return {Point} the label position
5633
+ * @return {Point}
5289
5634
  */
5290
5635
  function getFlowLabelPosition(waypoints) {
5291
5636
 
@@ -5315,10 +5660,11 @@
5315
5660
 
5316
5661
 
5317
5662
  /**
5318
- * Get the middle of a number of waypoints
5663
+ * Get the middle of a number of waypoints.
5664
+ *
5665
+ * @param {Point[]} waypoints
5319
5666
  *
5320
- * @param {Array<Point>} waypoints
5321
- * @return {Point} the mid point
5667
+ * @return {Point}
5322
5668
  */
5323
5669
  function getWaypointsMid(waypoints) {
5324
5670
 
@@ -5333,7 +5679,13 @@
5333
5679
  };
5334
5680
  }
5335
5681
 
5336
-
5682
+ /**
5683
+ * Get the middle of the external label of an element.
5684
+ *
5685
+ * @param {Element} element
5686
+ *
5687
+ * @return {Point}
5688
+ */
5337
5689
  function getExternalLabelMid(element) {
5338
5690
 
5339
5691
  if (element.waypoints) {
@@ -5353,11 +5705,13 @@
5353
5705
 
5354
5706
 
5355
5707
  /**
5356
- * Returns the bounds of an elements label, parsed from the elements DI or
5708
+ * Return the bounds of an elements label, parsed from the elements DI or
5357
5709
  * generated from its bounds.
5358
5710
  *
5359
- * @param {BpmndDi} di
5360
- * @param {djs.model.Base} element
5711
+ * @param {ModdleElement} di
5712
+ * @param {Element} element
5713
+ *
5714
+ * @return {Rect}
5361
5715
  */
5362
5716
  function getExternalLabelBounds(di, element) {
5363
5717
 
@@ -5515,7 +5869,7 @@
5515
5869
  /**
5516
5870
  * Get the mid of the given Element.
5517
5871
  *
5518
- * @param {Connection} connection
5872
+ * @param {Element} element
5519
5873
  *
5520
5874
  * @return {Point}
5521
5875
  */
@@ -5545,6 +5899,21 @@
5545
5899
  return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />';
5546
5900
  }
5547
5901
 
5902
+ /**
5903
+ * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
5904
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
5905
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
5906
+ * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
5907
+ *
5908
+ * @typedef {import('../features/modeling/ElementFactory').default} ElementFactory
5909
+ * @typedef {import('../draw/TextRenderer').default} TextRenderer
5910
+ *
5911
+ * @typedef {import('../model/Types').Element} Element
5912
+ * @typedef {import('../model/Types').Label} Label
5913
+ * @typedef {import('../model/Types').Shape} Shape
5914
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
5915
+ */
5916
+
5548
5917
  /**
5549
5918
  * @param {ModdleElement} semantic
5550
5919
  * @param {ModdleElement} di
@@ -5616,8 +5985,12 @@
5616
5985
 
5617
5986
 
5618
5987
  /**
5619
- * Add bpmn element (semantic) to the canvas onto the
5620
- * specified parent shape.
5988
+ * Add a BPMN element (semantic) to the canvas making it a child of the
5989
+ * given parent.
5990
+ *
5991
+ * @param {ModdleElement} semantic
5992
+ * @param {ModdleElement} di
5993
+ * @param {Shape} parentElement
5621
5994
  */
5622
5995
  BpmnImporter.prototype.add = function(semantic, di, parentElement) {
5623
5996
  var element,
@@ -5726,10 +6099,10 @@
5726
6099
 
5727
6100
 
5728
6101
  /**
5729
- * Attach the boundary element to the given host
6102
+ * Attach a boundary element to the given host.
5730
6103
  *
5731
6104
  * @param {ModdleElement} boundarySemantic
5732
- * @param {djs.model.Base} boundaryElement
6105
+ * @param {Shape} boundaryElement
5733
6106
  */
5734
6107
  BpmnImporter.prototype._attachBoundary = function(boundarySemantic, boundaryElement) {
5735
6108
  var translate = this._translate;
@@ -5762,7 +6135,13 @@
5762
6135
 
5763
6136
 
5764
6137
  /**
5765
- * add label for an element
6138
+ * Add a label to a given element.
6139
+ *
6140
+ * @param {ModdleElement} semantic
6141
+ * @param {ModdleElement} di
6142
+ * @param {Element} element
6143
+ *
6144
+ * @return {Label}
5766
6145
  */
5767
6146
  BpmnImporter.prototype.addLabel = function(semantic, di, element) {
5768
6147
  var bounds,
@@ -5794,11 +6173,14 @@
5794
6173
  };
5795
6174
 
5796
6175
  /**
5797
- * Return the drawn connection end based on the given side.
6176
+ * Get the source or target of the given connection.
6177
+ *
6178
+ * @param {ModdleElement} semantic
6179
+ * @param {'source' | 'target'} side
5798
6180
  *
5799
- * @throws {Error} if the end is not yet drawn
6181
+ * @return {Element}
5800
6182
  */
5801
- BpmnImporter.prototype._getEnd = function(semantic, side) {
6183
+ BpmnImporter.prototype._getConnectedElement = function(semantic, side) {
5802
6184
 
5803
6185
  var element,
5804
6186
  refSemantic,
@@ -5836,11 +6218,11 @@
5836
6218
  };
5837
6219
 
5838
6220
  BpmnImporter.prototype._getSource = function(semantic) {
5839
- return this._getEnd(semantic, 'source');
6221
+ return this._getConnectedElement(semantic, 'source');
5840
6222
  };
5841
6223
 
5842
6224
  BpmnImporter.prototype._getTarget = function(semantic) {
5843
- return this._getEnd(semantic, 'target');
6225
+ return this._getConnectedElement(semantic, 'target');
5844
6226
  };
5845
6227
 
5846
6228
 
@@ -5943,11 +6325,13 @@
5943
6325
  }
5944
6326
 
5945
6327
  /**
5946
- * @typedef {import('../../model').Base} Base
6328
+ * @typedef {import('../../model/Types').Element} Element
5947
6329
  *
5948
6330
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
5949
6331
  * @typedef {import('../../core/EventBus').default} EventBus
5950
6332
  * @typedef {import('../../draw/Styles').default} Styles
6333
+ *
6334
+ * @typedef {import('../../util/Types').Point} Point
5951
6335
  */
5952
6336
 
5953
6337
  function allowAll(event) { return true; }
@@ -5991,7 +6375,7 @@
5991
6375
  *
5992
6376
  * @param {string} type local event name, e.g. element.click.
5993
6377
  * @param {MouseEvent|TouchEvent} event native event
5994
- * @param {Base} [element] the diagram element to emit the event on;
6378
+ * @param {Element} [element] the diagram element to emit the event on;
5995
6379
  * defaults to the event target
5996
6380
  */
5997
6381
  function fire(type, event, element) {
@@ -6074,7 +6458,7 @@
6074
6458
  *
6075
6459
  * @param {string} eventName the name of the triggered DOM event
6076
6460
  * @param {MouseEvent|TouchEvent} event
6077
- * @param {Base} targetElement
6461
+ * @param {Element} targetElement
6078
6462
  */
6079
6463
  function triggerMouseEvent(eventName, event, targetElement) {
6080
6464
 
@@ -6240,7 +6624,7 @@
6240
6624
  /**
6241
6625
  * Create default hit for the given element.
6242
6626
  *
6243
- * @param {Base} element
6627
+ * @param {Element} element
6244
6628
  * @param {SVGElement} gfx
6245
6629
  *
6246
6630
  * @return {SVGElement} created hit
@@ -6267,7 +6651,7 @@
6267
6651
  * Create hits for the given waypoints.
6268
6652
  *
6269
6653
  * @param {SVGElement} gfx
6270
- * @param {Array<Point>} waypoints
6654
+ * @param {Point[]} waypoints
6271
6655
  *
6272
6656
  * @return {SVGElement}
6273
6657
  */
@@ -6286,7 +6670,7 @@
6286
6670
  * Create hits for a box.
6287
6671
  *
6288
6672
  * @param {SVGElement} gfx
6289
- * @param {string} hitType
6673
+ * @param {string} type
6290
6674
  * @param {Object} attrs
6291
6675
  *
6292
6676
  * @return {SVGElement}
@@ -6312,7 +6696,7 @@
6312
6696
  /**
6313
6697
  * Update default hit of the element.
6314
6698
  *
6315
- * @param {Base} element
6699
+ * @param {Element} element
6316
6700
  * @param {SVGElement} gfx
6317
6701
  *
6318
6702
  * @return {SVGElement} updated hit
@@ -6361,7 +6745,7 @@
6361
6745
  * @event element.hover
6362
6746
  *
6363
6747
  * @type {Object}
6364
- * @property {Base} element
6748
+ * @property {Element} element
6365
6749
  * @property {SVGElement} gfx
6366
6750
  * @property {Event} originalEvent
6367
6751
  */
@@ -6372,7 +6756,7 @@
6372
6756
  * @event element.out
6373
6757
  *
6374
6758
  * @type {Object}
6375
- * @property {Base} element
6759
+ * @property {Element} element
6376
6760
  * @property {SVGElement} gfx
6377
6761
  * @property {Event} originalEvent
6378
6762
  */
@@ -6383,7 +6767,7 @@
6383
6767
  * @event element.click
6384
6768
  *
6385
6769
  * @type {Object}
6386
- * @property {Base} element
6770
+ * @property {Element} element
6387
6771
  * @property {SVGElement} gfx
6388
6772
  * @property {Event} originalEvent
6389
6773
  */
@@ -6394,7 +6778,7 @@
6394
6778
  * @event element.dblclick
6395
6779
  *
6396
6780
  * @type {Object}
6397
- * @property {Base} element
6781
+ * @property {Element} element
6398
6782
  * @property {SVGElement} gfx
6399
6783
  * @property {Event} originalEvent
6400
6784
  */
@@ -6405,7 +6789,7 @@
6405
6789
  * @event element.mousedown
6406
6790
  *
6407
6791
  * @type {Object}
6408
- * @property {Base} element
6792
+ * @property {Element} element
6409
6793
  * @property {SVGElement} gfx
6410
6794
  * @property {Event} originalEvent
6411
6795
  */
@@ -6416,7 +6800,7 @@
6416
6800
  * @event element.mouseup
6417
6801
  *
6418
6802
  * @type {Object}
6419
- * @property {Base} element
6803
+ * @property {Element} element
6420
6804
  * @property {SVGElement} gfx
6421
6805
  * @property {Event} originalEvent
6422
6806
  */
@@ -6428,11 +6812,14 @@
6428
6812
  * @event element.contextmenu
6429
6813
  *
6430
6814
  * @type {Object}
6431
- * @property {Base} element
6815
+ * @property {Element} element
6432
6816
  * @property {SVGElement} gfx
6433
6817
  * @property {Event} originalEvent
6434
6818
  */
6435
6819
 
6820
+ /**
6821
+ * @type { import('didi').ModuleDeclaration }
6822
+ */
6436
6823
  var InteractionEventsModule = {
6437
6824
  __init__: [ 'interactionEvents' ],
6438
6825
  interactionEvents: [ 'type', InteractionEvents ]
@@ -6442,7 +6829,7 @@
6442
6829
  * Returns the surrounding bbox for all elements in
6443
6830
  * the array or the element primitive.
6444
6831
  *
6445
- * @param {Base|Base[]} elements
6832
+ * @param {Element|Element[]} elements
6446
6833
  * @param {boolean} [stopRecursion=false]
6447
6834
  *
6448
6835
  * @return {Rect}
@@ -6517,7 +6904,7 @@
6517
6904
  var LOW_PRIORITY$3 = 500;
6518
6905
 
6519
6906
  /**
6520
- * @typedef {import('../../model').Base} Base
6907
+ * @typedef {import('../../model/Types').Element} Element
6521
6908
  *
6522
6909
  * @typedef {import('../../core/EventBus').default} EventBus
6523
6910
  * @typedef {import('../../draw/Styles').default} Styles
@@ -6591,7 +6978,7 @@
6591
6978
  * element and an outline offset.
6592
6979
  *
6593
6980
  * @param {SVGElement} outline
6594
- * @param {Base} element
6981
+ * @param {Element} element
6595
6982
  */
6596
6983
  Outline.prototype.updateShapeOutline = function(outline, element) {
6597
6984
 
@@ -6610,7 +6997,7 @@
6610
6997
  * the connection and an outline offset.
6611
6998
  *
6612
6999
  * @param {SVGElement} outline
6613
- * @param {Base} element
7000
+ * @param {Element} connection
6614
7001
  */
6615
7002
  Outline.prototype.updateConnectionOutline = function(outline, connection) {
6616
7003
 
@@ -6628,12 +7015,16 @@
6628
7015
 
6629
7016
  Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
6630
7017
 
7018
+ /**
7019
+ * @type { import('didi').ModuleDeclaration }
7020
+ */
6631
7021
  var OutlineModule = {
6632
7022
  __init__: [ 'outline' ],
6633
7023
  outline: [ 'type', Outline ]
6634
7024
  };
6635
7025
 
6636
7026
  /**
7027
+ * @typedef {import('../../core/Canvas').default} Canvas
6637
7028
  * @typedef {import('../../core/EventBus').default} EventBus
6638
7029
  */
6639
7030
 
@@ -6641,15 +7032,17 @@
6641
7032
  * A service that offers the current selection in a diagram.
6642
7033
  * Offers the api to control the selection, too.
6643
7034
  *
6644
- * @class
6645
- *
6646
7035
  * @param {EventBus} eventBus
7036
+ * @param {Canvas} canvas
6647
7037
  */
6648
7038
  function Selection(eventBus, canvas) {
6649
7039
 
6650
7040
  this._eventBus = eventBus;
6651
7041
  this._canvas = canvas;
6652
7042
 
7043
+ /**
7044
+ * @type {Object[]}
7045
+ */
6653
7046
  this._selectedElements = [];
6654
7047
 
6655
7048
  var self = this;
@@ -6666,7 +7059,11 @@
6666
7059
 
6667
7060
  Selection.$inject = [ 'eventBus', 'canvas' ];
6668
7061
 
6669
-
7062
+ /**
7063
+ * Deselect an element.
7064
+ *
7065
+ * @param {Object} element The element to deselect.
7066
+ */
6670
7067
  Selection.prototype.deselect = function(element) {
6671
7068
  var selectedElements = this._selectedElements;
6672
7069
 
@@ -6681,26 +7078,33 @@
6681
7078
  }
6682
7079
  };
6683
7080
 
6684
-
7081
+ /**
7082
+ * Get the selected elements.
7083
+ *
7084
+ * @return {Object[]} The selected elements.
7085
+ */
6685
7086
  Selection.prototype.get = function() {
6686
7087
  return this._selectedElements;
6687
7088
  };
6688
7089
 
7090
+ /**
7091
+ * Check whether an element is selected.
7092
+ *
7093
+ * @param {Object} element The element.
7094
+ *
7095
+ * @return {boolean} Whether the element is selected.
7096
+ */
6689
7097
  Selection.prototype.isSelected = function(element) {
6690
7098
  return this._selectedElements.indexOf(element) !== -1;
6691
7099
  };
6692
7100
 
6693
7101
 
6694
7102
  /**
6695
- * This method selects one or more elements on the diagram.
6696
- *
6697
- * By passing an additional add parameter you can decide whether or not the element(s)
6698
- * should be added to the already existing selection or not.
7103
+ * Select one or many elements.
6699
7104
  *
6700
- * @method Selection#select
6701
- *
6702
- * @param {Object|Object[]} elements element or array of elements to be selected
6703
- * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
7105
+ * @param {Object|Object[]} elements The element(s) to select.
7106
+ * @param {boolean} [add] Whether to add the element(s) to the selected elements.
7107
+ * Defaults to `false`.
6704
7108
  */
6705
7109
  Selection.prototype.select = function(elements, add) {
6706
7110
  var selectedElements = this._selectedElements,
@@ -6986,6 +7390,9 @@
6986
7390
  return !element.hidden;
6987
7391
  }
6988
7392
 
7393
+ /**
7394
+ * @type { import('didi').ModuleDeclaration }
7395
+ */
6989
7396
  var SelectionModule = {
6990
7397
  __init__: [ 'selectionVisuals', 'selectionBehavior' ],
6991
7398
  __depends__: [
@@ -7016,7 +7423,7 @@
7016
7423
  /**
7017
7424
  * Returns a next unique ID.
7018
7425
  *
7019
- * @returns {string} the id
7426
+ * @return {string} the id
7020
7427
  */
7021
7428
  IdGenerator.prototype.next = function() {
7022
7429
  return this._prefix + (++this._counter);
@@ -7032,12 +7439,54 @@
7032
7439
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
7033
7440
  * @typedef {import('../../core/EventBus').default} EventBus
7034
7441
  *
7035
- * @typedef {import('./Overlays').Overlay} Overlay
7036
- * @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
7037
- * @typedef {import('./Overlays').OverlayContainer} OverlayContainer
7038
- * @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
7039
- * @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
7040
- * @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
7442
+ * @typedef {import('../../model/Types').Element} Element
7443
+ *
7444
+ * @typedef { {
7445
+ * minZoom?: number,
7446
+ * maxZoom?: number
7447
+ * } } OverlaysConfigShow
7448
+ *
7449
+ * @typedef { {
7450
+ * min?: number,
7451
+ * max?: number
7452
+ * } } OverlaysConfigScale
7453
+ *
7454
+ * @typedef { {
7455
+ * id: string,
7456
+ * type: string | null,
7457
+ * element: Element | string
7458
+ * } & OverlayAttrs } Overlay
7459
+ *
7460
+ * @typedef { {
7461
+ * html: HTMLElement | string,
7462
+ * position: {
7463
+ * top?: number,
7464
+ * right?: number,
7465
+ * bottom?: number,
7466
+ * left?: number
7467
+ * }
7468
+ * } & OverlaysConfigDefault } OverlayAttrs
7469
+ *
7470
+ * @typedef { {
7471
+ * html: HTMLElement,
7472
+ * element: Element,
7473
+ * overlays: Overlay[]
7474
+ * } } OverlayContainer
7475
+ *
7476
+ * @typedef {{
7477
+ * defaults?: OverlaysConfigDefault
7478
+ * }} OverlaysConfig
7479
+ *
7480
+ * @typedef { {
7481
+ * show?: OverlaysConfigShow,
7482
+ * scale?: OverlaysConfigScale | boolean
7483
+ * } } OverlaysConfigDefault
7484
+ *
7485
+ * @typedef { {
7486
+ * id?: string;
7487
+ * element?: Element | string;
7488
+ * type?: string;
7489
+ * } | string } OverlaysFilter
7041
7490
  */
7042
7491
 
7043
7492
  /**
@@ -7047,6 +7496,7 @@
7047
7496
  *
7048
7497
  * @example
7049
7498
  *
7499
+ * ```javascript
7050
7500
  * // add a pink badge on the top left of the shape
7051
7501
  *
7052
7502
  * overlays.add(someShape, {
@@ -7076,8 +7526,9 @@
7076
7526
  * }
7077
7527
  * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
7078
7528
  * });
7529
+ * ```
7079
7530
  *
7080
- *
7531
+ * ```javascript
7081
7532
  * // remove an overlay
7082
7533
  *
7083
7534
  * var id = overlays.add(...);
@@ -7099,6 +7550,7 @@
7099
7550
  * }
7100
7551
  * }
7101
7552
  * }
7553
+ * ```
7102
7554
  *
7103
7555
  * @param {OverlaysConfig} config
7104
7556
  * @param {EventBus} eventBus
@@ -7157,6 +7609,7 @@
7157
7609
  *
7158
7610
  * @example
7159
7611
  *
7612
+ * ```javascript
7160
7613
  * // return the single overlay with the given ID
7161
7614
  * overlays.get('some-id');
7162
7615
  *
@@ -7168,6 +7621,7 @@
7168
7621
  *
7169
7622
  * // shape can also be specified as ID
7170
7623
  * overlays.get({ element: 'element-id', type: 'badge' });
7624
+ * ```
7171
7625
  *
7172
7626
  * @param {OverlaysFilter} search The filter to be used to find the overlay(s).
7173
7627
  *
@@ -7205,7 +7659,7 @@
7205
7659
  /**
7206
7660
  * Adds an HTML overlay to an element.
7207
7661
  *
7208
- * @param {Base|string} element The element to add the overlay to.
7662
+ * @param {Element|string} element The element to add the overlay to.
7209
7663
  * @param {string} [type] An optional type that can be used to filter.
7210
7664
  * @param {OverlayAttrs} overlay The overlay.
7211
7665
  *
@@ -7293,7 +7747,7 @@
7293
7747
  /**
7294
7748
  * Checks whether overlays are shown.
7295
7749
  *
7296
- * @returns {boolean} Whether overlays are shown.
7750
+ * @return {boolean} Whether overlays are shown.
7297
7751
  */
7298
7752
  Overlays.prototype.isShown = function() {
7299
7753
  return this._overlayRoot.style.display !== 'none';
@@ -7686,6 +8140,9 @@
7686
8140
  });
7687
8141
  }
7688
8142
 
8143
+ /**
8144
+ * @type { import('didi').ModuleDeclaration }
8145
+ */
7689
8146
  var OverlaysModule = {
7690
8147
  __init__: [ 'overlays' ],
7691
8148
  overlays: [ 'type', Overlays ]
@@ -7762,15 +8219,22 @@
7762
8219
  'graphicsFactory'
7763
8220
  ];
7764
8221
 
8222
+ /**
8223
+ * @type { import('didi').ModuleDeclaration }
8224
+ */
7765
8225
  var ChangeSupportModule = {
7766
8226
  __init__: [ 'changeSupport' ],
7767
8227
  changeSupport: [ 'type', ChangeSupport ]
7768
8228
  };
7769
8229
 
7770
8230
  /**
8231
+ * @typedef {import('../core/Types').ElementLike} ElementLike
7771
8232
  * @typedef {import('../core/EventBus').default} EventBus
7772
- * @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
7773
- * @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
8233
+ * @typedef {import('./CommandStack').CommandContext} CommandContext
8234
+ *
8235
+ * @typedef {string|string[]} Events
8236
+ * @typedef { (context: CommandContext) => ElementLike[] | void } HandlerFunction
8237
+ * @typedef { (context: CommandContext) => void } ComposeHandlerFunction
7774
8238
  */
7775
8239
 
7776
8240
  var DEFAULT_PRIORITY$2 = 1000;
@@ -7782,10 +8246,9 @@
7782
8246
  * @class
7783
8247
  * @constructor
7784
8248
  *
7785
- * @param {EventBus} eventBus
7786
- *
7787
8249
  * @example
7788
8250
  *
8251
+ * ```javascript
7789
8252
  * import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
7790
8253
  *
7791
8254
  * class CommandLogger extends CommandInterceptor {
@@ -7796,6 +8259,9 @@
7796
8259
  * console.log('commandStack.shape-create.preExecute', event);
7797
8260
  * });
7798
8261
  * }
8262
+ * ```
8263
+ *
8264
+ * @param {EventBus} eventBus
7799
8265
  */
7800
8266
  function CommandInterceptor(eventBus) {
7801
8267
 
@@ -7813,16 +8279,17 @@
7813
8279
  };
7814
8280
  }
7815
8281
 
8282
+
7816
8283
  /**
7817
- * Intercept a command during one of the phases.
7818
- *
7819
- * @param {string|string[]} [events] One or more commands to intercept.
7820
- * @param {string} [hook] Phase during which to intercept command.
7821
- * @param {number} [priority] Priority with which command will be intercepted.
7822
- * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7823
- * @param {boolean} [unwrap] Whether the event should be unwrapped.
7824
- * @param {*} [that] `this` value the callback will be called with.
7825
- */
8284
+ * Intercept a command during one of the phases.
8285
+ *
8286
+ * @param {Events} [events] command(s) to intercept
8287
+ * @param {string} [hook] phase to intercept
8288
+ * @param {number} [priority]
8289
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8290
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8291
+ * @param {any} [that]
8292
+ */
7826
8293
  CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
7827
8294
 
7828
8295
  if (isFunction(hook) || isNumber(hook)) {
@@ -7864,35 +8331,130 @@
7864
8331
  });
7865
8332
  };
7866
8333
 
8334
+ /**
8335
+ * Add a <canExecute> phase of command interceptor.
8336
+ *
8337
+ * @param {Events} [events] command(s) to intercept
8338
+ * @param {number} [priority]
8339
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8340
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8341
+ * @param {any} [that]
8342
+ */
8343
+ CommandInterceptor.prototype.canExecute = createHook('canExecute');
7867
8344
 
7868
- var hooks = [
7869
- 'canExecute',
7870
- 'preExecute',
7871
- 'preExecuted',
7872
- 'execute',
7873
- 'executed',
7874
- 'postExecute',
7875
- 'postExecuted',
7876
- 'revert',
7877
- 'reverted'
7878
- ];
8345
+ /**
8346
+ * Add a <preExecute> phase of command interceptor.
8347
+ *
8348
+ * @param {Events} [events] command(s) to intercept
8349
+ * @param {number} [priority]
8350
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8351
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8352
+ * @param {any} [that]
8353
+ */
8354
+ CommandInterceptor.prototype.preExecute = createHook('preExecute');
8355
+
8356
+ /**
8357
+ * Add a <preExecuted> phase of command interceptor.
8358
+ *
8359
+ * @param {Events} [events] command(s) to intercept
8360
+ * @param {number} [priority]
8361
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8362
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8363
+ * @param {any} [that]
8364
+ */
8365
+ CommandInterceptor.prototype.preExecuted = createHook('preExecuted');
8366
+
8367
+ /**
8368
+ * Add a <execute> phase of command interceptor.
8369
+ *
8370
+ * @param {Events} [events] command(s) to intercept
8371
+ * @param {number} [priority]
8372
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8373
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8374
+ * @param {any} [that]
8375
+ */
8376
+ CommandInterceptor.prototype.execute = createHook('execute');
8377
+
8378
+ /**
8379
+ * Add a <executed> phase of command interceptor.
8380
+ *
8381
+ * @param {Events} [events] command(s) to intercept
8382
+ * @param {number} [priority]
8383
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8384
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8385
+ * @param {any} [that]
8386
+ */
8387
+ CommandInterceptor.prototype.executed = createHook('executed');
8388
+
8389
+ /**
8390
+ * Add a <postExecute> phase of command interceptor.
8391
+ *
8392
+ * @param {Events} [events] command(s) to intercept
8393
+ * @param {number} [priority]
8394
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8395
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8396
+ * @param {any} [that]
8397
+ */
8398
+ CommandInterceptor.prototype.postExecute = createHook('postExecute');
8399
+
8400
+ /**
8401
+ * Add a <postExecuted> phase of command interceptor.
8402
+ *
8403
+ * @param {Events} [events] command(s) to intercept
8404
+ * @param {number} [priority]
8405
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8406
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8407
+ * @param {any} [that]
8408
+ */
8409
+ CommandInterceptor.prototype.postExecuted = createHook('postExecuted');
8410
+
8411
+ /**
8412
+ * Add a <revert> phase of command interceptor.
8413
+ *
8414
+ * @param {Events} [events] command(s) to intercept
8415
+ * @param {number} [priority]
8416
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8417
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8418
+ * @param {any} [that]
8419
+ */
8420
+ CommandInterceptor.prototype.revert = createHook('revert');
8421
+
8422
+ /**
8423
+ * Add a <reverted> phase of command interceptor.
8424
+ *
8425
+ * @param {Events} [events] command(s) to intercept
8426
+ * @param {number} [priority]
8427
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8428
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8429
+ * @param {any} [that]
8430
+ */
8431
+ CommandInterceptor.prototype.reverted = createHook('reverted');
7879
8432
 
7880
8433
  /*
7881
8434
  * Add prototype methods for each phase of command execution (e.g. execute,
7882
8435
  * revert).
8436
+ *
8437
+ * @param {string} hook
8438
+ *
8439
+ * @return { (
8440
+ * events?: Events,
8441
+ * priority?: number,
8442
+ * handlerFn: ComposeHandlerFunction|HandlerFunction,
8443
+ * unwrap?: boolean
8444
+ * ) => any }
7883
8445
  */
7884
- forEach$1(hooks, function(hook) {
8446
+ function createHook(hook) {
7885
8447
 
7886
8448
  /**
7887
- * Add prototype method for a specific phase of command execution.
8449
+ * @this {CommandInterceptor}
7888
8450
  *
7889
- * @param {string|string[]} [events] One or more commands to intercept.
7890
- * @param {number} [priority] Priority with which command will be intercepted.
7891
- * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7892
- * @param {boolean} [unwrap] Whether the event should be unwrapped.
7893
- * @param {*} [that] `this` value the callback will be called with.
8451
+ * @param {Events} [events]
8452
+ * @param {number} [priority]
8453
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8454
+ * @param {boolean} [unwrap]
8455
+ * @param {any} [that]
7894
8456
  */
7895
- CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
8457
+ const hookFn = function(events, priority, handlerFn, unwrap, that) {
7896
8458
 
7897
8459
  if (isFunction(events) || isNumber(events)) {
7898
8460
  that = unwrap;
@@ -7904,7 +8466,9 @@
7904
8466
 
7905
8467
  this.on(events, hook, priority, handlerFn, unwrap, that);
7906
8468
  };
7907
- });
8469
+
8470
+ return hookFn;
8471
+ }
7908
8472
 
7909
8473
  /**
7910
8474
  * @typedef {import('didi').Injector} Injector
@@ -7946,6 +8510,9 @@
7946
8510
 
7947
8511
  RootElementsBehavior.$inject = [ 'canvas', 'injector' ];
7948
8512
 
8513
+ /**
8514
+ * @type { import('didi').ModuleDeclaration }
8515
+ */
7949
8516
  var RootElementsModule = {
7950
8517
  __init__: [ 'rootElementsBehavior' ],
7951
8518
  rootElementsBehavior: [ 'type', RootElementsBehavior ]
@@ -7953,7 +8520,7 @@
7953
8520
 
7954
8521
  /**
7955
8522
  * @param {string} str
7956
- * @returns {string}
8523
+ * @return {string}
7957
8524
  */
7958
8525
 
7959
8526
  var HTML_ESCAPE_MAP = {
@@ -7972,14 +8539,19 @@
7972
8539
  });
7973
8540
  }
7974
8541
 
8542
+ /**
8543
+ * @typedef {import('../model/Types').Element} Element
8544
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
8545
+ */
8546
+
7975
8547
  var planeSuffix = '_plane';
7976
8548
 
7977
8549
  /**
7978
8550
  * Get plane ID for a primary shape.
7979
8551
  *
7980
- * @param {djs.model.Base|ModdleElement} element
8552
+ * @param {Element|ModdleElement} element
7981
8553
  *
7982
- * @returns {String}
8554
+ * @return {string}
7983
8555
  */
7984
8556
  function getPlaneIdFromShape(element) {
7985
8557
  var id = element.id;
@@ -7995,32 +8567,40 @@
7995
8567
  return id + planeSuffix;
7996
8568
  }
7997
8569
 
8570
+ /**
8571
+ * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
8572
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
8573
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
8574
+ *
8575
+ * @typedef {import('../../model/Types').Element} Element
8576
+ * @typedef {import('../../model/Types').Shape} Shape
8577
+ */
8578
+
7998
8579
  var OPEN_CLASS = 'bjs-breadcrumbs-shown';
7999
8580
 
8000
8581
 
8001
8582
  /**
8002
8583
  * Adds overlays that allow switching planes on collapsed subprocesses.
8003
8584
  *
8004
- * @param {eventBus} eventBus
8005
- * @param {elementRegistry} elementRegistry
8006
- * @param {overlays} overlays
8007
- * @param {canvas} canvas
8585
+ * @param {EventBus} eventBus
8586
+ * @param {ElementRegistry} elementRegistry
8587
+ * @param {Canvas} canvas
8008
8588
  */
8009
- function DrilldownBreadcrumbs(eventBus, elementRegistry, overlays, canvas) {
8589
+ function DrilldownBreadcrumbs(eventBus, elementRegistry, canvas) {
8010
8590
  var breadcrumbs = domify$1('<ul class="bjs-breadcrumbs"></ul>');
8011
8591
  var container = canvas.getContainer();
8012
8592
  var containerClasses = classes(container);
8013
8593
  container.appendChild(breadcrumbs);
8014
8594
 
8015
- var boParents = [];
8595
+ var businessObjectParents = [];
8016
8596
 
8017
8597
  // update breadcrumbs if name or ID of the primary shape changes
8018
- eventBus.on('element.changed', function(e) {
8019
- var shape = e.element,
8020
- bo = getBusinessObject(shape);
8598
+ eventBus.on('element.changed', function(event) {
8599
+ var shape = event.element,
8600
+ businessObject = getBusinessObject(shape);
8021
8601
 
8022
- var isPresent = find(boParents, function(el) {
8023
- return el === bo;
8602
+ var isPresent = find(businessObjectParents, function(element) {
8603
+ return element === businessObject;
8024
8604
  });
8025
8605
 
8026
8606
  if (!isPresent) {
@@ -8034,14 +8614,14 @@
8034
8614
  * Updates the displayed breadcrumbs. If no element is provided, only the
8035
8615
  * labels are updated.
8036
8616
  *
8037
- * @param {djs.model.Base} [element]
8617
+ * @param {Element} [element]
8038
8618
  */
8039
8619
  function updateBreadcrumbs(element) {
8040
8620
  if (element) {
8041
- boParents = getBoParentChain(element);
8621
+ businessObjectParents = getBusinessObjectParentChain(element);
8042
8622
  }
8043
8623
 
8044
- var path = boParents.map(function(parent) {
8624
+ var path = businessObjectParents.map(function(parent) {
8045
8625
  var title = escapeHTML(parent.name || parent.id);
8046
8626
  var link = domify$1('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
8047
8627
 
@@ -8051,8 +8631,9 @@
8051
8631
  // element in the elementRegisty. Instead, we search for the corresponding participant
8052
8632
  if (!parentPlane && is$1(parent, 'bpmn:Process')) {
8053
8633
  var participant = elementRegistry.find(function(element) {
8054
- var bo = getBusinessObject(element);
8055
- return bo && bo.processRef && bo.processRef === parent;
8634
+ var businessObject = getBusinessObject(element);
8635
+
8636
+ return businessObject && businessObject.get('processRef') && businessObject.get('processRef') === parent;
8056
8637
  });
8057
8638
 
8058
8639
  parentPlane = canvas.findRoot(participant.id);
@@ -8069,10 +8650,11 @@
8069
8650
 
8070
8651
  // show breadcrumbs and expose state to .djs-container
8071
8652
  var visible = path.length > 1;
8653
+
8072
8654
  containerClasses.toggle(OPEN_CLASS, visible);
8073
8655
 
8074
- path.forEach(function(el) {
8075
- breadcrumbs.appendChild(el);
8656
+ path.forEach(function(element) {
8657
+ breadcrumbs.appendChild(element);
8076
8658
  });
8077
8659
  }
8078
8660
 
@@ -8082,7 +8664,7 @@
8082
8664
 
8083
8665
  }
8084
8666
 
8085
- DrilldownBreadcrumbs.$inject = [ 'eventBus', 'elementRegistry', 'overlays', 'canvas' ];
8667
+ DrilldownBreadcrumbs.$inject = [ 'eventBus', 'elementRegistry', 'canvas' ];
8086
8668
 
8087
8669
 
8088
8670
  // helpers //////////
@@ -8091,16 +8673,16 @@
8091
8673
  * Returns the parents for the element using the business object chain,
8092
8674
  * starting with the root element.
8093
8675
  *
8094
- * @param {djs.model.Shape} child
8676
+ * @param {Shape} child
8095
8677
  *
8096
- * @returns {Array<djs.model.Shape>} parents
8678
+ * @return {Shape}
8097
8679
  */
8098
- function getBoParentChain(child) {
8099
- var bo = getBusinessObject(child);
8680
+ function getBusinessObjectParentChain(child) {
8681
+ var businessObject = getBusinessObject(child);
8100
8682
 
8101
8683
  var parents = [];
8102
8684
 
8103
- for (var element = bo; element; element = element.$parent) {
8685
+ for (var element = businessObject; element; element = element.$parent) {
8104
8686
  if (is$1(element, 'bpmn:SubProcess') || is$1(element, 'bpmn:Process')) {
8105
8687
  parents.push(element);
8106
8688
  }
@@ -8109,13 +8691,18 @@
8109
8691
  return parents.reverse();
8110
8692
  }
8111
8693
 
8694
+ /**
8695
+ * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
8696
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
8697
+ */
8698
+
8112
8699
  /**
8113
8700
  * Move collapsed subprocesses into view when drilling down.
8114
8701
  *
8115
8702
  * Zoom and scroll are saved in a session.
8116
8703
  *
8117
- * @param {eventBus} eventBus
8118
- * @param {canvas} canvas
8704
+ * @param {EventBus} eventBus
8705
+ * @param {Canvas} canvas
8119
8706
  */
8120
8707
  function DrilldownCentering(eventBus, canvas) {
8121
8708
 
@@ -8226,6 +8813,18 @@
8226
8813
  };
8227
8814
  }
8228
8815
 
8816
+ /**
8817
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
8818
+ * @typedef {import('../../model/Types').Moddle} Moddle
8819
+ *
8820
+ * @typedef {import('../../model/Types').Element} Element
8821
+ * @typedef {import('../../model/Types').Shape} Shape
8822
+ *
8823
+ * @typedef {import('diagram-js/lib/core/Canvas').CanvasPlane} CanvasPlane
8824
+ *
8825
+ * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
8826
+ */
8827
+
8229
8828
  var DEFAULT_POSITION = {
8230
8829
  x: 180,
8231
8830
  y: 160
@@ -8233,10 +8832,10 @@
8233
8832
 
8234
8833
  /**
8235
8834
  * Hook into `import.render.start` and create new planes for diagrams with
8236
- * collapsed subprocesses and all dis on the same plane.
8835
+ * collapsed subprocesses and all DI elements on the same plane.
8237
8836
  *
8238
- * @param {eventBus} eventBus
8239
- * @param {moddle} moddle
8837
+ * @param {EventBus} eventBus
8838
+ * @param {Moddle} moddle
8240
8839
  */
8241
8840
  function SubprocessCompatibility(eventBus, moddle) {
8242
8841
  this._eventBus = eventBus;
@@ -8245,11 +8844,14 @@
8245
8844
  var self = this;
8246
8845
 
8247
8846
  eventBus.on('import.render.start', 1500, function(e, context) {
8248
- self.handleImport(context.definitions);
8847
+ self._handleImport(context.definitions);
8249
8848
  });
8250
8849
  }
8251
8850
 
8252
- SubprocessCompatibility.prototype.handleImport = function(definitions) {
8851
+ /**
8852
+ * @param {ModdleElement} definitions
8853
+ */
8854
+ SubprocessCompatibility.prototype._handleImport = function(definitions) {
8253
8855
  if (!definitions.diagrams) {
8254
8856
  return;
8255
8857
  }
@@ -8268,12 +8870,12 @@
8268
8870
 
8269
8871
  var newDiagrams = [];
8270
8872
  definitions.diagrams.forEach(function(diagram) {
8271
- var createdDiagrams = self.createNewDiagrams(diagram.plane);
8873
+ var createdDiagrams = self._createNewDiagrams(diagram.plane);
8272
8874
  Array.prototype.push.apply(newDiagrams, createdDiagrams);
8273
8875
  });
8274
8876
 
8275
8877
  newDiagrams.forEach(function(diagram) {
8276
- self.movePlaneElementsToOrigin(diagram.plane);
8878
+ self._movePlaneElementsToOrigin(diagram.plane);
8277
8879
  });
8278
8880
  };
8279
8881
 
@@ -8281,29 +8883,30 @@
8281
8883
  /**
8282
8884
  * Moves all DI elements from collapsed subprocesses to a new plane.
8283
8885
  *
8284
- * @param {Object} plane
8285
- * @return {Array} new diagrams created for the collapsed subprocesses
8886
+ * @param {CanvasPlane} plane
8887
+ *
8888
+ * @return {ModdleElement[]} new diagrams created for the collapsed subprocesses
8286
8889
  */
8287
- SubprocessCompatibility.prototype.createNewDiagrams = function(plane) {
8890
+ SubprocessCompatibility.prototype._createNewDiagrams = function(plane) {
8288
8891
  var self = this;
8289
8892
 
8290
8893
  var collapsedElements = [];
8291
8894
  var elementsToMove = [];
8292
8895
 
8293
8896
  plane.get('planeElement').forEach(function(diElement) {
8294
- var bo = diElement.bpmnElement;
8897
+ var businessObject = diElement.bpmnElement;
8295
8898
 
8296
- if (!bo) {
8899
+ if (!businessObject) {
8297
8900
  return;
8298
8901
  }
8299
8902
 
8300
- var parent = bo.$parent;
8903
+ var parent = businessObject.$parent;
8301
8904
 
8302
- if (is$1(bo, 'bpmn:SubProcess') && !diElement.isExpanded) {
8303
- collapsedElements.push(bo);
8905
+ if (is$1(businessObject, 'bpmn:SubProcess') && !diElement.isExpanded) {
8906
+ collapsedElements.push(businessObject);
8304
8907
  }
8305
8908
 
8306
- if (shouldMoveToPlane(bo, plane)) {
8909
+ if (shouldMoveToPlane(businessObject, plane)) {
8307
8910
 
8308
8911
  // don't change the array while we iterate over it
8309
8912
  elementsToMove.push({ diElement: diElement, parent: parent });
@@ -8314,9 +8917,11 @@
8314
8917
 
8315
8918
  // create new planes for all collapsed subprocesses, even when they are empty
8316
8919
  collapsedElements.forEach(function(element) {
8317
- if (!self._processToDiagramMap[element.id]) {
8318
- var diagram = self.createDiagram(element);
8920
+ if (!self._processToDiagramMap[ element.id ]) {
8921
+ var diagram = self._createDiagram(element);
8922
+
8319
8923
  self._processToDiagramMap[element.id] = diagram;
8924
+
8320
8925
  newDiagrams.push(diagram);
8321
8926
  }
8322
8927
  });
@@ -8335,14 +8940,18 @@
8335
8940
  return;
8336
8941
  }
8337
8942
 
8338
- var diagram = self._processToDiagramMap[parent.id];
8339
- self.moveToDiPlane(diElement, diagram.plane);
8943
+ var diagram = self._processToDiagramMap[ parent.id ];
8944
+
8945
+ self._moveToDiPlane(diElement, diagram.plane);
8340
8946
  });
8341
8947
 
8342
8948
  return newDiagrams;
8343
8949
  };
8344
8950
 
8345
- SubprocessCompatibility.prototype.movePlaneElementsToOrigin = function(plane) {
8951
+ /**
8952
+ * @param {CanvasPlane} plane
8953
+ */
8954
+ SubprocessCompatibility.prototype._movePlaneElementsToOrigin = function(plane) {
8346
8955
  var elements = plane.get('planeElement');
8347
8956
 
8348
8957
  // get bounding box of all elements
@@ -8366,33 +8975,50 @@
8366
8975
  });
8367
8976
  };
8368
8977
 
8369
-
8370
- SubprocessCompatibility.prototype.moveToDiPlane = function(diElement, newPlane) {
8978
+ /**
8979
+ * @param {ModdleElement} diElement
8980
+ * @param {CanvasPlane} newPlane
8981
+ */
8982
+ SubprocessCompatibility.prototype._moveToDiPlane = function(diElement, newPlane) {
8371
8983
  var containingDiagram = findRootDiagram(diElement);
8372
8984
 
8373
8985
  // remove DI from old Plane and add it to the new one
8374
8986
  var parentPlaneElement = containingDiagram.plane.get('planeElement');
8987
+
8375
8988
  parentPlaneElement.splice(parentPlaneElement.indexOf(diElement), 1);
8989
+
8376
8990
  newPlane.get('planeElement').push(diElement);
8377
8991
  };
8378
8992
 
8993
+ /**
8994
+ * @param {ModdleElement} businessObject
8995
+ *
8996
+ * @return {ModdleElement}
8997
+ */
8998
+ SubprocessCompatibility.prototype._createDiagram = function(businessObject) {
8999
+ var plane = this._moddle.create('bpmndi:BPMNPlane', {
9000
+ bpmnElement: businessObject
9001
+ });
8379
9002
 
8380
- SubprocessCompatibility.prototype.createDiagram = function(bo) {
8381
- var plane = this._moddle.create('bpmndi:BPMNPlane', { bpmnElement: bo });
8382
9003
  var diagram = this._moddle.create('bpmndi:BPMNDiagram', {
8383
9004
  plane: plane
8384
9005
  });
9006
+
8385
9007
  plane.$parent = diagram;
8386
- plane.bpmnElement = bo;
9008
+
9009
+ plane.bpmnElement = businessObject;
9010
+
8387
9011
  diagram.$parent = this._definitions;
9012
+
8388
9013
  this._definitions.diagrams.push(diagram);
9014
+
8389
9015
  return diagram;
8390
9016
  };
8391
9017
 
8392
9018
  SubprocessCompatibility.$inject = [ 'eventBus', 'moddle' ];
8393
9019
 
8394
9020
 
8395
- // helpers //////////////////////////
9021
+ // helpers //////////
8396
9022
 
8397
9023
  function findRootDiagram(element) {
8398
9024
  if (is$1(element, 'bpmndi:BPMNDiagram')) {
@@ -8402,6 +9028,11 @@
8402
9028
  }
8403
9029
  }
8404
9030
 
9031
+ /**
9032
+ * @param {CanvasPlane} plane
9033
+ *
9034
+ * @return {Rect}
9035
+ */
8405
9036
  function getPlaneBounds(plane) {
8406
9037
  var planeTrbl = {
8407
9038
  top: Infinity,
@@ -8424,8 +9055,14 @@
8424
9055
  return asBounds(planeTrbl);
8425
9056
  }
8426
9057
 
8427
- function shouldMoveToPlane(bo, plane) {
8428
- var parent = bo.$parent;
9058
+ /**
9059
+ * @param {ModdleElement} businessObject
9060
+ * @param {CanvasPlane} plane
9061
+ *
9062
+ * @return {boolean}
9063
+ */
9064
+ function shouldMoveToPlane(businessObject, plane) {
9065
+ var parent = businessObject.$parent;
8429
9066
 
8430
9067
  // don't move elements that are already on the plane
8431
9068
  if (!is$1(parent, 'bpmn:SubProcess') || parent === plane.bpmnElement) {
@@ -8434,18 +9071,35 @@
8434
9071
 
8435
9072
  // dataAssociations are children of the subprocess but rendered on process level
8436
9073
  // cf. https://github.com/bpmn-io/bpmn-js/issues/1619
8437
- if (isAny(bo, [ 'bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation' ])) {
9074
+ if (isAny(businessObject, [ 'bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation' ])) {
8438
9075
  return false;
8439
9076
  }
8440
9077
 
8441
9078
  return true;
8442
9079
  }
8443
9080
 
9081
+ /**
9082
+ * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
9083
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
9084
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
9085
+ * @typedef {import('diagram-js/lib/features/overlays/Overlays').default} Overlays
9086
+ *
9087
+ * @typedef {import('../../model/Types').Element} Element
9088
+ * @typedef {import('../../model/Types').Parent} Parent
9089
+ * @typedef {import('../../model/Types').Shape} Shape
9090
+ */
9091
+
8444
9092
  var LOW_PRIORITY$1 = 250;
8445
9093
  var ARROW_DOWN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>';
8446
9094
 
8447
9095
  var EMPTY_MARKER = 'bjs-drilldown-empty';
8448
9096
 
9097
+ /**
9098
+ * @param {Canvas} canvas
9099
+ * @param {EventBus} eventBus
9100
+ * @param {ElementRegistry} elementRegistry
9101
+ * @param {Overlays} overlays
9102
+ */
8449
9103
  function DrilldownOverlayBehavior(
8450
9104
  canvas, eventBus, elementRegistry, overlays
8451
9105
  ) {
@@ -8462,10 +9116,10 @@
8462
9116
  var shape = context.shape;
8463
9117
 
8464
9118
  // Add overlay to the collapsed shape
8465
- if (self.canDrillDown(shape)) {
8466
- self.addOverlay(shape);
9119
+ if (self._canDrillDown(shape)) {
9120
+ self._addOverlay(shape);
8467
9121
  } else {
8468
- self.removeOverlay(shape);
9122
+ self._removeOverlay(shape);
8469
9123
  }
8470
9124
  }, true);
8471
9125
 
@@ -8474,10 +9128,10 @@
8474
9128
  var shape = context.shape;
8475
9129
 
8476
9130
  // Add overlay to the collapsed shape
8477
- if (self.canDrillDown(shape)) {
8478
- self.addOverlay(shape);
9131
+ if (self._canDrillDown(shape)) {
9132
+ self._addOverlay(shape);
8479
9133
  } else {
8480
- self.removeOverlay(shape);
9134
+ self._removeOverlay(shape);
8481
9135
  }
8482
9136
  }, true);
8483
9137
 
@@ -8489,13 +9143,13 @@
8489
9143
  shape = context.shape;
8490
9144
 
8491
9145
  // Add overlay to the collapsed shape
8492
- if (self.canDrillDown(shape)) {
8493
- self.addOverlay(shape);
9146
+ if (self._canDrillDown(shape)) {
9147
+ self._addOverlay(shape);
8494
9148
  }
8495
9149
 
8496
- self.updateDrilldownOverlay(oldParent);
8497
- self.updateDrilldownOverlay(newParent);
8498
- self.updateDrilldownOverlay(shape);
9150
+ self._updateDrilldownOverlay(oldParent);
9151
+ self._updateDrilldownOverlay(newParent);
9152
+ self._updateDrilldownOverlay(shape);
8499
9153
  }, true);
8500
9154
 
8501
9155
 
@@ -8506,21 +9160,21 @@
8506
9160
  shape = context.shape;
8507
9161
 
8508
9162
  // Add overlay to the collapsed shape
8509
- if (self.canDrillDown(shape)) {
8510
- self.addOverlay(shape);
9163
+ if (self._canDrillDown(shape)) {
9164
+ self._addOverlay(shape);
8511
9165
  }
8512
9166
 
8513
- self.updateDrilldownOverlay(oldParent);
8514
- self.updateDrilldownOverlay(newParent);
8515
- self.updateDrilldownOverlay(shape);
9167
+ self._updateDrilldownOverlay(oldParent);
9168
+ self._updateDrilldownOverlay(newParent);
9169
+ self._updateDrilldownOverlay(shape);
8516
9170
  }, true);
8517
9171
 
8518
9172
 
8519
9173
  eventBus.on('import.render.complete', function() {
8520
9174
  elementRegistry.filter(function(e) {
8521
- return self.canDrillDown(e);
9175
+ return self._canDrillDown(e);
8522
9176
  }).map(function(el) {
8523
- self.addOverlay(el);
9177
+ self._addOverlay(el);
8524
9178
  });
8525
9179
  });
8526
9180
 
@@ -8528,7 +9182,10 @@
8528
9182
 
8529
9183
  e(DrilldownOverlayBehavior, CommandInterceptor);
8530
9184
 
8531
- DrilldownOverlayBehavior.prototype.updateDrilldownOverlay = function(shape) {
9185
+ /**
9186
+ * @param {Shape} shape
9187
+ */
9188
+ DrilldownOverlayBehavior.prototype._updateDrilldownOverlay = function(shape) {
8532
9189
  var canvas = this._canvas;
8533
9190
 
8534
9191
  if (!shape) {
@@ -8536,51 +9193,61 @@
8536
9193
  }
8537
9194
 
8538
9195
  var root = canvas.findRoot(shape);
9196
+
8539
9197
  if (root) {
8540
- this.updateOverlayVisibility(root);
9198
+ this._updateOverlayVisibility(root);
8541
9199
  }
8542
9200
  };
8543
9201
 
8544
-
8545
- DrilldownOverlayBehavior.prototype.canDrillDown = function(element) {
9202
+ /**
9203
+ * @param {Element} element
9204
+ *
9205
+ * @return {boolean}
9206
+ */
9207
+ DrilldownOverlayBehavior.prototype._canDrillDown = function(element) {
8546
9208
  var canvas = this._canvas;
9209
+
8547
9210
  return is$1(element, 'bpmn:SubProcess') && canvas.findRoot(getPlaneIdFromShape(element));
8548
9211
  };
8549
9212
 
8550
9213
  /**
8551
- * Updates visibility of the drilldown overlay. If the plane has no elements,
8552
- * the drilldown will be only shown when the element is selected.
9214
+ * Update the visibility of the drilldown overlay. If the plane has no elements,
9215
+ * the drilldown will only be shown when the element is selected.
8553
9216
  *
8554
- * @param {djs.model.Shape|djs.model.Root} element collapsed shape or root element
9217
+ * @param {Parent} element The collapsed root or shape.
8555
9218
  */
8556
- DrilldownOverlayBehavior.prototype.updateOverlayVisibility = function(element) {
9219
+ DrilldownOverlayBehavior.prototype._updateOverlayVisibility = function(element) {
8557
9220
  var overlays = this._overlays;
8558
9221
 
8559
- var bo = element.businessObject;
9222
+ var businessObject = getBusinessObject(element);
8560
9223
 
8561
- var overlay = overlays.get({ element: bo.id, type: 'drilldown' })[0];
9224
+ var overlay = overlays.get({ element: businessObject.id, type: 'drilldown' })[0];
8562
9225
 
8563
9226
  if (!overlay) {
8564
9227
  return;
8565
9228
  }
8566
9229
 
8567
- var hasContent = bo && bo.flowElements && bo.flowElements.length;
8568
- classes(overlay.html).toggle(EMPTY_MARKER, !hasContent);
9230
+ var hasFlowElements = businessObject
9231
+ && businessObject.get('flowElements')
9232
+ && businessObject.get('flowElements').length;
9233
+
9234
+ classes(overlay.html).toggle(EMPTY_MARKER, !hasFlowElements);
8569
9235
  };
8570
9236
 
8571
9237
  /**
8572
- * Attaches a drilldown button to the given element. We assume that the plane has
8573
- * the same id as the element.
9238
+ * Add a drilldown button to the given element assuming the plane has the same
9239
+ * ID as the element.
8574
9240
  *
8575
- * @param {djs.model.Shape} element collapsed shape
9241
+ * @param {Shape} element The collapsed shape.
8576
9242
  */
8577
- DrilldownOverlayBehavior.prototype.addOverlay = function(element) {
8578
- var canvas = this._canvas;
8579
- var overlays = this._overlays;
9243
+ DrilldownOverlayBehavior.prototype._addOverlay = function(element) {
9244
+ var canvas = this._canvas,
9245
+ overlays = this._overlays;
8580
9246
 
8581
9247
  var existingOverlays = overlays.get({ element: element, type: 'drilldown' });
9248
+
8582
9249
  if (existingOverlays.length) {
8583
- this.removeOverlay(element);
9250
+ this._removeOverlay(element);
8584
9251
  }
8585
9252
 
8586
9253
  var button = domify$1('<button class="bjs-drilldown">' + ARROW_DOWN_SVG + '</button>');
@@ -8597,10 +9264,10 @@
8597
9264
  html: button
8598
9265
  });
8599
9266
 
8600
- this.updateOverlayVisibility(element);
9267
+ this._updateOverlayVisibility(element);
8601
9268
  };
8602
9269
 
8603
- DrilldownOverlayBehavior.prototype.removeOverlay = function(element) {
9270
+ DrilldownOverlayBehavior.prototype._removeOverlay = function(element) {
8604
9271
  var overlays = this._overlays;
8605
9272
 
8606
9273
  overlays.remove({
@@ -9106,7 +9773,6 @@
9106
9773
  */
9107
9774
  function DefaultRenderer(eventBus, styles) {
9108
9775
 
9109
- //
9110
9776
  BaseRenderer.call(this, eventBus, DEFAULT_RENDER_PRIORITY);
9111
9777
 
9112
9778
  this.CONNECTION_STYLE = styles.style([ 'no-fill' ], { strokeWidth: 5, stroke: 'fuchsia' });
@@ -9117,10 +9783,16 @@
9117
9783
  e(DefaultRenderer, BaseRenderer);
9118
9784
 
9119
9785
 
9786
+ /**
9787
+ * @private
9788
+ */
9120
9789
  DefaultRenderer.prototype.canRender = function() {
9121
9790
  return true;
9122
9791
  };
9123
9792
 
9793
+ /**
9794
+ * @private
9795
+ */
9124
9796
  DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
9125
9797
  var rect = create$1('rect');
9126
9798
 
@@ -9142,6 +9814,9 @@
9142
9814
  return rect;
9143
9815
  };
9144
9816
 
9817
+ /**
9818
+ * @private
9819
+ */
9145
9820
  DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
9146
9821
 
9147
9822
  var line = createLine(connection.waypoints, assign$1({}, this.CONNECTION_STYLE, attrs || {}));
@@ -9150,6 +9825,9 @@
9150
9825
  return line;
9151
9826
  };
9152
9827
 
9828
+ /**
9829
+ * @private
9830
+ */
9153
9831
  DefaultRenderer.prototype.getShapePath = function getShapePath(shape) {
9154
9832
 
9155
9833
  var x = shape.x,
@@ -9168,6 +9846,9 @@
9168
9846
  return componentsToPath(shapePath);
9169
9847
  };
9170
9848
 
9849
+ /**
9850
+ * @private
9851
+ */
9171
9852
  DefaultRenderer.prototype.getConnectionPath = function getConnectionPath(connection) {
9172
9853
  var waypoints = connection.waypoints;
9173
9854
 
@@ -9185,7 +9866,6 @@
9185
9866
  return componentsToPath(connectionPath);
9186
9867
  };
9187
9868
 
9188
-
9189
9869
  DefaultRenderer.$inject = [ 'eventBus', 'styles' ];
9190
9870
 
9191
9871
  /**
@@ -9212,7 +9892,7 @@
9212
9892
  * Builds a style definition from a className, a list of traits and an object of additional attributes.
9213
9893
  *
9214
9894
  * @param {string} className
9215
- * @param {Array<string>} traits
9895
+ * @param {string[]} traits
9216
9896
  * @param {Object} additionalAttrs
9217
9897
  *
9218
9898
  * @return {Object} the style defintion
@@ -9226,7 +9906,7 @@
9226
9906
  /**
9227
9907
  * Builds a style definition from a list of traits and an object of additional attributes.
9228
9908
  *
9229
- * @param {Array<string>} traits
9909
+ * @param {string[]} traits
9230
9910
  * @param {Object} additionalAttrs
9231
9911
  *
9232
9912
  * @return {Object} the style defintion
@@ -9255,6 +9935,9 @@
9255
9935
  };
9256
9936
  }
9257
9937
 
9938
+ /**
9939
+ * @type { import('didi').ModuleDeclaration }
9940
+ */
9258
9941
  var DrawModule = {
9259
9942
  __init__: [ 'defaultRenderer' ],
9260
9943
  defaultRenderer: [ 'type', DefaultRenderer ],
@@ -9336,15 +10019,34 @@
9336
10019
  }
9337
10020
 
9338
10021
  /**
9339
- * @typedef {import('.').ConnectionLike} ConnectionLike
9340
- * @typedef {import('.').RootLike} RootLike
9341
- * @typedef {import('.').ShapeLike} ShapeLike
9342
- *
9343
- * @typedef {import('./Canvas').CanvasConfig} CanvasConfig
9344
- * @typedef {import('./Canvas').CanvasLayer} CanvasLayer
9345
- * @typedef {import('./Canvas').CanvasLayers} CanvasLayers
9346
- * @typedef {import('./Canvas').CanvasPlane} CanvasPlane
9347
- * @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
10022
+ * @typedef {import('./Types').ConnectionLike} ConnectionLike
10023
+ * @typedef {import('./Types').RootLike} RootLike
10024
+ * @typedef {import('./Types').ParentLike } ParentLike
10025
+ * @typedef {import('./Types').ShapeLike} ShapeLike
10026
+ *
10027
+ * @typedef { {
10028
+ * container?: HTMLElement;
10029
+ * deferUpdate?: boolean;
10030
+ * width?: number;
10031
+ * height?: number;
10032
+ * } } CanvasConfig
10033
+ * @typedef { {
10034
+ * group: SVGElement;
10035
+ * index: number;
10036
+ * visible: boolean;
10037
+ * } } CanvasLayer
10038
+ * @typedef { {
10039
+ * [key: string]: CanvasLayer;
10040
+ * } } CanvasLayers
10041
+ * @typedef { {
10042
+ * rootElement: ShapeLike;
10043
+ * layer: CanvasLayer;
10044
+ * } } CanvasPlane
10045
+ * @typedef { {
10046
+ * scale: number;
10047
+ * inner: Rect;
10048
+ * outer: Dimensions;
10049
+ * } & Rect } CanvasViewbox
9348
10050
  *
9349
10051
  * @typedef {import('./ElementRegistry').default} ElementRegistry
9350
10052
  * @typedef {import('./EventBus').default} EventBus
@@ -9685,7 +10387,7 @@
9685
10387
  /**
9686
10388
  * Shows a given layer.
9687
10389
  *
9688
- * @param {string} layer The name of the layer.
10390
+ * @param {string} name The name of the layer.
9689
10391
  *
9690
10392
  * @return {SVGElement} The SVG element of the layer.
9691
10393
  */
@@ -9721,7 +10423,7 @@
9721
10423
  /**
9722
10424
  * Hides a given layer.
9723
10425
  *
9724
- * @param {string} layer The name of the layer.
10426
+ * @param {string} name The name of the layer.
9725
10427
  *
9726
10428
  * @return {SVGElement} The SVG element of the layer.
9727
10429
  */
@@ -9863,7 +10565,7 @@
9863
10565
  *
9864
10566
  * @event element.marker.update
9865
10567
  * @type {Object}
9866
- * @property {Base} element the shape
10568
+ * @property {Element} element the shape
9867
10569
  * @property {SVGElement} gfx the graphical representation of the shape
9868
10570
  * @property {string} marker
9869
10571
  * @property {boolean} add true if the marker was added, false if it got removed
@@ -9969,7 +10671,7 @@
9969
10671
  /**
9970
10672
  * Adds a given root element and returns it.
9971
10673
  *
9972
- * @param {ShapeLike} [rootElement] The root element to be added.
10674
+ * @param {RootLike} [rootElement] The root element to be added.
9973
10675
  *
9974
10676
  * @return {RootLike} The added root element or an implicit root element.
9975
10677
  */
@@ -10005,9 +10707,9 @@
10005
10707
  /**
10006
10708
  * Removes a given root element and returns it.
10007
10709
  *
10008
- * @param {ShapeLike|string} rootElement The root element or its ID.
10710
+ * @param {RootLike|string} rootElement element or element ID
10009
10711
  *
10010
- * @return {ShapeLike|undefined} The removed root element.
10712
+ * @return {RootLike|undefined} removed element
10011
10713
  */
10012
10714
  Canvas.prototype.removeRootElement = function(rootElement) {
10013
10715
 
@@ -10049,11 +10751,7 @@
10049
10751
  *
10050
10752
  * @return {RootLike} The set root element.
10051
10753
  */
10052
- Canvas.prototype.setRootElement = function(rootElement, override) {
10053
-
10054
- if (isDefined(override)) {
10055
- throw new Error('override not supported');
10056
- }
10754
+ Canvas.prototype.setRootElement = function(rootElement) {
10057
10755
 
10058
10756
  if (rootElement === this._rootElement) {
10059
10757
  return;
@@ -10210,7 +10908,7 @@
10210
10908
  * Adds a shape to the canvas.
10211
10909
  *
10212
10910
  * @param {ShapeLike} shape The shape to be added
10213
- * @param {ShapeLike} [parent] The shape's parent.
10911
+ * @param {ParentLike} [parent] The shape's parent.
10214
10912
  * @param {number} [parentIndex] The index at which to add the shape to the parent's children.
10215
10913
  *
10216
10914
  * @return {ShapeLike} The added shape.
@@ -10223,7 +10921,7 @@
10223
10921
  * Adds a connection to the canvas.
10224
10922
  *
10225
10923
  * @param {ConnectionLike} connection The connection to be added.
10226
- * @param {ShapeLike} [parent] The connection's parent.
10924
+ * @param {ParentLike} [parent] The connection's parent.
10227
10925
  * @param {number} [parentIndex] The index at which to add the connection to the parent's children.
10228
10926
  *
10229
10927
  * @return {ConnectionLike} The added connection.
@@ -10590,7 +11288,7 @@
10590
11288
  * The getter may return a cached zoom level. Call it with `false` as the first
10591
11289
  * argument to force recomputation of the current level.
10592
11290
  *
10593
- * @param {number|string} [newScale] The new zoom level, either a number,
11291
+ * @param {number|'fit-viewport'} [newScale] The new zoom level, either a number,
10594
11292
  * i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
10595
11293
  * @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
10596
11294
  *
@@ -10785,11 +11483,12 @@
10785
11483
  var ELEMENT_ID = 'data-element-id';
10786
11484
 
10787
11485
  /**
10788
- * @typedef {import('.').ElementLike} ElementLike
11486
+ * @typedef {import('./Types').ElementLike} ElementLike
10789
11487
  *
10790
11488
  * @typedef {import('./EventBus').default} EventBus
10791
11489
  *
10792
- * @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
11490
+ * @typedef { (element: ElementLike, gfx: SVGElement) => boolean|any } ElementRegistryFilterCallback
11491
+ * @typedef { (element: ElementLike, gfx: SVGElement) => any } ElementRegistryForEachCallback
10793
11492
  */
10794
11493
 
10795
11494
  /**
@@ -10801,6 +11500,16 @@
10801
11500
  * @param {EventBus} eventBus
10802
11501
  */
10803
11502
  function ElementRegistry(eventBus) {
11503
+
11504
+ /**
11505
+ * @type { {
11506
+ * [id: string]: {
11507
+ * element: ElementLike;
11508
+ * gfx?: SVGElement;
11509
+ * secondaryGfx?: SVGElement;
11510
+ * }
11511
+ * } }
11512
+ */
10804
11513
  this._elements = {};
10805
11514
 
10806
11515
  this._eventBus = eventBus;
@@ -10886,7 +11595,7 @@
10886
11595
  /**
10887
11596
  * Update the graphical representation of an element.
10888
11597
  *
10889
- * @param {ElementLike|string} element The element or its ID.
11598
+ * @param {ElementLike|string} filter The element or its ID.
10890
11599
  * @param {SVGElement} gfx The new graphical representation.
10891
11600
  * @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
10892
11601
  */
@@ -10937,7 +11646,7 @@
10937
11646
  /**
10938
11647
  * Return all elements that match a given filter function.
10939
11648
  *
10940
- * @param {ElementRegistryCallback} fn The filter function.
11649
+ * @param {ElementRegistryFilterCallback} fn The filter function.
10941
11650
  *
10942
11651
  * @return {ElementLike[]} The matching elements.
10943
11652
  */
@@ -10957,7 +11666,7 @@
10957
11666
  /**
10958
11667
  * Return the first element that matches the given filter function.
10959
11668
  *
10960
- * @param {Function} fn The filter function.
11669
+ * @param {ElementRegistryFilterCallback} fn The filter function.
10961
11670
  *
10962
11671
  * @return {ElementLike|undefined} The matching element.
10963
11672
  */
@@ -10989,7 +11698,7 @@
10989
11698
  /**
10990
11699
  * Execute a given function for each element.
10991
11700
  *
10992
- * @param {Function} fn The function to execute.
11701
+ * @param {ElementRegistryForEachCallback} fn The function to execute.
10993
11702
  */
10994
11703
  ElementRegistry.prototype.forEach = function(fn) {
10995
11704
 
@@ -11376,19 +12085,26 @@
11376
12085
  outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
11377
12086
  incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
11378
12087
 
12088
+ /**
12089
+ * @typedef {import('./Types').Element} Element
12090
+ * @typedef {import('./Types').Shape} Shape
12091
+ * @typedef {import('./Types').Root} Root
12092
+ * @typedef {import('./Types').Label} Label
12093
+ * @typedef {import('./Types').Connection} Connection
12094
+ */
12095
+
11379
12096
  /**
11380
12097
  * The basic graphical representation
11381
12098
  *
11382
12099
  * @class
11383
- *
11384
- * @abstract
12100
+ * @constructor
11385
12101
  */
11386
- function Base$1() {
12102
+ function ElementImpl() {
11387
12103
 
11388
12104
  /**
11389
12105
  * The object that backs up the shape
11390
12106
  *
11391
- * @name Base#businessObject
12107
+ * @name Element#businessObject
11392
12108
  * @type Object
11393
12109
  */
11394
12110
  Object.defineProperty(this, 'businessObject', {
@@ -11399,7 +12115,7 @@
11399
12115
  /**
11400
12116
  * Single label support, will mapped to multi label array
11401
12117
  *
11402
- * @name Base#label
12118
+ * @name Element#label
11403
12119
  * @type Object
11404
12120
  */
11405
12121
  Object.defineProperty(this, 'label', {
@@ -11422,7 +12138,7 @@
11422
12138
  /**
11423
12139
  * The parent shape
11424
12140
  *
11425
- * @name Base#parent
12141
+ * @name Element#parent
11426
12142
  * @type Shape
11427
12143
  */
11428
12144
  parentRefs.bind(this, 'parent');
@@ -11430,7 +12146,7 @@
11430
12146
  /**
11431
12147
  * The list of labels
11432
12148
  *
11433
- * @name Base#labels
12149
+ * @name Element#labels
11434
12150
  * @type Label
11435
12151
  */
11436
12152
  labelRefs.bind(this, 'labels');
@@ -11438,7 +12154,7 @@
11438
12154
  /**
11439
12155
  * The list of outgoing connections
11440
12156
  *
11441
- * @name Base#outgoing
12157
+ * @name Element#outgoing
11442
12158
  * @type Array<Connection>
11443
12159
  */
11444
12160
  outgoingRefs.bind(this, 'outgoing');
@@ -11446,7 +12162,7 @@
11446
12162
  /**
11447
12163
  * The list of incoming connections
11448
12164
  *
11449
- * @name Base#incoming
12165
+ * @name Element#incoming
11450
12166
  * @type Array<Connection>
11451
12167
  */
11452
12168
  incomingRefs.bind(this, 'incoming');
@@ -11459,40 +12175,40 @@
11459
12175
  * @class
11460
12176
  * @constructor
11461
12177
  *
11462
- * @extends Base
12178
+ * @extends ElementImpl
11463
12179
  */
11464
- function Shape() {
11465
- Base$1.call(this);
12180
+ function ShapeImpl() {
12181
+ ElementImpl.call(this);
11466
12182
 
11467
12183
  /**
11468
12184
  * Indicates frame shapes
11469
12185
  *
11470
- * @name Shape#isFrame
12186
+ * @name ShapeImpl#isFrame
11471
12187
  * @type boolean
11472
12188
  */
11473
12189
 
11474
12190
  /**
11475
12191
  * The list of children
11476
12192
  *
11477
- * @name Shape#children
11478
- * @type Array<Base>
12193
+ * @name ShapeImpl#children
12194
+ * @type Element[]
11479
12195
  */
11480
12196
  parentRefs.bind(this, 'children');
11481
12197
 
11482
12198
  /**
11483
- * @name Shape#host
12199
+ * @name ShapeImpl#host
11484
12200
  * @type Shape
11485
12201
  */
11486
12202
  attacherRefs.bind(this, 'host');
11487
12203
 
11488
12204
  /**
11489
- * @name Shape#attachers
12205
+ * @name ShapeImpl#attachers
11490
12206
  * @type Shape
11491
12207
  */
11492
12208
  attacherRefs.bind(this, 'attachers');
11493
12209
  }
11494
12210
 
11495
- e(Shape, Base$1);
12211
+ e(ShapeImpl, ElementImpl);
11496
12212
 
11497
12213
 
11498
12214
  /**
@@ -11501,13 +12217,21 @@
11501
12217
  * @class
11502
12218
  * @constructor
11503
12219
  *
11504
- * @extends Shape
12220
+ * @extends ElementImpl
11505
12221
  */
11506
- function Root() {
11507
- Shape.call(this);
12222
+ function RootImpl() {
12223
+ ElementImpl.call(this);
12224
+
12225
+ /**
12226
+ * The list of children
12227
+ *
12228
+ * @name RootImpl#children
12229
+ * @type Element[]
12230
+ */
12231
+ parentRefs.bind(this, 'children');
11508
12232
  }
11509
12233
 
11510
- e(Root, Shape);
12234
+ e(RootImpl, ShapeImpl);
11511
12235
 
11512
12236
 
11513
12237
  /**
@@ -11516,21 +12240,21 @@
11516
12240
  * @class
11517
12241
  * @constructor
11518
12242
  *
11519
- * @extends Shape
12243
+ * @extends ShapeImpl
11520
12244
  */
11521
- function Label() {
11522
- Shape.call(this);
12245
+ function LabelImpl() {
12246
+ ShapeImpl.call(this);
11523
12247
 
11524
12248
  /**
11525
12249
  * The labeled element
11526
12250
  *
11527
- * @name Label#labelTarget
11528
- * @type Base
12251
+ * @name LabelImpl#labelTarget
12252
+ * @type Element
11529
12253
  */
11530
12254
  labelRefs.bind(this, 'labelTarget');
11531
12255
  }
11532
12256
 
11533
- e(Label, Shape);
12257
+ e(LabelImpl, ShapeImpl);
11534
12258
 
11535
12259
 
11536
12260
  /**
@@ -11539,45 +12263,69 @@
11539
12263
  * @class
11540
12264
  * @constructor
11541
12265
  *
11542
- * @extends Base
12266
+ * @extends ElementImpl
11543
12267
  */
11544
- function Connection() {
11545
- Base$1.call(this);
12268
+ function ConnectionImpl() {
12269
+ ElementImpl.call(this);
11546
12270
 
11547
12271
  /**
11548
12272
  * The element this connection originates from
11549
12273
  *
11550
- * @name Connection#source
11551
- * @type Base
12274
+ * @name ConnectionImpl#source
12275
+ * @type Element
11552
12276
  */
11553
12277
  outgoingRefs.bind(this, 'source');
11554
12278
 
11555
12279
  /**
11556
12280
  * The element this connection points to
11557
12281
  *
11558
- * @name Connection#target
11559
- * @type Base
12282
+ * @name ConnectionImpl#target
12283
+ * @type Element
11560
12284
  */
11561
12285
  incomingRefs.bind(this, 'target');
11562
12286
  }
11563
12287
 
11564
- e(Connection, Base$1);
12288
+ e(ConnectionImpl, ElementImpl);
11565
12289
 
11566
12290
 
11567
12291
  var types$6 = {
11568
- connection: Connection,
11569
- shape: Shape,
11570
- label: Label,
11571
- root: Root
12292
+ connection: ConnectionImpl,
12293
+ shape: ShapeImpl,
12294
+ label: LabelImpl,
12295
+ root: RootImpl
11572
12296
  };
11573
12297
 
11574
12298
  /**
11575
- * Creates a model element of the given type.
12299
+ * Creates a root element.
12300
+ *
12301
+ * @overlord
12302
+ *
12303
+ * @example
12304
+ *
12305
+ * ```
12306
+ * import * as Model from 'diagram-js/lib/model';
12307
+ *
12308
+ * const root = Model.create('root', {
12309
+ * x: 100,
12310
+ * y: 100,
12311
+ * width: 100,
12312
+ * height: 100
12313
+ * });
12314
+ * ```
12315
+ *
12316
+ * @param {'root'} type
12317
+ * @param {any} [attrs]
12318
+ *
12319
+ * @return {Root}
12320
+ */
12321
+ /**
12322
+ * Creates a connection.
11576
12323
  *
11577
- * @method create
12324
+ * @overlord
11578
12325
  *
11579
12326
  * @example
11580
12327
  *
12328
+ * ```
11581
12329
  * import * as Model from 'diagram-js/lib/model';
11582
12330
  *
11583
12331
  * const connection = Model.create('connection', {
@@ -11586,33 +12334,56 @@
11586
12334
  * { x: 200, y: 100 }
11587
12335
  * ]
11588
12336
  * });
12337
+ * ```
11589
12338
  *
11590
- * const label = Model.create('label', {
11591
- * x: 100,
11592
- * y: 100,
11593
- * width: 100,
11594
- * height: 100,
11595
- * labelTarget: shape
11596
- * });
12339
+ * @param {'connection'} type
12340
+ * @param {any} [attrs]
11597
12341
  *
11598
- * const root = Model.create('root', {
12342
+ * @return {Connection}
12343
+ */
12344
+ /**
12345
+ * Creates a shape.
12346
+ *
12347
+ * @overlord
12348
+ *
12349
+ * @example
12350
+ *
12351
+ * ```
12352
+ * import * as Model from 'diagram-js/lib/model';
12353
+ *
12354
+ * const shape = Model.create('shape', {
11599
12355
  * x: 100,
11600
12356
  * y: 100,
11601
12357
  * width: 100,
11602
12358
  * height: 100
11603
12359
  * });
12360
+ * ```
11604
12361
  *
11605
- * const shape = Model.create('shape', {
12362
+ * @param {'shape'} type
12363
+ * @param {any} [attrs]
12364
+ *
12365
+ * @return {Shape}
12366
+ */
12367
+ /**
12368
+ * Creates a label.
12369
+ *
12370
+ * @example
12371
+ *
12372
+ * ```
12373
+ * import * as Model from 'diagram-js/lib/model';
12374
+ *
12375
+ * const label = Model.create('label', {
11606
12376
  * x: 100,
11607
12377
  * y: 100,
11608
12378
  * width: 100,
11609
- * height: 100
12379
+ * height: 100,
12380
+ * labelTarget: shape
11610
12381
  * });
12382
+ * ```
11611
12383
  *
11612
- * @param {string} type The type of model element to be created.
11613
- * @param {Object} attrs Attributes to create the model element with.
11614
- *
11615
- * @return {Connection|Label|Root|Shape} The created model element.
12384
+ * @param {'label'} type
12385
+ * @param {any} [attrs]
12386
+ * @return {Label}
11616
12387
  */
11617
12388
  function create(type, attrs) {
11618
12389
  var Type = types$6[type];
@@ -11623,22 +12394,20 @@
11623
12394
  }
11624
12395
 
11625
12396
  /**
11626
- * @typedef {import('../model/index').Base} Base
11627
- * @typedef {import('../model/index').Connection} Connection
11628
- * @typedef {import('../model/index').Label} Label
11629
- * @typedef {import('../model/index').Root} Root
11630
- * @typedef {import('../model/index').Shape} Shape
11631
- * @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
11632
- * @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
11633
- * @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
11634
- * @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
12397
+ * @typedef {import('../model/Types').Element} Element
12398
+ * @typedef {import('../model/Types').Connection} Connection
12399
+ * @typedef {import('../model/Types').Label} Label
12400
+ * @typedef {import('../model/Types').Root} Root
12401
+ * @typedef {import('../model/Types').Shape} Shape
11635
12402
  */
11636
12403
 
11637
12404
  /**
11638
12405
  * A factory for model elements.
11639
12406
  *
11640
- * @class
11641
- * @constructor
12407
+ * @template {Connection} [T=Connection]
12408
+ * @template {Label} [U=Label]
12409
+ * @template {Root} [V=Root]
12410
+ * @template {Shape} [W=Shape]
11642
12411
  */
11643
12412
  function ElementFactory() {
11644
12413
  this._uid = 12;
@@ -11647,9 +12416,9 @@
11647
12416
  /**
11648
12417
  * Create a root element.
11649
12418
  *
11650
- * @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
12419
+ * @param {Partial<Root>} [attrs]
11651
12420
  *
11652
- * @return {Root} The created root element.
12421
+ * @return {V} The created root element.
11653
12422
  */
11654
12423
  ElementFactory.prototype.createRoot = function(attrs) {
11655
12424
  return this.create('root', attrs);
@@ -11658,9 +12427,9 @@
11658
12427
  /**
11659
12428
  * Create a label.
11660
12429
  *
11661
- * @param {ModelAttrsLabel} attrs The attributes of the label to be created.
12430
+ * @param {Partial<Label>} [attrs]
11662
12431
  *
11663
- * @return {Label} The created label.
12432
+ * @return {U} The created label.
11664
12433
  */
11665
12434
  ElementFactory.prototype.createLabel = function(attrs) {
11666
12435
  return this.create('label', attrs);
@@ -11669,9 +12438,9 @@
11669
12438
  /**
11670
12439
  * Create a shape.
11671
12440
  *
11672
- * @param {ModelAttrsShape} attrs The attributes of the shape to be created.
12441
+ * @param {Partial<Shape>} [attrs]
11673
12442
  *
11674
- * @return {Shape} The created shape.
12443
+ * @return {W} The created shape.
11675
12444
  */
11676
12445
  ElementFactory.prototype.createShape = function(attrs) {
11677
12446
  return this.create('shape', attrs);
@@ -11680,21 +12449,44 @@
11680
12449
  /**
11681
12450
  * Create a connection.
11682
12451
  *
11683
- * @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
12452
+ * @param {Partial<Connection>} [attrs]
11684
12453
  *
11685
- * @return {Connection} The created connection.
12454
+ * @return {T} The created connection.
11686
12455
  */
11687
12456
  ElementFactory.prototype.createConnection = function(attrs) {
11688
12457
  return this.create('connection', attrs);
11689
12458
  };
11690
12459
 
11691
12460
  /**
11692
- * Create a model element of the given type with the given attributes.
12461
+ * Create a root element.
12462
+ *
12463
+ * @overlord
12464
+ * @param {'root'} type
12465
+ * @param {Partial<Root>} [attrs]
12466
+ * @return {V}
12467
+ */
12468
+ /**
12469
+ * Create a shape.
12470
+ *
12471
+ * @overlord
12472
+ * @param {'shape'} type
12473
+ * @param {Partial<Shape>} [attrs]
12474
+ * @return {W}
12475
+ */
12476
+ /**
12477
+ * Create a connection.
11693
12478
  *
11694
- * @param {string} type The type of the model element.
11695
- * @param {Object} attrs The attributes of the model element.
12479
+ * @overlord
12480
+ * @param {'connection'} type
12481
+ * @param {Partial<Connection>} [attrs]
12482
+ * @return {T}
12483
+ */
12484
+ /**
12485
+ * Create a label.
11696
12486
  *
11697
- * @return {Connection|Label|Root|Shape} The created model element.
12487
+ * @param {'label'} type
12488
+ * @param {Partial<Label>} [attrs]
12489
+ * @return {U}
11698
12490
  */
11699
12491
  ElementFactory.prototype.create = function(type, attrs) {
11700
12492
 
@@ -11714,13 +12506,27 @@
11714
12506
  var slice = Array.prototype.slice;
11715
12507
 
11716
12508
  /**
11717
- * @typedef {import('./EventBus').Event} Event
11718
- * @typedef {import('./EventBus').EventCallback} EventCallback
12509
+ * @typedef { {
12510
+ * stopPropagation(): void;
12511
+ * preventDefault(): void;
12512
+ * cancelBubble: boolean;
12513
+ * defaultPrevented: boolean;
12514
+ * returnValue: any;
12515
+ * } } Event
12516
+ */
12517
+
12518
+ /**
12519
+ * @template E
11719
12520
  *
11720
- * @typedef {Object} EventListener
11721
- * @property {Function} callback
11722
- * @property {EventListener|null} next
11723
- * @property {number} priority
12521
+ * @typedef { (event: E & Event, ...any) => any } EventBusEventCallback
12522
+ */
12523
+
12524
+ /**
12525
+ * @typedef { {
12526
+ * priority: number;
12527
+ * next: EventBusListener | null;
12528
+ * callback: EventBusEventCallback<any>;
12529
+ * } } EventBusListener
11724
12530
  */
11725
12531
 
11726
12532
  /**
@@ -11807,6 +12613,10 @@
11807
12613
  * ```
11808
12614
  */
11809
12615
  function EventBus() {
12616
+
12617
+ /**
12618
+ * @type { Record<string, EventBusListener> }
12619
+ */
11810
12620
  this._listeners = {};
11811
12621
 
11812
12622
  // cleanup on destroy on lowest priority to allow
@@ -11827,10 +12637,12 @@
11827
12637
  *
11828
12638
  * Returning anything but `undefined` from a listener will stop the listener propagation.
11829
12639
  *
11830
- * @param {string|string[]} events The event(s) to listen to.
11831
- * @param {number} [priority=1000] The priority with which to listen.
11832
- * @param {EventCallback} callback The callback.
11833
- * @param {*} [that] Value of `this` the callback will be called with.
12640
+ * @template T
12641
+ *
12642
+ * @param {string|string[]} events to subscribe to
12643
+ * @param {number} [priority=1000] listen priority
12644
+ * @param {EventBusEventCallback<T>} callback
12645
+ * @param {any} [that] callback context
11834
12646
  */
11835
12647
  EventBus.prototype.on = function(events, priority, callback, that) {
11836
12648
 
@@ -11872,12 +12684,14 @@
11872
12684
  /**
11873
12685
  * Register an event listener that is called only once.
11874
12686
  *
11875
- * @param {string} event The event to listen to.
11876
- * @param {number} [priority=1000] The priority with which to listen.
11877
- * @param {EventCallback} callback The callback.
11878
- * @param {*} [that] Value of `this` the callback will be called with.
12687
+ * @template T
12688
+ *
12689
+ * @param {string|string[]} events to subscribe to
12690
+ * @param {number} [priority=1000] the listen priority
12691
+ * @param {EventBusEventCallback<T>} callback
12692
+ * @param {any} [that] callback context
11879
12693
  */
11880
- EventBus.prototype.once = function(event, priority, callback, that) {
12694
+ EventBus.prototype.once = function(events, priority, callback, that) {
11881
12695
  var self = this;
11882
12696
 
11883
12697
  if (isFunction(priority)) {
@@ -11895,7 +12709,7 @@
11895
12709
 
11896
12710
  var result = callback.apply(that, arguments);
11897
12711
 
11898
- self.off(event, wrappedCallback);
12712
+ self.off(events, wrappedCallback);
11899
12713
 
11900
12714
  return result;
11901
12715
  }
@@ -11905,7 +12719,7 @@
11905
12719
  // callback
11906
12720
  wrappedCallback[FN_REF] = callback;
11907
12721
 
11908
- this.on(event, priority, wrappedCallback);
12722
+ this.on(events, priority, wrappedCallback);
11909
12723
  };
11910
12724
 
11911
12725
 
@@ -11914,8 +12728,8 @@
11914
12728
  *
11915
12729
  * If no callback is given, all listeners for a given event name are being removed.
11916
12730
  *
11917
- * @param {string|string[]} events The events.
11918
- * @param {EventCallback} [callback] The callback.
12731
+ * @param {string|string[]} events
12732
+ * @param {EventBusEventCallback} [callback]
11919
12733
  */
11920
12734
  EventBus.prototype.off = function(events, callback) {
11921
12735
 
@@ -11951,6 +12765,7 @@
11951
12765
  *
11952
12766
  * @example
11953
12767
  *
12768
+ * ```javascript
11954
12769
  * // fire event by name
11955
12770
  * events.fire('foo');
11956
12771
  *
@@ -11968,12 +12783,13 @@
11968
12783
  * });
11969
12784
  *
11970
12785
  * events.fire({ type: 'foo' }, 'I am bar!');
12786
+ * ```
11971
12787
  *
11972
- * @param {string} [type] The event type.
11973
- * @param {Object} [data] The event or event data.
11974
- * @param {...*} additional Additional arguments the callback will be called with.
12788
+ * @param {string} [type] event type
12789
+ * @param {Object} [data] event or event data
12790
+ * @param {...any} [args] additional arguments the callback will be called with.
11975
12791
  *
11976
- * @return {*} The return value. Will be set to `false` if the default was prevented.
12792
+ * @return {any} The return value. Will be set to `false` if the default was prevented.
11977
12793
  */
11978
12794
  EventBus.prototype.fire = function(type, data) {
11979
12795
  var event,
@@ -12054,6 +12870,13 @@
12054
12870
  this._listeners = {};
12055
12871
  };
12056
12872
 
12873
+ /**
12874
+ * @param {Event} event
12875
+ * @param {any[]} args
12876
+ * @param {EventBusListener} listener
12877
+ *
12878
+ * @return {any}
12879
+ */
12057
12880
  EventBus.prototype._invokeListeners = function(event, args, listener) {
12058
12881
 
12059
12882
  var returnValue;
@@ -12073,6 +12896,13 @@
12073
12896
  return returnValue;
12074
12897
  };
12075
12898
 
12899
+ /**
12900
+ * @param {Event} event
12901
+ * @param {any[]} args
12902
+ * @param {EventBusListener} listener
12903
+ *
12904
+ * @return {any}
12905
+ */
12076
12906
  EventBus.prototype._invokeListener = function(event, args, listener) {
12077
12907
 
12078
12908
  var returnValue;
@@ -12121,7 +12951,7 @@
12121
12951
  * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
12122
12952
  *
12123
12953
  * @param {string} event
12124
- * @param {EventListener} listener
12954
+ * @param {EventBusListener} listener
12125
12955
  */
12126
12956
  EventBus.prototype._addListener = function(event, newListener) {
12127
12957
 
@@ -12161,10 +12991,19 @@
12161
12991
  };
12162
12992
 
12163
12993
 
12994
+ /**
12995
+ * @param {string} name
12996
+ *
12997
+ * @return {EventBusListener}
12998
+ */
12164
12999
  EventBus.prototype._getListeners = function(name) {
12165
13000
  return this._listeners[name];
12166
13001
  };
12167
13002
 
13003
+ /**
13004
+ * @param {string} name
13005
+ * @param {EventBusListener} listener
13006
+ */
12168
13007
  EventBus.prototype._setListeners = function(name, listener) {
12169
13008
  this._listeners[name] = listener;
12170
13009
  };
@@ -12227,9 +13066,9 @@
12227
13066
  * Invoke function. Be fast...
12228
13067
  *
12229
13068
  * @param {Function} fn
12230
- * @param {*[]} args
13069
+ * @param {any[]} args
12231
13070
  *
12232
- * @return {*}
13071
+ * @return {any}
12233
13072
  */
12234
13073
  function invokeFunction(fn, args) {
12235
13074
  return fn.apply(null, args);
@@ -12264,13 +13103,9 @@
12264
13103
  }
12265
13104
 
12266
13105
  /**
12267
- * @typedef {import('../model').ModelType} ModelType
12268
- * @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
12269
- * @typedef {import('../model').ModelTypeShape} ModelTypeShape
12270
- *
12271
- * @typedef {import('.').ConnectionLike} ConnectionLike
12272
- * @typedef {import('.').ElementLike} ElementLike
12273
- * @typedef {import('.').ShapeLike} ShapeLike
13106
+ * @typedef {import('./Types').ConnectionLike} ConnectionLike
13107
+ * @typedef {import('./Types').ElementLike} ElementLike
13108
+ * @typedef {import('./Types').ShapeLike} ShapeLike
12274
13109
  *
12275
13110
  * @typedef {import('./ElementRegistry').default} ElementRegistry
12276
13111
  * @typedef {import('./EventBus').default} EventBus
@@ -12289,7 +13124,10 @@
12289
13124
 
12290
13125
  GraphicsFactory.$inject = [ 'eventBus' , 'elementRegistry' ];
12291
13126
 
12292
-
13127
+ /**
13128
+ * @param { { parent?: any } } element
13129
+ * @return {SVGElement}
13130
+ */
12293
13131
  GraphicsFactory.prototype._getChildrenContainer = function(element) {
12294
13132
 
12295
13133
  var gfx = this._elementRegistry.getGraphics(element);
@@ -12386,7 +13224,7 @@
12386
13224
  /**
12387
13225
  * Create a graphical element.
12388
13226
  *
12389
- * @param {ModelType} type The type of the element.
13227
+ * @param { 'shape' | 'connection' | 'label' | 'root' } type The type of the element.
12390
13228
  * @param {ElementLike} element The element.
12391
13229
  * @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
12392
13230
  *
@@ -12442,6 +13280,8 @@
12442
13280
  *
12443
13281
  * @param {SVGElement} visual The graphical element.
12444
13282
  * @param {ShapeLike} element The shape.
13283
+ *
13284
+ * @return {SVGElement}
12445
13285
  */
12446
13286
  GraphicsFactory.prototype.drawShape = function(visual, element) {
12447
13287
  var eventBus = this._eventBus;
@@ -12467,6 +13307,8 @@
12467
13307
  *
12468
13308
  * @param {SVGElement} visual The graphical element.
12469
13309
  * @param {ConnectionLike} element The connection.
13310
+ *
13311
+ * @return {SVGElement}
12470
13312
  */
12471
13313
  GraphicsFactory.prototype.drawConnection = function(visual, element) {
12472
13314
  var eventBus = this._eventBus;
@@ -12477,7 +13319,7 @@
12477
13319
  /**
12478
13320
  * Get the path of a connection.
12479
13321
  *
12480
- * @param {ConnectionLike} element The connection.
13322
+ * @param {ConnectionLike} connection The connection.
12481
13323
  *
12482
13324
  * @return {string} The path of the connection.
12483
13325
  */
@@ -12490,9 +13332,9 @@
12490
13332
  /**
12491
13333
  * Update an elements graphical representation.
12492
13334
  *
12493
- * @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
12494
- * @param {ElementLike} element The element.
12495
- * @param {SVGElement} gfx The graphical representation.
13335
+ * @param {'shape'|'connection'} type
13336
+ * @param {ElementLike} element
13337
+ * @param {SVGElement} gfx
12496
13338
  */
12497
13339
  GraphicsFactory.prototype.update = function(type, element, gfx) {
12498
13340
 
@@ -12550,6 +13392,9 @@
12550
13392
  parentNode.insertBefore(newNode, node);
12551
13393
  }
12552
13394
 
13395
+ /**
13396
+ * @type { import('didi').ModuleDeclaration }
13397
+ */
12553
13398
  var CoreModule = {
12554
13399
  __depends__: [ DrawModule ],
12555
13400
  __init__: [ 'canvas' ],
@@ -12565,7 +13410,9 @@
12565
13410
  * @typedef {import('didi').LocalsMap} LocalsMap
12566
13411
  * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
12567
13412
  *
12568
- * @typedef {import('./Diagram').DiagramOptions} DiagramOptions
13413
+ * @typedef { {
13414
+ * modules?: ModuleDeclaration[];
13415
+ * } & Record<string, any> } DiagramOptions
12569
13416
  */
12570
13417
 
12571
13418
  /**
@@ -12594,6 +13441,9 @@
12594
13441
 
12595
13442
  options = options || {};
12596
13443
 
13444
+ /**
13445
+ * @type { ModuleDeclaration }
13446
+ */
12597
13447
  var configModule = {
12598
13448
  'config': [ 'value', options ]
12599
13449
  };
@@ -12613,11 +13463,10 @@
12613
13463
  * @class
12614
13464
  * @constructor
12615
13465
  *
12616
- * @example
12617
- *
12618
- * <caption>Creating a plug-in that logs whenever a shape is added to the canvas.</caption>
13466
+ * @example Creating a plug-in that logs whenever a shape is added to the canvas.
12619
13467
  *
12620
- * // plug-in implemenentation
13468
+ * ```javascript
13469
+ * // plug-in implementation
12621
13470
  * function MyLoggingPlugin(eventBus) {
12622
13471
  * eventBus.on('shape.added', function(event) {
12623
13472
  * console.log('shape ', event.shape, ' was added to the diagram');
@@ -12629,10 +13478,11 @@
12629
13478
  * __init__: [ 'myLoggingPlugin' ],
12630
13479
  * myLoggingPlugin: [ 'type', MyLoggingPlugin ]
12631
13480
  * };
13481
+ * ```
12632
13482
  *
13483
+ * Use the plug-in in a Diagram instance:
12633
13484
  *
12634
- * // instantiate the diagram with the new plug-in
12635
- *
13485
+ * ```javascript
12636
13486
  * import MyLoggingModule from 'path-to-my-logging-plugin';
12637
13487
  *
12638
13488
  * var diagram = new Diagram({
@@ -12647,36 +13497,39 @@
12647
13497
  * });
12648
13498
  *
12649
13499
  * // 'shape ... was added to the diagram' logged to console
13500
+ * ```
12650
13501
  *
12651
13502
  * @param {DiagramOptions} [options]
12652
- * @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
12653
13503
  * @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
12654
13504
  */
12655
13505
  function Diagram(options, injector) {
12656
13506
 
12657
- // create injector unless explicitly specified
12658
- this.injector = injector = injector || createInjector(options);
13507
+ this._injector = injector = injector || createInjector(options);
12659
13508
 
12660
13509
  // API
12661
13510
 
12662
13511
  /**
12663
13512
  * Resolves a diagram service.
12664
13513
  *
12665
- * @method Diagram#get
13514
+ * @template T
12666
13515
  *
12667
13516
  * @param {string} name The name of the service to get.
12668
13517
  * @param {boolean} [strict=true] If false, resolve missing services to null.
13518
+ *
13519
+ * @return {T|null}
12669
13520
  */
12670
13521
  this.get = injector.get;
12671
13522
 
12672
13523
  /**
12673
13524
  * Executes a function with its dependencies injected.
12674
13525
  *
12675
- * @method Diagram#invoke
13526
+ * @template T
12676
13527
  *
12677
- * @param {Function} fn The function to be executed.
12678
- * @param {InjectionContext} [context] The context.
12679
- * @param {LocalsMap} [locals] The locals.
13528
+ * @param {Function} func function to be invoked
13529
+ * @param {InjectionContext} [context] context of the invocation
13530
+ * @param {LocalsMap} [locals] locals provided
13531
+ *
13532
+ * @return {T|null}
12680
13533
  */
12681
13534
  this.invoke = injector.invoke;
12682
13535
 
@@ -12708,8 +13561,6 @@
12708
13561
 
12709
13562
  /**
12710
13563
  * Destroys the diagram
12711
- *
12712
- * @method Diagram#destroy
12713
13564
  */
12714
13565
  Diagram.prototype.destroy = function() {
12715
13566
  this.get('eventBus').fire('diagram.destroy');
@@ -20247,6 +21098,10 @@
20247
21098
  return new BpmnModdle(pks, options);
20248
21099
  }
20249
21100
 
21101
+ /**
21102
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
21103
+ */
21104
+
20250
21105
  // TODO(nikku): remove with future bpmn-js version
20251
21106
 
20252
21107
  /**
@@ -20256,6 +21111,10 @@
20256
21111
  * 2) If Promise class is implemented in current environment.
20257
21112
  *
20258
21113
  * @private
21114
+ *
21115
+ * @param {Function} api
21116
+ *
21117
+ * @return {Function}
20259
21118
  */
20260
21119
  function wrapForCompatibility(api) {
20261
21120
 
@@ -20304,6 +21163,11 @@
20304
21163
 
20305
21164
  var DI_ERROR_MESSAGE = 'Tried to access di from the businessObject. The di is available through the diagram element only. For more information, see https://github.com/bpmn-io/bpmn-js/issues/1472';
20306
21165
 
21166
+ /**
21167
+ * @private
21168
+ *
21169
+ * @param {ModdleElement} businessObject
21170
+ */
20307
21171
  function ensureCompatDiRef(businessObject) {
20308
21172
 
20309
21173
  // bpmnElement can have multiple independent DIs
@@ -20318,10 +21182,16 @@
20318
21182
  }
20319
21183
 
20320
21184
  /**
20321
- * Returns true if an element has the given meta-model type
21185
+ * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
21186
+ *
21187
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
21188
+ */
21189
+
21190
+ /**
21191
+ * Returns true if an element is of the given meta-model type.
20322
21192
  *
20323
- * @param {ModdleElement} element
20324
- * @param {string} type
21193
+ * @param {ModdleElement} element
21194
+ * @param {string} type
20325
21195
  *
20326
21196
  * @return {boolean}
20327
21197
  */
@@ -20333,6 +21203,10 @@
20333
21203
  /**
20334
21204
  * Find a suitable display candidate for definitions where the DI does not
20335
21205
  * correctly specify one.
21206
+ *
21207
+ * @param {ModdleElement}
21208
+ *
21209
+ * @return {ModdleElement}
20336
21210
  */
20337
21211
  function findDisplayCandidate(definitions) {
20338
21212
  return find(definitions.rootElements, function(e) {
@@ -20340,7 +21214,10 @@
20340
21214
  });
20341
21215
  }
20342
21216
 
20343
-
21217
+ /**
21218
+ * @param {Function} handler
21219
+ * @param {Translate} translate
21220
+ */
20344
21221
  function BpmnTreeWalker(handler, translate) {
20345
21222
 
20346
21223
  // list of containers already walked
@@ -20409,7 +21286,7 @@
20409
21286
 
20410
21287
  // DI handling //////////////////////
20411
21288
 
20412
- function registerDi(di) {
21289
+ var registerDi = this.registerDi = function registerDi(di) {
20413
21290
  var bpmnElement = di.bpmnElement;
20414
21291
 
20415
21292
  if (bpmnElement) {
@@ -20433,7 +21310,7 @@
20433
21310
  { element: di }
20434
21311
  );
20435
21312
  }
20436
- }
21313
+ };
20437
21314
 
20438
21315
  function handleDiagram(diagram) {
20439
21316
  handlePlane(diagram.plane);
@@ -20453,14 +21330,14 @@
20453
21330
  // Semantic handling //////////////////////
20454
21331
 
20455
21332
  /**
20456
- * Handle definitions and return the rendered diagram (if any)
21333
+ * Handle definitions and return the rendered diagram (if any).
20457
21334
  *
20458
21335
  * @param {ModdleElement} definitions to walk and import
20459
21336
  * @param {ModdleElement} [diagram] specific diagram to import and display
20460
21337
  *
20461
21338
  * @throws {Error} if no diagram to display could be found
20462
21339
  */
20463
- function handleDefinitions(definitions, diagram) {
21340
+ this.handleDefinitions = function handleDefinitions(definitions, diagram) {
20464
21341
 
20465
21342
  // make sure we walk the correct bpmnElement
20466
21343
 
@@ -20537,10 +21414,10 @@
20537
21414
  }
20538
21415
 
20539
21416
  // handle all deferred elements
20540
- handleDeferred();
20541
- }
21417
+ handleDeferred(deferred);
21418
+ };
20542
21419
 
20543
- function handleDeferred() {
21420
+ var handleDeferred = this.handleDeferred = function handleDeferred() {
20544
21421
 
20545
21422
  var fn;
20546
21423
 
@@ -20550,7 +21427,7 @@
20550
21427
 
20551
21428
  fn();
20552
21429
  }
20553
- }
21430
+ };
20554
21431
 
20555
21432
  function handleProcess(process, context) {
20556
21433
  handleFlowElementsContainer(process, context);
@@ -20626,10 +21503,10 @@
20626
21503
  forEach$1(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
20627
21504
  }
20628
21505
 
20629
- function handleSubProcess(subProcess, context) {
21506
+ var handleSubProcess = this.handleSubProcess = function handleSubProcess(subProcess, context) {
20630
21507
  handleFlowElementsContainer(subProcess, context);
20631
21508
  handleArtifacts(subProcess.artifacts, context);
20632
- }
21509
+ };
20633
21510
 
20634
21511
  function handleFlowNode(flowNode, context) {
20635
21512
  var childCtx = visitIfDi(flowNode, context);
@@ -20754,44 +21631,29 @@
20754
21631
  }
20755
21632
  });
20756
21633
  }
20757
-
20758
- // API //////////////////////
20759
-
20760
- return {
20761
- handleDeferred: handleDeferred,
20762
- handleDefinitions: handleDefinitions,
20763
- handleSubProcess: handleSubProcess,
20764
- registerDi: registerDi
20765
- };
20766
21634
  }
20767
21635
 
20768
21636
  /**
20769
- * The importBpmnDiagram result.
21637
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
20770
21638
  *
20771
- * @typedef {Object} ImportBPMNDiagramResult
21639
+ * @typedef { {
21640
+ * warnings: string[];
21641
+ * } } ImportBPMNDiagramResult
20772
21642
  *
20773
- * @property {Array<string>} warnings
21643
+ * @typedef {ImportBPMNDiagramResult & Error} ImportBPMNDiagramError
20774
21644
  */
20775
21645
 
20776
- /**
20777
- * The importBpmnDiagram error.
20778
- *
20779
- * @typedef {Error} ImportBPMNDiagramError
20780
- *
20781
- * @property {Array<string>} warnings
20782
- */
20783
-
20784
21646
  /**
20785
21647
  * Import the definitions into a diagram.
20786
21648
  *
20787
21649
  * Errors and warnings are reported through the specified callback.
20788
21650
  *
20789
- * @param {djs.Diagram} diagram
20790
- * @param {ModdleElement<Definitions>} definitions
20791
- * @param {ModdleElement<BPMNDiagram>} [bpmnDiagram] the diagram to be rendered
20792
- * (if not provided, the first one will be rendered)
21651
+ * @param {ModdleElement} diagram
21652
+ * @param {ModdleElement} definitions
21653
+ * @param {ModdleElement} [bpmnDiagram] The diagram to be rendered (if not
21654
+ * provided, the first one will be rendered).
20793
21655
  *
20794
- * Returns {Promise<ImportBPMNDiagramResult, ImportBPMNDiagramError>}
21656
+ * @return {Promise<ImportBPMNDiagramResult>}
20795
21657
  */
20796
21658
  function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
20797
21659
 
@@ -20807,8 +21669,8 @@
20807
21669
  * Walk the diagram semantically, importing (=drawing)
20808
21670
  * all elements you encounter.
20809
21671
  *
20810
- * @param {ModdleElement<Definitions>} definitions
20811
- * @param {ModdleElement<BPMNDiagram>} bpmnDiagram
21672
+ * @param {ModdleElement} definitions
21673
+ * @param {ModdleElement} bpmnDiagram
20812
21674
  */
20813
21675
  function render(definitions, bpmnDiagram) {
20814
21676
 
@@ -20883,10 +21745,10 @@
20883
21745
  * Returns all diagrams in the same hierarchy as the requested diagram.
20884
21746
  * Includes all parent and sub process diagrams.
20885
21747
  *
20886
- * @param {Array} definitions
20887
- * @param {Object} bpmnDiagram
21748
+ * @param {ModdleElement} definitions
21749
+ * @param {ModdleElement} bpmnDiagram
20888
21750
  *
20889
- * @returns {Array<Object>}
21751
+ * @return {ModdleElement[]}
20890
21752
  */
20891
21753
  function getDiagramsToImport(definitions, bpmnDiagram) {
20892
21754
  if (!bpmnDiagram) {
@@ -21080,22 +21942,89 @@
21080
21942
  * @see http://bpmn.io/license for more information.
21081
21943
  */
21082
21944
 
21945
+ /**
21946
+ * @template T
21947
+ *
21948
+ * @typedef {import('diagram-js/lib/core/EventBus').EventBusEventCallback<T>} EventBusEventCallback
21949
+ */
21083
21950
 
21084
21951
  /**
21085
21952
  * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
21086
21953
  *
21087
- * @typedef {import('./BaseViewer').BaseModelerOptions} BaseModelerOptions
21088
- * @typedef {import('./BaseViewer').ModdleElement} ModdleElement
21089
- * @typedef {import('./BaseViewer').ImportXMLResult} ImportXMLResult
21090
- * @typedef {import('./BaseViewer').ImportXMLError} ImportXMLError
21091
- * @typedef {import('./BaseViewer').ImportDefinitionsResult} ImportDefinitionsResult
21092
- * @typedef {import('./BaseViewer').ImportDefinitionsError} ImportDefinitionsError
21093
- * @typedef {import('./BaseViewer').ModdleElement} ModdleElement
21094
- * @typedef {import('./BaseViewer').ModdleElementsById} ModdleElementsById
21095
- * @typedef {import('./BaseViewer').OpenResult} OpenResult
21096
- * @typedef {import('./BaseViewer').OpenError} OpenError
21097
- * @typedef {import('./BaseViewer').SaveXMLOptions} SaveXMLOptions
21098
- * @typedef {import('./BaseViewer').SaveXMLResult} SaveXMLResult
21954
+ * @typedef {import('./model/Types').Moddle} Moddle
21955
+ * @typedef {import('./model/Types').ModdleElement} ModdleElement
21956
+ * @typedef {import('./model/Types').ModdleExtension} ModdleExtension
21957
+ *
21958
+ * @typedef { {
21959
+ * width?: number|string;
21960
+ * height?: number|string;
21961
+ * position?: string;
21962
+ * container?: string|HTMLElement;
21963
+ * moddleExtensions?: ModdleExtensions;
21964
+ * additionalModules?: ModuleDeclaration[];
21965
+ * } & Record<string, any> } BaseViewerOptions
21966
+ *
21967
+ * @typedef {Record<string, ModdleElement>} ModdleElementsById
21968
+ *
21969
+ * @typedef { {
21970
+ * [key: string]: ModdleExtension;
21971
+ * } } ModdleExtensions
21972
+ *
21973
+ * @typedef { {
21974
+ * warnings: string[];
21975
+ * } } ImportXMLResult
21976
+ *
21977
+ * @typedef {ImportXMLResult & Error} ImportXMLError
21978
+ *
21979
+ * @typedef {ImportXMLResult} ImportDefinitionsResult
21980
+ *
21981
+ * @typedef {ImportXMLError} ImportDefinitionsError
21982
+ *
21983
+ * @typedef {ImportXMLResult} OpenResult
21984
+ *
21985
+ * @typedef {ImportXMLError} OpenError
21986
+ *
21987
+ * @typedef { {
21988
+ * format?: boolean;
21989
+ * preamble?: boolean;
21990
+ * } } SaveXMLOptions
21991
+ *
21992
+ * @typedef { {
21993
+ * xml?: string;
21994
+ * error?: Error;
21995
+ * } } SaveXMLResult
21996
+ *
21997
+ * @typedef { {
21998
+ * svg: string;
21999
+ * } } SaveSVGResult
22000
+ *
22001
+ * @typedef { {
22002
+ * xml: string;
22003
+ * } } ImportParseStartEvent
22004
+ *
22005
+ * @typedef { {
22006
+ * error?: ImportXMLError;
22007
+ * definitions?: ModdleElement;
22008
+ * elementsById?: ModdleElementsById;
22009
+ * references?: ModdleElement[];
22010
+ * warnings: string[];
22011
+ * } } ImportParseCompleteEvent
22012
+ *
22013
+ * @typedef { {
22014
+ * error?: ImportXMLError;
22015
+ * warnings: string[];
22016
+ * } } ImportDoneEvent
22017
+ *
22018
+ * @typedef { {
22019
+ * definitions: ModdleElement;
22020
+ * } } SaveXMLStartEvent
22021
+ *
22022
+ * @typedef {SaveXMLResult} SaveXMLDoneEvent
22023
+ *
22024
+ * @typedef { {
22025
+ * error?: Error;
22026
+ * svg: string;
22027
+ * } } SaveSVGDoneEvent
21099
22028
  */
21100
22029
 
21101
22030
  /**
@@ -21104,15 +22033,18 @@
21104
22033
  * Have a look at {@link Viewer}, {@link NavigatedViewer} or {@link Modeler} for
21105
22034
  * bundles that include actual features.
21106
22035
  *
21107
- * @param {BaseModelerOptions} [options] The options to configure the viewer.
22036
+ * @param {BaseViewerOptions} [options] The options to configure the viewer.
21108
22037
  */
21109
22038
  function BaseViewer(options) {
21110
22039
 
21111
22040
  /**
21112
- * @type {BaseModelerOptions}
22041
+ * @type {BaseViewerOptions}
21113
22042
  */
21114
22043
  options = assign$1({}, DEFAULT_OPTIONS, options);
21115
22044
 
22045
+ /**
22046
+ * @type {Moddle}
22047
+ */
21116
22048
  this._moddle = this._createModdle(options);
21117
22049
 
21118
22050
  /**
@@ -21151,18 +22083,18 @@
21151
22083
  *
21152
22084
  * @throws {ImportXMLError} An error thrown during the import of the XML.
21153
22085
  *
21154
- * @fires BaseViewer#ImportParseStart
21155
- * @fires BaseViewer#ImportParseComplete
21156
- * @fires Importer#ImportRenderStart
21157
- * @fires Importer#ImportRenderComplete
21158
- * @fires BaseViewer#ImportDone
22086
+ * @fires BaseViewer#ImportParseStartEvent
22087
+ * @fires BaseViewer#ImportParseCompleteEvent
22088
+ * @fires Importer#ImportRenderStartEvent
22089
+ * @fires Importer#ImportRenderCompleteEvent
22090
+ * @fires BaseViewer#ImportDoneEvent
21159
22091
  *
21160
22092
  * @param {string} xml The BPMN 2.0 XML to be imported.
21161
22093
  * @param {ModdleElement|string} [bpmnDiagram] The optional diagram or Id of the BPMN diagram to open.
21162
22094
  *
21163
22095
  * @return {Promise<ImportXMLResult>} A promise resolving with warnings that were produced during the import.
21164
22096
  */
21165
- BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(xml, bpmnDiagram) {
22097
+ BaseViewer.prototype.importXML = async function importXML(xml, bpmnDiagram) {
21166
22098
 
21167
22099
  const self = this;
21168
22100
 
@@ -21200,9 +22132,8 @@
21200
22132
  /**
21201
22133
  * A `import.parse.start` event.
21202
22134
  *
21203
- * @event BaseViewer#ImportParseStart
21204
- * @type {Object}
21205
- * @property {string} xml The XML that is to be parsed.
22135
+ * @event BaseViewer#ImportParseStartEvent
22136
+ * @type {ImportParseStartEvent}
21206
22137
  */
21207
22138
  xml = this._emit('import.parse.start', { xml: xml }) || xml;
21208
22139
 
@@ -21230,13 +22161,8 @@
21230
22161
  /**
21231
22162
  * A `import.parse.complete` event.
21232
22163
  *
21233
- * @event BaseViewer#ImportParseComplete
21234
- * @type {Object}
21235
- * @property {Error|null} error An error thrown when parsing the XML.
21236
- * @property {ModdleElement} definitions The definitions model element.
21237
- * @property {ModdleElementsById} elementsById The model elements by ID.
21238
- * @property {ModdleElement[]} references The referenced model elements.
21239
- * @property {string[]} warnings The warnings produced when parsing the XML.
22164
+ * @event BaseViewer#ImportParseCompleteEvent
22165
+ * @type {ImportParseCompleteEvent}
21240
22166
  */
21241
22167
  definitions = this._emit('import.parse.complete', ParseCompleteEvent({
21242
22168
  error: null,
@@ -21253,10 +22179,8 @@
21253
22179
  /**
21254
22180
  * A `import.parse.complete` event.
21255
22181
  *
21256
- * @event BaseViewer#ImportDone
21257
- * @type {Object}
21258
- * @property {ImportXMLError|null} error An error thrown during import.
21259
- * @property {string[]} warnings The warnings.
22182
+ * @event BaseViewer#ImportDoneEvent
22183
+ * @type {ImportDoneEvent}
21260
22184
  */
21261
22185
  this._emit('import.done', { error: null, warnings: aggregatedWarnings });
21262
22186
 
@@ -21272,7 +22196,9 @@
21272
22196
 
21273
22197
  throw error;
21274
22198
  }
21275
- });
22199
+ };
22200
+
22201
+ BaseViewer.prototype.importXML = wrapForCompatibility(BaseViewer.prototype.importXML);
21276
22202
 
21277
22203
 
21278
22204
  /**
@@ -21297,12 +22223,14 @@
21297
22223
  *
21298
22224
  * @return {Promise<ImportDefinitionsResult>} A promise resolving with warnings that were produced during the import.
21299
22225
  */
21300
- BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
22226
+ BaseViewer.prototype.importDefinitions = async function importDefinitions(definitions, bpmnDiagram) {
21301
22227
  this._setDefinitions(definitions);
21302
22228
  const result = await this.open(bpmnDiagram);
21303
22229
 
21304
22230
  return { warnings: result.warnings };
21305
- });
22231
+ };
22232
+
22233
+ BaseViewer.prototype.importDefinitions = wrapForCompatibility(BaseViewer.prototype.importDefinitions);
21306
22234
 
21307
22235
 
21308
22236
  /**
@@ -21326,7 +22254,7 @@
21326
22254
  *
21327
22255
  * @return {Promise<OpenResult>} A promise resolving with warnings that were produced during opening.
21328
22256
  */
21329
- BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
22257
+ BaseViewer.prototype.open = async function open(bpmnDiagramOrId) {
21330
22258
 
21331
22259
  const definitions = this._definitions;
21332
22260
  let bpmnDiagram = bpmnDiagramOrId;
@@ -21363,7 +22291,9 @@
21363
22291
  const { warnings } = await importBpmnDiagram(this, definitions, bpmnDiagram);
21364
22292
 
21365
22293
  return { warnings };
21366
- });
22294
+ };
22295
+
22296
+ BaseViewer.prototype.open = wrapForCompatibility(BaseViewer.prototype.open);
21367
22297
 
21368
22298
  /**
21369
22299
  * Export the currently displayed BPMN 2.0 diagram as
@@ -21388,7 +22318,7 @@
21388
22318
  *
21389
22319
  * @return {Promise<SaveXMLResult>} A promise resolving with the XML.
21390
22320
  */
21391
- BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
22321
+ BaseViewer.prototype.saveXML = async function saveXML(options) {
21392
22322
 
21393
22323
  options = options || {};
21394
22324
 
@@ -21405,9 +22335,8 @@
21405
22335
  /**
21406
22336
  * A `saveXML.start` event.
21407
22337
  *
21408
- * @event BaseViewer#SaveXMLStart
21409
- * @type {Object}
21410
- * @property {ModdleElement} definitions The definitions model element.
22338
+ * @event BaseViewer#SaveXMLStartEvent
22339
+ * @type {SaveXMLStartEvent}
21411
22340
  */
21412
22341
  definitions = this._emit('saveXML.start', {
21413
22342
  definitions
@@ -21428,10 +22357,8 @@
21428
22357
  /**
21429
22358
  * A `saveXML.done` event.
21430
22359
  *
21431
- * @event BaseViewer#SaveXMLDone
21432
- * @type {Object}
21433
- * @property {Error} [error] An error thrown when saving the XML.
21434
- * @property {string} [xml] The saved XML.
22360
+ * @event BaseViewer#SaveXMLDoneEvent
22361
+ * @type {SaveXMLDoneEvent}
21435
22362
  */
21436
22363
  this._emit('saveXML.done', result);
21437
22364
 
@@ -21440,7 +22367,9 @@
21440
22367
  }
21441
22368
 
21442
22369
  return result;
21443
- });
22370
+ };
22371
+
22372
+ BaseViewer.prototype.saveXML = wrapForCompatibility(BaseViewer.prototype.saveXML);
21444
22373
 
21445
22374
 
21446
22375
  /**
@@ -21462,7 +22391,7 @@
21462
22391
  *
21463
22392
  * @return {Promise<SaveSVGResult>} A promise resolving with the SVG.
21464
22393
  */
21465
- BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG() {
22394
+ BaseViewer.prototype.saveSVG = async function saveSVG() {
21466
22395
  this._emit('saveSVG.start');
21467
22396
 
21468
22397
  let svg, err;
@@ -21494,10 +22423,8 @@
21494
22423
  /**
21495
22424
  * A `saveSVG.done` event.
21496
22425
  *
21497
- * @event BaseViewer#SaveSVGDone
21498
- * @type {Object}
21499
- * @property {Error} [error] An error thrown when saving the SVG.
21500
- * @property {string} [svg] The saved SVG.
22426
+ * @event BaseViewer#SaveSVGDoneEvent
22427
+ * @type {SaveSVGDoneEvent}
21501
22428
  */
21502
22429
  this._emit('saveSVG.done', {
21503
22430
  error: err,
@@ -21509,7 +22436,9 @@
21509
22436
  }
21510
22437
 
21511
22438
  return { svg };
21512
- });
22439
+ };
22440
+
22441
+ BaseViewer.prototype.saveSVG = wrapForCompatibility(BaseViewer.prototype.saveSVG);
21513
22442
 
21514
22443
  /**
21515
22444
  * Get a named diagram service.
@@ -21591,10 +22520,12 @@
21591
22520
  *
21592
22521
  * Remove an event listener via {@link BaseViewer#off}.
21593
22522
  *
22523
+ * @template T
22524
+ *
21594
22525
  * @param {string|string[]} events The event(s) to listen to.
21595
22526
  * @param {number} [priority] The priority with which to listen.
21596
- * @param {EventCallback} callback The callback.
21597
- * @param {*} [that] Value of `this` the callback will be called with.
22527
+ * @param {EventBusEventCallback<T>} callback The callback.
22528
+ * @param {any} [that] Value of `this` the callback will be called with.
21598
22529
  */
21599
22530
  BaseViewer.prototype.on = function(events, priority, callback, that) {
21600
22531
  return this.get('eventBus').on(events, priority, callback, that);
@@ -21644,7 +22575,7 @@
21644
22575
  /**
21645
22576
  * Get the definitions model element.
21646
22577
  *
21647
- * @returns {ModdleElement} The definitions model element.
22578
+ * @return {ModdleElement} The definitions model element.
21648
22579
  */
21649
22580
  BaseViewer.prototype.getDefinitions = function() {
21650
22581
  return this._definitions;
@@ -21713,6 +22644,11 @@
21713
22644
  return this.get('eventBus').fire(type, event);
21714
22645
  };
21715
22646
 
22647
+ /**
22648
+ * @param {BaseViewerOptions} options
22649
+ *
22650
+ * @return {HTMLElement}
22651
+ */
21716
22652
  BaseViewer.prototype._createContainer = function(options) {
21717
22653
 
21718
22654
  const container = domify$1('<div class="bjs-container"></div>');
@@ -21726,6 +22662,11 @@
21726
22662
  return container;
21727
22663
  };
21728
22664
 
22665
+ /**
22666
+ * @param {BaseViewerOptions} options
22667
+ *
22668
+ * @return {Moddle}
22669
+ */
21729
22670
  BaseViewer.prototype._createModdle = function(options) {
21730
22671
  const moddleOptions = assign$1({}, this._moddleExtensions, options.moddleExtensions);
21731
22672
 
@@ -21925,7 +22866,7 @@
21925
22866
  /**
21926
22867
  * Checks if key pressed is one of provided keys.
21927
22868
  *
21928
- * @param {string|Array<string>} keys
22869
+ * @param {string|string[]} keys
21929
22870
  * @param {KeyboardEvent} event
21930
22871
  */
21931
22872
  function isKey(keys, event) {
@@ -22318,6 +23259,9 @@
22318
23259
  });
22319
23260
  };
22320
23261
 
23262
+ /**
23263
+ * @type { import('didi').ModuleDeclaration }
23264
+ */
22321
23265
  var KeyboardModule = {
22322
23266
  __init__: [ 'keyboard', 'keyboardBindings' ],
22323
23267
  keyboard: [ 'type', Keyboard ],
@@ -22447,6 +23391,9 @@
22447
23391
  'canvas'
22448
23392
  ];
22449
23393
 
23394
+ /**
23395
+ * @type { import('didi').ModuleDeclaration }
23396
+ */
22450
23397
  var KeyboardMoveModule = {
22451
23398
  __depends__: [
22452
23399
  KeyboardModule
@@ -22619,6 +23566,9 @@
22619
23566
  return Math.sqrt(Math.pow(point.x, 2) + Math.pow(point.y, 2));
22620
23567
  }
22621
23568
 
23569
+ /**
23570
+ * @type { import('didi').ModuleDeclaration }
23571
+ */
22622
23572
  var MoveCanvasModule = {
22623
23573
  __init__: [ 'moveCanvas' ],
22624
23574
  moveCanvas: [ 'type', MoveCanvas ]
@@ -22657,6 +23607,8 @@
22657
23607
  /**
22658
23608
  * @typedef {import('../../core/Canvas').default} Canvas
22659
23609
  * @typedef {import('../../core/EventBus').default} EventBus
23610
+ *
23611
+ * @typedef {import('../../util/Types').Point} Point
22660
23612
  */
22661
23613
 
22662
23614
  var sign = Math.sign || function(n) {
@@ -22710,6 +23662,9 @@
22710
23662
  'canvas'
22711
23663
  ];
22712
23664
 
23665
+ /**
23666
+ * @param {Point} delta
23667
+ */
22713
23668
  ZoomScroll.prototype.scroll = function scroll(delta) {
22714
23669
  this._canvas.scroll(delta);
22715
23670
  };
@@ -22723,7 +23678,7 @@
22723
23678
  * Zoom depending on delta.
22724
23679
  *
22725
23680
  * @param {number} delta
22726
- * @param {Object} position
23681
+ * @param {Point} position
22727
23682
  */
22728
23683
  ZoomScroll.prototype.zoom = function zoom(delta, position) {
22729
23684
 
@@ -22807,8 +23762,8 @@
22807
23762
  /**
22808
23763
  * Zoom with fixed step size.
22809
23764
  *
22810
- * @param {number} delta - Zoom delta (1 for zooming in, -1 for out).
22811
- * @param {Object} position
23765
+ * @param {number} delta Zoom delta (1 for zooming in, -1 for zooming out).
23766
+ * @param {Point} position
22812
23767
  */
22813
23768
  ZoomScroll.prototype.stepZoom = function stepZoom(delta, position) {
22814
23769
 
@@ -22822,7 +23777,7 @@
22822
23777
  * Zoom in/out given a step size.
22823
23778
  *
22824
23779
  * @param {number} delta
22825
- * @param {Object} position
23780
+ * @param {Point} position
22826
23781
  * @param {number} stepSize
22827
23782
  */
22828
23783
  ZoomScroll.prototype._zoom = function(delta, position, stepSize) {
@@ -22880,6 +23835,9 @@
22880
23835
  this.toggle(newEnabled);
22881
23836
  };
22882
23837
 
23838
+ /**
23839
+ * @type { import('didi').ModuleDeclaration }
23840
+ */
22883
23841
  var ZoomScrollModule = {
22884
23842
  __init__: [ 'zoomScroll' ],
22885
23843
  zoomScroll: [ 'type', ZoomScroll ]