@eclipse-glsp/server 1.1.0-next.44aae0c.44 → 1.1.0-next.452eba9.51
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.
- package/lib/browser/di/app-module.d.ts +2 -7
- package/lib/browser/di/app-module.d.ts.map +1 -1
- package/lib/browser/di/app-module.js +5 -30
- package/lib/browser/di/app-module.js.map +1 -1
- package/lib/browser/index.d.ts +0 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/launch/worker-server-launcher.d.ts +11 -8
- package/lib/browser/launch/worker-server-launcher.d.ts.map +1 -1
- package/lib/browser/launch/worker-server-launcher.js +13 -21
- package/lib/browser/launch/worker-server-launcher.js.map +1 -1
- package/lib/common/actions/client-action-handler.d.ts +1 -2
- package/lib/common/actions/client-action-handler.d.ts.map +1 -1
- package/lib/common/actions/client-action-handler.js +17 -2
- package/lib/common/actions/client-action-handler.js.map +1 -1
- package/lib/common/command/command-stack.d.ts +16 -1
- package/lib/common/command/command-stack.d.ts.map +1 -1
- package/lib/common/command/command-stack.js +0 -15
- package/lib/common/command/command-stack.js.map +1 -1
- package/lib/common/command/recording-command.d.ts +7 -7
- package/lib/common/command/recording-command.d.ts.map +1 -1
- package/lib/common/command/recording-command.js +6 -6
- package/lib/common/command/recording-command.js.map +1 -1
- package/lib/common/di/client-session-module.d.ts +1 -1
- package/lib/common/di/client-session-module.d.ts.map +1 -1
- package/lib/common/di/client-session-module.js +2 -2
- package/lib/common/di/client-session-module.js.map +1 -1
- package/lib/common/di/glsp-module.d.ts +3 -1
- package/lib/common/di/glsp-module.d.ts.map +1 -1
- package/lib/common/di/glsp-module.js +0 -15
- package/lib/common/di/glsp-module.js.map +1 -1
- package/lib/common/di/multi-binding.d.ts +19 -4
- package/lib/common/di/multi-binding.d.ts.map +1 -1
- package/lib/common/di/multi-binding.js.map +1 -1
- package/lib/common/di/server-module.d.ts +1 -6
- package/lib/common/di/server-module.d.ts.map +1 -1
- package/lib/common/di/server-module.js +21 -17
- package/lib/common/di/server-module.js.map +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.js +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
- package/lib/common/index.d.ts +4 -3
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +4 -3
- package/lib/common/index.js.map +1 -1
- package/lib/common/launch/glsp-server-launcher.d.ts +8 -7
- package/lib/common/launch/glsp-server-launcher.d.ts.map +1 -1
- package/lib/common/launch/glsp-server-launcher.js +27 -4
- package/lib/common/launch/glsp-server-launcher.js.map +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.d.ts +38 -0
- package/lib/common/launch/jsonrpc-server-launcher.d.ts.map +1 -0
- package/lib/common/launch/jsonrpc-server-launcher.js +84 -0
- package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -0
- package/lib/common/protocol/glsp-server.d.ts +4 -104
- package/lib/common/protocol/glsp-server.d.ts.map +1 -1
- package/lib/common/protocol/glsp-server.js +13 -20
- package/lib/common/protocol/glsp-server.js.map +1 -1
- package/lib/common/protocol/glsp-server.spec.js +18 -5
- package/lib/common/protocol/glsp-server.spec.js.map +1 -1
- package/lib/common/session/client-session-factory.d.ts +1 -2
- package/lib/common/session/client-session-factory.d.ts.map +1 -1
- package/lib/common/session/client-session-factory.js +17 -2
- package/lib/common/session/client-session-factory.js.map +1 -1
- package/lib/common/session/client-session-factory.spec.js +2 -2
- package/lib/common/session/client-session-factory.spec.js.map +1 -1
- package/lib/common/session/client-session-manager.d.ts +1 -3
- package/lib/common/session/client-session-manager.d.ts.map +1 -1
- package/lib/common/session/client-session-manager.js.map +1 -1
- package/lib/common/test/mock-util.d.ts +3 -6
- package/lib/common/test/mock-util.d.ts.map +1 -1
- package/lib/common/test/mock-util.js.map +1 -1
- package/lib/{browser/di → common/utils}/console-logger.d.ts +7 -1
- package/lib/common/utils/console-logger.d.ts.map +1 -0
- package/lib/{browser/di → common/utils}/console-logger.js +26 -8
- package/lib/common/utils/console-logger.js.map +1 -0
- package/lib/common/utils/layout-util.d.ts +1 -1
- package/lib/common/utils/layout-util.d.ts.map +1 -1
- package/lib/common/utils/layout-util.js +3 -3
- package/lib/common/utils/layout-util.js.map +1 -1
- package/lib/common/utils/logger.d.ts +21 -0
- package/lib/common/utils/logger.d.ts.map +1 -1
- package/lib/common/utils/logger.js +12 -1
- package/lib/common/utils/logger.js.map +1 -1
- package/lib/node/di/app-module.d.ts +2 -2
- package/lib/node/di/app-module.d.ts.map +1 -1
- package/lib/node/di/app-module.js +10 -35
- package/lib/node/di/app-module.js.map +1 -1
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/launch/cli-parser.d.ts +2 -3
- package/lib/node/launch/cli-parser.d.ts.map +1 -1
- package/lib/node/launch/cli-parser.js.map +1 -1
- package/lib/node/launch/socket-cli-parser.js +1 -1
- package/lib/node/launch/socket-cli-parser.js.map +1 -1
- package/lib/node/launch/socket-server-launcher.d.ts +4 -24
- package/lib/node/launch/socket-server-launcher.d.ts.map +1 -1
- package/lib/node/launch/socket-server-launcher.js +15 -34
- package/lib/node/launch/socket-server-launcher.js.map +1 -1
- package/lib/node/launch/socket-server-launcher.spec.js +5 -0
- package/lib/node/launch/socket-server-launcher.spec.js.map +1 -1
- package/lib/node/launch/websocket-server-launcher.d.ts +53 -0
- package/lib/node/launch/websocket-server-launcher.d.ts.map +1 -0
- package/lib/node/launch/websocket-server-launcher.js +121 -0
- package/lib/node/launch/websocket-server-launcher.js.map +1 -0
- package/package.json +7 -5
- package/src/browser/di/app-module.ts +4 -32
- package/src/browser/index.ts +0 -1
- package/src/browser/launch/worker-server-launcher.ts +20 -22
- package/src/common/actions/client-action-handler.ts +1 -2
- package/src/common/command/command-stack.ts +1 -1
- package/src/common/command/recording-command.ts +11 -11
- package/src/common/di/client-session-module.ts +1 -1
- package/src/common/di/glsp-module.ts +3 -1
- package/src/common/di/multi-binding.ts +4 -5
- package/src/common/di/server-module.ts +6 -21
- package/src/common/features/layout/computed-bounds-action-handler.ts +2 -2
- package/src/common/index.ts +4 -3
- package/src/common/launch/glsp-server-launcher.ts +15 -9
- package/src/common/launch/jsonrpc-server-launcher.ts +95 -0
- package/src/common/protocol/glsp-server.spec.ts +7 -4
- package/src/common/protocol/glsp-server.ts +17 -132
- package/src/common/session/client-session-factory.spec.ts +1 -1
- package/src/common/session/client-session-factory.ts +1 -2
- package/src/common/session/client-session-manager.ts +1 -3
- package/src/common/test/mock-util.ts +5 -5
- package/src/{browser/di → common/utils}/console-logger.ts +19 -1
- package/src/common/utils/layout-util.ts +1 -1
- package/src/common/utils/logger.ts +16 -1
- package/src/node/di/app-module.ts +4 -13
- package/src/node/index.ts +1 -0
- package/src/node/launch/cli-parser.ts +2 -3
- package/src/node/launch/socket-cli-parser.ts +1 -1
- package/src/node/launch/socket-server-launcher.spec.ts +6 -0
- package/src/node/launch/socket-server-launcher.ts +19 -35
- package/src/node/launch/websocket-server-launcher.ts +138 -0
- package/lib/browser/di/console-logger.d.ts.map +0 -1
- package/lib/browser/di/console-logger.js.map +0 -1
- package/lib/common/protocol/glsp-client-proxy.d.ts +0 -45
- package/lib/common/protocol/glsp-client-proxy.d.ts.map +0 -1
- package/lib/common/protocol/glsp-client-proxy.js +0 -53
- package/lib/common/protocol/glsp-client-proxy.js.map +0 -1
- package/lib/common/protocol/glsp-server-listener.d.ts +0 -37
- package/lib/common/protocol/glsp-server-listener.d.ts.map +0 -1
- package/lib/common/protocol/glsp-server-listener.js +0 -5
- package/lib/common/protocol/glsp-server-listener.js.map +0 -1
- package/src/common/protocol/glsp-client-proxy.ts +0 -65
- package/src/common/protocol/glsp-server-listener.ts +0 -39
|
@@ -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,u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AO,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.
|
|
3
|
+
"version": "1.1.0-next.452eba9.51+452eba9",
|
|
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.
|
|
62
|
+
"@eclipse-glsp/graph": "1.1.0-next.452eba9.51+452eba9",
|
|
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": "
|
|
78
|
+
"gitHead": "452eba9316ed0eac3d741cd950f439c3f297a7b0"
|
|
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
|
|
18
|
-
import { InjectionContainer,
|
|
19
|
-
import { ConsoleLogger } from './console-logger';
|
|
17
|
+
import { ContainerModule } from 'inversify';
|
|
18
|
+
import { InjectionContainer, LogLevel, LoggerConfigOptions, configureConsoleLogger } from '../../common/';
|
|
20
19
|
|
|
21
|
-
export
|
|
22
|
-
consoleLog
|
|
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
|
-
}
|
package/src/browser/index.ts
CHANGED
|
@@ -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 {
|
|
17
|
+
import { injectable } from 'inversify';
|
|
18
18
|
import * as jsonrpc from 'vscode-jsonrpc/browser';
|
|
19
|
-
import {
|
|
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
|
|
23
|
-
|
|
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
|
-
|
|
30
|
-
this.
|
|
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
|
|
45
|
-
|
|
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
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
@@ -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 { MaybePromise } from '@eclipse-glsp/protocol';
|
|
16
17
|
import { inject, injectable } from 'inversify';
|
|
17
|
-
import { MaybePromise } from '..';
|
|
18
18
|
import { Logger } from '../utils/logger';
|
|
19
19
|
import { Command } from './command';
|
|
20
20
|
|
|
@@ -29,9 +29,9 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
|
|
|
29
29
|
protected redoPatch?: jsonPatch.Operation[];
|
|
30
30
|
|
|
31
31
|
async execute(): Promise<void> {
|
|
32
|
-
const beforeState = this.deepClone(this.getJsonObject());
|
|
32
|
+
const beforeState = this.deepClone(await this.getJsonObject());
|
|
33
33
|
await this.doExecute();
|
|
34
|
-
const afterState = this.getJsonObject();
|
|
34
|
+
const afterState = await this.getJsonObject();
|
|
35
35
|
this.undoPatch = jsonPatch.compare(afterState, beforeState);
|
|
36
36
|
this.redoPatch = jsonPatch.compare(beforeState, afterState);
|
|
37
37
|
}
|
|
@@ -41,14 +41,14 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
|
|
|
41
41
|
* right after {@link AbstractRecordingCommand.doExecute} to derive the undo & redo patches.
|
|
42
42
|
* @returns The current state of the JSON object
|
|
43
43
|
*/
|
|
44
|
-
protected abstract getJsonObject(): JsonObject
|
|
44
|
+
protected abstract getJsonObject(): MaybePromise<JsonObject>;
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* The actual execution i.e. series of changes applied to the JSOn object that should be captured.
|
|
48
48
|
*/
|
|
49
49
|
protected abstract doExecute(): MaybePromise<void>;
|
|
50
50
|
|
|
51
|
-
protected applyPatch(object: JsonObject, patch: jsonPatch.Operation[]): void {
|
|
51
|
+
protected applyPatch(object: JsonObject, patch: jsonPatch.Operation[]): MaybePromise<void> {
|
|
52
52
|
jsonPatch.applyPatch(object, patch, false, true);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -62,15 +62,15 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
|
|
|
62
62
|
return jsonPatch.deepClone(object);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
undo(): void {
|
|
65
|
+
async undo(): Promise<void> {
|
|
66
66
|
if (this.undoPatch) {
|
|
67
|
-
this.applyPatch(this.getJsonObject(), this.undoPatch);
|
|
67
|
+
return this.applyPatch(await this.getJsonObject(), this.undoPatch);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
redo(): void {
|
|
71
|
+
async redo(): Promise<void> {
|
|
72
72
|
if (this.redoPatch) {
|
|
73
|
-
this.applyPatch(this.getJsonObject(), this.redoPatch);
|
|
73
|
+
return this.applyPatch(await this.getJsonObject(), this.redoPatch);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -88,7 +88,7 @@ export class RecordingCommand<JsonObject extends AnyObject = AnyObject> extends
|
|
|
88
88
|
super();
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
protected getJsonObject(): JsonObject {
|
|
91
|
+
protected getJsonObject(): MaybePromise<JsonObject> {
|
|
92
92
|
return this.jsonObject;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -107,11 +107,11 @@ export class GModelRecordingCommand extends AbstractRecordingCommand<GModelRootS
|
|
|
107
107
|
this.modelState.index.indexRoot(this.modelState.root);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
protected getJsonObject(): GModelRootSchema {
|
|
110
|
+
protected getJsonObject(): MaybePromise<GModelRootSchema> {
|
|
111
111
|
return this.serializer.createSchema(this.modelState.root);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
protected override applyPatch(rootSchema: GModelRootSchema, patch: jsonPatch.Operation[]): void {
|
|
114
|
+
protected override applyPatch(rootSchema: GModelRootSchema, patch: jsonPatch.Operation[]): MaybePromise<void> {
|
|
115
115
|
super.applyPatch(rootSchema, patch);
|
|
116
116
|
const newRoot = this.serializer.createRoot(rootSchema);
|
|
117
117
|
this.modelState.updateRoot(newRoot);
|
|
@@ -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 { GLSPClientProxy } from '@eclipse-glsp/protocol';
|
|
16
17
|
import { ContainerModule } from 'inversify';
|
|
17
|
-
import { GLSPClientProxy } from '../protocol/glsp-client-proxy';
|
|
18
18
|
import { ClientId } from './service-identifiers';
|
|
19
19
|
|
|
20
20
|
export function createClientSessionModule(clientId: string, glspClient: GLSPClientProxy): ContainerModule {
|
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
import { BindingContext } from '@eclipse-glsp/protocol';
|
|
16
17
|
import { ContainerModule, injectable, interfaces } from 'inversify';
|
|
17
18
|
import { AbstractMultiBinding } from './multi-binding';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* A wrapper interface to get access to the binding related functions
|
|
21
22
|
* for a inversify container.
|
|
23
|
+
* @deprecated Use `BindingContext` from `@eclipse-glsp/protocol` instead
|
|
22
24
|
*/
|
|
23
25
|
export interface ModuleContext {
|
|
24
26
|
bind: interfaces.Bind;
|
|
@@ -34,7 +36,7 @@ export interface ModuleContext {
|
|
|
34
36
|
export abstract class GLSPModule extends ContainerModule {
|
|
35
37
|
public static CLIENT_ACTIONS = 'ClientActions';
|
|
36
38
|
|
|
37
|
-
protected context:
|
|
39
|
+
protected context: BindingContext;
|
|
38
40
|
|
|
39
41
|
constructor() {
|
|
40
42
|
super((bind, unbind, isBound, rebind) => {
|
|
@@ -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 { distinctAdd, flatPush, MaybeArray, remove } from '@eclipse-glsp/protocol';
|
|
16
|
+
import { BindingContext, distinctAdd, flatPush, MaybeArray, remove } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { applyBindingTarget, BindingTarget } from './binding-target';
|
|
18
|
-
import { ModuleContext } from './glsp-module';
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* A helper class used in `GLSPModules` to ease the configuration of multi-injected service identifiers.
|
|
@@ -29,7 +28,7 @@ export abstract class AbstractMultiBinding<T> {
|
|
|
29
28
|
|
|
30
29
|
constructor(readonly identifier: string | symbol) {}
|
|
31
30
|
|
|
32
|
-
abstract applyBindings(context:
|
|
31
|
+
abstract applyBindings(context: BindingContext): void;
|
|
33
32
|
|
|
34
33
|
add(newBinding: T): void {
|
|
35
34
|
distinctAdd(this.bindings, newBinding);
|
|
@@ -71,7 +70,7 @@ export abstract class AbstractMultiBinding<T> {
|
|
|
71
70
|
* @typeparam T the base type of {@link BindingTarget}.
|
|
72
71
|
*/
|
|
73
72
|
export class MultiBinding<T> extends AbstractMultiBinding<BindingTarget<T>> {
|
|
74
|
-
applyBindings(context:
|
|
73
|
+
applyBindings(context: BindingContext): void {
|
|
75
74
|
this.bindings.forEach(binding => applyBindingTarget(context, this.identifier, binding));
|
|
76
75
|
}
|
|
77
76
|
}
|
|
@@ -83,7 +82,7 @@ export class MultiBinding<T> extends AbstractMultiBinding<BindingTarget<T>> {
|
|
|
83
82
|
* * @typeparam T the type of the instances
|
|
84
83
|
*/
|
|
85
84
|
export class InstanceMultiBinding<T> extends AbstractMultiBinding<T> {
|
|
86
|
-
applyBindings(context:
|
|
85
|
+
applyBindings(context: BindingContext): void {
|
|
87
86
|
context.bind(this.identifier).toConstantValue(this.bindings);
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -13,14 +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 { GLSPServer, GLSPServerListener } from '@eclipse-glsp/protocol';
|
|
16
17
|
import { ContainerModule, interfaces } from 'inversify';
|
|
17
18
|
import { DefaultGlobalActionProvider, GlobalActionProvider } from '../actions/global-action-provider';
|
|
18
|
-
import {
|
|
19
|
-
import { DefaultGLSPServer, GLSPServer, JsonRpcGLSPServer } from '../protocol/glsp-server';
|
|
20
|
-
import { GLSPServerListener } from '../protocol/glsp-server-listener';
|
|
19
|
+
import { DefaultGLSPServer } from '../protocol/glsp-server';
|
|
21
20
|
import { ClientSessionFactory, DefaultClientSessionFactory } from '../session/client-session-factory';
|
|
22
21
|
import { ClientSessionManager, DefaultClientSessionManager } from '../session/client-session-manager';
|
|
23
|
-
import {
|
|
22
|
+
import { BindingTarget, applyBindingTarget } from './binding-target';
|
|
24
23
|
import { DiagramModule } from './diagram-module';
|
|
25
24
|
import { GLSPModule } from './glsp-module';
|
|
26
25
|
import { MultiBinding } from './multi-binding';
|
|
@@ -74,7 +73,6 @@ export class ServerModule extends GLSPModule {
|
|
|
74
73
|
applyBindingTarget(context, DiagramModules, this.bindDiagramModules());
|
|
75
74
|
|
|
76
75
|
applyBindingTarget(context, GLSPServer, this.bindGLSPServer()).inSingletonScope();
|
|
77
|
-
applyBindingTarget(context, JsonRpcGLSPServer, this.bindJsonRpcGLSPServer());
|
|
78
76
|
applyBindingTarget(context, ClientSessionFactory, this.bindClientSessionFactory()).inSingletonScope();
|
|
79
77
|
applyBindingTarget(context, ClientSessionManager, this.bindClientSessionManager()).inSingletonScope();
|
|
80
78
|
this.configureMultiBinding(new MultiBinding<GLSPServerListener>(GLSPServerListener), binding =>
|
|
@@ -83,10 +81,9 @@ export class ServerModule extends GLSPModule {
|
|
|
83
81
|
|
|
84
82
|
applyBindingTarget(context, GlobalActionProvider, this.bindGlobalActionProvider()).inSingletonScope();
|
|
85
83
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
applyBindingTarget(context, JsonRpcGLSPClientProxy, this.bindJsonRpcGLSPClientProxy());
|
|
84
|
+
if (!isBound(InjectionContainer)) {
|
|
85
|
+
applyBindingTarget(context, InjectionContainer, this.bindInjectionContainer());
|
|
86
|
+
}
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
protected bindDiagramModules(): BindingTarget<Map<string, ContainerModule[]>> {
|
|
@@ -97,10 +94,6 @@ export class ServerModule extends GLSPModule {
|
|
|
97
94
|
return DefaultGLSPServer;
|
|
98
95
|
}
|
|
99
96
|
|
|
100
|
-
protected bindJsonRpcGLSPServer(): BindingTarget<JsonRpcGLSPServer> {
|
|
101
|
-
return { service: GLSPServer };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
97
|
protected bindClientSessionFactory(): BindingTarget<ClientSessionFactory> {
|
|
105
98
|
return DefaultClientSessionFactory;
|
|
106
99
|
}
|
|
@@ -117,14 +110,6 @@ export class ServerModule extends GLSPModule {
|
|
|
117
110
|
return { dynamicValue: context => context.container };
|
|
118
111
|
}
|
|
119
112
|
|
|
120
|
-
protected bindGLSPClientProxy(): BindingTarget<GLSPClientProxy> {
|
|
121
|
-
return DefaultGLSPClientProxy;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
protected bindJsonRpcGLSPClientProxy(): BindingTarget<JsonRpcGLSPClientProxy> {
|
|
125
|
-
return { service: GLSPClientProxy };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
113
|
protected configureGLSPServerListeners(binding: MultiBinding<GLSPServerListener>): void {
|
|
129
114
|
binding.add({ service: ClientSessionManager });
|
|
130
115
|
}
|
|
@@ -17,7 +17,7 @@ import { GModelRoot } from '@eclipse-glsp/graph';
|
|
|
17
17
|
import { Action, ComputedBoundsAction, MaybePromise } from '@eclipse-glsp/protocol';
|
|
18
18
|
import { inject, injectable } from 'inversify';
|
|
19
19
|
import { ActionHandler } from '../../actions/action-handler';
|
|
20
|
-
import { applyAlignment,
|
|
20
|
+
import { applyAlignment, applyElementAndBounds, applyRoute } from '../../utils/layout-util';
|
|
21
21
|
import { ModelState } from '../model/model-state';
|
|
22
22
|
import { ModelSubmissionHandler } from '../model/model-submission-handler';
|
|
23
23
|
|
|
@@ -47,7 +47,7 @@ export class ComputedBoundsActionHandler implements ActionHandler {
|
|
|
47
47
|
|
|
48
48
|
protected applyBounds(root: GModelRoot, action: ComputedBoundsAction): void {
|
|
49
49
|
const index = this.modelState.index;
|
|
50
|
-
action.bounds.forEach(bounds =>
|
|
50
|
+
action.bounds.forEach(bounds => applyElementAndBounds(bounds, index));
|
|
51
51
|
(action.alignments ?? []).forEach(alignment => applyAlignment(alignment, index));
|
|
52
52
|
(action.routes ?? []).forEach(route => applyRoute(route, index));
|
|
53
53
|
}
|
package/src/common/index.ts
CHANGED
|
@@ -23,6 +23,8 @@ export * from './actions/client-action-handler';
|
|
|
23
23
|
export * from './actions/global-action-provider';
|
|
24
24
|
export * from './command/command';
|
|
25
25
|
export * from './command/command-stack';
|
|
26
|
+
export * from './command/recording-command';
|
|
27
|
+
export * from './command/undo-redo-action-handler';
|
|
26
28
|
export * from './di/binding-target';
|
|
27
29
|
export * from './di/client-session-module';
|
|
28
30
|
export * from './di/diagram-module';
|
|
@@ -65,7 +67,6 @@ export * from './features/popup/popup-model-factory';
|
|
|
65
67
|
export * from './features/popup/request-popup-model-action-handler';
|
|
66
68
|
export * from './features/validation/model-validator';
|
|
67
69
|
export * from './features/validation/request-markers-handler';
|
|
68
|
-
export * from './gmodel/cut-operation-handler';
|
|
69
70
|
export * from './gmodel/index';
|
|
70
71
|
export * from './launch/glsp-server-launcher';
|
|
71
72
|
export * from './operations/compound-operation-handler';
|
|
@@ -73,9 +74,7 @@ export * from './operations/create-operation-handler';
|
|
|
73
74
|
export * from './operations/operation-action-handler';
|
|
74
75
|
export * from './operations/operation-handler';
|
|
75
76
|
export * from './operations/operation-handler-registry';
|
|
76
|
-
export * from './protocol/glsp-client-proxy';
|
|
77
77
|
export * from './protocol/glsp-server';
|
|
78
|
-
export * from './protocol/glsp-server-listener';
|
|
79
78
|
export * from './session/client-session';
|
|
80
79
|
export * from './session/client-session-factory';
|
|
81
80
|
export * from './session/client-session-initializer';
|
|
@@ -83,7 +82,9 @@ export * from './session/client-session-listener';
|
|
|
83
82
|
export * from './session/client-session-manager';
|
|
84
83
|
export * from './utils/args-util';
|
|
85
84
|
export * from './utils/client-options-util';
|
|
85
|
+
export * from './utils/console-logger';
|
|
86
86
|
export * from './utils/glsp-server-error';
|
|
87
|
+
export * from './utils/layout-util';
|
|
87
88
|
export * from './utils/logger';
|
|
88
89
|
export * from './utils/promise-queue';
|
|
89
90
|
export * from './utils/registry';
|