@opensumi/ide-connection 2.27.3-rc-1713838390.0 → 2.27.3-rc-1714116491.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/common/capturer.d.ts +21 -1
- package/lib/common/capturer.d.ts.map +1 -1
- package/lib/common/capturer.js +130 -4
- package/lib/common/capturer.js.map +1 -1
- package/lib/common/index.d.ts +0 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +0 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/rpc/connection.d.ts +8 -2
- package/lib/common/rpc/connection.d.ts.map +1 -1
- package/lib/common/rpc/connection.js +17 -6
- package/lib/common/rpc/connection.js.map +1 -1
- package/lib/common/rpc/multiplexer.d.ts +9 -6
- package/lib/common/rpc/multiplexer.d.ts.map +1 -1
- package/lib/common/rpc/multiplexer.js +23 -23
- package/lib/common/rpc/multiplexer.js.map +1 -1
- package/lib/common/rpc-service/center.d.ts +1 -1
- package/lib/common/rpc-service/center.d.ts.map +1 -1
- package/lib/common/rpc-service/center.js.map +1 -1
- package/lib/common/rpc-service/proxy/base.d.ts +2 -11
- package/lib/common/rpc-service/proxy/base.d.ts.map +1 -1
- package/lib/common/rpc-service/proxy/base.js +3 -82
- package/lib/common/rpc-service/proxy/base.js.map +1 -1
- package/lib/common/rpc-service/proxy/json.d.ts +3 -1
- package/lib/common/rpc-service/proxy/json.d.ts.map +1 -1
- package/lib/common/rpc-service/proxy/json.js +12 -10
- package/lib/common/rpc-service/proxy/json.js.map +1 -1
- package/lib/common/rpc-service/proxy/sumi.d.ts.map +1 -1
- package/lib/common/rpc-service/proxy/sumi.js +3 -31
- package/lib/common/rpc-service/proxy/sumi.js.map +1 -1
- package/lib/common/rpc-service/registry.d.ts +1 -1
- package/lib/common/rpc-service/registry.d.ts.map +1 -1
- package/lib/common/rpc-service/registry.js +16 -15
- package/lib/common/rpc-service/registry.js.map +1 -1
- package/lib/common/ws-channel.d.ts +0 -1
- package/lib/common/ws-channel.d.ts.map +1 -1
- package/lib/common/ws-channel.js +0 -4
- package/lib/common/ws-channel.js.map +1 -1
- package/package.json +5 -5
- package/src/common/capturer.ts +169 -3
- package/src/common/index.ts +0 -1
- package/src/common/rpc/connection.ts +34 -7
- package/src/common/rpc/multiplexer.ts +31 -26
- package/src/common/rpc-service/center.ts +2 -1
- package/src/common/rpc-service/proxy/base.ts +5 -101
- package/src/common/rpc-service/proxy/json.ts +14 -12
- package/src/common/rpc-service/proxy/sumi.ts +3 -30
- package/src/common/rpc-service/registry.ts +20 -15
- package/src/common/ws-channel.ts +0 -4
|
@@ -10,7 +10,6 @@ export class ProxySumi extends ProxyBase<SumiConnection> {
|
|
|
10
10
|
for (const method of methods) {
|
|
11
11
|
if (method.startsWith('on')) {
|
|
12
12
|
this.connection.onNotification(method, async (...args: any[]) => {
|
|
13
|
-
this.captureOnNotification(method, args);
|
|
14
13
|
try {
|
|
15
14
|
await this.registry.invoke(method, ...args);
|
|
16
15
|
} catch (e) {
|
|
@@ -18,19 +17,7 @@ export class ProxySumi extends ProxyBase<SumiConnection> {
|
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
19
|
} else {
|
|
21
|
-
this.connection.onRequest(method, async (...args: any[]) =>
|
|
22
|
-
const requestId = this.nextRequestId();
|
|
23
|
-
this.captureOnRequest(requestId, method, args);
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const result = await this.registry.invoke(method, ...args);
|
|
27
|
-
this.captureOnRequestResult(requestId, method, result);
|
|
28
|
-
return result;
|
|
29
|
-
} catch (e) {
|
|
30
|
-
this.captureOnRequestFail(requestId, method, e);
|
|
31
|
-
throw e;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
20
|
+
this.connection.onRequest(method, async (...args: any[]) => await this.registry.invoke(method, ...args));
|
|
34
21
|
}
|
|
35
22
|
}
|
|
36
23
|
}
|
|
@@ -40,29 +27,15 @@ export class ProxySumi extends ProxyBase<SumiConnection> {
|
|
|
40
27
|
|
|
41
28
|
// 调用方法为 on 开头时,作为单项通知
|
|
42
29
|
if (prop.startsWith('on')) {
|
|
43
|
-
this.captureSendNotification(prop, args);
|
|
44
30
|
this.connection.sendNotification(prop, ...args);
|
|
45
31
|
} else {
|
|
46
|
-
|
|
47
|
-
const requestId = this.nextRequestId();
|
|
48
|
-
this.captureSendRequest(requestId, prop, args);
|
|
49
|
-
try {
|
|
50
|
-
const result = await this.connection.sendRequest(prop, ...args);
|
|
51
|
-
this.captureSendRequestResult(requestId, prop, result);
|
|
52
|
-
return result;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
this.captureSendRequestFail(requestId, prop, error);
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
32
|
+
return await this.connection.sendRequest(prop, ...args);
|
|
57
33
|
}
|
|
58
34
|
}
|
|
59
35
|
|
|
60
36
|
listen(connection: SumiConnection): void {
|
|
61
37
|
super.listen(connection);
|
|
62
|
-
connection.onRequestNotFound((
|
|
63
|
-
const requestId = this.nextRequestId();
|
|
64
|
-
this.captureOnRequest(requestId, method, []);
|
|
65
|
-
this.captureOnRequestFail(requestId, method, METHOD_NOT_REGISTERED);
|
|
38
|
+
connection.onRequestNotFound(() => {
|
|
66
39
|
throw METHOD_NOT_REGISTERED;
|
|
67
40
|
});
|
|
68
41
|
}
|
|
@@ -3,28 +3,33 @@ import { Emitter } from '@opensumi/ide-core-common';
|
|
|
3
3
|
import { MessageIO, TSumiProtocol, TSumiProtocolMethod } from '../rpc';
|
|
4
4
|
import { RPCServiceMethod } from '../types';
|
|
5
5
|
|
|
6
|
+
const skipMethods = new Set(['constructor']);
|
|
7
|
+
|
|
6
8
|
export function getServiceMethods(service: any): string[] {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const props = new Set<string>();
|
|
10
|
+
|
|
11
|
+
let obj = service;
|
|
12
|
+
do {
|
|
13
|
+
const propertyNames = Object.getOwnPropertyNames(obj);
|
|
14
|
+
|
|
15
|
+
for (const prop of propertyNames) {
|
|
16
|
+
if (skipMethods.has(prop)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof service[prop] === 'function') {
|
|
21
|
+
props.add(prop);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
}
|
|
24
|
+
} while ((obj = Object.getPrototypeOf(obj)));
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
const array = Array.from(props);
|
|
27
|
+
array.sort();
|
|
28
|
+
return array;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
|
-
* Store all executable services
|
|
32
|
+
* Store all executable services, and provide a way to invoke them.
|
|
28
33
|
*/
|
|
29
34
|
export class ServiceRegistry {
|
|
30
35
|
protected emitter = new Emitter<string[]>();
|
package/src/common/ws-channel.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { DisposableCollection } from '@opensumi/ide-core-common';
|
|
|
5
5
|
|
|
6
6
|
import { IConnectionShape } from './connection/types';
|
|
7
7
|
import { oneOf7 } from './fury-extends/one-of';
|
|
8
|
-
import { createWebSocketConnection } from './message';
|
|
9
8
|
import { ISumiConnectionOptions, SumiConnection } from './rpc/connection';
|
|
10
9
|
import { ILogger } from './types';
|
|
11
10
|
|
|
@@ -213,9 +212,6 @@ export class WSChannel {
|
|
|
213
212
|
onceClose(cb: (code: number, reason: string) => void) {
|
|
214
213
|
return this.emitter.once('close', cb);
|
|
215
214
|
}
|
|
216
|
-
createMessageConnection() {
|
|
217
|
-
return createWebSocketConnection(this);
|
|
218
|
-
}
|
|
219
215
|
|
|
220
216
|
createConnection() {
|
|
221
217
|
return {
|