@opensumi/ide-connection 2.27.3-next-1706686746.0 → 2.27.3-rc-1706687185.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.
Files changed (91) hide show
  1. package/lib/browser/ws-channel-handler.d.ts.map +1 -1
  2. package/lib/browser/ws-channel-handler.js +4 -0
  3. package/lib/browser/ws-channel-handler.js.map +1 -1
  4. package/lib/common/connection/drivers/base.d.ts +1 -0
  5. package/lib/common/connection/drivers/base.d.ts.map +1 -1
  6. package/lib/common/connection/drivers/base.js +4 -0
  7. package/lib/common/connection/drivers/base.js.map +1 -1
  8. package/lib/common/ext-rpc-protocol.d.ts.map +1 -1
  9. package/lib/common/ext-rpc-protocol.js +2 -3
  10. package/lib/common/ext-rpc-protocol.js.map +1 -1
  11. package/lib/common/proxy/base.d.ts +8 -16
  12. package/lib/common/proxy/base.d.ts.map +1 -1
  13. package/lib/common/proxy/base.js +21 -62
  14. package/lib/common/proxy/base.js.map +1 -1
  15. package/lib/common/proxy/legacy.d.ts +7 -3
  16. package/lib/common/proxy/legacy.d.ts.map +1 -1
  17. package/lib/common/proxy/legacy.js +135 -88
  18. package/lib/common/proxy/legacy.js.map +1 -1
  19. package/lib/common/rpc-service/center.d.ts +1 -5
  20. package/lib/common/rpc-service/center.d.ts.map +1 -1
  21. package/lib/common/rpc-service/center.js +16 -36
  22. package/lib/common/rpc-service/center.js.map +1 -1
  23. package/lib/common/rpc-service/stub.d.ts.map +1 -1
  24. package/lib/common/rpc-service/stub.js +5 -1
  25. package/lib/common/rpc-service/stub.js.map +1 -1
  26. package/lib/common/types.d.ts +1 -1
  27. package/lib/common/types.d.ts.map +1 -1
  28. package/lib/common/ws-channel.d.ts +18 -86
  29. package/lib/common/ws-channel.d.ts.map +1 -1
  30. package/lib/common/ws-channel.js +33 -80
  31. package/lib/common/ws-channel.js.map +1 -1
  32. package/package.json +4 -4
  33. package/src/browser/ws-channel-handler.ts +4 -0
  34. package/src/common/connection/drivers/base.ts +6 -0
  35. package/src/common/ext-rpc-protocol.ts +2 -4
  36. package/src/common/proxy/base.ts +28 -80
  37. package/src/common/proxy/legacy.ts +147 -97
  38. package/src/common/rpc-service/center.ts +16 -46
  39. package/src/common/rpc-service/stub.ts +5 -1
  40. package/src/common/types.ts +1 -1
  41. package/src/common/ws-channel.ts +35 -103
  42. package/lib/common/fury-extends/one-of.d.ts +0 -14
  43. package/lib/common/fury-extends/one-of.d.ts.map +0 -1
  44. package/lib/common/fury-extends/one-of.js +0 -53
  45. package/lib/common/fury-extends/one-of.js.map +0 -1
  46. package/lib/common/protocols/common-server.d.ts +0 -3
  47. package/lib/common/protocols/common-server.d.ts.map +0 -1
  48. package/lib/common/protocols/common-server.js +0 -18
  49. package/lib/common/protocols/common-server.js.map +0 -1
  50. package/lib/common/protocols/common.d.ts +0 -24
  51. package/lib/common/protocols/common.d.ts.map +0 -1
  52. package/lib/common/protocols/common.js +0 -12
  53. package/lib/common/protocols/common.js.map +0 -1
  54. package/lib/common/proxy/runner.d.ts +0 -20
  55. package/lib/common/proxy/runner.d.ts.map +0 -1
  56. package/lib/common/proxy/runner.js +0 -46
  57. package/lib/common/proxy/runner.js.map +0 -1
  58. package/lib/common/proxy/sumi.d.ts +0 -9
  59. package/lib/common/proxy/sumi.d.ts.map +0 -1
  60. package/lib/common/proxy/sumi.js +0 -86
  61. package/lib/common/proxy/sumi.js.map +0 -1
  62. package/lib/common/rpc/connection.d.ts +0 -29
  63. package/lib/common/rpc/connection.d.ts.map +0 -1
  64. package/lib/common/rpc/connection.js +0 -195
  65. package/lib/common/rpc/connection.js.map +0 -1
  66. package/lib/common/rpc/index.d.ts +0 -2
  67. package/lib/common/rpc/index.d.ts.map +0 -1
  68. package/lib/common/rpc/index.js +0 -5
  69. package/lib/common/rpc/index.js.map +0 -1
  70. package/lib/common/rpc/packet.d.ts +0 -49
  71. package/lib/common/rpc/packet.d.ts.map +0 -1
  72. package/lib/common/rpc/packet.js +0 -69
  73. package/lib/common/rpc/packet.js.map +0 -1
  74. package/lib/common/rpc/protocol-repository.d.ts +0 -32
  75. package/lib/common/rpc/protocol-repository.d.ts.map +0 -1
  76. package/lib/common/rpc/protocol-repository.js +0 -94
  77. package/lib/common/rpc/protocol-repository.js.map +0 -1
  78. package/lib/common/rpc/types.d.ts +0 -13
  79. package/lib/common/rpc/types.d.ts.map +0 -1
  80. package/lib/common/rpc/types.js +0 -3
  81. package/lib/common/rpc/types.js.map +0 -1
  82. package/src/common/fury-extends/one-of.ts +0 -63
  83. package/src/common/protocols/common-server.ts +0 -18
  84. package/src/common/protocols/common.ts +0 -9
  85. package/src/common/proxy/runner.ts +0 -58
  86. package/src/common/proxy/sumi.ts +0 -81
  87. package/src/common/rpc/connection.ts +0 -247
  88. package/src/common/rpc/index.ts +0 -1
  89. package/src/common/rpc/packet.ts +0 -85
  90. package/src/common/rpc/protocol-repository.ts +0 -148
  91. package/src/common/rpc/types.ts +0 -23
@@ -1,6 +1,6 @@
1
1
  import type net from 'net';
2
2
 
3
- import { Type } from '@furyjs/fury';
3
+ import Fury, { Type } from '@furyjs/fury';
4
4
  import type WebSocket from 'ws';
5
5
 
6
6
  import { EventEmitter } from '@opensumi/events';
@@ -8,10 +8,7 @@ import { DisposableCollection } from '@opensumi/ide-core-common';
8
8
 
9
9
  import { NetSocketConnection, WSWebSocketConnection } from './connection';
10
10
  import { IConnectionShape } from './connection/types';
11
- import { oneOf } from './fury-extends/one-of';
12
11
  import { createWebSocketConnection } from './message';
13
- import { Connection } from './rpc/connection';
14
- import type { ProtocolRepository } from './rpc/protocol-repository';
15
12
  import { ILogger } from './types';
16
13
 
17
14
  export interface IWebSocket {
@@ -71,12 +68,6 @@ export interface DataMessage {
71
68
  content: string;
72
69
  }
73
70
 
74
- export interface BinaryMessage {
75
- kind: 'binary';
76
- id: string;
77
- binary: Uint8Array;
78
- }
79
-
80
71
  export interface CloseMessage {
81
72
  kind: 'close';
82
73
  id: string;
@@ -84,14 +75,7 @@ export interface CloseMessage {
84
75
  reason: string;
85
76
  }
86
77
 
87
- export type ChannelMessage =
88
- | PingMessage
89
- | PongMessage
90
- | OpenMessage
91
- | ServerReadyMessage
92
- | DataMessage
93
- | BinaryMessage
94
- | CloseMessage;
78
+ export type ChannelMessage = PingMessage | PongMessage | OpenMessage | ServerReadyMessage | DataMessage | CloseMessage;
95
79
 
96
80
  export interface IWSChannelCreateOptions {
97
81
  /**
@@ -108,7 +92,6 @@ export class WSChannel implements IWebSocket {
108
92
  open: [id: string];
109
93
  reopen: [];
110
94
  close: [code?: number, reason?: string];
111
- binary: [data: Uint8Array];
112
95
  }>();
113
96
 
114
97
  public id: string;
@@ -159,19 +142,16 @@ export class WSChannel implements IWebSocket {
159
142
  this.LOG_TAG = `[WSChannel] [id:${id}]`;
160
143
  }
161
144
 
145
+ // server
162
146
  onMessage(cb: (data: string) => any) {
163
147
  return this.emitter.on('message', cb);
164
148
  }
165
- onBinary(cb: (data: Uint8Array) => any) {
166
- return this.emitter.on('binary', cb);
167
- }
168
149
  onOpen(cb: (id: string) => void) {
169
150
  return this.emitter.on('open', cb);
170
151
  }
171
152
  onReopen(cb: () => void) {
172
153
  return this.emitter.on('reopen', cb);
173
154
  }
174
-
175
155
  serverReady() {
176
156
  this.connection.send(
177
157
  stringify({
@@ -186,11 +166,10 @@ export class WSChannel implements IWebSocket {
186
166
  this.emitter.emit('open', msg.id);
187
167
  } else if (msg.kind === 'data') {
188
168
  this.emitter.emit('message', msg.content);
189
- } else if (msg.kind === 'binary') {
190
- this.emitter.emit('binary', msg.binary);
191
169
  }
192
170
  }
193
171
 
172
+ // client
194
173
  open(path: string, clientId: string) {
195
174
  this.channelPath = path;
196
175
  this.connection.send(
@@ -202,7 +181,6 @@ export class WSChannel implements IWebSocket {
202
181
  }),
203
182
  );
204
183
  }
205
-
206
184
  send(content: string) {
207
185
  this.connection.send(
208
186
  stringify({
@@ -212,17 +190,9 @@ export class WSChannel implements IWebSocket {
212
190
  }),
213
191
  );
214
192
  }
215
-
216
- sendBinary(data: Uint8Array) {
217
- this.connection.send(
218
- stringify({
219
- kind: 'binary',
220
- id: this.id,
221
- binary: data,
222
- }),
223
- );
193
+ hasMessageListener() {
194
+ return this.emitter.hasListener('message');
224
195
  }
225
-
226
196
  onError() {}
227
197
  close(code?: number, reason?: string) {
228
198
  this.emitter.emit('close', code, reason);
@@ -233,37 +203,9 @@ export class WSChannel implements IWebSocket {
233
203
  onClose(cb: (code: number, reason: string) => void) {
234
204
  return this.emitter.on('close', cb);
235
205
  }
236
- onceClose(cb: (code: number, reason: string) => void) {
237
- return this.emitter.once('close', cb);
238
- }
239
206
  createMessageConnection() {
240
207
  return createWebSocketConnection(this);
241
208
  }
242
- createConnection(protocolRepository: ProtocolRepository) {
243
- const conn = new Connection({
244
- onceClose: (cb) => {
245
- const toRemove = this.onceClose(cb);
246
- return {
247
- dispose() {
248
- toRemove();
249
- },
250
- };
251
- },
252
- onMessage: (cb) => {
253
- const remove = this.onBinary(cb);
254
- return {
255
- dispose: () => {
256
- remove();
257
- },
258
- };
259
- },
260
- send: (data) => {
261
- this.sendBinary(data);
262
- },
263
- });
264
- conn.setProtocolRepository(protocolRepository);
265
- return conn;
266
- }
267
209
  dispose() {
268
210
  this.emitter.dispose();
269
211
  }
@@ -272,9 +214,6 @@ export class WSChannel implements IWebSocket {
272
214
  channel.onMessage((data) => {
273
215
  this.send(data);
274
216
  });
275
- channel.onBinary((binary) => {
276
- this.sendBinary(binary);
277
- });
278
217
  channel.onClose((code, reason) => {
279
218
  this.close(code, reason);
280
219
  });
@@ -284,56 +223,49 @@ export class WSChannel implements IWebSocket {
284
223
  }
285
224
  }
286
225
 
287
- export const PingProtocol = Type.object('ping', {
288
- clientId: Type.string(),
289
- id: Type.string(),
290
- });
226
+ export type MessageString = string & {
227
+ origin?: any;
228
+ };
291
229
 
292
- export const PongProtocol = Type.object('pong', {
293
- clientId: Type.string(),
294
- id: Type.string(),
295
- });
230
+ /**
231
+ * 路径信息 ${pre}-${index}
232
+ */
233
+ export class ChildConnectPath {
234
+ public pathPre = 'child_connect-';
296
235
 
297
- export const OpenProtocol = Type.object('open', {
298
- clientId: Type.string(),
299
- id: Type.string(),
300
- path: Type.string(),
301
- });
236
+ getConnectPath(index: number, clientId: string) {
237
+ return `${this.pathPre}${index + 1}`;
238
+ }
302
239
 
303
- export const ServerReadyProtocol = Type.object('server-ready', {
304
- id: Type.string(),
305
- });
240
+ parseInfo(pathString: string) {
241
+ const list = pathString.split('-');
306
242
 
307
- export const DataProtocol = Type.object('data', {
308
- id: Type.string(),
309
- content: Type.string(),
310
- });
243
+ return {
244
+ pre: list[0],
245
+ index: list[1],
246
+ clientId: list[2],
247
+ };
248
+ }
249
+ }
311
250
 
312
- export const BinaryProtocol = Type.object('binary', {
313
- id: Type.string(),
314
- binary: Type.binary(),
315
- });
251
+ const fury = new Fury({});
316
252
 
317
- export const CloseProtocol = Type.object('close', {
253
+ export const wsChannelProtocol = Type.object('ws-channel-protocol', {
254
+ kind: Type.string(),
255
+ clientId: Type.string(),
318
256
  id: Type.string(),
257
+ path: Type.string(),
258
+ content: Type.string(),
319
259
  code: Type.uint32(),
320
260
  reason: Type.string(),
321
261
  });
322
262
 
323
- const serializer = oneOf([
324
- PingProtocol,
325
- PongProtocol,
326
- OpenProtocol,
327
- ServerReadyProtocol,
328
- DataProtocol,
329
- BinaryProtocol,
330
- CloseProtocol,
331
- ]);
263
+ const wsChannelProtocolSerializer = fury.registerSerializer(wsChannelProtocol);
332
264
 
333
265
  export function stringify(obj: ChannelMessage): Uint8Array {
334
- return serializer.serialize(obj);
266
+ return wsChannelProtocolSerializer.serialize(obj);
335
267
  }
336
268
 
337
269
  export function parse(input: Uint8Array): ChannelMessage {
338
- return serializer.deserialize(input) as any;
270
+ return wsChannelProtocolSerializer.deserialize(input) as any;
339
271
  }
@@ -1,14 +0,0 @@
1
- import { TypeDescription } from '@furyjs/fury';
2
- type Writable = Record<string, any> & {
3
- kind: string;
4
- };
5
- export declare const oneOf: (schemas: TypeDescription[]) => {
6
- deserialize: (bytes: Uint8Array) => any;
7
- serialize: (v: Writable) => import("@furyjs/fury/dist/lib/platformBuffer").PlatformBuffer;
8
- serializeVolatile: (v: Writable) => {
9
- get(): Uint8Array;
10
- dispose(): void;
11
- };
12
- };
13
- export {};
14
- //# sourceMappingURL=one-of.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"one-of.d.ts","sourceRoot":"","sources":["../../../src/common/fury-extends/one-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,eAAe,EAAE,MAAM,cAAc,CAAC;AAIlF,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAMvD,eAAO,MAAM,KAAK,YAAa,eAAe,EAAE;yBAOlB,UAAU;mBA2BhB,QAAQ;2BAbA,QAAQ;;;;CA+BvC,CAAC"}
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.oneOf = void 0;
4
- const tslib_1 = require("tslib");
5
- const fury_1 = tslib_1.__importDefault(require("@furyjs/fury/dist/lib/fury"));
6
- const gen_1 = require("@furyjs/fury/dist/lib/gen");
7
- const fury = (0, fury_1.default)({});
8
- const reader = fury.binaryReader;
9
- const writer = fury.binaryWriter;
10
- const oneOf = (schemas) => {
11
- const registry = new Map();
12
- schemas.forEach((schema) => {
13
- registry.set(schema.options.tag, (0, gen_1.generateSerializer)(fury, schema));
14
- });
15
- const deserialize = (bytes) => {
16
- reader.reset(bytes);
17
- const kind = reader.stringOfVarUInt32();
18
- const serializer = registry.get(kind);
19
- if (!serializer) {
20
- throw new Error(`Unknown kind: ${kind}`);
21
- }
22
- const v = serializer.read();
23
- v.kind = kind;
24
- return v;
25
- };
26
- const serializeVolatile = (v) => {
27
- const serializer = registry.get(v.kind);
28
- if (!serializer) {
29
- throw new Error(`Unknown kind: ${v.kind}`);
30
- }
31
- writer.reset();
32
- writer.stringOfVarUInt32(v.kind);
33
- serializer.write(v);
34
- return writer.dumpAndOwn();
35
- };
36
- const serialize = (v) => {
37
- const serializer = registry.get(v.kind);
38
- if (!serializer) {
39
- throw new Error(`Unknown kind: ${v.kind}`);
40
- }
41
- writer.reset();
42
- writer.stringOfVarUInt32(v.kind);
43
- serializer.write(v);
44
- return writer.dump();
45
- };
46
- return {
47
- deserialize,
48
- serialize,
49
- serializeVolatile,
50
- };
51
- };
52
- exports.oneOf = oneOf;
53
- //# sourceMappingURL=one-of.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"one-of.js","sourceRoot":"","sources":["../../../src/common/fury-extends/one-of.ts"],"names":[],"mappings":";;;;AACA,8EAA8C;AAC9C,mDAA+D;AAI/D,MAAM,IAAI,GAAG,IAAA,cAAI,EAAC,EAAE,CAAC,CAAC;AACtB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;AACjC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;AAE1B,MAAM,KAAK,GAAG,CAAC,OAA0B,EAAE,EAAE;IAClD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE/C,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACzB,QAAQ,CAAC,GAAG,CAAE,MAAgC,CAAC,OAAO,CAAC,GAAG,EAAE,IAAA,wBAAkB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,CAAC,KAAiB,EAAE,EAAE;QACxC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACxC,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CA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
- //# sourceMappingURL=common-server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common-server.d.ts","sourceRoot":"","sources":["../../../src/common/protocols/common-server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,eAAO,MAAM,oBAAoB,eAWf,CAAC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonServerProtocol = void 0;
4
- const fury_1 = require("@furyjs/fury");
5
- const ide_core_common_1 = require("@opensumi/ide-core-common");
6
- exports.CommonServerProtocol = {
7
- name: ide_core_common_1.CommonServerPath,
8
- methods: [
9
- {
10
- method: 'getBackendOS',
11
- request: [],
12
- response: {
13
- type: fury_1.Type.uint16(),
14
- },
15
- },
16
- ],
17
- };
18
- //# sourceMappingURL=common-server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common-server.js","sourceRoot":"","sources":["../../../src/common/protocols/common-server.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AAEpC,+DAA6D;AAIhD,QAAA,oBAAoB,GAAG;IAClC,IAAI,EAAE,kCAAgB;IACtB,OAAO,EAAE;QACP;YACE,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE;gBACR,IAAI,EAAE,WAAI,CAAC,MAAM,EAAE;aACpB;SACF;KACF;CACe,CAAC"}
@@ -1,24 +0,0 @@
1
- export declare const UriComponentsProto: {
2
- type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
3
- options: {
4
- tag: string;
5
- props: {
6
- scheme: {
7
- type: import("@furyjs/fury").InternalSerializerType.STRING;
8
- };
9
- authority: {
10
- type: import("@furyjs/fury").InternalSerializerType.STRING;
11
- };
12
- path: {
13
- type: import("@furyjs/fury").InternalSerializerType.STRING;
14
- };
15
- query: {
16
- type: import("@furyjs/fury").InternalSerializerType.STRING;
17
- };
18
- fragment: {
19
- type: import("@furyjs/fury").InternalSerializerType.STRING;
20
- };
21
- } | undefined;
22
- };
23
- };
24
- //# sourceMappingURL=common.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common/protocols/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;CAM7B,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UriComponentsProto = void 0;
4
- const fury_1 = require("@furyjs/fury");
5
- exports.UriComponentsProto = fury_1.Type.object('uri-components', {
6
- scheme: fury_1.Type.string(),
7
- authority: fury_1.Type.string(),
8
- path: fury_1.Type.string(),
9
- query: fury_1.Type.string(),
10
- fragment: fury_1.Type.string(),
11
- });
12
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/common/protocols/common.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AAEvB,QAAA,kBAAkB,GAAG,WAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9D,MAAM,EAAE,WAAI,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,WAAI,CAAC,MAAM,EAAE;IACxB,IAAI,EAAE,WAAI,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,WAAI,CAAC,MAAM,EAAE;IACpB,QAAQ,EAAE,WAAI,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC"}
@@ -1,20 +0,0 @@
1
- import { EventEmitter } from '@opensumi/events';
2
- import { RPCServiceMethod } from '../types';
3
- /**
4
- * Store all executable services
5
- */
6
- export declare class ServiceRunner {
7
- protected emitter: EventEmitter<{
8
- servicesUpdate: [services: string[]];
9
- }>;
10
- private serviceMethodMap;
11
- register(name: string, methodFn: RPCServiceMethod): void;
12
- registerService(service: any, options?: {
13
- nameConverter?: (str: string) => string;
14
- }): void;
15
- has(name: PropertyKey): boolean;
16
- run(name: PropertyKey, ...args: any[]): any;
17
- getServices(): string[];
18
- onServicesUpdate(cb: (services: string[]) => void): void;
19
- }
20
- //# sourceMappingURL=runner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/common/proxy/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAkB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5D;;GAEG;AACH,qBAAa,aAAa;IACxB,SAAS,CAAC,OAAO;wBACC,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;OACjC;IAEL,OAAO,CAAC,gBAAgB,CAAmC;IAE3D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB;IAKjD,eAAe,CACb,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;KACzC;IAkBH,GAAG,CAAC,IAAI,EAAE,WAAW;IAIrB,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG;IAI3C,WAAW;IAIX,gBAAgB,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI;CAGlD"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServiceRunner = void 0;
4
- const events_1 = require("@opensumi/events");
5
- const utils_1 = require("../utils");
6
- /**
7
- * Store all executable services
8
- */
9
- class ServiceRunner {
10
- constructor() {
11
- this.emitter = new events_1.EventEmitter();
12
- this.serviceMethodMap = {};
13
- }
14
- register(name, methodFn) {
15
- this.serviceMethodMap[name] = methodFn;
16
- this.emitter.emit('servicesUpdate', [name]);
17
- }
18
- registerService(service, options) {
19
- const serviceNames = [];
20
- const { nameConverter } = options || {};
21
- const methods = (0, utils_1.getServiceMethods)(service);
22
- for (const method of methods) {
23
- let methodName = method;
24
- if (nameConverter) {
25
- methodName = nameConverter(method);
26
- }
27
- this.serviceMethodMap[methodName] = service[method].bind(service);
28
- serviceNames.push(methodName);
29
- }
30
- this.emitter.emit('servicesUpdate', serviceNames);
31
- }
32
- has(name) {
33
- return !!this.serviceMethodMap[name];
34
- }
35
- run(name, ...args) {
36
- return this.serviceMethodMap[name](...args);
37
- }
38
- getServices() {
39
- return Object.keys(this.serviceMethodMap);
40
- }
41
- onServicesUpdate(cb) {
42
- this.emitter.on('servicesUpdate', cb);
43
- }
44
- }
45
- exports.ServiceRunner = ServiceRunner;
46
- //# sourceMappingURL=runner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/common/proxy/runner.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAGhD,oCAA6C;AAE7C;;GAEG;AACH,MAAa,aAAa;IAA1B;QACY,YAAO,GAAG,IAAI,qBAAY,EAEhC,CAAC;QAEG,qBAAgB,GAAG,EAA+B,CAAC;IA4C7D,CAAC;IA1CC,QAAQ,CAAC,IAAY,EAAE,QAA0B;QAC/C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;QACvC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,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,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAClE,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC/B;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC;IAED,GAAG,CAAC,IAAiB;QACnB,OAAO,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,IAAiB,EAAE,GAAG,IAAW;QACnC,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,WAAW;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,gBAAgB,CAAC,EAAgC;QAC/C,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;CACF;AAjDD,sCAiDC"}
@@ -1,9 +0,0 @@
1
- import { Connection } from '../rpc/connection';
2
- import { ProxyBase } from './base';
3
- export declare class ProxySumi extends ProxyBase<Connection> {
4
- protected engine: "sumi";
5
- protected bindMethods(methods: string[]): void;
6
- getInvokeProxy<T = any>(): T;
7
- listen(connection: Connection): void;
8
- }
9
- //# sourceMappingURL=sumi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sumi.d.ts","sourceRoot":"","sources":["../../../src/common/proxy/sumi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,qBAAa,SAAU,SAAQ,SAAS,CAAC,UAAU,CAAC;IAClD,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,UAAU,GAAG,IAAI;CAWrC"}
@@ -1,86 +0,0 @@
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.runner.run(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.runner.run(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
- const prop = p.toString();
45
- if (!target[prop]) {
46
- target[prop] = async (...args) => {
47
- await this.connectionPromise.promise;
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[prop];
70
- },
71
- });
72
- }
73
- listen(connection) {
74
- super.listen(connection);
75
- connection.onRequestNotFound((method) => {
76
- if (!this.runner.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
@@ -1 +0,0 @@
1
- {"version":3,"file":"sumi.js","sourceRoot":"","sources":["../../../src/common/proxy/sumi.ts"],"names":[],"mappings":";;;AAAA,4CAAqD;AAGrD,iCAAmC;AAEnC,MAAa,SAAU,SAAQ,gBAAqB;IAApD;;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,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;qBACxC;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,S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E,IAAI,EAAE,IAAI,CAAC,CAAC;4BAC/C,IAAI;gCACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,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,IAAI,CAAC,CAAC;YACtB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,UAAsB;QAC3B,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzB,UAAU,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,EAAE;YACtC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAC5B,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"}
@@ -1,29 +0,0 @@
1
- import { DisposableCollection, IDisposable } from '@opensumi/ide-utils';
2
- import { BaseConnection } from '../connection';
3
- import { ProtocolRepository } from './protocol-repository';
4
- import { TGenericNotificationHandler, TGenericRequestHandler, TOnNotificationNotFoundHandler, TOnRequestNotFoundHandler } from './types';
5
- export declare class Connection implements IDisposable {
6
- private socket;
7
- protected disposable: DisposableCollection;
8
- private _binaryEmitter;
9
- private _notificationEmitter;
10
- private _innerEventEmitter;
11
- private _requestId;
12
- private _callbacks;
13
- private protocolRepository;
14
- constructor(socket: BaseConnection<Uint8Array>);
15
- sendNotification(method: string, ...args: any[]): void;
16
- sendRequest(method: string, ...args: any[]): Promise<any>;
17
- onNotification(method: string, handler: TGenericNotificationHandler): IDisposable;
18
- onNotificationNotFound(handler: TOnNotificationNotFoundHandler): IDisposable;
19
- private runRequestHandler;
20
- onRequest<T = any>(method: string, handler: TGenericRequestHandler<T>): IDisposable;
21
- onRequestNotFound(handler: TOnRequestNotFoundHandler): IDisposable;
22
- setProtocolRepository(protocolRepository: ProtocolRepository): void;
23
- listen(): void;
24
- dispose(): void;
25
- }
26
- export declare class MethodProtocolNotFoundError extends Error {
27
- constructor(method: string);
28
- }
29
- //# sourceMappingURL=connection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/common/rpc/connection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAA0B,MAAM,qBAAqB,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAY/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,EAE1B,MAAM,SAAS,CAAC;AAiBjB,qBAAa,UAAW,YAAW,WAAW;IAoBhC,OAAO,CAAC,MAAM;IAnB1B,SAAS,CAAC,UAAU,uBAA8B;IAElD,OAAO,CAAC,cAAc,CAEjB;IACL,OAAO,CAAC,oBAAoB,CAEvB;IAEL,OAAO,CAAC,kBAAkB,CAGrB;IAEL,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,UAAU,CAAuC;IAEzD,OAAO,CAAC,kBAAkB,CAAqB;gBAE3B,MAAM,EAAE,cAAc,CAAC,UAA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