@theia/plugin-ext 1.20.0 → 1.21.0-next.11
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/common/connection.d.ts +47 -33
- package/lib/common/connection.d.ts.map +1 -1
- package/lib/common/connection.js +90 -28
- package/lib/common/connection.js.map +1 -1
- package/lib/common/plugin-api-rpc.d.ts +0 -2
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/plugin-protocol.d.ts +1 -0
- package/lib/common/plugin-protocol.d.ts.map +1 -1
- package/lib/common/plugin-protocol.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin.js +1 -1
- package/lib/hosted/browser/hosted-plugin.js.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.js +4 -1
- package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
- package/lib/main/browser/debug/debug-main.d.ts +3 -3
- package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
- package/lib/main/browser/debug/debug-main.js +1 -2
- package/lib/main/browser/debug/debug-main.js.map +1 -1
- package/lib/main/browser/debug/plugin-debug-session-factory.d.ts +4 -4
- package/lib/main/browser/debug/plugin-debug-session-factory.d.ts.map +1 -1
- package/lib/main/browser/debug/plugin-debug-session-factory.js +1 -1
- package/lib/main/browser/debug/plugin-debug-session-factory.js.map +1 -1
- package/lib/main/browser/file-system-main-impl.js +1 -1
- package/lib/main/browser/file-system-main-impl.js.map +1 -1
- package/lib/main/browser/main-context.js +2 -2
- package/lib/main/browser/main-context.js.map +1 -1
- package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
- package/lib/main/browser/view/plugin-view-registry.js +14 -3
- package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
- package/lib/plugin/node/debug/debug.d.ts +4 -4
- package/lib/plugin/node/debug/debug.d.ts.map +1 -1
- package/lib/plugin/node/debug/debug.js +3 -4
- package/lib/plugin/node/debug/debug.js.map +1 -1
- package/lib/plugin/node/debug/plugin-debug-adapter-session.d.ts +7 -7
- package/lib/plugin/node/debug/plugin-debug-adapter-session.d.ts.map +1 -1
- package/lib/plugin/node/debug/plugin-debug-adapter-session.js +6 -6
- package/lib/plugin/node/debug/plugin-debug-adapter-session.js.map +1 -1
- package/lib/plugin/node/debug/plugin-debug-adapter-starter.d.ts +7 -5
- package/lib/plugin/node/debug/plugin-debug-adapter-starter.d.ts.map +1 -1
- package/lib/plugin/node/debug/plugin-debug-adapter-starter.js +6 -13
- package/lib/plugin/node/debug/plugin-debug-adapter-starter.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +2 -2
- package/lib/plugin/plugin-context.js.map +1 -1
- package/package.json +23 -23
- package/src/common/connection.ts +98 -41
- package/src/common/plugin-api-rpc.ts +0 -2
- package/src/common/plugin-protocol.ts +1 -0
- package/src/hosted/browser/hosted-plugin.ts +1 -1
- package/src/hosted/node/scanners/scanner-theia.ts +4 -1
- package/src/main/browser/debug/debug-main.ts +3 -4
- package/src/main/browser/debug/plugin-debug-session-factory.ts +3 -3
- package/src/main/browser/file-system-main-impl.ts +1 -1
- package/src/main/browser/main-context.ts +3 -3
- package/src/main/browser/view/plugin-view-registry.ts +16 -3
- package/src/plugin/node/debug/debug.ts +7 -8
- package/src/plugin/node/debug/plugin-debug-adapter-session.ts +9 -9
- package/src/plugin/node/debug/plugin-debug-adapter-starter.ts +11 -18
- package/src/plugin/plugin-context.ts +4 -3
- package/lib/common/plugin-message-reader.d.ts +0 -46
- package/lib/common/plugin-message-reader.d.ts.map +0 -1
- package/lib/common/plugin-message-reader.js +0 -116
- package/lib/common/plugin-message-reader.js.map +0 -1
- package/lib/common/plugin-message-writer.d.ts +0 -38
- package/lib/common/plugin-message-writer.d.ts.map +0 -1
- package/lib/common/plugin-message-writer.js +0 -67
- package/lib/common/plugin-message-writer.js.map +0 -1
- package/lib/main/browser/connection-main.d.ts +0 -59
- package/lib/main/browser/connection-main.d.ts.map +0 -1
- package/lib/main/browser/connection-main.js +0 -98
- package/lib/main/browser/connection-main.js.map +0 -1
- package/lib/plugin/connection-ext.d.ts +0 -56
- package/lib/plugin/connection-ext.d.ts.map +0 -1
- package/lib/plugin/connection-ext.js +0 -88
- package/lib/plugin/connection-ext.js.map +0 -1
- package/src/common/plugin-message-reader.ts +0 -111
- package/src/common/plugin-message-writer.ts +0 -65
- package/src/main/browser/connection-main.ts +0 -107
- package/src/plugin/connection-ext.ts +0 -95
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-main.js","sourceRoot":"","sources":["../../../src/main/browser/connection-main.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,kEAAqF;AACrF,gEAA8F;AAE9F,wDAA2D;AAC3D,8EAAyE;AACzE,8EAAyE;AAEzE;;;GAGG;AACH,MAAa,kBAAkB;IAK3B,YAAY,GAAgB;QAFX,gBAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;QAClD,cAAS,GAAG,IAAI,iCAAoB,EAAE,CAAC;QAEpD,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,iCAAgB,CAAC,cAAc,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO;QACH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,OAAe;QAC1C,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAC1B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;SACzD;aAAM;YACH,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;SAC1E;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iBAAiB,CAAC,EAAU;QAC9B,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iBAAiB,CAAC,EAAU;QAC9B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,gBAAgB,CAAC,EAAU;QAC7B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACvC,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,kBAAkB,CAAC,EAAU;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QACrC,OAAO,UAAU,CAAC;IACtB,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,EAAU;QACzC,MAAM,MAAM,GAAG,IAAI,2CAAmB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,2CAAmB,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACvD,MAAM,UAAU,GAAG,IAAI,6BAAgB,CACnC,MAAM,EACN,MAAM,EACN,GAAG,EAAE;YACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACnB,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;aACpC;QACL,CAAC,CAAC,CAAC;QACP,MAAM,OAAO,GAAG,IAAI,iCAAoB,CAAC,uBAAU,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACtF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AA/ED,gDA+EC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (C) 2018 Red Hat, Inc. 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
|
-
import { ConnectionExt } from '../common/plugin-api-rpc';
|
|
17
|
-
import { RPCProtocol } from '../common/rpc-protocol';
|
|
18
|
-
import { PluginConnection } from '../common/connection';
|
|
19
|
-
/**
|
|
20
|
-
* Implementation of connection system of the plugin API.
|
|
21
|
-
* It allows to communicate with main side to send and read messages.
|
|
22
|
-
*/
|
|
23
|
-
export declare class ConnectionExtImpl implements ConnectionExt {
|
|
24
|
-
private proxy;
|
|
25
|
-
private connections;
|
|
26
|
-
constructor(rpc: RPCProtocol);
|
|
27
|
-
/**
|
|
28
|
-
* Gets the connection between plugin by id and sends string message to it.
|
|
29
|
-
*
|
|
30
|
-
* @param id connection's id
|
|
31
|
-
* @param message incoming message
|
|
32
|
-
*/
|
|
33
|
-
$sendMessage(id: string, message: string): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Instantiates a new connection by the given id.
|
|
36
|
-
* @param id the connection id
|
|
37
|
-
*/
|
|
38
|
-
$createConnection(id: string): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Deletes a connection.
|
|
41
|
-
* @param id the connection id
|
|
42
|
-
*/
|
|
43
|
-
$deleteConnection(id: string): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Returns existed connection or creates a new one.
|
|
46
|
-
* @param id the connection id
|
|
47
|
-
*/
|
|
48
|
-
ensureConnection(id: string): Promise<PluginConnection>;
|
|
49
|
-
/**
|
|
50
|
-
* Returns existed connection or creates a new one.
|
|
51
|
-
* @param id the connection id
|
|
52
|
-
*/
|
|
53
|
-
doEnsureConnection(id: string): Promise<PluginConnection>;
|
|
54
|
-
protected doCreateConnection(id: string): Promise<PluginConnection>;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=connection-ext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-ext.d.ts","sourceRoot":"","sources":["../../src/plugin/connection-ext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,aAAa,EAAsC,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,aAAa;IACnD,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,WAAW,CAAuC;gBAC9C,GAAG,EAAE,WAAW;IAI5B;;;;;OAKG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9D;;;OAGG;IACG,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;;OAGG;IACG,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;;OAGG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAM7D;;;OAGG;IACG,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;cAM/C,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAW5E"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/********************************************************************************
|
|
3
|
-
* Copyright (C) 2018 Red Hat, Inc. 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.ConnectionExtImpl = void 0;
|
|
19
|
-
const plugin_api_rpc_1 = require("../common/plugin-api-rpc");
|
|
20
|
-
const connection_1 = require("../common/connection");
|
|
21
|
-
const plugin_message_reader_1 = require("../common/plugin-message-reader");
|
|
22
|
-
const plugin_message_writer_1 = require("../common/plugin-message-writer");
|
|
23
|
-
/**
|
|
24
|
-
* Implementation of connection system of the plugin API.
|
|
25
|
-
* It allows to communicate with main side to send and read messages.
|
|
26
|
-
*/
|
|
27
|
-
class ConnectionExtImpl {
|
|
28
|
-
constructor(rpc) {
|
|
29
|
-
this.connections = new Map();
|
|
30
|
-
this.proxy = rpc.getProxy(plugin_api_rpc_1.PLUGIN_RPC_CONTEXT.CONNECTION_MAIN);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Gets the connection between plugin by id and sends string message to it.
|
|
34
|
-
*
|
|
35
|
-
* @param id connection's id
|
|
36
|
-
* @param message incoming message
|
|
37
|
-
*/
|
|
38
|
-
async $sendMessage(id, message) {
|
|
39
|
-
if (this.connections.has(id)) {
|
|
40
|
-
this.connections.get(id).reader.readMessage(message);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
console.warn('It is not possible to read message. Connection missed.');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Instantiates a new connection by the given id.
|
|
48
|
-
* @param id the connection id
|
|
49
|
-
*/
|
|
50
|
-
async $createConnection(id) {
|
|
51
|
-
await this.doEnsureConnection(id);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Deletes a connection.
|
|
55
|
-
* @param id the connection id
|
|
56
|
-
*/
|
|
57
|
-
async $deleteConnection(id) {
|
|
58
|
-
this.connections.delete(id);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Returns existed connection or creates a new one.
|
|
62
|
-
* @param id the connection id
|
|
63
|
-
*/
|
|
64
|
-
async ensureConnection(id) {
|
|
65
|
-
const connection = await this.doEnsureConnection(id);
|
|
66
|
-
this.proxy.$createConnection(id);
|
|
67
|
-
return connection;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Returns existed connection or creates a new one.
|
|
71
|
-
* @param id the connection id
|
|
72
|
-
*/
|
|
73
|
-
async doEnsureConnection(id) {
|
|
74
|
-
const connection = this.connections.get(id) || await this.doCreateConnection(id);
|
|
75
|
-
this.connections.set(id, connection);
|
|
76
|
-
return connection;
|
|
77
|
-
}
|
|
78
|
-
async doCreateConnection(id) {
|
|
79
|
-
const reader = new plugin_message_reader_1.PluginMessageReader();
|
|
80
|
-
const writer = new plugin_message_writer_1.PluginMessageWriter(id, this.proxy);
|
|
81
|
-
return new connection_1.PluginConnection(reader, writer, () => {
|
|
82
|
-
this.connections.delete(id);
|
|
83
|
-
this.proxy.$deleteConnection(id);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.ConnectionExtImpl = ConnectionExtImpl;
|
|
88
|
-
//# sourceMappingURL=connection-ext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-ext.js","sourceRoot":"","sources":["../../src/plugin/connection-ext.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,6DAA6F;AAE7F,qDAAwD;AACxD,2EAAsE;AACtE,2EAAsE;AAEtE;;;GAGG;AACH,MAAa,iBAAiB;IAG1B,YAAY,GAAgB;QADpB,gBAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;QAEtD,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,mCAAkB,CAAC,eAAe,CAAC,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,OAAe;QAC1C,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;YAC1B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;SACzD;aAAM;YACH,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;SAC1E;IACL,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iBAAiB,CAAC,EAAU;QAC9B,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,iBAAiB,CAAC,EAAU;QAC9B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,gBAAgB,CAAC,EAAU;QAC7B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACjC,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,kBAAkB,CAAC,EAAU;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,MAAM,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QACrC,OAAO,UAAU,CAAC;IACtB,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,EAAU;QACzC,MAAM,MAAM,GAAG,IAAI,2CAAmB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,2CAAmB,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,IAAI,6BAAgB,CACvB,MAAM,EACN,MAAM,EACN,GAAG,EAAE;YACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AApED,8CAoEC"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (C) 2018 Red Hat, Inc. 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 { DataCallback, Emitter, Event, PartialMessageInfo } from '@theia/core/shared/vscode-ws-jsonrpc';
|
|
18
|
-
|
|
19
|
-
export abstract class AbstractMessageReader {
|
|
20
|
-
protected errorEmitter = new Emitter<Error>();
|
|
21
|
-
protected closeEmitter = new Emitter<void>();
|
|
22
|
-
protected partialMessageEmitter = new Emitter<PartialMessageInfo>();
|
|
23
|
-
dispose(): void {
|
|
24
|
-
this.errorEmitter.dispose();
|
|
25
|
-
this.closeEmitter.dispose();
|
|
26
|
-
}
|
|
27
|
-
get onError(): Event<Error> {
|
|
28
|
-
return this.errorEmitter.event;
|
|
29
|
-
}
|
|
30
|
-
fireError(error: Error): void {
|
|
31
|
-
this.errorEmitter.fire(this.asError(error));
|
|
32
|
-
}
|
|
33
|
-
get onClose(): Event<void> {
|
|
34
|
-
return this.closeEmitter.event;
|
|
35
|
-
}
|
|
36
|
-
fireClose(): void {
|
|
37
|
-
this.closeEmitter.fire(undefined);
|
|
38
|
-
}
|
|
39
|
-
get onPartialMessage(): Event<PartialMessageInfo> {
|
|
40
|
-
return this.partialMessageEmitter.event;
|
|
41
|
-
}
|
|
42
|
-
firePartialMessage(info: PartialMessageInfo): void {
|
|
43
|
-
this.partialMessageEmitter.fire(info);
|
|
44
|
-
}
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
-
asError(error: any): Error {
|
|
47
|
-
if (error instanceof Error) {
|
|
48
|
-
return error;
|
|
49
|
-
} else {
|
|
50
|
-
return new Error(`Reader received error. Reason: ${typeof error.message === 'string' ? error.message : 'unknown'}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Support for reading string message through RPC protocol.
|
|
57
|
-
*/
|
|
58
|
-
export class PluginMessageReader extends AbstractMessageReader {
|
|
59
|
-
protected state: 'initial' | 'listening' | 'closed' = 'initial';
|
|
60
|
-
protected callback: DataCallback | undefined;
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
protected readonly events: { message?: any, error?: any }[] = [];
|
|
63
|
-
|
|
64
|
-
constructor() {
|
|
65
|
-
super();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
listen(callback: DataCallback): void {
|
|
69
|
-
if (this.state === 'initial') {
|
|
70
|
-
this.state = 'listening';
|
|
71
|
-
this.callback = callback;
|
|
72
|
-
while (this.events.length !== 0) {
|
|
73
|
-
const event = this.events.pop()!;
|
|
74
|
-
if (event.message) {
|
|
75
|
-
this.readMessage(event.message);
|
|
76
|
-
} else if (event.error) {
|
|
77
|
-
this.fireError(event.error);
|
|
78
|
-
} else {
|
|
79
|
-
this.fireClose();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
readMessage(message: string): void {
|
|
86
|
-
if (this.state === 'initial') {
|
|
87
|
-
this.events.splice(0, 0, { message });
|
|
88
|
-
} else if (this.state === 'listening') {
|
|
89
|
-
const data = JSON.parse(message);
|
|
90
|
-
this.callback!(data);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
-
fireError(error: any): void {
|
|
96
|
-
if (this.state === 'initial') {
|
|
97
|
-
this.events.splice(0, 0, { error });
|
|
98
|
-
} else if (this.state === 'listening') {
|
|
99
|
-
super.fireError(error);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
fireClose(): void {
|
|
104
|
-
if (this.state === 'initial') {
|
|
105
|
-
this.events.splice(0, 0, {});
|
|
106
|
-
} else if (this.state === 'listening') {
|
|
107
|
-
super.fireClose();
|
|
108
|
-
}
|
|
109
|
-
this.state = 'closed';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (C) 2018 Red Hat, Inc. 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 { Message, MessageWriter, Emitter, Event } from '@theia/core/shared/vscode-ws-jsonrpc';
|
|
18
|
-
import { ConnectionMain, ConnectionExt } from './plugin-api-rpc';
|
|
19
|
-
|
|
20
|
-
export abstract class AbstractMessageWriter {
|
|
21
|
-
protected errorEmitter = new Emitter<[Error, Message | undefined, number | undefined]>();
|
|
22
|
-
protected closeEmitter = new Emitter<void>();
|
|
23
|
-
dispose(): void {
|
|
24
|
-
this.errorEmitter.dispose();
|
|
25
|
-
this.closeEmitter.dispose();
|
|
26
|
-
}
|
|
27
|
-
get onError(): Event<[Error, Message | undefined, number | undefined]> {
|
|
28
|
-
return this.errorEmitter.event;
|
|
29
|
-
}
|
|
30
|
-
fireError(error: Error, message: Message | undefined, count: number | undefined): void {
|
|
31
|
-
this.errorEmitter.fire([this.asError(error), message, count]);
|
|
32
|
-
}
|
|
33
|
-
get onClose(): Event<void> {
|
|
34
|
-
return this.closeEmitter.event;
|
|
35
|
-
}
|
|
36
|
-
fireClose(): void {
|
|
37
|
-
this.closeEmitter.fire(undefined);
|
|
38
|
-
}
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
asError(error: any): Error {
|
|
41
|
-
if (error instanceof Error) {
|
|
42
|
-
return error;
|
|
43
|
-
} else {
|
|
44
|
-
return new Error(`Writer received error. Reason: ${typeof error.message === 'string' ? error.message : 'unknown'}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Support for writing string message through RPC protocol.
|
|
51
|
-
*/
|
|
52
|
-
export class PluginMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
|
53
|
-
constructor(
|
|
54
|
-
protected readonly id: string,
|
|
55
|
-
protected readonly proxy: ConnectionMain | ConnectionExt) {
|
|
56
|
-
super();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
write(message: string): void;
|
|
60
|
-
write(message: Message): void;
|
|
61
|
-
write(arg: string | Message): void {
|
|
62
|
-
const content = JSON.stringify(arg);
|
|
63
|
-
this.proxy.$sendMessage(this.id, content);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (C) 2018 Red Hat, Inc. 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 { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
|
|
18
|
-
import { MAIN_RPC_CONTEXT, ConnectionMain, ConnectionExt } from '../../common/plugin-api-rpc';
|
|
19
|
-
import { RPCProtocol } from '../../common/rpc-protocol';
|
|
20
|
-
import { PluginConnection } from '../../common/connection';
|
|
21
|
-
import { PluginMessageReader } from '../../common/plugin-message-reader';
|
|
22
|
-
import { PluginMessageWriter } from '../../common/plugin-message-writer';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Implementation of connection system of the plugin API.
|
|
26
|
-
* Creates holds the connections to the plugins. Allows to send a message to the plugin by getting already created connection via id.
|
|
27
|
-
*/
|
|
28
|
-
export class ConnectionMainImpl implements ConnectionMain, Disposable {
|
|
29
|
-
|
|
30
|
-
private readonly proxy: ConnectionExt;
|
|
31
|
-
private readonly connections = new Map<string, PluginConnection>();
|
|
32
|
-
private readonly toDispose = new DisposableCollection();
|
|
33
|
-
constructor(rpc: RPCProtocol) {
|
|
34
|
-
this.proxy = rpc.getProxy(MAIN_RPC_CONTEXT.CONNECTION_EXT);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
dispose(): void {
|
|
38
|
-
this.toDispose.dispose();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Gets the connection between plugin by id and sends string message to it.
|
|
43
|
-
*
|
|
44
|
-
* @param id connection's id
|
|
45
|
-
* @param message incoming message
|
|
46
|
-
*/
|
|
47
|
-
async $sendMessage(id: string, message: string): Promise<void> {
|
|
48
|
-
if (this.connections.has(id)) {
|
|
49
|
-
this.connections.get(id)!.reader.readMessage(message);
|
|
50
|
-
} else {
|
|
51
|
-
console.warn('It is not possible to read message. Connection missed.');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Instantiates a new connection by the given id.
|
|
57
|
-
* @param id the connection id
|
|
58
|
-
*/
|
|
59
|
-
async $createConnection(id: string): Promise<void> {
|
|
60
|
-
await this.doEnsureConnection(id);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Deletes a connection.
|
|
65
|
-
* @param id the connection id
|
|
66
|
-
*/
|
|
67
|
-
async $deleteConnection(id: string): Promise<void> {
|
|
68
|
-
this.connections.delete(id);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Returns existed connection or creates a new one.
|
|
73
|
-
* @param id the connection id
|
|
74
|
-
*/
|
|
75
|
-
async ensureConnection(id: string): Promise<PluginConnection> {
|
|
76
|
-
const connection = await this.doEnsureConnection(id);
|
|
77
|
-
await this.proxy.$createConnection(id);
|
|
78
|
-
return connection;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Returns existed connection or creates a new one.
|
|
83
|
-
* @param id the connection id
|
|
84
|
-
*/
|
|
85
|
-
async doEnsureConnection(id: string): Promise<PluginConnection> {
|
|
86
|
-
const connection = this.connections.get(id) || await this.doCreateConnection(id);
|
|
87
|
-
this.connections.set(id, connection);
|
|
88
|
-
return connection;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
protected async doCreateConnection(id: string): Promise<PluginConnection> {
|
|
92
|
-
const reader = new PluginMessageReader();
|
|
93
|
-
const writer = new PluginMessageWriter(id, this.proxy);
|
|
94
|
-
const connection = new PluginConnection(
|
|
95
|
-
reader,
|
|
96
|
-
writer,
|
|
97
|
-
() => {
|
|
98
|
-
this.connections.delete(id);
|
|
99
|
-
if (!toClose.disposed) {
|
|
100
|
-
this.proxy.$deleteConnection(id);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
const toClose = new DisposableCollection(Disposable.create(() => reader.fireClose()));
|
|
104
|
-
this.toDispose.push(toClose);
|
|
105
|
-
return connection;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (C) 2018 Red Hat, Inc. 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 { ConnectionExt, PLUGIN_RPC_CONTEXT, ConnectionMain } from '../common/plugin-api-rpc';
|
|
18
|
-
import { RPCProtocol } from '../common/rpc-protocol';
|
|
19
|
-
import { PluginConnection } from '../common/connection';
|
|
20
|
-
import { PluginMessageReader } from '../common/plugin-message-reader';
|
|
21
|
-
import { PluginMessageWriter } from '../common/plugin-message-writer';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Implementation of connection system of the plugin API.
|
|
25
|
-
* It allows to communicate with main side to send and read messages.
|
|
26
|
-
*/
|
|
27
|
-
export class ConnectionExtImpl implements ConnectionExt {
|
|
28
|
-
private proxy: ConnectionMain;
|
|
29
|
-
private connections = new Map<string, PluginConnection>();
|
|
30
|
-
constructor(rpc: RPCProtocol) {
|
|
31
|
-
this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.CONNECTION_MAIN);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Gets the connection between plugin by id and sends string message to it.
|
|
36
|
-
*
|
|
37
|
-
* @param id connection's id
|
|
38
|
-
* @param message incoming message
|
|
39
|
-
*/
|
|
40
|
-
async $sendMessage(id: string, message: string): Promise<void> {
|
|
41
|
-
if (this.connections.has(id)) {
|
|
42
|
-
this.connections.get(id)!.reader.readMessage(message);
|
|
43
|
-
} else {
|
|
44
|
-
console.warn('It is not possible to read message. Connection missed.');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Instantiates a new connection by the given id.
|
|
50
|
-
* @param id the connection id
|
|
51
|
-
*/
|
|
52
|
-
async $createConnection(id: string): Promise<void> {
|
|
53
|
-
await this.doEnsureConnection(id);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Deletes a connection.
|
|
58
|
-
* @param id the connection id
|
|
59
|
-
*/
|
|
60
|
-
async $deleteConnection(id: string): Promise<void> {
|
|
61
|
-
this.connections.delete(id);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Returns existed connection or creates a new one.
|
|
66
|
-
* @param id the connection id
|
|
67
|
-
*/
|
|
68
|
-
async ensureConnection(id: string): Promise<PluginConnection> {
|
|
69
|
-
const connection = await this.doEnsureConnection(id);
|
|
70
|
-
this.proxy.$createConnection(id);
|
|
71
|
-
return connection;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Returns existed connection or creates a new one.
|
|
76
|
-
* @param id the connection id
|
|
77
|
-
*/
|
|
78
|
-
async doEnsureConnection(id: string): Promise<PluginConnection> {
|
|
79
|
-
const connection = this.connections.get(id) || await this.doCreateConnection(id);
|
|
80
|
-
this.connections.set(id, connection);
|
|
81
|
-
return connection;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
protected async doCreateConnection(id: string): Promise<PluginConnection> {
|
|
85
|
-
const reader = new PluginMessageReader();
|
|
86
|
-
const writer = new PluginMessageWriter(id, this.proxy);
|
|
87
|
-
return new PluginConnection(
|
|
88
|
-
reader,
|
|
89
|
-
writer,
|
|
90
|
-
() => {
|
|
91
|
-
this.connections.delete(id);
|
|
92
|
-
this.proxy.$deleteConnection(id);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|