@hydranium/protocol 1.0.0-next.11 → 1.0.0-next.112
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 +152 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +214 -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 +17 -22
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +154 -76
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +194 -109
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +10 -7
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +10 -7
- 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 +143 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +171 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +41 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +44 -0
- package/lib/client-ids.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 +35 -2
- 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 +28 -11
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +35 -17
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/latency-collector.d.ts +8 -4
- package/lib/latency-collector.d.ts.map +1 -1
- package/lib/latency-collector.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 +174 -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 +31 -12
- package/lib/model-server.d.ts.map +1 -1
- package/lib/model-server.js +4 -2
- package/lib/model-server.js.map +1 -1
- package/lib/model-service/args.d.ts +14 -13
- package/lib/model-service/args.d.ts.map +1 -1
- package/lib/model-service/based-on.d.ts +55 -0
- package/lib/model-service/based-on.d.ts.map +1 -0
- package/lib/model-service/based-on.js +34 -0
- package/lib/model-service/based-on.js.map +1 -0
- package/lib/model-service/index.d.ts +1 -0
- package/lib/model-service/index.d.ts.map +1 -1
- package/lib/model-service/index.js +1 -0
- package/lib/model-service/index.js.map +1 -1
- package/lib/profile-session.d.ts +8 -4
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js.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/lib/transfer-document.d.ts +15 -5
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +14 -1
- package/lib/transfer-document.js.map +1 -1
- package/package.json +11 -2
- package/src/client/data-connection.ts +266 -0
- package/src/client/data-events.ts +24 -1
- package/src/client/data-port.ts +17 -23
- package/src/client/data-session.ts +279 -131
- package/src/client/index.ts +10 -7
- package/src/client/message-relay.ts +28 -6
- package/src/client/rpc-connection.ts +235 -0
- package/src/client-ids.ts +45 -0
- package/src/data/data-protocol-methods.ts +6 -3
- package/src/data/data-server-protocol.ts +46 -2
- package/src/data/events.ts +74 -3
- package/src/errors.ts +41 -19
- package/src/index.ts +5 -0
- package/src/latency-collector.ts +8 -3
- package/src/messages/index.ts +35 -0
- package/src/messages/primitives.ts +250 -0
- package/src/model-server.ts +34 -13
- package/src/model-service/args.ts +15 -13
- package/src/model-service/based-on.ts +60 -0
- package/src/model-service/index.ts +1 -0
- package/src/profile-session.ts +9 -4
- 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
- package/src/transfer-document.ts +22 -6
|
@@ -9,77 +9,68 @@
|
|
|
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.
|
|
25
|
+
* Generic over the transfer root so this file names no grammar.
|
|
35
26
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
27
|
+
* `TServer` is bound to a server answering with ITS OWN diagnostic shape, read
|
|
28
|
+
* back off the parameter being bound. Simplifying that to
|
|
29
|
+
* `DataServerProtocol<TTransfer>` compiles and costs the wrappers their
|
|
30
|
+
* return type: every call through `TServer` would resolve against that looser
|
|
31
|
+
* bound, so an adopter's diagnostics would come back as the framework's and
|
|
32
|
+
* the document would have to be cast on the way out.
|
|
39
33
|
*/
|
|
40
34
|
class DataSession {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
clientId;
|
|
36
|
+
host;
|
|
37
|
+
/** URIs this session holds open, so {@link dispose} can release exactly those. */
|
|
38
|
+
openUris = new Set();
|
|
39
|
+
/**
|
|
40
|
+
* The in-flight {@link openDocument} group per URI, while one is running.
|
|
41
|
+
*
|
|
42
|
+
* A hold is one per `(uri, clientId)`, and {@link openUris} is filled only
|
|
43
|
+
* once an open has fully returned — so overlapping opens of one URI all read
|
|
44
|
+
* it as unheld and all believe the hold is theirs to release. Tracking the
|
|
45
|
+
* group lets the last of them answer for it once, knowing what the rest did.
|
|
46
|
+
*/
|
|
47
|
+
openingUris = new Map();
|
|
46
48
|
disposed = false;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return this.port.clientId;
|
|
49
|
+
/**
|
|
50
|
+
* Disposed through {@link detach} rather than {@link dispose}, so nothing may
|
|
51
|
+
* be sent. Folding it into {@link disposed} costs {@link openDocument} the
|
|
52
|
+
* distinction, and its close would then go out on a detached session.
|
|
53
|
+
*/
|
|
54
|
+
detached = false;
|
|
55
|
+
constructor(clientId, host) {
|
|
56
|
+
this.clientId = clientId;
|
|
57
|
+
this.host = host;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
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.
|
|
60
|
+
* The connected, READY server proxy, for protocol methods this session does
|
|
61
|
+
* not wrap — the ones carrying no `clientId`, so no identity can be got
|
|
62
|
+
* wrong through them.
|
|
68
63
|
*/
|
|
69
64
|
async connected() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
generation.ready = this.awaitReady(generation);
|
|
76
|
-
}
|
|
77
|
-
await generation.ready;
|
|
78
|
-
return generation.server;
|
|
65
|
+
// `async` so a disposed session REJECTS rather than throwing
|
|
66
|
+
// synchronously: the connection's own `connected` rejects, and a caller
|
|
67
|
+
// reaching for `.catch` on one of them would not catch the other.
|
|
68
|
+
this.assertLive();
|
|
69
|
+
return this.host.connected();
|
|
79
70
|
}
|
|
80
71
|
/**
|
|
81
|
-
* Open `uri` for editing and start watching it, in that order,
|
|
82
|
-
* the opened snapshot.
|
|
72
|
+
* Open `args.uri` for editing and start watching it, in that order,
|
|
73
|
+
* returning the opened snapshot.
|
|
83
74
|
*
|
|
84
75
|
* **The order is the whole reason this method exists.**
|
|
85
76
|
* `watchModelDocument` baselines its dedup fingerprint from the *current*
|
|
@@ -94,23 +85,131 @@ class DataSession {
|
|
|
94
85
|
* valid: `open` settles at the integrity landmark, not at validation.
|
|
95
86
|
* Validity arrives asynchronously on `onDocumentUpdated`, or synchronously
|
|
96
87
|
* from `getModelDocument({ includeDiagnostics: true })`.
|
|
88
|
+
*
|
|
89
|
+
* A dispose landing between the two awaits is handled here rather than in
|
|
90
|
+
* {@link dispose}, which cannot release a hold that does not exist yet: it
|
|
91
|
+
* reads {@link openUris}, and this method fills it only once both calls have
|
|
92
|
+
* returned. Left to `dispose`, the hold and its watch outlive the participant
|
|
93
|
+
* and go only when the connection closes.
|
|
94
|
+
*
|
|
95
|
+
* A watch that REJECTS is the same problem arriving by a different door: the
|
|
96
|
+
* open already took a hold, and the caller sees only a failed open, so
|
|
97
|
+
* nothing on its side will ever issue the close.
|
|
98
|
+
*
|
|
99
|
+
* Which call releases it is decided by {@link finishOpening} rather than by
|
|
100
|
+
* the one that failed, because a hold is per `(uri, clientId)` and any number
|
|
101
|
+
* of this session's opens share it. A failing open that closed on its own
|
|
102
|
+
* behalf would revoke a peer's; one that deferred to a peer would leak the
|
|
103
|
+
* hold whenever that peer fails at its OWN open, having then taken no hold to
|
|
104
|
+
* roll back and having no rollback path to run. Making the last open for the
|
|
105
|
+
* URI answer for it is the only rule that holds in both directions.
|
|
97
106
|
*/
|
|
98
|
-
async openDocument(
|
|
107
|
+
async openDocument(args) {
|
|
99
108
|
const server = await this.connected();
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
const opening = this.beginOpening(args.uri);
|
|
110
|
+
try {
|
|
111
|
+
const document = await server.openModelDocument({ ...args, clientId: this.clientId });
|
|
112
|
+
// From here a hold exists. It belongs to the URI rather than to this
|
|
113
|
+
// call, so the flag lives on the shared per-URI record.
|
|
114
|
+
opening.holdTaken = true;
|
|
115
|
+
await server.watchModelDocument({ uri: args.uri, clientId: this.clientId });
|
|
116
|
+
if (this.disposed) {
|
|
117
|
+
// Registering the URI BEFORE the open, so `dispose` could close on
|
|
118
|
+
// intent, is NOT the same fix and can invert into the leak it is meant
|
|
119
|
+
// to prevent: the close would then be issued while the open is still in
|
|
120
|
+
// flight, and a peer that does not serialise the two can complete the
|
|
121
|
+
// close first, after which the open re-registers the hold. Closing
|
|
122
|
+
// strictly after the open has resolved is the only ordering with no
|
|
123
|
+
// losing interleaving.
|
|
124
|
+
if (!this.detached) {
|
|
125
|
+
void server.closeModelDocument({ uri: args.uri, clientId: this.clientId }).catch(() => undefined);
|
|
126
|
+
}
|
|
127
|
+
// Answered for here, so the group's own release sends no second one.
|
|
128
|
+
opening.holdTaken = false;
|
|
129
|
+
// Returned rather than thrown: the caller that reaches this window is
|
|
130
|
+
// one that never awaited the open, so a rejection here surfaces as an
|
|
131
|
+
// unhandled one against a participant already gone.
|
|
132
|
+
return document;
|
|
133
|
+
}
|
|
134
|
+
this.openUris.add(args.uri);
|
|
135
|
+
return document;
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
await this.finishOpening(args.uri, server);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Join (or start) the in-flight group for `uri`, counting this call into it. */
|
|
142
|
+
beginOpening(uri) {
|
|
143
|
+
const opening = this.openingUris.get(uri) ?? { inFlight: 0, holdTaken: false };
|
|
144
|
+
opening.inFlight += 1;
|
|
145
|
+
this.openingUris.set(uri, opening);
|
|
146
|
+
return opening;
|
|
103
147
|
}
|
|
104
148
|
/**
|
|
105
|
-
*
|
|
149
|
+
* Count this call out of the in-flight group for `uri` and, if it was the
|
|
150
|
+
* last one, answer for whatever hold the group took.
|
|
151
|
+
*
|
|
152
|
+
* The last call is the only one that can see the group's whole outcome, which
|
|
153
|
+
* is what makes it the right one to decide. A hold that some open took and no
|
|
154
|
+
* open claimed — `openUris` is the claim — belongs to nobody, and closing it
|
|
155
|
+
* here is the only release that will ever be issued for it.
|
|
156
|
+
*/
|
|
157
|
+
async finishOpening(uri, server) {
|
|
158
|
+
const opening = this.openingUris.get(uri);
|
|
159
|
+
if (opening === undefined) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
opening.inFlight -= 1;
|
|
163
|
+
if (opening.inFlight > 0) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
this.openingUris.delete(uri);
|
|
167
|
+
// `detached` means the wire is going away and the server's connection-close
|
|
168
|
+
// cleanup owns the release, so a close here would travel over a connection
|
|
169
|
+
// that is already leaving. A claimed URI is one an open is keeping.
|
|
170
|
+
if (!opening.holdTaken || this.detached || this.openUris.has(uri)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
await server.closeModelDocument({ uri, clientId: this.clientId }).catch(() => {
|
|
174
|
+
// Hand it to `dispose` while there is still a `dispose` to come. Once
|
|
175
|
+
// that has run it has already drained `openUris` and will not read it
|
|
176
|
+
// again, so tracking would read as handled while nothing released it —
|
|
177
|
+
// there the host is the owner, being the one thing that outlives this
|
|
178
|
+
// session and can still reach the server.
|
|
179
|
+
if (this.disposed) {
|
|
180
|
+
this.host.orphanHold?.(uri, this.clientId);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.openUris.add(uri);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Close `args.uri`. The server unwatches implicitly, so this is the dual of
|
|
106
189
|
* {@link openDocument} and needs no separate unwatch.
|
|
107
190
|
*/
|
|
108
|
-
async closeDocument(
|
|
191
|
+
async closeDocument(args) {
|
|
109
192
|
const server = await this.connected();
|
|
110
|
-
await server.closeModelDocument({
|
|
193
|
+
await server.closeModelDocument({ ...args, clientId: this.clientId });
|
|
194
|
+
// Untracked only once the close has actually landed. Dropping it first
|
|
195
|
+
// gives a FAILED close the same effect as a successful one: the hold
|
|
196
|
+
// survives on the server and `dispose` no longer knows to retry it.
|
|
197
|
+
// A `dispose` racing this therefore closes the same URI twice, which the
|
|
198
|
+
// server answers as a no-op for a client that no longer holds it.
|
|
199
|
+
this.openUris.delete(args.uri);
|
|
200
|
+
}
|
|
201
|
+
/** Write `args.model` back as this session. */
|
|
202
|
+
async updateDocument(args) {
|
|
203
|
+
const server = await this.connected();
|
|
204
|
+
return server.updateModelDocument({ ...args, clientId: this.clientId });
|
|
205
|
+
}
|
|
206
|
+
/** Persist `args.model` to disk as this session. */
|
|
207
|
+
async saveDocument(args) {
|
|
208
|
+
const server = await this.connected();
|
|
209
|
+
return server.saveModelDocument({ ...args, clientId: this.clientId });
|
|
111
210
|
}
|
|
112
211
|
/**
|
|
113
|
-
* Whether `
|
|
212
|
+
* Whether `sourceClientId` identifies this session's own write.
|
|
114
213
|
*
|
|
115
214
|
* Every watcher needs this and the check is one comparison, so getting it
|
|
116
215
|
* wrong is cheap to do and expensive to find: an unfiltered echo looks
|
|
@@ -119,60 +218,46 @@ class DataSession {
|
|
|
119
218
|
isOwnEcho(sourceClientId) {
|
|
120
219
|
return sourceClientId === this.clientId;
|
|
121
220
|
}
|
|
122
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Release this session's holds and detach it from the connection.
|
|
223
|
+
* Idempotent, and leaves the connection usable by its other sessions.
|
|
224
|
+
*
|
|
225
|
+
* The closes are fired without being awaited, because a `Disposable` cannot
|
|
226
|
+
* be: a host disposing a widget has nowhere to put the promise. A close
|
|
227
|
+
* that fails is no worse than the leak this exists to prevent, so the
|
|
228
|
+
* rejection is swallowed rather than surfaced from a teardown.
|
|
229
|
+
*/
|
|
123
230
|
dispose() {
|
|
124
231
|
if (this.disposed) {
|
|
125
232
|
return;
|
|
126
233
|
}
|
|
127
234
|
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;
|
|
235
|
+
const uris = [...this.openUris];
|
|
236
|
+
this.openUris.clear();
|
|
237
|
+
this.host.releaseSession(this);
|
|
238
|
+
for (const uri of uris) {
|
|
239
|
+
void this.host
|
|
240
|
+
.connected()
|
|
241
|
+
.then(server => server.closeModelDocument({ uri, clientId: this.clientId }))
|
|
242
|
+
.catch(() => undefined);
|
|
163
243
|
}
|
|
164
244
|
}
|
|
165
245
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
246
|
+
* Come off the connection because it is going away.
|
|
247
|
+
*
|
|
248
|
+
* Sends no close, unlike {@link dispose}: the server releases every hold on
|
|
249
|
+
* a connection it sees close, and the close would travel over the very
|
|
250
|
+
* connection being disposed.
|
|
168
251
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.
|
|
172
|
-
|
|
173
|
-
|
|
252
|
+
detach() {
|
|
253
|
+
this.disposed = true;
|
|
254
|
+
this.detached = true;
|
|
255
|
+
this.openUris.clear();
|
|
256
|
+
}
|
|
257
|
+
assertLive() {
|
|
258
|
+
if (this.disposed) {
|
|
259
|
+
throw new Error('DataSession is disposed');
|
|
174
260
|
}
|
|
175
|
-
generation.connection.then(connection => connection.dispose()).catch(() => undefined);
|
|
176
261
|
}
|
|
177
262
|
}
|
|
178
263
|
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;;;AAwFlF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,WAAW;IAwBT;IACU;IArBtB,kFAAkF;IAC/D,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAChD;;;;;;;OAO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,CAAC;IAES,UAAU;QACjB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC9C,CAAC;IACJ,CAAC;CACH;AA/OD,kCA+OC"}
|
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.
|
|
@@ -25,15 +26,17 @@
|
|
|
25
26
|
* carries the entries.
|
|
26
27
|
*
|
|
27
28
|
* The Theia-specific mounting of the same contract lives in
|
|
28
|
-
* `@hydranium/data-client-theia
|
|
29
|
-
*
|
|
30
|
-
* is the Theia-bound counterpart of `DataEvents`.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
29
|
+
* `@hydranium/data-client-theia`, and is now only the TRANSPORT: its
|
|
30
|
+
* `ChannelDataPort` fills the `DataPort` seam over a Theia channel, and its
|
|
31
|
+
* `EmitterDataClient` is the Theia-bound counterpart of `DataEvents`.
|
|
32
|
+
* Everything above the port is here, so a Theia frontend and a browser page
|
|
33
|
+
* differ by which port they construct and nothing else.
|
|
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.
|
|
@@ -41,15 +42,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
42
|
* carries the entries.
|
|
42
43
|
*
|
|
43
44
|
* The Theia-specific mounting of the same contract lives in
|
|
44
|
-
* `@hydranium/data-client-theia
|
|
45
|
-
*
|
|
46
|
-
* is the Theia-bound counterpart of `DataEvents`.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
45
|
+
* `@hydranium/data-client-theia`, and is now only the TRANSPORT: its
|
|
46
|
+
* `ChannelDataPort` fills the `DataPort` seam over a Theia channel, and its
|
|
47
|
+
* `EmitterDataClient` is the Theia-bound counterpart of `DataEvents`.
|
|
48
|
+
* Everything above the port is here, so a Theia frontend and a browser page
|
|
49
|
+
* differ by which port they construct and nothing else.
|
|
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,MAA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,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,YAAY,GAAG,IAAI,wBAAO,EAAQ,CAAC;IACzC,MAAM,aAAa,GAAiB,EAAE,CAAC;IACvC,IAAI,SAAqC,CAAC;IAC1C,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,yEAAyE;IACzE,mDAAmD;IACnD,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,IAAI,kBAAkB,GAA2B,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtG,MAAM,eAAe,GAAG,GAAS,EAAE;QAChC,IAAI,QAAQ,EAAE,CAAC;YACZ,OAAO;QACV,CAAC;QACD,YAAY,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,CAAC,KAAK,IAAsB,EAAE;QACzC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