@eclipse-glsp/server 1.1.0-next.44bd1e0.43 → 1.1.0-next.d47240f.50

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 (174) hide show
  1. package/lib/browser/di/app-module.d.ts +2 -7
  2. package/lib/browser/di/app-module.d.ts.map +1 -1
  3. package/lib/browser/di/app-module.js +5 -30
  4. package/lib/browser/di/app-module.js.map +1 -1
  5. package/lib/browser/index.d.ts +0 -1
  6. package/lib/browser/index.d.ts.map +1 -1
  7. package/lib/browser/index.js +0 -1
  8. package/lib/browser/index.js.map +1 -1
  9. package/lib/browser/launch/worker-server-launcher.d.ts +11 -8
  10. package/lib/browser/launch/worker-server-launcher.d.ts.map +1 -1
  11. package/lib/browser/launch/worker-server-launcher.js +13 -21
  12. package/lib/browser/launch/worker-server-launcher.js.map +1 -1
  13. package/lib/common/actions/client-action-handler.d.ts +1 -2
  14. package/lib/common/actions/client-action-handler.d.ts.map +1 -1
  15. package/lib/common/actions/client-action-handler.js +17 -2
  16. package/lib/common/actions/client-action-handler.js.map +1 -1
  17. package/lib/common/command/command-stack.d.ts +22 -6
  18. package/lib/common/command/command-stack.d.ts.map +1 -1
  19. package/lib/common/command/command-stack.js +6 -21
  20. package/lib/common/command/command-stack.js.map +1 -1
  21. package/lib/common/command/command-stack.spec.js +31 -31
  22. package/lib/common/command/command-stack.spec.js.map +1 -1
  23. package/lib/common/command/command.d.ts +7 -6
  24. package/lib/common/command/command.d.ts.map +1 -1
  25. package/lib/common/command/command.js +19 -15
  26. package/lib/common/command/command.js.map +1 -1
  27. package/lib/common/command/command.spec.js +8 -8
  28. package/lib/common/command/command.spec.js.map +1 -1
  29. package/lib/common/command/recording-command.d.ts +15 -15
  30. package/lib/common/command/recording-command.d.ts.map +1 -1
  31. package/lib/common/command/recording-command.js +10 -10
  32. package/lib/common/command/recording-command.js.map +1 -1
  33. package/lib/common/command/recording-command.spec.js +8 -8
  34. package/lib/common/command/recording-command.spec.js.map +1 -1
  35. package/lib/common/command/undo-redo-action-handler.d.ts +2 -2
  36. package/lib/common/command/undo-redo-action-handler.d.ts.map +1 -1
  37. package/lib/common/command/undo-redo-action-handler.js +4 -4
  38. package/lib/common/command/undo-redo-action-handler.js.map +1 -1
  39. package/lib/common/di/client-session-module.d.ts +1 -1
  40. package/lib/common/di/client-session-module.d.ts.map +1 -1
  41. package/lib/common/di/client-session-module.js +2 -2
  42. package/lib/common/di/client-session-module.js.map +1 -1
  43. package/lib/common/di/glsp-module.d.ts +3 -1
  44. package/lib/common/di/glsp-module.d.ts.map +1 -1
  45. package/lib/common/di/glsp-module.js +0 -15
  46. package/lib/common/di/glsp-module.js.map +1 -1
  47. package/lib/common/di/multi-binding.d.ts +19 -4
  48. package/lib/common/di/multi-binding.d.ts.map +1 -1
  49. package/lib/common/di/multi-binding.js.map +1 -1
  50. package/lib/common/di/server-module.d.ts +1 -6
  51. package/lib/common/di/server-module.d.ts.map +1 -1
  52. package/lib/common/di/server-module.js +21 -17
  53. package/lib/common/di/server-module.js.map +1 -1
  54. package/lib/common/features/layout/computed-bounds-action-handler.js +1 -1
  55. package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
  56. package/lib/common/index.d.ts +4 -3
  57. package/lib/common/index.d.ts.map +1 -1
  58. package/lib/common/index.js +4 -3
  59. package/lib/common/index.js.map +1 -1
  60. package/lib/common/launch/glsp-server-launcher.d.ts +8 -7
  61. package/lib/common/launch/glsp-server-launcher.d.ts.map +1 -1
  62. package/lib/common/launch/glsp-server-launcher.js +27 -4
  63. package/lib/common/launch/glsp-server-launcher.js.map +1 -1
  64. package/lib/common/launch/jsonrpc-server-launcher.d.ts +38 -0
  65. package/lib/common/launch/jsonrpc-server-launcher.d.ts.map +1 -0
  66. package/lib/common/launch/jsonrpc-server-launcher.js +84 -0
  67. package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -0
  68. package/lib/common/operations/operation-action-handler.d.ts +1 -1
  69. package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
  70. package/lib/common/operations/operation-action-handler.js +3 -3
  71. package/lib/common/operations/operation-action-handler.js.map +1 -1
  72. package/lib/common/protocol/glsp-server.d.ts +4 -104
  73. package/lib/common/protocol/glsp-server.d.ts.map +1 -1
  74. package/lib/common/protocol/glsp-server.js +13 -20
  75. package/lib/common/protocol/glsp-server.js.map +1 -1
  76. package/lib/common/protocol/glsp-server.spec.js +18 -5
  77. package/lib/common/protocol/glsp-server.spec.js.map +1 -1
  78. package/lib/common/session/client-session-factory.d.ts +1 -2
  79. package/lib/common/session/client-session-factory.d.ts.map +1 -1
  80. package/lib/common/session/client-session-factory.js +17 -2
  81. package/lib/common/session/client-session-factory.js.map +1 -1
  82. package/lib/common/session/client-session-factory.spec.js +2 -2
  83. package/lib/common/session/client-session-factory.spec.js.map +1 -1
  84. package/lib/common/session/client-session-manager.d.ts +1 -3
  85. package/lib/common/session/client-session-manager.d.ts.map +1 -1
  86. package/lib/common/session/client-session-manager.js.map +1 -1
  87. package/lib/common/test/mock-util.d.ts +9 -6
  88. package/lib/common/test/mock-util.d.ts.map +1 -1
  89. package/lib/common/test/mock-util.js +23 -1
  90. package/lib/common/test/mock-util.js.map +1 -1
  91. package/lib/{browser/di → common/utils}/console-logger.d.ts +7 -1
  92. package/lib/common/utils/console-logger.d.ts.map +1 -0
  93. package/lib/{browser/di → common/utils}/console-logger.js +26 -8
  94. package/lib/common/utils/console-logger.js.map +1 -0
  95. package/lib/common/utils/layout-util.d.ts +1 -1
  96. package/lib/common/utils/layout-util.d.ts.map +1 -1
  97. package/lib/common/utils/layout-util.js +3 -3
  98. package/lib/common/utils/layout-util.js.map +1 -1
  99. package/lib/common/utils/logger.d.ts +21 -0
  100. package/lib/common/utils/logger.d.ts.map +1 -1
  101. package/lib/common/utils/logger.js +12 -1
  102. package/lib/common/utils/logger.js.map +1 -1
  103. package/lib/node/di/app-module.d.ts +2 -2
  104. package/lib/node/di/app-module.d.ts.map +1 -1
  105. package/lib/node/di/app-module.js +10 -35
  106. package/lib/node/di/app-module.js.map +1 -1
  107. package/lib/node/index.d.ts +1 -0
  108. package/lib/node/index.d.ts.map +1 -1
  109. package/lib/node/index.js +1 -0
  110. package/lib/node/index.js.map +1 -1
  111. package/lib/node/launch/cli-parser.d.ts +2 -3
  112. package/lib/node/launch/cli-parser.d.ts.map +1 -1
  113. package/lib/node/launch/cli-parser.js.map +1 -1
  114. package/lib/node/launch/socket-cli-parser.js +1 -1
  115. package/lib/node/launch/socket-cli-parser.js.map +1 -1
  116. package/lib/node/launch/socket-server-launcher.d.ts +4 -24
  117. package/lib/node/launch/socket-server-launcher.d.ts.map +1 -1
  118. package/lib/node/launch/socket-server-launcher.js +15 -34
  119. package/lib/node/launch/socket-server-launcher.js.map +1 -1
  120. package/lib/node/launch/socket-server-launcher.spec.js +5 -0
  121. package/lib/node/launch/socket-server-launcher.spec.js.map +1 -1
  122. package/lib/node/launch/websocket-server-launcher.d.ts +53 -0
  123. package/lib/node/launch/websocket-server-launcher.d.ts.map +1 -0
  124. package/lib/node/launch/websocket-server-launcher.js +121 -0
  125. package/lib/node/launch/websocket-server-launcher.js.map +1 -0
  126. package/package.json +7 -5
  127. package/src/browser/di/app-module.ts +4 -32
  128. package/src/browser/index.ts +0 -1
  129. package/src/browser/launch/worker-server-launcher.ts +20 -22
  130. package/src/common/actions/client-action-handler.ts +1 -2
  131. package/src/common/command/command-stack.spec.ts +32 -32
  132. package/src/common/command/command-stack.ts +10 -9
  133. package/src/common/command/command.spec.ts +9 -10
  134. package/src/common/command/command.ts +23 -19
  135. package/src/common/command/recording-command.spec.ts +8 -8
  136. package/src/common/command/recording-command.ts +19 -19
  137. package/src/common/command/undo-redo-action-handler.ts +4 -4
  138. package/src/common/di/client-session-module.ts +1 -1
  139. package/src/common/di/glsp-module.ts +3 -1
  140. package/src/common/di/multi-binding.ts +4 -5
  141. package/src/common/di/server-module.ts +6 -21
  142. package/src/common/features/layout/computed-bounds-action-handler.ts +2 -2
  143. package/src/common/index.ts +4 -3
  144. package/src/common/launch/glsp-server-launcher.ts +15 -9
  145. package/src/common/launch/jsonrpc-server-launcher.ts +95 -0
  146. package/src/common/operations/operation-action-handler.ts +3 -3
  147. package/src/common/protocol/glsp-server.spec.ts +7 -4
  148. package/src/common/protocol/glsp-server.ts +17 -132
  149. package/src/common/session/client-session-factory.spec.ts +1 -1
  150. package/src/common/session/client-session-factory.ts +1 -2
  151. package/src/common/session/client-session-manager.ts +1 -3
  152. package/src/common/test/mock-util.ts +26 -5
  153. package/src/{browser/di → common/utils}/console-logger.ts +19 -1
  154. package/src/common/utils/layout-util.ts +1 -1
  155. package/src/common/utils/logger.ts +16 -1
  156. package/src/node/di/app-module.ts +4 -13
  157. package/src/node/index.ts +1 -0
  158. package/src/node/launch/cli-parser.ts +2 -3
  159. package/src/node/launch/socket-cli-parser.ts +1 -1
  160. package/src/node/launch/socket-server-launcher.spec.ts +6 -0
  161. package/src/node/launch/socket-server-launcher.ts +19 -35
  162. package/src/node/launch/websocket-server-launcher.ts +138 -0
  163. package/lib/browser/di/console-logger.d.ts.map +0 -1
  164. package/lib/browser/di/console-logger.js.map +0 -1
  165. package/lib/common/protocol/glsp-client-proxy.d.ts +0 -45
  166. package/lib/common/protocol/glsp-client-proxy.d.ts.map +0 -1
  167. package/lib/common/protocol/glsp-client-proxy.js +0 -53
  168. package/lib/common/protocol/glsp-client-proxy.js.map +0 -1
  169. package/lib/common/protocol/glsp-server-listener.d.ts +0 -37
  170. package/lib/common/protocol/glsp-server-listener.d.ts.map +0 -1
  171. package/lib/common/protocol/glsp-server-listener.js +0 -5
  172. package/lib/common/protocol/glsp-server-listener.js.map +0 -1
  173. package/src/common/protocol/glsp-client-proxy.ts +0 -65
  174. package/src/common/protocol/glsp-server-listener.ts +0 -39
@@ -1 +1 @@
1
- {"version":3,"file":"socket-server-launcher.spec.js","sourceRoot":"","sources":["../../../src/node/launch/socket-server-launcher.spec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;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AAC;QACpB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAClC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;YAClC,QAAQ;iBACH,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;gBAChB,aAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YAC3C,CAAC,CAAC;iBACD,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBACd,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC;gBACb,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACnB,GAAG,CAAC,IAAI,CAAC,CAAC;YACd,CAAC,CAAC;iBACD,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;gBAChB,aAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YAC1C,CAAC,CAAC;iBACD,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,MAAM,WAAW,CAAC;IACtB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"socket-server-launcher.spec.js","sourceRoot":"","sources":["../../../src/node/launch/socket-server-launcher.spec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;AAElF,qDAAoD;AACpD,+BAA8B;AAC9B,yCAAsC;AACtC,2BAA2B;AAC3B,+BAA+B;AAC/B,mEAAsE;AACtE,iDAAmD;AACnD,2DAAiE;AACjE,qEAAgE;AAChE,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,YAAY,GAAG,IAAI,qBAAS,EAAE,CAAC;QACrC,MAAM,UAAU,GAAG,KAAK,CAAC,kBAAkB,CAAC,+BAAiB,CAAC,CA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EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;gBAChB,aAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YAC3C,CAAC,CAAC;iBACD,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBACd,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC;gBACb,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACnB,GAAG,CAAC,IAAI,CAAC,CAAC;YACd,CAAC,CAAC;iBACD,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;gBAChB,aAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YAC1C,CAAC,CAAC;iBACD,OAAO,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,MAAM,WAAW,CAAC;IACtB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,53 @@
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
+ /// <reference types="node" />
17
+ import { MaybePromise, WebSocketWrapper } from '@eclipse-glsp/protocol';
18
+ import * as http from 'http';
19
+ import * as jsonrpc from 'vscode-jsonrpc';
20
+ import { Server, WebSocket } from 'ws';
21
+ import { JsonRpcGLSPServerLauncher } from '../../common/launch/jsonrpc-server-launcher';
22
+ import { Logger } from '../../common/utils/logger';
23
+ export interface WebSocketServerOptions {
24
+ host?: string;
25
+ port?: number;
26
+ path: string;
27
+ }
28
+ export interface ResolvedWebSocketServerOptions {
29
+ host?: string;
30
+ port: number;
31
+ path: string;
32
+ server: http.Server;
33
+ }
34
+ export interface WebsocketConnectionData {
35
+ socket: WebSocket;
36
+ connection: jsonrpc.MessageConnection;
37
+ }
38
+ export declare class WebSocketServerLauncher extends JsonRpcGLSPServerLauncher<WebSocketServerOptions> {
39
+ protected logger: Logger;
40
+ protected server: Server;
41
+ constructor();
42
+ protected run(options: WebSocketServerOptions): Promise<void>;
43
+ protected createConnection(socket: WebSocket): jsonrpc.MessageConnection;
44
+ protected resolveOptions(options: WebSocketServerOptions): Promise<ResolvedWebSocketServerOptions>;
45
+ protected createHttpServer(port: number, host?: string): http.Server;
46
+ start(options: WebSocketServerOptions): MaybePromise<void>;
47
+ }
48
+ /**
49
+ * Creates a {@link WebSocketWrapper} for the given plain WebSocket
50
+ * @param socket The socket to wrap
51
+ */
52
+ export declare function wrapWebSocket(socket: WebSocket): WebSocketWrapper;
53
+ //# sourceMappingURL=websocket-server-launcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket-server-launcher.d.ts","sourceRoot":"","sources":["../../../src/node/launch/websocket-server-launcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;;AAElF,OAAO,EAAyC,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/G,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,MAAM,WAAW,sBAAsB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,8BAA8B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC,iBAAiB,CAAC;CACzC;AAID,qBACa,uBAAwB,SAAQ,yBAAyB,CAAC,sBAAsB,CAAC;IAC1F,UACmB,MAAM,EAAE,MAAM,CAAC;IAElC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;;cAWT,GAAG,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBnE,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,iBAAiB;cAIxD,cAAc,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;IAQxG,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM;IAgB3D,KAAK,CAAC,OAAO,EAAE,sBAAsB,GAAG,YAAY,CAAC,IAAI,CAAC;CAGtE;AAeD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,gBAAgB,CAQjE"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ /********************************************************************************
3
+ * Copyright (c) 2023 EclipseSource and others.
4
+ *
5
+ * This program and the accompanying materials are made available under the
6
+ * terms of the Eclipse Public License v. 2.0 which is available at
7
+ * http://www.eclipse.org/legal/epl-2.0.
8
+ *
9
+ * This Source Code may also be made available under the following Secondary
10
+ * Licenses when the conditions for such availability set forth in the Eclipse
11
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ * with the GNU Classpath Exception which is available at
13
+ * https://www.gnu.org/software/classpath/license.html.
14
+ *
15
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ ********************************************************************************/
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.wrapWebSocket = exports.WebSocketServerLauncher = void 0;
28
+ const protocol_1 = require("@eclipse-glsp/protocol");
29
+ const http = require("http");
30
+ const inversify_1 = require("inversify");
31
+ const net = require("net");
32
+ const ws_1 = require("ws");
33
+ const jsonrpc_server_launcher_1 = require("../../common/launch/jsonrpc-server-launcher");
34
+ const logger_1 = require("../../common/utils/logger");
35
+ const STATUS_UPGRADE_REQUIRED = 426;
36
+ let WebSocketServerLauncher = class WebSocketServerLauncher extends jsonrpc_server_launcher_1.JsonRpcGLSPServerLauncher {
37
+ constructor() {
38
+ super();
39
+ this.toDispose.push(protocol_1.Disposable.create(() => {
40
+ this.server.close();
41
+ }));
42
+ }
43
+ async run(options) {
44
+ const resolvedOptions = await this.resolveOptions(options);
45
+ this.server = new ws_1.Server({ server: resolvedOptions.server, path: resolvedOptions.path });
46
+ const endpoint = `ws://${resolvedOptions.host}:${resolvedOptions.port}:${resolvedOptions.path}`;
47
+ this.logger.info(`The GLSP Websocket launcher is ready to accept new client requests on endpoint '${endpoint}'`);
48
+ console.log(this.startupCompleteMessage.concat(resolvedOptions.port.toString()));
49
+ this.server.on('connection', (ws, req) => {
50
+ const connection = this.createConnection(ws);
51
+ this.createServerInstance(connection);
52
+ });
53
+ return new Promise((resolve, reject) => {
54
+ this.server.on('close', () => resolve(undefined));
55
+ this.server.on('error', error => reject(error));
56
+ });
57
+ }
58
+ createConnection(socket) {
59
+ return (0, protocol_1.createWebSocketConnection)(wrapWebSocket(socket));
60
+ }
61
+ async resolveOptions(options) {
62
+ const port = !options.port || options.port === 0 ? await getFreePort() : options.port;
63
+ const path = options.path.startsWith('/') ? options.path : `/${options.path}`;
64
+ const server = this.createHttpServer(port, options.host);
65
+ return Object.assign(Object.assign({}, options), { port, path, server });
66
+ }
67
+ createHttpServer(port, host) {
68
+ const server = http.createServer((req, res) => {
69
+ const body = http.STATUS_CODES[STATUS_UPGRADE_REQUIRED];
70
+ res.writeHead(426, {
71
+ 'Content-Length': body === null || body === void 0 ? void 0 : body.length,
72
+ 'Content-Type': 'text/plain'
73
+ });
74
+ res.end(body);
75
+ });
76
+ server.listen(port, host);
77
+ // Set server timeout to infinite
78
+ server.setTimeout(0);
79
+ return server;
80
+ }
81
+ start(options) {
82
+ super.start(options);
83
+ }
84
+ };
85
+ __decorate([
86
+ (0, inversify_1.inject)(logger_1.Logger),
87
+ __metadata("design:type", logger_1.Logger)
88
+ ], WebSocketServerLauncher.prototype, "logger", void 0);
89
+ WebSocketServerLauncher = __decorate([
90
+ (0, inversify_1.injectable)(),
91
+ __metadata("design:paramtypes", [])
92
+ ], WebSocketServerLauncher);
93
+ exports.WebSocketServerLauncher = WebSocketServerLauncher;
94
+ async function getFreePort() {
95
+ return new Promise((resolve, reject) => {
96
+ const srv = net.createServer();
97
+ srv.listen(0, () => {
98
+ const address = srv.address();
99
+ if (!address || typeof address === 'string') {
100
+ reject(new Error('Could not address to compute a free port'));
101
+ return;
102
+ }
103
+ srv.close(() => resolve(address.port));
104
+ });
105
+ });
106
+ }
107
+ /**
108
+ * Creates a {@link WebSocketWrapper} for the given plain WebSocket
109
+ * @param socket The socket to wrap
110
+ */
111
+ function wrapWebSocket(socket) {
112
+ return {
113
+ send: content => socket.send(content),
114
+ onMessage: cb => socket.on('message', cb),
115
+ onClose: cb => socket.on('close', cb),
116
+ onError: cb => socket.on('error', cb),
117
+ dispose: () => socket.close()
118
+ };
119
+ }
120
+ exports.wrapWebSocket = wrapWebSocket;
121
+ //# sourceMappingURL=websocket-server-launcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket-server-launcher.js","sourceRoot":"","sources":["../../../src/node/launch/websocket-server-launcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;AAElF,qDAA+G;AAC/G,6BAA6B;AAC7B,yCAA+C;AAC/C,2BAA2B;AAE3B,2BAAuC;AACvC,yFAAwF;AACxF,sDAAmD;AAoBnD,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAG7B,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,mDAAiD;IAM1F;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,CAAC,IAAI,CACf,qBAAU,CAAC,MAAM,CAAC,GAAG,EAAE;YACnB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC,CAAC,CACL,CAAC;IACN,CAAC;IAES,KAAK,CAAC,GAAG,CAAC,OAA+B;QAC/C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,GAAG,IAAI,WAAM,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC;QACzF,MAAM,QAAQ,GAAG,QAAQ,eAAe,CAAC,IAAI,IAAI,eAAe,CAAC,IAAI,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;QAChG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mFAAmF,QAAQ,GAAG,C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,EAAE;gBACzC,MAAM,CAAC,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC,CAAC;gBAC9D,OAAO;aACV;YACD,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AACD;;;GAGG;AACH,SAAgB,aAAa,CAAC,MAAiB;IAC3C,OAAO;QACH,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACrC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC;QACzC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACrC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;KAChC,CAAC;AACN,CAAC;AARD,sCAQC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-glsp/server",
3
- "version": "1.1.0-next.44bd1e0.43+44bd1e0",
3
+ "version": "1.1.0-next.d47240f.50+d47240f",
4
4
  "description": "A js server framework for Eclipse GLSP",
5
5
  "keywords": [
6
6
  "eclipse",
@@ -59,19 +59,21 @@
59
59
  "watch": "tsc -w"
60
60
  },
61
61
  "dependencies": {
62
- "@eclipse-glsp/graph": "1.1.0-next.44bd1e0.43+44bd1e0",
62
+ "@eclipse-glsp/graph": "1.1.0-next.d47240f.50+d47240f",
63
63
  "@eclipse-glsp/protocol": "next",
64
64
  "@types/uuid": "8.3.1",
65
65
  "commander": "^8.3.0",
66
66
  "fast-json-patch": "^3.1.0",
67
67
  "inversify": "^5.1.1",
68
- "winston": "^3.3.3"
68
+ "winston": "^3.3.3",
69
+ "ws": "^8.12.1"
69
70
  },
70
71
  "devDependencies": {
71
- "@types/fs-extra": "^9.0.13"
72
+ "@types/fs-extra": "^9.0.13",
73
+ "@types/ws": "^8.5.4"
72
74
  },
73
75
  "publishConfig": {
74
76
  "access": "public"
75
77
  },
76
- "gitHead": "44bd1e05dcc86ad71386a5286eed7e3300afb51a"
78
+ "gitHead": "d47240f44513b242a84ab6c4996f79ecd740837e"
77
79
  }
@@ -14,42 +14,14 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { ContainerModule, interfaces } from 'inversify';
18
- import { InjectionContainer, Logger, LoggerFactory, LogLevel, ModuleContext, NullLogger } from '../../common/index';
19
- import { ConsoleLogger } from './console-logger';
17
+ import { ContainerModule } from 'inversify';
18
+ import { InjectionContainer, LogLevel, LoggerConfigOptions, configureConsoleLogger } from '../../common/';
20
19
 
21
- export interface LaunchOptions {
22
- consoleLog?: boolean;
23
- logLevel?: LogLevel;
24
- }
25
- export function createAppModule(options: LaunchOptions = {}): ContainerModule {
26
- const resolvedOptions: LaunchOptions = { consoleLog: true, logLevel: LogLevel.info, ...options };
20
+ export function createAppModule(options: LoggerConfigOptions = {}): ContainerModule {
21
+ const resolvedOptions: LoggerConfigOptions = { consoleLog: true, logLevel: LogLevel.info, ...options };
27
22
  return new ContainerModule((bind, unbind, isBound, rebind) => {
28
23
  bind(InjectionContainer).toDynamicValue(dynamicContext => dynamicContext.container);
29
24
  const context = { bind, unbind, isBound, rebind };
30
25
  configureConsoleLogger(context, resolvedOptions);
31
26
  });
32
27
  }
33
-
34
- export function configureConsoleLogger<T extends LaunchOptions>(context: ModuleContext, options: T): void {
35
- if (!options.consoleLog) {
36
- context.bind(Logger).to(NullLogger).inSingletonScope();
37
- } else {
38
- context.bind(Logger).toDynamicValue(ctx => new ConsoleLogger(options.logLevel, getRequestParentName(ctx)));
39
- }
40
- context.bind(LoggerFactory).toFactory(dynamicContext => (caller: string) => {
41
- const logger = dynamicContext.container.get(Logger);
42
- logger.caller = caller;
43
- return logger;
44
- });
45
- }
46
-
47
- function getRequestParentName(context: interfaces.Context): string | undefined {
48
- if (context.currentRequest.parentRequest) {
49
- const bindings = context.currentRequest.parentRequest.bindings;
50
- if (bindings.length > 0) {
51
- return bindings[0].implementationType?.name;
52
- }
53
- }
54
- return undefined;
55
- }
@@ -15,5 +15,4 @@
15
15
  ********************************************************************************/
16
16
  export * from '../common/index';
17
17
  export * from './di/app-module';
18
- export * from './di/console-logger';
19
18
  export * from './launch/worker-server-launcher';
@@ -14,26 +14,27 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { Container, injectable } from 'inversify';
17
+ import { injectable } from 'inversify';
18
18
  import * as jsonrpc from 'vscode-jsonrpc/browser';
19
- import { GLSPServer, GLSPServerLauncher, JsonRpcGLSPServer, MaybePromise, START_UP_COMPLETE_MSG } from '../../common/index';
19
+ import { MaybePromise } from '../../common/index';
20
+ import { JsonRpcGLSPServerLauncher, JsonRpcServerInstance } from '../../common/launch/jsonrpc-server-launcher';
21
+ export interface WorkerLaunchOptions {
22
+ context?: Worker;
23
+ }
24
+
25
+ export const START_UP_COMPLETE_MSG = '[GLSP-Server]:Startup completed.';
20
26
 
21
27
  @injectable()
22
- export class WorkerServerLauncher extends GLSPServerLauncher {
23
- private connection?: jsonrpc.MessageConnection;
28
+ export class WorkerServerLauncher extends JsonRpcGLSPServerLauncher<WorkerLaunchOptions> {
29
+ protected connection?: jsonrpc.MessageConnection;
24
30
 
25
- protected run(): MaybePromise<void> {
31
+ protected run(options: WorkerLaunchOptions): MaybePromise<void> {
26
32
  if (this.connection) {
27
33
  throw new Error('Error during launch. Server already has an active client connection');
28
34
  }
29
- const container = this.createContainer();
30
- this.connection = this.createConnection();
31
- const glspServer = container.get<JsonRpcGLSPServer>(JsonRpcGLSPServer);
32
- glspServer.connect(this.connection);
33
- this.connection.onDispose(() => this.disposeClientConnection(container, glspServer));
34
-
35
+ this.connection = this.createConnection(options);
36
+ this.createServerInstance(this.connection);
35
37
  this.logger.info('GLSP server worker connection established');
36
- this.connection.listen();
37
38
  postMessage(START_UP_COMPLETE_MSG);
38
39
  return new Promise((resolve, rejects) => {
39
40
  this.connection?.onClose(() => resolve(undefined));
@@ -41,18 +42,15 @@ export class WorkerServerLauncher extends GLSPServerLauncher {
41
42
  });
42
43
  }
43
44
 
44
- protected disposeClientConnection(container: Container, glspServer: GLSPServer): void {
45
- glspServer.shutdown();
46
- container.unbindAll();
45
+ protected override disposeServerInstance(instance: JsonRpcServerInstance): void {
46
+ super.disposeServerInstance(instance);
47
47
  this.connection = undefined;
48
48
  }
49
49
 
50
- protected stop(): MaybePromise<void> {
51
- this.logger.info('Shutdown WorkerServerLauncher');
52
- this.connection?.dispose();
53
- }
54
-
55
- protected createConnection(): jsonrpc.MessageConnection {
56
- return jsonrpc.createMessageConnection(new jsonrpc.BrowserMessageReader(self), new jsonrpc.BrowserMessageWriter(self));
50
+ protected createConnection(options: WorkerLaunchOptions): jsonrpc.MessageConnection {
51
+ return jsonrpc.createMessageConnection(
52
+ new jsonrpc.BrowserMessageReader(options.context ?? self),
53
+ new jsonrpc.BrowserMessageWriter(options.context ?? self)
54
+ );
57
55
  }
58
56
  }
@@ -13,10 +13,9 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { Action, ActionMessage } from '@eclipse-glsp/protocol';
16
+ import { Action, ActionMessage, GLSPClientProxy } from '@eclipse-glsp/protocol';
17
17
  import { inject, injectable, optional } from 'inversify';
18
18
  import { ClientActionKinds, ClientId } from '../di/service-identifiers';
19
- import { GLSPClientProxy } from '../protocol/glsp-client-proxy';
20
19
 
21
20
  /**
22
21
  * The client action handler is responsible of handling action kinds that are intended for the
@@ -16,7 +16,7 @@
16
16
  import { expect } from 'chai';
17
17
  import { Container, ContainerModule } from 'inversify';
18
18
  import * as sinon from 'sinon';
19
- import { StubCommand, StubLogger } from '../test/mock-util';
19
+ import { expectToThrowAsync, StubCommand, StubLogger } from '../test/mock-util';
20
20
  import { Logger } from '../utils/logger';
21
21
  import { DefaultCommandStack } from './command-stack';
22
22
 
@@ -41,17 +41,17 @@ describe('test DefaultCommandStack', () => {
41
41
  });
42
42
 
43
43
  describe('execute', () => {
44
- it('should execute the given command and become dirty', () => {
44
+ it('should execute the given command and become dirty', async () => {
45
45
  expect(commandStack.isDirty).to.be.false;
46
- commandStack.execute(command1);
46
+ await commandStack.execute(command1);
47
47
  expect(command1.execute.calledOnce).to.be.true;
48
48
  expect(commandStack.isDirty).to.be.true;
49
49
  });
50
50
 
51
- it('should execute the given commands in order and become dirty', () => {
51
+ it('should execute the given commands in order and become dirty', async () => {
52
52
  expect(commandStack.isDirty).to.be.false;
53
- commandStack.execute(command1);
54
- commandStack.execute(command2);
53
+ await commandStack.execute(command1);
54
+ await commandStack.execute(command2);
55
55
 
56
56
  expect(command1.execute.calledOnce).to.be.true;
57
57
  expect(command2.execute.calledOnce).to.be.true;
@@ -59,112 +59,112 @@ describe('test DefaultCommandStack', () => {
59
59
  expect(commandStack.isDirty).to.be.true;
60
60
  });
61
61
 
62
- it('should be able to undo after execute', () => {
62
+ it('should be able to undo after execute', async () => {
63
63
  expect(commandStack.canUndo()).to.be.false;
64
- commandStack.execute(command1);
64
+ await commandStack.execute(command1);
65
65
  expect(commandStack.canUndo()).to.be.true;
66
66
  });
67
67
 
68
- it('should clear the redo stack after execution', () => {
68
+ it('should clear the redo stack after execution', async () => {
69
69
  commandStack['commands'].push(command2);
70
70
  commandStack['top'] = -1;
71
71
  expect(commandStack.canRedo()).to.be.true;
72
72
 
73
- commandStack.execute(command1);
73
+ await commandStack.execute(command1);
74
74
  expect(commandStack.canRedo()).to.be.false;
75
75
  });
76
76
 
77
- it('should flush the stack in case of an execution error', () => {
77
+ it('should flush the stack in case of an execution error', async () => {
78
78
  command2.execute.throwsException();
79
79
  const flushSpy = sandbox.spy(commandStack, 'flush');
80
80
 
81
- expect(() => commandStack.execute(command2)).to.throw();
81
+ await expectToThrowAsync(() => commandStack.execute(command2));
82
82
  expect(command2.execute.calledOnce).to.be.true;
83
83
  expect(flushSpy.calledOnce).to.be.true;
84
84
  });
85
85
  });
86
86
 
87
87
  describe('undo', () => {
88
- it('should do nothing if the command stack is empty', () => {
88
+ it('should do nothing if the command stack is empty', async () => {
89
89
  expect(commandStack.isDirty).to.be.false;
90
90
 
91
- commandStack.undo();
91
+ await commandStack.undo();
92
92
  expect(commandStack.canUndo()).to.be.false;
93
93
  expect(commandStack.canRedo()).to.be.false;
94
94
  expect(commandStack.isDirty).to.be.false;
95
95
  });
96
96
 
97
- it('should undo the command and become non-dirty again', () => {
97
+ it('should undo the command and become non-dirty again', async () => {
98
98
  commandStack['commands'].push(command1);
99
99
  commandStack['top'] = 0;
100
100
  expect(commandStack.isDirty).to.be.true;
101
101
  expect(commandStack.canUndo()).to.be.true;
102
102
  expect(commandStack.canRedo()).to.be.false;
103
103
 
104
- commandStack.undo();
104
+ await commandStack.undo();
105
105
  expect(command1.undo.calledOnce).to.be.true;
106
106
  expect(commandStack.isDirty).to.be.false;
107
107
  expect(commandStack.canRedo()).to.be.true;
108
108
  expect(commandStack.canUndo()).to.be.false;
109
109
  });
110
110
 
111
- it('should undo multiple command and become non-dirty again', () => {
111
+ it('should undo multiple command and become non-dirty again', async () => {
112
112
  commandStack['commands'].push(command1, command2);
113
113
  commandStack['top'] = 1;
114
114
  expect(commandStack.isDirty).to.be.true;
115
115
  expect(commandStack.canUndo()).to.be.true;
116
116
  expect(commandStack.canRedo()).to.be.false;
117
117
 
118
- commandStack.undo();
118
+ await commandStack.undo();
119
119
  expect(command2.undo.calledOnce).to.be.true;
120
120
  expect(commandStack.canRedo()).to.be.true;
121
121
  expect(commandStack.canUndo()).to.be.true;
122
122
  expect(commandStack.isDirty).to.be.true;
123
123
 
124
- commandStack.undo();
124
+ await commandStack.undo();
125
125
  expect(command1.undo.calledOnce).to.be.true;
126
126
  expect(command1.undo.calledAfter(command2.undo)).to.be.true;
127
127
  expect(commandStack.isDirty).to.be.false;
128
128
  expect(commandStack.canRedo()).to.be.true;
129
129
  expect(commandStack.canUndo()).to.be.false;
130
130
  });
131
- it('should flush the stack in case of an execution error', () => {
131
+ it('should flush the stack in case of an execution error', async () => {
132
132
  command2.undo.throwsException();
133
133
  const flushSpy = sandbox.spy(commandStack, 'flush');
134
134
  commandStack['commands'].push(command2);
135
135
  commandStack['top'] = 0;
136
136
 
137
- expect(() => commandStack.undo()).to.throw();
137
+ await expectToThrowAsync(() => commandStack.undo());
138
138
  expect(command2.undo.calledOnce).to.be.true;
139
139
  expect(flushSpy.calledOnce).to.be.true;
140
140
  });
141
141
  });
142
142
 
143
143
  describe('redo', () => {
144
- it('should do nothing if the command stack is empty', () => {
144
+ it('should do nothing if the command stack is empty', async () => {
145
145
  expect(commandStack.isDirty).to.be.false;
146
146
 
147
- commandStack.redo();
147
+ await commandStack.redo();
148
148
  expect(commandStack.canUndo()).to.be.false;
149
149
  expect(commandStack.canRedo()).to.be.false;
150
150
  expect(commandStack.isDirty).to.be.false;
151
151
  });
152
152
 
153
- it('should redo the command and become dirty again', () => {
153
+ it('should redo the command and become dirty again', async () => {
154
154
  commandStack['commands'].push(command1);
155
155
  commandStack['top'] = -1;
156
156
  expect(commandStack.isDirty).to.be.false;
157
157
  expect(commandStack.canUndo()).to.be.false;
158
158
  expect(commandStack.canRedo()).to.be.true;
159
159
 
160
- commandStack.redo();
160
+ await commandStack.redo();
161
161
  expect(command1.redo.calledOnce).to.be.true;
162
162
  expect(commandStack.isDirty).to.be.true;
163
163
  expect(commandStack.canRedo()).to.be.false;
164
164
  expect(commandStack.canUndo()).to.be.true;
165
165
  });
166
166
 
167
- it('should undo multiple command and become non-dirty again', () => {
167
+ it('should undo multiple command and become non-dirty again', async () => {
168
168
  commandStack['commands'].push(command2, command1);
169
169
  commandStack['top'] = -1;
170
170
  commandStack['saveIndex'] = -1;
@@ -172,34 +172,34 @@ describe('test DefaultCommandStack', () => {
172
172
  expect(commandStack.canUndo()).to.be.false;
173
173
  expect(commandStack.canRedo()).to.be.true;
174
174
 
175
- commandStack.redo();
175
+ await commandStack.redo();
176
176
  expect(command2.redo.calledOnce).to.be.true;
177
177
  expect(commandStack.canRedo()).to.be.true;
178
178
  expect(commandStack.canUndo()).to.be.true;
179
179
  expect(commandStack.isDirty).to.be.true;
180
180
 
181
- commandStack.redo();
181
+ await commandStack.redo();
182
182
  expect(command1.redo.calledOnce).to.be.true;
183
183
  expect(command1.redo.calledAfter(command2.redo)).to.be.true;
184
184
  expect(commandStack.isDirty).to.be.true;
185
185
  expect(commandStack.canRedo()).to.be.false;
186
186
  expect(commandStack.canUndo()).to.be.true;
187
187
  });
188
- it('should flush the stack in case of an execution error', () => {
188
+ it('should flush the stack in case of an execution error', async () => {
189
189
  command2.redo.throwsException();
190
190
  const flushSpy = sandbox.spy(commandStack, 'flush');
191
191
  commandStack['commands'].push(command2);
192
192
  commandStack['top'] = -1;
193
193
 
194
- expect(() => commandStack.redo()).to.throw();
194
+ await expectToThrowAsync(() => commandStack.redo());
195
195
  expect(command2.redo.calledOnce).to.be.true;
196
196
  expect(flushSpy.calledOnce).to.be.true;
197
197
  });
198
- it('should be able to undo after redo', () => {
198
+ it('should be able to undo after redo', async () => {
199
199
  commandStack['commands'].push(command1);
200
200
  commandStack['top'] = -1;
201
201
  expect(commandStack.canUndo()).to.be.false;
202
- commandStack.redo();
202
+ await commandStack.redo();
203
203
  expect(commandStack.canUndo()).to.be.true;
204
204
  });
205
205
  });
@@ -13,6 +13,7 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
+ import { MaybePromise } from '@eclipse-glsp/protocol';
16
17
  import { inject, injectable } from 'inversify';
17
18
  import { Logger } from '../utils/logger';
18
19
  import { Command } from './command';
@@ -31,12 +32,12 @@ export interface CommandStack {
31
32
  * Clears any redoable commands not yet redone, adds the command to the stack and then invokes {@link Command.execute}.
32
33
  * @param command the command to execute.
33
34
  */
34
- execute(command: Command): void;
35
+ execute(command: Command): MaybePromise<void>;
35
36
 
36
37
  /**
37
38
  * Removes the topmost (i.e. last executed) command from the stack and invokes {@link Command.undo}.
38
39
  */
39
- undo(): void;
40
+ undo(): MaybePromise<void>;
40
41
 
41
42
  /**
42
43
  * Returns `true` if the top command on the stack can be undone.
@@ -46,7 +47,7 @@ export interface CommandStack {
46
47
  /**
47
48
  * Re-adds the last undo command on top of the stack and invokes {@link Command.redo}
48
49
  */
49
- redo(): void;
50
+ redo(): MaybePromise<void>;
50
51
 
51
52
  /**
52
53
  * Returns `true` if there are redoable commands in the stack.
@@ -86,9 +87,9 @@ export class DefaultCommandStack implements CommandStack {
86
87
  */
87
88
  protected saveIndex = -1;
88
89
 
89
- execute(command: Command): void {
90
+ async execute(command: Command): Promise<void> {
90
91
  try {
91
- command.execute();
92
+ await command.execute();
92
93
  } catch (error) {
93
94
  this.handleError(error);
94
95
  }
@@ -104,11 +105,11 @@ export class DefaultCommandStack implements CommandStack {
104
105
  }
105
106
  }
106
107
 
107
- undo(): void {
108
+ async undo(): Promise<void> {
108
109
  if (this.canUndo()) {
109
110
  const command = this.commands[this.top--];
110
111
  try {
111
- command.undo();
112
+ await command.undo();
112
113
  } catch (error) {
113
114
  this.handleError(error);
114
115
  }
@@ -121,11 +122,11 @@ export class DefaultCommandStack implements CommandStack {
121
122
  : false;
122
123
  }
123
124
 
124
- redo(): void {
125
+ async redo(): Promise<void> {
125
126
  if (this.canRedo()) {
126
127
  const command = this.commands[++this.top];
127
128
  try {
128
- command.redo();
129
+ await command.redo();
129
130
  } catch (error) {
130
131
  this.handleError(error);
131
132
  }