@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,200 +0,0 @@
|
|
|
1
|
-
import { uuid } from '@opensumi/ide-core-common';
|
|
2
|
-
import { MessageConnection } from '@opensumi/vscode-jsonrpc';
|
|
3
|
-
|
|
4
|
-
import { METHOD_NOT_REGISTERED } from '../constants';
|
|
5
|
-
import { IRPCServiceMap } from '../types';
|
|
6
|
-
import { MessageType, ResponseStatus, getServiceMethods } from '../utils';
|
|
7
|
-
|
|
8
|
-
import { ProxyBase } from './base';
|
|
9
|
-
|
|
10
|
-
interface IRPCResult {
|
|
11
|
-
error: boolean;
|
|
12
|
-
data: any;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class ProxyLegacy extends ProxyBase<MessageConnection> {
|
|
16
|
-
engine = 'legacy' as const;
|
|
17
|
-
|
|
18
|
-
public getInvokeProxy(): any {
|
|
19
|
-
return new Proxy(this, this);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public get(target: any, p: PropertyKey) {
|
|
23
|
-
const prop = p.toString();
|
|
24
|
-
return async (...args: any[]) => {
|
|
25
|
-
await this.connectionPromise.promise;
|
|
26
|
-
|
|
27
|
-
let isSingleArray = false;
|
|
28
|
-
if (args.length === 1 && Array.isArray(args[0])) {
|
|
29
|
-
isSingleArray = true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 调用方法为 on 开头时,作为单项通知
|
|
33
|
-
if (prop.startsWith('on')) {
|
|
34
|
-
if (isSingleArray) {
|
|
35
|
-
this.connection.sendNotification(prop, [...args]);
|
|
36
|
-
} else {
|
|
37
|
-
this.connection.sendNotification(prop, ...args);
|
|
38
|
-
}
|
|
39
|
-
this.capture({ type: MessageType.SendNotification, serviceMethod: prop, arguments: args });
|
|
40
|
-
} else {
|
|
41
|
-
let requestResult: Promise<any>;
|
|
42
|
-
// generate a unique requestId to associate request and requestResult
|
|
43
|
-
const requestId = uuid();
|
|
44
|
-
|
|
45
|
-
if (isSingleArray) {
|
|
46
|
-
requestResult = this.connection.sendRequest(prop, [...args]) as Promise<any>;
|
|
47
|
-
} else {
|
|
48
|
-
requestResult = this.connection.sendRequest(prop, ...args) as Promise<any>;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.capture({ type: MessageType.SendRequest, requestId, serviceMethod: prop, arguments: args });
|
|
52
|
-
|
|
53
|
-
const result: IRPCResult = await requestResult;
|
|
54
|
-
|
|
55
|
-
if (result.error) {
|
|
56
|
-
const error = new Error(result.data.message);
|
|
57
|
-
if (result.data.stack) {
|
|
58
|
-
error.stack = result.data.stack;
|
|
59
|
-
}
|
|
60
|
-
this.capture({
|
|
61
|
-
type: MessageType.RequestResult,
|
|
62
|
-
status: ResponseStatus.Fail,
|
|
63
|
-
requestId,
|
|
64
|
-
serviceMethod: prop,
|
|
65
|
-
error: result.data,
|
|
66
|
-
});
|
|
67
|
-
throw error;
|
|
68
|
-
} else {
|
|
69
|
-
this.capture({
|
|
70
|
-
type: MessageType.RequestResult,
|
|
71
|
-
status: ResponseStatus.Success,
|
|
72
|
-
requestId,
|
|
73
|
-
serviceMethod: prop,
|
|
74
|
-
data: result.data,
|
|
75
|
-
});
|
|
76
|
-
return result.data;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
protected bindOnRequest(service: IRPCServiceMap, cb?: ((service: IRPCServiceMap, prop: string) => void) | undefined) {
|
|
83
|
-
if (this.connection) {
|
|
84
|
-
const connection = this.connection;
|
|
85
|
-
|
|
86
|
-
const methods = getServiceMethods(service);
|
|
87
|
-
|
|
88
|
-
methods.forEach((method) => {
|
|
89
|
-
if (method.startsWith('on')) {
|
|
90
|
-
connection.onNotification(method, (...args) => {
|
|
91
|
-
this.onNotification(method, ...args);
|
|
92
|
-
this.capture({ type: MessageType.OnNotification, serviceMethod: method, arguments: args });
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
connection.onRequest(method, (...args) => {
|
|
96
|
-
const requestId = uuid();
|
|
97
|
-
const result = this.onRequest(method, ...args);
|
|
98
|
-
this.capture({ type: MessageType.OnRequest, requestId, serviceMethod: method, arguments: args });
|
|
99
|
-
|
|
100
|
-
result
|
|
101
|
-
.then((result) => {
|
|
102
|
-
this.capture({
|
|
103
|
-
type: MessageType.OnRequestResult,
|
|
104
|
-
status: ResponseStatus.Success,
|
|
105
|
-
requestId,
|
|
106
|
-
serviceMethod: method,
|
|
107
|
-
data: result.data,
|
|
108
|
-
});
|
|
109
|
-
})
|
|
110
|
-
.catch((err) => {
|
|
111
|
-
this.capture({
|
|
112
|
-
type: MessageType.OnRequestResult,
|
|
113
|
-
status: ResponseStatus.Fail,
|
|
114
|
-
requestId,
|
|
115
|
-
serviceMethod: method,
|
|
116
|
-
error: err.data,
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
return result;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (cb) {
|
|
125
|
-
cb(service, method);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* 对于纯数组参数的情况,收到请求/通知后做展开操作
|
|
133
|
-
* 因为在通信层会为每个 rpc 调用添加一个 CancellationToken 参数
|
|
134
|
-
* 如果参数本身是数组, 在方法中如果使用 spread 运算符获取参数(...args),则会出现 [...args, MutableToken] 这种情况
|
|
135
|
-
* 所以发送请求时将这类参数统一再用数组包了一层,形如 [[...args]], 参考 {@link ProxyLegacy.get get} 方法
|
|
136
|
-
* 此时接收到的数组类参数固定长度为 2,且最后一项一定是 MutableToken
|
|
137
|
-
* @param args
|
|
138
|
-
* @returns args
|
|
139
|
-
*/
|
|
140
|
-
private serializeArguments(args: any[]): any[] {
|
|
141
|
-
const maybeCancellationToken = args[args.length - 1];
|
|
142
|
-
if (
|
|
143
|
-
args.length === 2 &&
|
|
144
|
-
Array.isArray(args[0]) &&
|
|
145
|
-
Object.prototype.hasOwnProperty.call(maybeCancellationToken, '_isCancelled')
|
|
146
|
-
) {
|
|
147
|
-
return [...args[0], maybeCancellationToken];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return args;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private async onRequest(prop: PropertyKey, ...args: any[]) {
|
|
154
|
-
try {
|
|
155
|
-
const result = await this.proxyService[prop](...this.serializeArguments(args));
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
error: false,
|
|
159
|
-
data: result,
|
|
160
|
-
};
|
|
161
|
-
} catch (e) {
|
|
162
|
-
return {
|
|
163
|
-
error: true,
|
|
164
|
-
data: {
|
|
165
|
-
message: e.message,
|
|
166
|
-
stack: e.stack,
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private onNotification(prop: PropertyKey, ...args: any[]) {
|
|
173
|
-
try {
|
|
174
|
-
this.proxyService[prop](...this.serializeArguments(args));
|
|
175
|
-
} catch (e) {
|
|
176
|
-
this.logger.warn('notification', e);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
listen(connection: MessageConnection): void {
|
|
181
|
-
super.listen(connection);
|
|
182
|
-
connection.onRequest((method) => {
|
|
183
|
-
if (!this.proxyService[method]) {
|
|
184
|
-
const requestId = uuid();
|
|
185
|
-
this.capture({ type: MessageType.OnRequest, requestId, serviceMethod: method });
|
|
186
|
-
const result = {
|
|
187
|
-
data: METHOD_NOT_REGISTERED,
|
|
188
|
-
};
|
|
189
|
-
this.capture({
|
|
190
|
-
type: MessageType.OnRequestResult,
|
|
191
|
-
status: ResponseStatus.Fail,
|
|
192
|
-
requestId,
|
|
193
|
-
serviceMethod: method,
|
|
194
|
-
error: result.data,
|
|
195
|
-
});
|
|
196
|
-
return result;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|