@hydranium/protocol 1.0.0-next.23 → 1.0.0-next.230
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 +40 -3
- package/lib/abstract-logger.d.ts +5 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +7 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +236 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +404 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +13 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +21 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +27 -22
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +473 -81
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +743 -108
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +14 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +14 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +9 -3
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +11 -5
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/post-message-transport.d.ts +64 -3
- package/lib/client/post-message-transport.d.ts.map +1 -1
- package/lib/client/post-message-transport.js +175 -1
- package/lib/client/post-message-transport.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +157 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +214 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +45 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +48 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/clock.d.ts +38 -0
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- package/lib/console-logger.d.ts +23 -0
- package/lib/console-logger.d.ts.map +1 -0
- package/lib/console-logger.js +39 -0
- package/lib/console-logger.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 +12 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +132 -41
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +117 -21
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +69 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +187 -29
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +270 -29
- package/lib/errors.js.map +1 -1
- package/lib/glsp-request-model-args.d.ts +16 -0
- package/lib/glsp-request-model-args.d.ts.map +1 -0
- package/lib/glsp-request-model-args.js +19 -0
- package/lib/glsp-request-model-args.js.map +1 -0
- package/lib/glsp-save-model-actions.d.ts +50 -0
- package/lib/glsp-save-model-actions.d.ts.map +1 -0
- package/lib/glsp-save-model-actions.js +28 -0
- package/lib/glsp-save-model-actions.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -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/logger.d.ts +22 -1
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +31 -3
- package/lib/logger.js.map +1 -1
- package/lib/messages/index.d.ts +30 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +62 -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 +60 -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/base-version.d.ts +64 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/base-version.js +43 -0
- package/lib/model-service/base-version.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/model-service/reference-candidate.d.ts +5 -3
- package/lib/model-service/reference-candidate.d.ts.map +1 -1
- package/lib/{model-service/args.js → node/index.d.ts} +2 -3
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +29 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/process-memory.d.ts +66 -0
- package/lib/node/process-memory.d.ts.map +1 -0
- package/lib/node/process-memory.js +291 -0
- package/lib/node/process-memory.js.map +1 -0
- package/lib/noop-logger.d.ts.map +1 -1
- package/lib/noop-logger.js.map +1 -1
- package/lib/observable-value.js.map +1 -1
- package/lib/patch-merge.d.ts +35 -32
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +67 -23
- 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/random-uuid.d.ts +14 -0
- package/lib/random-uuid.d.ts.map +1 -0
- package/lib/random-uuid.js +24 -0
- package/lib/random-uuid.js.map +1 -0
- package/lib/reconcile-write.d.ts +65 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +67 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/bind-rpc-methods.d.ts +33 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +32 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +10 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +12 -2
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/rpc/index.d.ts +1 -0
- package/lib/rpc/index.d.ts.map +1 -1
- package/lib/rpc/index.js +1 -0
- package/lib/rpc/index.js.map +1 -1
- package/lib/rpc/send-by-method-name.d.ts +76 -0
- package/lib/rpc/send-by-method-name.d.ts.map +1 -0
- package/lib/rpc/send-by-method-name.js +120 -0
- package/lib/rpc/send-by-method-name.js.map +1 -0
- package/lib/rpc/wire-prefix.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 +42 -15
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +58 -10
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +9 -1
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +54 -45
- package/lib/testing/fake-clock.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 +5 -2
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/node/duplex-connection.d.ts.map +1 -1
- package/lib/testing/node/duplex-connection.js +3 -2
- package/lib/testing/node/duplex-connection.js.map +1 -1
- package/lib/testing/node/duplex-stream.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +2 -2
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/message-port-pair.d.ts +25 -0
- package/lib/testing/node/message-port-pair.d.ts.map +1 -0
- package/lib/testing/node/message-port-pair.js +26 -0
- package/lib/testing/node/message-port-pair.js.map +1 -0
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.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 +70 -32
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +17 -9
- package/lib/transfer-document.js.map +1 -1
- package/lib/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -0
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -0
- package/lib/util.js.map +1 -1
- package/package.json +29 -37
- package/src/abstract-logger.ts +8 -0
- package/src/client/data-connection.ts +502 -0
- package/src/client/data-events.ts +33 -1
- package/src/client/data-port.ts +29 -23
- package/src/client/data-session.ts +951 -126
- package/src/client/index.ts +14 -9
- package/src/client/message-relay.ts +29 -7
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +281 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +56 -0
- package/src/console-logger.ts +39 -0
- package/src/data/data-protocol-methods.ts +13 -4
- package/src/data/data-server-protocol.ts +157 -41
- package/src/data/events.ts +123 -21
- package/src/data/requests.ts +74 -11
- package/src/errors.ts +322 -36
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +10 -0
- package/src/latency-collector.ts +8 -3
- package/src/logger.ts +28 -2
- package/src/messages/index.ts +37 -0
- package/src/messages/primitives.ts +271 -0
- package/src/model-server.ts +63 -18
- package/src/model-service/base-version.ts +72 -0
- package/src/model-service/index.ts +4 -5
- package/src/model-service/reference-candidate.ts +5 -3
- package/src/node/index.ts +14 -0
- package/src/node/process-memory.ts +299 -0
- package/src/patch-merge.ts +97 -42
- package/src/profile-session.ts +9 -4
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +124 -0
- package/src/rpc/README.md +4 -5
- package/src/rpc/bind-rpc-methods.ts +59 -4
- package/src/rpc/create-rpc-proxy.ts +20 -2
- package/src/rpc/index.ts +1 -0
- package/src/rpc/send-by-method-name.ts +140 -0
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +145 -25
- package/src/testing/fake-clock.ts +62 -47
- package/src/testing/index.ts +5 -2
- package/src/testing/node/duplex-connection.ts +3 -2
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/transfer-diagnostic.ts +40 -0
- package/src/transfer-document.ts +87 -34
- package/src/util.ts +33 -0
- 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.map +0 -1
- package/src/model-service/args.ts +0 -67
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the MIT License which is available in the project root.
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
********************************************************************************/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.DataConnectionWithEvents = exports.DataConnection = exports.DATA_CONNECTION_SESSION_RESTORE_FAILED = exports.DATA_CONNECTION_WATCH_RESTORE_FAILED = void 0;
|
|
12
|
+
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
13
|
+
const client_ids_1 = require("../client-ids");
|
|
14
|
+
const data_1 = require("../data");
|
|
15
|
+
const errors_1 = require("../errors");
|
|
16
|
+
const primitives_1 = require("../messages/primitives");
|
|
17
|
+
const noop_logger_1 = require("../noop-logger");
|
|
18
|
+
const random_uuid_1 = require("../random-uuid");
|
|
19
|
+
const data_events_1 = require("./data-events");
|
|
20
|
+
const data_session_1 = require("./data-session");
|
|
21
|
+
const rpc_connection_1 = require("./rpc-connection");
|
|
22
|
+
/**
|
|
23
|
+
* A watch {@link DataConnection.watchDocument} keeps could not be sent again to
|
|
24
|
+
* a connection that became ready after a drop; the next one sends it again.
|
|
25
|
+
*/
|
|
26
|
+
exports.DATA_CONNECTION_WATCH_RESTORE_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/data-connection-watch-restore-failed', 'Could not watch {uri} again after reconnecting to the data server: {detail}');
|
|
27
|
+
/**
|
|
28
|
+
* A session's restore threw when its connection came back; the connection
|
|
29
|
+
* went on restoring the others.
|
|
30
|
+
*/
|
|
31
|
+
exports.DATA_CONNECTION_SESSION_RESTORE_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/data-connection-session-restore-failed', 'Could not restore a session after reconnecting to the data server: {detail}');
|
|
32
|
+
/**
|
|
33
|
+
* A {@link RpcConnection} to the data head, carrying as many participants as
|
|
34
|
+
* the host has interested parties.
|
|
35
|
+
*
|
|
36
|
+
* Document operations live on the participants rather than here: they carry a
|
|
37
|
+
* `clientId`, which identifies a participant rather than a wire, and the server
|
|
38
|
+
* keys its opens and watches per `(uri, clientId)`. Two parties sharing one
|
|
39
|
+
* identity cannot tell each other's writes from their own echoes.
|
|
40
|
+
* {@link DataConnection.watchDocument} is the exception: it acts as no
|
|
41
|
+
* participant, under an id no session holds, and opens or writes nothing.
|
|
42
|
+
*
|
|
43
|
+
* Generic over the transfer root so this file names no grammar. An adopter
|
|
44
|
+
* binds the concrete root (or the union of them, for a multi-grammar head) at
|
|
45
|
+
* its own edge.
|
|
46
|
+
*/
|
|
47
|
+
class DataConnection extends rpc_connection_1.RpcConnection {
|
|
48
|
+
sessions = new Set();
|
|
49
|
+
sessionFactory;
|
|
50
|
+
createSessionEmitter = new vscode_jsonrpc_1.Emitter();
|
|
51
|
+
/**
|
|
52
|
+
* Fires with each session {@link createSession} starts, before it returns,
|
|
53
|
+
* so a listener sees every session a caller can. A session started before
|
|
54
|
+
* the listener subscribed is in {@link liveSessions}.
|
|
55
|
+
*/
|
|
56
|
+
onDidCreateSession = this.createSessionEmitter.event;
|
|
57
|
+
/**
|
|
58
|
+
* Per URI, the `dirty` the client was last told, whether a session of this
|
|
59
|
+
* connection has it open or a watch follows it. A session's open or close
|
|
60
|
+
* of the URI forgets it; disposing a watch does not, since a watch knows
|
|
61
|
+
* only the caller's spelling of the URI, not the server's key. A
|
|
62
|
+
* session's restore and a watch sent again after a reconnect tell the
|
|
63
|
+
* client their answer where it differs, a forgotten URI included; see
|
|
64
|
+
* {@link restoreDirty}.
|
|
65
|
+
*/
|
|
66
|
+
dirtyStates = new Map();
|
|
67
|
+
/** Backs each session's {@link DataSessionHost.onDidChangeDirty}. */
|
|
68
|
+
dirtyChangedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
69
|
+
/** Backs each session's {@link DataSessionHost.onDidUpdateDocument}. */
|
|
70
|
+
documentUpdatedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
71
|
+
/**
|
|
72
|
+
* Per id {@link watchDocument} watches under, the URI it watches, which
|
|
73
|
+
* {@link generationReady} sends again to every later generation until the
|
|
74
|
+
* watch's handle is disposed.
|
|
75
|
+
*/
|
|
76
|
+
watches = new Map();
|
|
77
|
+
/** The port's logger, or one that logs nothing. */
|
|
78
|
+
logger;
|
|
79
|
+
/** Backs {@link onDidReconnect}. */
|
|
80
|
+
reconnectEmitter = new vscode_jsonrpc_1.Emitter();
|
|
81
|
+
/**
|
|
82
|
+
* Fires on every reconnect: once a connection becomes ready after an
|
|
83
|
+
* earlier one was, and its watches have been sent. The server sends no
|
|
84
|
+
* event for a change made while the connection was down, so a watcher reads
|
|
85
|
+
* its document again on this; a read it sends now reaches the server after
|
|
86
|
+
* its watch.
|
|
87
|
+
*/
|
|
88
|
+
onDidReconnect = this.reconnectEmitter.event;
|
|
89
|
+
/** Whether a generation was ready before, which makes the next one a reconnect. */
|
|
90
|
+
readyBefore = false;
|
|
91
|
+
constructor(port, client, ...rest) {
|
|
92
|
+
const [options = {}] = rest;
|
|
93
|
+
super(port, client, {
|
|
94
|
+
methodNamespace: options.methodNamespace ?? data_1.DATA_SERVER_WIRE_PREFIX,
|
|
95
|
+
// The default is reachable only where `TClient` satisfies
|
|
96
|
+
// `DataClientProtocol`, which the constructor's conditional enforces;
|
|
97
|
+
// the compiler cannot carry that through to the generic parameter.
|
|
98
|
+
clientMethods: options.clientMethods ?? data_1.DATA_CLIENT_PROTOCOL_METHODS,
|
|
99
|
+
lifecycle: options
|
|
100
|
+
});
|
|
101
|
+
this.sessionFactory =
|
|
102
|
+
options.sessionFactory ?? ((clientId, host, label) => new data_session_1.DataSession(clientId, host, label));
|
|
103
|
+
this.logger = (port.logger ?? new noop_logger_1.NoopLogger()).for('DataConnection');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The sessions of this connection that have not ended, in the order they
|
|
107
|
+
* started. A session is listed until its `onDidDispose` fires, or until
|
|
108
|
+
* {@link dispose} clears the list.
|
|
109
|
+
*/
|
|
110
|
+
get liveSessions() {
|
|
111
|
+
return [...this.sessions];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Start a participant on this connection, registered with the server under a
|
|
115
|
+
* fresh id, `label` plus `#` plus a random UUID, or under `clientId` when
|
|
116
|
+
* given. Pass a `label` naming the participant; without one it is
|
|
117
|
+
* `session`. Synchronous: the registration is sent at once, and the
|
|
118
|
+
* session's calls wait for it. The server refuses an id live anywhere in
|
|
119
|
+
* its process, and every call of that session then rejects with an error
|
|
120
|
+
* `isDuplicateClientIdError` recognises; an id the server reserves beyond
|
|
121
|
+
* {@link FRAMEWORK_CLIENT_IDS}, such as the integrity author, with one
|
|
122
|
+
* `isReservedClientIdError` recognises. Only the code crosses the wire, so
|
|
123
|
+
* test with those guards rather than `instanceof`.
|
|
124
|
+
*
|
|
125
|
+
* Throws a {@link ReservedClientIdError} for an id in
|
|
126
|
+
* {@link FRAMEWORK_CLIENT_IDS} — those are authors the SERVER emits rather
|
|
127
|
+
* than participants, so a session holding one would read the framework's
|
|
128
|
+
* own broadcasts as its own echoes and drop them — and a
|
|
129
|
+
* {@link DuplicateClientIdError} for an id a live session on this
|
|
130
|
+
* connection already holds.
|
|
131
|
+
*/
|
|
132
|
+
createSession(label = 'session', clientId) {
|
|
133
|
+
this.assertLive();
|
|
134
|
+
const id = clientId ?? `${label}#${(0, random_uuid_1.randomUuid)()}`;
|
|
135
|
+
if (client_ids_1.FRAMEWORK_CLIENT_IDS.includes(id)) {
|
|
136
|
+
throw new errors_1.ReservedClientIdError(id);
|
|
137
|
+
}
|
|
138
|
+
if ([...this.sessions].some(session => session.clientId === id)) {
|
|
139
|
+
throw new errors_1.DuplicateClientIdError(id);
|
|
140
|
+
}
|
|
141
|
+
const session = this.sessionFactory(id, {
|
|
142
|
+
connected: () => this.connected(),
|
|
143
|
+
reportError: (error, reported) => this.reportError(error, reported),
|
|
144
|
+
restoreDirty: event => this.restoreDirty(event),
|
|
145
|
+
forgetDirty: uri => this.dirtyStates.delete(uri),
|
|
146
|
+
onDidChangeDirty: this.dirtyChangedEmitter.event,
|
|
147
|
+
onDidUpdateDocument: this.documentUpdatedEmitter.event
|
|
148
|
+
}, label);
|
|
149
|
+
this.sessions.add(session);
|
|
150
|
+
// Subscribed before the session is handed out, so the id is free again
|
|
151
|
+
// on this connection by the time any caller's listener runs.
|
|
152
|
+
session.onDidDispose(() => this.sessions.delete(session));
|
|
153
|
+
// A failure reaches the session's own calls, which wait for the same
|
|
154
|
+
// registration; caught here only so it is not also reported unhandled.
|
|
155
|
+
session.connected().catch(() => undefined);
|
|
156
|
+
this.createSessionEmitter.fire(session);
|
|
157
|
+
return session;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Follow `uri` without opening it: its update events reach this
|
|
161
|
+
* connection's client once this resolves. An open would hold the document
|
|
162
|
+
* for as long as the caller follows it. The watch runs under an id of its
|
|
163
|
+
* own, `label` plus `#` plus a random UUID, and needs no session: a session
|
|
164
|
+
* closing the document would also end its own watch of it. Every later
|
|
165
|
+
* connection that becomes ready gets the watch again. Disposing the handle
|
|
166
|
+
* unwatches.
|
|
167
|
+
*/
|
|
168
|
+
async watchDocument(uri, label = 'watch') {
|
|
169
|
+
const clientId = `${label}#${(0, random_uuid_1.randomUuid)()}`;
|
|
170
|
+
const server = await this.connected();
|
|
171
|
+
// Kept only from here: kept during the wait, a generation that became
|
|
172
|
+
// ready meanwhile would send the watch a second time.
|
|
173
|
+
this.watches.set(clientId, uri);
|
|
174
|
+
try {
|
|
175
|
+
await server.watchModelDocument({ uri, clientId });
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
this.watches.delete(clientId);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
this.logger.debug(`Watch ${uri} as ${clientId}`);
|
|
182
|
+
return vscode_jsonrpc_1.Disposable.create(() => {
|
|
183
|
+
if (!this.watches.delete(clientId)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// Without a generation the server dropped the watch with its
|
|
187
|
+
// connection, and one that drops before it is ready drops it too: the
|
|
188
|
+
// unwatch follows no drop to a connection opened only for it.
|
|
189
|
+
const generation = this.generation;
|
|
190
|
+
if (generation) {
|
|
191
|
+
(generation.ready ??= this.awaitReady(generation)).then(() => {
|
|
192
|
+
if (this.generation === generation) {
|
|
193
|
+
this.logger.debug(`Unwatch ${uri} as ${clientId}`);
|
|
194
|
+
generation.server.unwatchModelDocument({ uri, clientId }).catch(() => undefined);
|
|
195
|
+
}
|
|
196
|
+
}, () => undefined);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The client, with its `onDocumentDirtyChanged` passing through
|
|
202
|
+
* {@link deliverDirty} first, so {@link dirtyStates} holds what the server
|
|
203
|
+
* told it, and every session hears it through {@link dirtyChangedEmitter};
|
|
204
|
+
* and with its `onDocumentUpdated` heard by every session through
|
|
205
|
+
* {@link documentUpdatedEmitter} first. Every other bound method forwards
|
|
206
|
+
* to the client unchanged, and one the client lacks stays absent, so the
|
|
207
|
+
* binding still refuses it.
|
|
208
|
+
*/
|
|
209
|
+
localTarget() {
|
|
210
|
+
const client = this.client;
|
|
211
|
+
const hearsDirty = typeof client.onDocumentDirtyChanged === 'function';
|
|
212
|
+
const hearsUpdates = typeof client.onDocumentUpdated === 'function';
|
|
213
|
+
if (!hearsDirty && !hearsUpdates) {
|
|
214
|
+
return this.client;
|
|
215
|
+
}
|
|
216
|
+
const target = {};
|
|
217
|
+
for (const name of this.clientMethods) {
|
|
218
|
+
const method = client[name];
|
|
219
|
+
if (typeof method === 'function') {
|
|
220
|
+
target[name] = (params) => method.call(client, params);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (hearsDirty) {
|
|
224
|
+
target.onDocumentDirtyChanged = (event) => {
|
|
225
|
+
this.dirtyChangedEmitter.fire(event);
|
|
226
|
+
this.deliverDirty(event);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
if (hearsUpdates) {
|
|
230
|
+
const forward = target.onDocumentUpdated;
|
|
231
|
+
target.onDocumentUpdated = (event) => {
|
|
232
|
+
this.documentUpdatedEmitter.fire(event);
|
|
233
|
+
forward(event);
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return target;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Hand a dirty state a restore read to the client, unless it is what
|
|
240
|
+
* {@link dirtyStates} says the client was last told; a URI it holds
|
|
241
|
+
* nothing for counts as different.
|
|
242
|
+
*/
|
|
243
|
+
restoreDirty(event) {
|
|
244
|
+
if (this.dirtyStates.get(event.uri) !== (event.text?.dirty ?? false)) {
|
|
245
|
+
this.deliverDirty(event);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/** Record `event` in {@link dirtyStates} and hand it to the client. */
|
|
249
|
+
deliverDirty(event) {
|
|
250
|
+
this.dirtyStates.set(event.uri, event.text?.dirty ?? false);
|
|
251
|
+
const client = this.client;
|
|
252
|
+
client.onDocumentDirtyChanged?.(event);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* After the transport dropped, reconnect on the next macrotask for the
|
|
256
|
+
* sessions with documents open, so they re-watch and follow their documents
|
|
257
|
+
* again without waiting for a call of their own, and connect for what
|
|
258
|
+
* {@link watchDocument} watches, which {@link generationReady} places
|
|
259
|
+
* again; a session with nothing open restores on its next call. Nothing is
|
|
260
|
+
* scheduled once this connection is disposed, which drops its generation
|
|
261
|
+
* too.
|
|
262
|
+
*/
|
|
263
|
+
dropGeneration() {
|
|
264
|
+
const dropped = this.generation !== undefined;
|
|
265
|
+
super.dropGeneration();
|
|
266
|
+
if (dropped && !this.disposed) {
|
|
267
|
+
setTimeout(() => {
|
|
268
|
+
if (!this.disposed) {
|
|
269
|
+
this.reconnectSessions();
|
|
270
|
+
if (this.watches.size > 0) {
|
|
271
|
+
// One generation, not `connected`, which follows a drop to
|
|
272
|
+
// the next: that drop's own timer asks again whether
|
|
273
|
+
// anything is still kept. A failure is reported by the gate.
|
|
274
|
+
const generation = this.currentGeneration();
|
|
275
|
+
(generation.ready ??= this.awaitReady(generation)).catch(() => undefined);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}, 0);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Call `reconnect()` on every session, reporting a throw instead of letting
|
|
283
|
+
* one session's restore stop the others and the watches after them, and,
|
|
284
|
+
* inside the readiness gate, fail the whole generation.
|
|
285
|
+
*/
|
|
286
|
+
reconnectSessions() {
|
|
287
|
+
for (const session of this.sessions) {
|
|
288
|
+
try {
|
|
289
|
+
session.reconnect();
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
// Reported, so it reaches the user on a port without a logger;
|
|
293
|
+
// logged too, since only the log names the session.
|
|
294
|
+
this.reportError(error, (0, primitives_1.resolve)(exports.DATA_CONNECTION_SESSION_RESTORE_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
295
|
+
this.logger.error(`Could not restore session ${session.clientId}: ${(0, primitives_1.describeError)(error)}`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Restore what the server lost with an earlier generation, whichever
|
|
301
|
+
* request brought this one up: the documents of sessions that have some
|
|
302
|
+
* open, and every watch {@link watchDocument} keeps.
|
|
303
|
+
*/
|
|
304
|
+
generationReady(generation) {
|
|
305
|
+
super.generationReady(generation);
|
|
306
|
+
this.reconnectSessions();
|
|
307
|
+
this.watches.forEach((uri, clientId) => this.watchAgain(generation, clientId, uri));
|
|
308
|
+
if (this.readyBefore) {
|
|
309
|
+
this.reconnectEmitter.fire(undefined);
|
|
310
|
+
}
|
|
311
|
+
this.readyBefore = true;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Send the watch of `uri` under `clientId` to `generation`, which has just
|
|
315
|
+
* passed its readiness gate. Sent at once rather than after a wait, so no
|
|
316
|
+
* drop can come between choosing the generation and sending. A failure is
|
|
317
|
+
* reported, since no caller waits on it, only while the watch is kept and
|
|
318
|
+
* `generation` is still current: otherwise the next generation sends it
|
|
319
|
+
* again.
|
|
320
|
+
*
|
|
321
|
+
* Once the watch is in place, the document's dirty state is read and goes
|
|
322
|
+
* through {@link restoreDirty}, as a session's restore does: a flip while
|
|
323
|
+
* the connection was down reached no one.
|
|
324
|
+
*/
|
|
325
|
+
watchAgain(generation, clientId, uri) {
|
|
326
|
+
generation.server.watchModelDocument({ uri, clientId }).then(() => {
|
|
327
|
+
if (!this.watches.has(clientId)) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
this.logger.debug(`Watch ${uri} again as ${clientId}`);
|
|
331
|
+
generation.server.getModelDocument({ uri }).then(current => {
|
|
332
|
+
if (current.text && this.watches.has(clientId)) {
|
|
333
|
+
try {
|
|
334
|
+
this.restoreDirty({ uri: current.uri, text: current.text });
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
// The client's listener failed, not the watch, which stays kept.
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}, () => undefined);
|
|
341
|
+
}, (error) => {
|
|
342
|
+
if (!this.watches.has(clientId)) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (this.generation !== generation) {
|
|
346
|
+
this.logger.debug(`Watch of ${uri} as ${clientId} cut short by a lost connection; the next one sends it again`);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
this.reportError(error, (0, primitives_1.resolve)(exports.DATA_CONNECTION_WATCH_RESTORE_FAILED, { uri, detail: (0, primitives_1.describeError)(error) }));
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Sessions are detached rather than disposed: the server ends every session
|
|
354
|
+
* on a connection it sees close, so ending each one first sends requests
|
|
355
|
+
* over a connection this call is about to dispose.
|
|
356
|
+
*/
|
|
357
|
+
dispose() {
|
|
358
|
+
for (const session of [...this.sessions]) {
|
|
359
|
+
session.detach();
|
|
360
|
+
}
|
|
361
|
+
// For a factory's session whose `detach` does not fire.
|
|
362
|
+
this.sessions.clear();
|
|
363
|
+
this.watches.clear();
|
|
364
|
+
this.createSessionEmitter.dispose();
|
|
365
|
+
this.reconnectEmitter.dispose();
|
|
366
|
+
this.dirtyChangedEmitter.dispose();
|
|
367
|
+
this.documentUpdatedEmitter.dispose();
|
|
368
|
+
super.dispose();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
exports.DataConnection = DataConnection;
|
|
372
|
+
/**
|
|
373
|
+
* A {@link DataConnection} that brings its own {@link DataEvents}, so a host
|
|
374
|
+
* with several interested parties does not have to supply one.
|
|
375
|
+
*
|
|
376
|
+
* **The client slot holds exactly one object, and that is why this exists.**
|
|
377
|
+
* `createRpcProxy` binds a single `localTarget`, and underneath a method name
|
|
378
|
+
* maps to one handler — a second registration replaces the first silently. So a
|
|
379
|
+
* properties panel and a tree cannot both be the client; one fan-out sits in the
|
|
380
|
+
* slot and both subscribe to it.
|
|
381
|
+
*
|
|
382
|
+
* Use {@link DataConnection} directly instead when the client is yours: an
|
|
383
|
+
* adopter service that implements the protocol plus its own methods, a single
|
|
384
|
+
* consumer that IS the client, or a request/response-only client that binds
|
|
385
|
+
* nothing.
|
|
386
|
+
*/
|
|
387
|
+
class DataConnectionWithEvents extends DataConnection {
|
|
388
|
+
/** Server pushes, fanned out to as many local listeners as the host has. */
|
|
389
|
+
events;
|
|
390
|
+
constructor(port, options) {
|
|
391
|
+
// Built as a local because `this` is unavailable before `super`, then
|
|
392
|
+
// read back onto the field.
|
|
393
|
+
const events = new data_events_1.DataEvents();
|
|
394
|
+
super(port, events, options);
|
|
395
|
+
this.events = events;
|
|
396
|
+
}
|
|
397
|
+
/** Disposes the fan-out it created, which no caller else holds. */
|
|
398
|
+
dispose() {
|
|
399
|
+
super.dispose();
|
|
400
|
+
this.events.dispose();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
exports.DataConnectionWithEvents = DataConnectionWithEvents;
|
|
404
|
+
//# sourceMappingURL=data-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-connection.js","sourceRoot":"","sources":["../../src/client/data-connection.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mDAAiE;AACjE,8CAAqD;AACrD,kCASiB;AACjB,sCAA0E;AAE1E,uDAA+E;AAC/E,gDAA4C;AAC5C,gDAA4C;AAE5C,+CAA2C;AAE3C,iDAAsE;AACtE,qDAA4G;AAE5G;;;GAGG;AACU,QAAA,oCAAoC,GAAG,IAAA,0BAAa,EAC9D,yDAAyD,EACzD,6EAA6E,CAC/E,CAAC;AAEF;;;GAGG;AACU,QAAA,sCAAsC,GAAG,IAAA,0BAAa,EAChE,2DAA2D,EAC3D,6EAA6E,CAC/E,CAAC;AAkDF;;;;;;;;;;;;;;GAcG;AACH,oBAIE,SAAQ,8BAA+B;IACnB,QAAQ,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AO,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,mEAAmE;IAC1D,OAAO;QACb,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACH"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { Emitter, type Event } from 'vscode-jsonrpc';
|
|
10
|
-
import type { DataClientProtocol, ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from '../data';
|
|
10
|
+
import type { DataClientProtocol, ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentDirtyChangedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from '../data';
|
|
11
11
|
import type { Project } from '../project';
|
|
12
12
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
13
13
|
import type { TransferElement } from '../transfer-element';
|
|
@@ -34,15 +34,27 @@ import type { TransferElement } from '../transfer-element';
|
|
|
34
34
|
export declare class DataEvents<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> implements DataClientProtocol<TTransfer, TDiagnostic, TProject> {
|
|
35
35
|
protected readonly documentUpdatedEmitter: Emitter<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
|
|
36
36
|
protected readonly documentSavedEmitter: Emitter<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
|
|
37
|
+
protected readonly documentDirtyChangedEmitter: Emitter<TransferDocumentDirtyChangedEvent>;
|
|
38
|
+
protected readonly documentDeletedEmitter: Emitter<TransferDocumentDeletedEvent>;
|
|
39
|
+
protected readonly documentsBuiltEmitter: Emitter<TransferDocumentsBuiltEvent>;
|
|
37
40
|
protected readonly projectsChangedEmitter: Emitter<ProjectsChangedEvent<TProject>>;
|
|
38
41
|
/** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
|
|
39
42
|
readonly onDidUpdateDocument: Event<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
|
|
40
43
|
/** A watched document was persisted to disk. */
|
|
41
44
|
readonly onDidSaveDocument: Event<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
|
|
45
|
+
/** A watched document's text started or stopped differing from its file. */
|
|
46
|
+
readonly onDidChangeDocumentDirty: Event<TransferDocumentDirtyChangedEvent>;
|
|
47
|
+
/** A document's backing file was removed, watched or not. Any watch survives. */
|
|
48
|
+
readonly onDidDeleteDocument: Event<TransferDocumentDeletedEvent>;
|
|
49
|
+
/** Documents built that nobody watches — re-read anything derived from them. */
|
|
50
|
+
readonly onDidBuildDocuments: Event<TransferDocumentsBuiltEvent>;
|
|
42
51
|
/** The project set changed. */
|
|
43
52
|
readonly onDidChangeProjects: Event<ProjectsChangedEvent<TProject>>;
|
|
44
53
|
onDocumentUpdated(event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>): void;
|
|
45
54
|
onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
|
|
55
|
+
onDocumentDirtyChanged(event: TransferDocumentDirtyChangedEvent): void;
|
|
56
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
|
|
57
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
|
|
46
58
|
onProjectsChanged(event: ProjectsChangedEvent<TProject>): void;
|
|
47
59
|
dispose(): void;
|
|
48
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-events.d.ts","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"data-events.d.ts","sourceRoot":"","sources":["../../src/client/data-events.ts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,CAAC,CAA0C;IACrH,iFAAiF;IACjF,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAqC;IACtG,gFAAgF;IAChF,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAoC;IACpG,+BAA+B;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAqC;IAIxG,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI,CAEnF;IAED,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI,CAE/E;IAED,sBAAsB,CAAC,KAAK,EAAE,iCAAiC,GAAG,IAAI,CAErE;IAED,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,GAAG,IAAI,CAE3D;IAED,gBAAgB,CAAC,KAAK,EAAE,2BAA2B,GAAG,IAAI,CAEzD;IAED,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,IAAI,CAE7D;IAED,OAAO,IAAI,IAAI,CAOd;CACH"}
|
|
@@ -33,11 +33,20 @@ const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
|
33
33
|
class DataEvents {
|
|
34
34
|
documentUpdatedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
35
35
|
documentSavedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
36
|
+
documentDirtyChangedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
37
|
+
documentDeletedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
38
|
+
documentsBuiltEmitter = new vscode_jsonrpc_1.Emitter();
|
|
36
39
|
projectsChangedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
37
40
|
/** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
|
|
38
41
|
onDidUpdateDocument = this.documentUpdatedEmitter.event;
|
|
39
42
|
/** A watched document was persisted to disk. */
|
|
40
43
|
onDidSaveDocument = this.documentSavedEmitter.event;
|
|
44
|
+
/** A watched document's text started or stopped differing from its file. */
|
|
45
|
+
onDidChangeDocumentDirty = this.documentDirtyChangedEmitter.event;
|
|
46
|
+
/** A document's backing file was removed, watched or not. Any watch survives. */
|
|
47
|
+
onDidDeleteDocument = this.documentDeletedEmitter.event;
|
|
48
|
+
/** Documents built that nobody watches — re-read anything derived from them. */
|
|
49
|
+
onDidBuildDocuments = this.documentsBuiltEmitter.event;
|
|
41
50
|
/** The project set changed. */
|
|
42
51
|
onDidChangeProjects = this.projectsChangedEmitter.event;
|
|
43
52
|
// --- DataClientProtocol (wire names) ---
|
|
@@ -47,12 +56,24 @@ class DataEvents {
|
|
|
47
56
|
onDocumentSaved(event) {
|
|
48
57
|
this.documentSavedEmitter.fire(event);
|
|
49
58
|
}
|
|
59
|
+
onDocumentDirtyChanged(event) {
|
|
60
|
+
this.documentDirtyChangedEmitter.fire(event);
|
|
61
|
+
}
|
|
62
|
+
onDocumentDeleted(event) {
|
|
63
|
+
this.documentDeletedEmitter.fire(event);
|
|
64
|
+
}
|
|
65
|
+
onDocumentsBuilt(event) {
|
|
66
|
+
this.documentsBuiltEmitter.fire(event);
|
|
67
|
+
}
|
|
50
68
|
onProjectsChanged(event) {
|
|
51
69
|
this.projectsChangedEmitter.fire(event);
|
|
52
70
|
}
|
|
53
71
|
dispose() {
|
|
54
72
|
this.documentUpdatedEmitter.dispose();
|
|
55
73
|
this.documentSavedEmitter.dispose();
|
|
74
|
+
this.documentDirtyChangedEmitter.dispose();
|
|
75
|
+
this.documentDeletedEmitter.dispose();
|
|
76
|
+
this.documentsBuiltEmitter.dispose();
|
|
56
77
|
this.projectsChangedEmitter.dispose();
|
|
57
78
|
}
|
|
58
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-events.js","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":";AAAA;;;;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AChD,CAAC;IAED,iBAAiB,CAAC,KAAmC;QAClD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,gBAAgB,CAAC,KAAkC;QAChD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,iBAAiB,CAAC,KAAqC;QACpD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACJ,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,CAAC;QAC3C,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACH"}
|
|
@@ -7,14 +7,20 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import type { Event, MessageConnection } from 'vscode-jsonrpc';
|
|
10
|
+
import type { Logger } from '../logger';
|
|
11
|
+
import type { ResolvedMessage } from '../messages/primitives';
|
|
12
|
+
import type { RpcConnectionLifecycle } from './rpc-connection';
|
|
10
13
|
/**
|
|
11
14
|
* The one thing a host has to supply for the data head: a live JSON-RPC
|
|
12
|
-
* connection to the data server, plus the
|
|
13
|
-
* with it.
|
|
15
|
+
* connection to the data server, plus the failure sink that goes with it.
|
|
14
16
|
*
|
|
15
|
-
* "Port" in the hexagonal sense — the host implements it, `
|
|
17
|
+
* "Port" in the hexagonal sense — the host implements it, `DataConnection`
|
|
16
18
|
* consumes it, and nothing on either side of the boundary imports the other.
|
|
17
19
|
*
|
|
20
|
+
* Carries no identity. A `clientId` names a participant, and one transport
|
|
21
|
+
* serves as many as the host has; binding an identity here is what makes two
|
|
22
|
+
* of them share one, so it lives on `DataSession` instead.
|
|
23
|
+
*
|
|
18
24
|
* **This deliberately does NOT wrap the protocol methods.** `createRpcProxy`
|
|
19
25
|
* already takes a promise of a connection and produces the whole typed
|
|
20
26
|
* `DataServerProtocol` surface, so wrapping it would re-derive the framework's
|
|
@@ -22,7 +28,7 @@ import type { Event, MessageConnection } from 'vscode-jsonrpc';
|
|
|
22
28
|
* method allowlists, which cannot drift. Everything a form or a tree actually
|
|
23
29
|
* does — the wire contract, the open/watch/update/close sequence, `baseVersion`
|
|
24
30
|
* conflict handling, echo filtering by `sourceClientId` — is host-invariant and
|
|
25
|
-
* lives above this interface. What varies between hosts is exactly the
|
|
31
|
+
* lives above this interface. What varies between hosts is exactly the
|
|
26
32
|
* members below.
|
|
27
33
|
*
|
|
28
34
|
* **Why the transport hop and not merely the protocol.** In a Theia frontend
|
|
@@ -43,21 +49,6 @@ import type { Event, MessageConnection } from 'vscode-jsonrpc';
|
|
|
43
49
|
* calls on the promise but never calls `listen` itself.
|
|
44
50
|
*/
|
|
45
51
|
export interface DataPort {
|
|
46
|
-
/**
|
|
47
|
-
* Stable identity of this client on the data server, passed as `clientId`
|
|
48
|
-
* on every document request.
|
|
49
|
-
*
|
|
50
|
-
* It has to be stable for the session because it is the echo key: an
|
|
51
|
-
* inbound `onDocumentUpdated` carries the originating mutation's
|
|
52
|
-
* `clientId` as `sourceClientId`, and a client that cannot recognise its
|
|
53
|
-
* own echo treats its own write as a concurrent third-party one. It also
|
|
54
|
-
* has to be distinct per client, since it keys the server's per-
|
|
55
|
-
* `(uri, clientId)` watch bucket.
|
|
56
|
-
*
|
|
57
|
-
* Avoid the three values the framework itself uses as sentinels —
|
|
58
|
-
* `'language-client'`, `'unknown'` and `'revert-on-close'`.
|
|
59
|
-
*/
|
|
60
|
-
readonly clientId: string;
|
|
61
52
|
/**
|
|
62
53
|
* Open the transport and hand back a listening `MessageConnection`.
|
|
63
54
|
*
|
|
@@ -73,10 +64,18 @@ export interface DataPort {
|
|
|
73
64
|
*
|
|
74
65
|
* It exists because the alternative is worse in both directions: this tier
|
|
75
66
|
* cannot import a host's UI, and swallowing the error makes a dead
|
|
76
|
-
* connection look like an empty model.
|
|
77
|
-
*
|
|
67
|
+
* connection look like an empty model.
|
|
68
|
+
*
|
|
69
|
+
* `reported` is a complete sentence plus the identity needed to render it in
|
|
70
|
+
* another language. It carries a value rather than using a protocol field
|
|
71
|
+
* because this tier does not know whether a process hop intervenes — in a
|
|
72
|
+
* webview host the render happens across one — and a `ResolvedMessage` is
|
|
73
|
+
* structured-clone safe either way. Render it with `renderFrameworkMessage`;
|
|
74
|
+
* passing no translation map yields the English.
|
|
78
75
|
*/
|
|
79
|
-
reportError(error: unknown,
|
|
76
|
+
reportError(error: unknown, reported: ResolvedMessage): void;
|
|
77
|
+
/** Where a connection over this port logs what it does on its own. Without one it logs nothing. */
|
|
78
|
+
readonly logger?: Logger;
|
|
80
79
|
/**
|
|
81
80
|
* Fires when the host tears the transport down and the current connection
|
|
82
81
|
* is no longer usable — a language-server restart being the case that
|
|
@@ -91,5 +90,11 @@ export interface DataPort {
|
|
|
91
90
|
* `Disposable` on the *wire* would not be.
|
|
92
91
|
*/
|
|
93
92
|
readonly onDispose: Event<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Called for each connection generation, beside the lifecycle the
|
|
95
|
+
* connection's options pass, so a host reporting its connections itself
|
|
96
|
+
* does so without every connection built over it passing this on.
|
|
97
|
+
*/
|
|
98
|
+
readonly connectionLifecycle?: RpcConnectionLifecycle;
|
|
94
99
|
}
|
|
95
100
|
//# sourceMappingURL=data-port.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-port.d.ts","sourceRoot":"","sources":["../../src/client/data-port.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"data-port.d.ts","sourceRoot":"","sources":["../../src/client/data-port.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,WAAW,QAAQ;IACtB;;;;;;;OAOG;IACH,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAE7D,mGAAmG;IACnG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEhC;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,sBAAsB,CAAC;CACxD"}
|