@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/proxy/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAEzB,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG;IACtC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC;IAC7B,IAAI,MAAM,kBAET;CACF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RPCService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./legacy"), exports);
|
|
6
|
-
class RPCService {
|
|
7
|
-
get client() {
|
|
8
|
-
return this.rpcClient ? this.rpcClient[0] : undefined;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.RPCService = RPCService;
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/proxy/index.ts"],"names":[],"mappings":";;;;AAAA,mDAAyB;AAEzB,MAAsB,UAAU;IAI9B,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxD,CAAC;CACF;AAPD,gCAOC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../../src/common/proxy/legacy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAOnC,qBAAa,WAAY,SAAQ,SAAS,CAAC,iBAAiB,CAAC;IAC3D,MAAM,WAAqB;IAEpB,cAAc,IAAI,GAAG;IAIrB,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,aAEb,GAAG,EAAE;IA0D9B,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS;IAiDnH;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;YAaZ,SAAS;IAmBvB,OAAO,CAAC,cAAc;IAQtB,MAAM,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;CAoB5C"}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProxyLegacy = void 0;
|
|
4
|
-
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const base_1 = require("./base");
|
|
8
|
-
class ProxyLegacy extends base_1.ProxyBase {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.engine = 'legacy';
|
|
12
|
-
}
|
|
13
|
-
getInvokeProxy() {
|
|
14
|
-
return new Proxy(this, this);
|
|
15
|
-
}
|
|
16
|
-
get(target, p) {
|
|
17
|
-
const prop = p.toString();
|
|
18
|
-
return async (...args) => {
|
|
19
|
-
await this.connectionPromise.promise;
|
|
20
|
-
let isSingleArray = false;
|
|
21
|
-
if (args.length === 1 && Array.isArray(args[0])) {
|
|
22
|
-
isSingleArray = true;
|
|
23
|
-
}
|
|
24
|
-
// 调用方法为 on 开头时,作为单项通知
|
|
25
|
-
if (prop.startsWith('on')) {
|
|
26
|
-
if (isSingleArray) {
|
|
27
|
-
this.connection.sendNotification(prop, [...args]);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
this.connection.sendNotification(prop, ...args);
|
|
31
|
-
}
|
|
32
|
-
this.capture({ type: utils_1.MessageType.SendNotification, serviceMethod: prop, arguments: args });
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
let requestResult;
|
|
36
|
-
// generate a unique requestId to associate request and requestResult
|
|
37
|
-
const requestId = (0, ide_core_common_1.uuid)();
|
|
38
|
-
if (isSingleArray) {
|
|
39
|
-
requestResult = this.connection.sendRequest(prop, [...args]);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
requestResult = this.connection.sendRequest(prop, ...args);
|
|
43
|
-
}
|
|
44
|
-
this.capture({ type: utils_1.MessageType.SendRequest, requestId, serviceMethod: prop, arguments: args });
|
|
45
|
-
const result = await requestResult;
|
|
46
|
-
if (result.error) {
|
|
47
|
-
const error = new Error(result.data.message);
|
|
48
|
-
if (result.data.stack) {
|
|
49
|
-
error.stack = result.data.stack;
|
|
50
|
-
}
|
|
51
|
-
this.capture({
|
|
52
|
-
type: utils_1.MessageType.RequestResult,
|
|
53
|
-
status: utils_1.ResponseStatus.Fail,
|
|
54
|
-
requestId,
|
|
55
|
-
serviceMethod: prop,
|
|
56
|
-
error: result.data,
|
|
57
|
-
});
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.capture({
|
|
62
|
-
type: utils_1.MessageType.RequestResult,
|
|
63
|
-
status: utils_1.ResponseStatus.Success,
|
|
64
|
-
requestId,
|
|
65
|
-
serviceMethod: prop,
|
|
66
|
-
data: result.data,
|
|
67
|
-
});
|
|
68
|
-
return result.data;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
bindOnRequest(service, cb) {
|
|
74
|
-
if (this.connection) {
|
|
75
|
-
const connection = this.connection;
|
|
76
|
-
const methods = (0, utils_1.getServiceMethods)(service);
|
|
77
|
-
methods.forEach((method) => {
|
|
78
|
-
if (method.startsWith('on')) {
|
|
79
|
-
connection.onNotification(method, (...args) => {
|
|
80
|
-
this.onNotification(method, ...args);
|
|
81
|
-
this.capture({ type: utils_1.MessageType.OnNotification, serviceMethod: method, arguments: args });
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
connection.onRequest(method, (...args) => {
|
|
86
|
-
const requestId = (0, ide_core_common_1.uuid)();
|
|
87
|
-
const result = this.onRequest(method, ...args);
|
|
88
|
-
this.capture({ type: utils_1.MessageType.OnRequest, requestId, serviceMethod: method, arguments: args });
|
|
89
|
-
result
|
|
90
|
-
.then((result) => {
|
|
91
|
-
this.capture({
|
|
92
|
-
type: utils_1.MessageType.OnRequestResult,
|
|
93
|
-
status: utils_1.ResponseStatus.Success,
|
|
94
|
-
requestId,
|
|
95
|
-
serviceMethod: method,
|
|
96
|
-
data: result.data,
|
|
97
|
-
});
|
|
98
|
-
})
|
|
99
|
-
.catch((err) => {
|
|
100
|
-
this.capture({
|
|
101
|
-
type: utils_1.MessageType.OnRequestResult,
|
|
102
|
-
status: utils_1.ResponseStatus.Fail,
|
|
103
|
-
requestId,
|
|
104
|
-
serviceMethod: method,
|
|
105
|
-
error: err.data,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
return result;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (cb) {
|
|
112
|
-
cb(service, method);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* 对于纯数组参数的情况,收到请求/通知后做展开操作
|
|
119
|
-
* 因为在通信层会为每个 rpc 调用添加一个 CancellationToken 参数
|
|
120
|
-
* 如果参数本身是数组, 在方法中如果使用 spread 运算符获取参数(...args),则会出现 [...args, MutableToken] 这种情况
|
|
121
|
-
* 所以发送请求时将这类参数统一再用数组包了一层,形如 [[...args]], 参考 {@link ProxyLegacy.get get} 方法
|
|
122
|
-
* 此时接收到的数组类参数固定长度为 2,且最后一项一定是 MutableToken
|
|
123
|
-
* @param args
|
|
124
|
-
* @returns args
|
|
125
|
-
*/
|
|
126
|
-
serializeArguments(args) {
|
|
127
|
-
const maybeCancellationToken = args[args.length - 1];
|
|
128
|
-
if (args.length === 2 &&
|
|
129
|
-
Array.isArray(args[0]) &&
|
|
130
|
-
Object.prototype.hasOwnProperty.call(maybeCancellationToken, '_isCancelled')) {
|
|
131
|
-
return [...args[0], maybeCancellationToken];
|
|
132
|
-
}
|
|
133
|
-
return args;
|
|
134
|
-
}
|
|
135
|
-
async onRequest(prop, ...args) {
|
|
136
|
-
try {
|
|
137
|
-
const result = await this.proxyService[prop](...this.serializeArguments(args));
|
|
138
|
-
return {
|
|
139
|
-
error: false,
|
|
140
|
-
data: result,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
return {
|
|
145
|
-
error: true,
|
|
146
|
-
data: {
|
|
147
|
-
message: e.message,
|
|
148
|
-
stack: e.stack,
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
onNotification(prop, ...args) {
|
|
154
|
-
try {
|
|
155
|
-
this.proxyService[prop](...this.serializeArguments(args));
|
|
156
|
-
}
|
|
157
|
-
catch (e) {
|
|
158
|
-
this.logger.warn('notification', e);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
listen(connection) {
|
|
162
|
-
super.listen(connection);
|
|
163
|
-
connection.onRequest((method) => {
|
|
164
|
-
if (!this.proxyService[method]) {
|
|
165
|
-
const requestId = (0, ide_core_common_1.uuid)();
|
|
166
|
-
this.capture({ type: utils_1.MessageType.OnRequest, requestId, serviceMethod: method });
|
|
167
|
-
const result = {
|
|
168
|
-
data: constants_1.METHOD_NOT_REGISTERED,
|
|
169
|
-
};
|
|
170
|
-
this.capture({
|
|
171
|
-
type: utils_1.MessageType.OnRequestResult,
|
|
172
|
-
status: utils_1.ResponseStatus.Fail,
|
|
173
|
-
requestId,
|
|
174
|
-
serviceMethod: method,
|
|
175
|
-
error: result.data,
|
|
176
|
-
});
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
exports.ProxyLegacy = ProxyLegacy;
|
|
183
|
-
//# sourceMappingURL=legacy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../../src/common/proxy/legacy.ts"],"names":[],"mappings":";;;AAAA,+DAAiD;AAGjD,4CAAqD;AAErD,oCAA0E;AAE1E,iCAAmC;AAOnC,MAAa,WAAY,SAAQ,gBAA4B;IAA7D;;QACE,WAAM,GAAG,QAAiB,CAAC;IAwL7B,CAAC;IAtLQ,cAAc;QACnB,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE,I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M,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;SACrC;IACH,CAAC;IAED,MAAM,CAAC,UAA6B;QAClC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzB,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YAC9B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;gBAC9B,MAAM,SAAS,GAAG,IAAA,sBAAI,GAAE,CAAC;gBACzB,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,mBAAW,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;gBAChF,MAAM,MAAM,GAAG;oBACb,IAAI,EAAE,iCAAqB;iBAC5B,CAAC;gBACF,IAAI,CAAC,OAAO,CAAC;oBACX,IAAI,EAAE,mBAAW,CAAC,eAAe;oBACjC,MAAM,EAAE,sBAAc,CAAC,IAAI;oBAC3B,SAAS;oBACT,aAAa,EAAE,MAAM;oBACrB,KAAK,EAAE,MAAM,CAAC,IAAI;iBACnB,CAAC,CAAC;gBACH,OAAO,MAAM,CAAC;aACf;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAzLD,kCAyLC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IDisposable } from '@opensumi/ide-core-common';
|
|
2
|
-
|
|
3
|
-
import { BaseConnection } from './base';
|
|
4
|
-
|
|
5
|
-
export class EmptyConnection extends BaseConnection<Uint8Array> {
|
|
6
|
-
send(data: Uint8Array): void {
|
|
7
|
-
// do nothing
|
|
8
|
-
}
|
|
9
|
-
onMessage(cb: (data: Uint8Array) => void): IDisposable {
|
|
10
|
-
return {
|
|
11
|
-
dispose: () => {},
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
onceClose(cb: () => void): IDisposable {
|
|
15
|
-
return {
|
|
16
|
-
dispose: () => {},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { BinaryReader } from '@furyjs/fury/dist/lib/reader';
|
|
2
|
-
import { BinaryWriter } from '@furyjs/fury/dist/lib/writer';
|
|
3
|
-
|
|
4
|
-
import { EventEmitter } from '@opensumi/events';
|
|
5
|
-
|
|
6
|
-
import { Buffers } from '../buffers';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* You can use `Buffer.from('Sumi')` to get this magic number
|
|
10
|
-
*/
|
|
11
|
-
export const kMagicNumber = 0x53756d69;
|
|
12
|
-
|
|
13
|
-
const writer = BinaryWriter({});
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* When we send data through net.Socket, the data is not guaranteed to be sent as a whole.
|
|
17
|
-
*
|
|
18
|
-
* So we need to add a header to the data, so that the receiver can know the length of the data,
|
|
19
|
-
* The header is 4 bytes, the first 4 bytes is a magic number, which is `Sumi` in little endian.
|
|
20
|
-
* use magic number can help us to detect the start of the packet in the stream.
|
|
21
|
-
*
|
|
22
|
-
* The next 4 bytes is a varUInt32, which means the length of the following data, and
|
|
23
|
-
* the following data is the content.
|
|
24
|
-
*/
|
|
25
|
-
export function createStreamPacket(content: Uint8Array) {
|
|
26
|
-
writer.reset();
|
|
27
|
-
writer.uint32(kMagicNumber);
|
|
28
|
-
writer.varUInt32(content.byteLength);
|
|
29
|
-
writer.buffer(content);
|
|
30
|
-
return writer.dump();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class StreamPacketDecoder {
|
|
34
|
-
protected emitter = new EventEmitter<{
|
|
35
|
-
data: [Uint8Array];
|
|
36
|
-
}>();
|
|
37
|
-
|
|
38
|
-
protected buffers = new Buffers();
|
|
39
|
-
protected cursor = this.buffers.cursor();
|
|
40
|
-
|
|
41
|
-
protected reader = BinaryReader({});
|
|
42
|
-
|
|
43
|
-
protected state = 0;
|
|
44
|
-
protected contentLength = 0;
|
|
45
|
-
|
|
46
|
-
reset() {
|
|
47
|
-
this.state = 0;
|
|
48
|
-
this.contentLength = 0;
|
|
49
|
-
|
|
50
|
-
this.cursor.reset();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
push(chunk: Uint8Array): void {
|
|
54
|
-
this.buffers.push(chunk);
|
|
55
|
-
let done = false;
|
|
56
|
-
|
|
57
|
-
while (!done) {
|
|
58
|
-
done = this.readPacket();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
protected readPacket(): boolean {
|
|
63
|
-
const found = this.readHeader();
|
|
64
|
-
|
|
65
|
-
if (found) {
|
|
66
|
-
const start = this.cursor.offset;
|
|
67
|
-
const end = start + this.contentLength;
|
|
68
|
-
|
|
69
|
-
const binary = this.buffers.slice(start, end);
|
|
70
|
-
|
|
71
|
-
this.emitter.emit('data', binary);
|
|
72
|
-
|
|
73
|
-
if (this.buffers.byteLength > end) {
|
|
74
|
-
this.cursor.moveTo(end);
|
|
75
|
-
this.state = 0;
|
|
76
|
-
this.contentLength = 0;
|
|
77
|
-
// has more data, continue to parse
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// delete used buffers
|
|
82
|
-
this.buffers.splice(0, end);
|
|
83
|
-
this.reset();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* First we read the first 4 bytes, if it is not magic 4 bytes
|
|
91
|
-
* discard it and continue to read the next byte until we get magic 4 bytes
|
|
92
|
-
* Then read the next byte, this is a varUint32, which means the length of the following data
|
|
93
|
-
* Then read the following data, until we get the length of varUint32, then return this data and continue to read the next packet
|
|
94
|
-
*/
|
|
95
|
-
protected readHeader() {
|
|
96
|
-
if (this.buffers.byteLength === 0) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (this.state !== 4) {
|
|
101
|
-
this.readMagicNumber();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (this.state !== 4) {
|
|
105
|
-
// Not enough data yet, wait for more data
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (this.cursor.offset + 4 > this.buffers.byteLength) {
|
|
110
|
-
// Not enough data yet, wait for more data
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!this.contentLength) {
|
|
115
|
-
// read the content length
|
|
116
|
-
const buffers = this.buffers.slice(this.cursor.offset, this.cursor.offset + 4);
|
|
117
|
-
this.reader.reset(buffers);
|
|
118
|
-
this.contentLength = this.reader.varUInt32();
|
|
119
|
-
this.cursor.move(this.reader.getCursor());
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (this.cursor.offset + this.contentLength > this.buffers.byteLength) {
|
|
123
|
-
// Not enough data yet, wait for more data
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
protected readMagicNumber() {
|
|
131
|
-
const iter = this.cursor.iterator();
|
|
132
|
-
|
|
133
|
-
let result = iter.next();
|
|
134
|
-
while (!result.done) {
|
|
135
|
-
// Fury use little endian to store data
|
|
136
|
-
switch (result.value) {
|
|
137
|
-
case 0x69:
|
|
138
|
-
switch (this.state) {
|
|
139
|
-
case 0:
|
|
140
|
-
this.state = 1;
|
|
141
|
-
break;
|
|
142
|
-
default:
|
|
143
|
-
this.state = 0;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
break;
|
|
147
|
-
case 0x6d:
|
|
148
|
-
switch (this.state) {
|
|
149
|
-
case 1:
|
|
150
|
-
this.state = 2;
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
this.state = 0;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
case 0x75:
|
|
158
|
-
switch (this.state) {
|
|
159
|
-
case 2:
|
|
160
|
-
this.state = 3;
|
|
161
|
-
break;
|
|
162
|
-
default:
|
|
163
|
-
this.state = 0;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
break;
|
|
167
|
-
case 0x53:
|
|
168
|
-
switch (this.state) {
|
|
169
|
-
case 3:
|
|
170
|
-
this.state = 4;
|
|
171
|
-
iter.return();
|
|
172
|
-
break;
|
|
173
|
-
default:
|
|
174
|
-
this.state = 0;
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
default:
|
|
179
|
-
this.state = 0;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
result = iter.next();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
onData(cb: (data: Uint8Array) => void) {
|
|
187
|
-
return this.emitter.on('data', cb);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
dispose() {
|
|
191
|
-
this.reader = BinaryReader({});
|
|
192
|
-
this.emitter.dispose();
|
|
193
|
-
this.buffers.dispose();
|
|
194
|
-
this.cursor.dispose();
|
|
195
|
-
}
|
|
196
|
-
}
|
package/src/common/proxy/base.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Deferred, isDefined } from '@opensumi/ide-core-common';
|
|
2
|
-
|
|
3
|
-
import { ILogger, IRPCServiceMap } from '../types';
|
|
4
|
-
import { ICapturedMessage, getCapturer, getServiceMethods } from '../utils';
|
|
5
|
-
|
|
6
|
-
interface IBaseConnection {
|
|
7
|
-
listen(): void;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export abstract class ProxyBase<T extends IBaseConnection> {
|
|
11
|
-
protected proxyService: any = {};
|
|
12
|
-
|
|
13
|
-
protected logger: ILogger;
|
|
14
|
-
protected connection: T;
|
|
15
|
-
|
|
16
|
-
protected connectionPromise: Deferred<void> = new Deferred<void>();
|
|
17
|
-
|
|
18
|
-
protected abstract engine: 'legacy';
|
|
19
|
-
|
|
20
|
-
constructor(public target?: IRPCServiceMap, logger?: ILogger) {
|
|
21
|
-
this.logger = logger || console;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// capture messages for opensumi devtools
|
|
25
|
-
protected capture(message: ICapturedMessage): void {
|
|
26
|
-
const capturer = getCapturer();
|
|
27
|
-
if (isDefined(capturer)) {
|
|
28
|
-
capturer({
|
|
29
|
-
...message,
|
|
30
|
-
engine: this.engine,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
listen(connection: T): void {
|
|
36
|
-
this.connection = connection;
|
|
37
|
-
|
|
38
|
-
if (this.target) {
|
|
39
|
-
this.listenService(this.target);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
connection.listen();
|
|
43
|
-
this.connectionPromise.resolve();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public listenService(service: IRPCServiceMap) {
|
|
47
|
-
if (this.connection) {
|
|
48
|
-
this.bindOnRequest(service, (service, prop) => {
|
|
49
|
-
this.proxyService[prop] = service[prop].bind(service);
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
if (!this.target) {
|
|
53
|
-
this.target = {} as any;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const methods = getServiceMethods(service);
|
|
57
|
-
for (const method of methods) {
|
|
58
|
-
// `getServiceMethods` ensure that method is a function
|
|
59
|
-
(this.target as any)[method] = service[method]!.bind(service);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
abstract getInvokeProxy(): any;
|
|
65
|
-
|
|
66
|
-
protected abstract bindOnRequest(service: IRPCServiceMap, cb: (service: IRPCServiceMap, prop: string) => void): void;
|
|
67
|
-
}
|