@adminide-stack/extension-api 1.1.3-alpha.17 → 1.1.3-alpha.170
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.js +10 -10
- package/lib/connections/jsonrpc2/connection.js.map +1 -1
- package/lib/connections/jsonrpc2/connection.test.js +172 -181
- package/lib/connections/jsonrpc2/connection.test.js.map +1 -1
- package/lib/connections/jsonrpc2/index.js +5 -1
- package/lib/connections/jsonrpc2/index.js.map +1 -1
- package/lib/connections/jsonrpc2/transports/webWorker.js +2 -1
- package/lib/connections/jsonrpc2/transports/webWorker.js.map +1 -1
- package/lib/connections/proxy/index.js +5 -1
- package/lib/connections/proxy/index.js.map +1 -1
- package/lib/connections/proxy/proxy.test.js +15 -24
- package/lib/connections/proxy/proxy.test.js.map +1 -1
- package/lib/connections/remote-rpc/browser-remote-rpc.js +4 -4
- package/lib/connections/remote-rpc/browser-remote-rpc.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/connections/remote-rpc/index.js +5 -1
- package/lib/connections/remote-rpc/index.js.map +1 -1
- package/lib/connections/remote-rpc/old-browser-remote-rpc.js +1 -1
- package/lib/connections/remote-rpc/old-browser-remote-rpc.js.map +1 -1
- package/lib/constants/index.js +5 -1
- package/lib/constants/index.js.map +1 -1
- package/lib/core/expr/evaluator.test.js +1 -1
- package/lib/core/expr/evaluator.test.js.map +1 -1
- package/lib/core/expr/index.js +5 -1
- package/lib/core/expr/index.js.map +1 -1
- package/lib/core/index.js +5 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/types/ext-host-types.js +2 -2
- package/lib/core/types/ext-host-types.js.map +1 -1
- package/lib/core/types/index.js +5 -1
- package/lib/core/types/index.js.map +1 -1
- package/lib/errors/index.js +5 -1
- package/lib/errors/index.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces/contributions/index.js +5 -1
- package/lib/interfaces/contributions/index.js.map +1 -1
- package/lib/interfaces/ext-services/index.js +5 -1
- package/lib/interfaces/ext-services/index.js.map +1 -1
- package/lib/interfaces/generated-models.d.ts +343 -419
- package/lib/interfaces/generated-models.js +14 -26
- package/lib/interfaces/generated-models.js.map +1 -1
- package/lib/interfaces/index.js +5 -1
- package/lib/interfaces/index.js.map +1 -1
- package/lib/interfaces/react-props/index.js +5 -1
- package/lib/interfaces/react-props/index.js.map +1 -1
- package/lib/interfaces/text-document.js +2 -2
- package/lib/interfaces/text-document.js.map +1 -1
- package/lib/interfaces/webview/index.js +5 -1
- package/lib/interfaces/webview/index.js.map +1 -1
- package/lib/protocol/client.protocol.js +1 -1
- package/lib/protocol/client.protocol.js.map +1 -1
- package/lib/protocol/index.js +5 -1
- package/lib/protocol/index.js.map +1 -1
- package/lib/protocol/proxy-identifier.js +2 -2
- package/lib/protocol/proxy-identifier.js.map +1 -1
- package/lib/protocol/rpc-protocol.js +57 -57
- package/lib/protocol/rpc-protocol.js.map +1 -1
- package/lib/protocol/server.protocol.d.ts +3 -1
- package/lib/protocol/server.protocol.js +10 -10
- package/lib/protocol/server.protocol.js.map +1 -1
- package/lib/protocol/shared/editor.js +2 -2
- package/lib/protocol/shared/editor.js.map +1 -1
- package/lib/protocol/utils/index.js +5 -1
- package/lib/protocol/utils/index.js.map +1 -1
- package/lib/protocol/utils/lazy-promise.js +2 -1
- package/lib/protocol/utils/lazy-promise.js.map +1 -1
- package/lib/utils/extensions.js +1 -1
- package/lib/utils/extensions.js.map +1 -1
- package/lib/utils/index.js +5 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/rxjs/combineLatestOrDefault.js +4 -4
- package/lib/utils/rxjs/combineLatestOrDefault.js.map +1 -1
- package/lib/utils/rxjs/combineLatestOrDefault.test.js +9 -9
- package/lib/utils/rxjs/combineLatestOrDefault.test.js.map +1 -1
- package/lib/utils/rxjs/index.js +5 -1
- package/lib/utils/rxjs/index.js.map +1 -1
- package/lib/utils/util.js +1 -1
- package/lib/utils/util.js.map +1 -1
- package/lib/worker-lib/index.js +5 -1
- package/lib/worker-lib/index.js.map +1 -1
- package/lib/worker-lib/webWorkerLink.js +3 -3
- package/lib/worker-lib/webWorkerLink.js.map +1 -1
- package/lib/worker-lib/workerUtils.js +8 -8
- package/lib/worker-lib/workerUtils.js.map +1 -1
- package/package.json +58 -59
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
require("babel-polyfill");
|
|
13
4
|
const abort_controller_1 = require("abort-controller");
|
|
@@ -23,58 +14,58 @@ describe('Connection', () => {
|
|
|
23
14
|
// Polyfill
|
|
24
15
|
;
|
|
25
16
|
global.AbortController = abort_controller_1.default;
|
|
26
|
-
it('handle single request', () =>
|
|
17
|
+
it('handle single request', async () => {
|
|
27
18
|
const method = 'test/handleSingleRequest';
|
|
28
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
29
|
-
const server = connection_1.createConnection(serverTransports);
|
|
19
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
20
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
30
21
|
server.onRequest(method, (p1, _signal) => {
|
|
31
22
|
assert.deepStrictEqual(p1, ['foo']);
|
|
32
23
|
return p1;
|
|
33
24
|
});
|
|
34
25
|
server.listen();
|
|
35
|
-
const client = connection_1.createConnection(clientTransports);
|
|
26
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
36
27
|
client.listen();
|
|
37
|
-
assert.deepStrictEqual(
|
|
38
|
-
})
|
|
39
|
-
it('handle single request with async result', () =>
|
|
28
|
+
assert.deepStrictEqual(await client.sendRequest(method, ['foo']), ['foo']);
|
|
29
|
+
});
|
|
30
|
+
it('handle single request with async result', async () => {
|
|
40
31
|
const method = 'test/handleSingleRequest';
|
|
41
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
42
|
-
const server = connection_1.createConnection(serverTransports);
|
|
32
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
33
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
43
34
|
server.onRequest(method, (p1, _signal) => {
|
|
44
35
|
assert.deepStrictEqual(p1, ['foo']);
|
|
45
36
|
return Promise.resolve(p1);
|
|
46
37
|
});
|
|
47
38
|
server.listen();
|
|
48
|
-
const client = connection_1.createConnection(clientTransports);
|
|
49
|
-
client.listen();
|
|
50
|
-
assert.deepStrictEqual(
|
|
51
|
-
})
|
|
52
|
-
it('abort undispatched request', () =>
|
|
53
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
54
|
-
const b1 = utils_1.createBarrier();
|
|
55
|
-
const b2 = utils_1.createBarrier();
|
|
56
|
-
const server = connection_1.createConnection(serverTransports);
|
|
57
|
-
server.onRequest('block', () =>
|
|
39
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
40
|
+
client.listen();
|
|
41
|
+
assert.deepStrictEqual(await client.sendRequest(method, ['foo']), ['foo']);
|
|
42
|
+
});
|
|
43
|
+
it('abort undispatched request', async () => {
|
|
44
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
45
|
+
const b1 = (0, utils_1.createBarrier)();
|
|
46
|
+
const b2 = (0, utils_1.createBarrier)();
|
|
47
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
48
|
+
server.onRequest('block', async () => {
|
|
58
49
|
b2.done();
|
|
59
|
-
|
|
60
|
-
})
|
|
50
|
+
await b1.wait;
|
|
51
|
+
});
|
|
61
52
|
server.onRequest('undispatched', () => {
|
|
62
53
|
throw new Error('handler should not be called');
|
|
63
54
|
});
|
|
64
55
|
server.listen();
|
|
65
|
-
const client = connection_1.createConnection(clientTransports);
|
|
56
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
66
57
|
client.listen();
|
|
67
58
|
client.sendRequest('block').catch(null);
|
|
68
|
-
|
|
59
|
+
await b2.wait;
|
|
69
60
|
const abortController = new abort_controller_1.default();
|
|
70
61
|
const result = client.sendRequest('undispatched', ['foo'], abortController.signal);
|
|
71
62
|
abortController.abort();
|
|
72
63
|
b1.done();
|
|
73
|
-
|
|
74
|
-
})
|
|
75
|
-
it('abort request currently being handled', () =>
|
|
76
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
77
|
-
const server = connection_1.createConnection(serverTransports);
|
|
64
|
+
await assert.rejects(result, (err) => err.name === 'AbortError');
|
|
65
|
+
});
|
|
66
|
+
it('abort request currently being handled', async () => {
|
|
67
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
68
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
78
69
|
server.onRequest('m', (_params, signal) => {
|
|
79
70
|
if (!signal) {
|
|
80
71
|
throw new Error('!signal');
|
|
@@ -85,36 +76,36 @@ describe('Connection', () => {
|
|
|
85
76
|
});
|
|
86
77
|
server.onRequest('ping', () => 'pong');
|
|
87
78
|
server.listen();
|
|
88
|
-
const client = connection_1.createConnection(clientTransports);
|
|
79
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
89
80
|
client.listen();
|
|
90
81
|
const abortController = new abort_controller_1.default();
|
|
91
82
|
const result = client.sendRequest('m', undefined, abortController.signal);
|
|
92
|
-
assert.strictEqual(
|
|
83
|
+
assert.strictEqual(await client.sendRequest('ping'), 'pong'); // waits until the 'm' message starts to be handled
|
|
93
84
|
abortController.abort();
|
|
94
|
-
|
|
95
|
-
})
|
|
96
|
-
it('send request with single observable emission', () =>
|
|
97
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
98
|
-
const server = connection_1.createConnection(serverTransports);
|
|
99
|
-
server.onRequest('m', (params) => rxjs_1.of(params[0] + 1).pipe(operators_1.delay(0)));
|
|
85
|
+
await assert.rejects(result, (err) => err.name === 'AbortError');
|
|
86
|
+
});
|
|
87
|
+
it('send request with single observable emission', async () => {
|
|
88
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
89
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
90
|
+
server.onRequest('m', (params) => (0, rxjs_1.of)(params[0] + 1).pipe((0, operators_1.delay)(0)));
|
|
100
91
|
server.listen();
|
|
101
|
-
const client = connection_1.createConnection(clientTransports);
|
|
102
|
-
client.listen();
|
|
103
|
-
assert.strictEqual(
|
|
104
|
-
})
|
|
105
|
-
it('observe request with single observable emission', () =>
|
|
106
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
107
|
-
const server = connection_1.createConnection(serverTransports);
|
|
108
|
-
server.onRequest('m', (params) => rxjs_1.of(params[0] + 1));
|
|
92
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
93
|
+
client.listen();
|
|
94
|
+
assert.strictEqual(await client.sendRequest('m', [1]), 2);
|
|
95
|
+
});
|
|
96
|
+
it('observe request with single observable emission', async () => {
|
|
97
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
98
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
99
|
+
server.onRequest('m', (params) => (0, rxjs_1.of)(params[0] + 1));
|
|
109
100
|
server.listen();
|
|
110
|
-
const client = connection_1.createConnection(clientTransports);
|
|
101
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
111
102
|
client.listen();
|
|
112
103
|
const result = client.observeRequest('m', [1]);
|
|
113
|
-
assert.deepStrictEqual(
|
|
114
|
-
})
|
|
115
|
-
it('observe request with multiple observable emissions', () =>
|
|
116
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
117
|
-
const server = connection_1.createConnection(serverTransports);
|
|
104
|
+
assert.deepStrictEqual(await result.toPromise(), 2);
|
|
105
|
+
});
|
|
106
|
+
it('observe request with multiple observable emissions', async () => {
|
|
107
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
108
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
118
109
|
server.onRequest('m', (params) => new rxjs_1.Observable(observer => {
|
|
119
110
|
for (const v of params) {
|
|
120
111
|
observer.next(v + 1);
|
|
@@ -122,168 +113,168 @@ describe('Connection', () => {
|
|
|
122
113
|
observer.complete();
|
|
123
114
|
}));
|
|
124
115
|
server.listen();
|
|
125
|
-
const client = connection_1.createConnection(clientTransports);
|
|
116
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
126
117
|
client.listen();
|
|
127
|
-
assert.deepStrictEqual(
|
|
118
|
+
assert.deepStrictEqual(await client
|
|
128
119
|
.observeRequest('m', [1, 2, 3, 4])
|
|
129
|
-
.pipe(operators_1.bufferCount(4))
|
|
120
|
+
.pipe((0, operators_1.bufferCount)(4))
|
|
130
121
|
.toPromise(), [2, 3, 4, 5]);
|
|
131
|
-
})
|
|
132
|
-
it('handle multiple requests', () =>
|
|
122
|
+
});
|
|
123
|
+
it('handle multiple requests', async () => {
|
|
133
124
|
const method = 'test/handleSingleRequest';
|
|
134
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
135
|
-
const server = connection_1.createConnection(serverTransports);
|
|
125
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
126
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
136
127
|
server.onRequest(method, (p1, _signal) => p1);
|
|
137
128
|
server.listen();
|
|
138
|
-
const client = connection_1.createConnection(clientTransports);
|
|
129
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
139
130
|
client.listen();
|
|
140
131
|
const promises = [];
|
|
141
132
|
promises.push(client.sendRequest(method, ['foo']));
|
|
142
133
|
promises.push(client.sendRequest(method, ['bar']));
|
|
143
|
-
const values =
|
|
134
|
+
const values = await Promise.all(promises);
|
|
144
135
|
assert.deepStrictEqual(values, [['foo'], ['bar']]);
|
|
145
|
-
})
|
|
146
|
-
it('unhandled request', () =>
|
|
136
|
+
});
|
|
137
|
+
it('unhandled request', async () => {
|
|
147
138
|
const method = 'test/handleSingleRequest';
|
|
148
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
149
|
-
const server = connection_1.createConnection(serverTransports);
|
|
139
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
140
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
150
141
|
server.listen();
|
|
151
|
-
const client = connection_1.createConnection(clientTransports);
|
|
142
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
152
143
|
client.listen();
|
|
153
|
-
|
|
154
|
-
})
|
|
155
|
-
it('handler throws an Error', () =>
|
|
144
|
+
await assert.rejects(() => client.sendRequest(method, ['foo']), (error) => error.code === messages_1.ErrorCodes.MethodNotFound);
|
|
145
|
+
});
|
|
146
|
+
it('handler throws an Error', async () => {
|
|
156
147
|
const method = 'test/handleSingleRequest';
|
|
157
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
158
|
-
const server = connection_1.createConnection(serverTransports);
|
|
148
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
149
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
159
150
|
server.onRequest(method, () => {
|
|
160
151
|
throw new Error('test');
|
|
161
152
|
});
|
|
162
153
|
server.listen();
|
|
163
|
-
const client = connection_1.createConnection(clientTransports);
|
|
154
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
164
155
|
client.listen();
|
|
165
|
-
|
|
156
|
+
await assert.rejects(() => client.sendRequest(method, ['foo']), (error) => error.code === messages_1.ErrorCodes.InternalError &&
|
|
166
157
|
error.message === 'test' &&
|
|
167
158
|
error.data &&
|
|
168
159
|
typeof error.data.stack === 'string');
|
|
169
|
-
})
|
|
170
|
-
it('handler returns a rejected Promise with an Error', () =>
|
|
160
|
+
});
|
|
161
|
+
it('handler returns a rejected Promise with an Error', async () => {
|
|
171
162
|
const method = 'test/handleSingleRequest';
|
|
172
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
173
|
-
const server = connection_1.createConnection(serverTransports);
|
|
163
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
164
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
174
165
|
server.onRequest(method, () => Promise.reject(new Error('test')));
|
|
175
166
|
server.listen();
|
|
176
|
-
const client = connection_1.createConnection(clientTransports);
|
|
167
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
177
168
|
client.listen();
|
|
178
|
-
|
|
169
|
+
await assert.rejects(() => client.sendRequest(method, ['foo']), (error) => error.code === messages_1.ErrorCodes.InternalError &&
|
|
179
170
|
error.message === 'test' &&
|
|
180
171
|
error.data &&
|
|
181
172
|
typeof error.data.stack === 'string');
|
|
182
|
-
})
|
|
183
|
-
it('receives undefined request params as null', () =>
|
|
173
|
+
});
|
|
174
|
+
it('receives undefined request params as null', async () => {
|
|
184
175
|
const method = 'test/handleSingleRequest';
|
|
185
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
186
|
-
const server = connection_1.createConnection(serverTransports);
|
|
176
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
177
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
187
178
|
server.onRequest(method, params => {
|
|
188
179
|
assert.strictEqual(params, null);
|
|
189
180
|
return '';
|
|
190
181
|
});
|
|
191
182
|
server.listen();
|
|
192
|
-
const client = connection_1.createConnection(clientTransports);
|
|
183
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
193
184
|
client.listen();
|
|
194
|
-
|
|
195
|
-
})
|
|
196
|
-
it('receives undefined notification params as null', () =>
|
|
185
|
+
await client.sendRequest(method);
|
|
186
|
+
});
|
|
187
|
+
it('receives undefined notification params as null', async () => {
|
|
197
188
|
const method = 'testNotification';
|
|
198
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
199
|
-
const server = connection_1.createConnection(serverTransports);
|
|
189
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
190
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
200
191
|
server.onNotification(method, params => {
|
|
201
192
|
assert.strictEqual(params, null);
|
|
202
193
|
return '';
|
|
203
194
|
});
|
|
204
195
|
server.listen();
|
|
205
|
-
const client = connection_1.createConnection(clientTransports);
|
|
196
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
206
197
|
client.listen();
|
|
207
198
|
client.sendNotification(method);
|
|
208
|
-
})
|
|
209
|
-
it('receives null as null', () =>
|
|
199
|
+
});
|
|
200
|
+
it('receives null as null', async () => {
|
|
210
201
|
const method = 'test/handleSingleRequest';
|
|
211
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
212
|
-
const server = connection_1.createConnection(serverTransports);
|
|
202
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
203
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
213
204
|
server.onRequest(method, params => {
|
|
214
205
|
assert.deepStrictEqual(params, [null]);
|
|
215
206
|
return null;
|
|
216
207
|
});
|
|
217
208
|
server.listen();
|
|
218
|
-
const client = connection_1.createConnection(clientTransports);
|
|
209
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
219
210
|
client.listen();
|
|
220
|
-
assert.strictEqual(
|
|
221
|
-
})
|
|
222
|
-
it('receives 0 as 0', () =>
|
|
211
|
+
assert.strictEqual(await client.sendRequest(method, [null]), null);
|
|
212
|
+
});
|
|
213
|
+
it('receives 0 as 0', async () => {
|
|
223
214
|
const method = 'test/handleSingleRequest';
|
|
224
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
225
|
-
const server = connection_1.createConnection(serverTransports);
|
|
215
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
216
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
226
217
|
server.onRequest(method, params => {
|
|
227
218
|
assert.deepStrictEqual(params, [0]);
|
|
228
219
|
return 0;
|
|
229
220
|
});
|
|
230
221
|
server.listen();
|
|
231
|
-
const client = connection_1.createConnection(clientTransports);
|
|
222
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
232
223
|
client.listen();
|
|
233
|
-
assert.strictEqual(
|
|
234
|
-
})
|
|
224
|
+
assert.strictEqual(await client.sendRequest(method, [0]), 0);
|
|
225
|
+
});
|
|
235
226
|
const testNotification = 'testNotification';
|
|
236
227
|
it('sends and receives notification', done => {
|
|
237
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
238
|
-
const server = connection_1.createConnection(serverTransports);
|
|
228
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
229
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
239
230
|
server.onNotification(testNotification, params => {
|
|
240
231
|
assert.deepStrictEqual(params, [{ value: true }]);
|
|
241
232
|
done();
|
|
242
233
|
});
|
|
243
234
|
server.listen();
|
|
244
|
-
const client = connection_1.createConnection(clientTransports);
|
|
235
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
245
236
|
client.listen();
|
|
246
237
|
client.sendNotification(testNotification, [{ value: true }]);
|
|
247
238
|
});
|
|
248
239
|
it('unhandled notification event', done => {
|
|
249
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
250
|
-
const server = connection_1.createConnection(serverTransports);
|
|
240
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
241
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
251
242
|
server.onUnhandledNotification(message => {
|
|
252
243
|
assert.strictEqual(message.method, testNotification);
|
|
253
244
|
assert.deepStrictEqual(message.params, [{ value: true }]);
|
|
254
245
|
done();
|
|
255
246
|
});
|
|
256
247
|
server.listen();
|
|
257
|
-
const client = connection_1.createConnection(clientTransports);
|
|
248
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
258
249
|
client.listen();
|
|
259
250
|
client.sendNotification(testNotification, [{ value: true }]);
|
|
260
251
|
});
|
|
261
|
-
it('unsubscribes client connection', () =>
|
|
252
|
+
it('unsubscribes client connection', async () => {
|
|
262
253
|
const method = 'test/handleSingleRequest';
|
|
263
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
264
|
-
const client = connection_1.createConnection(clientTransports);
|
|
265
|
-
const server = connection_1.createConnection(serverTransports);
|
|
254
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
255
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
256
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
266
257
|
server.onRequest(method, _param => {
|
|
267
258
|
client.unsubscribe();
|
|
268
259
|
return '';
|
|
269
260
|
});
|
|
270
261
|
server.listen();
|
|
271
262
|
client.listen();
|
|
272
|
-
|
|
273
|
-
})
|
|
263
|
+
await assert.rejects(() => client.sendRequest(method, ['']));
|
|
264
|
+
});
|
|
274
265
|
it('unsubscribed connection throws', () => {
|
|
275
|
-
const client = connection_1.createConnection(test_helper_1.createMessagePipe());
|
|
266
|
+
const client = (0, connection_1.createConnection)((0, test_helper_1.createMessagePipe)());
|
|
276
267
|
client.listen();
|
|
277
268
|
client.unsubscribe();
|
|
278
269
|
assert.throws(() => client.sendNotification(testNotification));
|
|
279
270
|
});
|
|
280
271
|
it('two listen throw', () => {
|
|
281
|
-
const client = connection_1.createConnection(test_helper_1.createMessagePipe());
|
|
272
|
+
const client = (0, connection_1.createConnection)((0, test_helper_1.createMessagePipe)());
|
|
282
273
|
client.listen();
|
|
283
274
|
assert.throws(() => client.listen());
|
|
284
275
|
});
|
|
285
276
|
it('notify on connection unsubscribe', done => {
|
|
286
|
-
const client = connection_1.createConnection(test_helper_1.createMessagePipe());
|
|
277
|
+
const client = (0, connection_1.createConnection)((0, test_helper_1.createMessagePipe)());
|
|
287
278
|
client.listen();
|
|
288
279
|
client.onUnsubscribe(() => {
|
|
289
280
|
done();
|
|
@@ -292,48 +283,48 @@ describe('Connection', () => {
|
|
|
292
283
|
});
|
|
293
284
|
it('params in notifications', done => {
|
|
294
285
|
const method = 'test';
|
|
295
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
296
|
-
const server = connection_1.createConnection(serverTransports);
|
|
286
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
287
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
297
288
|
server.onNotification(method, params => {
|
|
298
289
|
assert.deepStrictEqual(params, [10, 'vscode']);
|
|
299
290
|
done();
|
|
300
291
|
});
|
|
301
292
|
server.listen();
|
|
302
|
-
const client = connection_1.createConnection(clientTransports);
|
|
293
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
303
294
|
client.listen();
|
|
304
295
|
client.sendNotification(method, [10, 'vscode']);
|
|
305
296
|
});
|
|
306
|
-
it('params in request/response', () =>
|
|
297
|
+
it('params in request/response', async () => {
|
|
307
298
|
const method = 'add';
|
|
308
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
309
|
-
const server = connection_1.createConnection(serverTransports);
|
|
299
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
300
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
310
301
|
server.onRequest(method, (params) => {
|
|
311
302
|
assert.deepStrictEqual(params, [10, 20, 30]);
|
|
312
303
|
return params.reduce((sum, n) => sum + n, 0);
|
|
313
304
|
});
|
|
314
305
|
server.listen();
|
|
315
|
-
const client = connection_1.createConnection(clientTransports);
|
|
306
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
316
307
|
client.listen();
|
|
317
|
-
assert.strictEqual(
|
|
318
|
-
})
|
|
319
|
-
it('params in request/response with signal', () =>
|
|
308
|
+
assert.strictEqual(await client.sendRequest(method, [10, 20, 30]), 60);
|
|
309
|
+
});
|
|
310
|
+
it('params in request/response with signal', async () => {
|
|
320
311
|
const method = 'add';
|
|
321
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
322
|
-
const server = connection_1.createConnection(serverTransports);
|
|
312
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
313
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
323
314
|
server.onRequest(method, (params, _signal) => {
|
|
324
315
|
assert.deepStrictEqual(params, [10, 20, 30]);
|
|
325
316
|
return params.reduce((sum, n) => sum + n, 0);
|
|
326
317
|
});
|
|
327
318
|
server.listen();
|
|
328
|
-
const client = connection_1.createConnection(clientTransports);
|
|
319
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
329
320
|
const signal = new abort_controller_1.default().signal;
|
|
330
321
|
client.listen();
|
|
331
|
-
assert.strictEqual(
|
|
332
|
-
})
|
|
333
|
-
it('1 param as array in request', () =>
|
|
322
|
+
assert.strictEqual(await client.sendRequest(method, [10, 20, 30], signal), 60);
|
|
323
|
+
});
|
|
324
|
+
it('1 param as array in request', async () => {
|
|
334
325
|
const type = 'add';
|
|
335
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
336
|
-
const server = connection_1.createConnection(serverTransports);
|
|
326
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
327
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
337
328
|
server.onRequest(type, p1 => {
|
|
338
329
|
assert(Array.isArray(p1));
|
|
339
330
|
assert.strictEqual(p1[0], 10);
|
|
@@ -342,109 +333,109 @@ describe('Connection', () => {
|
|
|
342
333
|
return 60;
|
|
343
334
|
});
|
|
344
335
|
server.listen();
|
|
345
|
-
const client = connection_1.createConnection(clientTransports);
|
|
336
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
346
337
|
const signal = new abort_controller_1.default().signal;
|
|
347
338
|
client.listen();
|
|
348
|
-
assert.strictEqual(
|
|
349
|
-
})
|
|
339
|
+
assert.strictEqual(await client.sendRequest(type, [10, 20, 30], signal), 60);
|
|
340
|
+
});
|
|
350
341
|
it('1 param as array in notification', done => {
|
|
351
342
|
const type = 'add';
|
|
352
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
353
|
-
const server = connection_1.createConnection(serverTransports);
|
|
343
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
344
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
354
345
|
server.onNotification(type, params => {
|
|
355
346
|
assert.deepStrictEqual(params, [10, 20, 30]);
|
|
356
347
|
done();
|
|
357
348
|
});
|
|
358
349
|
server.listen();
|
|
359
|
-
const client = connection_1.createConnection(clientTransports);
|
|
350
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
360
351
|
client.listen();
|
|
361
352
|
client.sendNotification(type, [10, 20, 30]);
|
|
362
353
|
});
|
|
363
|
-
it('untyped request/response', () =>
|
|
364
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
365
|
-
const server = connection_1.createConnection(serverTransports);
|
|
354
|
+
it('untyped request/response', async () => {
|
|
355
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
356
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
366
357
|
server.onRequest('test', (params, _signal) => {
|
|
367
358
|
assert.deepStrictEqual(params, [10, 20, 30]);
|
|
368
359
|
return params.reduce((sum, n) => sum + n, 0);
|
|
369
360
|
});
|
|
370
361
|
server.listen();
|
|
371
|
-
const client = connection_1.createConnection(clientTransports);
|
|
362
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
372
363
|
const signal = new abort_controller_1.default().signal;
|
|
373
364
|
client.listen();
|
|
374
|
-
assert.strictEqual(
|
|
375
|
-
})
|
|
365
|
+
assert.strictEqual(await client.sendRequest('test', [10, 20, 30], signal), 60);
|
|
366
|
+
});
|
|
376
367
|
it('untyped notification', done => {
|
|
377
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
378
|
-
const server = connection_1.createConnection(serverTransports);
|
|
368
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
369
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
379
370
|
server.onNotification('test', (params) => {
|
|
380
371
|
assert.deepStrictEqual(params, [10, 20, 30]);
|
|
381
372
|
done();
|
|
382
373
|
});
|
|
383
374
|
server.listen();
|
|
384
|
-
const client = connection_1.createConnection(clientTransports);
|
|
375
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
385
376
|
client.listen();
|
|
386
377
|
client.sendNotification('test', [10, 20, 30]);
|
|
387
378
|
});
|
|
388
|
-
it('star request handler', () =>
|
|
389
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
390
|
-
const server = connection_1.createConnection(serverTransports);
|
|
379
|
+
it('star request handler', async () => {
|
|
380
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
381
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
391
382
|
server.onRequest((method, params, _signal) => {
|
|
392
383
|
assert.strictEqual(method, 'test');
|
|
393
384
|
assert.deepStrictEqual(params, [10, 20, 30]);
|
|
394
385
|
return params.reduce((sum, n) => sum + n, 0);
|
|
395
386
|
});
|
|
396
387
|
server.listen();
|
|
397
|
-
const client = connection_1.createConnection(clientTransports);
|
|
388
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
398
389
|
const signal = new abort_controller_1.default().signal;
|
|
399
390
|
client.listen();
|
|
400
|
-
assert.strictEqual(
|
|
401
|
-
})
|
|
391
|
+
assert.strictEqual(await client.sendRequest('test', [10, 20, 30], signal), 60);
|
|
392
|
+
});
|
|
402
393
|
it('star notification handler', done => {
|
|
403
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
404
|
-
const server = connection_1.createConnection(serverTransports);
|
|
394
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
395
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
405
396
|
server.onNotification((method, params) => {
|
|
406
397
|
assert.strictEqual(method, 'test');
|
|
407
398
|
assert.deepStrictEqual(params, [10, 20, 30]);
|
|
408
399
|
done();
|
|
409
400
|
});
|
|
410
401
|
server.listen();
|
|
411
|
-
const client = connection_1.createConnection(clientTransports);
|
|
402
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
412
403
|
client.listen();
|
|
413
404
|
client.sendNotification('test', [10, 20, 30]);
|
|
414
405
|
});
|
|
415
|
-
it('abort signal is undefined', () =>
|
|
406
|
+
it('abort signal is undefined', async () => {
|
|
416
407
|
const type = 'add';
|
|
417
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
418
|
-
const server = connection_1.createConnection(serverTransports);
|
|
408
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
409
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
419
410
|
server.onRequest(type, (params, _signal) => {
|
|
420
411
|
assert.deepStrictEqual(params, [10, 20, 30]);
|
|
421
412
|
return params.reduce((sum, n) => sum + n, 0);
|
|
422
413
|
});
|
|
423
414
|
server.listen();
|
|
424
|
-
const client = connection_1.createConnection(clientTransports);
|
|
415
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
425
416
|
client.listen();
|
|
426
|
-
assert.strictEqual(
|
|
427
|
-
})
|
|
428
|
-
it('null params in request', () =>
|
|
417
|
+
assert.strictEqual(await client.sendRequest(type, [10, 20, 30], undefined), 60);
|
|
418
|
+
});
|
|
419
|
+
it('null params in request', async () => {
|
|
429
420
|
const type = 'add';
|
|
430
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
431
|
-
const server = connection_1.createConnection(serverTransports);
|
|
421
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
422
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
432
423
|
server.onRequest(type, _signal => 123);
|
|
433
424
|
server.listen();
|
|
434
|
-
const client = connection_1.createConnection(clientTransports);
|
|
425
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
435
426
|
client.listen();
|
|
436
427
|
client.sendRequest(type, null).then((result) => assert.strictEqual(result, 123));
|
|
437
|
-
})
|
|
428
|
+
});
|
|
438
429
|
it('null params in notifications', done => {
|
|
439
430
|
const type = 'test';
|
|
440
|
-
const [serverTransports, clientTransports] = test_helper_1.createMessageTransports();
|
|
441
|
-
const server = connection_1.createConnection(serverTransports);
|
|
431
|
+
const [serverTransports, clientTransports] = (0, test_helper_1.createMessageTransports)();
|
|
432
|
+
const server = (0, connection_1.createConnection)(serverTransports);
|
|
442
433
|
server.onNotification(type, params => {
|
|
443
434
|
assert.strictEqual(params, null);
|
|
444
435
|
done();
|
|
445
436
|
});
|
|
446
437
|
server.listen();
|
|
447
|
-
const client = connection_1.createConnection(clientTransports);
|
|
438
|
+
const client = (0, connection_1.createConnection)(clientTransports);
|
|
448
439
|
client.listen();
|
|
449
440
|
client.sendNotification(type, null);
|
|
450
441
|
});
|