@opensumi/ide-connection 2.27.3-rc-1706687185.0 → 2.27.3-rc-1708222409.0
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/ws-channel-handler.d.ts.map +1 -1
- package/lib/browser/ws-channel-handler.js +2 -6
- package/lib/browser/ws-channel-handler.js.map +1 -1
- package/lib/common/{connection → buffers}/buffers.d.ts +2 -1
- package/lib/common/buffers/buffers.d.ts.map +1 -0
- package/lib/common/{connection → buffers}/buffers.js +21 -3
- package/lib/common/buffers/buffers.js.map +1 -0
- package/lib/common/connection/drivers/base.d.ts +2 -2
- package/lib/common/connection/drivers/base.d.ts.map +1 -1
- package/lib/common/connection/drivers/base.js +0 -4
- package/lib/common/connection/drivers/base.js.map +1 -1
- package/lib/common/connection/drivers/frame-decoder.d.ts +34 -0
- package/lib/common/connection/drivers/frame-decoder.d.ts.map +1 -0
- package/lib/common/connection/drivers/frame-decoder.js +147 -0
- package/lib/common/connection/drivers/frame-decoder.js.map +1 -0
- package/lib/common/connection/drivers/{empty.d.ts → message-port.d.ts} +5 -2
- package/lib/common/connection/drivers/message-port.d.ts.map +1 -0
- package/lib/common/connection/drivers/message-port.js +41 -0
- package/lib/common/connection/drivers/message-port.js.map +1 -0
- package/lib/common/connection/drivers/node-message-port.d.ts +1 -0
- package/lib/common/connection/drivers/node-message-port.d.ts.map +1 -1
- package/lib/common/connection/drivers/node-message-port.js +3 -0
- package/lib/common/connection/drivers/node-message-port.js.map +1 -1
- package/lib/common/connection/drivers/reconnecting-websocket.d.ts +1 -0
- package/lib/common/connection/drivers/reconnecting-websocket.d.ts.map +1 -1
- package/lib/common/connection/drivers/reconnecting-websocket.js +3 -0
- package/lib/common/connection/drivers/reconnecting-websocket.js.map +1 -1
- package/lib/common/connection/drivers/simple.d.ts +17 -0
- package/lib/common/connection/drivers/simple.d.ts.map +1 -0
- package/lib/common/connection/drivers/simple.js +32 -0
- package/lib/common/connection/drivers/simple.js.map +1 -0
- package/lib/common/connection/drivers/socket.d.ts +4 -2
- package/lib/common/connection/drivers/socket.d.ts.map +1 -1
- package/lib/common/connection/drivers/socket.js +10 -7
- package/lib/common/connection/drivers/socket.js.map +1 -1
- package/lib/common/connection/drivers/ws-websocket.d.ts +2 -0
- package/lib/common/connection/drivers/ws-websocket.d.ts.map +1 -1
- package/lib/common/connection/drivers/ws-websocket.js +6 -0
- package/lib/common/connection/drivers/ws-websocket.js.map +1 -1
- package/lib/common/connection/types.d.ts +1 -1
- package/lib/common/connection/types.d.ts.map +1 -1
- package/lib/common/ext-rpc-protocol.d.ts +7 -21
- package/lib/common/ext-rpc-protocol.d.ts.map +1 -1
- package/lib/common/ext-rpc-protocol.js +13 -33
- package/lib/common/ext-rpc-protocol.js.map +1 -1
- package/lib/common/fury-extends/any.d.ts +22 -0
- package/lib/common/fury-extends/any.d.ts.map +1 -0
- package/lib/common/fury-extends/any.js +143 -0
- package/lib/common/fury-extends/any.js.map +1 -0
- package/lib/common/fury-extends/one-of.d.ts +14 -0
- package/lib/common/fury-extends/one-of.d.ts.map +1 -0
- package/lib/common/fury-extends/one-of.js +50 -0
- package/lib/common/fury-extends/one-of.js.map +1 -0
- package/lib/common/fury-extends/shared.d.ts +142 -0
- package/lib/common/fury-extends/shared.d.ts.map +1 -0
- package/lib/common/fury-extends/shared.js +17 -0
- package/lib/common/fury-extends/shared.js.map +1 -0
- package/lib/common/index.d.ts +2 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +2 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/protocols/common-server.d.ts +3 -0
- package/lib/common/protocols/common-server.d.ts.map +1 -0
- package/lib/common/protocols/common-server.js +18 -0
- package/lib/common/protocols/common-server.js.map +1 -0
- package/lib/common/protocols/common.d.ts +24 -0
- package/lib/common/protocols/common.d.ts.map +1 -0
- package/lib/common/protocols/common.js +12 -0
- package/lib/common/protocols/common.js.map +1 -0
- package/lib/common/rpc/connection.d.ts +44 -0
- package/lib/common/rpc/connection.d.ts.map +1 -0
- package/lib/common/rpc/connection.js +256 -0
- package/lib/common/rpc/connection.js.map +1 -0
- package/lib/common/rpc/errors.d.ts +4 -0
- package/lib/common/rpc/errors.d.ts.map +1 -0
- package/lib/common/rpc/errors.js +10 -0
- package/lib/common/rpc/errors.js.map +1 -0
- package/lib/common/rpc/index.d.ts +3 -0
- package/lib/common/rpc/index.d.ts.map +1 -0
- package/lib/common/rpc/index.js +6 -0
- package/lib/common/rpc/index.js.map +1 -0
- package/lib/common/rpc/multiplexer.d.ts +28 -0
- package/lib/common/rpc/multiplexer.d.ts.map +1 -0
- package/lib/common/rpc/multiplexer.js +82 -0
- package/lib/common/rpc/multiplexer.js.map +1 -0
- package/lib/common/rpc/packet.d.ts +65 -0
- package/lib/common/rpc/packet.d.ts.map +1 -0
- package/lib/common/rpc/packet.js +82 -0
- package/lib/common/rpc/packet.js.map +1 -0
- package/lib/common/rpc/protocol-repository.d.ts +32 -0
- package/lib/common/rpc/protocol-repository.d.ts.map +1 -0
- package/lib/common/rpc/protocol-repository.js +118 -0
- package/lib/common/rpc/protocol-repository.js.map +1 -0
- package/lib/common/rpc/types.d.ts +13 -0
- package/lib/common/rpc/types.d.ts.map +1 -0
- package/lib/common/rpc/types.js +3 -0
- package/lib/common/rpc/types.js.map +1 -0
- package/lib/common/rpc/utils.d.ts +2 -0
- package/lib/common/rpc/utils.d.ts.map +1 -0
- package/lib/common/rpc/utils.js +10 -0
- package/lib/common/rpc/utils.js.map +1 -0
- package/lib/common/rpc-service/center.d.ts +12 -5
- package/lib/common/rpc-service/center.d.ts.map +1 -1
- package/lib/common/rpc-service/center.js +47 -42
- package/lib/common/rpc-service/center.js.map +1 -1
- package/lib/common/rpc-service/index.d.ts +6 -0
- package/lib/common/rpc-service/index.d.ts.map +1 -1
- package/lib/common/rpc-service/index.js +7 -0
- package/lib/common/rpc-service/index.js.map +1 -1
- package/lib/common/rpc-service/proxy/base.d.ts +32 -0
- package/lib/common/rpc-service/proxy/base.d.ts.map +1 -0
- package/lib/common/rpc-service/proxy/base.js +93 -0
- package/lib/common/rpc-service/proxy/base.js.map +1 -0
- package/lib/common/rpc-service/proxy/index.d.ts +5 -0
- package/lib/common/rpc-service/proxy/index.d.ts.map +1 -0
- package/lib/common/rpc-service/proxy/index.js +8 -0
- package/lib/common/rpc-service/proxy/index.js.map +1 -0
- package/lib/common/rpc-service/proxy/invoker.d.ts +14 -0
- package/lib/common/rpc-service/proxy/invoker.d.ts.map +1 -0
- package/lib/common/rpc-service/proxy/invoker.js +34 -0
- package/lib/common/rpc-service/proxy/invoker.js.map +1 -0
- package/lib/common/{proxy → rpc-service/proxy}/legacy.d.ts +3 -7
- package/lib/common/rpc-service/proxy/legacy.d.ts.map +1 -0
- package/lib/common/rpc-service/proxy/legacy.js +136 -0
- package/lib/common/rpc-service/proxy/legacy.js.map +1 -0
- package/lib/common/rpc-service/proxy/registry.d.ts +18 -0
- package/lib/common/rpc-service/proxy/registry.d.ts.map +1 -0
- package/lib/common/rpc-service/proxy/registry.js +46 -0
- package/lib/common/rpc-service/proxy/registry.js.map +1 -0
- package/lib/common/rpc-service/proxy/sumi.d.ts +9 -0
- package/lib/common/rpc-service/proxy/sumi.d.ts.map +1 -0
- package/lib/common/rpc-service/proxy/sumi.js +86 -0
- package/lib/common/rpc-service/proxy/sumi.js.map +1 -0
- package/lib/common/rpc-service/stub.d.ts +0 -1
- package/lib/common/rpc-service/stub.d.ts.map +1 -1
- package/lib/common/rpc-service/stub.js +3 -11
- package/lib/common/rpc-service/stub.js.map +1 -1
- package/lib/common/types.d.ts +1 -1
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/ws-channel.d.ts +97 -32
- package/lib/common/ws-channel.d.ts.map +1 -1
- package/lib/common/ws-channel.js +75 -51
- package/lib/common/ws-channel.js.map +1 -1
- package/lib/node/common-channel-handler.js +1 -1
- package/lib/node/common-channel-handler.js.map +1 -1
- package/package.json +5 -5
- package/src/browser/ws-channel-handler.ts +2 -6
- package/src/common/{connection → buffers}/buffers.ts +24 -3
- package/src/common/connection/drivers/base.ts +2 -6
- package/src/common/connection/drivers/frame-decoder.ts +170 -0
- package/src/common/connection/drivers/message-port.ts +42 -0
- package/src/common/connection/drivers/node-message-port.ts +3 -0
- package/src/common/connection/drivers/reconnecting-websocket.ts +4 -0
- package/src/common/connection/drivers/simple.ts +33 -0
- package/src/common/connection/drivers/socket.ts +11 -7
- package/src/common/connection/drivers/ws-websocket.ts +8 -0
- package/src/common/connection/types.ts +1 -1
- package/src/common/ext-rpc-protocol.ts +16 -51
- package/src/common/fury-extends/any.ts +144 -0
- package/src/common/fury-extends/one-of.ts +61 -0
- package/src/common/fury-extends/shared.ts +15 -0
- package/src/common/index.ts +2 -1
- package/src/common/protocols/common-server.ts +18 -0
- package/src/common/protocols/common.ts +9 -0
- package/src/common/rpc/connection.ts +345 -0
- package/src/common/rpc/errors.ts +5 -0
- package/src/common/rpc/index.ts +2 -0
- package/src/common/rpc/multiplexer.ts +105 -0
- package/src/common/rpc/packet.ts +104 -0
- package/src/common/rpc/protocol-repository.ts +180 -0
- package/src/common/rpc/types.ts +23 -0
- package/src/common/rpc/utils.ts +5 -0
- package/src/common/rpc-service/center.ts +59 -49
- package/src/common/rpc-service/index.ts +9 -0
- package/src/common/rpc-service/proxy/base.ts +126 -0
- package/src/common/rpc-service/proxy/index.ts +4 -0
- package/src/common/rpc-service/proxy/invoker.ts +45 -0
- package/src/common/rpc-service/proxy/legacy.ts +150 -0
- package/src/common/rpc-service/proxy/registry.ts +56 -0
- package/src/common/rpc-service/proxy/sumi.ts +81 -0
- package/src/common/rpc-service/stub.ts +4 -11
- package/src/common/types.ts +1 -1
- package/src/common/ws-channel.ts +100 -61
- package/src/node/common-channel-handler.ts +1 -1
- package/lib/common/connection/buffers.d.ts.map +0 -1
- package/lib/common/connection/buffers.js.map +0 -1
- package/lib/common/connection/drivers/empty.d.ts.map +0 -1
- package/lib/common/connection/drivers/empty.js +0 -21
- package/lib/common/connection/drivers/empty.js.map +0 -1
- package/lib/common/connection/drivers/stream-decoder.d.ts +0 -67
- package/lib/common/connection/drivers/stream-decoder.d.ts.map +0 -1
- package/lib/common/connection/drivers/stream-decoder.js +0 -171
- package/lib/common/connection/drivers/stream-decoder.js.map +0 -1
- package/lib/common/proxy/base.d.ts +0 -22
- package/lib/common/proxy/base.d.ts.map +0 -1
- package/lib/common/proxy/base.js +0 -47
- package/lib/common/proxy/base.js.map +0 -1
- package/lib/common/proxy/index.d.ts +0 -8
- package/lib/common/proxy/index.d.ts.map +0 -1
- package/lib/common/proxy/index.js +0 -12
- package/lib/common/proxy/index.js.map +0 -1
- package/lib/common/proxy/legacy.d.ts.map +0 -1
- package/lib/common/proxy/legacy.js +0 -183
- package/lib/common/proxy/legacy.js.map +0 -1
- package/src/common/connection/drivers/empty.ts +0 -19
- package/src/common/connection/drivers/stream-decoder.ts +0 -196
- package/src/common/proxy/base.ts +0 -67
- package/src/common/proxy/index.ts +0 -10
- package/src/common/proxy/legacy.ts +0 -200
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceRegistry = void 0;
|
|
4
|
+
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
/**
|
|
7
|
+
* Store all executable services
|
|
8
|
+
*/
|
|
9
|
+
class ServiceRegistry {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.emitter = new ide_core_common_1.Emitter();
|
|
12
|
+
this.serviceMethodMap = new Map();
|
|
13
|
+
this.onServicesUpdate = this.emitter.event;
|
|
14
|
+
}
|
|
15
|
+
register(name, methodFn) {
|
|
16
|
+
this.serviceMethodMap.set(name, methodFn);
|
|
17
|
+
this.emitter.fire([name]);
|
|
18
|
+
}
|
|
19
|
+
registerService(service, options) {
|
|
20
|
+
const serviceNames = [];
|
|
21
|
+
const { nameConverter } = options || {};
|
|
22
|
+
const methods = (0, utils_1.getServiceMethods)(service);
|
|
23
|
+
for (const method of methods) {
|
|
24
|
+
let methodName = method;
|
|
25
|
+
if (nameConverter) {
|
|
26
|
+
methodName = nameConverter(method);
|
|
27
|
+
}
|
|
28
|
+
this.serviceMethodMap.set(methodName, service[method].bind(service));
|
|
29
|
+
serviceNames.push(methodName);
|
|
30
|
+
}
|
|
31
|
+
this.emitter.fire(serviceNames);
|
|
32
|
+
}
|
|
33
|
+
has(name) {
|
|
34
|
+
return this.serviceMethodMap.has(name);
|
|
35
|
+
}
|
|
36
|
+
invoke(name, ...args) {
|
|
37
|
+
// here because we have checked the existence of the method
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
39
|
+
return this.serviceMethodMap.get(name)(...args);
|
|
40
|
+
}
|
|
41
|
+
methods() {
|
|
42
|
+
return Array.from(this.serviceMethodMap.keys());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ServiceRegistry = ServiceRegistry;
|
|
46
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/common/rpc-service/proxy/registry.ts"],"names":[],"mappings":";;;AAAA,+DAAoD;AAGpD,uCAAgD;AAEhD;;GAEG;AACH,MAAa,eAAe;IAA5B;QACY,YAAO,GAAG,IAAI,yBAAO,EAAY,CAAC;QAEpC,qBAAgB,GAAG,IAAI,GAAG,EAAiC,CAAC;QAEpE,qBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IA0CxC,CAAC;IAxCC,QAAQ,CAAC,IAAY,EAAE,QAA0B;QAC/C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,eAAe,CACb,OAAY,EACZ,OAEC;QAED,MAAM,YAAY,GAAG,EAAc,CAAC;QACpC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,IAAA,yBAAiB,EAAC,OAAO,CAAC,CAAC;QAC3C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,UAAU,GAAG,MAAM,CAAC;YACxB,IAAI,aAAa,EAAE;gBACjB,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;aACpC;YAED,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACrE,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC/B;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,GAAG,CAAC,IAAiB;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,IAAiB,EAAE,GAAG,IAAW;QACtC,2DAA2D;QAC3D,oEAAoE;QACpE,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;CACF;AA/CD,0CA+CC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SumiConnection } from '../../rpc/connection';
|
|
2
|
+
import { ProxyBase } from './base';
|
|
3
|
+
export declare class ProxySumi extends ProxyBase<SumiConnection> {
|
|
4
|
+
protected engine: "sumi";
|
|
5
|
+
protected bindMethods(methods: string[]): void;
|
|
6
|
+
getInvokeProxy<T = any>(): T;
|
|
7
|
+
listen(connection: SumiConnection): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=sumi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sumi.d.ts","sourceRoot":"","sources":["../../../../src/common/rpc-service/proxy/sumi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,qBAAa,SAAU,SAAQ,SAAS,CAAC,cAAc,CAAC;IACtD,SAAS,CAAC,MAAM,SAAmB;IAEnC,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IA6BvC,cAAc,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC;IAgCnC,MAAM,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI;CAWzC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProxySumi = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
class ProxySumi extends base_1.ProxyBase {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.engine = 'sumi';
|
|
10
|
+
}
|
|
11
|
+
bindMethods(methods) {
|
|
12
|
+
for (const method of methods) {
|
|
13
|
+
if (method.startsWith('on')) {
|
|
14
|
+
this.connection.onNotification(method, async (...args) => {
|
|
15
|
+
this.captureOnNotification(method, args);
|
|
16
|
+
try {
|
|
17
|
+
await this.registry.invoke(method, ...args);
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
this.logger.warn(`notification exec ${method} error`, e);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.connection.onRequest(method, async (...args) => {
|
|
26
|
+
const requestId = this.nextRequestId();
|
|
27
|
+
this.captureOnRequest(requestId, method, args);
|
|
28
|
+
try {
|
|
29
|
+
const result = await this.registry.invoke(method, ...args);
|
|
30
|
+
this.captureOnRequestResult(requestId, method, result);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
this.captureOnRequestFail(requestId, method, e);
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
getInvokeProxy() {
|
|
42
|
+
return new Proxy(Object.create(null), {
|
|
43
|
+
get: (target, p) => {
|
|
44
|
+
if (!target[p]) {
|
|
45
|
+
target[p] = async (...args) => {
|
|
46
|
+
await this.connectionPromise.promise;
|
|
47
|
+
const prop = p.toString();
|
|
48
|
+
// 调用方法为 on 开头时,作为单项通知
|
|
49
|
+
if (prop.startsWith('on')) {
|
|
50
|
+
this.captureSendNotification(prop, args);
|
|
51
|
+
this.connection.sendNotification(prop, ...args);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// generate a unique requestId to associate request and requestResult
|
|
55
|
+
const requestId = this.nextRequestId();
|
|
56
|
+
this.captureSendRequest(requestId, prop, args);
|
|
57
|
+
try {
|
|
58
|
+
const result = await this.connection.sendRequest(prop, ...args);
|
|
59
|
+
this.captureSendRequestResult(requestId, prop, result);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
this.captureSendRequestFail(requestId, prop, error);
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return target[p];
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
listen(connection) {
|
|
74
|
+
super.listen(connection);
|
|
75
|
+
connection.onRequestNotFound((method) => {
|
|
76
|
+
if (!this.registry.has(method)) {
|
|
77
|
+
const requestId = this.nextRequestId();
|
|
78
|
+
this.captureOnRequest(requestId, method, []);
|
|
79
|
+
this.captureOnRequestFail(requestId, method, constants_1.METHOD_NOT_REGISTERED);
|
|
80
|
+
throw constants_1.METHOD_NOT_REGISTERED;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.ProxySumi = ProxySumi;
|
|
86
|
+
//# sourceMappingURL=sumi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sumi.js","sourceRoot":"","sources":["../../../../src/common/rpc-service/proxy/sumi.ts"],"names":[],"mappings":";;;AAAA,+CAAwD;AAGxD,iCAAmC;AAEnC,MAAa,SAAU,SAAQ,gBAAyB;IAAxD;;QACY,WAAM,GAAG,MAAe,CAAC;IA0ErC,CAAC;IAxEW,WAAW,CAAC,OAAiB;QACrC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC3B,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;oBAC9D,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;oBACzC,IAAI;wBACF,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;qBAC7C;oBAAC,OAAO,CAAC,EAAE;wBACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,MAAM,QAAQ,EAAE,CAAC,CAAC,CAAC;qBAC1D;gBACH,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;oBACzD,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;oBACvC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,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AC,WAAW,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;gCAChE,IAAI,CAAC,wBAAwB,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;gCACvD,OAAO,MAAM,CAAC;6BACf;4BAAC,OAAO,KAAK,EAAE;gCACd,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;gCACpD,MAAM,KAAK,CAAC;6BACb;yBACF;oBACH,CAAC,CAAC;iBACH;gBACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,UAA0B;QAC/B,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzB,UAAU,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,EAAE;YACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;gBACvC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC7C,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,iCAAqB,CAAC,CAAC;gBACpE,MAAM,iCAAqB,CAAC;aAC7B;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3ED,8BA2EC"}
|
|
@@ -5,7 +5,6 @@ export declare class RPCServiceStub {
|
|
|
5
5
|
private center;
|
|
6
6
|
private type;
|
|
7
7
|
constructor(serviceName: string, center: RPCServiceCenter, type: ServiceType);
|
|
8
|
-
ready(): Promise<void>;
|
|
9
8
|
on(name: string, method: RPCServiceMethod): void;
|
|
10
9
|
onRequestService(service: any): void;
|
|
11
10
|
onRequest(name: string, method: RPCServiceMethod): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stub.d.ts","sourceRoot":"","sources":["../../../src/common/rpc-service/stub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"stub.d.ts","sourceRoot":"","sources":["../../../src/common/rpc-service/stub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,qBAAa,cAAc;IACb,OAAO,CAAC,WAAW;IAAU,OAAO,CAAC,MAAM;IAAoB,OAAO,CAAC,IAAI;gBAAnE,WAAW,EAAE,MAAM,EAAU,MAAM,EAAE,gBAAgB,EAAU,IAAI,EAAE,WAAW;IAIpG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB;IAIzC,gBAAgB,CAAC,OAAO,EAAE,GAAG;IAI7B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB;IAIhD,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAIrD,QAAQ,gEAeH;CACN"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RPCServiceStub = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
4
|
class RPCServiceStub {
|
|
6
5
|
constructor(serviceName, center, type) {
|
|
7
6
|
this.serviceName = serviceName;
|
|
@@ -14,9 +13,8 @@ class RPCServiceStub {
|
|
|
14
13
|
if (typeof prop === 'symbol') {
|
|
15
14
|
return Promise.resolve();
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
16
|
+
target[prop] = (...args) => this.broadcast(prop, ...args);
|
|
17
|
+
return target[prop];
|
|
20
18
|
}
|
|
21
19
|
else {
|
|
22
20
|
return target[prop];
|
|
@@ -25,17 +23,11 @@ class RPCServiceStub {
|
|
|
25
23
|
});
|
|
26
24
|
this.center.registerService(serviceName, this.type);
|
|
27
25
|
}
|
|
28
|
-
async ready() {
|
|
29
|
-
return this.center.ready();
|
|
30
|
-
}
|
|
31
26
|
on(name, method) {
|
|
32
27
|
this.onRequest(name, method);
|
|
33
28
|
}
|
|
34
29
|
onRequestService(service) {
|
|
35
|
-
|
|
36
|
-
for (const method of methods) {
|
|
37
|
-
this.onRequest(method, service[method].bind(service));
|
|
38
|
-
}
|
|
30
|
+
this.center.onRequestService(this.serviceName, service);
|
|
39
31
|
}
|
|
40
32
|
onRequest(name, method) {
|
|
41
33
|
this.center.onRequest(this.serviceName, name, method);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stub.js","sourceRoot":"","sources":["../../../src/common/rpc-service/stub.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"stub.js","sourceRoot":"","sources":["../../../src/common/rpc-service/stub.ts"],"names":[],"mappings":";;;AAIA,MAAa,cAAc;IACzB,YAAoB,WAAmB,EAAU,MAAwB,EAAU,IAAiB;QAAhF,gBAAW,GAAX,WAAW,CAAQ;QAAU,WAAM,GAAN,MAAM,CAAkB;QAAU,SAAI,GAAJ,IAAI,CAAa;QAoBpG,aAAQ,GAAG,GAAM,EAAE,CACjB,IAAI,KAAK,CAAuD,IAAW,EAAE;YAC3E,MAAM;YACN,GAAG,EAAE,CAAC,MAAM,EAAE,IAAY,EAAE,EAAE;gBAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBACjB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;wBAC5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;qBAC1B;oBAED,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;oBACjE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;iBACrB;qBAAM;oBACL,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;iBACrB;YACH,CAAC;SACF,CAAC,CAAC;QAlCH,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,EAAE,CAAC,IAAY,EAAE,MAAwB;QACvC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,gBAAgB,CAAC,OAAY;QAC3B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,MAAwB;QAC9C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,GAAG,IAAW;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IAChE,CAAC;CAkBF;AArCD,wCAqCC"}
|
package/lib/common/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface ILogger {
|
|
|
4
4
|
error(...args: any[]): void;
|
|
5
5
|
}
|
|
6
6
|
export type RPCServiceMethod = (...args: any[]) => any;
|
|
7
|
-
export type IRPCServiceMap = Record<
|
|
7
|
+
export type IRPCServiceMap = Record<PropertyKey, RPCServiceMethod>;
|
|
8
8
|
export declare enum ServiceType {
|
|
9
9
|
Service = 0,
|
|
10
10
|
Stub = 1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAEnE,oBAAY,WAAW;IACrB,OAAO,IAAA;IACP,IAAI,IAAA;CACL;AAED,MAAM,WAAW,MAAM;IACrB,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C"}
|
|
@@ -3,14 +3,8 @@ import type net from 'net';
|
|
|
3
3
|
import type WebSocket from 'ws';
|
|
4
4
|
import { EventEmitter } from '@opensumi/events';
|
|
5
5
|
import { IConnectionShape } from './connection/types';
|
|
6
|
+
import { SumiConnection, ISumiConnectionOptions } from './rpc/connection';
|
|
6
7
|
import { ILogger } from './types';
|
|
7
|
-
export interface IWebSocket {
|
|
8
|
-
send(content: string): void;
|
|
9
|
-
close(...args: any[]): void;
|
|
10
|
-
onMessage(cb: (data: any) => void): void;
|
|
11
|
-
onError(cb: (reason: any) => void): void;
|
|
12
|
-
onClose(cb: (code: number, reason: string) => void): void;
|
|
13
|
-
}
|
|
14
8
|
/**
|
|
15
9
|
* `ping` and `pong` are used to detect whether the connection is alive.
|
|
16
10
|
*/
|
|
@@ -55,13 +49,18 @@ export interface DataMessage {
|
|
|
55
49
|
id: string;
|
|
56
50
|
content: string;
|
|
57
51
|
}
|
|
52
|
+
export interface BinaryMessage {
|
|
53
|
+
kind: 'binary';
|
|
54
|
+
id: string;
|
|
55
|
+
binary: Uint8Array;
|
|
56
|
+
}
|
|
58
57
|
export interface CloseMessage {
|
|
59
58
|
kind: 'close';
|
|
60
59
|
id: string;
|
|
61
60
|
code: number;
|
|
62
61
|
reason: string;
|
|
63
62
|
}
|
|
64
|
-
export type ChannelMessage = PingMessage | PongMessage | OpenMessage | ServerReadyMessage | DataMessage | CloseMessage;
|
|
63
|
+
export type ChannelMessage = PingMessage | PongMessage | OpenMessage | ServerReadyMessage | DataMessage | BinaryMessage | CloseMessage;
|
|
65
64
|
export interface IWSChannelCreateOptions {
|
|
66
65
|
/**
|
|
67
66
|
* every channel's unique id, it only used in client to server architecture.
|
|
@@ -70,13 +69,14 @@ export interface IWSChannelCreateOptions {
|
|
|
70
69
|
id: string;
|
|
71
70
|
logger?: ILogger;
|
|
72
71
|
}
|
|
73
|
-
export declare class WSChannel
|
|
72
|
+
export declare class WSChannel {
|
|
74
73
|
connection: IConnectionShape<Uint8Array>;
|
|
75
74
|
protected emitter: EventEmitter<{
|
|
76
75
|
message: [data: string];
|
|
77
76
|
open: [id: string];
|
|
78
77
|
reopen: [];
|
|
79
78
|
close: [code?: number, reason?: string];
|
|
79
|
+
binary: [data: Uint8Array];
|
|
80
80
|
}>;
|
|
81
81
|
id: string;
|
|
82
82
|
LOG_TAG: string;
|
|
@@ -86,45 +86,63 @@ export declare class WSChannel implements IWebSocket {
|
|
|
86
86
|
static forWebSocket(socket: WebSocket, options: IWSChannelCreateOptions): WSChannel;
|
|
87
87
|
static forNetSocket(socket: net.Socket, options: IWSChannelCreateOptions): WSChannel;
|
|
88
88
|
constructor(connection: IConnectionShape<Uint8Array>, options: IWSChannelCreateOptions);
|
|
89
|
-
onMessage(cb: (data: string) => any): ()
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
onMessage(cb: (data: string) => any): import("@opensumi/events").IDisposable;
|
|
90
|
+
onBinary(cb: (data: Uint8Array) => any): import("@opensumi/events").IDisposable;
|
|
91
|
+
onOpen(cb: (id: string) => void): import("@opensumi/events").IDisposable;
|
|
92
|
+
onReopen(cb: () => void): import("@opensumi/events").IDisposable;
|
|
92
93
|
serverReady(): void;
|
|
93
|
-
|
|
94
|
+
dispatchChannelMessage(msg: ChannelMessage): void;
|
|
94
95
|
open(path: string, clientId: string): void;
|
|
95
96
|
send(content: string): void;
|
|
96
|
-
|
|
97
|
+
sendBinary(data: Uint8Array): void;
|
|
97
98
|
onError(): void;
|
|
98
99
|
close(code?: number, reason?: string): void;
|
|
99
100
|
fireReopen(): void;
|
|
100
|
-
onClose(cb: (code: number, reason: string) => void): ()
|
|
101
|
+
onClose(cb: (code: number, reason: string) => void): import("@opensumi/events").IDisposable;
|
|
102
|
+
onceClose(cb: (code: number, reason: string) => void): import("@opensumi/events").IDisposable;
|
|
101
103
|
createMessageConnection(): import("@opensumi/vscode-jsonrpc").MessageConnection;
|
|
104
|
+
createConnection(): {
|
|
105
|
+
onceClose: (cb: any) => import("@opensumi/events").IDisposable;
|
|
106
|
+
onMessage: (cb: any) => import("@opensumi/events").IDisposable;
|
|
107
|
+
send: (data: any) => void;
|
|
108
|
+
dispose(): void;
|
|
109
|
+
};
|
|
110
|
+
createSumiConnection(options?: ISumiConnectionOptions): SumiConnection;
|
|
102
111
|
dispose(): void;
|
|
103
|
-
listen(channel: WSChannel): void;
|
|
104
112
|
}
|
|
105
|
-
export
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
clientId: string;
|
|
113
|
+
export declare const PingProtocol: {
|
|
114
|
+
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
115
|
+
options: {
|
|
116
|
+
tag: string;
|
|
117
|
+
props: {
|
|
118
|
+
clientId: {
|
|
119
|
+
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
120
|
+
};
|
|
121
|
+
id: {
|
|
122
|
+
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
123
|
+
};
|
|
124
|
+
} | undefined;
|
|
118
125
|
};
|
|
119
|
-
}
|
|
120
|
-
export declare const
|
|
126
|
+
};
|
|
127
|
+
export declare const PongProtocol: {
|
|
121
128
|
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
122
129
|
options: {
|
|
123
130
|
tag: string;
|
|
124
131
|
props: {
|
|
125
|
-
|
|
132
|
+
clientId: {
|
|
126
133
|
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
127
134
|
};
|
|
135
|
+
id: {
|
|
136
|
+
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
137
|
+
};
|
|
138
|
+
} | undefined;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
export declare const OpenProtocol: {
|
|
142
|
+
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
143
|
+
options: {
|
|
144
|
+
tag: string;
|
|
145
|
+
props: {
|
|
128
146
|
clientId: {
|
|
129
147
|
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
130
148
|
};
|
|
@@ -134,9 +152,56 @@ export declare const wsChannelProtocol: {
|
|
|
134
152
|
path: {
|
|
135
153
|
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
136
154
|
};
|
|
155
|
+
} | undefined;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
export declare const ServerReadyProtocol: {
|
|
159
|
+
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
160
|
+
options: {
|
|
161
|
+
tag: string;
|
|
162
|
+
props: {
|
|
163
|
+
id: {
|
|
164
|
+
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
165
|
+
};
|
|
166
|
+
} | undefined;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
export declare const DataProtocol: {
|
|
170
|
+
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
171
|
+
options: {
|
|
172
|
+
tag: string;
|
|
173
|
+
props: {
|
|
174
|
+
id: {
|
|
175
|
+
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
176
|
+
};
|
|
137
177
|
content: {
|
|
138
178
|
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
139
179
|
};
|
|
180
|
+
} | undefined;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export declare const BinaryProtocol: {
|
|
184
|
+
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
185
|
+
options: {
|
|
186
|
+
tag: string;
|
|
187
|
+
props: {
|
|
188
|
+
id: {
|
|
189
|
+
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
190
|
+
};
|
|
191
|
+
binary: {
|
|
192
|
+
type: import("@furyjs/fury").InternalSerializerType.BINARY;
|
|
193
|
+
};
|
|
194
|
+
} | undefined;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
export declare const CloseProtocol: {
|
|
198
|
+
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
199
|
+
options: {
|
|
200
|
+
tag: string;
|
|
201
|
+
props: {
|
|
202
|
+
id: {
|
|
203
|
+
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
204
|
+
};
|
|
140
205
|
code: {
|
|
141
206
|
type: import("@furyjs/fury").InternalSerializerType.UINT32;
|
|
142
207
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-channel.d.ts","sourceRoot":"","sources":["../../src/common/ws-channel.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,OAAO,KAAK,SAAS,MAAM,IAAI,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ws-channel.d.ts","sourceRoot":"","sources":["../../src/common/ws-channel.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,OAAO,KAAK,SAAS,MAAM,IAAI,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED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zB,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;CAIxB,CAAC;AAYH,wBAAgB,SAAS,CAAC,GAAG,EAAE,cAAc,GAAG,UAAU,CAEzD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,cAAc,CAEvD"}
|
package/lib/common/ws-channel.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse = exports.stringify = exports.
|
|
4
|
-
const
|
|
5
|
-
const fury_1 = tslib_1.__importStar(require("@furyjs/fury"));
|
|
3
|
+
exports.parse = exports.stringify = exports.CloseProtocol = exports.BinaryProtocol = exports.DataProtocol = exports.ServerReadyProtocol = exports.OpenProtocol = exports.PongProtocol = exports.PingProtocol = exports.WSChannel = void 0;
|
|
4
|
+
const fury_1 = require("@furyjs/fury");
|
|
6
5
|
const events_1 = require("@opensumi/events");
|
|
7
6
|
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
8
7
|
const connection_1 = require("./connection");
|
|
8
|
+
const one_of_1 = require("./fury-extends/one-of");
|
|
9
9
|
const message_1 = require("./message");
|
|
10
|
+
const connection_2 = require("./rpc/connection");
|
|
10
11
|
class WSChannel {
|
|
11
12
|
static forClient(connection, options) {
|
|
12
13
|
const disposable = new ide_core_common_1.DisposableCollection();
|
|
13
14
|
const channel = new WSChannel(connection, options);
|
|
14
15
|
disposable.push(connection.onMessage((data) => {
|
|
15
|
-
channel.
|
|
16
|
+
channel.dispatchChannelMessage(parse(data));
|
|
16
17
|
}));
|
|
17
18
|
disposable.push(channel);
|
|
18
19
|
disposable.push(connection.onceClose(() => {
|
|
@@ -40,10 +41,12 @@ class WSChannel {
|
|
|
40
41
|
}
|
|
41
42
|
this.LOG_TAG = `[WSChannel] [id:${id}]`;
|
|
42
43
|
}
|
|
43
|
-
// server
|
|
44
44
|
onMessage(cb) {
|
|
45
45
|
return this.emitter.on('message', cb);
|
|
46
46
|
}
|
|
47
|
+
onBinary(cb) {
|
|
48
|
+
return this.emitter.on('binary', cb);
|
|
49
|
+
}
|
|
47
50
|
onOpen(cb) {
|
|
48
51
|
return this.emitter.on('open', cb);
|
|
49
52
|
}
|
|
@@ -56,15 +59,19 @@ class WSChannel {
|
|
|
56
59
|
id: this.id,
|
|
57
60
|
}));
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
dispatchChannelMessage(msg) {
|
|
63
|
+
switch (msg.kind) {
|
|
64
|
+
case 'server-ready':
|
|
65
|
+
this.emitter.emit('open', msg.id);
|
|
66
|
+
break;
|
|
67
|
+
case 'data':
|
|
68
|
+
this.emitter.emit('message', msg.content);
|
|
69
|
+
break;
|
|
70
|
+
case 'binary':
|
|
71
|
+
this.emitter.emit('binary', msg.binary);
|
|
72
|
+
break;
|
|
65
73
|
}
|
|
66
74
|
}
|
|
67
|
-
// client
|
|
68
75
|
open(path, clientId) {
|
|
69
76
|
this.channelPath = path;
|
|
70
77
|
this.connection.send(stringify({
|
|
@@ -81,8 +88,12 @@ class WSChannel {
|
|
|
81
88
|
content,
|
|
82
89
|
}));
|
|
83
90
|
}
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
sendBinary(data) {
|
|
92
|
+
this.connection.send(stringify({
|
|
93
|
+
kind: 'binary',
|
|
94
|
+
id: this.id,
|
|
95
|
+
binary: data,
|
|
96
|
+
}));
|
|
86
97
|
}
|
|
87
98
|
onError() { }
|
|
88
99
|
close(code, reason) {
|
|
@@ -94,62 +105,75 @@ class WSChannel {
|
|
|
94
105
|
onClose(cb) {
|
|
95
106
|
return this.emitter.on('close', cb);
|
|
96
107
|
}
|
|
108
|
+
onceClose(cb) {
|
|
109
|
+
return this.emitter.once('close', cb);
|
|
110
|
+
}
|
|
97
111
|
createMessageConnection() {
|
|
98
112
|
return (0, message_1.createWebSocketConnection)(this);
|
|
99
113
|
}
|
|
114
|
+
createConnection() {
|
|
115
|
+
return {
|
|
116
|
+
onceClose: (cb) => this.onceClose(cb),
|
|
117
|
+
onMessage: (cb) => this.onBinary(cb),
|
|
118
|
+
send: (data) => {
|
|
119
|
+
this.sendBinary(data);
|
|
120
|
+
},
|
|
121
|
+
dispose() { },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
createSumiConnection(options = {}) {
|
|
125
|
+
const conn = new connection_2.SumiConnection(this.createConnection(), options);
|
|
126
|
+
return conn;
|
|
127
|
+
}
|
|
100
128
|
dispose() {
|
|
101
129
|
this.emitter.dispose();
|
|
102
130
|
}
|
|
103
|
-
listen(channel) {
|
|
104
|
-
channel.onMessage((data) => {
|
|
105
|
-
this.send(data);
|
|
106
|
-
});
|
|
107
|
-
channel.onClose((code, reason) => {
|
|
108
|
-
this.close(code, reason);
|
|
109
|
-
});
|
|
110
|
-
channel.onReopen(() => {
|
|
111
|
-
this.fireReopen();
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
131
|
}
|
|
115
132
|
exports.WSChannel = WSChannel;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
parseInfo(pathString) {
|
|
127
|
-
const list = pathString.split('-');
|
|
128
|
-
return {
|
|
129
|
-
pre: list[0],
|
|
130
|
-
index: list[1],
|
|
131
|
-
clientId: list[2],
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.ChildConnectPath = ChildConnectPath;
|
|
136
|
-
const fury = new fury_1.default({});
|
|
137
|
-
exports.wsChannelProtocol = fury_1.Type.object('ws-channel-protocol', {
|
|
138
|
-
kind: fury_1.Type.string(),
|
|
133
|
+
exports.PingProtocol = fury_1.Type.object('ping', {
|
|
134
|
+
clientId: fury_1.Type.string(),
|
|
135
|
+
id: fury_1.Type.string(),
|
|
136
|
+
});
|
|
137
|
+
exports.PongProtocol = fury_1.Type.object('pong', {
|
|
138
|
+
clientId: fury_1.Type.string(),
|
|
139
|
+
id: fury_1.Type.string(),
|
|
140
|
+
});
|
|
141
|
+
exports.OpenProtocol = fury_1.Type.object('open', {
|
|
139
142
|
clientId: fury_1.Type.string(),
|
|
140
143
|
id: fury_1.Type.string(),
|
|
141
144
|
path: fury_1.Type.string(),
|
|
145
|
+
});
|
|
146
|
+
exports.ServerReadyProtocol = fury_1.Type.object('server-ready', {
|
|
147
|
+
id: fury_1.Type.string(),
|
|
148
|
+
});
|
|
149
|
+
exports.DataProtocol = fury_1.Type.object('data', {
|
|
150
|
+
id: fury_1.Type.string(),
|
|
142
151
|
content: fury_1.Type.string(),
|
|
152
|
+
});
|
|
153
|
+
exports.BinaryProtocol = fury_1.Type.object('binary', {
|
|
154
|
+
id: fury_1.Type.string(),
|
|
155
|
+
binary: fury_1.Type.binary(),
|
|
156
|
+
});
|
|
157
|
+
exports.CloseProtocol = fury_1.Type.object('close', {
|
|
158
|
+
id: fury_1.Type.string(),
|
|
143
159
|
code: fury_1.Type.uint32(),
|
|
144
160
|
reason: fury_1.Type.string(),
|
|
145
161
|
});
|
|
146
|
-
const
|
|
162
|
+
const serializer = (0, one_of_1.oneOf)([
|
|
163
|
+
exports.PingProtocol,
|
|
164
|
+
exports.PongProtocol,
|
|
165
|
+
exports.OpenProtocol,
|
|
166
|
+
exports.ServerReadyProtocol,
|
|
167
|
+
exports.DataProtocol,
|
|
168
|
+
exports.BinaryProtocol,
|
|
169
|
+
exports.CloseProtocol,
|
|
170
|
+
]);
|
|
147
171
|
function stringify(obj) {
|
|
148
|
-
return
|
|
172
|
+
return serializer.serialize(obj);
|
|
149
173
|
}
|
|
150
174
|
exports.stringify = stringify;
|
|
151
175
|
function parse(input) {
|
|
152
|
-
return
|
|
176
|
+
return serializer.deserialize(input);
|
|
153
177
|
}
|
|
154
178
|
exports.parse = parse;
|
|
155
179
|
//# sourceMappingURL=ws-channel.js.map
|