@hydranium/protocol 1.0.0-next.12 → 1.0.0-next.123
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 +114 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +143 -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 +235 -82
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +337 -108
- 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 +4 -4
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +10 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +100 -31
- 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/data/requests.d.ts +67 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/errors.d.ts +91 -12
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +127 -18
- 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 +29 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +55 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +188 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +161 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +44 -13
- 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/based-on.d.ts +57 -0
- package/lib/model-service/based-on.d.ts.map +1 -0
- package/lib/model-service/based-on.js +37 -0
- package/lib/model-service/based-on.js.map +1 -0
- package/lib/model-service/index.d.ts +1 -1
- package/lib/model-service/index.d.ts.map +1 -1
- package/lib/model-service/index.js +4 -5
- package/lib/model-service/index.js.map +1 -1
- package/lib/patch-merge.d.ts +28 -27
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +66 -22
- package/lib/patch-merge.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 +14 -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 +216 -0
- package/src/client/data-events.ts +24 -1
- package/src/client/data-port.ts +17 -23
- package/src/client/data-session.ts +447 -128
- 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 +10 -3
- package/src/data/data-server-protocol.ts +119 -31
- package/src/data/events.ts +74 -3
- package/src/data/requests.ts +71 -11
- package/src/errors.ts +139 -20
- package/src/index.ts +5 -0
- package/src/latency-collector.ts +8 -3
- package/src/messages/index.ts +36 -0
- package/src/messages/primitives.ts +271 -0
- package/src/model-server.ts +47 -18
- package/src/model-service/based-on.ts +63 -0
- package/src/model-service/index.ts +4 -5
- package/src/patch-merge.ts +90 -37
- 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 +21 -6
- package/lib/model-service/args.d.ts +0 -64
- package/lib/model-service/args.d.ts.map +0 -1
- package/lib/model-service/args.js +0 -11
- package/lib/model-service/args.js.map +0 -1
- package/src/model-service/args.ts +0 -67
|
@@ -8,78 +8,128 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.DataSession = void 0;
|
|
12
|
-
const
|
|
13
|
-
const rpc_1 = require("../rpc");
|
|
11
|
+
exports.DataSession = exports.DATA_SESSION_UNSAVED_LOST = exports.DATA_SESSION_RESTORE_FAILED = void 0;
|
|
12
|
+
const primitives_1 = require("../messages/primitives");
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
14
|
+
* A session could not re-open a document it had open after its connection
|
|
15
|
+
* dropped.
|
|
16
|
+
*/
|
|
17
|
+
exports.DATA_SESSION_RESTORE_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/data-session-restore-failed', 'Could not restore {uri} after reconnecting to the data server: {detail}');
|
|
18
|
+
/**
|
|
19
|
+
* A session re-opened documents after its connection dropped whose version had
|
|
20
|
+
* moved on since the session's last unsaved write to them: another client
|
|
21
|
+
* edited them, even while the session was still connected, the server reverted
|
|
22
|
+
* them to what is on disk, or the server restarted. The session's unsaved edits
|
|
23
|
+
* may be gone.
|
|
24
|
+
*/
|
|
25
|
+
exports.DATA_SESSION_UNSAVED_LOST = (0, primitives_1.defineMessage)('hydranium/protocol/data-session-unsaved-lost', 'Unsaved changes to {uris} may have been lost when the connection to the data server dropped.');
|
|
26
|
+
/**
|
|
27
|
+
* One participant on a data connection: a properties panel, a tree, a form
|
|
28
|
+
* editor. The client side of a server client session, registered over the
|
|
29
|
+
* wire under {@link clientId}.
|
|
30
|
+
*
|
|
31
|
+
* The session writes only what it has open: the server refuses its update or
|
|
32
|
+
* save of a document it has not opened with a `DocumentNotOpenError` code.
|
|
33
|
+
* Every call waits for the registration, so the first can be issued at once.
|
|
34
|
+
*
|
|
35
|
+
* Every document operation stamps {@link clientId} itself. A caller that
|
|
36
|
+
* passed its own could pass another participant's, and the server would
|
|
37
|
+
* attribute the write and close the document accordingly.
|
|
18
38
|
*
|
|
19
|
-
*
|
|
39
|
+
* {@link closeDocument} and {@link dispose} first wait, up to
|
|
40
|
+
* {@link settleBeforeCloseMs}, for this session's calls still in flight on the
|
|
41
|
+
* URI, or on any URI for `dispose`: a save sent just before its close would
|
|
42
|
+
* otherwise reach the server after it, and fail as not open.
|
|
20
43
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
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.
|
|
44
|
+
* After the connection drops, the session registers again under the same id,
|
|
45
|
+
* re-opens and re-watches what it had open, and reports the documents whose
|
|
46
|
+
* unsaved edits did not survive; see {@link restore}. The connection does this at
|
|
47
|
+
* once for a session with documents open, and any session's next call does it
|
|
48
|
+
* too.
|
|
30
49
|
*
|
|
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.
|
|
50
|
+
* Generic over the transfer root so this file names no grammar.
|
|
35
51
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
52
|
+
* `TServer` is bound to a server answering with ITS OWN diagnostic shape, read
|
|
53
|
+
* back off the parameter being bound. Simplifying that to
|
|
54
|
+
* `DataServerProtocol<TTransfer>` compiles and costs the wrappers their
|
|
55
|
+
* return type: every call through `TServer` would resolve against that looser
|
|
56
|
+
* bound, so an adopter's diagnostics would come back as the framework's and
|
|
57
|
+
* the document would have to be cast on the way out.
|
|
39
58
|
*/
|
|
40
59
|
class DataSession {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
|
|
60
|
+
clientId;
|
|
61
|
+
host;
|
|
62
|
+
label;
|
|
63
|
+
/**
|
|
64
|
+
* How long {@link closeDocument} and {@link dispose} wait for this session's
|
|
65
|
+
* calls in flight before closing anyway. Long, because the wait only runs
|
|
66
|
+
* out when a call hangs, and a close sent while a save is still running
|
|
67
|
+
* fails that save.
|
|
68
|
+
*/
|
|
69
|
+
settleBeforeCloseMs = 10_000;
|
|
70
|
+
/** URIs this session has open, re-opened after a reconnect. */
|
|
71
|
+
openUris = new Set();
|
|
72
|
+
/**
|
|
73
|
+
* Per URI, how many opens of it this session has under way. Such a URI
|
|
74
|
+
* counts as open for {@link withOpenDocument}, which would otherwise close
|
|
75
|
+
* it under the open that is still being made.
|
|
76
|
+
*/
|
|
77
|
+
openingUris = new Map();
|
|
78
|
+
/**
|
|
79
|
+
* Per URI written since its last save, the version the server answered this
|
|
80
|
+
* session's last write with; see {@link restore}.
|
|
81
|
+
*/
|
|
82
|
+
unsavedWrites = new Map();
|
|
83
|
+
/** Per URI, this session's calls still in flight on it, which a close waits for. */
|
|
84
|
+
inFlight = new Map();
|
|
85
|
+
/**
|
|
86
|
+
* Sent with every registration, so the server lets this session register
|
|
87
|
+
* its id again while the dropped connection's session is still live there:
|
|
88
|
+
* a server that has not yet noticed the drop would otherwise refuse the id
|
|
89
|
+
* as a duplicate until it does.
|
|
90
|
+
*/
|
|
91
|
+
resumeToken = globalThis.crypto.randomUUID();
|
|
92
|
+
/** The proxy the session is registered on; another one means the connection was replaced. */
|
|
93
|
+
registeredOn;
|
|
94
|
+
registration;
|
|
46
95
|
disposed = false;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Disposed through {@link detach} rather than {@link dispose}, so nothing may
|
|
98
|
+
* be sent. Folding it into {@link disposed} would send the session's close
|
|
99
|
+
* over a connection that is going away.
|
|
100
|
+
*/
|
|
101
|
+
detached = false;
|
|
102
|
+
constructor(clientId, host, label) {
|
|
103
|
+
this.clientId = clientId;
|
|
104
|
+
this.host = host;
|
|
105
|
+
this.label = label;
|
|
57
106
|
}
|
|
58
107
|
/**
|
|
59
|
-
* The connected, READY server proxy
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
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.
|
|
108
|
+
* The connected, READY server proxy once this session is registered on it,
|
|
109
|
+
* for protocol methods this session does not wrap. The proxy stamps
|
|
110
|
+
* nothing: pass this session's {@link clientId} to any method that carries
|
|
111
|
+
* one.
|
|
68
112
|
*/
|
|
69
113
|
async connected() {
|
|
70
|
-
|
|
71
|
-
|
|
114
|
+
// `async` so a disposed session REJECTS rather than throwing
|
|
115
|
+
// synchronously: the connection's own `connected` rejects, and a caller
|
|
116
|
+
// reaching for `.catch` on one of them would not catch the other.
|
|
117
|
+
this.assertLive();
|
|
118
|
+
const server = await this.host.connected();
|
|
119
|
+
// Again after the wait: a session disposed meanwhile must not register,
|
|
120
|
+
// since its dispose found nothing registered to end.
|
|
121
|
+
this.assertLive();
|
|
122
|
+
if (this.registeredOn !== server) {
|
|
123
|
+
const reconnected = this.registeredOn !== undefined;
|
|
124
|
+
this.registeredOn = server;
|
|
125
|
+
this.registration = this.register(server, reconnected);
|
|
72
126
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
generation.ready = this.awaitReady(generation);
|
|
76
|
-
}
|
|
77
|
-
await generation.ready;
|
|
78
|
-
return generation.server;
|
|
127
|
+
await this.registration;
|
|
128
|
+
return server;
|
|
79
129
|
}
|
|
80
130
|
/**
|
|
81
|
-
* Open `uri` for editing and start watching it, in that order,
|
|
82
|
-
* the opened snapshot.
|
|
131
|
+
* Open `args.uri` for editing and start watching it, in that order,
|
|
132
|
+
* returning the opened snapshot.
|
|
83
133
|
*
|
|
84
134
|
* **The order is the whole reason this method exists.**
|
|
85
135
|
* `watchModelDocument` baselines its dedup fingerprint from the *current*
|
|
@@ -87,30 +137,113 @@ class DataSession {
|
|
|
87
137
|
* baseline, and the first phase event after the open arrives as a spurious
|
|
88
138
|
* `'changed'` — which a widget that resets its in-memory root to the server
|
|
89
139
|
* view misreads as a concurrent third-party write, losing whatever the user
|
|
90
|
-
* had typed.
|
|
91
|
-
* here rather than documented and re-derived.
|
|
140
|
+
* had typed.
|
|
92
141
|
*
|
|
93
142
|
* Note that the returned snapshot's empty `diagnostics` does not mean
|
|
94
143
|
* valid: `open` settles at the integrity landmark, not at validation.
|
|
95
144
|
* Validity arrives asynchronously on `onDocumentUpdated`, or synchronously
|
|
96
145
|
* from `getModelDocument({ includeDiagnostics: true })`.
|
|
97
146
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
147
|
+
openDocument(args) {
|
|
148
|
+
return this.trackOpen(args.uri, async () => {
|
|
149
|
+
const server = await this.connected();
|
|
150
|
+
return this.watchOpened(server, args.uri, await server.openModelDocument({ ...args, clientId: this.clientId }));
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Create a document that exists nowhere yet, open and watched for this
|
|
155
|
+
* session; it reaches disk with the first {@link saveDocument}. The server
|
|
156
|
+
* refuses a URI that exists on disk or that any client has open.
|
|
157
|
+
*/
|
|
158
|
+
createDocument(args) {
|
|
159
|
+
return this.trackOpen(args.uri, async () => {
|
|
160
|
+
const server = await this.connected();
|
|
161
|
+
return this.watchOpened(server, args.uri, await server.createModelDocument({ ...args, clientId: this.clientId }));
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Watch a document this session just opened, and record it as open. A
|
|
166
|
+
* failed watch closes it again: the caller sees a failed open and so would
|
|
167
|
+
* never close it.
|
|
168
|
+
*/
|
|
169
|
+
async watchOpened(server, uri, document) {
|
|
170
|
+
try {
|
|
171
|
+
await server.watchModelDocument({ uri, clientId: this.clientId });
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
await server.closeModelDocument({ uri, clientId: this.clientId }).catch(() => undefined);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
this.openUris.add(uri);
|
|
102
178
|
return document;
|
|
103
179
|
}
|
|
104
180
|
/**
|
|
105
|
-
* Close `uri
|
|
106
|
-
* {@link
|
|
181
|
+
* Close `args.uri`, once this session's calls on it have settled or
|
|
182
|
+
* {@link settleBeforeCloseMs} has passed. The server unwatches implicitly,
|
|
183
|
+
* so this is the dual of {@link openDocument} and needs no separate unwatch.
|
|
107
184
|
*/
|
|
108
|
-
async closeDocument(
|
|
185
|
+
async closeDocument(args) {
|
|
186
|
+
this.assertLive();
|
|
187
|
+
await this.settle(this.inFlight.get(args.uri));
|
|
188
|
+
// Forgotten before the close is sent, so a reconnect in between does not
|
|
189
|
+
// re-open a document the caller has closed; after the wait, so an open
|
|
190
|
+
// of it that was still in flight does not record it again.
|
|
191
|
+
this.openUris.delete(args.uri);
|
|
192
|
+
this.unsavedWrites.delete(args.uri);
|
|
109
193
|
const server = await this.connected();
|
|
110
|
-
await server.closeModelDocument({
|
|
194
|
+
await server.closeModelDocument({ ...args, clientId: this.clientId });
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Open `args.uri`, run `fn` with the opened snapshot, and close it once
|
|
198
|
+
* `fn` settles, whether it returned or threw. A URI this session already
|
|
199
|
+
* had open, or is still opening through another call, stays open: the close
|
|
200
|
+
* undoes only the open this call made.
|
|
201
|
+
*/
|
|
202
|
+
async withOpenDocument(args, fn) {
|
|
203
|
+
const alreadyOpen = this.openUris.has(args.uri) || this.openingUris.has(args.uri);
|
|
204
|
+
const document = await this.openDocument(args);
|
|
205
|
+
try {
|
|
206
|
+
return await fn(document);
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
if (!alreadyOpen && !this.disposed) {
|
|
210
|
+
await this.closeDocument({ uri: args.uri });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Write `args.model` back as this session. The session must have `args.uri` open. */
|
|
215
|
+
updateDocument(args) {
|
|
216
|
+
return this.track([args.uri], async () => {
|
|
217
|
+
const server = await this.connected();
|
|
218
|
+
const document = await server.updateModelDocument({ ...args, clientId: this.clientId });
|
|
219
|
+
this.unsavedWrites.set(args.uri, document.version);
|
|
220
|
+
return document;
|
|
221
|
+
});
|
|
111
222
|
}
|
|
112
223
|
/**
|
|
113
|
-
*
|
|
224
|
+
* Write several documents this session has open, all or none: the server
|
|
225
|
+
* refuses the whole set, before any text applies, when one is stale or not
|
|
226
|
+
* open. Resolves to the documents in the order given.
|
|
227
|
+
*/
|
|
228
|
+
updateDocuments(args) {
|
|
229
|
+
return this.track(args.updates.map(update => update.uri), async () => {
|
|
230
|
+
const server = await this.connected();
|
|
231
|
+
const documents = await server.updateModelDocuments({ ...args, clientId: this.clientId });
|
|
232
|
+
args.updates.forEach((update, i) => this.unsavedWrites.set(update.uri, documents[i].version));
|
|
233
|
+
return documents;
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/** Persist `args.model` to disk as this session. The session must have `args.uri` open. */
|
|
237
|
+
saveDocument(args) {
|
|
238
|
+
return this.track([args.uri], async () => {
|
|
239
|
+
const server = await this.connected();
|
|
240
|
+
const document = await server.saveModelDocument({ ...args, clientId: this.clientId });
|
|
241
|
+
this.unsavedWrites.delete(args.uri);
|
|
242
|
+
return document;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Whether `sourceClientId` identifies this session's own write.
|
|
114
247
|
*
|
|
115
248
|
* Every watcher needs this and the check is one comparison, so getting it
|
|
116
249
|
* wrong is cheap to do and expensive to find: an unfiltered echo looks
|
|
@@ -119,60 +252,156 @@ class DataSession {
|
|
|
119
252
|
isOwnEcho(sourceClientId) {
|
|
120
253
|
return sourceClientId === this.clientId;
|
|
121
254
|
}
|
|
122
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* End the session: detach it from the connection at once, and once its
|
|
257
|
+
* calls in flight have settled or {@link settleBeforeCloseMs} has passed,
|
|
258
|
+
* end it on the server, which closes everything it has open. Idempotent,
|
|
259
|
+
* and leaves the connection usable by its other sessions.
|
|
260
|
+
*
|
|
261
|
+
* Every later call rejects. The server close is not awaited, because a
|
|
262
|
+
* `Disposable` cannot be; a close that fails leaves the session to the
|
|
263
|
+
* server's connection-close cleanup.
|
|
264
|
+
*/
|
|
123
265
|
dispose() {
|
|
124
266
|
if (this.disposed) {
|
|
125
267
|
return;
|
|
126
268
|
}
|
|
127
269
|
this.disposed = true;
|
|
128
|
-
this.
|
|
129
|
-
this.
|
|
270
|
+
this.host.releaseSession(this);
|
|
271
|
+
const pending = [...this.inFlight.values()].flatMap(calls => [...calls]);
|
|
272
|
+
void (async () => {
|
|
273
|
+
await this.settle(pending);
|
|
274
|
+
await this.registration;
|
|
275
|
+
// The proxy the session registered on, never a fresh connection: a
|
|
276
|
+
// connection that dropped already ended the session on the server.
|
|
277
|
+
if (!this.detached && this.registeredOn) {
|
|
278
|
+
await this.registeredOn.closeSession({ clientId: this.clientId });
|
|
279
|
+
}
|
|
280
|
+
})().catch(() => undefined);
|
|
130
281
|
}
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
localTarget: this.client,
|
|
144
|
-
localMethods: data_1.DATA_CLIENT_PROTOCOL_METHODS
|
|
145
|
-
});
|
|
146
|
-
this.generation = { connection, server };
|
|
147
|
-
return this.generation;
|
|
282
|
+
/**
|
|
283
|
+
* Come off the connection because it is going away.
|
|
284
|
+
*
|
|
285
|
+
* Sends nothing, unlike {@link dispose}: the server ends every session on a
|
|
286
|
+
* connection it sees close, and the close would travel over the very
|
|
287
|
+
* connection being disposed.
|
|
288
|
+
*/
|
|
289
|
+
detach() {
|
|
290
|
+
this.disposed = true;
|
|
291
|
+
this.detached = true;
|
|
292
|
+
this.openUris.clear();
|
|
293
|
+
this.unsavedWrites.clear();
|
|
148
294
|
}
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Register again and restore now, after the connection dropped, instead of
|
|
297
|
+
* on the next call. A no-op for a session with nothing open, which the next
|
|
298
|
+
* call restores anyway. A failure is left to that next call, which meets it
|
|
299
|
+
* again.
|
|
300
|
+
*/
|
|
301
|
+
reconnect() {
|
|
302
|
+
if (!this.disposed && this.openUris.size > 0) {
|
|
303
|
+
this.connected().catch(() => undefined);
|
|
154
304
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Register on `server`, and after a reconnect restore what the ended session
|
|
308
|
+
* had. Calls issued meanwhile wait for this.
|
|
309
|
+
*/
|
|
310
|
+
async register(server, reconnected) {
|
|
311
|
+
await server.createSession({ clientId: this.clientId, label: this.label, resumeToken: this.resumeToken });
|
|
312
|
+
if (reconnected) {
|
|
313
|
+
await this.restore(server);
|
|
163
314
|
}
|
|
164
315
|
}
|
|
165
316
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
317
|
+
* Re-open and re-watch every document the session had open, and tell the
|
|
318
|
+
* host which of them lost what the session wrote since their last save.
|
|
319
|
+
*
|
|
320
|
+
* The unsaved text is not sent again. A document whose re-opened version is
|
|
321
|
+
* the one the session's last write was answered with still holds that
|
|
322
|
+
* write. Any other version means the text changed after that write:
|
|
323
|
+
* another client edited it, even while the session was still connected;
|
|
324
|
+
* the server reverted it to disk when the session's open closed as the
|
|
325
|
+
* document's last; or the server restarted and numbers versions afresh.
|
|
326
|
+
* Re-sending based on the write's own version then always conflicts, and
|
|
327
|
+
* based on the re-opened version it would overwrite whatever changed, so
|
|
328
|
+
* neither is done.
|
|
329
|
+
*
|
|
330
|
+
* No caller is waiting, so both outcomes go through the host: one report
|
|
331
|
+
* naming every document whose unsaved text is gone, whose record is then
|
|
332
|
+
* dropped, and one per document that could not be re-opened, which is
|
|
333
|
+
* forgotten.
|
|
168
334
|
*/
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
this.
|
|
172
|
-
|
|
335
|
+
async restore(server) {
|
|
336
|
+
const lost = [];
|
|
337
|
+
for (const uri of [...this.openUris]) {
|
|
338
|
+
try {
|
|
339
|
+
const document = await server.openModelDocument({ uri, clientId: this.clientId });
|
|
340
|
+
await server.watchModelDocument({ uri, clientId: this.clientId });
|
|
341
|
+
const written = this.unsavedWrites.get(uri);
|
|
342
|
+
if (written !== undefined && written !== document.version) {
|
|
343
|
+
lost.push(uri);
|
|
344
|
+
this.unsavedWrites.delete(uri);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
this.openUris.delete(uri);
|
|
349
|
+
this.unsavedWrites.delete(uri);
|
|
350
|
+
this.host.reportError?.(error, (0, primitives_1.resolve)(exports.DATA_SESSION_RESTORE_FAILED, { uri, detail: (0, primitives_1.describeError)(error) }));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (lost.length > 0) {
|
|
354
|
+
const reported = (0, primitives_1.resolve)(exports.DATA_SESSION_UNSAVED_LOST, { uris: lost.join(', ') });
|
|
355
|
+
this.host.reportError?.(new Error(reported.text), reported);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/** Run `call`, counted as in flight on each of `uris` until it settles. */
|
|
359
|
+
track(uris, call) {
|
|
360
|
+
const running = call();
|
|
361
|
+
for (const uri of uris) {
|
|
362
|
+
this.inFlight.set(uri, (this.inFlight.get(uri) ?? new Set()).add(running));
|
|
363
|
+
}
|
|
364
|
+
const done = () => uris.forEach(uri => this.inFlight.get(uri)?.delete(running));
|
|
365
|
+
running.then(done, done);
|
|
366
|
+
return running;
|
|
367
|
+
}
|
|
368
|
+
/** {@link track} an open of `uri`, counted in {@link openingUris} until it settles. */
|
|
369
|
+
trackOpen(uri, call) {
|
|
370
|
+
this.openingUris.set(uri, (this.openingUris.get(uri) ?? 0) + 1);
|
|
371
|
+
const done = () => {
|
|
372
|
+
const remaining = (this.openingUris.get(uri) ?? 1) - 1;
|
|
373
|
+
if (remaining > 0) {
|
|
374
|
+
this.openingUris.set(uri, remaining);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.openingUris.delete(uri);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
const running = this.track([uri], call);
|
|
381
|
+
running.then(done, done);
|
|
382
|
+
return running;
|
|
383
|
+
}
|
|
384
|
+
/** Wait until `calls` have settled, or {@link settleBeforeCloseMs} has passed. */
|
|
385
|
+
async settle(calls) {
|
|
386
|
+
const pending = [...(calls ?? [])];
|
|
387
|
+
if (pending.length === 0) {
|
|
173
388
|
return;
|
|
174
389
|
}
|
|
175
|
-
|
|
390
|
+
let timer;
|
|
391
|
+
const bound = new Promise(resolveBound => {
|
|
392
|
+
timer = setTimeout(resolveBound, this.settleBeforeCloseMs);
|
|
393
|
+
});
|
|
394
|
+
try {
|
|
395
|
+
await Promise.race([Promise.allSettled(pending), bound]);
|
|
396
|
+
}
|
|
397
|
+
finally {
|
|
398
|
+
clearTimeout(timer);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
assertLive() {
|
|
402
|
+
if (this.disposed) {
|
|
403
|
+
throw new Error('DataSession is disposed');
|
|
404
|
+
}
|
|
176
405
|
}
|
|
177
406
|
}
|
|
178
407
|
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;;;AAIlF,uDAAqG;AAOrG;;;GAGG;AACU,QAAA,2BAA2B,GAAG,IAAA,0BAAa,EACrD,gDAAgD,EAChD,yEAAyE,CAC3E,CAAC;AAEF;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,IAAA,0BAAa,EACnD,8CAA8C,EAC9C,8FAA8F,CAChG,CAAC;AAqFF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAa,WAAW;IA6CT;IACU;IACV;IA3CZ;;;;;OAKG;IACgB,mBAAmB,GAAW,MAAM,CAAC;IACxD,+DAA+D;IAC5C,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAChD;;;;OAIG;IACgB,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3D;;;OAGG;IACgB,aAAa,GAAG,IAAI,GAAG,EAA2B,CAAC;IACtE,oFAAoF;IACjE,QAAQ,GAAG,IAAI,GAAG,EAAiC,CAAC;IACvE;;;;;OAKG;IACgB,WAAW,GAAW,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACxE,6FAA6F;IACnF,YAAY,CAAqB;IACjC,YAAY,CAAiB;IAC7B,QAAQ,GAAG,KAAK,CAAC;IAC3B;;;;OAIG;IACO,QAAQ,GAAG,KAAK,CAAC;IAE3B,YACY,QAAgB,EACN,IAAyC,EACnD,KAAa;QAFb,aAAQ,GAAR,QAAQ,CAAQ;QACN,SAAI,GAAJ,IAAI,CAAqC;QACnD,UAAK,GAAL,KAAK,CAAQ;IACtB,CAAC;IAEJ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AC,CAAC;QAC9C,CAAC;IACJ,CAAC;CACH;AApXD,kCAoXC"}
|
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"}
|