@adminide-stack/extension-api 1.1.3-alpha.86 → 2.0.1-alpha.2
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/connections/jsonrpc2/connection.test.js +72 -81
- package/lib/connections/jsonrpc2/connection.test.js.map +1 -1
- package/lib/connections/proxy/proxy.test.js +9 -18
- package/lib/connections/proxy/proxy.test.js.map +1 -1
- package/lib/connections/remote-rpc/browser-server-rpc.test.d.ts +0 -1
- package/lib/connections/remote-rpc/browser-server-rpc.test.js +316 -322
- package/lib/connections/remote-rpc/browser-server-rpc.test.js.map +1 -1
- package/lib/interfaces/generated-models.d.ts +322 -311
- package/lib/interfaces/generated-models.js +102 -109
- package/lib/interfaces/generated-models.js.map +1 -1
- package/lib/protocol/rpc-protocol.d.ts +0 -1
- package/lib/protocol/server.protocol.d.ts +0 -1
- package/lib/worker-lib/webWorkerLink.d.ts +0 -1
- package/package.json +58 -59
|
@@ -1,323 +1,317 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const result = client.sendRequest('aa/$m', [4, 1], abortController.signal);
|
|
318
|
-
abortController.abort();
|
|
319
|
-
b1.done();
|
|
320
|
-
yield assert.rejects(result, (err /** : AbortError*/) => err.name === 'AbortError');
|
|
321
|
-
}));
|
|
322
|
-
});
|
|
1
|
+
// import 'reflect-metadata';
|
|
2
|
+
// import AbortController from 'abort-controller';
|
|
3
|
+
// import { WebSocket, Server } from 'mock-socket';
|
|
4
|
+
// import { Logger, createConnection } from '../jsonrpc2/connection';
|
|
5
|
+
// import * as assert from 'assert';
|
|
6
|
+
// import { BrowserRemoteRPC } from './browser-remote-rpc';
|
|
7
|
+
// import { createBarrier } from '../../utils';
|
|
8
|
+
// import { WsProtocol } from '@workbench-stack/extension-module-server';
|
|
9
|
+
// import { RPCProtocol, IRPCMessagePassingProtocol } from '../../protocol/rpc-protocol';
|
|
10
|
+
// // import { MessageBuffer as ServerMessageBuffer, MessageIO as ServerMessageIO } from '../../protocol/server-message-io';
|
|
11
|
+
// // import { MessageBuffer as BrowserMessageBuffer, MessageIO as BrowserMessageIO, MessageBuffer } from '../../protocol/browser-message-io';
|
|
12
|
+
// import { logger } from '@cdm-logger/server';
|
|
13
|
+
// import { Event, Emitter, EventMultiplexer } from '@vscode-alt/monaco-editor/esm/vs/base/common/event';
|
|
14
|
+
// import { RPCLogger } from '../../protocol/rpc-logger';
|
|
15
|
+
// import { createMessagePipe, createMessageTransports } from '../jsonrpc2/test-helper';
|
|
16
|
+
// import { handleServerProxyRequest } from '../proxy/proxy';
|
|
17
|
+
// // import 'jest';
|
|
18
|
+
// import { ProxyIdentifier, TransportType, HostIdentifier, RequestType } from '../../protocol';
|
|
19
|
+
// import { VSBuffer } from '@vscode-alt/monaco-editor/esm/vs/base/common/buffer';
|
|
20
|
+
// const consoleLogger: Logger = {
|
|
21
|
+
// error(message: string): void {
|
|
22
|
+
// console.error(message);
|
|
23
|
+
// },
|
|
24
|
+
// warn(message: string): void {
|
|
25
|
+
// console.warn(message);
|
|
26
|
+
// },
|
|
27
|
+
// info(message: string): void {
|
|
28
|
+
// // tslint:disable-next-line:no-console
|
|
29
|
+
// console.info(message);
|
|
30
|
+
// },
|
|
31
|
+
// log(message: string): void {
|
|
32
|
+
// // tslint:disable-next-line:no-console
|
|
33
|
+
// console.log(message);
|
|
34
|
+
// },
|
|
35
|
+
// };
|
|
36
|
+
// class MessagePassingProtocol implements IRPCMessagePassingProtocol {
|
|
37
|
+
// private _pair: MultiMessagePassingProtocol;
|
|
38
|
+
// public readonly _onNativeMessage = new Emitter<VSBuffer>();
|
|
39
|
+
// public readonly onMessage: Event<VSBuffer> = this._onNativeMessage.event;
|
|
40
|
+
// private readonly _localHostId: HostIdentifier;
|
|
41
|
+
// constructor(hostId: HostIdentifier = HostIdentifier.ServerExtHost) {
|
|
42
|
+
// this._localHostId = hostId;
|
|
43
|
+
// }
|
|
44
|
+
// public setPair(other: MultiMessagePassingProtocol) {
|
|
45
|
+
// this._pair = other;
|
|
46
|
+
// }
|
|
47
|
+
// public send(buffer: VSBuffer, hostIdentifier: HostIdentifier): void {
|
|
48
|
+
// console.log('--send From Ext', hostIdentifier);
|
|
49
|
+
// const headerBuf = VSBuffer.alloc(2);
|
|
50
|
+
// // add destination host id
|
|
51
|
+
// headerBuf.writeUInt8(hostIdentifier, 0);
|
|
52
|
+
// // add sender host id
|
|
53
|
+
// headerBuf.writeUInt8(this._localHostId, 1);
|
|
54
|
+
// const cocatBuf = VSBuffer.concat([headerBuf, buffer]);
|
|
55
|
+
// process.nextTick(() => {
|
|
56
|
+
// this._pair._onNativeMessage.fire(cocatBuf);
|
|
57
|
+
// });
|
|
58
|
+
// }
|
|
59
|
+
// }
|
|
60
|
+
// class MultiMessagePassingProtocol implements IRPCMessagePassingProtocol {
|
|
61
|
+
// private _pair: MessagePassingProtocol;
|
|
62
|
+
// private _wsProtocol = new WsProtocol();
|
|
63
|
+
// public readonly _onNativeMessage = new Emitter<VSBuffer>();
|
|
64
|
+
// private readonly _onMessage = new EventMultiplexer<VSBuffer>();
|
|
65
|
+
// private readonly _localHostId: HostIdentifier;
|
|
66
|
+
// constructor(hostId: HostIdentifier = HostIdentifier.ServerMainThread) {
|
|
67
|
+
// this._localHostId = hostId;
|
|
68
|
+
// this._onMessage.add(this._onNativeMessage.event);
|
|
69
|
+
// this._onMessage.add(this._wsProtocol.onMessage);
|
|
70
|
+
// }
|
|
71
|
+
// public onMessage: Event<VSBuffer> = this._onMessage.event;
|
|
72
|
+
// public connect(socket: any) {
|
|
73
|
+
// this._wsProtocol.connect(socket);
|
|
74
|
+
// }
|
|
75
|
+
// public setPair(other: MessagePassingProtocol) {
|
|
76
|
+
// this._pair = other;
|
|
77
|
+
// }
|
|
78
|
+
// public send(buffer: VSBuffer, hostIdentifier: HostIdentifier): void {
|
|
79
|
+
// const transportType = this.getRequestTypeRouting(hostIdentifier);
|
|
80
|
+
// const headerBuf = VSBuffer.alloc(2);
|
|
81
|
+
// // add destination host id
|
|
82
|
+
// headerBuf.writeUInt8(hostIdentifier, 0);
|
|
83
|
+
// // add sender host id
|
|
84
|
+
// headerBuf.writeUInt8(this._localHostId, 1);
|
|
85
|
+
// const cocatBuf = VSBuffer.concat([headerBuf, buffer]);
|
|
86
|
+
// this._send(cocatBuf, transportType);
|
|
87
|
+
// }
|
|
88
|
+
// public _send(buffer: VSBuffer, transportType?: TransportType): void {
|
|
89
|
+
// console.log('---_send fromMulitp transportType websocket', transportType === TransportType.WebSocket);
|
|
90
|
+
// if (transportType === TransportType.WebSocket) {
|
|
91
|
+
// this.webSend(buffer);
|
|
92
|
+
// } else {
|
|
93
|
+
// this.nativeSend(buffer);
|
|
94
|
+
// }
|
|
95
|
+
// }
|
|
96
|
+
// public forward(buffer: VSBuffer, hostIdentifier?: HostIdentifier) {
|
|
97
|
+
// console.log('---forward the request to hostId', hostIdentifier);
|
|
98
|
+
// const transportType = this.getRequestTypeRouting(hostIdentifier);
|
|
99
|
+
// if (transportType === TransportType.WebSocket) {
|
|
100
|
+
// this._send(buffer, TransportType.WebSocket);
|
|
101
|
+
// } else {
|
|
102
|
+
// this._send(buffer, TransportType.Socket);
|
|
103
|
+
// }
|
|
104
|
+
// }
|
|
105
|
+
// private webSend(buffer: VSBuffer) {
|
|
106
|
+
// return this._wsProtocol.send(buffer);
|
|
107
|
+
// }
|
|
108
|
+
// private nativeSend(buffer: VSBuffer): void {
|
|
109
|
+
// process.nextTick(() => {
|
|
110
|
+
// this._pair._onNativeMessage.fire(buffer);
|
|
111
|
+
// });
|
|
112
|
+
// }
|
|
113
|
+
// private getRequestTypeRouting(hostIdentifier?: HostIdentifier) {
|
|
114
|
+
// if (hostIdentifier === HostIdentifier.ServerExtHost) {
|
|
115
|
+
// return TransportType.Socket;
|
|
116
|
+
// } else if (hostIdentifier === HostIdentifier.BrowserExtHost) {
|
|
117
|
+
// return TransportType.WebSocket;
|
|
118
|
+
// } else {
|
|
119
|
+
// return TransportType.Socket;
|
|
120
|
+
// }
|
|
121
|
+
// }
|
|
122
|
+
// }
|
|
123
|
+
// describe('Websocket RPC', () => {
|
|
124
|
+
// let fakeURL;
|
|
125
|
+
// let mockServer;
|
|
126
|
+
// let socket1;
|
|
127
|
+
// let delegate: (a1: any, a2: any) => any;
|
|
128
|
+
// let bProxyFromA: BClass;
|
|
129
|
+
// let bProdyFromC: BClass;
|
|
130
|
+
// let aProxyFromB: AClass;
|
|
131
|
+
// let aProxyFromC: AClass;
|
|
132
|
+
// let cProxyFromA: CClass;
|
|
133
|
+
// class AClass {
|
|
134
|
+
// public $m(a1: any, a2: any): Promise<any> {
|
|
135
|
+
// return Promise.resolve(delegate.call(null, a1, a2));
|
|
136
|
+
// }
|
|
137
|
+
// }
|
|
138
|
+
// class BClass {
|
|
139
|
+
// public $n(a1: any, a2: any): Promise<any> {
|
|
140
|
+
// return Promise.resolve(delegate.call(null, a1, a2));
|
|
141
|
+
// }
|
|
142
|
+
// }
|
|
143
|
+
// class CClass {
|
|
144
|
+
// public $o(a1: any, a2: any): Promise<any> {
|
|
145
|
+
// return Promise.resolve(delegate.call(null, a1, a2));
|
|
146
|
+
// }
|
|
147
|
+
// }
|
|
148
|
+
// beforeEach((done) => {
|
|
149
|
+
// fakeURL = 'ws://localhost:8080';
|
|
150
|
+
// mockServer = new Server(fakeURL);
|
|
151
|
+
// let b_protocol = new BrowserRemoteRPC();
|
|
152
|
+
// b_protocol.connect(fakeURL, () => {
|
|
153
|
+
// socket1 = new WebSocket(fakeURL);
|
|
154
|
+
// socket1.binaryType = 'arraybuffer';
|
|
155
|
+
// return socket1;
|
|
156
|
+
// });
|
|
157
|
+
// mockServer.on('connection', socket => {
|
|
158
|
+
// console.log('---SOCKET MOCK SErver', socket);
|
|
159
|
+
// let a_protocol = new MultiMessagePassingProtocol();
|
|
160
|
+
// a_protocol.connect(socket);
|
|
161
|
+
// let c_protocol = new MessagePassingProtocol();
|
|
162
|
+
// c_protocol.setPair(a_protocol);
|
|
163
|
+
// a_protocol.setPair(c_protocol);
|
|
164
|
+
// let A = new RPCProtocol(a_protocol, HostIdentifier.ServerMainThread, new RPCLogger(), null);
|
|
165
|
+
// let B = new RPCProtocol(b_protocol, HostIdentifier.BrowserExtHost, new RPCLogger(), null);
|
|
166
|
+
// let C = new RPCProtocol(c_protocol, HostIdentifier.ServerExtHost, new RPCLogger(), null);
|
|
167
|
+
// const bIdentifier = new ProxyIdentifier<BClass>(false, 'bb', HostIdentifier.BrowserExtHost);
|
|
168
|
+
// const bInstance = new BClass();
|
|
169
|
+
// const aIdentifier = new ProxyIdentifier<AClass>(false, 'aa', HostIdentifier.ServerMainThread);
|
|
170
|
+
// const aInstance = new AClass();
|
|
171
|
+
// const cIdentifer = new ProxyIdentifier<CClass>(false, 'cc', HostIdentifier.ServerExtHost);
|
|
172
|
+
// const cInstance = new CClass();
|
|
173
|
+
// B.set(bIdentifier, bInstance);
|
|
174
|
+
// A.set(aIdentifier, aInstance);
|
|
175
|
+
// C.set(cIdentifer, cInstance);
|
|
176
|
+
// bProxyFromA = A.getProxy(bIdentifier);
|
|
177
|
+
// aProxyFromC = C.getProxy(aIdentifier);
|
|
178
|
+
// aProxyFromB = B.getProxy(aIdentifier);
|
|
179
|
+
// cProxyFromA = A.getProxy(cIdentifer);
|
|
180
|
+
// bProdyFromC = C.getProxy(bIdentifier);
|
|
181
|
+
// cProxyFromA = A.getProxy(cIdentifer);
|
|
182
|
+
// done();
|
|
183
|
+
// });
|
|
184
|
+
// });
|
|
185
|
+
// afterEach(() => {
|
|
186
|
+
// socket1.close();
|
|
187
|
+
// mockServer.close();
|
|
188
|
+
// });
|
|
189
|
+
// test('simple call C -> A', function (done) {
|
|
190
|
+
// delegate = (a1: number, a2: number) => a1 + a2;
|
|
191
|
+
// aProxyFromC.$m(4, 1).then((res: number) => {
|
|
192
|
+
// assert.equal(res, 5);
|
|
193
|
+
// done();
|
|
194
|
+
// }, done.fail);
|
|
195
|
+
// });
|
|
196
|
+
// test('simple call B -> A', function (done) {
|
|
197
|
+
// delegate = (a1: number, a2: number) => a1 + a2;
|
|
198
|
+
// aProxyFromB.$m(4, 1).then((res: number) => {
|
|
199
|
+
// assert.equal(res, 5);
|
|
200
|
+
// done();
|
|
201
|
+
// }, done.fail);
|
|
202
|
+
// });
|
|
203
|
+
// test('simple call C -> B', function (done) {
|
|
204
|
+
// delegate = (a1: number, a2: number) => a1 + a2;
|
|
205
|
+
// bProdyFromC.$n(4, 1).then((res: number) => {
|
|
206
|
+
// assert.equal(res, 5);
|
|
207
|
+
// done();
|
|
208
|
+
// }, done.fail);
|
|
209
|
+
// });
|
|
210
|
+
// test('simple call A -> C', function (done) {
|
|
211
|
+
// delegate = (a1: number, a2: number) => a1 + a2;
|
|
212
|
+
// cProxyFromA.$o(4, 1).then((res: number) => {
|
|
213
|
+
// assert.equal(res, 5);
|
|
214
|
+
// done();
|
|
215
|
+
// }, done.fail);
|
|
216
|
+
// });
|
|
217
|
+
// test('test buffer', function () {
|
|
218
|
+
// const b1 = Buffer.allocUnsafe(2);
|
|
219
|
+
// const b2 = Buffer.allocUnsafe(1);
|
|
220
|
+
// b1.writeUInt8(10, 0);
|
|
221
|
+
// b1.writeUInt8(99, 1);
|
|
222
|
+
// b2.writeUInt8(20, 0);
|
|
223
|
+
// const buf = Buffer.concat([b1, b2]);
|
|
224
|
+
// const a1 = buf.readUInt8(0);
|
|
225
|
+
// // const bufNew = buf.slice(3);
|
|
226
|
+
// const a2 = buf.readUInt8(2);
|
|
227
|
+
// console.log('---a1', a1);
|
|
228
|
+
// console.log('---a2', a2);
|
|
229
|
+
// });
|
|
230
|
+
// test('simple call A->C', function (done) {
|
|
231
|
+
// delegate = (a1: number, a2: number) => a1 + a2;
|
|
232
|
+
// cProxyFromA.$o(6, 1).then((res: number) => {
|
|
233
|
+
// assert.equal(res, 7);
|
|
234
|
+
// done();
|
|
235
|
+
// }, done.fail);
|
|
236
|
+
// });
|
|
237
|
+
// test('works', () => {
|
|
238
|
+
// const result: number[] = [];
|
|
239
|
+
// const m = new EventMultiplexer<number>();
|
|
240
|
+
// m.event(r => result.push(r));
|
|
241
|
+
// const e1 = new Emitter<number>();
|
|
242
|
+
// m.add(e1.event);
|
|
243
|
+
// assert.deepEqual(result, []);
|
|
244
|
+
// e1.fire(0);
|
|
245
|
+
// assert.deepEqual(result, [0]);
|
|
246
|
+
// });
|
|
247
|
+
// });
|
|
248
|
+
// xdescribe('Connection', () => {
|
|
249
|
+
// let delegate: (a1: any, a2: any) => any;
|
|
250
|
+
// interface IAClass {
|
|
251
|
+
// $m(a1: any, a2: any): Promise<any>;
|
|
252
|
+
// }
|
|
253
|
+
// let aProxy: AClass;
|
|
254
|
+
// class AClass implements IAClass {
|
|
255
|
+
// public $m(a1: any, a2: any): Promise<any> {
|
|
256
|
+
// return Promise.resolve(delegate.call(null, a1, a2));
|
|
257
|
+
// }
|
|
258
|
+
// }
|
|
259
|
+
// class BClass {
|
|
260
|
+
// public $m(b1: any, b2: any): Promise<any> {
|
|
261
|
+
// return Promise.resolve(delegate.call(null, b1, b2));
|
|
262
|
+
// }
|
|
263
|
+
// }
|
|
264
|
+
// // Polyfill
|
|
265
|
+
// ; (global as any).AbortController = AbortController;
|
|
266
|
+
// let mockServer, socket1: WebSocket;
|
|
267
|
+
// const aIdentifier = new ProxyIdentifier<AClass>(false, 'aa');
|
|
268
|
+
// let A, B;
|
|
269
|
+
// beforeEach((done) => {
|
|
270
|
+
// });
|
|
271
|
+
// afterEach(() => {
|
|
272
|
+
// socket1.close();
|
|
273
|
+
// mockServer.close();
|
|
274
|
+
// });
|
|
275
|
+
// xtest('handle single request', async (done) => {
|
|
276
|
+
// const [serverTransports, clientTransports] = createMessageTransports();
|
|
277
|
+
// delegate = (a1: number, a2: number) => a1 + a2;
|
|
278
|
+
// const server = createConnection(serverTransports, consoleLogger);
|
|
279
|
+
// handleServerProxyRequest(server, B, aIdentifier);
|
|
280
|
+
// server.listen();
|
|
281
|
+
// server.onClose(event => done());
|
|
282
|
+
// const client = createConnection(clientTransports);
|
|
283
|
+
// client.listen();
|
|
284
|
+
// const signal = new AbortController().signal;
|
|
285
|
+
// const result = await client.sendRequest('aa/$m', [4, 1], signal as any);
|
|
286
|
+
// expect(result).toBe(5);
|
|
287
|
+
// done();
|
|
288
|
+
// });
|
|
289
|
+
// xit('abort undispatched request', async (done) => {
|
|
290
|
+
// const [serverTransports, clientTransports] = createMessageTransports();
|
|
291
|
+
// const b1 = createBarrier();
|
|
292
|
+
// const b2 = createBarrier();
|
|
293
|
+
// delegate = (a1: number, a2: number) => a1 + a2;
|
|
294
|
+
// const server = createConnection(serverTransports, consoleLogger);
|
|
295
|
+
// server.onRequest('block', async () => {
|
|
296
|
+
// b2.done();
|
|
297
|
+
// await b1.wait;
|
|
298
|
+
// });
|
|
299
|
+
// // server.onRequest('undispatched', () => {
|
|
300
|
+
// // throw new Error('handler should not be called')
|
|
301
|
+
// // })
|
|
302
|
+
// handleServerProxyRequest(server, B, aIdentifier);
|
|
303
|
+
// server.listen();
|
|
304
|
+
// const client = createConnection(clientTransports);
|
|
305
|
+
// client.listen();
|
|
306
|
+
// server.onClose(event => done());
|
|
307
|
+
// client.sendRequest('block').catch(null);
|
|
308
|
+
// await b2.wait;
|
|
309
|
+
// const abortController = new AbortController();
|
|
310
|
+
// // const result = client.sendRequest('undispatched', ['foo'], abortController.signal)
|
|
311
|
+
// const result = client.sendRequest('aa/$m', [4, 1], abortController.signal as any);
|
|
312
|
+
// abortController.abort();
|
|
313
|
+
// b1.done();
|
|
314
|
+
// await assert.rejects(result, (err/** : AbortError*/) => err.name === 'AbortError');
|
|
315
|
+
// });
|
|
316
|
+
// });
|
|
323
317
|
//# sourceMappingURL=browser-server-rpc.test.js.map
|