@eclipse-glsp/server 1.1.0-next.f692ea4.55 → 2.1.0-next.70

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 (279) hide show
  1. package/lib/browser/launch/worker-server-launcher.js +2 -2
  2. package/lib/browser/launch/worker-server-launcher.js.map +1 -1
  3. package/lib/common/actions/action-dispatcher.d.ts +2 -1
  4. package/lib/common/actions/action-dispatcher.d.ts.map +1 -1
  5. package/lib/common/actions/action-dispatcher.js +9 -7
  6. package/lib/common/actions/action-dispatcher.js.map +1 -1
  7. package/lib/common/actions/action-handler-registry.js +4 -4
  8. package/lib/common/actions/action-handler-registry.js.map +1 -1
  9. package/lib/common/actions/client-action-handler.d.ts +17 -8
  10. package/lib/common/actions/client-action-handler.d.ts.map +1 -1
  11. package/lib/common/actions/client-action-handler.js +32 -22
  12. package/lib/common/actions/client-action-handler.js.map +1 -1
  13. package/lib/common/actions/global-action-provider.d.ts +6 -21
  14. package/lib/common/actions/global-action-provider.d.ts.map +1 -1
  15. package/lib/common/actions/global-action-provider.js +17 -22
  16. package/lib/common/actions/global-action-provider.js.map +1 -1
  17. package/lib/common/command/command-stack.js +2 -2
  18. package/lib/common/command/command-stack.js.map +1 -1
  19. package/lib/common/command/command.js +1 -1
  20. package/lib/common/command/command.js.map +1 -1
  21. package/lib/common/command/recording-command.d.ts +9 -15
  22. package/lib/common/command/recording-command.d.ts.map +1 -1
  23. package/lib/common/command/recording-command.js +12 -26
  24. package/lib/common/command/recording-command.js.map +1 -1
  25. package/lib/common/command/undo-redo-action-handler.js +2 -2
  26. package/lib/common/command/undo-redo-action-handler.js.map +1 -1
  27. package/lib/common/di/binding-target.d.ts.map +1 -1
  28. package/lib/common/di/binding-target.js +3 -2
  29. package/lib/common/di/binding-target.js.map +1 -1
  30. package/lib/common/di/client-session-module.d.ts +9 -1
  31. package/lib/common/di/client-session-module.d.ts.map +1 -1
  32. package/lib/common/di/client-session-module.js +9 -9
  33. package/lib/common/di/client-session-module.js.map +1 -1
  34. package/lib/common/di/diagram-module.d.ts +23 -1
  35. package/lib/common/di/diagram-module.d.ts.map +1 -1
  36. package/lib/common/di/diagram-module.js +23 -53
  37. package/lib/common/di/diagram-module.js.map +1 -1
  38. package/lib/common/di/glsp-module.js +2 -2
  39. package/lib/common/di/glsp-module.js.map +1 -1
  40. package/lib/common/di/server-module.d.ts +0 -1
  41. package/lib/common/di/server-module.d.ts.map +1 -1
  42. package/lib/common/di/server-module.js +0 -1
  43. package/lib/common/di/server-module.js.map +1 -1
  44. package/lib/common/diagram/diagram-configuration.js +1 -1
  45. package/lib/common/diagram/diagram-configuration.js.map +1 -1
  46. package/lib/common/features/clipboard/request-clipboard-data-action-handler.d.ts.map +1 -1
  47. package/lib/common/features/clipboard/request-clipboard-data-action-handler.js +2 -2
  48. package/lib/common/features/clipboard/request-clipboard-data-action-handler.js.map +1 -1
  49. package/lib/common/features/contextactions/command-palette-action-provider.js +2 -2
  50. package/lib/common/features/contextactions/command-palette-action-provider.js.map +1 -1
  51. package/lib/common/features/contextactions/context-actions-provider-registry.js +2 -2
  52. package/lib/common/features/contextactions/context-actions-provider-registry.js.map +1 -1
  53. package/lib/common/features/contextactions/context-menu-item-provider.js +2 -2
  54. package/lib/common/features/contextactions/context-menu-item-provider.js.map +1 -1
  55. package/lib/common/features/contextactions/request-context-actions-handler.js +2 -2
  56. package/lib/common/features/contextactions/request-context-actions-handler.js.map +1 -1
  57. package/lib/common/features/contextactions/tool-palette-item-provider.js +4 -4
  58. package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -1
  59. package/lib/common/features/directediting/context-edit-validator-registry.js +2 -2
  60. package/lib/common/features/directediting/context-edit-validator-registry.js.map +1 -1
  61. package/lib/common/features/directediting/label-edit-validator.js +2 -2
  62. package/lib/common/features/directediting/label-edit-validator.js.map +1 -1
  63. package/lib/common/features/directediting/request-edit-validation-handler.js +2 -2
  64. package/lib/common/features/directediting/request-edit-validation-handler.js.map +1 -1
  65. package/lib/common/features/layout/computed-bounds-action-handler.js +2 -2
  66. package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
  67. package/lib/common/features/layout/layout-operation-handler.js +2 -2
  68. package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
  69. package/lib/common/features/model/gmodel-factory.js +2 -2
  70. package/lib/common/features/model/gmodel-factory.js.map +1 -1
  71. package/lib/common/features/model/gmodel-index.js +2 -2
  72. package/lib/common/features/model/gmodel-index.js.map +1 -1
  73. package/lib/common/features/model/gmodel-serializer.d.ts +10 -10
  74. package/lib/common/features/model/gmodel-serializer.d.ts.map +1 -1
  75. package/lib/common/features/model/gmodel-serializer.js +2 -2
  76. package/lib/common/features/model/gmodel-serializer.js.map +1 -1
  77. package/lib/common/features/model/model-state.d.ts.map +1 -1
  78. package/lib/common/features/model/model-state.js +5 -2
  79. package/lib/common/features/model/model-state.js.map +1 -1
  80. package/lib/common/features/model/model-submission-handler.d.ts +30 -3
  81. package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
  82. package/lib/common/features/model/model-submission-handler.js +73 -9
  83. package/lib/common/features/model/model-submission-handler.js.map +1 -1
  84. package/lib/common/features/model/request-model-action-handler.d.ts +5 -6
  85. package/lib/common/features/model/request-model-action-handler.d.ts.map +1 -1
  86. package/lib/common/features/model/request-model-action-handler.js +37 -15
  87. package/lib/common/features/model/request-model-action-handler.js.map +1 -1
  88. package/lib/common/features/model/save-model-action-handler.js +2 -2
  89. package/lib/common/features/model/save-model-action-handler.js.map +1 -1
  90. package/lib/common/features/navigation/navigation-target-provider-registry.js +2 -2
  91. package/lib/common/features/navigation/navigation-target-provider-registry.js.map +1 -1
  92. package/lib/common/features/navigation/navigation-target-resolver.js +2 -2
  93. package/lib/common/features/navigation/navigation-target-resolver.js.map +1 -1
  94. package/lib/common/features/navigation/request-navigation-targets-action-handler.js +2 -2
  95. package/lib/common/features/navigation/request-navigation-targets-action-handler.js.map +1 -1
  96. package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js +2 -2
  97. package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js.map +1 -1
  98. package/lib/common/features/popup/request-popup-model-action-handler.js +2 -2
  99. package/lib/common/features/popup/request-popup-model-action-handler.js.map +1 -1
  100. package/lib/common/features/progress/progress-service.d.ts +44 -0
  101. package/lib/common/features/progress/progress-service.d.ts.map +1 -0
  102. package/lib/common/features/progress/progress-service.js +51 -0
  103. package/lib/common/features/progress/progress-service.js.map +1 -0
  104. package/lib/common/features/type-hints/edge-creation-checker.d.ts +42 -0
  105. package/lib/common/features/type-hints/edge-creation-checker.d.ts.map +1 -0
  106. package/lib/common/features/type-hints/edge-creation-checker.js +20 -0
  107. package/lib/common/features/type-hints/edge-creation-checker.js.map +1 -0
  108. package/lib/common/features/type-hints/request-check-edge-action-handler.d.ts +29 -0
  109. package/lib/common/features/type-hints/request-check-edge-action-handler.d.ts.map +1 -0
  110. package/lib/common/features/type-hints/request-check-edge-action-handler.js +72 -0
  111. package/lib/common/features/type-hints/request-check-edge-action-handler.js.map +1 -0
  112. package/lib/common/{diagram → features/type-hints}/request-type-hints-action-handler.d.ts +2 -3
  113. package/lib/common/features/type-hints/request-type-hints-action-handler.d.ts.map +1 -0
  114. package/lib/common/{diagram → features/type-hints}/request-type-hints-action-handler.js +3 -4
  115. package/lib/common/features/type-hints/request-type-hints-action-handler.js.map +1 -0
  116. package/lib/common/features/validation/model-validator.d.ts +47 -2
  117. package/lib/common/features/validation/model-validator.d.ts.map +1 -1
  118. package/lib/common/features/validation/model-validator.js +80 -1
  119. package/lib/common/features/validation/model-validator.js.map +1 -1
  120. package/lib/common/features/validation/request-markers-handler.d.ts +15 -0
  121. package/lib/common/features/validation/request-markers-handler.d.ts.map +1 -1
  122. package/lib/common/features/validation/request-markers-handler.js +5 -11
  123. package/lib/common/features/validation/request-markers-handler.js.map +1 -1
  124. package/lib/common/gmodel/apply-label-edit-operation-handler.js +2 -2
  125. package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -1
  126. package/lib/common/gmodel/change-bounds-operation-handler.js +2 -2
  127. package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -1
  128. package/lib/common/gmodel/change-routing-points-operation-handler.js +2 -2
  129. package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
  130. package/lib/common/gmodel/cut-operation-handler.d.ts.map +1 -1
  131. package/lib/common/gmodel/cut-operation-handler.js +7 -5
  132. package/lib/common/gmodel/cut-operation-handler.js.map +1 -1
  133. package/lib/common/gmodel/delete-operation-handler.d.ts +1 -1
  134. package/lib/common/gmodel/delete-operation-handler.d.ts.map +1 -1
  135. package/lib/common/gmodel/delete-operation-handler.js +7 -7
  136. package/lib/common/gmodel/delete-operation-handler.js.map +1 -1
  137. package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +3 -3
  138. package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts.map +1 -1
  139. package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +2 -2
  140. package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -1
  141. package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts +3 -3
  142. package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts.map +1 -1
  143. package/lib/common/gmodel/gmodel-create-node-operation-handler.js +2 -2
  144. package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
  145. package/lib/common/gmodel/gmodel-diagram-module.js +2 -2
  146. package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -1
  147. package/lib/common/gmodel/gmodel-operation-handler.js +1 -1
  148. package/lib/common/gmodel/gmodel-operation-handler.js.map +1 -1
  149. package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
  150. package/lib/common/gmodel/paste-operation-handler.js +2 -2
  151. package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
  152. package/lib/common/gmodel/reconnect-edge-operation-handler.js +2 -2
  153. package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -1
  154. package/lib/common/index.d.ts +3 -1
  155. package/lib/common/index.d.ts.map +1 -1
  156. package/lib/common/index.js +3 -1
  157. package/lib/common/index.js.map +1 -1
  158. package/lib/common/launch/glsp-server-launcher.js +2 -2
  159. package/lib/common/launch/glsp-server-launcher.js.map +1 -1
  160. package/lib/common/launch/jsonrpc-server-launcher.js +2 -2
  161. package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -1
  162. package/lib/common/operations/compound-operation-handler.d.ts +5 -0
  163. package/lib/common/operations/compound-operation-handler.d.ts.map +1 -1
  164. package/lib/common/operations/compound-operation-handler.js +12 -12
  165. package/lib/common/operations/compound-operation-handler.js.map +1 -1
  166. package/lib/common/operations/create-operation-handler.d.ts +19 -5
  167. package/lib/common/operations/create-operation-handler.d.ts.map +1 -1
  168. package/lib/common/operations/create-operation-handler.js +3 -2
  169. package/lib/common/operations/create-operation-handler.js.map +1 -1
  170. package/lib/common/operations/json-operation-handler.d.ts +94 -0
  171. package/lib/common/operations/json-operation-handler.d.ts.map +1 -0
  172. package/lib/common/operations/json-operation-handler.js +120 -0
  173. package/lib/common/operations/json-operation-handler.js.map +1 -0
  174. package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
  175. package/lib/common/operations/operation-action-handler.js +3 -3
  176. package/lib/common/operations/operation-action-handler.js.map +1 -1
  177. package/lib/common/operations/operation-handler-registry.d.ts +1 -9
  178. package/lib/common/operations/operation-handler-registry.d.ts.map +1 -1
  179. package/lib/common/operations/operation-handler-registry.js +4 -14
  180. package/lib/common/operations/operation-handler-registry.js.map +1 -1
  181. package/lib/common/operations/operation-handler.d.ts +2 -2
  182. package/lib/common/operations/operation-handler.d.ts.map +1 -1
  183. package/lib/common/operations/operation-handler.js +2 -2
  184. package/lib/common/operations/operation-handler.js.map +1 -1
  185. package/lib/common/protocol/client-action.d.ts +31 -0
  186. package/lib/common/protocol/client-action.d.ts.map +1 -0
  187. package/lib/common/protocol/client-action.js +35 -0
  188. package/lib/common/protocol/client-action.js.map +1 -0
  189. package/lib/common/protocol/glsp-server.d.ts +1 -1
  190. package/lib/common/protocol/glsp-server.d.ts.map +1 -1
  191. package/lib/common/protocol/glsp-server.js +9 -11
  192. package/lib/common/protocol/glsp-server.js.map +1 -1
  193. package/lib/common/session/client-session-factory.js +5 -5
  194. package/lib/common/session/client-session-factory.js.map +1 -1
  195. package/lib/common/session/client-session-manager.js +2 -2
  196. package/lib/common/session/client-session-manager.js.map +1 -1
  197. package/lib/common/utils/args-util.js +2 -2
  198. package/lib/common/utils/args-util.js.map +1 -1
  199. package/lib/common/utils/client-options-util.d.ts +3 -0
  200. package/lib/common/utils/client-options-util.d.ts.map +1 -1
  201. package/lib/common/utils/client-options-util.js +5 -15
  202. package/lib/common/utils/client-options-util.js.map +1 -1
  203. package/lib/common/utils/console-logger.js +2 -2
  204. package/lib/common/utils/console-logger.js.map +1 -1
  205. package/lib/common/utils/logger.d.ts.map +1 -1
  206. package/lib/common/utils/logger.js +5 -4
  207. package/lib/common/utils/logger.js.map +1 -1
  208. package/lib/common/utils/promise-queue.d.ts.map +1 -1
  209. package/lib/common/utils/promise-queue.js +3 -6
  210. package/lib/common/utils/promise-queue.js.map +1 -1
  211. package/lib/common/utils/registry.d.ts +3 -1
  212. package/lib/common/utils/registry.d.ts.map +1 -1
  213. package/lib/common/utils/registry.js +15 -6
  214. package/lib/common/utils/registry.js.map +1 -1
  215. package/lib/node/abstract-json-model-storage.d.ts.map +1 -1
  216. package/lib/node/abstract-json-model-storage.js +10 -4
  217. package/lib/node/abstract-json-model-storage.js.map +1 -1
  218. package/lib/node/gmodel/gmodel-storage.d.ts.map +1 -1
  219. package/lib/node/gmodel/gmodel-storage.js +4 -3
  220. package/lib/node/gmodel/gmodel-storage.js.map +1 -1
  221. package/lib/node/launch/cli-parser.js +1 -1
  222. package/lib/node/launch/cli-parser.js.map +1 -1
  223. package/lib/node/launch/socket-server-launcher.js +2 -2
  224. package/lib/node/launch/socket-server-launcher.js.map +1 -1
  225. package/lib/node/launch/websocket-server-launcher.js +2 -2
  226. package/lib/node/launch/websocket-server-launcher.js.map +1 -1
  227. package/package.json +7 -6
  228. package/src/common/actions/action-dispatcher.spec.ts +3 -2
  229. package/src/common/actions/action-dispatcher.ts +8 -5
  230. package/src/common/actions/client-action-handler.ts +28 -18
  231. package/src/common/actions/global-action-provider.spec.ts +4 -15
  232. package/src/common/actions/global-action-provider.ts +21 -25
  233. package/src/common/command/recording-command.spec.ts +15 -5
  234. package/src/common/command/recording-command.ts +16 -27
  235. package/src/common/di/binding-target.ts +1 -0
  236. package/src/common/di/client-session-module.ts +17 -10
  237. package/src/common/di/diagram-module.ts +31 -70
  238. package/src/common/di/server-module.ts +0 -1
  239. package/src/common/features/clipboard/request-clipboard-data-action-handler.ts +3 -3
  240. package/src/common/features/model/gmodel-serializer.ts +11 -11
  241. package/src/common/features/model/model-state.ts +3 -0
  242. package/src/common/features/model/model-submission-handler.ts +64 -7
  243. package/src/common/features/model/request-model-action-handler.ts +37 -17
  244. package/src/common/features/progress/progress-service.ts +74 -0
  245. package/src/common/features/type-hints/edge-creation-checker.ts +44 -0
  246. package/src/common/features/type-hints/request-check-edge-action-handler.ts +62 -0
  247. package/src/common/{diagram → features/type-hints}/request-type-hints-action-handler.spec.ts +2 -2
  248. package/src/common/{diagram → features/type-hints}/request-type-hints-action-handler.ts +2 -3
  249. package/src/common/features/validation/model-validator.ts +75 -3
  250. package/src/common/features/validation/request-markers-handler.ts +4 -10
  251. package/src/common/gmodel/cut-operation-handler.ts +5 -3
  252. package/src/common/gmodel/delete-operation-handler.ts +6 -5
  253. package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +3 -3
  254. package/src/common/gmodel/gmodel-create-node-operation-handler.ts +3 -3
  255. package/src/common/gmodel/paste-operation-handler.ts +2 -2
  256. package/src/common/index.ts +3 -1
  257. package/src/common/operations/compound-operation-handler.ts +6 -1
  258. package/src/common/operations/create-operation-handler.ts +22 -5
  259. package/src/common/operations/json-operation-handler.ts +147 -0
  260. package/src/common/operations/operation-action-handler.ts +2 -2
  261. package/src/common/operations/operation-handler-registry.ts +1 -12
  262. package/src/common/operations/operation-handler.ts +2 -2
  263. package/src/common/protocol/client-action.ts +38 -0
  264. package/src/common/protocol/glsp-server.spec.ts +11 -10
  265. package/src/common/protocol/glsp-server.ts +11 -14
  266. package/src/common/session/client-session-factory.spec.ts +2 -2
  267. package/src/common/session/client-session-factory.ts +3 -3
  268. package/src/common/session/client-session-manager.spec.ts +4 -3
  269. package/src/common/utils/args-util.ts +1 -1
  270. package/src/common/utils/client-options-util.ts +8 -0
  271. package/src/common/utils/logger.ts +2 -1
  272. package/src/common/utils/promise-queue.ts +4 -5
  273. package/src/common/utils/registry.spec.ts +3 -1
  274. package/src/common/utils/registry.ts +8 -3
  275. package/src/node/abstract-json-model-storage.ts +8 -2
  276. package/src/node/gmodel/gmodel-storage.ts +3 -3
  277. package/src/node/launch/cli-parser.ts +1 -1
  278. package/lib/common/diagram/request-type-hints-action-handler.d.ts.map +0 -1
  279. package/lib/common/diagram/request-type-hints-action-handler.js.map +0 -1
@@ -13,9 +13,8 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { Args, CreateOperation, MaybePromise, Operation } from '@eclipse-glsp/protocol';
16
+ import { Args, CreateOperation, Operation } from '@eclipse-glsp/protocol';
17
17
  import { inject, injectable, optional } from 'inversify';
18
- import { Command } from '../command/command';
19
18
  import { ClientSessionInitializer } from '../session/client-session-initializer';
20
19
  import { Registry } from '../utils/registry';
21
20
  import { CreateOperationHandler } from './create-operation-handler';
@@ -35,16 +34,6 @@ export class OperationHandlerRegistry extends Registry<string, OperationHandler>
35
34
  getOperationHandler(operation: Operation): OperationHandler | undefined {
36
35
  return CreateOperation.is(operation) ? this.get(`${operation.kind}_${operation.elementTypeId}`) : this.get(operation.kind);
37
36
  }
38
-
39
- /**
40
- * Returns the matching command for the given operation.
41
- *
42
- * @param operation operation
43
- * @return the matching command for the given operation
44
- */
45
- getExecutableCommand(operation: Operation): MaybePromise<Command | undefined> {
46
- return this.getOperationHandler(operation)?.createCommand(operation);
47
- }
48
37
  }
49
38
 
50
39
  @injectable()
@@ -37,7 +37,7 @@ export abstract class OperationHandler {
37
37
  *
38
38
  * @returns the operation type that can be handled.
39
39
  */
40
- abstract operationType: string;
40
+ abstract readonly operationType: string;
41
41
 
42
42
  readonly label?: string;
43
43
 
@@ -46,7 +46,7 @@ export abstract class OperationHandler {
46
46
  * is performed on the model(s).
47
47
  *
48
48
  * @param operation The operation to process.
49
- * @return The created command to be executed on the command stack or `undefined` nothing should be done.
49
+ * @return The created command to be executed on the command stack or `undefined` if nothing should be done.
50
50
  */
51
51
  abstract createCommand(operation: Operation): MaybePromise<Command | undefined>;
52
52
 
@@ -0,0 +1,38 @@
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 { Action } from '@eclipse-glsp/protocol';
18
+
19
+ /**
20
+ * A helper interface that allows the server to mark actions that have been received from the client.
21
+ */
22
+ export interface ClientAction extends Action {
23
+ __receivedFromClient: true;
24
+ }
25
+
26
+ export namespace ClientAction {
27
+ export function is(object: unknown): object is ClientAction {
28
+ return Action.is(object) && '__receivedFromClient' in object && object.__receivedFromClient === true;
29
+ }
30
+
31
+ /**
32
+ * Mark the given action as {@link ClientAction} by attaching the "__receivedFromClient" property
33
+ * @param action The action that should be marked as client action
34
+ */
35
+ export function mark(action: Action): void {
36
+ (action as ClientAction).__receivedFromClient = true;
37
+ }
38
+ }
@@ -20,6 +20,7 @@ import {
20
20
  InitializeClientSessionParameters,
21
21
  InitializeParameters
22
22
  } from '@eclipse-glsp/protocol';
23
+ import * as assert from 'assert';
23
24
  import { expect } from 'chai';
24
25
  import { Container, ContainerModule } from 'inversify';
25
26
  import * as sinon from 'sinon';
@@ -28,7 +29,6 @@ import { ClientSessionManager } from '../session/client-session-manager';
28
29
  import * as mock from '../test/mock-util';
29
30
  import { Logger } from '../utils/logger';
30
31
  import { DefaultGLSPServer } from './glsp-server';
31
- import assert = require('assert');
32
32
 
33
33
  describe('test DefaultGLSPServer', () => {
34
34
  const container = new Container();
@@ -36,8 +36,8 @@ describe('test DefaultGLSPServer', () => {
36
36
  const diagramType = 'myDiagram';
37
37
  const applicationId = 'Test';
38
38
  const protocolVersion = '1.0.0';
39
- const serverActionKinds = new Map<string, string[]>();
40
- serverActionKinds.set(diagramType, ['A1', 'A2']);
39
+ const actionKinds = new Map<string, string[]>();
40
+ actionKinds.set(diagramType, ['A1', 'A2']);
41
41
  const sessionManager = new mock.StubClientSessionManager();
42
42
  const spy_sessionManager_getOrCreate = sinon.spy(sessionManager, 'getOrCreateClientSession');
43
43
  const spy_sessionManager_dispose = sinon.spy(sessionManager, 'disposeClientSession');
@@ -53,7 +53,7 @@ describe('test DefaultGLSPServer', () => {
53
53
  bind(Logger).toConstantValue(new mock.StubLogger());
54
54
  bind(GLSPClientProxy).toConstantValue(new mock.StubGLSPClientProxy());
55
55
  bind(ClientSessionManager).toConstantValue(sessionManager);
56
- bind(GlobalActionProvider).toConstantValue({ clientActionKinds: new Map<string, string[]>(), serverActionKinds });
56
+ bind(GlobalActionProvider).toConstantValue(<GlobalActionProvider>{ actionKinds });
57
57
  bind(GLSPServerListener).toConstantValue(listener1);
58
58
  })
59
59
  );
@@ -70,7 +70,7 @@ describe('test DefaultGLSPServer', () => {
70
70
  });
71
71
 
72
72
  it('Test calls before server initialization (should throw errors)', async () => {
73
- assert.rejects(() => glspServer.initializeClientSession({ clientSessionId: 'id', diagramType: 'type' }));
73
+ assert.rejects(() => glspServer.initializeClientSession({ clientSessionId: 'id', diagramType: 'type', clientActionKinds: [] }));
74
74
  assert.rejects(() => glspServer.disposeClientSession({ clientSessionId: 'id' }));
75
75
  assert.throws(() => glspServer.process({ clientId: 'id', action: { kind: 'action' } }));
76
76
  });
@@ -109,8 +109,8 @@ describe('test DefaultGLSPServer', () => {
109
109
  const initializeParameters: InitializeParameters = { applicationId, protocolVersion };
110
110
  const result = await glspServer.initialize(initializeParameters);
111
111
  expect(result.protocolVersion).to.be.equal(protocolVersion);
112
- expect(result.serverActions[diagramType]).to.be.equal(serverActionKinds.get(diagramType));
113
- expect(result.serverActions[diagramType]).to.be.equal(serverActionKinds.get(diagramType));
112
+ expect(result.serverActions[diagramType]).to.be.equal(actionKinds.get(diagramType));
113
+ expect(result.serverActions[diagramType]).to.be.equal(actionKinds.get(diagramType));
114
114
  expect(spy_listener1_initialize.calledWith(glspServer));
115
115
  expect(spy_listener2_initialize.notCalled);
116
116
  });
@@ -119,8 +119,8 @@ describe('test DefaultGLSPServer', () => {
119
119
  const initializeParameters: InitializeParameters = { applicationId, protocolVersion };
120
120
  const result = await glspServer.initialize(initializeParameters);
121
121
  expect(result.protocolVersion).to.be.equal(protocolVersion);
122
- expect(result.serverActions[diagramType]).to.be.equal(serverActionKinds.get(diagramType));
123
- expect(result.serverActions[diagramType]).to.be.equal(serverActionKinds.get(diagramType));
122
+ expect(result.serverActions[diagramType]).to.be.equal(actionKinds.get(diagramType));
123
+ expect(result.serverActions[diagramType]).to.be.equal(actionKinds.get(diagramType));
124
124
  });
125
125
 
126
126
  it('initialize - subsequent call with other parameters', async () => {
@@ -131,7 +131,8 @@ describe('test DefaultGLSPServer', () => {
131
131
  it('initialize client session', async () => {
132
132
  const initializeClientSessionParameters: InitializeClientSessionParameters = {
133
133
  clientSessionId,
134
- diagramType
134
+ diagramType,
135
+ clientActionKinds: []
135
136
  };
136
137
  await glspServer.initializeClientSession(initializeClientSessionParameters);
137
138
  expect(spy_sessionManager_getOrCreate.calledWith(initializeClientSessionParameters));
@@ -17,7 +17,6 @@ import {
17
17
  ActionMessage,
18
18
  Args,
19
19
  DisposeClientSessionParameters,
20
- distinctAdd,
21
20
  GLSPClientProxy,
22
21
  GLSPServer,
23
22
  GLSPServerListener,
@@ -25,9 +24,10 @@ import {
25
24
  InitializeParameters,
26
25
  InitializeResult,
27
26
  MaybePromise,
28
- remove,
27
+ MessageAction,
29
28
  ServerActions,
30
- ServerMessageAction
29
+ distinctAdd,
30
+ remove
31
31
  } from '@eclipse-glsp/protocol';
32
32
  import { inject, injectable, multiInject, optional } from 'inversify';
33
33
  import { GlobalActionProvider } from '../actions/global-action-provider';
@@ -35,6 +35,7 @@ import { ClientSession } from '../session/client-session';
35
35
  import { ClientSessionManager } from '../session/client-session-manager';
36
36
  import { GLSPServerError } from '../utils/glsp-server-error';
37
37
  import { Logger } from '../utils/logger';
38
+ import { ClientAction } from './client-action';
38
39
 
39
40
  @injectable()
40
41
  export class DefaultGLSPServer implements GLSPServer {
@@ -50,8 +51,7 @@ export class DefaultGLSPServer implements GLSPServer {
50
51
  protected actionProvider: GlobalActionProvider;
51
52
 
52
53
  @inject(GLSPClientProxy)
53
- @optional()
54
- protected glspClientProxy?: GLSPClientProxy;
54
+ protected glspClientProxy: GLSPClientProxy;
55
55
 
56
56
  protected initializeResult?: InitializeResult;
57
57
 
@@ -97,7 +97,7 @@ export class DefaultGLSPServer implements GLSPServer {
97
97
  this.applicationId = params.applicationId;
98
98
  const serverActions: ServerActions = {};
99
99
 
100
- this.actionProvider.serverActionKinds.forEach((kinds, diagramType) => (serverActions[diagramType] = kinds));
100
+ this.actionProvider.actionKinds.forEach((kinds, diagramType) => (serverActions[diagramType] = kinds));
101
101
 
102
102
  let result = { protocolVersion: DefaultGLSPServer.PROTOCOL_VERSION, serverActions };
103
103
 
@@ -149,8 +149,9 @@ export class DefaultGLSPServer implements GLSPServer {
149
149
  if (!clientSession) {
150
150
  throw new Error(`No client session has been initialized for client id: ${clientSessionId}`);
151
151
  }
152
-
153
- clientSession.actionDispatcher.dispatch(message.action).catch(error => this.handleProcessError(message, error));
152
+ const action = message.action;
153
+ ClientAction.mark(action);
154
+ clientSession.actionDispatcher.dispatch(action).catch(error => this.handleProcessError(message, error));
154
155
  }
155
156
 
156
157
  protected handleProcessError(message: ActionMessage, reason: any): void | PromiseLike<void> {
@@ -162,16 +163,12 @@ export class DefaultGLSPServer implements GLSPServer {
162
163
  details = reason.cause?.toString?.();
163
164
  errorMsg = reason.message;
164
165
  }
165
- const errorAction = ServerMessageAction.create(errorMsg, { severity: 'ERROR', details });
166
+ const errorAction = MessageAction.create(errorMsg, { severity: 'ERROR', details });
166
167
  this.sendToClient({ clientId: message.clientId, action: errorAction });
167
168
  }
168
169
 
169
170
  protected sendToClient(message: ActionMessage): void {
170
- if (this.glspClientProxy) {
171
- this.glspClientProxy.process(message);
172
- return;
173
- }
174
- throw new Error("Could not send message to client. No 'GLSPClientProxy' is connected");
171
+ this.glspClientProxy.process(message);
175
172
  }
176
173
 
177
174
  getClientSession(sessionId: string): ClientSession | undefined {
@@ -47,7 +47,7 @@ describe('test DefaultClientSessionFactory', () => {
47
47
  const factory = container.resolve(DefaultClientSessionFactory);
48
48
 
49
49
  it('create - new client session', () => {
50
- const session = factory.create({ clientSessionId, diagramType });
50
+ const session = factory.create({ clientSessionId, diagramType, clientActionKinds: [] });
51
51
  expect(session.id).to.be.equal(clientSessionId);
52
52
  expect(session.diagramType).to.be.equal(diagramType);
53
53
  expect(session.container.parent).to.be.equal(container);
@@ -55,6 +55,6 @@ describe('test DefaultClientSessionFactory', () => {
55
55
  });
56
56
 
57
57
  it('create - unknown diagram type', () => {
58
- expect(() => factory.create({ clientSessionId, diagramType: 'unknown-type' })).to.throw(GLSPServerError);
58
+ expect(() => factory.create({ clientSessionId, diagramType: 'unknown-type', clientActionKinds: [] })).to.throw(GLSPServerError);
59
59
  });
60
60
  });
@@ -52,18 +52,18 @@ export class DefaultClientSessionFactory implements ClientSessionFactory {
52
52
  protected glspClient: GLSPClientProxy;
53
53
 
54
54
  create(params: InitializeClientSessionParameters): ClientSession {
55
- const { clientSessionId: id, diagramType, args } = params;
55
+ const { clientSessionId: clientId, diagramType, clientActionKinds, args } = params;
56
56
  const diagramModules = this.diagramModules.get(diagramType);
57
57
  if (!diagramModules || diagramModules.length === 0) {
58
58
  throw new GLSPServerError(`Could not retrieve diagram module configuration for diagram type: '${diagramType}''`);
59
59
  }
60
60
 
61
- const sessionModule = createClientSessionModule(id, this.glspClient);
61
+ const sessionModule = createClientSessionModule({ clientId, glspClient: this.glspClient, clientActionKinds });
62
62
  const sessionContainer = this.serverContainer.createChild();
63
63
  sessionContainer.load(...diagramModules, sessionModule);
64
64
  const initializers = sessionContainer.getAll<ClientSessionInitializer>(ClientSessionInitializer);
65
65
  initializers.forEach(service => service.initialize(args));
66
66
  const actionDispatcher = sessionContainer.get<ActionDispatcher>(ActionDispatcher);
67
- return new DefaultClientSession(id, diagramType, actionDispatcher, sessionContainer);
67
+ return new DefaultClientSession(clientId, diagramType, actionDispatcher, sessionContainer);
68
68
  }
69
69
  }
@@ -13,13 +13,13 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
+ import { expect } from 'chai';
16
17
  import { Container, ContainerModule } from 'inversify';
18
+ import * as sinon from 'sinon';
17
19
  import * as mock from '../test/mock-util';
18
20
  import { Logger } from '../utils/logger';
19
21
  import { ClientSessionFactory } from './client-session-factory';
20
22
  import { DefaultClientSessionManager } from './client-session-manager';
21
- import { expect } from 'chai';
22
- import * as sinon from 'sinon';
23
23
 
24
24
  describe('test DefaultClientSessionManager', () => {
25
25
  const testSession = mock.createClientSession('myId', 'myDiagram');
@@ -47,7 +47,8 @@ describe('test DefaultClientSessionManager', () => {
47
47
  // Test execution
48
48
  const createdSession = sessionManager.getOrCreateClientSession({
49
49
  clientSessionId: testSession.id,
50
- diagramType: testSession.diagramType
50
+ diagramType: testSession.diagramType,
51
+ clientActionKinds: []
51
52
  });
52
53
  expect(createdSession).to.not.be.undefined;
53
54
  expect(createdSession.id).to.be.equal(testSession.id);
@@ -48,7 +48,7 @@ export namespace ArgsUtil {
48
48
  }
49
49
 
50
50
  return {
51
- [KEY_RADIUS_TOP_RIGHT]: topLeft,
51
+ [KEY_RADIUS_TOP_LEFT]: topLeft,
52
52
  [KEY_RADIUS_BOTTOM_LEFT]: bottomLeft,
53
53
  [KEY_RADIUS_BOTTOM_RIGHT]: bottomRight,
54
54
  [KEY_RADIUS_TOP_RIGHT]: topRight
@@ -13,10 +13,18 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
+ import { Args } from '@eclipse-glsp/protocol';
17
+ import { ArgsUtil } from './args-util';
18
+
16
19
  export class ClientOptionsUtil {
17
20
  private static FILE_PREFIX = 'file://';
21
+ public static IS_RECONNECTING = 'isReconnecting';
18
22
 
19
23
  public static adaptUri(uri: string): string {
20
24
  return uri.replace(this.FILE_PREFIX, '');
21
25
  }
26
+
27
+ public static isReconnecting(options?: Args): boolean {
28
+ return ArgsUtil.getBoolean(options, ClientOptionsUtil.IS_RECONNECTING);
29
+ }
22
30
  }
@@ -80,7 +80,8 @@ export function getRequestParentName(context: interfaces.Context): string | unde
80
80
  if (context.currentRequest.parentRequest) {
81
81
  const bindings = context.currentRequest.parentRequest.bindings;
82
82
  if (bindings.length > 0) {
83
- return bindings[0].implementationType?.name;
83
+ const binding = bindings[0] as interfaces.Binding<{ name?: string }>;
84
+ return binding.implementationType?.name;
84
85
  }
85
86
  }
86
87
  return undefined;
@@ -62,14 +62,13 @@ export class PromiseQueue<T = void> {
62
62
  return false;
63
63
  }
64
64
 
65
- try {
66
- this.busy = true;
67
- this.resolveQueuedPromise(element);
68
- } catch (error) {
65
+ this.busy = true;
66
+ this.resolveQueuedPromise(element).catch(error => {
69
67
  element.reject(error);
70
68
  this.busy = false;
71
69
  this.dequeue();
72
- }
70
+ });
71
+
73
72
  return true;
74
73
  }
75
74
 
@@ -13,14 +13,16 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { MultiRegistry, Registry } from './registry';
17
16
  import { expect } from 'chai';
17
+ import { NullLogger } from './logger';
18
+ import { MultiRegistry, Registry } from './registry';
18
19
 
19
20
  describe('Test Registry', () => {
20
21
  let registry: Registry<string, string>;
21
22
 
22
23
  beforeEach(() => {
23
24
  registry = new Registry();
25
+ registry['logger'] = new NullLogger();
24
26
  });
25
27
 
26
28
  it('register - with new key-value pair', () => {
@@ -14,7 +14,8 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  import { remove } from '@eclipse-glsp/protocol/lib/utils/array-util';
17
- import { injectable } from 'inversify';
17
+ import { inject, injectable } from 'inversify';
18
+ import { Logger } from './logger';
18
19
 
19
20
  /**
20
21
  * A registry manages a set of key-value pairs and provides query functionality. In GLSP this is typically used to
@@ -27,6 +28,9 @@ import { injectable } from 'inversify';
27
28
 
28
29
  @injectable()
29
30
  export class Registry<K, V> {
31
+ @inject(Logger)
32
+ protected logger: Logger;
33
+
30
34
  protected elements: Map<K, V> = new Map();
31
35
  /**
32
36
  * Registers a new key-value pair.
@@ -36,11 +40,12 @@ export class Registry<K, V> {
36
40
  * @returns `true` if the pair was registered successfully, `false` if another pair with the same key is already
37
41
  * registered.
38
42
  */
39
- register(key: K, instance: V): boolean {
43
+ register(key: K, value: V): boolean {
40
44
  if (!this.hasKey(key)) {
41
- this.elements.set(key, instance);
45
+ this.elements.set(key, value);
42
46
  return true;
43
47
  }
48
+ this.logger.warn('Could not register key-value pair. Key is already registered', { key, value });
44
49
  return false;
45
50
  }
46
51
 
@@ -14,8 +14,9 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  import { MaybePromise, RequestModelAction, SaveModelAction, TypeGuard } from '@eclipse-glsp/protocol';
17
- import * as fs from 'fs-extra';
17
+ import * as fs from 'fs';
18
18
  import { inject, injectable } from 'inversify';
19
+ import * as os from 'os';
19
20
  import { fileURLToPath } from 'url';
20
21
  import { ModelState, SOURCE_URI_ARG } from '../common/features/model/model-state';
21
22
  import { SourceModelStorage } from '../common/features/model/source-model-storage';
@@ -91,7 +92,12 @@ export abstract class AbstractJsonModelStorage implements SourceModelStorage {
91
92
  }
92
93
 
93
94
  protected toPath(sourceUri: string): string {
94
- return sourceUri.startsWith('file://') ? fileURLToPath(sourceUri) : sourceUri;
95
+ let path = sourceUri.startsWith('file://') ? fileURLToPath(sourceUri) : sourceUri;
96
+ if (os.platform() === 'win32') {
97
+ // Remove the leading slash if it exists (Windows paths don't have it)
98
+ path = path.replace(/^\//, '');
99
+ }
100
+ return path;
95
101
  }
96
102
 
97
103
  protected getFileUri(action: SaveModelAction): string {
@@ -13,8 +13,8 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { GGraph, GModelElementSchema } from '@eclipse-glsp/graph';
17
- import { MaybePromise, RequestModelAction, SaveModelAction } from '@eclipse-glsp/protocol';
16
+ import { GGraph } from '@eclipse-glsp/graph';
17
+ import { MaybePromise, RequestModelAction, SaveModelAction, isGModelElementSchema } from '@eclipse-glsp/protocol';
18
18
  import { inject, injectable } from 'inversify';
19
19
  import { GModelSerializer } from '../../common/features/model/gmodel-serializer';
20
20
  import { ModelState } from '../../common/features/model/model-state';
@@ -40,7 +40,7 @@ export class GModelStorage extends AbstractJsonModelStorage {
40
40
 
41
41
  loadSourceModel(action: RequestModelAction): MaybePromise<void> {
42
42
  const sourceUri = this.getSourceUri(action);
43
- const rootSchema = this.loadFromFile(sourceUri, GModelElementSchema.is);
43
+ const rootSchema = this.loadFromFile(sourceUri, isGModelElementSchema);
44
44
  const root = this.modelSerializer.createRoot(rootSchema);
45
45
  this.modelState.updateRoot(root);
46
46
  }
@@ -14,7 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  import * as cmd from 'commander';
17
- import * as fs from 'fs-extra';
17
+ import * as fs from 'fs';
18
18
  import * as path from 'path';
19
19
  import { LogLevel, LoggerConfigOptions, asLogLevel } from '../../common/utils/logger';
20
20
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-type-hints-action-handler.d.ts","sourceRoot":"","sources":["../../../src/common/diagram/request-type-hints-action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,sBAAsB,EAAsB,MAAM,wBAAwB,CAAC;AAE1G,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,qBACa,6BAA8B,YAAW,aAAa;IACjC,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IACnF,MAAM,CAAC,KAAK,WAAiC;IAE7C,OAAO,CAAC,MAAM,EAAE,sBAAsB,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;IAS/D,QAAQ,CAAC,WAAW,WAAiC;CACxD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-type-hints-action-handler.js","sourceRoot":"","sources":["../../../src/common/diagram/request-type-hints-action-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAA0G;AAC1G,yCAA+C;AAE/C,mEAA+D;AAGxD,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAAnC;QAaM,gBAAW,GAAG,CAAC,iCAAsB,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IAVG,OAAO,CAAC,MAA8B;QAClC,OAAO;YACH,6BAAkB,CAAC,MAAM,CAAC;gBACtB,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,cAAc;gBACpD,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,aAAa;aACrD,CAAC;SACL,CAAC;IACN,CAAC;;AATM,mCAAK,GAAG,CAAC,iCAAsB,CAAC,IAAI,CAAC,CAAC;AAD7C;IAAC,IAAA,kBAAM,EAAC,4CAAoB,CAAC;;2EAAsD;AAD1E,6BAA6B;IADzC,IAAA,sBAAU,GAAE;GACA,6BAA6B,CAczC;AAdY,sEAA6B"}