@opensumi/ide-connection 3.0.4-next-1716529130.0 → 3.0.4-next-1716962745.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 +8 -1
- package/lib/browser/ws-channel-handler.d.ts.map +1 -1
- package/lib/browser/ws-channel-handler.js +10 -21
- package/lib/browser/ws-channel-handler.js.map +1 -1
- package/lib/common/channel/index.d.ts +2 -0
- package/lib/common/channel/index.d.ts.map +1 -0
- package/lib/common/channel/index.js +5 -0
- package/lib/common/channel/index.js.map +1 -0
- package/lib/common/channel/types.d.ts +66 -0
- package/lib/common/channel/types.d.ts.map +1 -0
- package/lib/common/channel/types.js +8 -0
- package/lib/common/channel/types.js.map +1 -0
- package/lib/common/connection/drivers/simple.d.ts +7 -7
- package/lib/common/connection/drivers/simple.d.ts.map +1 -1
- package/lib/common/connection/drivers/simple.js.map +1 -1
- package/lib/common/index.d.ts +4 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +4 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/rpc/connection.d.ts +4 -3
- package/lib/common/rpc/connection.d.ts.map +1 -1
- package/lib/common/rpc/connection.js +14 -30
- package/lib/common/rpc/connection.js.map +1 -1
- package/lib/common/rpc/message-io.d.ts +54 -11
- package/lib/common/rpc/message-io.d.ts.map +1 -1
- package/lib/common/rpc/message-io.js +63 -10
- package/lib/common/rpc/message-io.js.map +1 -1
- package/lib/common/rpc/multiplexer.d.ts +2 -0
- package/lib/common/rpc/multiplexer.d.ts.map +1 -1
- package/lib/common/rpc/multiplexer.js +1 -0
- package/lib/common/rpc/multiplexer.js.map +1 -1
- package/lib/common/rpc-service/index.d.ts +1 -0
- package/lib/common/rpc-service/index.d.ts.map +1 -1
- package/lib/common/rpc-service/index.js +1 -0
- package/lib/common/rpc-service/index.js.map +1 -1
- package/lib/common/rpc-service/registry.d.ts +2 -2
- package/lib/common/rpc-service/registry.d.ts.map +1 -1
- package/lib/common/rpc-service/registry.js +6 -0
- package/lib/common/rpc-service/registry.js.map +1 -1
- package/lib/common/serializer/fury.d.ts +122 -0
- package/lib/common/serializer/fury.d.ts.map +1 -0
- package/lib/common/serializer/fury.js +51 -0
- package/lib/common/serializer/fury.js.map +1 -0
- package/lib/common/serializer/index.d.ts +6 -0
- package/lib/common/serializer/index.d.ts.map +1 -0
- package/lib/common/serializer/index.js +21 -0
- package/lib/common/serializer/index.js.map +1 -0
- package/lib/common/serializer/raw.d.ts +4 -0
- package/lib/common/serializer/raw.d.ts.map +1 -0
- package/lib/common/serializer/raw.js +8 -0
- package/lib/common/serializer/raw.js.map +1 -0
- package/lib/common/serializer/types.d.ts +5 -0
- package/lib/common/serializer/types.d.ts.map +1 -0
- package/lib/common/serializer/types.js +3 -0
- package/lib/common/serializer/types.js.map +1 -0
- package/lib/common/server-handler.d.ts +7 -1
- package/lib/common/server-handler.d.ts.map +1 -1
- package/lib/common/server-handler.js +13 -11
- package/lib/common/server-handler.js.map +1 -1
- package/lib/common/ws-channel.d.ts +11 -201
- package/lib/common/ws-channel.d.ts.map +1 -1
- package/lib/common/ws-channel.js +49 -85
- package/lib/common/ws-channel.js.map +1 -1
- package/package.json +5 -5
- package/src/browser/ws-channel-handler.ts +26 -23
- package/src/common/channel/index.ts +1 -0
- package/src/common/channel/types.ts +82 -0
- package/src/common/connection/drivers/simple.ts +5 -5
- package/src/common/index.ts +4 -0
- package/src/common/rpc/connection.ts +19 -36
- package/src/common/rpc/message-io.ts +123 -10
- package/src/common/rpc/multiplexer.ts +3 -1
- package/src/common/rpc-service/index.ts +1 -0
- package/src/common/rpc-service/registry.ts +10 -2
- package/src/common/serializer/fury.ts +61 -0
- package/src/common/serializer/index.ts +23 -0
- package/src/common/serializer/raw.ts +8 -0
- package/src/common/serializer/types.ts +4 -0
- package/src/common/server-handler.ts +24 -26
- package/src/common/ws-channel.ts +72 -207
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RPCServiceChannelPath = exports.BaseCommonChannelHandler = exports.commonChannelPathHandler = exports.CommonChannelPathHandler = void 0;
|
|
4
|
+
const types_1 = require("./channel/types");
|
|
5
|
+
const serializer_1 = require("./serializer");
|
|
4
6
|
const ws_channel_1 = require("./ws-channel");
|
|
5
7
|
class CommonChannelPathHandler {
|
|
6
8
|
constructor() {
|
|
@@ -89,11 +91,15 @@ class CommonChannelPathHandler {
|
|
|
89
91
|
exports.CommonChannelPathHandler = CommonChannelPathHandler;
|
|
90
92
|
exports.commonChannelPathHandler = new CommonChannelPathHandler();
|
|
91
93
|
class BaseCommonChannelHandler {
|
|
92
|
-
constructor(handlerId, logger = console) {
|
|
94
|
+
constructor(handlerId, logger = console, options = {}) {
|
|
93
95
|
this.handlerId = handlerId;
|
|
94
96
|
this.logger = logger;
|
|
95
97
|
this.channelMap = new Map();
|
|
96
98
|
this.heartbeatTimer = null;
|
|
99
|
+
this.serializer = serializer_1.furySerializer;
|
|
100
|
+
if (options.serializer) {
|
|
101
|
+
this.serializer = options.serializer;
|
|
102
|
+
}
|
|
97
103
|
}
|
|
98
104
|
heartbeat(connection) {
|
|
99
105
|
if (this.heartbeatTimer) {
|
|
@@ -107,22 +113,18 @@ class BaseCommonChannelHandler {
|
|
|
107
113
|
receiveConnection(connection) {
|
|
108
114
|
let clientId;
|
|
109
115
|
this.heartbeat(connection);
|
|
116
|
+
const wrappedConnection = (0, serializer_1.wrapSerializer)(connection, this.serializer);
|
|
110
117
|
const getOrCreateChannel = (id, clientId) => {
|
|
111
118
|
let channel = this.channelMap.get(id);
|
|
112
119
|
if (!channel) {
|
|
113
|
-
channel = new ws_channel_1.WSServerChannel(
|
|
120
|
+
channel = new ws_channel_1.WSServerChannel(wrappedConnection, { id, clientId, logger: this.logger });
|
|
114
121
|
this.channelMap.set(id, channel);
|
|
115
122
|
}
|
|
116
123
|
return channel;
|
|
117
124
|
};
|
|
118
|
-
|
|
119
|
-
let msg;
|
|
125
|
+
wrappedConnection.onMessage((msg) => {
|
|
120
126
|
try {
|
|
121
|
-
msg = (0, ws_channel_1.parse)(data);
|
|
122
127
|
switch (msg.kind) {
|
|
123
|
-
case 'ping':
|
|
124
|
-
connection.send(ws_channel_1.pongMessage);
|
|
125
|
-
break;
|
|
126
128
|
case 'open': {
|
|
127
129
|
const { id, path, connectionToken } = msg;
|
|
128
130
|
clientId = msg.clientId;
|
|
@@ -139,12 +141,12 @@ class BaseCommonChannelHandler {
|
|
|
139
141
|
channel.dispatch(msg);
|
|
140
142
|
}
|
|
141
143
|
else {
|
|
142
|
-
|
|
144
|
+
wrappedConnection.send({
|
|
143
145
|
kind: 'error',
|
|
144
146
|
id,
|
|
145
|
-
code:
|
|
147
|
+
code: types_1.ErrorMessageCode.ChannelNotFound,
|
|
146
148
|
message: `channel ${id} not found`,
|
|
147
|
-
})
|
|
149
|
+
});
|
|
148
150
|
this.logger.warn(`channel ${id} is not found`);
|
|
149
151
|
}
|
|
150
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-handler.js","sourceRoot":"","sources":["../../src/common/server-handler.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"server-handler.js","sourceRoot":"","sources":["../../src/common/server-handler.ts"],"names":[],"mappings":";;;AAAA,2CAAmE;AAEnE,6CAA8D;AAG9D,6CAA0D;AAS1D,MAAa,wBAAwB;IAArC;QACU,eAAU,GAAgC,IAAI,GAAG,EAAE,CAAC;QACpD,cAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;IAkFrD,CAAC;IAhFC,QAAQ,CAAC,WAAmB,EAAE,OAAqB;QACjD,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,SAAS,GAAG,WAAW,IAAI,CAAC,CAAC;QACnC,IAAI,YAAY,GAAG,WAAW,CAAC;QAC/B,IAAI,SAAS,EAAE;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AK,QAAQ,CAAC;iBAClD,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBACnB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBAC1B,OAAO,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBACnC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SACnC;IACH,CAAC;CACF;AA/FD,4DA+FC;AAEY,QAAA,qBAAqB,GAAG,YAAY,CAAC"}
|
|
@@ -1,45 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from '@opensumi/events';
|
|
3
3
|
import { DisposableStore, EventQueue, StateTracer } from '@opensumi/ide-core-common';
|
|
4
|
+
import { ChannelMessage } from './channel/types';
|
|
4
5
|
import { IConnectionShape } from './connection/types';
|
|
5
6
|
import { ISumiConnectionOptions, SumiConnection } from './rpc/connection';
|
|
6
7
|
import { ILogger } from './types';
|
|
7
|
-
/**
|
|
8
|
-
* `ping` and `pong` are used to detect whether the connection is alive.
|
|
9
|
-
*/
|
|
10
|
-
export interface PingMessage {
|
|
11
|
-
kind: 'ping';
|
|
12
|
-
id: string;
|
|
13
|
-
clientId: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* when server receive a `ping` message, it should reply a `pong` message, vice versa.
|
|
17
|
-
*/
|
|
18
|
-
export interface PongMessage {
|
|
19
|
-
kind: 'pong';
|
|
20
|
-
id: string;
|
|
21
|
-
clientId: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* `data` message indicate that the channel has received some data.
|
|
25
|
-
* the `content` field is the data, it should be a string.
|
|
26
|
-
*/
|
|
27
|
-
export interface DataMessage {
|
|
28
|
-
kind: 'data';
|
|
29
|
-
id: string;
|
|
30
|
-
content: string;
|
|
31
|
-
}
|
|
32
|
-
export interface BinaryMessage {
|
|
33
|
-
kind: 'binary';
|
|
34
|
-
id: string;
|
|
35
|
-
binary: Uint8Array;
|
|
36
|
-
}
|
|
37
|
-
export interface CloseMessage {
|
|
38
|
-
kind: 'close';
|
|
39
|
-
id: string;
|
|
40
|
-
code: number;
|
|
41
|
-
reason: string;
|
|
42
|
-
}
|
|
43
8
|
export interface IWSChannelCreateOptions {
|
|
44
9
|
/**
|
|
45
10
|
* every channel's unique id, it only used in client to server architecture.
|
|
@@ -50,7 +15,7 @@ export interface IWSChannelCreateOptions {
|
|
|
50
15
|
ensureServerReady?: boolean;
|
|
51
16
|
}
|
|
52
17
|
export declare class WSChannel {
|
|
53
|
-
connection: IConnectionShape<
|
|
18
|
+
connection: IConnectionShape<ChannelMessage>;
|
|
54
19
|
protected _disposables: DisposableStore;
|
|
55
20
|
protected emitter: EventEmitter<{
|
|
56
21
|
message: [data: string];
|
|
@@ -60,15 +25,17 @@ export declare class WSChannel {
|
|
|
60
25
|
binary: [data: Uint8Array];
|
|
61
26
|
}>;
|
|
62
27
|
protected onBinaryQueue: EventQueue<Uint8Array>;
|
|
63
|
-
protected sendQueue:
|
|
28
|
+
protected sendQueue: ChannelMessage[];
|
|
64
29
|
protected _isServerReady: boolean;
|
|
65
30
|
protected _ensureServerReady: boolean | undefined;
|
|
66
31
|
id: string;
|
|
67
32
|
channelPath: string;
|
|
33
|
+
clientId: string;
|
|
34
|
+
protected LOG_TAG: string;
|
|
68
35
|
logger: ILogger;
|
|
69
36
|
static forClient(connection: IConnectionShape<Uint8Array>, options: IWSChannelCreateOptions): WSChannel;
|
|
70
|
-
constructor(connection: IConnectionShape<
|
|
71
|
-
protected inqueue(data:
|
|
37
|
+
constructor(connection: IConnectionShape<ChannelMessage>, options: IWSChannelCreateOptions);
|
|
38
|
+
protected inqueue(data: ChannelMessage): void;
|
|
72
39
|
onMessage(cb: (data: string) => any): import("@opensumi/events").IDisposable;
|
|
73
40
|
onBinary(cb: (data: Uint8Array) => any): import("@opensumi/ide-core-common").IDisposable;
|
|
74
41
|
onOpen(cb: (id: string) => void): import("@opensumi/events").IDisposable;
|
|
@@ -101,7 +68,9 @@ export declare class WSChannel {
|
|
|
101
68
|
dispose(): void;
|
|
102
69
|
};
|
|
103
70
|
createSumiConnection(options?: ISumiConnectionOptions): SumiConnection;
|
|
71
|
+
listen(): import("@opensumi/ide-core-common").IDisposable;
|
|
104
72
|
dispose(): void;
|
|
73
|
+
ping(): void;
|
|
105
74
|
}
|
|
106
75
|
interface IWSServerChannelCreateOptions extends IWSChannelCreateOptions {
|
|
107
76
|
clientId: string;
|
|
@@ -110,171 +79,12 @@ interface IWSServerChannelCreateOptions extends IWSChannelCreateOptions {
|
|
|
110
79
|
* The server side channel, it will send a `server-ready` message after it receive a `open` message.
|
|
111
80
|
*/
|
|
112
81
|
export declare class WSServerChannel extends WSChannel {
|
|
113
|
-
connection: IConnectionShape<
|
|
82
|
+
connection: IConnectionShape<ChannelMessage>;
|
|
114
83
|
messageQueue: ChannelMessage[];
|
|
115
84
|
clientId: string;
|
|
116
|
-
constructor(connection: IConnectionShape<
|
|
85
|
+
constructor(connection: IConnectionShape<ChannelMessage>, options: IWSServerChannelCreateOptions);
|
|
117
86
|
serverReady(token: string): void;
|
|
118
87
|
dispatch(msg: ChannelMessage): void;
|
|
119
88
|
}
|
|
120
|
-
export type ChannelMessage = PingMessage | PongMessage | OpenMessage | ServerReadyMessage | DataMessage | BinaryMessage | CloseMessage | ErrorMessage;
|
|
121
|
-
export declare const PingProtocol: {
|
|
122
|
-
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
123
|
-
options: {
|
|
124
|
-
tag: string;
|
|
125
|
-
props: {
|
|
126
|
-
clientId: {
|
|
127
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
128
|
-
};
|
|
129
|
-
id: {
|
|
130
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
131
|
-
};
|
|
132
|
-
} | undefined;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
export declare const PongProtocol: {
|
|
136
|
-
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
137
|
-
options: {
|
|
138
|
-
tag: string;
|
|
139
|
-
props: {
|
|
140
|
-
clientId: {
|
|
141
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
142
|
-
};
|
|
143
|
-
id: {
|
|
144
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
145
|
-
};
|
|
146
|
-
} | undefined;
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* `open` message is used to open a new channel.
|
|
151
|
-
* `path` is used to identify which handler should be used to handle the channel.
|
|
152
|
-
* `clientId` is used to identify the client.
|
|
153
|
-
*/
|
|
154
|
-
export interface OpenMessage {
|
|
155
|
-
kind: 'open';
|
|
156
|
-
id: string;
|
|
157
|
-
path: string;
|
|
158
|
-
clientId: string;
|
|
159
|
-
connectionToken: string;
|
|
160
|
-
}
|
|
161
|
-
export declare const OpenProtocol: {
|
|
162
|
-
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
163
|
-
options: {
|
|
164
|
-
tag: string;
|
|
165
|
-
props: {
|
|
166
|
-
clientId: {
|
|
167
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
168
|
-
};
|
|
169
|
-
id: {
|
|
170
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
171
|
-
};
|
|
172
|
-
path: {
|
|
173
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
174
|
-
};
|
|
175
|
-
connectionToken: {
|
|
176
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
177
|
-
};
|
|
178
|
-
} | undefined;
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* when server receive a `open` message, it should reply a `server-ready` message.
|
|
183
|
-
* this is indicate that the channel is ready to use.
|
|
184
|
-
*/
|
|
185
|
-
export interface ServerReadyMessage {
|
|
186
|
-
kind: 'server-ready';
|
|
187
|
-
id: string;
|
|
188
|
-
token: string;
|
|
189
|
-
}
|
|
190
|
-
export declare const ServerReadyProtocol: {
|
|
191
|
-
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
192
|
-
options: {
|
|
193
|
-
tag: string;
|
|
194
|
-
props: {
|
|
195
|
-
id: {
|
|
196
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
197
|
-
};
|
|
198
|
-
token: {
|
|
199
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
200
|
-
};
|
|
201
|
-
} | undefined;
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
export declare enum ErrorMessageCode {
|
|
205
|
-
ChannelNotFound = 1
|
|
206
|
-
}
|
|
207
|
-
export interface ErrorMessage {
|
|
208
|
-
kind: 'error';
|
|
209
|
-
id: string;
|
|
210
|
-
code: ErrorMessageCode;
|
|
211
|
-
message: string;
|
|
212
|
-
}
|
|
213
|
-
export declare const ErrorProtocol: {
|
|
214
|
-
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
215
|
-
options: {
|
|
216
|
-
tag: string;
|
|
217
|
-
props: {
|
|
218
|
-
id: {
|
|
219
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
220
|
-
};
|
|
221
|
-
code: {
|
|
222
|
-
type: import("@furyjs/fury").InternalSerializerType.UINT16;
|
|
223
|
-
};
|
|
224
|
-
message: {
|
|
225
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
226
|
-
};
|
|
227
|
-
} | undefined;
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
|
-
export declare const DataProtocol: {
|
|
231
|
-
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
232
|
-
options: {
|
|
233
|
-
tag: string;
|
|
234
|
-
props: {
|
|
235
|
-
id: {
|
|
236
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
237
|
-
};
|
|
238
|
-
content: {
|
|
239
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
240
|
-
};
|
|
241
|
-
} | undefined;
|
|
242
|
-
};
|
|
243
|
-
};
|
|
244
|
-
export declare const BinaryProtocol: {
|
|
245
|
-
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
246
|
-
options: {
|
|
247
|
-
tag: string;
|
|
248
|
-
props: {
|
|
249
|
-
id: {
|
|
250
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
251
|
-
};
|
|
252
|
-
binary: {
|
|
253
|
-
type: import("@furyjs/fury").InternalSerializerType.BINARY;
|
|
254
|
-
};
|
|
255
|
-
} | undefined;
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
export declare const CloseProtocol: {
|
|
259
|
-
type: import("@furyjs/fury").InternalSerializerType.FURY_TYPE_TAG;
|
|
260
|
-
options: {
|
|
261
|
-
tag: string;
|
|
262
|
-
props: {
|
|
263
|
-
id: {
|
|
264
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
265
|
-
};
|
|
266
|
-
code: {
|
|
267
|
-
type: import("@furyjs/fury").InternalSerializerType.UINT32;
|
|
268
|
-
};
|
|
269
|
-
reason: {
|
|
270
|
-
type: import("@furyjs/fury").InternalSerializerType.STRING;
|
|
271
|
-
};
|
|
272
|
-
} | undefined;
|
|
273
|
-
};
|
|
274
|
-
};
|
|
275
|
-
export declare function stringify(obj: ChannelMessage): Uint8Array;
|
|
276
|
-
export declare function parse(input: Uint8Array): ChannelMessage;
|
|
277
|
-
export declare const pingMessage: Uint8Array;
|
|
278
|
-
export declare const pongMessage: Uint8Array;
|
|
279
89
|
export {};
|
|
280
90
|
//# sourceMappingURL=ws-channel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-channel.d.ts","sourceRoot":"","sources":["../../src/common/ws-channel.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ws-channel.d.ts","sourceRoot":"","sources":["../../src/common/ws-channel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAEL,eAAe,EACf,UAAU,EACV,WAAW,EAEZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAoB,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,qBAAa,SAAS;IAyCD,UAAU,EAAE,gBAAgB,CAAC,cAAc,CAAC;IAxC/D,SAAS,CAAC,YAAY,kBAAyB;IAC/C,SAAS,CAAC,OAAO;iBAEJ,CAAC,IAAI,EAAE,MAAM,CAAC;cACjB,CAAC,EAAE,EAAE,MAAM,CAAC;gBACV,EAAE;eACH,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC;gBAC/B,CAAC,IAAI,EAAE,UAAU,CAAC;OAE5B;IAEF,SAAS,CAAC,aAAa,yBAAuD;IAE9E,SAAS,CAAC,SAAS,EAAE,cAAc,EAAE,CAAM;IAC3C,SAAS,CAAC,cAAc,UAAS;IACjC,SAAS,CAAC,kBAAkB,EAAE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E,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;IAGlD,SAAS,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;IAIpD,gBAAgB;+BAEW,MAAM,UAAU,MAAM,KAAK,IAAI;+BAC/B,UAAU,KAAK,GAAG;qBAC5B,UAAU;;;IAO3B,oBAAoB,CAAC,OAAO,GAAE,sBAA2B;IAKzD,MAAM;IAMN,OAAO;IAQP,IAAI;CAML;AAED,UAAU,6BAA8B,SAAQ,uBAAuB;IACrE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAIzB,UAAU,EAAE,gBAAgB,CAAC,cAAc,CAAC;IAH/D,YAAY,EAAE,cAAc,EAAE,CAAM;IAEpC,QAAQ,EAAE,MAAM,CAAC;gBACE,UAAU,EAAE,gBAAgB,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,6BAA6B;IAKvG,WAAW,CAAC,KAAK,EAAE,MAAM;IAQzB,QAAQ,CAAC,GAAG,EAAE,cAAc;CAgB7B"}
|
package/lib/common/ws-channel.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const fury_1 = require("@furyjs/fury");
|
|
3
|
+
exports.WSServerChannel = exports.WSChannel = void 0;
|
|
5
4
|
const events_1 = require("@opensumi/events");
|
|
6
5
|
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
7
|
-
const
|
|
6
|
+
const types_1 = require("./channel/types");
|
|
8
7
|
const connection_1 = require("./rpc/connection");
|
|
8
|
+
const serializer_1 = require("./serializer");
|
|
9
9
|
class WSChannel {
|
|
10
10
|
static forClient(connection, options) {
|
|
11
11
|
const disposable = new ide_core_common_1.DisposableCollection();
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}));
|
|
12
|
+
const wrappedConnection = (0, serializer_1.wrapSerializer)(connection, serializer_1.furySerializer);
|
|
13
|
+
const channel = new WSChannel(wrappedConnection, options);
|
|
14
|
+
disposable.push(channel.listen());
|
|
16
15
|
connection.onceClose(() => {
|
|
17
16
|
disposable.dispose();
|
|
18
17
|
});
|
|
@@ -25,10 +24,12 @@ class WSChannel {
|
|
|
25
24
|
this.onBinaryQueue = this._disposables.add(new ide_core_common_1.EventQueue());
|
|
26
25
|
this.sendQueue = [];
|
|
27
26
|
this._isServerReady = false;
|
|
27
|
+
this.LOG_TAG = '[WSChannel]';
|
|
28
28
|
this.logger = console;
|
|
29
29
|
this.stateTracer = this._disposables.add(new ide_core_common_1.StateTracer());
|
|
30
30
|
const { id, logger, ensureServerReady } = options;
|
|
31
31
|
this.id = id;
|
|
32
|
+
this.LOG_TAG = `[WSChannel id=${this.id}]`;
|
|
32
33
|
if (logger) {
|
|
33
34
|
this.logger = logger;
|
|
34
35
|
}
|
|
@@ -92,6 +93,20 @@ class WSChannel {
|
|
|
92
93
|
case 'binary':
|
|
93
94
|
this.emitter.emit('binary', msg.binary);
|
|
94
95
|
break;
|
|
96
|
+
case 'error':
|
|
97
|
+
this.logger.error(this.LOG_TAG, `receive error: id: ${msg.id}, code: ${msg.code}, error: ${msg.message}`);
|
|
98
|
+
switch (msg.code) {
|
|
99
|
+
case types_1.ErrorMessageCode.ChannelNotFound:
|
|
100
|
+
// 有 channelPath 说明该 channel 曾经被打开过
|
|
101
|
+
// 重新打开 channel
|
|
102
|
+
if (this.channelPath) {
|
|
103
|
+
// 暂停消息发送, 直到收到 server-ready
|
|
104
|
+
this.pause();
|
|
105
|
+
this.open(this.channelPath, this.clientId);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
95
110
|
}
|
|
96
111
|
}
|
|
97
112
|
/**
|
|
@@ -99,18 +114,20 @@ class WSChannel {
|
|
|
99
114
|
*/
|
|
100
115
|
open(path, clientId, connectionToken = (0, ide_core_common_1.randomString)(16)) {
|
|
101
116
|
this.channelPath = path;
|
|
117
|
+
this.clientId = clientId;
|
|
118
|
+
this.LOG_TAG = `[WSChannel id=${this.id} path=${path}]`;
|
|
102
119
|
if (this.stateTracer.has(connectionToken)) {
|
|
103
120
|
this.logger.warn(`channel already opened or in progress, path: ${path}, clientId: ${clientId}, connectionToken: ${connectionToken}`);
|
|
104
121
|
return;
|
|
105
122
|
}
|
|
106
123
|
this.stateTracer.record(connectionToken);
|
|
107
|
-
this.connection.send(
|
|
124
|
+
this.connection.send({
|
|
108
125
|
kind: 'open',
|
|
109
126
|
id: this.id,
|
|
110
127
|
path,
|
|
111
128
|
clientId,
|
|
112
129
|
connectionToken,
|
|
113
|
-
})
|
|
130
|
+
});
|
|
114
131
|
if (this._ensureServerReady) {
|
|
115
132
|
this.ensureOpenSend(path, clientId, connectionToken);
|
|
116
133
|
}
|
|
@@ -132,18 +149,18 @@ class WSChannel {
|
|
|
132
149
|
}, 500);
|
|
133
150
|
}
|
|
134
151
|
send(content) {
|
|
135
|
-
this.inqueue(
|
|
152
|
+
this.inqueue({
|
|
136
153
|
kind: 'data',
|
|
137
154
|
id: this.id,
|
|
138
155
|
content,
|
|
139
|
-
})
|
|
156
|
+
});
|
|
140
157
|
}
|
|
141
158
|
sendBinary(data) {
|
|
142
|
-
this.inqueue(
|
|
159
|
+
this.inqueue({
|
|
143
160
|
kind: 'binary',
|
|
144
161
|
id: this.id,
|
|
145
162
|
binary: data,
|
|
146
|
-
})
|
|
163
|
+
});
|
|
147
164
|
}
|
|
148
165
|
onError() { }
|
|
149
166
|
close(code, reason) {
|
|
@@ -173,6 +190,11 @@ class WSChannel {
|
|
|
173
190
|
const conn = new connection_1.SumiConnection(this.createConnection(), options);
|
|
174
191
|
return conn;
|
|
175
192
|
}
|
|
193
|
+
listen() {
|
|
194
|
+
return this.connection.onMessage((data) => {
|
|
195
|
+
this.dispatch(data);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
176
198
|
dispose() {
|
|
177
199
|
if (this.timer) {
|
|
178
200
|
clearTimeout(this.timer);
|
|
@@ -180,6 +202,12 @@ class WSChannel {
|
|
|
180
202
|
this.sendQueue = [];
|
|
181
203
|
this._disposables.dispose();
|
|
182
204
|
}
|
|
205
|
+
ping() {
|
|
206
|
+
this.connection.send({
|
|
207
|
+
kind: 'ping',
|
|
208
|
+
id: this.id,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
183
211
|
}
|
|
184
212
|
exports.WSChannel = WSChannel;
|
|
185
213
|
/**
|
|
@@ -193,11 +221,11 @@ class WSServerChannel extends WSChannel {
|
|
|
193
221
|
this.clientId = options.clientId;
|
|
194
222
|
}
|
|
195
223
|
serverReady(token) {
|
|
196
|
-
this.connection.send(
|
|
224
|
+
this.connection.send({
|
|
197
225
|
kind: 'server-ready',
|
|
198
226
|
id: this.id,
|
|
199
227
|
token,
|
|
200
|
-
})
|
|
228
|
+
});
|
|
201
229
|
}
|
|
202
230
|
dispatch(msg) {
|
|
203
231
|
switch (msg.kind) {
|
|
@@ -207,78 +235,14 @@ class WSServerChannel extends WSChannel {
|
|
|
207
235
|
case 'binary':
|
|
208
236
|
this.emitter.emit('binary', msg.binary);
|
|
209
237
|
break;
|
|
238
|
+
case 'ping':
|
|
239
|
+
this.connection.send({
|
|
240
|
+
kind: 'pong',
|
|
241
|
+
id: this.id,
|
|
242
|
+
});
|
|
243
|
+
break;
|
|
210
244
|
}
|
|
211
245
|
}
|
|
212
246
|
}
|
|
213
247
|
exports.WSServerChannel = WSServerChannel;
|
|
214
|
-
exports.PingProtocol = fury_1.Type.object('ping', {
|
|
215
|
-
clientId: fury_1.Type.string(),
|
|
216
|
-
id: fury_1.Type.string(),
|
|
217
|
-
});
|
|
218
|
-
exports.PongProtocol = fury_1.Type.object('pong', {
|
|
219
|
-
clientId: fury_1.Type.string(),
|
|
220
|
-
id: fury_1.Type.string(),
|
|
221
|
-
});
|
|
222
|
-
exports.OpenProtocol = fury_1.Type.object('open', {
|
|
223
|
-
clientId: fury_1.Type.string(),
|
|
224
|
-
id: fury_1.Type.string(),
|
|
225
|
-
path: fury_1.Type.string(),
|
|
226
|
-
connectionToken: fury_1.Type.string(),
|
|
227
|
-
});
|
|
228
|
-
exports.ServerReadyProtocol = fury_1.Type.object('server-ready', {
|
|
229
|
-
id: fury_1.Type.string(),
|
|
230
|
-
token: fury_1.Type.string(),
|
|
231
|
-
});
|
|
232
|
-
var ErrorMessageCode;
|
|
233
|
-
(function (ErrorMessageCode) {
|
|
234
|
-
ErrorMessageCode[ErrorMessageCode["ChannelNotFound"] = 1] = "ChannelNotFound";
|
|
235
|
-
})(ErrorMessageCode = exports.ErrorMessageCode || (exports.ErrorMessageCode = {}));
|
|
236
|
-
exports.ErrorProtocol = fury_1.Type.object('error', {
|
|
237
|
-
id: fury_1.Type.string(),
|
|
238
|
-
code: fury_1.Type.uint16(),
|
|
239
|
-
message: fury_1.Type.string(),
|
|
240
|
-
});
|
|
241
|
-
exports.DataProtocol = fury_1.Type.object('data', {
|
|
242
|
-
id: fury_1.Type.string(),
|
|
243
|
-
content: fury_1.Type.string(),
|
|
244
|
-
});
|
|
245
|
-
exports.BinaryProtocol = fury_1.Type.object('binary', {
|
|
246
|
-
id: fury_1.Type.string(),
|
|
247
|
-
binary: fury_1.Type.binary(),
|
|
248
|
-
});
|
|
249
|
-
exports.CloseProtocol = fury_1.Type.object('close', {
|
|
250
|
-
id: fury_1.Type.string(),
|
|
251
|
-
code: fury_1.Type.uint32(),
|
|
252
|
-
reason: fury_1.Type.string(),
|
|
253
|
-
});
|
|
254
|
-
const serializer = (0, one_of_1.oneOf)([
|
|
255
|
-
exports.PingProtocol,
|
|
256
|
-
exports.PongProtocol,
|
|
257
|
-
exports.OpenProtocol,
|
|
258
|
-
exports.ServerReadyProtocol,
|
|
259
|
-
exports.DataProtocol,
|
|
260
|
-
exports.BinaryProtocol,
|
|
261
|
-
exports.CloseProtocol,
|
|
262
|
-
exports.ErrorProtocol,
|
|
263
|
-
]);
|
|
264
|
-
function stringify(obj) {
|
|
265
|
-
return serializer.serialize(obj);
|
|
266
|
-
}
|
|
267
|
-
exports.stringify = stringify;
|
|
268
|
-
function parse(input) {
|
|
269
|
-
return serializer.deserialize(input);
|
|
270
|
-
}
|
|
271
|
-
exports.parse = parse;
|
|
272
|
-
const _pingMessage = {
|
|
273
|
-
kind: 'ping',
|
|
274
|
-
id: '',
|
|
275
|
-
clientId: '',
|
|
276
|
-
};
|
|
277
|
-
const _pongMessage = {
|
|
278
|
-
kind: 'pong',
|
|
279
|
-
id: '',
|
|
280
|
-
clientId: '',
|
|
281
|
-
};
|
|
282
|
-
exports.pingMessage = stringify(_pingMessage);
|
|
283
|
-
exports.pongMessage = stringify(_pongMessage);
|
|
284
248
|
//# sourceMappingURL=ws-channel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws-channel.js","sourceRoot":"","sources":["../../src/common/ws-channel.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ws-channel.js","sourceRoot":"","sources":["../../src/common/ws-channel.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAChD,+DAMmC;AAEnC,2CAAmE;AAEnE,iDAA0E;AAC1E,6CAA8D;AAc9D,MAAa,SAAS;IA2BpB,MAAM,CAAC,SAAS,CAAC,UAAwC,EAAE,OAAgC;QACzF,MAAM,UAAU,GAAG,IAAI,sCAAoB,EAAE,CAAC;QAE9C,MAAM,iBAAiB,GAAG,IAAA,2BAAc,EAAC,UAAU,EAAE,2BAAc,CAAC,CAAC;QACrE,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAC1D,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAElC,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE;YACxB,UAAU,CAAC,OAAO,EAAE,CAAC;QACv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AC,IAAI,CAAC;oBACnB,IAAI,EAAE,MAAM;oBACZ,EAAE,EAAE,IAAI,CAAC,EAAE;iBACZ,CAAC,CAAC;gBACH,MAAM;SACT;IACH,CAAC;CACF;AAjCD,0CAiCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-connection",
|
|
3
|
-
"version": "3.0.4-next-
|
|
3
|
+
"version": "3.0.4-next-1716962745.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@furyjs/fury": "0.5.9-beta",
|
|
21
21
|
"@opensumi/events": "^1.0.0",
|
|
22
|
-
"@opensumi/ide-core-common": "3.0.4-next-
|
|
22
|
+
"@opensumi/ide-core-common": "3.0.4-next-1716962745.0",
|
|
23
23
|
"@opensumi/reconnecting-websocket": "^4.4.0",
|
|
24
24
|
"@opensumi/vscode-jsonrpc": "^8.0.0-next.2",
|
|
25
25
|
"path-to-regexp": "^6.2.1",
|
|
26
26
|
"ws": "^8.16.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@opensumi/ide-components": "3.0.4-next-
|
|
30
|
-
"@opensumi/ide-dev-tool": "3.0.4-next-
|
|
29
|
+
"@opensumi/ide-components": "3.0.4-next-1716962745.0",
|
|
30
|
+
"@opensumi/ide-dev-tool": "3.0.4-next-1716962745.0",
|
|
31
31
|
"@opensumi/mock-socket": "^9.3.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "9dde139af0f26309f70aa0b9b21e009e1d61a737"
|
|
34
34
|
}
|