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-viewer v12.1.0
2
+ * bpmn-js - bpmn-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
196
259
  *
197
- * @return {Any} result returned from last iterator
260
+ * @param {Collection<T>} collection
261
+ * @param {(result: V, entry: T, index: any) => V} iterator
262
+ * @param {V} result
263
+ *
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
272
341
  *
273
- * @return {Function} matcherFn
342
+ * @param {T} pattern
343
+ *
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
495
+ *
496
+ * @param {T} target
497
+ * @param {V} properties
405
498
  *
406
- * @return {Object} target
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
429
522
  *
430
- * @return {Object} target
523
+ * @param {T} target
524
+ * @param {V} properties
525
+ *
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.
5319
5664
  *
5320
- * @param {Array<Point>} waypoints
5321
- * @return {Point} the mid point
5665
+ * @param {Point[]} waypoints
5666
+ *
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.
5798
6177
  *
5799
- * @throws {Error} if the end is not yet drawn
6178
+ * @param {ModdleElement} semantic
6179
+ * @param {'source' | 'target'} side
6180
+ *
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
 
@@ -5926,11 +6308,13 @@
5926
6308
  }
5927
6309
 
5928
6310
  /**
5929
- * @typedef {import('../../model').Base} Base
6311
+ * @typedef {import('../../model/Types').Element} Element
5930
6312
  *
5931
6313
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
5932
6314
  * @typedef {import('../../core/EventBus').default} EventBus
5933
6315
  * @typedef {import('../../draw/Styles').default} Styles
6316
+ *
6317
+ * @typedef {import('../../util/Types').Point} Point
5934
6318
  */
5935
6319
 
5936
6320
  function allowAll(event) { return true; }
@@ -5974,7 +6358,7 @@
5974
6358
  *
5975
6359
  * @param {string} type local event name, e.g. element.click.
5976
6360
  * @param {MouseEvent|TouchEvent} event native event
5977
- * @param {Base} [element] the diagram element to emit the event on;
6361
+ * @param {Element} [element] the diagram element to emit the event on;
5978
6362
  * defaults to the event target
5979
6363
  */
5980
6364
  function fire(type, event, element) {
@@ -6057,7 +6441,7 @@
6057
6441
  *
6058
6442
  * @param {string} eventName the name of the triggered DOM event
6059
6443
  * @param {MouseEvent|TouchEvent} event
6060
- * @param {Base} targetElement
6444
+ * @param {Element} targetElement
6061
6445
  */
6062
6446
  function triggerMouseEvent(eventName, event, targetElement) {
6063
6447
 
@@ -6223,7 +6607,7 @@
6223
6607
  /**
6224
6608
  * Create default hit for the given element.
6225
6609
  *
6226
- * @param {Base} element
6610
+ * @param {Element} element
6227
6611
  * @param {SVGElement} gfx
6228
6612
  *
6229
6613
  * @return {SVGElement} created hit
@@ -6250,7 +6634,7 @@
6250
6634
  * Create hits for the given waypoints.
6251
6635
  *
6252
6636
  * @param {SVGElement} gfx
6253
- * @param {Array<Point>} waypoints
6637
+ * @param {Point[]} waypoints
6254
6638
  *
6255
6639
  * @return {SVGElement}
6256
6640
  */
@@ -6269,7 +6653,7 @@
6269
6653
  * Create hits for a box.
6270
6654
  *
6271
6655
  * @param {SVGElement} gfx
6272
- * @param {string} hitType
6656
+ * @param {string} type
6273
6657
  * @param {Object} attrs
6274
6658
  *
6275
6659
  * @return {SVGElement}
@@ -6295,7 +6679,7 @@
6295
6679
  /**
6296
6680
  * Update default hit of the element.
6297
6681
  *
6298
- * @param {Base} element
6682
+ * @param {Element} element
6299
6683
  * @param {SVGElement} gfx
6300
6684
  *
6301
6685
  * @return {SVGElement} updated hit
@@ -6344,7 +6728,7 @@
6344
6728
  * @event element.hover
6345
6729
  *
6346
6730
  * @type {Object}
6347
- * @property {Base} element
6731
+ * @property {Element} element
6348
6732
  * @property {SVGElement} gfx
6349
6733
  * @property {Event} originalEvent
6350
6734
  */
@@ -6355,7 +6739,7 @@
6355
6739
  * @event element.out
6356
6740
  *
6357
6741
  * @type {Object}
6358
- * @property {Base} element
6742
+ * @property {Element} element
6359
6743
  * @property {SVGElement} gfx
6360
6744
  * @property {Event} originalEvent
6361
6745
  */
@@ -6366,7 +6750,7 @@
6366
6750
  * @event element.click
6367
6751
  *
6368
6752
  * @type {Object}
6369
- * @property {Base} element
6753
+ * @property {Element} element
6370
6754
  * @property {SVGElement} gfx
6371
6755
  * @property {Event} originalEvent
6372
6756
  */
@@ -6377,7 +6761,7 @@
6377
6761
  * @event element.dblclick
6378
6762
  *
6379
6763
  * @type {Object}
6380
- * @property {Base} element
6764
+ * @property {Element} element
6381
6765
  * @property {SVGElement} gfx
6382
6766
  * @property {Event} originalEvent
6383
6767
  */
@@ -6388,7 +6772,7 @@
6388
6772
  * @event element.mousedown
6389
6773
  *
6390
6774
  * @type {Object}
6391
- * @property {Base} element
6775
+ * @property {Element} element
6392
6776
  * @property {SVGElement} gfx
6393
6777
  * @property {Event} originalEvent
6394
6778
  */
@@ -6399,7 +6783,7 @@
6399
6783
  * @event element.mouseup
6400
6784
  *
6401
6785
  * @type {Object}
6402
- * @property {Base} element
6786
+ * @property {Element} element
6403
6787
  * @property {SVGElement} gfx
6404
6788
  * @property {Event} originalEvent
6405
6789
  */
@@ -6411,11 +6795,14 @@
6411
6795
  * @event element.contextmenu
6412
6796
  *
6413
6797
  * @type {Object}
6414
- * @property {Base} element
6798
+ * @property {Element} element
6415
6799
  * @property {SVGElement} gfx
6416
6800
  * @property {Event} originalEvent
6417
6801
  */
6418
6802
 
6803
+ /**
6804
+ * @type { import('didi').ModuleDeclaration }
6805
+ */
6419
6806
  var InteractionEventsModule = {
6420
6807
  __init__: [ 'interactionEvents' ],
6421
6808
  interactionEvents: [ 'type', InteractionEvents ]
@@ -6425,7 +6812,7 @@
6425
6812
  * Returns the surrounding bbox for all elements in
6426
6813
  * the array or the element primitive.
6427
6814
  *
6428
- * @param {Base|Base[]} elements
6815
+ * @param {Element|Element[]} elements
6429
6816
  * @param {boolean} [stopRecursion=false]
6430
6817
  *
6431
6818
  * @return {Rect}
@@ -6500,7 +6887,7 @@
6500
6887
  var LOW_PRIORITY$2 = 500;
6501
6888
 
6502
6889
  /**
6503
- * @typedef {import('../../model').Base} Base
6890
+ * @typedef {import('../../model/Types').Element} Element
6504
6891
  *
6505
6892
  * @typedef {import('../../core/EventBus').default} EventBus
6506
6893
  * @typedef {import('../../draw/Styles').default} Styles
@@ -6574,7 +6961,7 @@
6574
6961
  * element and an outline offset.
6575
6962
  *
6576
6963
  * @param {SVGElement} outline
6577
- * @param {Base} element
6964
+ * @param {Element} element
6578
6965
  */
6579
6966
  Outline.prototype.updateShapeOutline = function(outline, element) {
6580
6967
 
@@ -6593,7 +6980,7 @@
6593
6980
  * the connection and an outline offset.
6594
6981
  *
6595
6982
  * @param {SVGElement} outline
6596
- * @param {Base} element
6983
+ * @param {Element} connection
6597
6984
  */
6598
6985
  Outline.prototype.updateConnectionOutline = function(outline, connection) {
6599
6986
 
@@ -6611,12 +6998,16 @@
6611
6998
 
6612
6999
  Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
6613
7000
 
7001
+ /**
7002
+ * @type { import('didi').ModuleDeclaration }
7003
+ */
6614
7004
  var OutlineModule = {
6615
7005
  __init__: [ 'outline' ],
6616
7006
  outline: [ 'type', Outline ]
6617
7007
  };
6618
7008
 
6619
7009
  /**
7010
+ * @typedef {import('../../core/Canvas').default} Canvas
6620
7011
  * @typedef {import('../../core/EventBus').default} EventBus
6621
7012
  */
6622
7013
 
@@ -6624,15 +7015,17 @@
6624
7015
  * A service that offers the current selection in a diagram.
6625
7016
  * Offers the api to control the selection, too.
6626
7017
  *
6627
- * @class
6628
- *
6629
7018
  * @param {EventBus} eventBus
7019
+ * @param {Canvas} canvas
6630
7020
  */
6631
7021
  function Selection(eventBus, canvas) {
6632
7022
 
6633
7023
  this._eventBus = eventBus;
6634
7024
  this._canvas = canvas;
6635
7025
 
7026
+ /**
7027
+ * @type {Object[]}
7028
+ */
6636
7029
  this._selectedElements = [];
6637
7030
 
6638
7031
  var self = this;
@@ -6649,7 +7042,11 @@
6649
7042
 
6650
7043
  Selection.$inject = [ 'eventBus', 'canvas' ];
6651
7044
 
6652
-
7045
+ /**
7046
+ * Deselect an element.
7047
+ *
7048
+ * @param {Object} element The element to deselect.
7049
+ */
6653
7050
  Selection.prototype.deselect = function(element) {
6654
7051
  var selectedElements = this._selectedElements;
6655
7052
 
@@ -6664,26 +7061,33 @@
6664
7061
  }
6665
7062
  };
6666
7063
 
6667
-
7064
+ /**
7065
+ * Get the selected elements.
7066
+ *
7067
+ * @return {Object[]} The selected elements.
7068
+ */
6668
7069
  Selection.prototype.get = function() {
6669
7070
  return this._selectedElements;
6670
7071
  };
6671
7072
 
7073
+ /**
7074
+ * Check whether an element is selected.
7075
+ *
7076
+ * @param {Object} element The element.
7077
+ *
7078
+ * @return {boolean} Whether the element is selected.
7079
+ */
6672
7080
  Selection.prototype.isSelected = function(element) {
6673
7081
  return this._selectedElements.indexOf(element) !== -1;
6674
7082
  };
6675
7083
 
6676
7084
 
6677
7085
  /**
6678
- * This method selects one or more elements on the diagram.
7086
+ * Select one or many elements.
6679
7087
  *
6680
- * By passing an additional add parameter you can decide whether or not the element(s)
6681
- * should be added to the already existing selection or not.
6682
- *
6683
- * @method Selection#select
6684
- *
6685
- * @param {Object|Object[]} elements element or array of elements to be selected
6686
- * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
7088
+ * @param {Object|Object[]} elements The element(s) to select.
7089
+ * @param {boolean} [add] Whether to add the element(s) to the selected elements.
7090
+ * Defaults to `false`.
6687
7091
  */
6688
7092
  Selection.prototype.select = function(elements, add) {
6689
7093
  var selectedElements = this._selectedElements,
@@ -6969,6 +7373,9 @@
6969
7373
  return !element.hidden;
6970
7374
  }
6971
7375
 
7376
+ /**
7377
+ * @type { import('didi').ModuleDeclaration }
7378
+ */
6972
7379
  var SelectionModule = {
6973
7380
  __init__: [ 'selectionVisuals', 'selectionBehavior' ],
6974
7381
  __depends__: [
@@ -6999,7 +7406,7 @@
6999
7406
  /**
7000
7407
  * Returns a next unique ID.
7001
7408
  *
7002
- * @returns {string} the id
7409
+ * @return {string} the id
7003
7410
  */
7004
7411
  IdGenerator.prototype.next = function() {
7005
7412
  return this._prefix + (++this._counter);
@@ -7015,12 +7422,54 @@
7015
7422
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
7016
7423
  * @typedef {import('../../core/EventBus').default} EventBus
7017
7424
  *
7018
- * @typedef {import('./Overlays').Overlay} Overlay
7019
- * @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
7020
- * @typedef {import('./Overlays').OverlayContainer} OverlayContainer
7021
- * @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
7022
- * @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
7023
- * @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
7425
+ * @typedef {import('../../model/Types').Element} Element
7426
+ *
7427
+ * @typedef { {
7428
+ * minZoom?: number,
7429
+ * maxZoom?: number
7430
+ * } } OverlaysConfigShow
7431
+ *
7432
+ * @typedef { {
7433
+ * min?: number,
7434
+ * max?: number
7435
+ * } } OverlaysConfigScale
7436
+ *
7437
+ * @typedef { {
7438
+ * id: string,
7439
+ * type: string | null,
7440
+ * element: Element | string
7441
+ * } & OverlayAttrs } Overlay
7442
+ *
7443
+ * @typedef { {
7444
+ * html: HTMLElement | string,
7445
+ * position: {
7446
+ * top?: number,
7447
+ * right?: number,
7448
+ * bottom?: number,
7449
+ * left?: number
7450
+ * }
7451
+ * } & OverlaysConfigDefault } OverlayAttrs
7452
+ *
7453
+ * @typedef { {
7454
+ * html: HTMLElement,
7455
+ * element: Element,
7456
+ * overlays: Overlay[]
7457
+ * } } OverlayContainer
7458
+ *
7459
+ * @typedef {{
7460
+ * defaults?: OverlaysConfigDefault
7461
+ * }} OverlaysConfig
7462
+ *
7463
+ * @typedef { {
7464
+ * show?: OverlaysConfigShow,
7465
+ * scale?: OverlaysConfigScale | boolean
7466
+ * } } OverlaysConfigDefault
7467
+ *
7468
+ * @typedef { {
7469
+ * id?: string;
7470
+ * element?: Element | string;
7471
+ * type?: string;
7472
+ * } | string } OverlaysFilter
7024
7473
  */
7025
7474
 
7026
7475
  /**
@@ -7030,6 +7479,7 @@
7030
7479
  *
7031
7480
  * @example
7032
7481
  *
7482
+ * ```javascript
7033
7483
  * // add a pink badge on the top left of the shape
7034
7484
  *
7035
7485
  * overlays.add(someShape, {
@@ -7059,8 +7509,9 @@
7059
7509
  * }
7060
7510
  * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
7061
7511
  * });
7512
+ * ```
7062
7513
  *
7063
- *
7514
+ * ```javascript
7064
7515
  * // remove an overlay
7065
7516
  *
7066
7517
  * var id = overlays.add(...);
@@ -7082,6 +7533,7 @@
7082
7533
  * }
7083
7534
  * }
7084
7535
  * }
7536
+ * ```
7085
7537
  *
7086
7538
  * @param {OverlaysConfig} config
7087
7539
  * @param {EventBus} eventBus
@@ -7140,6 +7592,7 @@
7140
7592
  *
7141
7593
  * @example
7142
7594
  *
7595
+ * ```javascript
7143
7596
  * // return the single overlay with the given ID
7144
7597
  * overlays.get('some-id');
7145
7598
  *
@@ -7151,6 +7604,7 @@
7151
7604
  *
7152
7605
  * // shape can also be specified as ID
7153
7606
  * overlays.get({ element: 'element-id', type: 'badge' });
7607
+ * ```
7154
7608
  *
7155
7609
  * @param {OverlaysFilter} search The filter to be used to find the overlay(s).
7156
7610
  *
@@ -7188,7 +7642,7 @@
7188
7642
  /**
7189
7643
  * Adds an HTML overlay to an element.
7190
7644
  *
7191
- * @param {Base|string} element The element to add the overlay to.
7645
+ * @param {Element|string} element The element to add the overlay to.
7192
7646
  * @param {string} [type] An optional type that can be used to filter.
7193
7647
  * @param {OverlayAttrs} overlay The overlay.
7194
7648
  *
@@ -7276,7 +7730,7 @@
7276
7730
  /**
7277
7731
  * Checks whether overlays are shown.
7278
7732
  *
7279
- * @returns {boolean} Whether overlays are shown.
7733
+ * @return {boolean} Whether overlays are shown.
7280
7734
  */
7281
7735
  Overlays.prototype.isShown = function() {
7282
7736
  return this._overlayRoot.style.display !== 'none';
@@ -7669,6 +8123,9 @@
7669
8123
  });
7670
8124
  }
7671
8125
 
8126
+ /**
8127
+ * @type { import('didi').ModuleDeclaration }
8128
+ */
7672
8129
  var OverlaysModule = {
7673
8130
  __init__: [ 'overlays' ],
7674
8131
  overlays: [ 'type', Overlays ]
@@ -7745,15 +8202,22 @@
7745
8202
  'graphicsFactory'
7746
8203
  ];
7747
8204
 
8205
+ /**
8206
+ * @type { import('didi').ModuleDeclaration }
8207
+ */
7748
8208
  var ChangeSupportModule = {
7749
8209
  __init__: [ 'changeSupport' ],
7750
8210
  changeSupport: [ 'type', ChangeSupport ]
7751
8211
  };
7752
8212
 
7753
8213
  /**
8214
+ * @typedef {import('../core/Types').ElementLike} ElementLike
7754
8215
  * @typedef {import('../core/EventBus').default} EventBus
7755
- * @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
7756
- * @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
8216
+ * @typedef {import('./CommandStack').CommandContext} CommandContext
8217
+ *
8218
+ * @typedef {string|string[]} Events
8219
+ * @typedef { (context: CommandContext) => ElementLike[] | void } HandlerFunction
8220
+ * @typedef { (context: CommandContext) => void } ComposeHandlerFunction
7757
8221
  */
7758
8222
 
7759
8223
  var DEFAULT_PRIORITY$1 = 1000;
@@ -7765,10 +8229,9 @@
7765
8229
  * @class
7766
8230
  * @constructor
7767
8231
  *
7768
- * @param {EventBus} eventBus
7769
- *
7770
8232
  * @example
7771
8233
  *
8234
+ * ```javascript
7772
8235
  * import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
7773
8236
  *
7774
8237
  * class CommandLogger extends CommandInterceptor {
@@ -7779,6 +8242,9 @@
7779
8242
  * console.log('commandStack.shape-create.preExecute', event);
7780
8243
  * });
7781
8244
  * }
8245
+ * ```
8246
+ *
8247
+ * @param {EventBus} eventBus
7782
8248
  */
7783
8249
  function CommandInterceptor(eventBus) {
7784
8250
 
@@ -7796,16 +8262,17 @@
7796
8262
  };
7797
8263
  }
7798
8264
 
8265
+
7799
8266
  /**
7800
- * Intercept a command during one of the phases.
7801
- *
7802
- * @param {string|string[]} [events] One or more commands to intercept.
7803
- * @param {string} [hook] Phase during which to intercept command.
7804
- * @param {number} [priority] Priority with which command will be intercepted.
7805
- * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7806
- * @param {boolean} [unwrap] Whether the event should be unwrapped.
7807
- * @param {*} [that] `this` value the callback will be called with.
7808
- */
8267
+ * Intercept a command during one of the phases.
8268
+ *
8269
+ * @param {Events} [events] command(s) to intercept
8270
+ * @param {string} [hook] phase to intercept
8271
+ * @param {number} [priority]
8272
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8273
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8274
+ * @param {any} [that]
8275
+ */
7809
8276
  CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
7810
8277
 
7811
8278
  if (isFunction(hook) || isNumber(hook)) {
@@ -7847,35 +8314,130 @@
7847
8314
  });
7848
8315
  };
7849
8316
 
8317
+ /**
8318
+ * Add a <canExecute> phase of command interceptor.
8319
+ *
8320
+ * @param {Events} [events] command(s) to intercept
8321
+ * @param {number} [priority]
8322
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8323
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8324
+ * @param {any} [that]
8325
+ */
8326
+ CommandInterceptor.prototype.canExecute = createHook('canExecute');
8327
+
8328
+ /**
8329
+ * Add a <preExecute> phase of command interceptor.
8330
+ *
8331
+ * @param {Events} [events] command(s) to intercept
8332
+ * @param {number} [priority]
8333
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8334
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8335
+ * @param {any} [that]
8336
+ */
8337
+ CommandInterceptor.prototype.preExecute = createHook('preExecute');
7850
8338
 
7851
- var hooks = [
7852
- 'canExecute',
7853
- 'preExecute',
7854
- 'preExecuted',
7855
- 'execute',
7856
- 'executed',
7857
- 'postExecute',
7858
- 'postExecuted',
7859
- 'revert',
7860
- 'reverted'
7861
- ];
8339
+ /**
8340
+ * Add a <preExecuted> phase of command interceptor.
8341
+ *
8342
+ * @param {Events} [events] command(s) to intercept
8343
+ * @param {number} [priority]
8344
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8345
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8346
+ * @param {any} [that]
8347
+ */
8348
+ CommandInterceptor.prototype.preExecuted = createHook('preExecuted');
8349
+
8350
+ /**
8351
+ * Add a <execute> phase of command interceptor.
8352
+ *
8353
+ * @param {Events} [events] command(s) to intercept
8354
+ * @param {number} [priority]
8355
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8356
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8357
+ * @param {any} [that]
8358
+ */
8359
+ CommandInterceptor.prototype.execute = createHook('execute');
8360
+
8361
+ /**
8362
+ * Add a <executed> phase of command interceptor.
8363
+ *
8364
+ * @param {Events} [events] command(s) to intercept
8365
+ * @param {number} [priority]
8366
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8367
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8368
+ * @param {any} [that]
8369
+ */
8370
+ CommandInterceptor.prototype.executed = createHook('executed');
8371
+
8372
+ /**
8373
+ * Add a <postExecute> phase of command interceptor.
8374
+ *
8375
+ * @param {Events} [events] command(s) to intercept
8376
+ * @param {number} [priority]
8377
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8378
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8379
+ * @param {any} [that]
8380
+ */
8381
+ CommandInterceptor.prototype.postExecute = createHook('postExecute');
8382
+
8383
+ /**
8384
+ * Add a <postExecuted> phase of command interceptor.
8385
+ *
8386
+ * @param {Events} [events] command(s) to intercept
8387
+ * @param {number} [priority]
8388
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8389
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8390
+ * @param {any} [that]
8391
+ */
8392
+ CommandInterceptor.prototype.postExecuted = createHook('postExecuted');
8393
+
8394
+ /**
8395
+ * Add a <revert> phase of command interceptor.
8396
+ *
8397
+ * @param {Events} [events] command(s) to intercept
8398
+ * @param {number} [priority]
8399
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8400
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8401
+ * @param {any} [that]
8402
+ */
8403
+ CommandInterceptor.prototype.revert = createHook('revert');
8404
+
8405
+ /**
8406
+ * Add a <reverted> phase of command interceptor.
8407
+ *
8408
+ * @param {Events} [events] command(s) to intercept
8409
+ * @param {number} [priority]
8410
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8411
+ * @param {boolean} [unwrap] whether the event should be unwrapped
8412
+ * @param {any} [that]
8413
+ */
8414
+ CommandInterceptor.prototype.reverted = createHook('reverted');
7862
8415
 
7863
8416
  /*
7864
8417
  * Add prototype methods for each phase of command execution (e.g. execute,
7865
8418
  * revert).
8419
+ *
8420
+ * @param {string} hook
8421
+ *
8422
+ * @return { (
8423
+ * events?: Events,
8424
+ * priority?: number,
8425
+ * handlerFn: ComposeHandlerFunction|HandlerFunction,
8426
+ * unwrap?: boolean
8427
+ * ) => any }
7866
8428
  */
7867
- forEach$1(hooks, function(hook) {
8429
+ function createHook(hook) {
7868
8430
 
7869
8431
  /**
7870
- * Add prototype method for a specific phase of command execution.
8432
+ * @this {CommandInterceptor}
7871
8433
  *
7872
- * @param {string|string[]} [events] One or more commands to intercept.
7873
- * @param {number} [priority] Priority with which command will be intercepted.
7874
- * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7875
- * @param {boolean} [unwrap] Whether the event should be unwrapped.
7876
- * @param {*} [that] `this` value the callback will be called with.
8434
+ * @param {Events} [events]
8435
+ * @param {number} [priority]
8436
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn
8437
+ * @param {boolean} [unwrap]
8438
+ * @param {any} [that]
7877
8439
  */
7878
- CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
8440
+ const hookFn = function(events, priority, handlerFn, unwrap, that) {
7879
8441
 
7880
8442
  if (isFunction(events) || isNumber(events)) {
7881
8443
  that = unwrap;
@@ -7887,7 +8449,9 @@
7887
8449
 
7888
8450
  this.on(events, hook, priority, handlerFn, unwrap, that);
7889
8451
  };
7890
- });
8452
+
8453
+ return hookFn;
8454
+ }
7891
8455
 
7892
8456
  /**
7893
8457
  * @typedef {import('didi').Injector} Injector
@@ -7929,6 +8493,9 @@
7929
8493
 
7930
8494
  RootElementsBehavior.$inject = [ 'canvas', 'injector' ];
7931
8495
 
8496
+ /**
8497
+ * @type { import('didi').ModuleDeclaration }
8498
+ */
7932
8499
  var RootElementsModule = {
7933
8500
  __init__: [ 'rootElementsBehavior' ],
7934
8501
  rootElementsBehavior: [ 'type', RootElementsBehavior ]
@@ -7936,7 +8503,7 @@
7936
8503
 
7937
8504
  /**
7938
8505
  * @param {string} str
7939
- * @returns {string}
8506
+ * @return {string}
7940
8507
  */
7941
8508
 
7942
8509
  var HTML_ESCAPE_MAP = {
@@ -7955,14 +8522,19 @@
7955
8522
  });
7956
8523
  }
7957
8524
 
8525
+ /**
8526
+ * @typedef {import('../model/Types').Element} Element
8527
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
8528
+ */
8529
+
7958
8530
  var planeSuffix = '_plane';
7959
8531
 
7960
8532
  /**
7961
8533
  * Get plane ID for a primary shape.
7962
8534
  *
7963
- * @param {djs.model.Base|ModdleElement} element
8535
+ * @param {Element|ModdleElement} element
7964
8536
  *
7965
- * @returns {String}
8537
+ * @return {string}
7966
8538
  */
7967
8539
  function getPlaneIdFromShape(element) {
7968
8540
  var id = element.id;
@@ -7978,32 +8550,40 @@
7978
8550
  return id + planeSuffix;
7979
8551
  }
7980
8552
 
8553
+ /**
8554
+ * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
8555
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
8556
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
8557
+ *
8558
+ * @typedef {import('../../model/Types').Element} Element
8559
+ * @typedef {import('../../model/Types').Shape} Shape
8560
+ */
8561
+
7981
8562
  var OPEN_CLASS = 'bjs-breadcrumbs-shown';
7982
8563
 
7983
8564
 
7984
8565
  /**
7985
8566
  * Adds overlays that allow switching planes on collapsed subprocesses.
7986
8567
  *
7987
- * @param {eventBus} eventBus
7988
- * @param {elementRegistry} elementRegistry
7989
- * @param {overlays} overlays
7990
- * @param {canvas} canvas
8568
+ * @param {EventBus} eventBus
8569
+ * @param {ElementRegistry} elementRegistry
8570
+ * @param {Canvas} canvas
7991
8571
  */
7992
- function DrilldownBreadcrumbs(eventBus, elementRegistry, overlays, canvas) {
8572
+ function DrilldownBreadcrumbs(eventBus, elementRegistry, canvas) {
7993
8573
  var breadcrumbs = domify$1('<ul class="bjs-breadcrumbs"></ul>');
7994
8574
  var container = canvas.getContainer();
7995
8575
  var containerClasses = classes(container);
7996
8576
  container.appendChild(breadcrumbs);
7997
8577
 
7998
- var boParents = [];
8578
+ var businessObjectParents = [];
7999
8579
 
8000
8580
  // update breadcrumbs if name or ID of the primary shape changes
8001
- eventBus.on('element.changed', function(e) {
8002
- var shape = e.element,
8003
- bo = getBusinessObject(shape);
8581
+ eventBus.on('element.changed', function(event) {
8582
+ var shape = event.element,
8583
+ businessObject = getBusinessObject(shape);
8004
8584
 
8005
- var isPresent = find(boParents, function(el) {
8006
- return el === bo;
8585
+ var isPresent = find(businessObjectParents, function(element) {
8586
+ return element === businessObject;
8007
8587
  });
8008
8588
 
8009
8589
  if (!isPresent) {
@@ -8017,14 +8597,14 @@
8017
8597
  * Updates the displayed breadcrumbs. If no element is provided, only the
8018
8598
  * labels are updated.
8019
8599
  *
8020
- * @param {djs.model.Base} [element]
8600
+ * @param {Element} [element]
8021
8601
  */
8022
8602
  function updateBreadcrumbs(element) {
8023
8603
  if (element) {
8024
- boParents = getBoParentChain(element);
8604
+ businessObjectParents = getBusinessObjectParentChain(element);
8025
8605
  }
8026
8606
 
8027
- var path = boParents.map(function(parent) {
8607
+ var path = businessObjectParents.map(function(parent) {
8028
8608
  var title = escapeHTML(parent.name || parent.id);
8029
8609
  var link = domify$1('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
8030
8610
 
@@ -8034,8 +8614,9 @@
8034
8614
  // element in the elementRegisty. Instead, we search for the corresponding participant
8035
8615
  if (!parentPlane && is$1(parent, 'bpmn:Process')) {
8036
8616
  var participant = elementRegistry.find(function(element) {
8037
- var bo = getBusinessObject(element);
8038
- return bo && bo.processRef && bo.processRef === parent;
8617
+ var businessObject = getBusinessObject(element);
8618
+
8619
+ return businessObject && businessObject.get('processRef') && businessObject.get('processRef') === parent;
8039
8620
  });
8040
8621
 
8041
8622
  parentPlane = canvas.findRoot(participant.id);
@@ -8052,10 +8633,11 @@
8052
8633
 
8053
8634
  // show breadcrumbs and expose state to .djs-container
8054
8635
  var visible = path.length > 1;
8636
+
8055
8637
  containerClasses.toggle(OPEN_CLASS, visible);
8056
8638
 
8057
- path.forEach(function(el) {
8058
- breadcrumbs.appendChild(el);
8639
+ path.forEach(function(element) {
8640
+ breadcrumbs.appendChild(element);
8059
8641
  });
8060
8642
  }
8061
8643
 
@@ -8065,7 +8647,7 @@
8065
8647
 
8066
8648
  }
8067
8649
 
8068
- DrilldownBreadcrumbs.$inject = [ 'eventBus', 'elementRegistry', 'overlays', 'canvas' ];
8650
+ DrilldownBreadcrumbs.$inject = [ 'eventBus', 'elementRegistry', 'canvas' ];
8069
8651
 
8070
8652
 
8071
8653
  // helpers //////////
@@ -8074,16 +8656,16 @@
8074
8656
  * Returns the parents for the element using the business object chain,
8075
8657
  * starting with the root element.
8076
8658
  *
8077
- * @param {djs.model.Shape} child
8659
+ * @param {Shape} child
8078
8660
  *
8079
- * @returns {Array<djs.model.Shape>} parents
8661
+ * @return {Shape}
8080
8662
  */
8081
- function getBoParentChain(child) {
8082
- var bo = getBusinessObject(child);
8663
+ function getBusinessObjectParentChain(child) {
8664
+ var businessObject = getBusinessObject(child);
8083
8665
 
8084
8666
  var parents = [];
8085
8667
 
8086
- for (var element = bo; element; element = element.$parent) {
8668
+ for (var element = businessObject; element; element = element.$parent) {
8087
8669
  if (is$1(element, 'bpmn:SubProcess') || is$1(element, 'bpmn:Process')) {
8088
8670
  parents.push(element);
8089
8671
  }
@@ -8092,13 +8674,18 @@
8092
8674
  return parents.reverse();
8093
8675
  }
8094
8676
 
8677
+ /**
8678
+ * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
8679
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
8680
+ */
8681
+
8095
8682
  /**
8096
8683
  * Move collapsed subprocesses into view when drilling down.
8097
8684
  *
8098
8685
  * Zoom and scroll are saved in a session.
8099
8686
  *
8100
- * @param {eventBus} eventBus
8101
- * @param {canvas} canvas
8687
+ * @param {EventBus} eventBus
8688
+ * @param {Canvas} canvas
8102
8689
  */
8103
8690
  function DrilldownCentering(eventBus, canvas) {
8104
8691
 
@@ -8209,6 +8796,18 @@
8209
8796
  };
8210
8797
  }
8211
8798
 
8799
+ /**
8800
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
8801
+ * @typedef {import('../../model/Types').Moddle} Moddle
8802
+ *
8803
+ * @typedef {import('../../model/Types').Element} Element
8804
+ * @typedef {import('../../model/Types').Shape} Shape
8805
+ *
8806
+ * @typedef {import('diagram-js/lib/core/Canvas').CanvasPlane} CanvasPlane
8807
+ *
8808
+ * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
8809
+ */
8810
+
8212
8811
  var DEFAULT_POSITION = {
8213
8812
  x: 180,
8214
8813
  y: 160
@@ -8216,10 +8815,10 @@
8216
8815
 
8217
8816
  /**
8218
8817
  * Hook into `import.render.start` and create new planes for diagrams with
8219
- * collapsed subprocesses and all dis on the same plane.
8818
+ * collapsed subprocesses and all DI elements on the same plane.
8220
8819
  *
8221
- * @param {eventBus} eventBus
8222
- * @param {moddle} moddle
8820
+ * @param {EventBus} eventBus
8821
+ * @param {Moddle} moddle
8223
8822
  */
8224
8823
  function SubprocessCompatibility(eventBus, moddle) {
8225
8824
  this._eventBus = eventBus;
@@ -8228,11 +8827,14 @@
8228
8827
  var self = this;
8229
8828
 
8230
8829
  eventBus.on('import.render.start', 1500, function(e, context) {
8231
- self.handleImport(context.definitions);
8830
+ self._handleImport(context.definitions);
8232
8831
  });
8233
8832
  }
8234
8833
 
8235
- SubprocessCompatibility.prototype.handleImport = function(definitions) {
8834
+ /**
8835
+ * @param {ModdleElement} definitions
8836
+ */
8837
+ SubprocessCompatibility.prototype._handleImport = function(definitions) {
8236
8838
  if (!definitions.diagrams) {
8237
8839
  return;
8238
8840
  }
@@ -8251,12 +8853,12 @@
8251
8853
 
8252
8854
  var newDiagrams = [];
8253
8855
  definitions.diagrams.forEach(function(diagram) {
8254
- var createdDiagrams = self.createNewDiagrams(diagram.plane);
8856
+ var createdDiagrams = self._createNewDiagrams(diagram.plane);
8255
8857
  Array.prototype.push.apply(newDiagrams, createdDiagrams);
8256
8858
  });
8257
8859
 
8258
8860
  newDiagrams.forEach(function(diagram) {
8259
- self.movePlaneElementsToOrigin(diagram.plane);
8861
+ self._movePlaneElementsToOrigin(diagram.plane);
8260
8862
  });
8261
8863
  };
8262
8864
 
@@ -8264,29 +8866,30 @@
8264
8866
  /**
8265
8867
  * Moves all DI elements from collapsed subprocesses to a new plane.
8266
8868
  *
8267
- * @param {Object} plane
8268
- * @return {Array} new diagrams created for the collapsed subprocesses
8869
+ * @param {CanvasPlane} plane
8870
+ *
8871
+ * @return {ModdleElement[]} new diagrams created for the collapsed subprocesses
8269
8872
  */
8270
- SubprocessCompatibility.prototype.createNewDiagrams = function(plane) {
8873
+ SubprocessCompatibility.prototype._createNewDiagrams = function(plane) {
8271
8874
  var self = this;
8272
8875
 
8273
8876
  var collapsedElements = [];
8274
8877
  var elementsToMove = [];
8275
8878
 
8276
8879
  plane.get('planeElement').forEach(function(diElement) {
8277
- var bo = diElement.bpmnElement;
8880
+ var businessObject = diElement.bpmnElement;
8278
8881
 
8279
- if (!bo) {
8882
+ if (!businessObject) {
8280
8883
  return;
8281
8884
  }
8282
8885
 
8283
- var parent = bo.$parent;
8886
+ var parent = businessObject.$parent;
8284
8887
 
8285
- if (is$1(bo, 'bpmn:SubProcess') && !diElement.isExpanded) {
8286
- collapsedElements.push(bo);
8888
+ if (is$1(businessObject, 'bpmn:SubProcess') && !diElement.isExpanded) {
8889
+ collapsedElements.push(businessObject);
8287
8890
  }
8288
8891
 
8289
- if (shouldMoveToPlane(bo, plane)) {
8892
+ if (shouldMoveToPlane(businessObject, plane)) {
8290
8893
 
8291
8894
  // don't change the array while we iterate over it
8292
8895
  elementsToMove.push({ diElement: diElement, parent: parent });
@@ -8297,9 +8900,11 @@
8297
8900
 
8298
8901
  // create new planes for all collapsed subprocesses, even when they are empty
8299
8902
  collapsedElements.forEach(function(element) {
8300
- if (!self._processToDiagramMap[element.id]) {
8301
- var diagram = self.createDiagram(element);
8903
+ if (!self._processToDiagramMap[ element.id ]) {
8904
+ var diagram = self._createDiagram(element);
8905
+
8302
8906
  self._processToDiagramMap[element.id] = diagram;
8907
+
8303
8908
  newDiagrams.push(diagram);
8304
8909
  }
8305
8910
  });
@@ -8318,14 +8923,18 @@
8318
8923
  return;
8319
8924
  }
8320
8925
 
8321
- var diagram = self._processToDiagramMap[parent.id];
8322
- self.moveToDiPlane(diElement, diagram.plane);
8926
+ var diagram = self._processToDiagramMap[ parent.id ];
8927
+
8928
+ self._moveToDiPlane(diElement, diagram.plane);
8323
8929
  });
8324
8930
 
8325
8931
  return newDiagrams;
8326
8932
  };
8327
8933
 
8328
- SubprocessCompatibility.prototype.movePlaneElementsToOrigin = function(plane) {
8934
+ /**
8935
+ * @param {CanvasPlane} plane
8936
+ */
8937
+ SubprocessCompatibility.prototype._movePlaneElementsToOrigin = function(plane) {
8329
8938
  var elements = plane.get('planeElement');
8330
8939
 
8331
8940
  // get bounding box of all elements
@@ -8349,33 +8958,50 @@
8349
8958
  });
8350
8959
  };
8351
8960
 
8352
-
8353
- SubprocessCompatibility.prototype.moveToDiPlane = function(diElement, newPlane) {
8961
+ /**
8962
+ * @param {ModdleElement} diElement
8963
+ * @param {CanvasPlane} newPlane
8964
+ */
8965
+ SubprocessCompatibility.prototype._moveToDiPlane = function(diElement, newPlane) {
8354
8966
  var containingDiagram = findRootDiagram(diElement);
8355
8967
 
8356
8968
  // remove DI from old Plane and add it to the new one
8357
8969
  var parentPlaneElement = containingDiagram.plane.get('planeElement');
8970
+
8358
8971
  parentPlaneElement.splice(parentPlaneElement.indexOf(diElement), 1);
8972
+
8359
8973
  newPlane.get('planeElement').push(diElement);
8360
8974
  };
8361
8975
 
8976
+ /**
8977
+ * @param {ModdleElement} businessObject
8978
+ *
8979
+ * @return {ModdleElement}
8980
+ */
8981
+ SubprocessCompatibility.prototype._createDiagram = function(businessObject) {
8982
+ var plane = this._moddle.create('bpmndi:BPMNPlane', {
8983
+ bpmnElement: businessObject
8984
+ });
8362
8985
 
8363
- SubprocessCompatibility.prototype.createDiagram = function(bo) {
8364
- var plane = this._moddle.create('bpmndi:BPMNPlane', { bpmnElement: bo });
8365
8986
  var diagram = this._moddle.create('bpmndi:BPMNDiagram', {
8366
8987
  plane: plane
8367
8988
  });
8989
+
8368
8990
  plane.$parent = diagram;
8369
- plane.bpmnElement = bo;
8991
+
8992
+ plane.bpmnElement = businessObject;
8993
+
8370
8994
  diagram.$parent = this._definitions;
8995
+
8371
8996
  this._definitions.diagrams.push(diagram);
8997
+
8372
8998
  return diagram;
8373
8999
  };
8374
9000
 
8375
9001
  SubprocessCompatibility.$inject = [ 'eventBus', 'moddle' ];
8376
9002
 
8377
9003
 
8378
- // helpers //////////////////////////
9004
+ // helpers //////////
8379
9005
 
8380
9006
  function findRootDiagram(element) {
8381
9007
  if (is$1(element, 'bpmndi:BPMNDiagram')) {
@@ -8385,6 +9011,11 @@
8385
9011
  }
8386
9012
  }
8387
9013
 
9014
+ /**
9015
+ * @param {CanvasPlane} plane
9016
+ *
9017
+ * @return {Rect}
9018
+ */
8388
9019
  function getPlaneBounds(plane) {
8389
9020
  var planeTrbl = {
8390
9021
  top: Infinity,
@@ -8407,8 +9038,14 @@
8407
9038
  return asBounds(planeTrbl);
8408
9039
  }
8409
9040
 
8410
- function shouldMoveToPlane(bo, plane) {
8411
- var parent = bo.$parent;
9041
+ /**
9042
+ * @param {ModdleElement} businessObject
9043
+ * @param {CanvasPlane} plane
9044
+ *
9045
+ * @return {boolean}
9046
+ */
9047
+ function shouldMoveToPlane(businessObject, plane) {
9048
+ var parent = businessObject.$parent;
8412
9049
 
8413
9050
  // don't move elements that are already on the plane
8414
9051
  if (!is$1(parent, 'bpmn:SubProcess') || parent === plane.bpmnElement) {
@@ -8417,18 +9054,35 @@
8417
9054
 
8418
9055
  // dataAssociations are children of the subprocess but rendered on process level
8419
9056
  // cf. https://github.com/bpmn-io/bpmn-js/issues/1619
8420
- if (isAny(bo, [ 'bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation' ])) {
9057
+ if (isAny(businessObject, [ 'bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation' ])) {
8421
9058
  return false;
8422
9059
  }
8423
9060
 
8424
9061
  return true;
8425
9062
  }
8426
9063
 
9064
+ /**
9065
+ * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
9066
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
9067
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
9068
+ * @typedef {import('diagram-js/lib/features/overlays/Overlays').default} Overlays
9069
+ *
9070
+ * @typedef {import('../../model/Types').Element} Element
9071
+ * @typedef {import('../../model/Types').Parent} Parent
9072
+ * @typedef {import('../../model/Types').Shape} Shape
9073
+ */
9074
+
8427
9075
  var LOW_PRIORITY = 250;
8428
9076
  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>';
8429
9077
 
8430
9078
  var EMPTY_MARKER = 'bjs-drilldown-empty';
8431
9079
 
9080
+ /**
9081
+ * @param {Canvas} canvas
9082
+ * @param {EventBus} eventBus
9083
+ * @param {ElementRegistry} elementRegistry
9084
+ * @param {Overlays} overlays
9085
+ */
8432
9086
  function DrilldownOverlayBehavior(
8433
9087
  canvas, eventBus, elementRegistry, overlays
8434
9088
  ) {
@@ -8445,10 +9099,10 @@
8445
9099
  var shape = context.shape;
8446
9100
 
8447
9101
  // Add overlay to the collapsed shape
8448
- if (self.canDrillDown(shape)) {
8449
- self.addOverlay(shape);
9102
+ if (self._canDrillDown(shape)) {
9103
+ self._addOverlay(shape);
8450
9104
  } else {
8451
- self.removeOverlay(shape);
9105
+ self._removeOverlay(shape);
8452
9106
  }
8453
9107
  }, true);
8454
9108
 
@@ -8457,10 +9111,10 @@
8457
9111
  var shape = context.shape;
8458
9112
 
8459
9113
  // Add overlay to the collapsed shape
8460
- if (self.canDrillDown(shape)) {
8461
- self.addOverlay(shape);
9114
+ if (self._canDrillDown(shape)) {
9115
+ self._addOverlay(shape);
8462
9116
  } else {
8463
- self.removeOverlay(shape);
9117
+ self._removeOverlay(shape);
8464
9118
  }
8465
9119
  }, true);
8466
9120
 
@@ -8472,13 +9126,13 @@
8472
9126
  shape = context.shape;
8473
9127
 
8474
9128
  // Add overlay to the collapsed shape
8475
- if (self.canDrillDown(shape)) {
8476
- self.addOverlay(shape);
9129
+ if (self._canDrillDown(shape)) {
9130
+ self._addOverlay(shape);
8477
9131
  }
8478
9132
 
8479
- self.updateDrilldownOverlay(oldParent);
8480
- self.updateDrilldownOverlay(newParent);
8481
- self.updateDrilldownOverlay(shape);
9133
+ self._updateDrilldownOverlay(oldParent);
9134
+ self._updateDrilldownOverlay(newParent);
9135
+ self._updateDrilldownOverlay(shape);
8482
9136
  }, true);
8483
9137
 
8484
9138
 
@@ -8489,21 +9143,21 @@
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
 
8502
9156
  eventBus.on('import.render.complete', function() {
8503
9157
  elementRegistry.filter(function(e) {
8504
- return self.canDrillDown(e);
9158
+ return self._canDrillDown(e);
8505
9159
  }).map(function(el) {
8506
- self.addOverlay(el);
9160
+ self._addOverlay(el);
8507
9161
  });
8508
9162
  });
8509
9163
 
@@ -8511,7 +9165,10 @@
8511
9165
 
8512
9166
  e(DrilldownOverlayBehavior, CommandInterceptor);
8513
9167
 
8514
- DrilldownOverlayBehavior.prototype.updateDrilldownOverlay = function(shape) {
9168
+ /**
9169
+ * @param {Shape} shape
9170
+ */
9171
+ DrilldownOverlayBehavior.prototype._updateDrilldownOverlay = function(shape) {
8515
9172
  var canvas = this._canvas;
8516
9173
 
8517
9174
  if (!shape) {
@@ -8519,51 +9176,61 @@
8519
9176
  }
8520
9177
 
8521
9178
  var root = canvas.findRoot(shape);
9179
+
8522
9180
  if (root) {
8523
- this.updateOverlayVisibility(root);
9181
+ this._updateOverlayVisibility(root);
8524
9182
  }
8525
9183
  };
8526
9184
 
8527
-
8528
- DrilldownOverlayBehavior.prototype.canDrillDown = function(element) {
9185
+ /**
9186
+ * @param {Element} element
9187
+ *
9188
+ * @return {boolean}
9189
+ */
9190
+ DrilldownOverlayBehavior.prototype._canDrillDown = function(element) {
8529
9191
  var canvas = this._canvas;
9192
+
8530
9193
  return is$1(element, 'bpmn:SubProcess') && canvas.findRoot(getPlaneIdFromShape(element));
8531
9194
  };
8532
9195
 
8533
9196
  /**
8534
- * Updates visibility of the drilldown overlay. If the plane has no elements,
8535
- * the drilldown will be only shown when the element is selected.
9197
+ * Update the visibility of the drilldown overlay. If the plane has no elements,
9198
+ * the drilldown will only be shown when the element is selected.
8536
9199
  *
8537
- * @param {djs.model.Shape|djs.model.Root} element collapsed shape or root element
9200
+ * @param {Parent} element The collapsed root or shape.
8538
9201
  */
8539
- DrilldownOverlayBehavior.prototype.updateOverlayVisibility = function(element) {
9202
+ DrilldownOverlayBehavior.prototype._updateOverlayVisibility = function(element) {
8540
9203
  var overlays = this._overlays;
8541
9204
 
8542
- var bo = element.businessObject;
9205
+ var businessObject = getBusinessObject(element);
8543
9206
 
8544
- var overlay = overlays.get({ element: bo.id, type: 'drilldown' })[0];
9207
+ var overlay = overlays.get({ element: businessObject.id, type: 'drilldown' })[0];
8545
9208
 
8546
9209
  if (!overlay) {
8547
9210
  return;
8548
9211
  }
8549
9212
 
8550
- var hasContent = bo && bo.flowElements && bo.flowElements.length;
8551
- classes(overlay.html).toggle(EMPTY_MARKER, !hasContent);
9213
+ var hasFlowElements = businessObject
9214
+ && businessObject.get('flowElements')
9215
+ && businessObject.get('flowElements').length;
9216
+
9217
+ classes(overlay.html).toggle(EMPTY_MARKER, !hasFlowElements);
8552
9218
  };
8553
9219
 
8554
9220
  /**
8555
- * Attaches a drilldown button to the given element. We assume that the plane has
8556
- * the same id as the element.
9221
+ * Add a drilldown button to the given element assuming the plane has the same
9222
+ * ID as the element.
8557
9223
  *
8558
- * @param {djs.model.Shape} element collapsed shape
9224
+ * @param {Shape} element The collapsed shape.
8559
9225
  */
8560
- DrilldownOverlayBehavior.prototype.addOverlay = function(element) {
8561
- var canvas = this._canvas;
8562
- var overlays = this._overlays;
9226
+ DrilldownOverlayBehavior.prototype._addOverlay = function(element) {
9227
+ var canvas = this._canvas,
9228
+ overlays = this._overlays;
8563
9229
 
8564
9230
  var existingOverlays = overlays.get({ element: element, type: 'drilldown' });
9231
+
8565
9232
  if (existingOverlays.length) {
8566
- this.removeOverlay(element);
9233
+ this._removeOverlay(element);
8567
9234
  }
8568
9235
 
8569
9236
  var button = domify$1('<button class="bjs-drilldown">' + ARROW_DOWN_SVG + '</button>');
@@ -8580,10 +9247,10 @@
8580
9247
  html: button
8581
9248
  });
8582
9249
 
8583
- this.updateOverlayVisibility(element);
9250
+ this._updateOverlayVisibility(element);
8584
9251
  };
8585
9252
 
8586
- DrilldownOverlayBehavior.prototype.removeOverlay = function(element) {
9253
+ DrilldownOverlayBehavior.prototype._removeOverlay = function(element) {
8587
9254
  var overlays = this._overlays;
8588
9255
 
8589
9256
  overlays.remove({
@@ -9089,7 +9756,6 @@
9089
9756
  */
9090
9757
  function DefaultRenderer(eventBus, styles) {
9091
9758
 
9092
- //
9093
9759
  BaseRenderer.call(this, eventBus, DEFAULT_RENDER_PRIORITY);
9094
9760
 
9095
9761
  this.CONNECTION_STYLE = styles.style([ 'no-fill' ], { strokeWidth: 5, stroke: 'fuchsia' });
@@ -9100,10 +9766,16 @@
9100
9766
  e(DefaultRenderer, BaseRenderer);
9101
9767
 
9102
9768
 
9769
+ /**
9770
+ * @private
9771
+ */
9103
9772
  DefaultRenderer.prototype.canRender = function() {
9104
9773
  return true;
9105
9774
  };
9106
9775
 
9776
+ /**
9777
+ * @private
9778
+ */
9107
9779
  DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
9108
9780
  var rect = create$1('rect');
9109
9781
 
@@ -9125,6 +9797,9 @@
9125
9797
  return rect;
9126
9798
  };
9127
9799
 
9800
+ /**
9801
+ * @private
9802
+ */
9128
9803
  DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
9129
9804
 
9130
9805
  var line = createLine(connection.waypoints, assign$1({}, this.CONNECTION_STYLE, attrs || {}));
@@ -9133,6 +9808,9 @@
9133
9808
  return line;
9134
9809
  };
9135
9810
 
9811
+ /**
9812
+ * @private
9813
+ */
9136
9814
  DefaultRenderer.prototype.getShapePath = function getShapePath(shape) {
9137
9815
 
9138
9816
  var x = shape.x,
@@ -9151,6 +9829,9 @@
9151
9829
  return componentsToPath(shapePath);
9152
9830
  };
9153
9831
 
9832
+ /**
9833
+ * @private
9834
+ */
9154
9835
  DefaultRenderer.prototype.getConnectionPath = function getConnectionPath(connection) {
9155
9836
  var waypoints = connection.waypoints;
9156
9837
 
@@ -9168,7 +9849,6 @@
9168
9849
  return componentsToPath(connectionPath);
9169
9850
  };
9170
9851
 
9171
-
9172
9852
  DefaultRenderer.$inject = [ 'eventBus', 'styles' ];
9173
9853
 
9174
9854
  /**
@@ -9195,7 +9875,7 @@
9195
9875
  * Builds a style definition from a className, a list of traits and an object of additional attributes.
9196
9876
  *
9197
9877
  * @param {string} className
9198
- * @param {Array<string>} traits
9878
+ * @param {string[]} traits
9199
9879
  * @param {Object} additionalAttrs
9200
9880
  *
9201
9881
  * @return {Object} the style defintion
@@ -9209,7 +9889,7 @@
9209
9889
  /**
9210
9890
  * Builds a style definition from a list of traits and an object of additional attributes.
9211
9891
  *
9212
- * @param {Array<string>} traits
9892
+ * @param {string[]} traits
9213
9893
  * @param {Object} additionalAttrs
9214
9894
  *
9215
9895
  * @return {Object} the style defintion
@@ -9238,6 +9918,9 @@
9238
9918
  };
9239
9919
  }
9240
9920
 
9921
+ /**
9922
+ * @type { import('didi').ModuleDeclaration }
9923
+ */
9241
9924
  var DrawModule = {
9242
9925
  __init__: [ 'defaultRenderer' ],
9243
9926
  defaultRenderer: [ 'type', DefaultRenderer ],
@@ -9319,15 +10002,34 @@
9319
10002
  }
9320
10003
 
9321
10004
  /**
9322
- * @typedef {import('.').ConnectionLike} ConnectionLike
9323
- * @typedef {import('.').RootLike} RootLike
9324
- * @typedef {import('.').ShapeLike} ShapeLike
9325
- *
9326
- * @typedef {import('./Canvas').CanvasConfig} CanvasConfig
9327
- * @typedef {import('./Canvas').CanvasLayer} CanvasLayer
9328
- * @typedef {import('./Canvas').CanvasLayers} CanvasLayers
9329
- * @typedef {import('./Canvas').CanvasPlane} CanvasPlane
9330
- * @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
10005
+ * @typedef {import('./Types').ConnectionLike} ConnectionLike
10006
+ * @typedef {import('./Types').RootLike} RootLike
10007
+ * @typedef {import('./Types').ParentLike } ParentLike
10008
+ * @typedef {import('./Types').ShapeLike} ShapeLike
10009
+ *
10010
+ * @typedef { {
10011
+ * container?: HTMLElement;
10012
+ * deferUpdate?: boolean;
10013
+ * width?: number;
10014
+ * height?: number;
10015
+ * } } CanvasConfig
10016
+ * @typedef { {
10017
+ * group: SVGElement;
10018
+ * index: number;
10019
+ * visible: boolean;
10020
+ * } } CanvasLayer
10021
+ * @typedef { {
10022
+ * [key: string]: CanvasLayer;
10023
+ * } } CanvasLayers
10024
+ * @typedef { {
10025
+ * rootElement: ShapeLike;
10026
+ * layer: CanvasLayer;
10027
+ * } } CanvasPlane
10028
+ * @typedef { {
10029
+ * scale: number;
10030
+ * inner: Rect;
10031
+ * outer: Dimensions;
10032
+ * } & Rect } CanvasViewbox
9331
10033
  *
9332
10034
  * @typedef {import('./ElementRegistry').default} ElementRegistry
9333
10035
  * @typedef {import('./EventBus').default} EventBus
@@ -9668,7 +10370,7 @@
9668
10370
  /**
9669
10371
  * Shows a given layer.
9670
10372
  *
9671
- * @param {string} layer The name of the layer.
10373
+ * @param {string} name The name of the layer.
9672
10374
  *
9673
10375
  * @return {SVGElement} The SVG element of the layer.
9674
10376
  */
@@ -9704,7 +10406,7 @@
9704
10406
  /**
9705
10407
  * Hides a given layer.
9706
10408
  *
9707
- * @param {string} layer The name of the layer.
10409
+ * @param {string} name The name of the layer.
9708
10410
  *
9709
10411
  * @return {SVGElement} The SVG element of the layer.
9710
10412
  */
@@ -9846,7 +10548,7 @@
9846
10548
  *
9847
10549
  * @event element.marker.update
9848
10550
  * @type {Object}
9849
- * @property {Base} element the shape
10551
+ * @property {Element} element the shape
9850
10552
  * @property {SVGElement} gfx the graphical representation of the shape
9851
10553
  * @property {string} marker
9852
10554
  * @property {boolean} add true if the marker was added, false if it got removed
@@ -9952,7 +10654,7 @@
9952
10654
  /**
9953
10655
  * Adds a given root element and returns it.
9954
10656
  *
9955
- * @param {ShapeLike} [rootElement] The root element to be added.
10657
+ * @param {RootLike} [rootElement] The root element to be added.
9956
10658
  *
9957
10659
  * @return {RootLike} The added root element or an implicit root element.
9958
10660
  */
@@ -9988,9 +10690,9 @@
9988
10690
  /**
9989
10691
  * Removes a given root element and returns it.
9990
10692
  *
9991
- * @param {ShapeLike|string} rootElement The root element or its ID.
10693
+ * @param {RootLike|string} rootElement element or element ID
9992
10694
  *
9993
- * @return {ShapeLike|undefined} The removed root element.
10695
+ * @return {RootLike|undefined} removed element
9994
10696
  */
9995
10697
  Canvas.prototype.removeRootElement = function(rootElement) {
9996
10698
 
@@ -10032,11 +10734,7 @@
10032
10734
  *
10033
10735
  * @return {RootLike} The set root element.
10034
10736
  */
10035
- Canvas.prototype.setRootElement = function(rootElement, override) {
10036
-
10037
- if (isDefined(override)) {
10038
- throw new Error('override not supported');
10039
- }
10737
+ Canvas.prototype.setRootElement = function(rootElement) {
10040
10738
 
10041
10739
  if (rootElement === this._rootElement) {
10042
10740
  return;
@@ -10193,7 +10891,7 @@
10193
10891
  * Adds a shape to the canvas.
10194
10892
  *
10195
10893
  * @param {ShapeLike} shape The shape to be added
10196
- * @param {ShapeLike} [parent] The shape's parent.
10894
+ * @param {ParentLike} [parent] The shape's parent.
10197
10895
  * @param {number} [parentIndex] The index at which to add the shape to the parent's children.
10198
10896
  *
10199
10897
  * @return {ShapeLike} The added shape.
@@ -10206,7 +10904,7 @@
10206
10904
  * Adds a connection to the canvas.
10207
10905
  *
10208
10906
  * @param {ConnectionLike} connection The connection to be added.
10209
- * @param {ShapeLike} [parent] The connection's parent.
10907
+ * @param {ParentLike} [parent] The connection's parent.
10210
10908
  * @param {number} [parentIndex] The index at which to add the connection to the parent's children.
10211
10909
  *
10212
10910
  * @return {ConnectionLike} The added connection.
@@ -10573,7 +11271,7 @@
10573
11271
  * The getter may return a cached zoom level. Call it with `false` as the first
10574
11272
  * argument to force recomputation of the current level.
10575
11273
  *
10576
- * @param {number|string} [newScale] The new zoom level, either a number,
11274
+ * @param {number|'fit-viewport'} [newScale] The new zoom level, either a number,
10577
11275
  * i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
10578
11276
  * @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
10579
11277
  *
@@ -10768,11 +11466,12 @@
10768
11466
  var ELEMENT_ID = 'data-element-id';
10769
11467
 
10770
11468
  /**
10771
- * @typedef {import('.').ElementLike} ElementLike
11469
+ * @typedef {import('./Types').ElementLike} ElementLike
10772
11470
  *
10773
11471
  * @typedef {import('./EventBus').default} EventBus
10774
11472
  *
10775
- * @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
11473
+ * @typedef { (element: ElementLike, gfx: SVGElement) => boolean|any } ElementRegistryFilterCallback
11474
+ * @typedef { (element: ElementLike, gfx: SVGElement) => any } ElementRegistryForEachCallback
10776
11475
  */
10777
11476
 
10778
11477
  /**
@@ -10784,6 +11483,16 @@
10784
11483
  * @param {EventBus} eventBus
10785
11484
  */
10786
11485
  function ElementRegistry(eventBus) {
11486
+
11487
+ /**
11488
+ * @type { {
11489
+ * [id: string]: {
11490
+ * element: ElementLike;
11491
+ * gfx?: SVGElement;
11492
+ * secondaryGfx?: SVGElement;
11493
+ * }
11494
+ * } }
11495
+ */
10787
11496
  this._elements = {};
10788
11497
 
10789
11498
  this._eventBus = eventBus;
@@ -10869,7 +11578,7 @@
10869
11578
  /**
10870
11579
  * Update the graphical representation of an element.
10871
11580
  *
10872
- * @param {ElementLike|string} element The element or its ID.
11581
+ * @param {ElementLike|string} filter The element or its ID.
10873
11582
  * @param {SVGElement} gfx The new graphical representation.
10874
11583
  * @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
10875
11584
  */
@@ -10920,7 +11629,7 @@
10920
11629
  /**
10921
11630
  * Return all elements that match a given filter function.
10922
11631
  *
10923
- * @param {ElementRegistryCallback} fn The filter function.
11632
+ * @param {ElementRegistryFilterCallback} fn The filter function.
10924
11633
  *
10925
11634
  * @return {ElementLike[]} The matching elements.
10926
11635
  */
@@ -10940,7 +11649,7 @@
10940
11649
  /**
10941
11650
  * Return the first element that matches the given filter function.
10942
11651
  *
10943
- * @param {Function} fn The filter function.
11652
+ * @param {ElementRegistryFilterCallback} fn The filter function.
10944
11653
  *
10945
11654
  * @return {ElementLike|undefined} The matching element.
10946
11655
  */
@@ -10972,7 +11681,7 @@
10972
11681
  /**
10973
11682
  * Execute a given function for each element.
10974
11683
  *
10975
- * @param {Function} fn The function to execute.
11684
+ * @param {ElementRegistryForEachCallback} fn The function to execute.
10976
11685
  */
10977
11686
  ElementRegistry.prototype.forEach = function(fn) {
10978
11687
 
@@ -11359,19 +12068,26 @@
11359
12068
  outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
11360
12069
  incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
11361
12070
 
12071
+ /**
12072
+ * @typedef {import('./Types').Element} Element
12073
+ * @typedef {import('./Types').Shape} Shape
12074
+ * @typedef {import('./Types').Root} Root
12075
+ * @typedef {import('./Types').Label} Label
12076
+ * @typedef {import('./Types').Connection} Connection
12077
+ */
12078
+
11362
12079
  /**
11363
12080
  * The basic graphical representation
11364
12081
  *
11365
12082
  * @class
11366
- *
11367
- * @abstract
12083
+ * @constructor
11368
12084
  */
11369
- function Base$1() {
12085
+ function ElementImpl() {
11370
12086
 
11371
12087
  /**
11372
12088
  * The object that backs up the shape
11373
12089
  *
11374
- * @name Base#businessObject
12090
+ * @name Element#businessObject
11375
12091
  * @type Object
11376
12092
  */
11377
12093
  Object.defineProperty(this, 'businessObject', {
@@ -11382,7 +12098,7 @@
11382
12098
  /**
11383
12099
  * Single label support, will mapped to multi label array
11384
12100
  *
11385
- * @name Base#label
12101
+ * @name Element#label
11386
12102
  * @type Object
11387
12103
  */
11388
12104
  Object.defineProperty(this, 'label', {
@@ -11405,7 +12121,7 @@
11405
12121
  /**
11406
12122
  * The parent shape
11407
12123
  *
11408
- * @name Base#parent
12124
+ * @name Element#parent
11409
12125
  * @type Shape
11410
12126
  */
11411
12127
  parentRefs.bind(this, 'parent');
@@ -11413,7 +12129,7 @@
11413
12129
  /**
11414
12130
  * The list of labels
11415
12131
  *
11416
- * @name Base#labels
12132
+ * @name Element#labels
11417
12133
  * @type Label
11418
12134
  */
11419
12135
  labelRefs.bind(this, 'labels');
@@ -11421,7 +12137,7 @@
11421
12137
  /**
11422
12138
  * The list of outgoing connections
11423
12139
  *
11424
- * @name Base#outgoing
12140
+ * @name Element#outgoing
11425
12141
  * @type Array<Connection>
11426
12142
  */
11427
12143
  outgoingRefs.bind(this, 'outgoing');
@@ -11429,7 +12145,7 @@
11429
12145
  /**
11430
12146
  * The list of incoming connections
11431
12147
  *
11432
- * @name Base#incoming
12148
+ * @name Element#incoming
11433
12149
  * @type Array<Connection>
11434
12150
  */
11435
12151
  incomingRefs.bind(this, 'incoming');
@@ -11442,40 +12158,40 @@
11442
12158
  * @class
11443
12159
  * @constructor
11444
12160
  *
11445
- * @extends Base
12161
+ * @extends ElementImpl
11446
12162
  */
11447
- function Shape() {
11448
- Base$1.call(this);
12163
+ function ShapeImpl() {
12164
+ ElementImpl.call(this);
11449
12165
 
11450
12166
  /**
11451
12167
  * Indicates frame shapes
11452
12168
  *
11453
- * @name Shape#isFrame
12169
+ * @name ShapeImpl#isFrame
11454
12170
  * @type boolean
11455
12171
  */
11456
12172
 
11457
12173
  /**
11458
12174
  * The list of children
11459
12175
  *
11460
- * @name Shape#children
11461
- * @type Array<Base>
12176
+ * @name ShapeImpl#children
12177
+ * @type Element[]
11462
12178
  */
11463
12179
  parentRefs.bind(this, 'children');
11464
12180
 
11465
12181
  /**
11466
- * @name Shape#host
12182
+ * @name ShapeImpl#host
11467
12183
  * @type Shape
11468
12184
  */
11469
12185
  attacherRefs.bind(this, 'host');
11470
12186
 
11471
12187
  /**
11472
- * @name Shape#attachers
12188
+ * @name ShapeImpl#attachers
11473
12189
  * @type Shape
11474
12190
  */
11475
12191
  attacherRefs.bind(this, 'attachers');
11476
12192
  }
11477
12193
 
11478
- e(Shape, Base$1);
12194
+ e(ShapeImpl, ElementImpl);
11479
12195
 
11480
12196
 
11481
12197
  /**
@@ -11484,13 +12200,21 @@
11484
12200
  * @class
11485
12201
  * @constructor
11486
12202
  *
11487
- * @extends Shape
12203
+ * @extends ElementImpl
11488
12204
  */
11489
- function Root() {
11490
- Shape.call(this);
12205
+ function RootImpl() {
12206
+ ElementImpl.call(this);
12207
+
12208
+ /**
12209
+ * The list of children
12210
+ *
12211
+ * @name RootImpl#children
12212
+ * @type Element[]
12213
+ */
12214
+ parentRefs.bind(this, 'children');
11491
12215
  }
11492
12216
 
11493
- e(Root, Shape);
12217
+ e(RootImpl, ShapeImpl);
11494
12218
 
11495
12219
 
11496
12220
  /**
@@ -11499,21 +12223,21 @@
11499
12223
  * @class
11500
12224
  * @constructor
11501
12225
  *
11502
- * @extends Shape
12226
+ * @extends ShapeImpl
11503
12227
  */
11504
- function Label() {
11505
- Shape.call(this);
12228
+ function LabelImpl() {
12229
+ ShapeImpl.call(this);
11506
12230
 
11507
12231
  /**
11508
12232
  * The labeled element
11509
12233
  *
11510
- * @name Label#labelTarget
11511
- * @type Base
12234
+ * @name LabelImpl#labelTarget
12235
+ * @type Element
11512
12236
  */
11513
12237
  labelRefs.bind(this, 'labelTarget');
11514
12238
  }
11515
12239
 
11516
- e(Label, Shape);
12240
+ e(LabelImpl, ShapeImpl);
11517
12241
 
11518
12242
 
11519
12243
  /**
@@ -11522,45 +12246,69 @@
11522
12246
  * @class
11523
12247
  * @constructor
11524
12248
  *
11525
- * @extends Base
12249
+ * @extends ElementImpl
11526
12250
  */
11527
- function Connection() {
11528
- Base$1.call(this);
12251
+ function ConnectionImpl() {
12252
+ ElementImpl.call(this);
11529
12253
 
11530
12254
  /**
11531
12255
  * The element this connection originates from
11532
12256
  *
11533
- * @name Connection#source
11534
- * @type Base
12257
+ * @name ConnectionImpl#source
12258
+ * @type Element
11535
12259
  */
11536
12260
  outgoingRefs.bind(this, 'source');
11537
12261
 
11538
12262
  /**
11539
12263
  * The element this connection points to
11540
12264
  *
11541
- * @name Connection#target
11542
- * @type Base
12265
+ * @name ConnectionImpl#target
12266
+ * @type Element
11543
12267
  */
11544
12268
  incomingRefs.bind(this, 'target');
11545
12269
  }
11546
12270
 
11547
- e(Connection, Base$1);
12271
+ e(ConnectionImpl, ElementImpl);
11548
12272
 
11549
12273
 
11550
12274
  var types$6 = {
11551
- connection: Connection,
11552
- shape: Shape,
11553
- label: Label,
11554
- root: Root
12275
+ connection: ConnectionImpl,
12276
+ shape: ShapeImpl,
12277
+ label: LabelImpl,
12278
+ root: RootImpl
11555
12279
  };
11556
12280
 
11557
12281
  /**
11558
- * Creates a model element of the given type.
12282
+ * Creates a root element.
12283
+ *
12284
+ * @overlord
12285
+ *
12286
+ * @example
12287
+ *
12288
+ * ```
12289
+ * import * as Model from 'diagram-js/lib/model';
12290
+ *
12291
+ * const root = Model.create('root', {
12292
+ * x: 100,
12293
+ * y: 100,
12294
+ * width: 100,
12295
+ * height: 100
12296
+ * });
12297
+ * ```
12298
+ *
12299
+ * @param {'root'} type
12300
+ * @param {any} [attrs]
12301
+ *
12302
+ * @return {Root}
12303
+ */
12304
+ /**
12305
+ * Creates a connection.
11559
12306
  *
11560
- * @method create
12307
+ * @overlord
11561
12308
  *
11562
12309
  * @example
11563
12310
  *
12311
+ * ```
11564
12312
  * import * as Model from 'diagram-js/lib/model';
11565
12313
  *
11566
12314
  * const connection = Model.create('connection', {
@@ -11569,33 +12317,56 @@
11569
12317
  * { x: 200, y: 100 }
11570
12318
  * ]
11571
12319
  * });
12320
+ * ```
11572
12321
  *
11573
- * const label = Model.create('label', {
11574
- * x: 100,
11575
- * y: 100,
11576
- * width: 100,
11577
- * height: 100,
11578
- * labelTarget: shape
11579
- * });
12322
+ * @param {'connection'} type
12323
+ * @param {any} [attrs]
11580
12324
  *
11581
- * const root = Model.create('root', {
12325
+ * @return {Connection}
12326
+ */
12327
+ /**
12328
+ * Creates a shape.
12329
+ *
12330
+ * @overlord
12331
+ *
12332
+ * @example
12333
+ *
12334
+ * ```
12335
+ * import * as Model from 'diagram-js/lib/model';
12336
+ *
12337
+ * const shape = Model.create('shape', {
11582
12338
  * x: 100,
11583
12339
  * y: 100,
11584
12340
  * width: 100,
11585
12341
  * height: 100
11586
12342
  * });
12343
+ * ```
11587
12344
  *
11588
- * const shape = Model.create('shape', {
12345
+ * @param {'shape'} type
12346
+ * @param {any} [attrs]
12347
+ *
12348
+ * @return {Shape}
12349
+ */
12350
+ /**
12351
+ * Creates a label.
12352
+ *
12353
+ * @example
12354
+ *
12355
+ * ```
12356
+ * import * as Model from 'diagram-js/lib/model';
12357
+ *
12358
+ * const label = Model.create('label', {
11589
12359
  * x: 100,
11590
12360
  * y: 100,
11591
12361
  * width: 100,
11592
- * height: 100
12362
+ * height: 100,
12363
+ * labelTarget: shape
11593
12364
  * });
12365
+ * ```
11594
12366
  *
11595
- * @param {string} type The type of model element to be created.
11596
- * @param {Object} attrs Attributes to create the model element with.
11597
- *
11598
- * @return {Connection|Label|Root|Shape} The created model element.
12367
+ * @param {'label'} type
12368
+ * @param {any} [attrs]
12369
+ * @return {Label}
11599
12370
  */
11600
12371
  function create(type, attrs) {
11601
12372
  var Type = types$6[type];
@@ -11606,22 +12377,20 @@
11606
12377
  }
11607
12378
 
11608
12379
  /**
11609
- * @typedef {import('../model/index').Base} Base
11610
- * @typedef {import('../model/index').Connection} Connection
11611
- * @typedef {import('../model/index').Label} Label
11612
- * @typedef {import('../model/index').Root} Root
11613
- * @typedef {import('../model/index').Shape} Shape
11614
- * @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
11615
- * @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
11616
- * @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
11617
- * @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
12380
+ * @typedef {import('../model/Types').Element} Element
12381
+ * @typedef {import('../model/Types').Connection} Connection
12382
+ * @typedef {import('../model/Types').Label} Label
12383
+ * @typedef {import('../model/Types').Root} Root
12384
+ * @typedef {import('../model/Types').Shape} Shape
11618
12385
  */
11619
12386
 
11620
12387
  /**
11621
12388
  * A factory for model elements.
11622
12389
  *
11623
- * @class
11624
- * @constructor
12390
+ * @template {Connection} [T=Connection]
12391
+ * @template {Label} [U=Label]
12392
+ * @template {Root} [V=Root]
12393
+ * @template {Shape} [W=Shape]
11625
12394
  */
11626
12395
  function ElementFactory() {
11627
12396
  this._uid = 12;
@@ -11630,9 +12399,9 @@
11630
12399
  /**
11631
12400
  * Create a root element.
11632
12401
  *
11633
- * @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
12402
+ * @param {Partial<Root>} [attrs]
11634
12403
  *
11635
- * @return {Root} The created root element.
12404
+ * @return {V} The created root element.
11636
12405
  */
11637
12406
  ElementFactory.prototype.createRoot = function(attrs) {
11638
12407
  return this.create('root', attrs);
@@ -11641,9 +12410,9 @@
11641
12410
  /**
11642
12411
  * Create a label.
11643
12412
  *
11644
- * @param {ModelAttrsLabel} attrs The attributes of the label to be created.
12413
+ * @param {Partial<Label>} [attrs]
11645
12414
  *
11646
- * @return {Label} The created label.
12415
+ * @return {U} The created label.
11647
12416
  */
11648
12417
  ElementFactory.prototype.createLabel = function(attrs) {
11649
12418
  return this.create('label', attrs);
@@ -11652,9 +12421,9 @@
11652
12421
  /**
11653
12422
  * Create a shape.
11654
12423
  *
11655
- * @param {ModelAttrsShape} attrs The attributes of the shape to be created.
12424
+ * @param {Partial<Shape>} [attrs]
11656
12425
  *
11657
- * @return {Shape} The created shape.
12426
+ * @return {W} The created shape.
11658
12427
  */
11659
12428
  ElementFactory.prototype.createShape = function(attrs) {
11660
12429
  return this.create('shape', attrs);
@@ -11663,21 +12432,44 @@
11663
12432
  /**
11664
12433
  * Create a connection.
11665
12434
  *
11666
- * @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
12435
+ * @param {Partial<Connection>} [attrs]
11667
12436
  *
11668
- * @return {Connection} The created connection.
12437
+ * @return {T} The created connection.
11669
12438
  */
11670
12439
  ElementFactory.prototype.createConnection = function(attrs) {
11671
12440
  return this.create('connection', attrs);
11672
12441
  };
11673
12442
 
11674
12443
  /**
11675
- * Create a model element of the given type with the given attributes.
12444
+ * Create a root element.
12445
+ *
12446
+ * @overlord
12447
+ * @param {'root'} type
12448
+ * @param {Partial<Root>} [attrs]
12449
+ * @return {V}
12450
+ */
12451
+ /**
12452
+ * Create a shape.
12453
+ *
12454
+ * @overlord
12455
+ * @param {'shape'} type
12456
+ * @param {Partial<Shape>} [attrs]
12457
+ * @return {W}
12458
+ */
12459
+ /**
12460
+ * Create a connection.
11676
12461
  *
11677
- * @param {string} type The type of the model element.
11678
- * @param {Object} attrs The attributes of the model element.
12462
+ * @overlord
12463
+ * @param {'connection'} type
12464
+ * @param {Partial<Connection>} [attrs]
12465
+ * @return {T}
12466
+ */
12467
+ /**
12468
+ * Create a label.
11679
12469
  *
11680
- * @return {Connection|Label|Root|Shape} The created model element.
12470
+ * @param {'label'} type
12471
+ * @param {Partial<Label>} [attrs]
12472
+ * @return {U}
11681
12473
  */
11682
12474
  ElementFactory.prototype.create = function(type, attrs) {
11683
12475
 
@@ -11697,13 +12489,27 @@
11697
12489
  var slice = Array.prototype.slice;
11698
12490
 
11699
12491
  /**
11700
- * @typedef {import('./EventBus').Event} Event
11701
- * @typedef {import('./EventBus').EventCallback} EventCallback
12492
+ * @typedef { {
12493
+ * stopPropagation(): void;
12494
+ * preventDefault(): void;
12495
+ * cancelBubble: boolean;
12496
+ * defaultPrevented: boolean;
12497
+ * returnValue: any;
12498
+ * } } Event
12499
+ */
12500
+
12501
+ /**
12502
+ * @template E
11702
12503
  *
11703
- * @typedef {Object} EventListener
11704
- * @property {Function} callback
11705
- * @property {EventListener|null} next
11706
- * @property {number} priority
12504
+ * @typedef { (event: E & Event, ...any) => any } EventBusEventCallback
12505
+ */
12506
+
12507
+ /**
12508
+ * @typedef { {
12509
+ * priority: number;
12510
+ * next: EventBusListener | null;
12511
+ * callback: EventBusEventCallback<any>;
12512
+ * } } EventBusListener
11707
12513
  */
11708
12514
 
11709
12515
  /**
@@ -11790,6 +12596,10 @@
11790
12596
  * ```
11791
12597
  */
11792
12598
  function EventBus() {
12599
+
12600
+ /**
12601
+ * @type { Record<string, EventBusListener> }
12602
+ */
11793
12603
  this._listeners = {};
11794
12604
 
11795
12605
  // cleanup on destroy on lowest priority to allow
@@ -11810,10 +12620,12 @@
11810
12620
  *
11811
12621
  * Returning anything but `undefined` from a listener will stop the listener propagation.
11812
12622
  *
11813
- * @param {string|string[]} events The event(s) to listen to.
11814
- * @param {number} [priority=1000] The priority with which to listen.
11815
- * @param {EventCallback} callback The callback.
11816
- * @param {*} [that] Value of `this` the callback will be called with.
12623
+ * @template T
12624
+ *
12625
+ * @param {string|string[]} events to subscribe to
12626
+ * @param {number} [priority=1000] listen priority
12627
+ * @param {EventBusEventCallback<T>} callback
12628
+ * @param {any} [that] callback context
11817
12629
  */
11818
12630
  EventBus.prototype.on = function(events, priority, callback, that) {
11819
12631
 
@@ -11855,12 +12667,14 @@
11855
12667
  /**
11856
12668
  * Register an event listener that is called only once.
11857
12669
  *
11858
- * @param {string} event The event to listen to.
11859
- * @param {number} [priority=1000] The priority with which to listen.
11860
- * @param {EventCallback} callback The callback.
11861
- * @param {*} [that] Value of `this` the callback will be called with.
12670
+ * @template T
12671
+ *
12672
+ * @param {string|string[]} events to subscribe to
12673
+ * @param {number} [priority=1000] the listen priority
12674
+ * @param {EventBusEventCallback<T>} callback
12675
+ * @param {any} [that] callback context
11862
12676
  */
11863
- EventBus.prototype.once = function(event, priority, callback, that) {
12677
+ EventBus.prototype.once = function(events, priority, callback, that) {
11864
12678
  var self = this;
11865
12679
 
11866
12680
  if (isFunction(priority)) {
@@ -11878,7 +12692,7 @@
11878
12692
 
11879
12693
  var result = callback.apply(that, arguments);
11880
12694
 
11881
- self.off(event, wrappedCallback);
12695
+ self.off(events, wrappedCallback);
11882
12696
 
11883
12697
  return result;
11884
12698
  }
@@ -11888,7 +12702,7 @@
11888
12702
  // callback
11889
12703
  wrappedCallback[FN_REF] = callback;
11890
12704
 
11891
- this.on(event, priority, wrappedCallback);
12705
+ this.on(events, priority, wrappedCallback);
11892
12706
  };
11893
12707
 
11894
12708
 
@@ -11897,8 +12711,8 @@
11897
12711
  *
11898
12712
  * If no callback is given, all listeners for a given event name are being removed.
11899
12713
  *
11900
- * @param {string|string[]} events The events.
11901
- * @param {EventCallback} [callback] The callback.
12714
+ * @param {string|string[]} events
12715
+ * @param {EventBusEventCallback} [callback]
11902
12716
  */
11903
12717
  EventBus.prototype.off = function(events, callback) {
11904
12718
 
@@ -11934,6 +12748,7 @@
11934
12748
  *
11935
12749
  * @example
11936
12750
  *
12751
+ * ```javascript
11937
12752
  * // fire event by name
11938
12753
  * events.fire('foo');
11939
12754
  *
@@ -11951,12 +12766,13 @@
11951
12766
  * });
11952
12767
  *
11953
12768
  * events.fire({ type: 'foo' }, 'I am bar!');
12769
+ * ```
11954
12770
  *
11955
- * @param {string} [type] The event type.
11956
- * @param {Object} [data] The event or event data.
11957
- * @param {...*} additional Additional arguments the callback will be called with.
12771
+ * @param {string} [type] event type
12772
+ * @param {Object} [data] event or event data
12773
+ * @param {...any} [args] additional arguments the callback will be called with.
11958
12774
  *
11959
- * @return {*} The return value. Will be set to `false` if the default was prevented.
12775
+ * @return {any} The return value. Will be set to `false` if the default was prevented.
11960
12776
  */
11961
12777
  EventBus.prototype.fire = function(type, data) {
11962
12778
  var event,
@@ -12037,6 +12853,13 @@
12037
12853
  this._listeners = {};
12038
12854
  };
12039
12855
 
12856
+ /**
12857
+ * @param {Event} event
12858
+ * @param {any[]} args
12859
+ * @param {EventBusListener} listener
12860
+ *
12861
+ * @return {any}
12862
+ */
12040
12863
  EventBus.prototype._invokeListeners = function(event, args, listener) {
12041
12864
 
12042
12865
  var returnValue;
@@ -12056,6 +12879,13 @@
12056
12879
  return returnValue;
12057
12880
  };
12058
12881
 
12882
+ /**
12883
+ * @param {Event} event
12884
+ * @param {any[]} args
12885
+ * @param {EventBusListener} listener
12886
+ *
12887
+ * @return {any}
12888
+ */
12059
12889
  EventBus.prototype._invokeListener = function(event, args, listener) {
12060
12890
 
12061
12891
  var returnValue;
@@ -12104,7 +12934,7 @@
12104
12934
  * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
12105
12935
  *
12106
12936
  * @param {string} event
12107
- * @param {EventListener} listener
12937
+ * @param {EventBusListener} listener
12108
12938
  */
12109
12939
  EventBus.prototype._addListener = function(event, newListener) {
12110
12940
 
@@ -12144,10 +12974,19 @@
12144
12974
  };
12145
12975
 
12146
12976
 
12977
+ /**
12978
+ * @param {string} name
12979
+ *
12980
+ * @return {EventBusListener}
12981
+ */
12147
12982
  EventBus.prototype._getListeners = function(name) {
12148
12983
  return this._listeners[name];
12149
12984
  };
12150
12985
 
12986
+ /**
12987
+ * @param {string} name
12988
+ * @param {EventBusListener} listener
12989
+ */
12151
12990
  EventBus.prototype._setListeners = function(name, listener) {
12152
12991
  this._listeners[name] = listener;
12153
12992
  };
@@ -12210,9 +13049,9 @@
12210
13049
  * Invoke function. Be fast...
12211
13050
  *
12212
13051
  * @param {Function} fn
12213
- * @param {*[]} args
13052
+ * @param {any[]} args
12214
13053
  *
12215
- * @return {*}
13054
+ * @return {any}
12216
13055
  */
12217
13056
  function invokeFunction(fn, args) {
12218
13057
  return fn.apply(null, args);
@@ -12247,13 +13086,9 @@
12247
13086
  }
12248
13087
 
12249
13088
  /**
12250
- * @typedef {import('../model').ModelType} ModelType
12251
- * @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
12252
- * @typedef {import('../model').ModelTypeShape} ModelTypeShape
12253
- *
12254
- * @typedef {import('.').ConnectionLike} ConnectionLike
12255
- * @typedef {import('.').ElementLike} ElementLike
12256
- * @typedef {import('.').ShapeLike} ShapeLike
13089
+ * @typedef {import('./Types').ConnectionLike} ConnectionLike
13090
+ * @typedef {import('./Types').ElementLike} ElementLike
13091
+ * @typedef {import('./Types').ShapeLike} ShapeLike
12257
13092
  *
12258
13093
  * @typedef {import('./ElementRegistry').default} ElementRegistry
12259
13094
  * @typedef {import('./EventBus').default} EventBus
@@ -12272,7 +13107,10 @@
12272
13107
 
12273
13108
  GraphicsFactory.$inject = [ 'eventBus' , 'elementRegistry' ];
12274
13109
 
12275
-
13110
+ /**
13111
+ * @param { { parent?: any } } element
13112
+ * @return {SVGElement}
13113
+ */
12276
13114
  GraphicsFactory.prototype._getChildrenContainer = function(element) {
12277
13115
 
12278
13116
  var gfx = this._elementRegistry.getGraphics(element);
@@ -12369,7 +13207,7 @@
12369
13207
  /**
12370
13208
  * Create a graphical element.
12371
13209
  *
12372
- * @param {ModelType} type The type of the element.
13210
+ * @param { 'shape' | 'connection' | 'label' | 'root' } type The type of the element.
12373
13211
  * @param {ElementLike} element The element.
12374
13212
  * @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
12375
13213
  *
@@ -12425,6 +13263,8 @@
12425
13263
  *
12426
13264
  * @param {SVGElement} visual The graphical element.
12427
13265
  * @param {ShapeLike} element The shape.
13266
+ *
13267
+ * @return {SVGElement}
12428
13268
  */
12429
13269
  GraphicsFactory.prototype.drawShape = function(visual, element) {
12430
13270
  var eventBus = this._eventBus;
@@ -12450,6 +13290,8 @@
12450
13290
  *
12451
13291
  * @param {SVGElement} visual The graphical element.
12452
13292
  * @param {ConnectionLike} element The connection.
13293
+ *
13294
+ * @return {SVGElement}
12453
13295
  */
12454
13296
  GraphicsFactory.prototype.drawConnection = function(visual, element) {
12455
13297
  var eventBus = this._eventBus;
@@ -12460,7 +13302,7 @@
12460
13302
  /**
12461
13303
  * Get the path of a connection.
12462
13304
  *
12463
- * @param {ConnectionLike} element The connection.
13305
+ * @param {ConnectionLike} connection The connection.
12464
13306
  *
12465
13307
  * @return {string} The path of the connection.
12466
13308
  */
@@ -12473,9 +13315,9 @@
12473
13315
  /**
12474
13316
  * Update an elements graphical representation.
12475
13317
  *
12476
- * @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
12477
- * @param {ElementLike} element The element.
12478
- * @param {SVGElement} gfx The graphical representation.
13318
+ * @param {'shape'|'connection'} type
13319
+ * @param {ElementLike} element
13320
+ * @param {SVGElement} gfx
12479
13321
  */
12480
13322
  GraphicsFactory.prototype.update = function(type, element, gfx) {
12481
13323
 
@@ -12533,6 +13375,9 @@
12533
13375
  parentNode.insertBefore(newNode, node);
12534
13376
  }
12535
13377
 
13378
+ /**
13379
+ * @type { import('didi').ModuleDeclaration }
13380
+ */
12536
13381
  var CoreModule = {
12537
13382
  __depends__: [ DrawModule ],
12538
13383
  __init__: [ 'canvas' ],
@@ -12548,7 +13393,9 @@
12548
13393
  * @typedef {import('didi').LocalsMap} LocalsMap
12549
13394
  * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
12550
13395
  *
12551
- * @typedef {import('./Diagram').DiagramOptions} DiagramOptions
13396
+ * @typedef { {
13397
+ * modules?: ModuleDeclaration[];
13398
+ * } & Record<string, any> } DiagramOptions
12552
13399
  */
12553
13400
 
12554
13401
  /**
@@ -12577,6 +13424,9 @@
12577
13424
 
12578
13425
  options = options || {};
12579
13426
 
13427
+ /**
13428
+ * @type { ModuleDeclaration }
13429
+ */
12580
13430
  var configModule = {
12581
13431
  'config': [ 'value', options ]
12582
13432
  };
@@ -12596,11 +13446,10 @@
12596
13446
  * @class
12597
13447
  * @constructor
12598
13448
  *
12599
- * @example
12600
- *
12601
- * <caption>Creating a plug-in that logs whenever a shape is added to the canvas.</caption>
13449
+ * @example Creating a plug-in that logs whenever a shape is added to the canvas.
12602
13450
  *
12603
- * // plug-in implemenentation
13451
+ * ```javascript
13452
+ * // plug-in implementation
12604
13453
  * function MyLoggingPlugin(eventBus) {
12605
13454
  * eventBus.on('shape.added', function(event) {
12606
13455
  * console.log('shape ', event.shape, ' was added to the diagram');
@@ -12612,10 +13461,11 @@
12612
13461
  * __init__: [ 'myLoggingPlugin' ],
12613
13462
  * myLoggingPlugin: [ 'type', MyLoggingPlugin ]
12614
13463
  * };
13464
+ * ```
12615
13465
  *
13466
+ * Use the plug-in in a Diagram instance:
12616
13467
  *
12617
- * // instantiate the diagram with the new plug-in
12618
- *
13468
+ * ```javascript
12619
13469
  * import MyLoggingModule from 'path-to-my-logging-plugin';
12620
13470
  *
12621
13471
  * var diagram = new Diagram({
@@ -12630,36 +13480,39 @@
12630
13480
  * });
12631
13481
  *
12632
13482
  * // 'shape ... was added to the diagram' logged to console
13483
+ * ```
12633
13484
  *
12634
13485
  * @param {DiagramOptions} [options]
12635
- * @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
12636
13486
  * @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
12637
13487
  */
12638
13488
  function Diagram(options, injector) {
12639
13489
 
12640
- // create injector unless explicitly specified
12641
- this.injector = injector = injector || createInjector(options);
13490
+ this._injector = injector = injector || createInjector(options);
12642
13491
 
12643
13492
  // API
12644
13493
 
12645
13494
  /**
12646
13495
  * Resolves a diagram service.
12647
13496
  *
12648
- * @method Diagram#get
13497
+ * @template T
12649
13498
  *
12650
13499
  * @param {string} name The name of the service to get.
12651
13500
  * @param {boolean} [strict=true] If false, resolve missing services to null.
13501
+ *
13502
+ * @return {T|null}
12652
13503
  */
12653
13504
  this.get = injector.get;
12654
13505
 
12655
13506
  /**
12656
13507
  * Executes a function with its dependencies injected.
12657
13508
  *
12658
- * @method Diagram#invoke
13509
+ * @template T
13510
+ *
13511
+ * @param {Function} func function to be invoked
13512
+ * @param {InjectionContext} [context] context of the invocation
13513
+ * @param {LocalsMap} [locals] locals provided
12659
13514
  *
12660
- * @param {Function} fn The function to be executed.
12661
- * @param {InjectionContext} [context] The context.
12662
- * @param {LocalsMap} [locals] The locals.
13515
+ * @return {T|null}
12663
13516
  */
12664
13517
  this.invoke = injector.invoke;
12665
13518
 
@@ -12691,8 +13544,6 @@
12691
13544
 
12692
13545
  /**
12693
13546
  * Destroys the diagram
12694
- *
12695
- * @method Diagram#destroy
12696
13547
  */
12697
13548
  Diagram.prototype.destroy = function() {
12698
13549
  this.get('eventBus').fire('diagram.destroy');
@@ -20230,6 +21081,10 @@
20230
21081
  return new BpmnModdle(pks, options);
20231
21082
  }
20232
21083
 
21084
+ /**
21085
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
21086
+ */
21087
+
20233
21088
  // TODO(nikku): remove with future bpmn-js version
20234
21089
 
20235
21090
  /**
@@ -20239,6 +21094,10 @@
20239
21094
  * 2) If Promise class is implemented in current environment.
20240
21095
  *
20241
21096
  * @private
21097
+ *
21098
+ * @param {Function} api
21099
+ *
21100
+ * @return {Function}
20242
21101
  */
20243
21102
  function wrapForCompatibility(api) {
20244
21103
 
@@ -20287,6 +21146,11 @@
20287
21146
 
20288
21147
  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';
20289
21148
 
21149
+ /**
21150
+ * @private
21151
+ *
21152
+ * @param {ModdleElement} businessObject
21153
+ */
20290
21154
  function ensureCompatDiRef(businessObject) {
20291
21155
 
20292
21156
  // bpmnElement can have multiple independent DIs
@@ -20301,10 +21165,16 @@
20301
21165
  }
20302
21166
 
20303
21167
  /**
20304
- * Returns true if an element has the given meta-model type
21168
+ * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
21169
+ *
21170
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
21171
+ */
21172
+
21173
+ /**
21174
+ * Returns true if an element is of the given meta-model type.
20305
21175
  *
20306
- * @param {ModdleElement} element
20307
- * @param {string} type
21176
+ * @param {ModdleElement} element
21177
+ * @param {string} type
20308
21178
  *
20309
21179
  * @return {boolean}
20310
21180
  */
@@ -20316,6 +21186,10 @@
20316
21186
  /**
20317
21187
  * Find a suitable display candidate for definitions where the DI does not
20318
21188
  * correctly specify one.
21189
+ *
21190
+ * @param {ModdleElement}
21191
+ *
21192
+ * @return {ModdleElement}
20319
21193
  */
20320
21194
  function findDisplayCandidate(definitions) {
20321
21195
  return find(definitions.rootElements, function(e) {
@@ -20323,7 +21197,10 @@
20323
21197
  });
20324
21198
  }
20325
21199
 
20326
-
21200
+ /**
21201
+ * @param {Function} handler
21202
+ * @param {Translate} translate
21203
+ */
20327
21204
  function BpmnTreeWalker(handler, translate) {
20328
21205
 
20329
21206
  // list of containers already walked
@@ -20392,7 +21269,7 @@
20392
21269
 
20393
21270
  // DI handling //////////////////////
20394
21271
 
20395
- function registerDi(di) {
21272
+ var registerDi = this.registerDi = function registerDi(di) {
20396
21273
  var bpmnElement = di.bpmnElement;
20397
21274
 
20398
21275
  if (bpmnElement) {
@@ -20416,7 +21293,7 @@
20416
21293
  { element: di }
20417
21294
  );
20418
21295
  }
20419
- }
21296
+ };
20420
21297
 
20421
21298
  function handleDiagram(diagram) {
20422
21299
  handlePlane(diagram.plane);
@@ -20436,14 +21313,14 @@
20436
21313
  // Semantic handling //////////////////////
20437
21314
 
20438
21315
  /**
20439
- * Handle definitions and return the rendered diagram (if any)
21316
+ * Handle definitions and return the rendered diagram (if any).
20440
21317
  *
20441
21318
  * @param {ModdleElement} definitions to walk and import
20442
21319
  * @param {ModdleElement} [diagram] specific diagram to import and display
20443
21320
  *
20444
21321
  * @throws {Error} if no diagram to display could be found
20445
21322
  */
20446
- function handleDefinitions(definitions, diagram) {
21323
+ this.handleDefinitions = function handleDefinitions(definitions, diagram) {
20447
21324
 
20448
21325
  // make sure we walk the correct bpmnElement
20449
21326
 
@@ -20520,10 +21397,10 @@
20520
21397
  }
20521
21398
 
20522
21399
  // handle all deferred elements
20523
- handleDeferred();
20524
- }
21400
+ handleDeferred(deferred);
21401
+ };
20525
21402
 
20526
- function handleDeferred() {
21403
+ var handleDeferred = this.handleDeferred = function handleDeferred() {
20527
21404
 
20528
21405
  var fn;
20529
21406
 
@@ -20533,7 +21410,7 @@
20533
21410
 
20534
21411
  fn();
20535
21412
  }
20536
- }
21413
+ };
20537
21414
 
20538
21415
  function handleProcess(process, context) {
20539
21416
  handleFlowElementsContainer(process, context);
@@ -20609,10 +21486,10 @@
20609
21486
  forEach$1(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
20610
21487
  }
20611
21488
 
20612
- function handleSubProcess(subProcess, context) {
21489
+ var handleSubProcess = this.handleSubProcess = function handleSubProcess(subProcess, context) {
20613
21490
  handleFlowElementsContainer(subProcess, context);
20614
21491
  handleArtifacts(subProcess.artifacts, context);
20615
- }
21492
+ };
20616
21493
 
20617
21494
  function handleFlowNode(flowNode, context) {
20618
21495
  var childCtx = visitIfDi(flowNode, context);
@@ -20737,44 +21614,29 @@
20737
21614
  }
20738
21615
  });
20739
21616
  }
20740
-
20741
- // API //////////////////////
20742
-
20743
- return {
20744
- handleDeferred: handleDeferred,
20745
- handleDefinitions: handleDefinitions,
20746
- handleSubProcess: handleSubProcess,
20747
- registerDi: registerDi
20748
- };
20749
21617
  }
20750
21618
 
20751
21619
  /**
20752
- * The importBpmnDiagram result.
21620
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
20753
21621
  *
20754
- * @typedef {Object} ImportBPMNDiagramResult
21622
+ * @typedef { {
21623
+ * warnings: string[];
21624
+ * } } ImportBPMNDiagramResult
20755
21625
  *
20756
- * @property {Array<string>} warnings
21626
+ * @typedef {ImportBPMNDiagramResult & Error} ImportBPMNDiagramError
20757
21627
  */
20758
21628
 
20759
- /**
20760
- * The importBpmnDiagram error.
20761
- *
20762
- * @typedef {Error} ImportBPMNDiagramError
20763
- *
20764
- * @property {Array<string>} warnings
20765
- */
20766
-
20767
21629
  /**
20768
21630
  * Import the definitions into a diagram.
20769
21631
  *
20770
21632
  * Errors and warnings are reported through the specified callback.
20771
21633
  *
20772
- * @param {djs.Diagram} diagram
20773
- * @param {ModdleElement<Definitions>} definitions
20774
- * @param {ModdleElement<BPMNDiagram>} [bpmnDiagram] the diagram to be rendered
20775
- * (if not provided, the first one will be rendered)
21634
+ * @param {ModdleElement} diagram
21635
+ * @param {ModdleElement} definitions
21636
+ * @param {ModdleElement} [bpmnDiagram] The diagram to be rendered (if not
21637
+ * provided, the first one will be rendered).
20776
21638
  *
20777
- * Returns {Promise<ImportBPMNDiagramResult, ImportBPMNDiagramError>}
21639
+ * @return {Promise<ImportBPMNDiagramResult>}
20778
21640
  */
20779
21641
  function importBpmnDiagram(diagram, definitions, bpmnDiagram) {
20780
21642
 
@@ -20790,8 +21652,8 @@
20790
21652
  * Walk the diagram semantically, importing (=drawing)
20791
21653
  * all elements you encounter.
20792
21654
  *
20793
- * @param {ModdleElement<Definitions>} definitions
20794
- * @param {ModdleElement<BPMNDiagram>} bpmnDiagram
21655
+ * @param {ModdleElement} definitions
21656
+ * @param {ModdleElement} bpmnDiagram
20795
21657
  */
20796
21658
  function render(definitions, bpmnDiagram) {
20797
21659
 
@@ -20866,10 +21728,10 @@
20866
21728
  * Returns all diagrams in the same hierarchy as the requested diagram.
20867
21729
  * Includes all parent and sub process diagrams.
20868
21730
  *
20869
- * @param {Array} definitions
20870
- * @param {Object} bpmnDiagram
21731
+ * @param {ModdleElement} definitions
21732
+ * @param {ModdleElement} bpmnDiagram
20871
21733
  *
20872
- * @returns {Array<Object>}
21734
+ * @return {ModdleElement[]}
20873
21735
  */
20874
21736
  function getDiagramsToImport(definitions, bpmnDiagram) {
20875
21737
  if (!bpmnDiagram) {
@@ -21063,22 +21925,89 @@
21063
21925
  * @see http://bpmn.io/license for more information.
21064
21926
  */
21065
21927
 
21928
+ /**
21929
+ * @template T
21930
+ *
21931
+ * @typedef {import('diagram-js/lib/core/EventBus').EventBusEventCallback<T>} EventBusEventCallback
21932
+ */
21066
21933
 
21067
21934
  /**
21068
21935
  * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
21069
21936
  *
21070
- * @typedef {import('./BaseViewer').BaseModelerOptions} BaseModelerOptions
21071
- * @typedef {import('./BaseViewer').ModdleElement} ModdleElement
21072
- * @typedef {import('./BaseViewer').ImportXMLResult} ImportXMLResult
21073
- * @typedef {import('./BaseViewer').ImportXMLError} ImportXMLError
21074
- * @typedef {import('./BaseViewer').ImportDefinitionsResult} ImportDefinitionsResult
21075
- * @typedef {import('./BaseViewer').ImportDefinitionsError} ImportDefinitionsError
21076
- * @typedef {import('./BaseViewer').ModdleElement} ModdleElement
21077
- * @typedef {import('./BaseViewer').ModdleElementsById} ModdleElementsById
21078
- * @typedef {import('./BaseViewer').OpenResult} OpenResult
21079
- * @typedef {import('./BaseViewer').OpenError} OpenError
21080
- * @typedef {import('./BaseViewer').SaveXMLOptions} SaveXMLOptions
21081
- * @typedef {import('./BaseViewer').SaveXMLResult} SaveXMLResult
21937
+ * @typedef {import('./model/Types').Moddle} Moddle
21938
+ * @typedef {import('./model/Types').ModdleElement} ModdleElement
21939
+ * @typedef {import('./model/Types').ModdleExtension} ModdleExtension
21940
+ *
21941
+ * @typedef { {
21942
+ * width?: number|string;
21943
+ * height?: number|string;
21944
+ * position?: string;
21945
+ * container?: string|HTMLElement;
21946
+ * moddleExtensions?: ModdleExtensions;
21947
+ * additionalModules?: ModuleDeclaration[];
21948
+ * } & Record<string, any> } BaseViewerOptions
21949
+ *
21950
+ * @typedef {Record<string, ModdleElement>} ModdleElementsById
21951
+ *
21952
+ * @typedef { {
21953
+ * [key: string]: ModdleExtension;
21954
+ * } } ModdleExtensions
21955
+ *
21956
+ * @typedef { {
21957
+ * warnings: string[];
21958
+ * } } ImportXMLResult
21959
+ *
21960
+ * @typedef {ImportXMLResult & Error} ImportXMLError
21961
+ *
21962
+ * @typedef {ImportXMLResult} ImportDefinitionsResult
21963
+ *
21964
+ * @typedef {ImportXMLError} ImportDefinitionsError
21965
+ *
21966
+ * @typedef {ImportXMLResult} OpenResult
21967
+ *
21968
+ * @typedef {ImportXMLError} OpenError
21969
+ *
21970
+ * @typedef { {
21971
+ * format?: boolean;
21972
+ * preamble?: boolean;
21973
+ * } } SaveXMLOptions
21974
+ *
21975
+ * @typedef { {
21976
+ * xml?: string;
21977
+ * error?: Error;
21978
+ * } } SaveXMLResult
21979
+ *
21980
+ * @typedef { {
21981
+ * svg: string;
21982
+ * } } SaveSVGResult
21983
+ *
21984
+ * @typedef { {
21985
+ * xml: string;
21986
+ * } } ImportParseStartEvent
21987
+ *
21988
+ * @typedef { {
21989
+ * error?: ImportXMLError;
21990
+ * definitions?: ModdleElement;
21991
+ * elementsById?: ModdleElementsById;
21992
+ * references?: ModdleElement[];
21993
+ * warnings: string[];
21994
+ * } } ImportParseCompleteEvent
21995
+ *
21996
+ * @typedef { {
21997
+ * error?: ImportXMLError;
21998
+ * warnings: string[];
21999
+ * } } ImportDoneEvent
22000
+ *
22001
+ * @typedef { {
22002
+ * definitions: ModdleElement;
22003
+ * } } SaveXMLStartEvent
22004
+ *
22005
+ * @typedef {SaveXMLResult} SaveXMLDoneEvent
22006
+ *
22007
+ * @typedef { {
22008
+ * error?: Error;
22009
+ * svg: string;
22010
+ * } } SaveSVGDoneEvent
21082
22011
  */
21083
22012
 
21084
22013
  /**
@@ -21087,15 +22016,18 @@
21087
22016
  * Have a look at {@link Viewer}, {@link NavigatedViewer} or {@link Modeler} for
21088
22017
  * bundles that include actual features.
21089
22018
  *
21090
- * @param {BaseModelerOptions} [options] The options to configure the viewer.
22019
+ * @param {BaseViewerOptions} [options] The options to configure the viewer.
21091
22020
  */
21092
22021
  function BaseViewer(options) {
21093
22022
 
21094
22023
  /**
21095
- * @type {BaseModelerOptions}
22024
+ * @type {BaseViewerOptions}
21096
22025
  */
21097
22026
  options = assign$1({}, DEFAULT_OPTIONS, options);
21098
22027
 
22028
+ /**
22029
+ * @type {Moddle}
22030
+ */
21099
22031
  this._moddle = this._createModdle(options);
21100
22032
 
21101
22033
  /**
@@ -21134,18 +22066,18 @@
21134
22066
  *
21135
22067
  * @throws {ImportXMLError} An error thrown during the import of the XML.
21136
22068
  *
21137
- * @fires BaseViewer#ImportParseStart
21138
- * @fires BaseViewer#ImportParseComplete
21139
- * @fires Importer#ImportRenderStart
21140
- * @fires Importer#ImportRenderComplete
21141
- * @fires BaseViewer#ImportDone
22069
+ * @fires BaseViewer#ImportParseStartEvent
22070
+ * @fires BaseViewer#ImportParseCompleteEvent
22071
+ * @fires Importer#ImportRenderStartEvent
22072
+ * @fires Importer#ImportRenderCompleteEvent
22073
+ * @fires BaseViewer#ImportDoneEvent
21142
22074
  *
21143
22075
  * @param {string} xml The BPMN 2.0 XML to be imported.
21144
22076
  * @param {ModdleElement|string} [bpmnDiagram] The optional diagram or Id of the BPMN diagram to open.
21145
22077
  *
21146
22078
  * @return {Promise<ImportXMLResult>} A promise resolving with warnings that were produced during the import.
21147
22079
  */
21148
- BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(xml, bpmnDiagram) {
22080
+ BaseViewer.prototype.importXML = async function importXML(xml, bpmnDiagram) {
21149
22081
 
21150
22082
  const self = this;
21151
22083
 
@@ -21183,9 +22115,8 @@
21183
22115
  /**
21184
22116
  * A `import.parse.start` event.
21185
22117
  *
21186
- * @event BaseViewer#ImportParseStart
21187
- * @type {Object}
21188
- * @property {string} xml The XML that is to be parsed.
22118
+ * @event BaseViewer#ImportParseStartEvent
22119
+ * @type {ImportParseStartEvent}
21189
22120
  */
21190
22121
  xml = this._emit('import.parse.start', { xml: xml }) || xml;
21191
22122
 
@@ -21213,13 +22144,8 @@
21213
22144
  /**
21214
22145
  * A `import.parse.complete` event.
21215
22146
  *
21216
- * @event BaseViewer#ImportParseComplete
21217
- * @type {Object}
21218
- * @property {Error|null} error An error thrown when parsing the XML.
21219
- * @property {ModdleElement} definitions The definitions model element.
21220
- * @property {ModdleElementsById} elementsById The model elements by ID.
21221
- * @property {ModdleElement[]} references The referenced model elements.
21222
- * @property {string[]} warnings The warnings produced when parsing the XML.
22147
+ * @event BaseViewer#ImportParseCompleteEvent
22148
+ * @type {ImportParseCompleteEvent}
21223
22149
  */
21224
22150
  definitions = this._emit('import.parse.complete', ParseCompleteEvent({
21225
22151
  error: null,
@@ -21236,10 +22162,8 @@
21236
22162
  /**
21237
22163
  * A `import.parse.complete` event.
21238
22164
  *
21239
- * @event BaseViewer#ImportDone
21240
- * @type {Object}
21241
- * @property {ImportXMLError|null} error An error thrown during import.
21242
- * @property {string[]} warnings The warnings.
22165
+ * @event BaseViewer#ImportDoneEvent
22166
+ * @type {ImportDoneEvent}
21243
22167
  */
21244
22168
  this._emit('import.done', { error: null, warnings: aggregatedWarnings });
21245
22169
 
@@ -21255,7 +22179,9 @@
21255
22179
 
21256
22180
  throw error;
21257
22181
  }
21258
- });
22182
+ };
22183
+
22184
+ BaseViewer.prototype.importXML = wrapForCompatibility(BaseViewer.prototype.importXML);
21259
22185
 
21260
22186
 
21261
22187
  /**
@@ -21280,12 +22206,14 @@
21280
22206
  *
21281
22207
  * @return {Promise<ImportDefinitionsResult>} A promise resolving with warnings that were produced during the import.
21282
22208
  */
21283
- BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
22209
+ BaseViewer.prototype.importDefinitions = async function importDefinitions(definitions, bpmnDiagram) {
21284
22210
  this._setDefinitions(definitions);
21285
22211
  const result = await this.open(bpmnDiagram);
21286
22212
 
21287
22213
  return { warnings: result.warnings };
21288
- });
22214
+ };
22215
+
22216
+ BaseViewer.prototype.importDefinitions = wrapForCompatibility(BaseViewer.prototype.importDefinitions);
21289
22217
 
21290
22218
 
21291
22219
  /**
@@ -21309,7 +22237,7 @@
21309
22237
  *
21310
22238
  * @return {Promise<OpenResult>} A promise resolving with warnings that were produced during opening.
21311
22239
  */
21312
- BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
22240
+ BaseViewer.prototype.open = async function open(bpmnDiagramOrId) {
21313
22241
 
21314
22242
  const definitions = this._definitions;
21315
22243
  let bpmnDiagram = bpmnDiagramOrId;
@@ -21346,7 +22274,9 @@
21346
22274
  const { warnings } = await importBpmnDiagram(this, definitions, bpmnDiagram);
21347
22275
 
21348
22276
  return { warnings };
21349
- });
22277
+ };
22278
+
22279
+ BaseViewer.prototype.open = wrapForCompatibility(BaseViewer.prototype.open);
21350
22280
 
21351
22281
  /**
21352
22282
  * Export the currently displayed BPMN 2.0 diagram as
@@ -21371,7 +22301,7 @@
21371
22301
  *
21372
22302
  * @return {Promise<SaveXMLResult>} A promise resolving with the XML.
21373
22303
  */
21374
- BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
22304
+ BaseViewer.prototype.saveXML = async function saveXML(options) {
21375
22305
 
21376
22306
  options = options || {};
21377
22307
 
@@ -21388,9 +22318,8 @@
21388
22318
  /**
21389
22319
  * A `saveXML.start` event.
21390
22320
  *
21391
- * @event BaseViewer#SaveXMLStart
21392
- * @type {Object}
21393
- * @property {ModdleElement} definitions The definitions model element.
22321
+ * @event BaseViewer#SaveXMLStartEvent
22322
+ * @type {SaveXMLStartEvent}
21394
22323
  */
21395
22324
  definitions = this._emit('saveXML.start', {
21396
22325
  definitions
@@ -21411,10 +22340,8 @@
21411
22340
  /**
21412
22341
  * A `saveXML.done` event.
21413
22342
  *
21414
- * @event BaseViewer#SaveXMLDone
21415
- * @type {Object}
21416
- * @property {Error} [error] An error thrown when saving the XML.
21417
- * @property {string} [xml] The saved XML.
22343
+ * @event BaseViewer#SaveXMLDoneEvent
22344
+ * @type {SaveXMLDoneEvent}
21418
22345
  */
21419
22346
  this._emit('saveXML.done', result);
21420
22347
 
@@ -21423,7 +22350,9 @@
21423
22350
  }
21424
22351
 
21425
22352
  return result;
21426
- });
22353
+ };
22354
+
22355
+ BaseViewer.prototype.saveXML = wrapForCompatibility(BaseViewer.prototype.saveXML);
21427
22356
 
21428
22357
 
21429
22358
  /**
@@ -21445,7 +22374,7 @@
21445
22374
  *
21446
22375
  * @return {Promise<SaveSVGResult>} A promise resolving with the SVG.
21447
22376
  */
21448
- BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG() {
22377
+ BaseViewer.prototype.saveSVG = async function saveSVG() {
21449
22378
  this._emit('saveSVG.start');
21450
22379
 
21451
22380
  let svg, err;
@@ -21477,10 +22406,8 @@
21477
22406
  /**
21478
22407
  * A `saveSVG.done` event.
21479
22408
  *
21480
- * @event BaseViewer#SaveSVGDone
21481
- * @type {Object}
21482
- * @property {Error} [error] An error thrown when saving the SVG.
21483
- * @property {string} [svg] The saved SVG.
22409
+ * @event BaseViewer#SaveSVGDoneEvent
22410
+ * @type {SaveSVGDoneEvent}
21484
22411
  */
21485
22412
  this._emit('saveSVG.done', {
21486
22413
  error: err,
@@ -21492,7 +22419,9 @@
21492
22419
  }
21493
22420
 
21494
22421
  return { svg };
21495
- });
22422
+ };
22423
+
22424
+ BaseViewer.prototype.saveSVG = wrapForCompatibility(BaseViewer.prototype.saveSVG);
21496
22425
 
21497
22426
  /**
21498
22427
  * Get a named diagram service.
@@ -21574,10 +22503,12 @@
21574
22503
  *
21575
22504
  * Remove an event listener via {@link BaseViewer#off}.
21576
22505
  *
22506
+ * @template T
22507
+ *
21577
22508
  * @param {string|string[]} events The event(s) to listen to.
21578
22509
  * @param {number} [priority] The priority with which to listen.
21579
- * @param {EventCallback} callback The callback.
21580
- * @param {*} [that] Value of `this` the callback will be called with.
22510
+ * @param {EventBusEventCallback<T>} callback The callback.
22511
+ * @param {any} [that] Value of `this` the callback will be called with.
21581
22512
  */
21582
22513
  BaseViewer.prototype.on = function(events, priority, callback, that) {
21583
22514
  return this.get('eventBus').on(events, priority, callback, that);
@@ -21627,7 +22558,7 @@
21627
22558
  /**
21628
22559
  * Get the definitions model element.
21629
22560
  *
21630
- * @returns {ModdleElement} The definitions model element.
22561
+ * @return {ModdleElement} The definitions model element.
21631
22562
  */
21632
22563
  BaseViewer.prototype.getDefinitions = function() {
21633
22564
  return this._definitions;
@@ -21696,6 +22627,11 @@
21696
22627
  return this.get('eventBus').fire(type, event);
21697
22628
  };
21698
22629
 
22630
+ /**
22631
+ * @param {BaseViewerOptions} options
22632
+ *
22633
+ * @return {HTMLElement}
22634
+ */
21699
22635
  BaseViewer.prototype._createContainer = function(options) {
21700
22636
 
21701
22637
  const container = domify$1('<div class="bjs-container"></div>');
@@ -21709,6 +22645,11 @@
21709
22645
  return container;
21710
22646
  };
21711
22647
 
22648
+ /**
22649
+ * @param {BaseViewerOptions} options
22650
+ *
22651
+ * @return {Moddle}
22652
+ */
21712
22653
  BaseViewer.prototype._createModdle = function(options) {
21713
22654
  const moddleOptions = assign$1({}, this._moddleExtensions, options.moddleExtensions);
21714
22655