@eclipse-glsp/client 1.1.0-next.383e4e9.264 → 1.1.0-next.3d1b3e6.280

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 (387) hide show
  1. package/css/decoration.css +0 -7
  2. package/css/glsp-sprotty.css +7 -0
  3. package/css/key-shortcut.css +5 -1
  4. package/{lib/base/source-uri-aware.js → css/navigation.css} +11 -9
  5. package/css/status-overlay.css +75 -0
  6. package/css/toast.css +45 -0
  7. package/lib/base/action-dispatcher.d.ts +8 -2
  8. package/lib/base/action-dispatcher.d.ts.map +1 -1
  9. package/lib/base/action-dispatcher.js +15 -7
  10. package/lib/base/action-dispatcher.js.map +1 -1
  11. package/lib/base/action-dispatcher.spec.d.ts +2 -0
  12. package/lib/base/action-dispatcher.spec.d.ts.map +1 -0
  13. package/lib/base/action-dispatcher.spec.js +78 -0
  14. package/lib/base/action-dispatcher.spec.js.map +1 -0
  15. package/lib/base/action-handler-registry.d.ts +25 -0
  16. package/lib/base/action-handler-registry.d.ts.map +1 -0
  17. package/lib/{features/tools/base-glsp-creation-tool.js → base/action-handler-registry.js} +20 -25
  18. package/lib/base/action-handler-registry.js.map +1 -0
  19. package/lib/base/default.module.d.ts +1 -10
  20. package/lib/base/default.module.d.ts.map +1 -1
  21. package/lib/base/default.module.js +20 -30
  22. package/lib/base/default.module.js.map +1 -1
  23. package/lib/base/editor-context-service.d.ts +17 -5
  24. package/lib/base/editor-context-service.d.ts.map +1 -1
  25. package/lib/base/editor-context-service.js +41 -14
  26. package/lib/base/editor-context-service.js.map +1 -1
  27. package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
  28. package/lib/base/feedback/feedback-action-dispatcher.js +5 -3
  29. package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
  30. package/lib/base/focus/focus-tracker.d.ts +4 -0
  31. package/lib/base/focus/focus-tracker.d.ts.map +1 -1
  32. package/lib/base/focus/focus-tracker.js +12 -5
  33. package/lib/base/focus/focus-tracker.js.map +1 -1
  34. package/lib/base/model/diagram-loader.d.ts +116 -0
  35. package/lib/base/model/diagram-loader.d.ts.map +1 -0
  36. package/lib/base/model/diagram-loader.js +130 -0
  37. package/lib/base/model/diagram-loader.js.map +1 -0
  38. package/lib/base/model/glsp-model-source.d.ts +74 -0
  39. package/lib/base/model/glsp-model-source.d.ts.map +1 -0
  40. package/lib/base/model/glsp-model-source.js +178 -0
  41. package/lib/base/model/glsp-model-source.js.map +1 -0
  42. package/lib/base/{model-initialization-constraint.d.ts → model/model-initialization-constraint.d.ts} +24 -3
  43. package/lib/base/model/model-initialization-constraint.d.ts.map +1 -0
  44. package/lib/base/{model-initialization-constraint.js → model/model-initialization-constraint.js} +20 -10
  45. package/lib/base/model/model-initialization-constraint.js.map +1 -0
  46. package/lib/base/model/model-initialization-constraint.spec.d.ts +2 -0
  47. package/lib/base/model/model-initialization-constraint.spec.d.ts.map +1 -0
  48. package/lib/base/model/model-initialization-constraint.spec.js +97 -0
  49. package/lib/base/model/model-initialization-constraint.spec.js.map +1 -0
  50. package/lib/base/selection-service.spec.js +9 -8
  51. package/lib/base/selection-service.spec.js.map +1 -1
  52. package/lib/base/tool-manager/tool-manager.d.ts +82 -0
  53. package/lib/base/tool-manager/tool-manager.d.ts.map +1 -0
  54. package/lib/base/tool-manager/tool-manager.js +140 -0
  55. package/lib/base/tool-manager/tool-manager.js.map +1 -0
  56. package/lib/base/tool-manager/tool.d.ts +54 -0
  57. package/lib/base/tool-manager/tool.d.ts.map +1 -0
  58. package/lib/base/tool-manager/tool.js +60 -0
  59. package/lib/base/tool-manager/tool.js.map +1 -0
  60. package/lib/default-modules.d.ts +20 -26
  61. package/lib/default-modules.d.ts.map +1 -1
  62. package/lib/default-modules.js +31 -29
  63. package/lib/default-modules.js.map +1 -1
  64. package/lib/features/accessibility/accessibility-module.d.ts.map +1 -1
  65. package/lib/features/accessibility/accessibility-module.js +6 -0
  66. package/lib/features/accessibility/accessibility-module.js.map +1 -1
  67. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.d.ts +65 -0
  68. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.d.ts.map +1 -0
  69. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js +290 -0
  70. package/lib/features/accessibility/element-navigation/diagram-navigation-tool.js.map +1 -0
  71. package/lib/features/accessibility/element-navigation/element-navigation-module.d.ts +24 -0
  72. package/lib/features/accessibility/element-navigation/element-navigation-module.d.ts.map +1 -0
  73. package/lib/features/accessibility/element-navigation/element-navigation-module.js +38 -0
  74. package/lib/features/accessibility/element-navigation/element-navigation-module.js.map +1 -0
  75. package/lib/features/accessibility/element-navigation/element-navigator.d.ts +26 -0
  76. package/lib/features/accessibility/element-navigation/element-navigator.d.ts.map +1 -0
  77. package/{src/base/source-uri-aware.ts → lib/features/accessibility/element-navigation/element-navigator.js} +4 -9
  78. package/lib/features/accessibility/element-navigation/element-navigator.js.map +1 -0
  79. package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.d.ts +28 -0
  80. package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.d.ts.map +1 -0
  81. package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js +104 -0
  82. package/lib/features/accessibility/element-navigation/left-right-top-bottom-navigator.js.map +1 -0
  83. package/lib/features/accessibility/element-navigation/local-element-navigator.d.ts +35 -0
  84. package/lib/features/accessibility/element-navigation/local-element-navigator.d.ts.map +1 -0
  85. package/lib/features/accessibility/element-navigation/local-element-navigator.js +117 -0
  86. package/lib/features/accessibility/element-navigation/local-element-navigator.js.map +1 -0
  87. package/lib/features/accessibility/element-navigation/position-navigator.d.ts +32 -0
  88. package/lib/features/accessibility/element-navigation/position-navigator.d.ts.map +1 -0
  89. package/lib/features/accessibility/element-navigation/position-navigator.js +80 -0
  90. package/lib/features/accessibility/element-navigation/position-navigator.js.map +1 -0
  91. package/lib/features/accessibility/focus-tracker/focus-tracker-module.d.ts +23 -0
  92. package/lib/features/accessibility/focus-tracker/focus-tracker-module.d.ts.map +1 -0
  93. package/lib/features/accessibility/focus-tracker/focus-tracker-module.js +33 -0
  94. package/lib/features/accessibility/focus-tracker/focus-tracker-module.js.map +1 -0
  95. package/lib/features/accessibility/focus-tracker/focus-tracker-tool.d.ts +37 -0
  96. package/lib/features/accessibility/focus-tracker/focus-tracker-tool.d.ts.map +1 -0
  97. package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js +133 -0
  98. package/lib/features/accessibility/focus-tracker/focus-tracker-tool.js.map +1 -0
  99. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts +2 -2
  100. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.d.ts.map +1 -1
  101. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.js +2 -2
  102. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut-tool.js.map +1 -1
  103. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.d.ts +1 -0
  104. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.d.ts.map +1 -1
  105. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.js +15 -3
  106. package/lib/features/accessibility/key-shortcut/accessible-key-shortcut.js.map +1 -1
  107. package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts +2 -2
  108. package/lib/features/accessibility/resize-key-tool/resize-key-tool.d.ts.map +1 -1
  109. package/lib/features/accessibility/resize-key-tool/resize-key-tool.js +22 -15
  110. package/lib/features/accessibility/resize-key-tool/resize-key-tool.js.map +1 -1
  111. package/lib/features/accessibility/search/search-palette.d.ts.map +1 -1
  112. package/lib/features/accessibility/search/search-palette.js +3 -1
  113. package/lib/features/accessibility/search/search-palette.js.map +1 -1
  114. package/lib/features/accessibility/search/search-tool.d.ts +2 -1
  115. package/lib/features/accessibility/search/search-tool.d.ts.map +1 -1
  116. package/lib/features/accessibility/search/search-tool.js +4 -8
  117. package/lib/features/accessibility/search/search-tool.js.map +1 -1
  118. package/lib/features/accessibility/toast/messages.json +16 -0
  119. package/lib/features/accessibility/toast/toast-handler.d.ts +45 -0
  120. package/lib/features/accessibility/toast/toast-handler.d.ts.map +1 -0
  121. package/lib/features/accessibility/toast/toast-handler.js +54 -0
  122. package/lib/features/accessibility/toast/toast-handler.js.map +1 -0
  123. package/lib/features/accessibility/toast/toast-module.d.ts +24 -0
  124. package/lib/features/accessibility/toast/toast-module.d.ts.map +1 -0
  125. package/lib/features/accessibility/toast/toast-module.js +38 -0
  126. package/lib/features/accessibility/toast/toast-module.js.map +1 -0
  127. package/lib/features/accessibility/toast/toast-tool.d.ts +43 -0
  128. package/lib/features/accessibility/toast/toast-tool.d.ts.map +1 -0
  129. package/lib/features/accessibility/toast/toast-tool.js +115 -0
  130. package/lib/features/accessibility/toast/toast-tool.js.map +1 -0
  131. package/lib/features/accessibility/view-key-tools/deselect-key-tool.d.ts +2 -2
  132. package/lib/features/accessibility/view-key-tools/deselect-key-tool.d.ts.map +1 -1
  133. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts +2 -2
  134. package/lib/features/accessibility/view-key-tools/movement-key-tool.d.ts.map +1 -1
  135. package/lib/features/accessibility/view-key-tools/movement-key-tool.js +4 -8
  136. package/lib/features/accessibility/view-key-tools/movement-key-tool.js.map +1 -1
  137. package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts +2 -2
  138. package/lib/features/accessibility/view-key-tools/zoom-key-tool.d.ts.map +1 -1
  139. package/lib/features/accessibility/view-key-tools/zoom-key-tool.js +9 -13
  140. package/lib/features/accessibility/view-key-tools/zoom-key-tool.js.map +1 -1
  141. package/lib/features/bounds/bounds-module.d.ts.map +1 -1
  142. package/lib/features/bounds/bounds-module.js +2 -1
  143. package/lib/features/bounds/bounds-module.js.map +1 -1
  144. package/lib/features/command-palette/command-palette-tool.d.ts +2 -1
  145. package/lib/features/command-palette/command-palette-tool.d.ts.map +1 -1
  146. package/lib/features/command-palette/command-palette-tool.js.map +1 -1
  147. package/lib/features/command-palette/server-command-palette-provider.d.ts.map +1 -1
  148. package/lib/features/command-palette/server-command-palette-provider.js +3 -2
  149. package/lib/features/command-palette/server-command-palette-provider.js.map +1 -1
  150. package/lib/features/context-menu/context-menu-module.d.ts.map +1 -1
  151. package/lib/features/context-menu/context-menu-module.js +8 -8
  152. package/lib/features/context-menu/context-menu-module.js.map +1 -1
  153. package/lib/features/context-menu/{selection-service-aware-context-menu-mouse-listener.d.ts → glsp-context-menu-mouse-listener.d.ts} +2 -4
  154. package/lib/features/context-menu/glsp-context-menu-mouse-listener.d.ts.map +1 -0
  155. package/lib/features/context-menu/{selection-service-aware-context-menu-mouse-listener.js → glsp-context-menu-mouse-listener.js} +7 -12
  156. package/lib/features/context-menu/glsp-context-menu-mouse-listener.js.map +1 -0
  157. package/lib/features/context-menu/server-context-menu-provider.d.ts +1 -1
  158. package/lib/features/context-menu/server-context-menu-provider.d.ts.map +1 -1
  159. package/lib/features/context-menu/server-context-menu-provider.js +3 -2
  160. package/lib/features/context-menu/server-context-menu-provider.js.map +1 -1
  161. package/lib/features/copy-paste/copy-paste-context-menu.d.ts.map +1 -1
  162. package/lib/features/copy-paste/copy-paste-context-menu.js +1 -4
  163. package/lib/features/copy-paste/copy-paste-context-menu.js.map +1 -1
  164. package/lib/features/hints/type-hints-module.d.ts.map +1 -1
  165. package/lib/features/hints/type-hints-module.js +6 -5
  166. package/lib/features/hints/type-hints-module.js.map +1 -1
  167. package/lib/features/hints/type-hints.d.ts +6 -2
  168. package/lib/features/hints/type-hints.d.ts.map +1 -1
  169. package/lib/features/hints/type-hints.js +8 -0
  170. package/lib/features/hints/type-hints.js.map +1 -1
  171. package/lib/features/hover/hover-module.d.ts.map +1 -1
  172. package/lib/features/hover/hover-module.js +3 -2
  173. package/lib/features/hover/hover-module.js.map +1 -1
  174. package/lib/features/hover/hover.d.ts.map +1 -1
  175. package/lib/features/hover/hover.js +3 -2
  176. package/lib/features/hover/hover.js.map +1 -1
  177. package/lib/features/label-edit/edit-label-tool.d.ts +2 -2
  178. package/lib/features/label-edit/edit-label-tool.d.ts.map +1 -1
  179. package/lib/features/label-edit/edit-label-tool.js +2 -2
  180. package/lib/features/label-edit/edit-label-tool.js.map +1 -1
  181. package/lib/features/label-edit/edit-label-validator.d.ts.map +1 -1
  182. package/lib/features/label-edit/edit-label-validator.js +3 -2
  183. package/lib/features/label-edit/edit-label-validator.js.map +1 -1
  184. package/lib/features/navigation/navigation-action-handler.d.ts.map +1 -1
  185. package/lib/features/navigation/navigation-action-handler.js +1 -4
  186. package/lib/features/navigation/navigation-action-handler.js.map +1 -1
  187. package/lib/features/navigation/navigation-target-resolver.d.ts +3 -3
  188. package/lib/features/navigation/navigation-target-resolver.d.ts.map +1 -1
  189. package/lib/features/navigation/navigation-target-resolver.js +5 -7
  190. package/lib/features/navigation/navigation-target-resolver.js.map +1 -1
  191. package/lib/features/select/select-mouse-listener.d.ts +4 -2
  192. package/lib/features/select/select-mouse-listener.d.ts.map +1 -1
  193. package/lib/features/select/select-mouse-listener.js +17 -58
  194. package/lib/features/select/select-mouse-listener.js.map +1 -1
  195. package/lib/features/source-model-watcher/source-model-changed-action-handler.d.ts.map +1 -1
  196. package/lib/features/source-model-watcher/source-model-changed-action-handler.js +1 -4
  197. package/lib/features/source-model-watcher/source-model-changed-action-handler.js.map +1 -1
  198. package/lib/features/status/status-module.d.ts +19 -0
  199. package/lib/features/status/status-module.d.ts.map +1 -0
  200. package/lib/features/status/status-module.js +28 -0
  201. package/lib/features/status/status-module.js.map +1 -0
  202. package/lib/features/status/status-overlay.d.ts +25 -0
  203. package/lib/features/status/status-overlay.d.ts.map +1 -0
  204. package/lib/features/status/status-overlay.js +124 -0
  205. package/lib/features/status/status-overlay.js.map +1 -0
  206. package/lib/features/tool-palette/tool-palette-module.d.ts.map +1 -1
  207. package/lib/features/tool-palette/tool-palette-module.js +3 -2
  208. package/lib/features/tool-palette/tool-palette-module.js.map +1 -1
  209. package/lib/features/tool-palette/tool-palette.d.ts +10 -8
  210. package/lib/features/tool-palette/tool-palette.d.ts.map +1 -1
  211. package/lib/features/tool-palette/tool-palette.js +36 -29
  212. package/lib/features/tool-palette/tool-palette.js.map +1 -1
  213. package/lib/features/tools/{base-glsp-tool.d.ts → base-tools.d.ts} +14 -4
  214. package/lib/features/tools/base-tools.d.ts.map +1 -0
  215. package/lib/features/tools/{base-glsp-tool.js → base-tools.js} +31 -10
  216. package/lib/features/tools/base-tools.js.map +1 -0
  217. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts +2 -2
  218. package/lib/features/tools/change-bounds/change-bounds-tool.d.ts.map +1 -1
  219. package/lib/features/tools/change-bounds/change-bounds-tool.js +2 -2
  220. package/lib/features/tools/change-bounds/change-bounds-tool.js.map +1 -1
  221. package/lib/features/tools/deletion/delete-tool.d.ts +4 -4
  222. package/lib/features/tools/deletion/delete-tool.d.ts.map +1 -1
  223. package/lib/features/tools/deletion/delete-tool.js +4 -3
  224. package/lib/features/tools/deletion/delete-tool.js.map +1 -1
  225. package/lib/features/tools/edge-creation/edge-creation-tool.d.ts +2 -2
  226. package/lib/features/tools/edge-creation/edge-creation-tool.d.ts.map +1 -1
  227. package/lib/features/tools/edge-creation/edge-creation-tool.js +5 -4
  228. package/lib/features/tools/edge-creation/edge-creation-tool.js.map +1 -1
  229. package/lib/features/tools/edge-edit/edge-edit-tool.d.ts +2 -2
  230. package/lib/features/tools/edge-edit/edge-edit-tool.d.ts.map +1 -1
  231. package/lib/features/tools/edge-edit/edge-edit-tool.js +2 -2
  232. package/lib/features/tools/edge-edit/edge-edit-tool.js.map +1 -1
  233. package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts +2 -2
  234. package/lib/features/tools/marquee-selection/marquee-mouse-tool.d.ts.map +1 -1
  235. package/lib/features/tools/marquee-selection/marquee-mouse-tool.js +5 -4
  236. package/lib/features/tools/marquee-selection/marquee-mouse-tool.js.map +1 -1
  237. package/lib/features/tools/marquee-selection/marquee-tool.d.ts +2 -2
  238. package/lib/features/tools/marquee-selection/marquee-tool.d.ts.map +1 -1
  239. package/lib/features/tools/marquee-selection/marquee-tool.js +4 -3
  240. package/lib/features/tools/marquee-selection/marquee-tool.js.map +1 -1
  241. package/lib/features/tools/node-creation/node-creation-tool.d.ts +2 -2
  242. package/lib/features/tools/node-creation/node-creation-tool.d.ts.map +1 -1
  243. package/lib/features/tools/node-creation/node-creation-tool.js +4 -3
  244. package/lib/features/tools/node-creation/node-creation-tool.js.map +1 -1
  245. package/lib/features/tools/tool-focus-loss-module.d.ts.map +1 -1
  246. package/lib/features/tools/tool-focus-loss-module.js +2 -1
  247. package/lib/features/tools/tool-focus-loss-module.js.map +1 -1
  248. package/lib/features/validation/validate.js +1 -1
  249. package/lib/features/validation/validate.js.map +1 -1
  250. package/lib/features/viewport/glsp-scroll-mouse-listener.d.ts.map +1 -1
  251. package/lib/features/viewport/glsp-scroll-mouse-listener.js +3 -2
  252. package/lib/features/viewport/glsp-scroll-mouse-listener.js.map +1 -1
  253. package/lib/features/viewport/reposition.d.ts +38 -0
  254. package/lib/features/viewport/reposition.d.ts.map +1 -0
  255. package/lib/features/viewport/reposition.js +109 -0
  256. package/lib/features/viewport/reposition.js.map +1 -0
  257. package/lib/features/viewport/viewport-modules.d.ts.map +1 -1
  258. package/lib/features/viewport/viewport-modules.js +5 -2
  259. package/lib/features/viewport/viewport-modules.js.map +1 -1
  260. package/lib/glsp-sprotty/augmented-actions.d.ts +2 -10
  261. package/lib/glsp-sprotty/augmented-actions.d.ts.map +1 -1
  262. package/lib/glsp-sprotty/augmented-actions.js +2 -6
  263. package/lib/glsp-sprotty/augmented-actions.js.map +1 -1
  264. package/lib/glsp-sprotty/index.d.ts +3 -6
  265. package/lib/glsp-sprotty/index.d.ts.map +1 -1
  266. package/lib/glsp-sprotty/index.js +4 -7
  267. package/lib/glsp-sprotty/index.js.map +1 -1
  268. package/lib/glsp-sprotty/types.d.ts +5 -82
  269. package/lib/glsp-sprotty/types.d.ts.map +1 -1
  270. package/lib/glsp-sprotty/types.js +2 -8
  271. package/lib/glsp-sprotty/types.js.map +1 -1
  272. package/lib/index.d.ts +17 -7
  273. package/lib/index.d.ts.map +1 -1
  274. package/lib/index.js +17 -7
  275. package/lib/index.js.map +1 -1
  276. package/lib/standalone-modules.d.ts +11 -2
  277. package/lib/standalone-modules.d.ts.map +1 -1
  278. package/lib/standalone-modules.js +37 -1
  279. package/lib/standalone-modules.js.map +1 -1
  280. package/lib/views/base-view-module.d.ts.map +1 -1
  281. package/lib/views/base-view-module.js +2 -1
  282. package/lib/views/base-view-module.js.map +1 -1
  283. package/lib/views/glsp-projection-view.d.ts +2 -1
  284. package/lib/views/glsp-projection-view.d.ts.map +1 -1
  285. package/lib/views/glsp-projection-view.js +11 -2
  286. package/lib/views/glsp-projection-view.js.map +1 -1
  287. package/package.json +4 -4
  288. package/src/base/action-dispatcher.spec.ts +87 -0
  289. package/src/base/action-dispatcher.ts +24 -10
  290. package/src/{features/tools/base-glsp-creation-tool.ts → base/action-handler-registry.ts} +10 -20
  291. package/src/base/default.module.ts +21 -34
  292. package/src/base/editor-context-service.ts +49 -16
  293. package/src/base/feedback/feedback-action-dispatcher.ts +5 -3
  294. package/src/base/focus/focus-tracker.ts +16 -5
  295. package/src/base/model/diagram-loader.ts +215 -0
  296. package/src/base/model/glsp-model-source.ts +199 -0
  297. package/src/base/model/model-initialization-constraint.spec.ts +95 -0
  298. package/src/base/{model-initialization-constraint.ts → model/model-initialization-constraint.ts} +43 -10
  299. package/src/base/selection-service.spec.ts +10 -9
  300. package/src/base/tool-manager/tool-manager.ts +183 -0
  301. package/src/base/tool-manager/tool.ts +85 -0
  302. package/src/default-modules.ts +37 -28
  303. package/src/features/accessibility/README.md +18 -0
  304. package/src/features/accessibility/accessibility-module.ts +6 -1
  305. package/src/features/accessibility/element-navigation/diagram-navigation-tool.ts +307 -0
  306. package/src/features/accessibility/element-navigation/element-navigation-module.ts +36 -0
  307. package/src/features/accessibility/element-navigation/element-navigator.ts +57 -0
  308. package/src/features/accessibility/element-navigation/left-right-top-bottom-navigator.ts +113 -0
  309. package/src/features/accessibility/element-navigation/local-element-navigator.ts +147 -0
  310. package/src/features/accessibility/element-navigation/position-navigator.ts +102 -0
  311. package/src/features/accessibility/focus-tracker/focus-tracker-module.ts +32 -0
  312. package/src/features/accessibility/focus-tracker/focus-tracker-tool.ts +129 -0
  313. package/src/features/accessibility/key-shortcut/accessible-key-shortcut-tool.ts +3 -3
  314. package/src/features/accessibility/key-shortcut/accessible-key-shortcut.ts +18 -3
  315. package/src/features/accessibility/resize-key-tool/resize-key-tool.ts +30 -16
  316. package/src/features/accessibility/search/search-palette.ts +4 -2
  317. package/src/features/accessibility/search/search-tool.ts +8 -9
  318. package/src/features/accessibility/toast/messages.json +16 -0
  319. package/src/features/accessibility/toast/toast-handler.ts +69 -0
  320. package/src/features/accessibility/toast/toast-module.ts +36 -0
  321. package/src/features/accessibility/toast/toast-tool.ts +108 -0
  322. package/src/features/accessibility/view-key-tools/deselect-key-tool.ts +2 -2
  323. package/src/features/accessibility/view-key-tools/movement-key-tool.ts +8 -10
  324. package/src/features/accessibility/view-key-tools/zoom-key-tool.ts +13 -15
  325. package/src/features/bounds/bounds-module.ts +2 -2
  326. package/src/features/command-palette/command-palette-tool.ts +2 -1
  327. package/src/features/command-palette/server-command-palette-provider.ts +3 -2
  328. package/src/features/context-menu/context-menu-module.ts +11 -12
  329. package/src/features/context-menu/{selection-service-aware-context-menu-mouse-listener.ts → glsp-context-menu-mouse-listener.ts} +1 -5
  330. package/src/features/context-menu/server-context-menu-provider.ts +3 -2
  331. package/src/features/copy-paste/copy-paste-context-menu.ts +3 -6
  332. package/src/features/hints/type-hints-module.ts +7 -6
  333. package/src/features/hints/type-hints.ts +12 -1
  334. package/src/features/hover/hover-module.ts +1 -2
  335. package/src/features/hover/hover.ts +2 -3
  336. package/src/features/label-edit/edit-label-tool.ts +2 -2
  337. package/src/features/label-edit/edit-label-validator.ts +7 -6
  338. package/src/features/navigation/navigation-action-handler.ts +5 -8
  339. package/src/features/navigation/navigation-target-resolver.ts +10 -7
  340. package/src/features/select/select-mouse-listener.ts +27 -79
  341. package/src/features/source-model-watcher/source-model-changed-action-handler.ts +3 -6
  342. package/src/features/status/status-module.ts +26 -0
  343. package/src/features/status/status-overlay.ts +121 -0
  344. package/src/features/tool-palette/tool-palette-module.ts +4 -3
  345. package/src/features/tool-palette/tool-palette.ts +44 -33
  346. package/src/features/tools/{base-glsp-tool.ts → base-tools.ts} +28 -3
  347. package/src/features/tools/change-bounds/change-bounds-tool.ts +2 -2
  348. package/src/features/tools/deletion/delete-tool.ts +4 -5
  349. package/src/features/tools/edge-creation/edge-creation-tool.ts +3 -3
  350. package/src/features/tools/edge-edit/edge-edit-tool.ts +2 -2
  351. package/src/features/tools/marquee-selection/marquee-mouse-tool.ts +3 -3
  352. package/src/features/tools/marquee-selection/marquee-tool.ts +4 -3
  353. package/src/features/tools/node-creation/node-creation-tool.ts +3 -3
  354. package/src/features/tools/tool-focus-loss-module.ts +2 -1
  355. package/src/features/validation/validate.ts +1 -1
  356. package/src/features/viewport/glsp-scroll-mouse-listener.ts +2 -9
  357. package/src/features/viewport/reposition.ts +119 -0
  358. package/src/features/viewport/viewport-modules.ts +3 -2
  359. package/src/glsp-sprotty/augmented-actions.ts +1 -16
  360. package/src/glsp-sprotty/index.ts +4 -7
  361. package/src/glsp-sprotty/types.ts +6 -8
  362. package/src/index.ts +17 -7
  363. package/src/standalone-modules.ts +40 -1
  364. package/src/views/base-view-module.ts +2 -2
  365. package/src/views/glsp-projection-view.tsx +18 -8
  366. package/lib/base/model-initialization-constraint.d.ts.map +0 -1
  367. package/lib/base/model-initialization-constraint.js.map +0 -1
  368. package/lib/base/source-uri-aware.d.ts +0 -5
  369. package/lib/base/source-uri-aware.d.ts.map +0 -1
  370. package/lib/base/source-uri-aware.js.map +0 -1
  371. package/lib/base/tool-manager/glsp-tool-manager.d.ts +0 -21
  372. package/lib/base/tool-manager/glsp-tool-manager.d.ts.map +0 -1
  373. package/lib/base/tool-manager/glsp-tool-manager.js +0 -113
  374. package/lib/base/tool-manager/glsp-tool-manager.js.map +0 -1
  375. package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.d.ts.map +0 -1
  376. package/lib/features/context-menu/selection-service-aware-context-menu-mouse-listener.js.map +0 -1
  377. package/lib/features/tools/base-glsp-creation-tool.d.ts +0 -10
  378. package/lib/features/tools/base-glsp-creation-tool.d.ts.map +0 -1
  379. package/lib/features/tools/base-glsp-creation-tool.js.map +0 -1
  380. package/lib/features/tools/base-glsp-tool.d.ts.map +0 -1
  381. package/lib/features/tools/base-glsp-tool.js.map +0 -1
  382. package/lib/model-source/glsp-diagram-server.d.ts +0 -21
  383. package/lib/model-source/glsp-diagram-server.d.ts.map +0 -1
  384. package/lib/model-source/glsp-diagram-server.js +0 -107
  385. package/lib/model-source/glsp-diagram-server.js.map +0 -1
  386. package/src/base/tool-manager/glsp-tool-manager.ts +0 -96
  387. package/src/model-source/glsp-diagram-server.ts +0 -125
@@ -15,14 +15,15 @@
15
15
  ********************************************************************************/
16
16
  import { inject, injectable } from 'inversify';
17
17
  import { Action, ActionDispatcher, RequestAction, ResponseAction } from '~glsp-sprotty';
18
- import { ModelInitializationConstraint } from './model-initialization-constraint';
18
+ import { ModelInitializationConstraint } from './model/model-initialization-constraint';
19
19
 
20
20
  @injectable()
21
21
  export class GLSPActionDispatcher extends ActionDispatcher {
22
22
  protected readonly timeouts: Map<string, NodeJS.Timeout> = new Map();
23
23
  protected initializedConstraint = false;
24
24
 
25
- @inject(ModelInitializationConstraint) protected initializationConstraint: ModelInitializationConstraint;
25
+ @inject(ModelInitializationConstraint)
26
+ protected initializationConstraint: ModelInitializationConstraint;
26
27
 
27
28
  override initialize(): Promise<void> {
28
29
  return super.initialize().then(() => this.startModelInitialization());
@@ -31,7 +32,7 @@ export class GLSPActionDispatcher extends ActionDispatcher {
31
32
  startModelInitialization(): void {
32
33
  if (!this.initializedConstraint) {
33
34
  this.logger.log(this, 'Starting model initialization mode');
34
- this.initializationConstraint.onInitialized().then(() => this.logger.log(this, 'Model initialization completed'));
35
+ this.initializationConstraint.onInitialized(() => this.logger.log(this, 'Model initialization completed'));
35
36
  this.initializedConstraint = true;
36
37
  }
37
38
  }
@@ -44,8 +45,17 @@ export class GLSPActionDispatcher extends ActionDispatcher {
44
45
  return this.actionHandlerRegistry.get(action.kind).length > 0;
45
46
  }
46
47
 
47
- override dispatch(action: Action): Promise<void> {
48
- const result = super.dispatch(action);
48
+ /**
49
+ * Processes all given actions, by dispatching them to the corresponding handlers, after the model initialization is completed.
50
+ *
51
+ * @param actions The actions that should be dispatched after the model initialization
52
+ */
53
+ dispatchOnceModelInitialized(...actions: Action[]): void {
54
+ this.initializationConstraint.onInitialized(() => this.dispatchAll(actions));
55
+ }
56
+
57
+ override async dispatch(action: Action): Promise<void> {
58
+ const result = await super.dispatch(action);
49
59
  this.initializationConstraint.notifyDispatched(action);
50
60
  return result;
51
61
  }
@@ -59,11 +69,11 @@ export class GLSPActionDispatcher extends ActionDispatcher {
59
69
  this.timeouts.delete(action.responseId);
60
70
  }
61
71
 
62
- // we might have reached a timeout, so we simply drop the response
72
+ // Check if we have a pending request for the response.
73
+ // If not the we clear the responseId => action will be dispatched normally
63
74
  const deferred = this.requests.get(action.responseId);
64
75
  if (deferred === undefined) {
65
- this.logger.log(this, 'No matching request for response', action);
66
- return Promise.resolve();
76
+ action.responseId = '';
67
77
  }
68
78
  }
69
79
  return super.handleAction(action);
@@ -87,7 +97,11 @@ export class GLSPActionDispatcher extends ActionDispatcher {
87
97
  * If `rejectOnTimeout` is set to false (default) the returned promise will be resolved with
88
98
  * no value, otherwise it will be rejected.
89
99
  */
90
- requestUntil<Res extends ResponseAction>(action: RequestAction<Res>, timeoutMs = 2000, rejectOnTimeout = false): Promise<Res> {
100
+ requestUntil<Res extends ResponseAction>(
101
+ action: RequestAction<Res>,
102
+ timeoutMs = 2000,
103
+ rejectOnTimeout = false
104
+ ): Promise<Res | undefined> {
91
105
  if (!action.requestId && action.requestId === '') {
92
106
  // No request id has been specified. So we use a generated one.
93
107
  action.requestId = RequestAction.generateRequestId();
@@ -112,6 +126,6 @@ export class GLSPActionDispatcher extends ActionDispatcher {
112
126
  }, timeoutMs);
113
127
  this.timeouts.set(requestId, timeout);
114
128
 
115
- return super.request(action);
129
+ return super.request<Res>(action);
116
130
  }
117
131
  }
@@ -13,28 +13,18 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
+
16
17
  import { injectable } from 'inversify';
17
- import { Action, EnableToolsAction, IActionHandler } from '~glsp-sprotty';
18
- import { BaseGLSPTool } from './base-glsp-tool';
18
+ import { ActionHandlerRegistry } from '~glsp-sprotty';
19
19
 
20
20
  @injectable()
21
- export abstract class BaseGLSPCreationTool<T extends Action> extends BaseGLSPTool implements IActionHandler {
22
- protected abstract isTriggerAction: (obj: any) => obj is T;
23
- protected triggerAction: T;
24
-
25
- handle(action: Action): Action | void {
26
- if (this.isTriggerAction(action)) {
27
- this.triggerAction = action;
28
- return EnableToolsAction.create([this.id]);
29
- }
21
+ export class GLSPActionHandlerRegistry extends ActionHandlerRegistry {
22
+ /**
23
+ * Retrieve a set of all action kinds for which (at least) one
24
+ * handler is registered
25
+ * @returns the set of handled action kinds
26
+ */
27
+ getHandledActionKinds(): string[] {
28
+ return Array.from(this.elements.keys());
30
29
  }
31
-
32
- override enable(): void {
33
- if (this.triggerAction === undefined) {
34
- throw new TypeError(`Could not enable tool ${this.id}. The triggerAction cannot be undefined.`);
35
- }
36
- this.doEnable();
37
- }
38
-
39
- protected abstract doEnable(): void;
40
30
  }
@@ -14,16 +14,14 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  import '@vscode/codicons/dist/codicon.css';
17
- import { Container } from 'inversify';
18
17
  import {
19
18
  ActionHandlerRegistry,
20
19
  FeatureModule,
21
- InitializeResult,
22
20
  KeyTool,
23
21
  LocationPostprocessor,
24
- ModelSource,
25
22
  MouseTool,
26
23
  MoveCommand,
24
+ SetDirtyStateAction,
27
25
  SetEditModeAction,
28
26
  TYPES,
29
27
  bindAsService,
@@ -34,6 +32,7 @@ import {
34
32
  } from '~glsp-sprotty';
35
33
  import '../../css/glsp-sprotty.css';
36
34
  import { GLSPActionDispatcher } from './action-dispatcher';
35
+ import { GLSPActionHandlerRegistry } from './action-handler-registry';
37
36
  import { GLSPCommandStack } from './command-stack';
38
37
  import { EditorContextService } from './editor-context-service';
39
38
  import { ModifyCssFeedbackCommand } from './feedback/css-feedback';
@@ -41,11 +40,14 @@ import { FeedbackActionDispatcher } from './feedback/feedback-action-dispatcher'
41
40
  import { FeedbackAwareUpdateModelCommand } from './feedback/update-model-command';
42
41
  import { FocusStateChangedAction } from './focus/focus-state-change-action';
43
42
  import { FocusTracker } from './focus/focus-tracker';
44
- import { DefaultModelInitializationConstraint, ModelInitializationConstraint } from './model-initialization-constraint';
43
+ import { DiagramLoader } from './model/diagram-loader';
44
+ import { GLSPModelSource } from './model/glsp-model-source';
45
+ import { DefaultModelInitializationConstraint, ModelInitializationConstraint } from './model/model-initialization-constraint';
45
46
  import { GLSPModelRegistry } from './model/model-registry';
46
47
  import { SelectionClearingMouseListener } from './selection-clearing-mouse-listener';
47
48
  import { SelectionService } from './selection-service';
48
- import { GLSPToolManager } from './tool-manager/glsp-tool-manager';
49
+ import { EnableDefaultToolsAction, EnableToolsAction } from './tool-manager/tool';
50
+ import { DefaultToolsEnablingKeyListener, ToolManager, ToolManagerActionHandler } from './tool-manager/tool-manager';
49
51
  import { GLSPKeyTool } from './view/key-tool';
50
52
  import { GLSPMouseTool } from './view/mouse-tool';
51
53
  import { GLSPViewRegistry } from './view/view-registry';
@@ -60,18 +62,10 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
60
62
  const context = { bind, unbind, isBound, rebind };
61
63
 
62
64
  bind(EditorContextService).toSelf().inSingletonScope();
63
- bind(TYPES.IEditorContextServiceProvider).toProvider<EditorContextService>(
64
- ctx => () =>
65
- new Promise<EditorContextService>((resolve, reject) => {
66
- if (ctx.container.isBound(EditorContextService)) {
67
- resolve(ctx.container.get<EditorContextService>(EditorContextService));
68
- } else {
69
- reject();
70
- }
71
- })
72
- );
65
+ bind(TYPES.IEditorContextServiceProvider).toProvider<EditorContextService>(ctx => async () => ctx.container.get(EditorContextService));
73
66
 
74
67
  configureActionHandler(context, SetEditModeAction.KIND, EditorContextService);
68
+ configureActionHandler(context, SetDirtyStateAction.KIND, EditorContextService);
75
69
 
76
70
  bind(FocusTracker).toSelf().inSingletonScope();
77
71
  configureActionHandler(context, FocusStateChangedAction.KIND, FocusTracker);
@@ -88,11 +82,13 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
88
82
  bindAsService(context, TYPES.MouseListener, SelectionClearingMouseListener);
89
83
 
90
84
  bindOrRebind(context, TYPES.ICommandStack).to(GLSPCommandStack).inSingletonScope();
91
- bind(GLSPToolManager).toSelf().inSingletonScope();
92
- bindOrRebind(context, TYPES.IToolManager).toService(GLSPToolManager);
93
85
  bind(GLSPActionDispatcher).toSelf().inSingletonScope();
94
86
  bindOrRebind(context, TYPES.IActionDispatcher).toService(GLSPActionDispatcher);
87
+ bind(GLSPActionHandlerRegistry).toSelf().inSingletonScope();
88
+ bindOrRebind(context, ActionHandlerRegistry).toService(GLSPActionHandlerRegistry);
95
89
 
90
+ bindAsService(context, TYPES.ModelSource, GLSPModelSource);
91
+ bind(DiagramLoader).toSelf().inSingletonScope();
96
92
  bind(ModelInitializationConstraint).to(DefaultModelInitializationConstraint).inSingletonScope();
97
93
 
98
94
  // support re-registration of model elements and views
@@ -110,21 +106,12 @@ export const defaultModule = new FeatureModule((bind, unbind, isBound, rebind, .
110
106
 
111
107
  bindAsService(context, TYPES.IVNodePostprocessor, LocationPostprocessor);
112
108
  bind(TYPES.HiddenVNodePostprocessor).toService(LocationPostprocessor);
113
- });
114
109
 
115
- /**
116
- * Utility function to configure the {@link ModelSource}, i.e. the `DiagramServer`, as action handler for all server actions for the given
117
- * diagramType.
118
- * @param result A promise that resolves after all server actions have been registered.
119
- * @param diagramType The diagram type.
120
- * @param container The di container.
121
- */
122
- export async function configureServerActions(result: InitializeResult, diagramType: string, container: Container): Promise<void> {
123
- const modelSource = container.get<ModelSource>(TYPES.ModelSource);
124
- const actionHandlerRegistry = container.get<ActionHandlerRegistry>(ActionHandlerRegistry);
125
- const serverActions = result.serverActions[diagramType];
126
- if (serverActions.length === 0) {
127
- throw new Error(`No server-handled actions could be derived from the initialize result for diagramType: ${diagramType}!`);
128
- }
129
- serverActions.forEach(actionKind => actionHandlerRegistry.register(actionKind, modelSource));
130
- }
110
+ // Tool manager initialization ------------------------------------
111
+ bind(TYPES.IToolManager).to(ToolManager).inSingletonScope();
112
+ bind(DefaultToolsEnablingKeyListener).toSelf().inSingletonScope();
113
+ bind(TYPES.KeyListener).toService(DefaultToolsEnablingKeyListener);
114
+ bind(ToolManagerActionHandler).toSelf().inSingletonScope();
115
+ configureActionHandler(context, EnableDefaultToolsAction.KIND, ToolManagerActionHandler);
116
+ configureActionHandler(context, EnableToolsAction.KIND, ToolManagerActionHandler);
117
+ });
@@ -24,21 +24,24 @@ import {
24
24
  Emitter,
25
25
  Event,
26
26
  IActionHandler,
27
- ModelSource,
27
+ MaybePromise,
28
28
  MousePositionTracker,
29
29
  SModelElement,
30
30
  SModelRoot,
31
+ SetDirtyStateAction,
31
32
  SetEditModeAction,
32
33
  TYPES,
33
34
  ValueChange
34
35
  } from '~glsp-sprotty';
36
+ import { GLSPActionDispatcher } from './action-dispatcher';
37
+ import { IDiagramOptions, IDiagramStartup } from './model/diagram-loader';
35
38
  import { SelectionService } from './selection-service';
36
- import { isSourceUriAware } from './source-uri-aware';
37
39
 
38
40
  export interface IEditModeListener {
39
41
  editModeChanged(newValue: string, oldValue: string): void;
40
42
  }
41
43
 
44
+ export type DirtyStateChange = Pick<SetDirtyStateAction, 'isDirty' | 'reason'>;
42
45
  /**
43
46
  * The `EditorContextService` is a central injectable component that gives read-only access to
44
47
  * certain aspects of the diagram, such as the currently selected elements, the model root,
@@ -52,32 +55,41 @@ export interface IEditModeListener {
52
55
  * position, etc.).
53
56
  */
54
57
  @injectable()
55
- export class EditorContextService implements IActionHandler, Disposable {
58
+ export class EditorContextService implements IActionHandler, Disposable, IDiagramStartup {
56
59
  @inject(SelectionService)
57
60
  protected selectionService: SelectionService;
58
61
 
59
62
  @inject(MousePositionTracker)
60
63
  protected mousePositionTracker: MousePositionTracker;
61
64
 
65
+ @inject(TYPES.IDiagramOptions)
66
+ protected diagramOptions: IDiagramOptions;
67
+
62
68
  @multiInject(TYPES.IEditModeListener)
63
69
  @optional()
64
70
  protected editModeListeners: IEditModeListener[] = [];
65
71
 
66
- @inject(TYPES.ModelSourceProvider)
67
- protected modelSourceProvider: () => Promise<ModelSource>;
72
+ @inject(GLSPActionDispatcher)
73
+ protected actionDispatcher: GLSPActionDispatcher;
68
74
 
69
75
  protected _editMode: string;
70
-
71
76
  protected onEditModeChangedEmitter = new Emitter<ValueChange<string>>();
72
77
  get onEditModeChanged(): Event<ValueChange<string>> {
73
78
  return this.onEditModeChangedEmitter.event;
74
79
  }
75
80
 
81
+ protected _isDirty: boolean;
82
+ protected onDirtyStateChangedEmitter = new Emitter<DirtyStateChange>();
83
+ get onDirtyStateChanged(): Event<DirtyStateChange> {
84
+ return this.onDirtyStateChangedEmitter.event;
85
+ }
86
+
76
87
  protected toDispose = new DisposableCollection();
77
88
 
78
89
  @postConstruct()
79
90
  protected initialize(): void {
80
- this.toDispose.push(this.onEditModeChangedEmitter);
91
+ this._editMode = this.diagramOptions.editMode ?? EditMode.EDITABLE;
92
+ this.toDispose.push(this.onEditModeChangedEmitter, this.onDirtyStateChangedEmitter);
81
93
  this.editModeListeners.forEach(listener =>
82
94
  this.onEditModeChanged(change => listener.editModeChanged(change.newValue, change.oldValue))
83
95
  );
@@ -106,28 +118,41 @@ export class EditorContextService implements IActionHandler, Disposable {
106
118
 
107
119
  handle(action: Action): void {
108
120
  if (SetEditModeAction.is(action)) {
109
- const oldValue = this._editMode;
110
- this._editMode = action.editMode;
111
- this.notifyEditModeListeners(oldValue);
121
+ this.handleSetEditModeAction(action);
122
+ } else if (SetDirtyStateAction.is(action)) {
123
+ this.handleSetDirtyStateAction(action);
112
124
  }
113
125
  }
114
126
 
115
- protected notifyEditModeListeners(oldValue: string): void {
127
+ protected handleSetEditModeAction(action: SetEditModeAction): void {
128
+ const oldValue = this._editMode;
129
+ this._editMode = action.editMode;
116
130
  this.onEditModeChangedEmitter.fire({ newValue: this.editMode, oldValue });
117
131
  }
118
132
 
119
- async getSourceUri(): Promise<string | undefined> {
120
- const modelSource = await this.modelSourceProvider();
121
- if (isSourceUriAware(modelSource)) {
122
- return modelSource.sourceURI;
133
+ protected handleSetDirtyStateAction(action: SetDirtyStateAction): void {
134
+ if (action.isDirty !== this._isDirty) {
135
+ this._isDirty = action.isDirty;
136
+ this.onDirtyStateChangedEmitter.fire(action);
123
137
  }
124
- return undefined;
138
+ }
139
+
140
+ get sourceUri(): string | undefined {
141
+ return this.diagramOptions.sourceUri;
125
142
  }
126
143
 
127
144
  get editMode(): string {
128
145
  return this._editMode;
129
146
  }
130
147
 
148
+ get diagramType(): string {
149
+ return this.diagramOptions.diagramType;
150
+ }
151
+
152
+ get clientId(): string {
153
+ return this.diagramOptions.clientId;
154
+ }
155
+
131
156
  get modelRoot(): Readonly<SModelRoot> {
132
157
  return this.selectionService.getModelRoot();
133
158
  }
@@ -139,6 +164,14 @@ export class EditorContextService implements IActionHandler, Disposable {
139
164
  get isReadonly(): boolean {
140
165
  return this.editMode === EditMode.READONLY;
141
166
  }
167
+
168
+ get isDirty(): boolean {
169
+ return this._isDirty;
170
+ }
171
+
172
+ postRequestModel(): MaybePromise<void> {
173
+ this.actionDispatcher.dispatch(SetEditModeAction.create(this.editMode));
174
+ }
142
175
  }
143
176
 
144
177
  export type EditorContextServiceProvider = () => Promise<EditorContextService>;
@@ -67,14 +67,16 @@ export class FeedbackActionDispatcher implements IFeedbackActionDispatcher {
67
67
  @inject(TYPES.ILogger) protected logger: ILogger;
68
68
 
69
69
  registerFeedback(feedbackEmitter: IFeedbackEmitter, feedbackActions: Action[], cleanupActions?: Action[] | undefined): Disposable {
70
- this.registeredFeedback.set(feedbackEmitter, feedbackActions);
71
- this.dispatchFeedback(feedbackActions, feedbackEmitter);
70
+ if (feedbackActions.length > 0) {
71
+ this.registeredFeedback.set(feedbackEmitter, feedbackActions);
72
+ this.dispatchFeedback(feedbackActions, feedbackEmitter);
73
+ }
72
74
  return Disposable.create(() => this.deregisterFeedback(feedbackEmitter, cleanupActions));
73
75
  }
74
76
 
75
77
  deregisterFeedback(feedbackEmitter: IFeedbackEmitter, cleanupActions?: Action[] | undefined): void {
76
78
  this.registeredFeedback.delete(feedbackEmitter);
77
- if (cleanupActions) {
79
+ if (cleanupActions && cleanupActions.length > 0) {
78
80
  this.dispatchFeedback(cleanupActions, feedbackEmitter);
79
81
  }
80
82
  }
@@ -21,6 +21,8 @@ import { FocusStateChangedAction } from './focus-state-change-action';
21
21
  export class FocusTracker implements IActionHandler {
22
22
  protected inActiveCssClass = 'inactive';
23
23
  protected _hasFocus = true;
24
+ protected _focusElement: HTMLOrSVGElement | null;
25
+ protected _diagramElement: HTMLElement | null;
24
26
 
25
27
  @inject(TYPES.ViewerOptions) protected options: ViewerOptions;
26
28
 
@@ -28,19 +30,28 @@ export class FocusTracker implements IActionHandler {
28
30
  return this._hasFocus;
29
31
  }
30
32
 
33
+ get focusElement(): HTMLOrSVGElement | null {
34
+ return this._focusElement;
35
+ }
36
+
37
+ get diagramElement(): HTMLElement | null {
38
+ return this._diagramElement;
39
+ }
40
+
31
41
  handle(action: Action): void | Action | ICommand {
32
42
  if (FocusStateChangedAction.is(action)) {
33
43
  this._hasFocus = action.hasFocus;
34
- const placeholder = document.getElementById(this.options.baseDiv);
35
- if (!placeholder) {
44
+ this._focusElement = document.activeElement as HTMLOrSVGElement | null;
45
+ this._diagramElement = document.getElementById(this.options.baseDiv);
46
+ if (!this._diagramElement) {
36
47
  return;
37
48
  }
38
49
  if (this.hasFocus) {
39
- if (placeholder.classList.contains(this.inActiveCssClass)) {
40
- placeholder.classList.remove(this.inActiveCssClass);
50
+ if (this._diagramElement.classList.contains(this.inActiveCssClass)) {
51
+ this._diagramElement.classList.remove(this.inActiveCssClass);
41
52
  }
42
53
  } else {
43
- placeholder.classList.add(this.inActiveCssClass);
54
+ this._diagramElement.classList.add(this.inActiveCssClass);
44
55
  }
45
56
  }
46
57
  }
@@ -0,0 +1,215 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2023 EclipseSource and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { inject, injectable, multiInject, optional, postConstruct } from 'inversify';
18
+ import {
19
+ AnyObject,
20
+ ApplicationIdProvider,
21
+ Args,
22
+ EMPTY_ROOT,
23
+ GLSPClient,
24
+ InitializeParameters,
25
+ MaybePromise,
26
+ RequestModelAction,
27
+ SetModelAction,
28
+ StatusAction,
29
+ TYPES,
30
+ hasNumberProp
31
+ } from '~glsp-sprotty';
32
+ import { GLSPActionDispatcher } from '../action-dispatcher';
33
+ import { Ranked } from '../ranked';
34
+ import { GLSPModelSource } from './glsp-model-source';
35
+ import { ModelInitializationConstraint } from './model-initialization-constraint';
36
+
37
+ /**
38
+ * Configuration options for a specific GLSP diagram instance.
39
+ */
40
+ export interface IDiagramOptions {
41
+ /**
42
+ * Unique id associated with this diagram. Used on the server side to identify the
43
+ * corresponding client session.
44
+ */
45
+ clientId: string;
46
+ /**
47
+ * The diagram type i.e. diagram language this diagram is associated with.
48
+ */
49
+ diagramType: string;
50
+ /**
51
+ * The provider function to retrieve the GLSP client used by this diagram to communicate with the server.
52
+ * Multiple invocations of the provder function should always return the same `GLSPClient` instance.
53
+ */
54
+ glspClientProvider: () => Promise<GLSPClient>;
55
+ /**
56
+ * The file source URI associated with this diagram.
57
+ */
58
+ sourceUri?: string;
59
+ /**
60
+ * The initial edit mode of diagram. Defaults to `editable`.
61
+ */
62
+ editMode?: string;
63
+ }
64
+
65
+ /**
66
+ * Services that implement startup hooks which are invoked during the {@link DiagramLoader.load} process.
67
+ * Typically used to dispatch additional initial actions and/or activate UI extensions on startup.
68
+ * Execution order is derived by the `rank` property of the service. If not present, the {@link Ranked.DEFAULT_RANK} will be assumed.
69
+ */
70
+ export interface IDiagramStartup extends Partial<Ranked> {
71
+ /**
72
+ * Hook for services that should be executed before the underlying GLSP client is configured and the server is initialized.
73
+ */
74
+ preInitialize?(): MaybePromise<void>;
75
+ /**
76
+ * Hook for services that should be executed before the initial model loading request (i.e. `RequestModelAction`) but
77
+ * after the underlying GLSP client has been configured and the server is initialized.
78
+ */
79
+ preRequestModel?(): MaybePromise<void>;
80
+ /**
81
+ * Hook for services that should be executed after the initial model loading request (i.e. `RequestModelAction`).
82
+ * Note that this hook is invoked directly after the `RequestModelAction` has been dispatched. It does not necessarily wait
83
+ * until the client-server update roundtrip is completed. If you need to wait until the diagram is fully initialized use the
84
+ * {@link postModelInitialization} hook.
85
+ */
86
+ postRequestModel?(): MaybePromise<void>;
87
+ /* Hook for services that should be executed after the diagram model is fully initialized
88
+ * (i.e. `ModelInitializationConstraint` is completed).
89
+ */
90
+ postModelInitialization?(): MaybePromise<void>;
91
+ }
92
+
93
+ export namespace IDiagramStartup {
94
+ export function is(object: unknown): object is IDiagramStartup {
95
+ return (
96
+ AnyObject.is(object) &&
97
+ hasNumberProp(object, 'rank', true) &&
98
+ ('preInitialize' in object ||
99
+ 'preRequestModel' in object ||
100
+ 'postRequestModel' in object ||
101
+ 'postModelInitialization' in object)
102
+ );
103
+ }
104
+ }
105
+
106
+ export interface DiagramLoadingOptions {
107
+ /**
108
+ * Optional custom options that should be used the initial {@link RequestModelAction}.
109
+ * These options will be merged with the default options (`diagramType` and `sourceUri`).
110
+ * Defaults to an empty object if not defined.
111
+ */
112
+ requestModelOptions?: Args;
113
+
114
+ /**
115
+ * Optional partial {@link InitializeParameters} that should be used for `initializeServer` request if the underlying
116
+ * {@link GLSPClient} has not been initialized yet.
117
+ */
118
+ initializeParameters?: Partial<InitializeParameters>;
119
+
120
+ /**
121
+ * Flag to enable/disable client side notifications during the loading process.
122
+ * Defaults to `true` if not defined
123
+ */
124
+ enableNotifications?: boolean;
125
+ }
126
+
127
+ export interface ResolvedDiagramLoadingOptions {
128
+ requestModelOptions: Args;
129
+ initializeParameters: InitializeParameters;
130
+ enableNotifications: boolean;
131
+ }
132
+
133
+ /**
134
+ * The central component responsible for initializing the diagram and loading the graphical model
135
+ * from the GLSP server.
136
+ * Invoking the {@link DiagramLoader.load} method is typically the first operation that is executed after
137
+ * a diagram DI container has been created.
138
+ */
139
+ @injectable()
140
+ export class DiagramLoader {
141
+ @inject(TYPES.IDiagramOptions)
142
+ protected options: IDiagramOptions;
143
+
144
+ @inject(GLSPActionDispatcher)
145
+ protected actionDispatcher: GLSPActionDispatcher;
146
+
147
+ @multiInject(TYPES.IDiagramStartup)
148
+ @optional()
149
+ protected diagramStartups: IDiagramStartup[] = [];
150
+
151
+ @inject(GLSPModelSource)
152
+ protected modelSource: GLSPModelSource;
153
+
154
+ @inject(ModelInitializationConstraint)
155
+ protected modelInitializationConstraint: ModelInitializationConstraint;
156
+
157
+ @postConstruct()
158
+ protected postConstruct(): void {
159
+ this.diagramStartups.sort((a, b) => Ranked.getRank(a) - Ranked.getRank(b));
160
+ }
161
+
162
+ async load(options: DiagramLoadingOptions = {}): Promise<void> {
163
+ const resolvedOptions: ResolvedDiagramLoadingOptions = {
164
+ requestModelOptions: {
165
+ sourceUri: this.options.sourceUri ?? '',
166
+ diagramType: this.options.diagramType,
167
+ ...options.requestModelOptions
168
+ },
169
+ initializeParameters: {
170
+ applicationId: ApplicationIdProvider.get(),
171
+ protocolVersion: GLSPClient.protocolVersion,
172
+ ...options.initializeParameters
173
+ },
174
+ enableNotifications: options.enableNotifications ?? true
175
+ };
176
+ // Set empty place holder model until actual model from server is available
177
+ await this.actionDispatcher.dispatch(SetModelAction.create(EMPTY_ROOT));
178
+ await this.invokeStartupHook('preInitialize');
179
+ await this.initialize(resolvedOptions);
180
+ await this.invokeStartupHook('preRequestModel');
181
+ await this.requestModel(resolvedOptions);
182
+ await this.invokeStartupHook('postRequestModel');
183
+ this.modelInitializationConstraint.onInitialized(() => this.invokeStartupHook('postModelInitialization'));
184
+ }
185
+
186
+ protected async invokeStartupHook(hook: keyof Omit<IDiagramStartup, 'rank'>): Promise<void> {
187
+ for (const startup of this.diagramStartups) {
188
+ await startup[hook]?.();
189
+ }
190
+ }
191
+
192
+ protected async requestModel(options: ResolvedDiagramLoadingOptions): Promise<void> {
193
+ const response = await this.actionDispatcher.request<SetModelAction>(
194
+ RequestModelAction.create({ options: options.requestModelOptions })
195
+ );
196
+ return this.actionDispatcher.dispatch(response);
197
+ }
198
+
199
+ protected async initialize(options: ResolvedDiagramLoadingOptions): Promise<void> {
200
+ if (options.enableNotifications) {
201
+ await this.actionDispatcher.dispatch(StatusAction.create('Initializing...', { severity: 'INFO' }));
202
+ }
203
+
204
+ const glspClient = await this.options.glspClientProvider();
205
+ await glspClient.start();
206
+ if (!glspClient.initializeResult) {
207
+ await glspClient.initializeServer(options.initializeParameters);
208
+ }
209
+ this.modelSource.configure(glspClient);
210
+
211
+ if (options.enableNotifications) {
212
+ this.actionDispatcher.dispatch(StatusAction.create('', { severity: 'NONE' }));
213
+ }
214
+ }
215
+ }