@hydranium/protocol 1.0.0-next.10 → 1.0.0-next.103
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 +141 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +138 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +27 -10
- 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 +215 -0
- package/src/model-server.ts +30 -11
- 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
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ names, a worked example — is in
|
|
|
60
60
|
@hydranium/protocol # transfer documents, references, RPC machinery
|
|
61
61
|
@hydranium/protocol/data # DataServerProtocol / DataClientProtocol
|
|
62
62
|
@hydranium/protocol/client # the host-neutral client tier
|
|
63
|
-
@hydranium/protocol/testing # test doubles
|
|
63
|
+
@hydranium/protocol/testing # test doubles, waiters, catalogue audit
|
|
64
64
|
@hydranium/protocol/testing/node # the Node-only doubles
|
|
65
65
|
```
|
|
66
66
|
|
|
@@ -69,6 +69,40 @@ narrower surface rather than reach; `testing` is only reachable by its own
|
|
|
69
69
|
specifier, which is what keeps the doubles out of a production bundle. The RPC
|
|
70
70
|
machinery documents itself in [`src/rpc/README.md`](./src/rpc/README.md).
|
|
71
71
|
|
|
72
|
+
### Auditing a translation catalogue
|
|
73
|
+
|
|
74
|
+
An adopter with i18n has one failure mode nothing else catches: a catalogue key
|
|
75
|
+
naming no declared code falls back to the English, which is byte-identical to
|
|
76
|
+
the deliberately-partial behaviour every adopter relies on. So a typo is
|
|
77
|
+
invisible at runtime, and `theia nls-extract` reports what the source declares
|
|
78
|
+
rather than whether a catalogue matches it.
|
|
79
|
+
|
|
80
|
+
`@hydranium/protocol/testing` ships the audit for it — call it from your own
|
|
81
|
+
test, over your own barrels:
|
|
82
|
+
|
|
83
|
+
<!-- snippet-preamble
|
|
84
|
+
import { flattenCatalogue, findUndeclaredCodes, findSharedCodes } from '@hydranium/protocol/testing';
|
|
85
|
+
import * as protocolMessages from '@hydranium/protocol';
|
|
86
|
+
declare const readFileSync: (path: string, encoding: string) => string;
|
|
87
|
+
declare const expect: (actual: unknown) => { toEqual(expected: unknown): void };
|
|
88
|
+
-->
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
const keys = Object.keys(flattenCatalogue(JSON.parse(readFileSync('nls/de.json', 'utf-8'))));
|
|
92
|
+
|
|
93
|
+
// Every key names a code some barrel declares. `exemptPrefixes` is for keys no
|
|
94
|
+
// barrel CAN declare — a host mechanism taking its key as an inline literal.
|
|
95
|
+
expect(findUndeclaredCodes(keys, [protocolMessages])).toEqual([]);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`flattenCatalogue` joins nested keys with `/` (the separator a code already
|
|
99
|
+
uses, and what Theia does to a nested catalogue) and drops `_`-prefixed note
|
|
100
|
+
keys, so a flat server-side catalogue and a nested host-side one both go through
|
|
101
|
+
it. `findSharedCodes` covers the other half: exactly one side renders a given
|
|
102
|
+
message, so two catalogues holding one code are two authorities over one
|
|
103
|
+
sentence — assert both key sets non-empty first, since an empty one satisfies
|
|
104
|
+
disjointness while proving nothing.
|
|
105
|
+
|
|
72
106
|
## Status
|
|
73
107
|
|
|
74
108
|
Alpha — pre-v0. The package is being populated incrementally, and its API is
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import { type DataClientProtocol, type DataServerProtocol, type DiagnosticOf, type ProjectOf } from '../data';
|
|
10
|
+
import type { TransferElement } from '../transfer-element';
|
|
11
|
+
import { DataEvents } from './data-events';
|
|
12
|
+
import type { DataPort } from './data-port';
|
|
13
|
+
import { DataSession } from './data-session';
|
|
14
|
+
import { RpcConnection, type RpcConnectionLifecycle } from './rpc-connection';
|
|
15
|
+
/** Options for {@link DataConnection}. */
|
|
16
|
+
export interface DataConnectionOptions extends RpcConnectionLifecycle {
|
|
17
|
+
/**
|
|
18
|
+
* Wire namespace the server is addressed under. Defaults to the
|
|
19
|
+
* framework's {@link DATA_SERVER_WIRE_PREFIX}, which is what an unmodified
|
|
20
|
+
* `DataServer` binds. Override only alongside the server's own
|
|
21
|
+
* `methodNamespace` option — a mismatch turns every request into
|
|
22
|
+
* "Unhandled method" rather than failing at wire-up.
|
|
23
|
+
*/
|
|
24
|
+
readonly methodNamespace?: string;
|
|
25
|
+
}
|
|
26
|
+
/** {@link DataConnectionOptions} for a client that does not speak {@link DataClientProtocol}. */
|
|
27
|
+
export interface DataConnectionOptionsWithMethods<TClient extends object> extends DataConnectionOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Method names of the client to bind as inbound handlers. Declare it
|
|
30
|
+
* `as const satisfies ReadonlyArray<keyof YourClient & string>` so the list
|
|
31
|
+
* cannot drift from the interface.
|
|
32
|
+
*/
|
|
33
|
+
readonly clientMethods: readonly (keyof TClient & string)[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Trailing constructor arguments, required only when the client cannot take
|
|
37
|
+
* the framework's default method list.
|
|
38
|
+
*
|
|
39
|
+
* `bindRpcMethods` throws for a name the target does not implement, so a
|
|
40
|
+
* request/response-only client binding the default list fails at wire-up. The
|
|
41
|
+
* conditional turns that into a compile error.
|
|
42
|
+
*/
|
|
43
|
+
export type DataConnectionArgs<TTransfer extends TransferElement, TClient extends object> = TClient extends DataClientProtocol<TTransfer> ? [options?: DataConnectionOptions & Partial<DataConnectionOptionsWithMethods<TClient>>] : [options: DataConnectionOptionsWithMethods<TClient>];
|
|
44
|
+
/**
|
|
45
|
+
* A {@link RpcConnection} to the data head, carrying as many participants as
|
|
46
|
+
* the host has interested parties.
|
|
47
|
+
*
|
|
48
|
+
* Document operations live on the participants rather than here: they carry a
|
|
49
|
+
* `clientId`, which identifies a participant rather than a wire, and the server
|
|
50
|
+
* keys its holds and watches per `(uri, clientId)`. Two parties sharing one
|
|
51
|
+
* identity cannot tell each other's writes from their own echoes.
|
|
52
|
+
*
|
|
53
|
+
* Generic over the transfer root so this file names no grammar. An adopter
|
|
54
|
+
* binds the concrete root (or the union of them, for a multi-grammar head) at
|
|
55
|
+
* its own edge.
|
|
56
|
+
*/
|
|
57
|
+
export declare class DataConnection<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>, TClient extends object = DataClientProtocol<TTransfer>> extends RpcConnection<TServer, TClient> {
|
|
58
|
+
protected readonly sessions: Set<DataSession<TTransfer, TServer>>;
|
|
59
|
+
/**
|
|
60
|
+
* Holds a disposed session could not release, keyed `clientId` + `uri` so a
|
|
61
|
+
* repeated handover does not queue the same close twice.
|
|
62
|
+
*
|
|
63
|
+
* Retried on this connection's own activity rather than on a timer: every
|
|
64
|
+
* session operation asks for the proxy, so a shared connection with anything
|
|
65
|
+
* else going on supplies the occasions, and one with nothing going on has
|
|
66
|
+
* nobody whose documents the stale hold could affect.
|
|
67
|
+
*/
|
|
68
|
+
protected readonly orphanedHolds: Map<string, {
|
|
69
|
+
readonly uri: string;
|
|
70
|
+
readonly clientId: string;
|
|
71
|
+
}>;
|
|
72
|
+
/** Guards {@link releaseOrphanedHolds} against re-entering through its own proxy lookup. */
|
|
73
|
+
protected releasingOrphans: boolean;
|
|
74
|
+
constructor(port: DataPort, client: TClient, ...rest: DataConnectionArgs<TTransfer, TClient>);
|
|
75
|
+
/**
|
|
76
|
+
* Mint a participant on this connection under `clientId`.
|
|
77
|
+
*
|
|
78
|
+
* `clientId` must be distinct per participant and stable for its lifetime:
|
|
79
|
+
* it keys the server's per-`(uri, clientId)` hold and watch, and it is the
|
|
80
|
+
* echo key an inbound `onDocumentUpdated` is matched against.
|
|
81
|
+
*
|
|
82
|
+
* Throws for an id in {@link FRAMEWORK_CLIENT_IDS} — those are authors the
|
|
83
|
+
* SERVER emits rather than participants, so a session holding one would read
|
|
84
|
+
* the framework's own broadcasts as its own echoes and drop them. Nothing
|
|
85
|
+
* about that fails on its own: the document simply stops following, which
|
|
86
|
+
* looks like a dead connection.
|
|
87
|
+
*
|
|
88
|
+
* Throws, too, for an id a LIVE session on this connection already holds.
|
|
89
|
+
* Per-document membership is a set of client ids, so two participants
|
|
90
|
+
* sharing one collapse to a single hold and the first close releases it
|
|
91
|
+
* under the survivor, which then stops receiving updates for a document it
|
|
92
|
+
* is still showing. A constant bound once per participant KIND — one per
|
|
93
|
+
* widget class rather than per instance — satisfies the type and violates
|
|
94
|
+
* this.
|
|
95
|
+
*
|
|
96
|
+
* And throws for an id whose previous session left a hold this connection is
|
|
97
|
+
* still trying to release. That release closes `(uri, clientId)`, so an id
|
|
98
|
+
* reissued while it is outstanding can have the new participant's hold closed
|
|
99
|
+
* out from under it. The id frees itself as soon as the release lands.
|
|
100
|
+
*
|
|
101
|
+
* The checks span this connection only, so a head several connections reach
|
|
102
|
+
* can still be addressed twice under one id.
|
|
103
|
+
*/
|
|
104
|
+
createSession(clientId: string): DataSession<TTransfer, TServer>;
|
|
105
|
+
/**
|
|
106
|
+
* Take over a `(uri, clientId)` hold a disposed session could not release.
|
|
107
|
+
*
|
|
108
|
+
* One attempt is made straight away, since whatever refused the session's
|
|
109
|
+
* close may already be over; a refusal leaves the entry for the next
|
|
110
|
+
* operation on this connection to retry.
|
|
111
|
+
*/
|
|
112
|
+
protected orphanHold(uri: string, clientId: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Try to close every hold handed over by a disposed session, keeping the ones
|
|
115
|
+
* the server still refuses.
|
|
116
|
+
*
|
|
117
|
+
* Errors are swallowed per entry: this runs off another participant's
|
|
118
|
+
* operation, which has no interest in an unrelated release and no caller to
|
|
119
|
+
* surface it to. A hold that survives every attempt is released by the
|
|
120
|
+
* server's connection-close cleanup.
|
|
121
|
+
*/
|
|
122
|
+
protected releaseOrphanedHolds(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Sessions are detached rather than disposed: the server releases every hold
|
|
125
|
+
* on a connection it sees close, so closing each document first sends
|
|
126
|
+
* requests over a connection this call is about to dispose.
|
|
127
|
+
*/
|
|
128
|
+
dispose(): void;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A {@link DataConnection} that brings its own {@link DataEvents}, so a host
|
|
132
|
+
* with several interested parties does not have to supply one.
|
|
133
|
+
*
|
|
134
|
+
* **The client slot holds exactly one object, and that is why this exists.**
|
|
135
|
+
* `createRpcProxy` binds a single `localTarget`, and underneath a method name
|
|
136
|
+
* maps to one handler — a second registration replaces the first silently. So a
|
|
137
|
+
* properties panel and a tree cannot both be the client; one fan-out sits in the
|
|
138
|
+
* slot and both subscribe to it.
|
|
139
|
+
*
|
|
140
|
+
* Use {@link DataConnection} directly instead when the client is yours: an
|
|
141
|
+
* adopter service that implements the protocol plus its own methods, a single
|
|
142
|
+
* consumer that IS the client, or a request/response-only client that binds
|
|
143
|
+
* nothing.
|
|
144
|
+
*/
|
|
145
|
+
export declare class DataConnectionWithEvents<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> extends DataConnection<TTransfer, TServer, DataEvents<TTransfer, DiagnosticOf<TServer>, ProjectOf<TServer>>> {
|
|
146
|
+
/** Server pushes, fanned out to as many local listeners as the host has. */
|
|
147
|
+
readonly events: DataEvents<TTransfer, DiagnosticOf<TServer>, ProjectOf<TServer>>;
|
|
148
|
+
constructor(port: DataPort, options?: DataConnectionOptions);
|
|
149
|
+
/** Disposes the fan-out it created, which no caller else holds. */
|
|
150
|
+
dispose(): void;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=data-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-connection.d.ts","sourceRoot":"","sources":["../../src/client/data-connection.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,EAGJ,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,SAAS,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EA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,SAAS,EAAE,OAAO,CAAC;IAY5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC;IAqChE;;;;;;OAMG;IACH,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKzD;;;;;;;;OAQG;cACa,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBrD;;;;OAIG;IACM,OAAO,IAAI,IAAI;CAW1B;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,wBAAwB,CAClC,SAAS,SAAS,eAAe,EACjC,OAAO,SAAS,kBAAkB,CAAC,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,kBAAkB,CAAC,SAAS,CAAC,CACrG,SAAQ,cAAc,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3G,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBAEtE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAQ3D,mEAAmE;IAC1D,OAAO,IAAI,IAAI;CAI1B"}
|
|
@@ -0,0 +1,214 @@
|
|
|
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 = void 0;
|
|
12
|
+
const client_ids_1 = require("../client-ids");
|
|
13
|
+
const data_1 = require("../data");
|
|
14
|
+
const data_events_1 = require("./data-events");
|
|
15
|
+
const data_session_1 = require("./data-session");
|
|
16
|
+
const rpc_connection_1 = require("./rpc-connection");
|
|
17
|
+
/**
|
|
18
|
+
* A {@link RpcConnection} to the data head, carrying as many participants as
|
|
19
|
+
* the host has interested parties.
|
|
20
|
+
*
|
|
21
|
+
* Document operations live on the participants rather than here: they carry a
|
|
22
|
+
* `clientId`, which identifies a participant rather than a wire, and the server
|
|
23
|
+
* keys its holds and watches per `(uri, clientId)`. Two parties sharing one
|
|
24
|
+
* identity cannot tell each other's writes from their own echoes.
|
|
25
|
+
*
|
|
26
|
+
* Generic over the transfer root so this file names no grammar. An adopter
|
|
27
|
+
* binds the concrete root (or the union of them, for a multi-grammar head) at
|
|
28
|
+
* its own edge.
|
|
29
|
+
*/
|
|
30
|
+
class DataConnection extends rpc_connection_1.RpcConnection {
|
|
31
|
+
sessions = new Set();
|
|
32
|
+
/**
|
|
33
|
+
* Holds a disposed session could not release, keyed `clientId` + `uri` so a
|
|
34
|
+
* repeated handover does not queue the same close twice.
|
|
35
|
+
*
|
|
36
|
+
* Retried on this connection's own activity rather than on a timer: every
|
|
37
|
+
* session operation asks for the proxy, so a shared connection with anything
|
|
38
|
+
* else going on supplies the occasions, and one with nothing going on has
|
|
39
|
+
* nobody whose documents the stale hold could affect.
|
|
40
|
+
*/
|
|
41
|
+
orphanedHolds = new Map();
|
|
42
|
+
/** Guards {@link releaseOrphanedHolds} against re-entering through its own proxy lookup. */
|
|
43
|
+
releasingOrphans = false;
|
|
44
|
+
constructor(port, client, ...rest) {
|
|
45
|
+
const [options = {}] = rest;
|
|
46
|
+
super(port, client, {
|
|
47
|
+
methodNamespace: options.methodNamespace ?? data_1.DATA_SERVER_WIRE_PREFIX,
|
|
48
|
+
// The default is reachable only where `TClient` satisfies
|
|
49
|
+
// `DataClientProtocol`, which the constructor's conditional enforces;
|
|
50
|
+
// the compiler cannot carry that through to the generic parameter.
|
|
51
|
+
clientMethods: options.clientMethods ?? data_1.DATA_CLIENT_PROTOCOL_METHODS,
|
|
52
|
+
lifecycle: options
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Mint a participant on this connection under `clientId`.
|
|
57
|
+
*
|
|
58
|
+
* `clientId` must be distinct per participant and stable for its lifetime:
|
|
59
|
+
* it keys the server's per-`(uri, clientId)` hold and watch, and it is the
|
|
60
|
+
* echo key an inbound `onDocumentUpdated` is matched against.
|
|
61
|
+
*
|
|
62
|
+
* Throws for an id in {@link FRAMEWORK_CLIENT_IDS} — those are authors the
|
|
63
|
+
* SERVER emits rather than participants, so a session holding one would read
|
|
64
|
+
* the framework's own broadcasts as its own echoes and drop them. Nothing
|
|
65
|
+
* about that fails on its own: the document simply stops following, which
|
|
66
|
+
* looks like a dead connection.
|
|
67
|
+
*
|
|
68
|
+
* Throws, too, for an id a LIVE session on this connection already holds.
|
|
69
|
+
* Per-document membership is a set of client ids, so two participants
|
|
70
|
+
* sharing one collapse to a single hold and the first close releases it
|
|
71
|
+
* under the survivor, which then stops receiving updates for a document it
|
|
72
|
+
* is still showing. A constant bound once per participant KIND — one per
|
|
73
|
+
* widget class rather than per instance — satisfies the type and violates
|
|
74
|
+
* this.
|
|
75
|
+
*
|
|
76
|
+
* And throws for an id whose previous session left a hold this connection is
|
|
77
|
+
* still trying to release. That release closes `(uri, clientId)`, so an id
|
|
78
|
+
* reissued while it is outstanding can have the new participant's hold closed
|
|
79
|
+
* out from under it. The id frees itself as soon as the release lands.
|
|
80
|
+
*
|
|
81
|
+
* The checks span this connection only, so a head several connections reach
|
|
82
|
+
* can still be addressed twice under one id.
|
|
83
|
+
*/
|
|
84
|
+
createSession(clientId) {
|
|
85
|
+
this.assertLive();
|
|
86
|
+
if (client_ids_1.FRAMEWORK_CLIENT_IDS.includes(clientId)) {
|
|
87
|
+
throw new Error(`clientId '${clientId}' is reserved by the framework and cannot identify a participant`);
|
|
88
|
+
}
|
|
89
|
+
if ([...this.sessions].some(session => session.clientId === clientId)) {
|
|
90
|
+
throw new Error(`clientId '${clientId}' already identifies a live participant on this connection`);
|
|
91
|
+
}
|
|
92
|
+
if ([...this.orphanedHolds.values()].some(hold => hold.clientId === clientId)) {
|
|
93
|
+
// A retry is still outstanding for this id, and it closes
|
|
94
|
+
// `(uri, clientId)` — which the server keys one hold per. Handing the
|
|
95
|
+
// id over now lets that close land on the NEW participant's hold
|
|
96
|
+
// instead, taking a document away from a session that opened it
|
|
97
|
+
// successfully. Nothing about that fails on its own: the document
|
|
98
|
+
// simply stops following, and the close that did it was issued for a
|
|
99
|
+
// participant already gone.
|
|
100
|
+
//
|
|
101
|
+
// Attempted first, so an id whose release has become possible is free
|
|
102
|
+
// by the next call rather than waiting for other traffic.
|
|
103
|
+
void this.releaseOrphanedHolds();
|
|
104
|
+
throw new Error(`clientId '${clientId}' has an unreleased hold on this connection and cannot identify a new participant yet`);
|
|
105
|
+
}
|
|
106
|
+
const session = new data_session_1.DataSession(clientId, {
|
|
107
|
+
connected: async () => {
|
|
108
|
+
const server = await this.connected();
|
|
109
|
+
// Unawaited: a session's own operation must not wait on, or fail
|
|
110
|
+
// for, the release of a hold another participant abandoned.
|
|
111
|
+
void this.releaseOrphanedHolds();
|
|
112
|
+
return server;
|
|
113
|
+
},
|
|
114
|
+
releaseSession: released => this.sessions.delete(released),
|
|
115
|
+
orphanHold: (uri, holder) => this.orphanHold(uri, holder)
|
|
116
|
+
});
|
|
117
|
+
this.sessions.add(session);
|
|
118
|
+
return session;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Take over a `(uri, clientId)` hold a disposed session could not release.
|
|
122
|
+
*
|
|
123
|
+
* One attempt is made straight away, since whatever refused the session's
|
|
124
|
+
* close may already be over; a refusal leaves the entry for the next
|
|
125
|
+
* operation on this connection to retry.
|
|
126
|
+
*/
|
|
127
|
+
orphanHold(uri, clientId) {
|
|
128
|
+
this.orphanedHolds.set(`${clientId}\u0000${uri}`, { uri, clientId });
|
|
129
|
+
void this.releaseOrphanedHolds();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Try to close every hold handed over by a disposed session, keeping the ones
|
|
133
|
+
* the server still refuses.
|
|
134
|
+
*
|
|
135
|
+
* Errors are swallowed per entry: this runs off another participant's
|
|
136
|
+
* operation, which has no interest in an unrelated release and no caller to
|
|
137
|
+
* surface it to. A hold that survives every attempt is released by the
|
|
138
|
+
* server's connection-close cleanup.
|
|
139
|
+
*/
|
|
140
|
+
async releaseOrphanedHolds() {
|
|
141
|
+
if (this.releasingOrphans || this.orphanedHolds.size === 0 || this.disposed) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this.releasingOrphans = true;
|
|
145
|
+
try {
|
|
146
|
+
const server = await this.connected();
|
|
147
|
+
for (const [key, hold] of [...this.orphanedHolds]) {
|
|
148
|
+
try {
|
|
149
|
+
await server.closeModelDocument({ uri: hold.uri, clientId: hold.clientId });
|
|
150
|
+
this.orphanedHolds.delete(key);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// Kept for the next occasion.
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// No proxy to release through; the entries wait for one.
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
this.releasingOrphans = false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Sessions are detached rather than disposed: the server releases every hold
|
|
166
|
+
* on a connection it sees close, so closing each document first sends
|
|
167
|
+
* requests over a connection this call is about to dispose.
|
|
168
|
+
*/
|
|
169
|
+
dispose() {
|
|
170
|
+
for (const session of [...this.sessions]) {
|
|
171
|
+
session.detach();
|
|
172
|
+
}
|
|
173
|
+
this.sessions.clear();
|
|
174
|
+
// Dropped rather than closed, for the same reason the sessions detach: the
|
|
175
|
+
// server releases every hold on a connection it sees close, and the close
|
|
176
|
+
// would travel over the connection being disposed.
|
|
177
|
+
this.orphanedHolds.clear();
|
|
178
|
+
super.dispose();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.DataConnection = DataConnection;
|
|
182
|
+
/**
|
|
183
|
+
* A {@link DataConnection} that brings its own {@link DataEvents}, so a host
|
|
184
|
+
* with several interested parties does not have to supply one.
|
|
185
|
+
*
|
|
186
|
+
* **The client slot holds exactly one object, and that is why this exists.**
|
|
187
|
+
* `createRpcProxy` binds a single `localTarget`, and underneath a method name
|
|
188
|
+
* maps to one handler — a second registration replaces the first silently. So a
|
|
189
|
+
* properties panel and a tree cannot both be the client; one fan-out sits in the
|
|
190
|
+
* slot and both subscribe to it.
|
|
191
|
+
*
|
|
192
|
+
* Use {@link DataConnection} directly instead when the client is yours: an
|
|
193
|
+
* adopter service that implements the protocol plus its own methods, a single
|
|
194
|
+
* consumer that IS the client, or a request/response-only client that binds
|
|
195
|
+
* nothing.
|
|
196
|
+
*/
|
|
197
|
+
class DataConnectionWithEvents extends DataConnection {
|
|
198
|
+
/** Server pushes, fanned out to as many local listeners as the host has. */
|
|
199
|
+
events;
|
|
200
|
+
constructor(port, options) {
|
|
201
|
+
// Built as a local because `this` is unavailable before `super`, then
|
|
202
|
+
// read back onto the field.
|
|
203
|
+
const events = new data_events_1.DataEvents();
|
|
204
|
+
super(port, events, options);
|
|
205
|
+
this.events = events;
|
|
206
|
+
}
|
|
207
|
+
/** Disposes the fan-out it created, which no caller else holds. */
|
|
208
|
+
dispose() {
|
|
209
|
+
super.dispose();
|
|
210
|
+
this.events.dispose();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
exports.DataConnectionWithEvents = DataConnectionWithEvents;
|
|
214
|
+
//# sourceMappingURL=data-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-connection.js","sourceRoot":"","sources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M,CAAmE;IAElF,YAAY,IAAc,EAAE,OAA+B;QACxD,sEAAsE;QACtE,4BAA4B;QAC5B,MAAM,MAAM,GAAG,IAAI,wBAAU,EAAwD,CAAC;QACtF,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,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;AApBD,4DAoBC"}
|
|
@@ -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, 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,23 @@ 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 documentDeletedEmitter: Emitter<TransferDocumentDeletedEvent>;
|
|
38
|
+
protected readonly documentsBuiltEmitter: Emitter<TransferDocumentsBuiltEvent>;
|
|
37
39
|
protected readonly projectsChangedEmitter: Emitter<ProjectsChangedEvent<TProject>>;
|
|
38
40
|
/** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
|
|
39
41
|
readonly onDidUpdateDocument: Event<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
|
|
40
42
|
/** A watched document was persisted to disk. */
|
|
41
43
|
readonly onDidSaveDocument: Event<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
|
|
44
|
+
/** A document's backing file was removed, watched or not. Any watch survives. */
|
|
45
|
+
readonly onDidDeleteDocument: Event<TransferDocumentDeletedEvent>;
|
|
46
|
+
/** Documents built that nobody watches — re-read anything derived from them. */
|
|
47
|
+
readonly onDidBuildDocuments: Event<TransferDocumentsBuiltEvent>;
|
|
42
48
|
/** The project set changed. */
|
|
43
49
|
readonly onDidChangeProjects: Event<ProjectsChangedEvent<TProject>>;
|
|
44
50
|
onDocumentUpdated(event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>): void;
|
|
45
51
|
onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
|
|
52
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
|
|
53
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
|
|
46
54
|
onProjectsChanged(event: ProjectsChangedEvent<TProject>): void;
|
|
47
55
|
dispose(): void;
|
|
48
56
|
}
|
|
@@ -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"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,OAA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,CAAC,mBAAmB,EAAE,KAAK,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAqC;IAIxG,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;IAIpF,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;IAIhF,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,GAAG,IAAI;IAI5D,gBAAgB,CAAC,KAAK,EAAE,2BAA2B,GAAG,IAAI;IAI1D,iBAAiB,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,IAAI;IAI9D,OAAO,IAAI,IAAI;CAOjB"}
|
|
@@ -33,11 +33,17 @@ 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
|
+
documentDeletedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
37
|
+
documentsBuiltEmitter = new vscode_jsonrpc_1.Emitter();
|
|
36
38
|
projectsChangedEmitter = new vscode_jsonrpc_1.Emitter();
|
|
37
39
|
/** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
|
|
38
40
|
onDidUpdateDocument = this.documentUpdatedEmitter.event;
|
|
39
41
|
/** A watched document was persisted to disk. */
|
|
40
42
|
onDidSaveDocument = this.documentSavedEmitter.event;
|
|
43
|
+
/** A document's backing file was removed, watched or not. Any watch survives. */
|
|
44
|
+
onDidDeleteDocument = this.documentDeletedEmitter.event;
|
|
45
|
+
/** Documents built that nobody watches — re-read anything derived from them. */
|
|
46
|
+
onDidBuildDocuments = this.documentsBuiltEmitter.event;
|
|
41
47
|
/** The project set changed. */
|
|
42
48
|
onDidChangeProjects = this.projectsChangedEmitter.event;
|
|
43
49
|
// --- DataClientProtocol (wire names) ---
|
|
@@ -47,12 +53,20 @@ class DataEvents {
|
|
|
47
53
|
onDocumentSaved(event) {
|
|
48
54
|
this.documentSavedEmitter.fire(event);
|
|
49
55
|
}
|
|
56
|
+
onDocumentDeleted(event) {
|
|
57
|
+
this.documentDeletedEmitter.fire(event);
|
|
58
|
+
}
|
|
59
|
+
onDocumentsBuilt(event) {
|
|
60
|
+
this.documentsBuiltEmitter.fire(event);
|
|
61
|
+
}
|
|
50
62
|
onProjectsChanged(event) {
|
|
51
63
|
this.projectsChangedEmitter.fire(event);
|
|
52
64
|
}
|
|
53
65
|
dispose() {
|
|
54
66
|
this.documentUpdatedEmitter.dispose();
|
|
55
67
|
this.documentSavedEmitter.dispose();
|
|
68
|
+
this.documentDeletedEmitter.dispose();
|
|
69
|
+
this.documentsBuiltEmitter.dispose();
|
|
56
70
|
this.projectsChangedEmitter.dispose();
|
|
57
71
|
}
|
|
58
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-events.js","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mDAAqD;
|
|
1
|
+
{"version":3,"file":"data-events.js","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mDAAqD;AAarD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,UAAU;IAKD,sBAAsB,GAAG,IAAI,wBAAO,EAAwD,CAAC;IAC7F,oBAAoB,GAAG,IAAI,wBAAO,EAAsD,CAAC;IACzF,sBAAsB,GAAG,IAAI,wBAAO,EAAgC,CAAC;IACrE,qBAAqB,GAAG,IAAI,wBAAO,EAA+B,CAAC;IACnE,sBAAsB,GAAG,IAAI,wBAAO,EAAkC,CAAC;IAE1F,4FAA4F;IACnF,mBAAmB,GAAgE,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC;IAC9H,gDAAgD;IACvC,iBAAiB,GAA8D,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;IACxH,iFAAiF;IACxE,mBAAmB,GAAwC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC;IACtG,gFAAgF;IACvE,mBAAmB,GAAuC,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC;IACpG,+BAA+B;IACtB,mBAAmB,GAA0C,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC;IAExG,0CAA0C;IAE1C,iBAAiB,CAAC,KAA2D;QAC1E,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,eAAe,CAAC,KAAyD;QACtE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,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,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACH;AAnDD,gCAmDC"}
|
|
@@ -7,20 +7,24 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import type { Event, MessageConnection } from 'vscode-jsonrpc';
|
|
10
|
+
import type { ResolvedMessage } from '../messages/primitives';
|
|
10
11
|
/**
|
|
11
12
|
* 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.
|
|
13
|
+
* connection to the data server, plus the failure sink that goes with it.
|
|
14
14
|
*
|
|
15
|
-
* "Port" in the hexagonal sense — the host implements it, `
|
|
15
|
+
* "Port" in the hexagonal sense — the host implements it, `DataConnection`
|
|
16
16
|
* consumes it, and nothing on either side of the boundary imports the other.
|
|
17
17
|
*
|
|
18
|
+
* Carries no identity. A `clientId` names a participant, and one transport
|
|
19
|
+
* serves as many as the host has; binding an identity here is what makes two
|
|
20
|
+
* of them share one, so it lives on `DataSession` instead.
|
|
21
|
+
*
|
|
18
22
|
* **This deliberately does NOT wrap the protocol methods.** `createRpcProxy`
|
|
19
23
|
* already takes a promise of a connection and produces the whole typed
|
|
20
24
|
* `DataServerProtocol` surface, so wrapping it would re-derive the framework's
|
|
21
25
|
* pass-throughs in a second place and lose the `as const satisfies keyof`
|
|
22
26
|
* method allowlists, which cannot drift. Everything a form or a tree actually
|
|
23
|
-
* does — the wire contract, the open/watch/update/close sequence, `
|
|
27
|
+
* does — the wire contract, the open/watch/update/close sequence, `basedOn`
|
|
24
28
|
* conflict handling, echo filtering by `sourceClientId` — is host-invariant and
|
|
25
29
|
* lives above this interface. What varies between hosts is exactly the four
|
|
26
30
|
* members below.
|
|
@@ -43,21 +47,6 @@ import type { Event, MessageConnection } from 'vscode-jsonrpc';
|
|
|
43
47
|
* calls on the promise but never calls `listen` itself.
|
|
44
48
|
*/
|
|
45
49
|
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
50
|
/**
|
|
62
51
|
* Open the transport and hand back a listening `MessageConnection`.
|
|
63
52
|
*
|
|
@@ -73,10 +62,16 @@ export interface DataPort {
|
|
|
73
62
|
*
|
|
74
63
|
* It exists because the alternative is worse in both directions: this tier
|
|
75
64
|
* cannot import a host's UI, and swallowing the error makes a dead
|
|
76
|
-
* connection look like an empty model.
|
|
77
|
-
*
|
|
65
|
+
* connection look like an empty model.
|
|
66
|
+
*
|
|
67
|
+
* `reported` is a complete sentence plus the identity needed to render it in
|
|
68
|
+
* another language. It carries a value rather than using a protocol field
|
|
69
|
+
* because this tier does not know whether a process hop intervenes — in a
|
|
70
|
+
* webview host the render happens across one — and a `ResolvedMessage` is
|
|
71
|
+
* structured-clone safe either way. Render it with `renderFrameworkMessage`;
|
|
72
|
+
* passing no translation map yields the English.
|
|
78
73
|
*/
|
|
79
|
-
reportError(error: unknown,
|
|
74
|
+
reportError(error: unknown, reported: ResolvedMessage): void;
|
|
80
75
|
/**
|
|
81
76
|
* Fires when the host tears the transport down and the current connection
|
|
82
77
|
* is no longer usable — a language-server restart being the case that
|
|
@@ -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,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAClC"}
|