@hydranium/protocol 1.0.0-next.6 → 1.0.0-next.61
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/README.md +35 -1
- package/lib/client/data-connection.d.ts +76 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +73 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +9 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +14 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +16 -21
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +56 -74
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +67 -101
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +5 -2
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +5 -2
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +8 -2
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +10 -4
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +116 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +155 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +2 -2
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +6 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +21 -1
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +70 -3
- package/lib/data/events.d.ts.map +1 -1
- package/lib/errors.d.ts +25 -6
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +32 -12
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/messages/index.d.ts +28 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +52 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +141 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +138 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +2 -2
- package/lib/model-server.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.d.ts +29 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +22 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +7 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +11 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +14 -5
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +4 -1
- package/lib/testing/index.js.map +1 -1
- package/lib/transfer-diagnostic.d.ts +33 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +23 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/package.json +11 -2
- package/src/client/data-connection.ts +114 -0
- package/src/client/data-events.ts +24 -1
- package/src/client/data-port.ts +16 -22
- package/src/client/data-session.ts +86 -124
- package/src/client/index.ts +5 -2
- package/src/client/message-relay.ts +28 -6
- package/src/client/rpc-connection.ts +205 -0
- package/src/data/data-protocol-methods.ts +6 -3
- package/src/data/data-server-protocol.ts +29 -1
- package/src/data/events.ts +74 -3
- package/src/errors.ts +38 -14
- package/src/index.ts +4 -0
- package/src/messages/index.ts +35 -0
- package/src/messages/primitives.ts +215 -0
- package/src/model-server.ts +2 -2
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +14 -1
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +33 -17
- package/src/testing/index.ts +4 -1
- package/src/transfer-diagnostic.ts +40 -0
|
@@ -9,73 +9,42 @@
|
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.DataSession = void 0;
|
|
12
|
-
const data_1 = require("../data");
|
|
13
|
-
const rpc_1 = require("../rpc");
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* adapter.
|
|
13
|
+
* One participant on a data connection: a properties panel, a tree, a
|
|
14
|
+
* form editor.
|
|
18
15
|
*
|
|
19
|
-
*
|
|
16
|
+
* The server keys every hold and watch per `(uri, clientId)`, so the identity
|
|
17
|
+
* belongs to the participant rather than to the wire — several sessions share
|
|
18
|
+
* one connection, and two participants forced to share one identity cannot
|
|
19
|
+
* distinguish each other's writes from their own echoes.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* across concurrent callers. A socket client can connect before the
|
|
25
|
-
* workspace walk finishes, and an early request is then answered correctly
|
|
26
|
-
* from an empty registry, which reads as a broken project tier rather than
|
|
27
|
-
* as a race.
|
|
28
|
-
* 3. **Own the reconnect policy**, by dropping its connection generation when
|
|
29
|
-
* the port disposes and building a fresh one on the next request.
|
|
21
|
+
* Every document operation stamps {@link clientId} itself. A caller that
|
|
22
|
+
* passed its own could pass another participant's, and the server would
|
|
23
|
+
* attribute the write and release the hold accordingly.
|
|
30
24
|
*
|
|
31
|
-
*
|
|
32
|
-
* {@link connected}. The one exception is {@link openDocument}, which exists
|
|
33
|
-
* because the open/watch *order* is silently wrong the other way round — see
|
|
34
|
-
* its own doc.
|
|
35
|
-
*
|
|
36
|
-
* Generic over the transfer root so this file names no grammar. An adopter
|
|
37
|
-
* binds the concrete root (or the union of them, for a multi-grammar head) at
|
|
38
|
-
* its own edge.
|
|
25
|
+
* Generic over the transfer root so this file names no grammar.
|
|
39
26
|
*/
|
|
40
27
|
class DataSession {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
generation;
|
|
28
|
+
clientId;
|
|
29
|
+
host;
|
|
30
|
+
/** URIs this session holds open, so {@link dispose} can release exactly those. */
|
|
31
|
+
openUris = new Set();
|
|
46
32
|
disposed = false;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
this.client = client;
|
|
51
|
-
this.methodNamespace = options.methodNamespace ?? data_1.DATA_SERVER_WIRE_PREFIX;
|
|
52
|
-
this.portDisposeListener = this.port.onDispose(() => this.dropGeneration());
|
|
53
|
-
}
|
|
54
|
-
/** The identity every request is made under — the port's, not a second one. */
|
|
55
|
-
get clientId() {
|
|
56
|
-
return this.port.clientId;
|
|
33
|
+
constructor(clientId, host) {
|
|
34
|
+
this.clientId = clientId;
|
|
35
|
+
this.host = host;
|
|
57
36
|
}
|
|
58
37
|
/**
|
|
59
|
-
* The connected, READY server proxy
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* proxy, so a caller that cached one from an earlier call would go on
|
|
63
|
-
* addressing a dead connection with no error — handing it back per call
|
|
64
|
-
* makes the stale reference unrepresentable.
|
|
65
|
-
*
|
|
66
|
-
* Concurrent callers share one readiness promise, so `waitForReady` is
|
|
67
|
-
* awaited once per generation and not once per caller.
|
|
38
|
+
* The connected, READY server proxy, for protocol methods this session does
|
|
39
|
+
* not wrap — the ones carrying no `clientId`, so no identity can be got
|
|
40
|
+
* wrong through them.
|
|
68
41
|
*/
|
|
69
42
|
async connected() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
generation.ready = this.awaitReady(generation);
|
|
76
|
-
}
|
|
77
|
-
await generation.ready;
|
|
78
|
-
return generation.server;
|
|
43
|
+
// `async` so a disposed session REJECTS rather than throwing
|
|
44
|
+
// synchronously: the connection's own `connected` rejects, and a caller
|
|
45
|
+
// reaching for `.catch` on one of them would not catch the other.
|
|
46
|
+
this.assertLive();
|
|
47
|
+
return this.host.connected();
|
|
79
48
|
}
|
|
80
49
|
/**
|
|
81
50
|
* Open `uri` for editing and start watching it, in that order, returning
|
|
@@ -99,6 +68,7 @@ class DataSession {
|
|
|
99
68
|
const server = await this.connected();
|
|
100
69
|
const document = await server.openModelDocument({ uri, clientId: this.clientId });
|
|
101
70
|
await server.watchModelDocument({ uri, clientId: this.clientId });
|
|
71
|
+
this.openUris.add(uri);
|
|
102
72
|
return document;
|
|
103
73
|
}
|
|
104
74
|
/**
|
|
@@ -107,10 +77,21 @@ class DataSession {
|
|
|
107
77
|
*/
|
|
108
78
|
async closeDocument(uri) {
|
|
109
79
|
const server = await this.connected();
|
|
80
|
+
this.openUris.delete(uri);
|
|
110
81
|
await server.closeModelDocument({ uri, clientId: this.clientId });
|
|
111
82
|
}
|
|
83
|
+
/** Write `args.model` back as this session. */
|
|
84
|
+
async updateDocument(args) {
|
|
85
|
+
const server = await this.connected();
|
|
86
|
+
return server.updateModelDocument({ ...args, clientId: this.clientId });
|
|
87
|
+
}
|
|
88
|
+
/** Persist `args.model` to disk as this session. */
|
|
89
|
+
async saveDocument(args) {
|
|
90
|
+
const server = await this.connected();
|
|
91
|
+
return server.saveModelDocument({ ...args, clientId: this.clientId });
|
|
92
|
+
}
|
|
112
93
|
/**
|
|
113
|
-
* Whether `
|
|
94
|
+
* Whether `sourceClientId` identifies this session's own write.
|
|
114
95
|
*
|
|
115
96
|
* Every watcher needs this and the check is one comparison, so getting it
|
|
116
97
|
* wrong is cheap to do and expensive to find: an unfiltered echo looks
|
|
@@ -119,60 +100,45 @@ class DataSession {
|
|
|
119
100
|
isOwnEcho(sourceClientId) {
|
|
120
101
|
return sourceClientId === this.clientId;
|
|
121
102
|
}
|
|
122
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Release this session's holds and detach it from the connection.
|
|
105
|
+
* Idempotent, and leaves the connection usable by its other sessions.
|
|
106
|
+
*
|
|
107
|
+
* The closes are fired without being awaited, because a `Disposable` cannot
|
|
108
|
+
* be: a host disposing a widget has nowhere to put the promise. A close
|
|
109
|
+
* that fails is no worse than the leak this exists to prevent, so the
|
|
110
|
+
* rejection is swallowed rather than surfaced from a teardown.
|
|
111
|
+
*/
|
|
123
112
|
dispose() {
|
|
124
113
|
if (this.disposed) {
|
|
125
114
|
return;
|
|
126
115
|
}
|
|
127
116
|
this.disposed = true;
|
|
128
|
-
this.
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const connection = this.port.connect();
|
|
137
|
-
// Rejection is reported here rather than left to float: an unhandled
|
|
138
|
-
// rejection on a connection promise is the failure mode that reads as
|
|
139
|
-
// "the model is empty" instead of "the transport never opened".
|
|
140
|
-
connection.catch((error) => this.port.reportError(error, 'connecting to the data server'));
|
|
141
|
-
const server = (0, rpc_1.createRpcProxy)(connection, {
|
|
142
|
-
methodNamespace: this.methodNamespace,
|
|
143
|
-
localTarget: this.client,
|
|
144
|
-
localMethods: data_1.DATA_CLIENT_PROTOCOL_METHODS
|
|
145
|
-
});
|
|
146
|
-
this.generation = { connection, server };
|
|
147
|
-
return this.generation;
|
|
148
|
-
}
|
|
149
|
-
/** Await the connection and the server's startup gate for one generation. */
|
|
150
|
-
async awaitReady(generation) {
|
|
151
|
-
try {
|
|
152
|
-
await generation.connection;
|
|
153
|
-
await generation.server.waitForReady();
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
// Drop the generation so the next request retries rather than
|
|
157
|
-
// re-awaiting a settled rejection forever.
|
|
158
|
-
if (this.generation === generation) {
|
|
159
|
-
this.generation = undefined;
|
|
160
|
-
}
|
|
161
|
-
this.port.reportError(error, 'waiting for the data server to become ready');
|
|
162
|
-
throw error;
|
|
117
|
+
const uris = [...this.openUris];
|
|
118
|
+
this.openUris.clear();
|
|
119
|
+
this.host.releaseSession(this);
|
|
120
|
+
for (const uri of uris) {
|
|
121
|
+
void this.host
|
|
122
|
+
.connected()
|
|
123
|
+
.then(server => server.closeModelDocument({ uri, clientId: this.clientId }))
|
|
124
|
+
.catch(() => undefined);
|
|
163
125
|
}
|
|
164
126
|
}
|
|
165
127
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
128
|
+
* Come off the connection because it is going away.
|
|
129
|
+
*
|
|
130
|
+
* Sends no close, unlike {@link dispose}: the server releases every hold on
|
|
131
|
+
* a connection it sees close, and the close would travel over the very
|
|
132
|
+
* connection being disposed.
|
|
168
133
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.
|
|
172
|
-
|
|
173
|
-
|
|
134
|
+
detach() {
|
|
135
|
+
this.disposed = true;
|
|
136
|
+
this.openUris.clear();
|
|
137
|
+
}
|
|
138
|
+
assertLive() {
|
|
139
|
+
if (this.disposed) {
|
|
140
|
+
throw new Error('DataSession is disposed');
|
|
174
141
|
}
|
|
175
|
-
generation.connection.then(connection => connection.dispose()).catch(() => undefined);
|
|
176
142
|
}
|
|
177
143
|
}
|
|
178
144
|
exports.DataSession = DataSession;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-session.js","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;
|
|
1
|
+
{"version":3,"file":"data-session.js","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAwBlF;;;;;;;;;;;;;;GAcG;AACH,MAAa,WAAW;IAMT;IACU;IANtB,kFAAkF;I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AES,UAAU;QACjB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC9C,CAAC;IACJ,CAAC;CACH;AA5HD,kCA4HC"}
|
package/lib/client/index.d.ts
CHANGED
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Where `./data` is the wire *contract* and `./rpc` is the machinery that lowers
|
|
14
14
|
* it onto a connection, this is what a client wraps around both: the seam a host
|
|
15
|
-
* fills in (`DataPort`), the
|
|
16
|
-
*
|
|
15
|
+
* fills in (`DataPort`), the connection above it (`DataConnection` — readiness
|
|
16
|
+
* gate and reconnect), the participants on that connection (`DataSession` —
|
|
17
|
+
* identity, open/watch ordering, echo recognition), the inbound
|
|
17
18
|
* fan-out (`DataEvents`), and the two halves of the hop for hosts whose
|
|
18
19
|
* client cannot hold a socket — `createPostMessageTransport` on the client
|
|
19
20
|
* side and `relayToPostMessageChannel` on the side that does hold it.
|
|
@@ -31,9 +32,11 @@
|
|
|
31
32
|
* anything new, and reach for the Theia package only for what genuinely needs
|
|
32
33
|
* Theia DI.
|
|
33
34
|
*/
|
|
35
|
+
export * from './data-connection';
|
|
34
36
|
export * from './data-events';
|
|
35
37
|
export * from './data-port';
|
|
36
38
|
export * from './data-session';
|
|
37
39
|
export * from './message-relay';
|
|
38
40
|
export * from './post-message-transport';
|
|
41
|
+
export * from './rpc-connection';
|
|
39
42
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC"}
|
package/lib/client/index.js
CHANGED
|
@@ -28,8 +28,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
28
28
|
*
|
|
29
29
|
* Where `./data` is the wire *contract* and `./rpc` is the machinery that lowers
|
|
30
30
|
* it onto a connection, this is what a client wraps around both: the seam a host
|
|
31
|
-
* fills in (`DataPort`), the
|
|
32
|
-
*
|
|
31
|
+
* fills in (`DataPort`), the connection above it (`DataConnection` — readiness
|
|
32
|
+
* gate and reconnect), the participants on that connection (`DataSession` —
|
|
33
|
+
* identity, open/watch ordering, echo recognition), the inbound
|
|
33
34
|
* fan-out (`DataEvents`), and the two halves of the hop for hosts whose
|
|
34
35
|
* client cannot hold a socket — `createPostMessageTransport` on the client
|
|
35
36
|
* side and `relayToPostMessageChannel` on the side that does hold it.
|
|
@@ -47,9 +48,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
47
48
|
* anything new, and reach for the Theia package only for what genuinely needs
|
|
48
49
|
* Theia DI.
|
|
49
50
|
*/
|
|
51
|
+
__exportStar(require("./data-connection"), exports);
|
|
50
52
|
__exportStar(require("./data-events"), exports);
|
|
51
53
|
__exportStar(require("./data-port"), exports);
|
|
52
54
|
__exportStar(require("./data-session"), exports);
|
|
53
55
|
__exportStar(require("./message-relay"), exports);
|
|
54
56
|
__exportStar(require("./post-message-transport"), exports);
|
|
57
|
+
__exportStar(require("./rpc-connection"), exports);
|
|
55
58
|
//# sourceMappingURL=index.js.map
|
package/lib/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,oDAAkC;AAClC,gDAA8B;AAC9B,8CAA4B;AAC5B,iDAA+B;AAC/B,kDAAgC;AAChC,2DAAyC;AACzC,mDAAiC"}
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type Disposable, type Event, type MessageReader, type MessageWriter } from 'vscode-jsonrpc';
|
|
10
|
+
import { type ResolvedMessage } from '../messages/primitives';
|
|
10
11
|
import type { PostMessageChannel } from './post-message-transport';
|
|
12
|
+
export declare const RELAY_TRANSPORT_OPEN_FAILED: import("../messages/primitives").MessageDefinition<"Could not open the transport to relay: {detail}">;
|
|
13
|
+
export declare const RELAY_TRANSPORT_READ_FAILED: import("../messages/primitives").MessageDefinition<"Could not read from the relayed transport: {detail}">;
|
|
14
|
+
export declare const RELAY_TRANSPORT_WRITE_FAILED: import("../messages/primitives").MessageDefinition<"Could not write to the relayed transport: {detail}">;
|
|
15
|
+
export declare const RELAY_REPLAY_FAILED: import("../messages/primitives").MessageDefinition<"Could not replay a buffered message to the relayed transport: {detail}">;
|
|
11
16
|
/**
|
|
12
17
|
* The framed side of a relay: the reader/writer pair over whatever transport the
|
|
13
18
|
* host actually holds — a TCP socket to the data-server, a child process' stdio,
|
|
@@ -27,13 +32,14 @@ export interface RelayTransport {
|
|
|
27
32
|
export interface MessageRelayOptions {
|
|
28
33
|
/**
|
|
29
34
|
* Surface a failure the way the host does. Same contract as
|
|
30
|
-
* `DataPort.reportError`: `
|
|
35
|
+
* `DataPort.reportError`: `reported` is a complete sentence plus the identity
|
|
36
|
+
* needed to render it in another language.
|
|
31
37
|
*
|
|
32
38
|
* A relay has no other way to report — it sits between two transports and
|
|
33
39
|
* owns neither, so a swallowed error here presents as a form that never
|
|
34
40
|
* populates.
|
|
35
41
|
*/
|
|
36
|
-
readonly reportError?: (error: unknown,
|
|
42
|
+
readonly reportError?: (error: unknown, reported: ResolvedMessage) => void;
|
|
37
43
|
}
|
|
38
44
|
/** A live relay. Dispose to tear both directions down. */
|
|
39
45
|
export interface MessageRelay extends Disposable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-relay.d.ts","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,KAAK,EAAgB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,gEAAgE;IAChE,OAAO,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IACjC
|
|
1
|
+
{"version":3,"file":"message-relay.d.ts","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,KAAK,EAAgB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,eAAO,MAAM,2BAA2B,uGAGvC,CAAC;AAEF,eAAO,MAAM,2BAA2B,2GAGvC,CAAC;AAEF,eAAO,MAAM,4BAA4B,0GAGxC,CAAC;AAEF,eAAO,MAAM,mBAAmB,8HAG/B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,gEAAgE;IAChE,OAAO,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IACjC;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;CAC7E;AAED,0DAA0D;AAC1D,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC7C;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,yBAAyB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,aAAa,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,EAC5C,OAAO,GAAE,mBAAwB,GACjC,YAAY,CAgGd"}
|
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.RELAY_REPLAY_FAILED = exports.RELAY_TRANSPORT_WRITE_FAILED = exports.RELAY_TRANSPORT_READ_FAILED = exports.RELAY_TRANSPORT_OPEN_FAILED = void 0;
|
|
11
12
|
exports.relayToPostMessageChannel = relayToPostMessageChannel;
|
|
12
13
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
14
|
+
const primitives_1 = require("../messages/primitives");
|
|
15
|
+
exports.RELAY_TRANSPORT_OPEN_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/relay-transport-open-failed', 'Could not open the transport to relay: {detail}');
|
|
16
|
+
exports.RELAY_TRANSPORT_READ_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/relay-transport-read-failed', 'Could not read from the relayed transport: {detail}');
|
|
17
|
+
exports.RELAY_TRANSPORT_WRITE_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/relay-transport-write-failed', 'Could not write to the relayed transport: {detail}');
|
|
18
|
+
exports.RELAY_REPLAY_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/relay-replay-failed', 'Could not replay a buffered message to the relayed transport: {detail}');
|
|
13
19
|
/**
|
|
14
20
|
* Pump JSON-RPC messages between a framed transport and a structured-clone
|
|
15
21
|
* {@link PostMessageChannel}, decoding neither.
|
|
@@ -78,7 +84,7 @@ function relayToPostMessageChannel(channel, openTransport, options = {}) {
|
|
|
78
84
|
bufferSubscription?.dispose();
|
|
79
85
|
bufferSubscription = undefined;
|
|
80
86
|
buffered.length = 0;
|
|
81
|
-
options.reportError?.(error,
|
|
87
|
+
options.reportError?.(error, (0, primitives_1.resolve)(exports.RELAY_TRANSPORT_OPEN_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
82
88
|
closeFramedSide();
|
|
83
89
|
return false;
|
|
84
90
|
}
|
|
@@ -95,11 +101,11 @@ function relayToPostMessageChannel(channel, openTransport, options = {}) {
|
|
|
95
101
|
bufferSubscription?.dispose();
|
|
96
102
|
bufferSubscription = undefined;
|
|
97
103
|
subscriptions.push(opened.reader.listen(message => channel.post(message)), opened.reader.onClose(() => closeFramedSide()), opened.reader.onError(error => {
|
|
98
|
-
options.reportError?.(error,
|
|
104
|
+
options.reportError?.(error, (0, primitives_1.resolve)(exports.RELAY_TRANSPORT_READ_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
99
105
|
closeFramedSide();
|
|
100
106
|
}), channel.onMessage(message => {
|
|
101
107
|
void opened.writer.write(message).catch((error) => {
|
|
102
|
-
options.reportError?.(error,
|
|
108
|
+
options.reportError?.(error, (0, primitives_1.resolve)(exports.RELAY_TRANSPORT_WRITE_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
103
109
|
});
|
|
104
110
|
}));
|
|
105
111
|
const onChannelClose = channel.onClose?.(() => dispose());
|
|
@@ -108,7 +114,7 @@ function relayToPostMessageChannel(channel, openTransport, options = {}) {
|
|
|
108
114
|
}
|
|
109
115
|
for (const message of buffered) {
|
|
110
116
|
void opened.writer.write(message).catch((error) => {
|
|
111
|
-
options.reportError?.(error,
|
|
117
|
+
options.reportError?.(error, (0, primitives_1.resolve)(exports.RELAY_REPLAY_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
112
118
|
});
|
|
113
119
|
}
|
|
114
120
|
buffered.length = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-relay.js","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"message-relay.js","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAkIlF,8DAoGC;AApOD,mDAA4H;AAC5H,uDAAqG;AAGxF,QAAA,2BAA2B,GAAG,IAAA,0BAAa,EACrD,gDAAgD,EAChD,iDAAiD,CACnD,CAAC;AAEW,QAAA,2BAA2B,GAAG,IAAA,0BAAa,EACrD,gDAAgD,EAChD,qDAAqD,CACvD,CAAC;AAEW,QAAA,4BAA4B,GAAG,IAAA,0BAAa,EACtD,iDAAiD,EACjD,oDAAoD,CACtD,CAAC;AAEW,QAAA,mBAAmB,GAAG,IAAA,0BAAa,EAC7C,wCAAwC,EACxC,wEAAwE,CAC1E,CAAC;AA8DF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,SAAgB,yBAAyB,CACtC,OAA2B,EAC3B,aAA4C,EAC5C,UAA+B,EAAE;IAEjC,MAAM,YA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AE,CAAC,KAAK,EAAE,IAAA,oBAAO,EAAC,2BAAmB,EAAE,EAAE,MAAM,EAAE,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YAChG,CAAC,CAAC,CAAC;QACN,CAAC;QACD,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QAEpB,OAAO,IAAI,CAAC;IACf,CAAC,CAAC,EAAE,CAAC;IAEL,SAAS,OAAO;QACb,IAAI,QAAQ,EAAE,CAAC;YACZ,OAAO;QACV,CAAC;QACD,QAAQ,GAAG,IAAI,CAAC;QAChB,kBAAkB,EAAE,OAAO,EAAE,CAAC;QAC9B,kBAAkB,GAAG,SAAS,CAAC;QAC/B,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACpB,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;YACxC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC1B,CAAC;QACD,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QACzB,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC;QACvB,SAAS,GAAG,SAAS,CAAC;QACtB,YAAY,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO;QACJ,KAAK;QACL,OAAO,EAAE,YAAY,CAAC,KAAK;QAC3B,OAAO;KACT,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import type { MessageConnection } from 'vscode-jsonrpc';
|
|
10
|
+
import { type RpcProxy } from '../rpc';
|
|
11
|
+
import type { DataPort } from './data-port';
|
|
12
|
+
/**
|
|
13
|
+
* The transport never opened. A complete sentence rather than a fragment: a
|
|
14
|
+
* fragment is nested inside a sentence the framework does not own, so no
|
|
15
|
+
* translator controls the whole and the composition cannot be made to read
|
|
16
|
+
* correctly in every language.
|
|
17
|
+
*/
|
|
18
|
+
export declare const DATA_SERVER_CONNECT_FAILED: import("../messages/primitives").MessageDefinition<"Could not connect to the data server: {detail}">;
|
|
19
|
+
export declare const DATA_SERVER_NOT_READY: import("../messages/primitives").MessageDefinition<"The data server did not become ready: {detail}">;
|
|
20
|
+
/** The one method a connection needs of any server: its startup gate. */
|
|
21
|
+
export interface ReadyServer {
|
|
22
|
+
waitForReady(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/** Lifecycle reporting, for a host that raises warm-up UI around the two waits. */
|
|
25
|
+
export interface RpcConnectionLifecycle {
|
|
26
|
+
/** A generation is opening its transport, including on each reconnect. */
|
|
27
|
+
readonly onConnecting?: () => void;
|
|
28
|
+
/** The server's readiness gate has settled for a generation. */
|
|
29
|
+
readonly onReady?: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* A generation failed to connect or to become ready. The failure is still
|
|
32
|
+
* reported through {@link DataPort.reportError} and still rejects the
|
|
33
|
+
* awaiting caller; this is for a host that also drives its own UI.
|
|
34
|
+
*/
|
|
35
|
+
readonly onFailed?: (error: unknown) => void;
|
|
36
|
+
}
|
|
37
|
+
/** Everything {@link RpcConnection} needs once a subclass has resolved its defaults. */
|
|
38
|
+
export interface ResolvedRpcConnectionOptions<TClient extends object> {
|
|
39
|
+
readonly methodNamespace: string;
|
|
40
|
+
readonly clientMethods: readonly (keyof TClient & string)[];
|
|
41
|
+
readonly lifecycle: RpcConnectionLifecycle;
|
|
42
|
+
}
|
|
43
|
+
/** One connection generation: its connection, its proxy, and its readiness. */
|
|
44
|
+
interface Generation<TServer extends object> {
|
|
45
|
+
readonly connection: Promise<MessageConnection>;
|
|
46
|
+
readonly server: RpcProxy<TServer>;
|
|
47
|
+
/** Set on first use; the shared readiness gate for this generation. */
|
|
48
|
+
ready?: Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One JSON-RPC connection to a head, with the three jobs every host adapter
|
|
52
|
+
* would otherwise re-derive above {@link DataPort}:
|
|
53
|
+
*
|
|
54
|
+
* 1. **Build the typed proxy** over the port's connection, with the caller's
|
|
55
|
+
* wire prefix and client-method allowlist.
|
|
56
|
+
* 2. **Own the readiness gate** — `waitForReady` once per connection, shared
|
|
57
|
+
* across concurrent callers. A client can connect before the workspace walk
|
|
58
|
+
* finishes, and an early request is then answered correctly from an empty
|
|
59
|
+
* registry, which reads as a broken project tier rather than as a race.
|
|
60
|
+
* 3. **Own the reconnect policy**, by dropping its generation when the port
|
|
61
|
+
* disposes and building a fresh one on the next request.
|
|
62
|
+
*
|
|
63
|
+
* Bounded only by {@link ReadyServer}, so a head serving a slice of the data
|
|
64
|
+
* protocol — diagnostics alone, or one with methods excluded — is still a
|
|
65
|
+
* legal server here. `DataConnection` narrows the bound because its sessions
|
|
66
|
+
* call the document methods; nothing at this layer does.
|
|
67
|
+
*/
|
|
68
|
+
export declare class RpcConnection<TServer extends ReadyServer, TClient extends object> {
|
|
69
|
+
protected readonly port: DataPort;
|
|
70
|
+
protected readonly client: TClient;
|
|
71
|
+
protected readonly methodNamespace: string;
|
|
72
|
+
protected readonly clientMethods: readonly (keyof TClient & string)[];
|
|
73
|
+
protected readonly lifecycle: RpcConnectionLifecycle;
|
|
74
|
+
/** The current generation, or `undefined` before the first request / after a teardown. */
|
|
75
|
+
protected generation?: Generation<TServer>;
|
|
76
|
+
protected disposed: boolean;
|
|
77
|
+
protected readonly portDisposeListener: {
|
|
78
|
+
dispose(): void;
|
|
79
|
+
};
|
|
80
|
+
constructor(port: DataPort, client: TClient, options: ResolvedRpcConnectionOptions<TClient>);
|
|
81
|
+
/**
|
|
82
|
+
* The connected, READY server proxy.
|
|
83
|
+
*
|
|
84
|
+
* Returns the proxy rather than `void` on purpose. A reconnect replaces the
|
|
85
|
+
* proxy, so a caller that cached one from an earlier call would go on
|
|
86
|
+
* addressing a dead connection with no error — handing it back per call
|
|
87
|
+
* makes the stale reference unrepresentable.
|
|
88
|
+
*
|
|
89
|
+
* Concurrent callers share one readiness promise, so `waitForReady` is
|
|
90
|
+
* awaited once per generation and not once per caller.
|
|
91
|
+
*/
|
|
92
|
+
connected(): Promise<RpcProxy<TServer>>;
|
|
93
|
+
/**
|
|
94
|
+
* The current generation's proxy WITHOUT awaiting readiness — calls queue
|
|
95
|
+
* against the connection promise.
|
|
96
|
+
*
|
|
97
|
+
* Read per access, never cached: a reconnect replaces the generation, and a
|
|
98
|
+
* held reference would address the dead one. Prefer {@link connected}, which
|
|
99
|
+
* also waits for the server's startup gate.
|
|
100
|
+
*/
|
|
101
|
+
get server(): RpcProxy<TServer>;
|
|
102
|
+
/** Tear down the current connection and stop tracking the port. Idempotent. */
|
|
103
|
+
dispose(): void;
|
|
104
|
+
/** The live generation, building one if there is none. */
|
|
105
|
+
protected currentGeneration(): Generation<TServer>;
|
|
106
|
+
/** Await the connection and the server's startup gate for one generation. */
|
|
107
|
+
protected awaitReady(generation: Generation<TServer>): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Discard the current generation, disposing its connection if it opened.
|
|
110
|
+
* The next {@link connected} builds a fresh one.
|
|
111
|
+
*/
|
|
112
|
+
protected dropGeneration(): void;
|
|
113
|
+
protected assertLive(): void;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
|
116
|
+
//# sourceMappingURL=rpc-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-connection.d.ts","sourceRoot":"","sources":["../../src/client/rpc-connection.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,QAAQ,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C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