@hydranium/protocol 1.0.0-next.6 → 1.0.0-next.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -1
- package/lib/client/data-connection.d.ts +76 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +73 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +9 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +14 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +16 -21
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +56 -74
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +67 -101
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +5 -2
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +5 -2
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +8 -2
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +10 -4
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +116 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +155 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +2 -2
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +6 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +21 -1
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +70 -3
- package/lib/data/events.d.ts.map +1 -1
- package/lib/errors.d.ts +25 -6
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +32 -12
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/messages/index.d.ts +28 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +52 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +141 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +138 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +2 -2
- package/lib/model-server.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.d.ts +29 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +22 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +7 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +11 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +14 -5
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +4 -1
- package/lib/testing/index.js.map +1 -1
- package/lib/transfer-diagnostic.d.ts +33 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +23 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/package.json +11 -2
- package/src/client/data-connection.ts +114 -0
- package/src/client/data-events.ts +24 -1
- package/src/client/data-port.ts +16 -22
- package/src/client/data-session.ts +86 -124
- package/src/client/index.ts +5 -2
- package/src/client/message-relay.ts +28 -6
- package/src/client/rpc-connection.ts +205 -0
- package/src/data/data-protocol-methods.ts +6 -3
- package/src/data/data-server-protocol.ts +29 -1
- package/src/data/events.ts +74 -3
- package/src/errors.ts +38 -14
- package/src/index.ts +4 -0
- package/src/messages/index.ts +35 -0
- package/src/messages/primitives.ts +215 -0
- package/src/model-server.ts +2 -2
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +14 -1
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +33 -17
- package/src/testing/index.ts +4 -1
- package/src/transfer-diagnostic.ts +40 -0
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,76 @@
|
|
|
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 } from '../data';
|
|
10
|
+
import type { TransferElement } from '../transfer-element';
|
|
11
|
+
import type { DataPort } from './data-port';
|
|
12
|
+
import { DataSession } from './data-session';
|
|
13
|
+
import { RpcConnection, type RpcConnectionLifecycle } from './rpc-connection';
|
|
14
|
+
/** Options for {@link DataConnection}. */
|
|
15
|
+
export interface DataConnectionOptions extends RpcConnectionLifecycle {
|
|
16
|
+
/**
|
|
17
|
+
* Wire namespace the server is addressed under. Defaults to the
|
|
18
|
+
* framework's {@link DATA_SERVER_WIRE_PREFIX}, which is what an unmodified
|
|
19
|
+
* `DataServer` binds. Override only alongside the server's own
|
|
20
|
+
* `methodNamespace` option — a mismatch turns every request into
|
|
21
|
+
* "Unhandled method" rather than failing at wire-up.
|
|
22
|
+
*/
|
|
23
|
+
readonly methodNamespace?: string;
|
|
24
|
+
}
|
|
25
|
+
/** {@link DataConnectionOptions} for a client that does not speak {@link DataClientProtocol}. */
|
|
26
|
+
export interface DataConnectionOptionsWithMethods<TClient extends object> extends DataConnectionOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Method names of the client to bind as inbound handlers. Declare it
|
|
29
|
+
* `as const satisfies ReadonlyArray<keyof YourClient & string>` so the list
|
|
30
|
+
* cannot drift from the interface.
|
|
31
|
+
*/
|
|
32
|
+
readonly clientMethods: readonly (keyof TClient & string)[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Trailing constructor arguments, required only when the client cannot take
|
|
36
|
+
* the framework's default method list.
|
|
37
|
+
*
|
|
38
|
+
* `bindRpcMethods` throws for a name the target does not implement, so a
|
|
39
|
+
* request/response-only client binding the default list fails at wire-up. The
|
|
40
|
+
* conditional turns that into a compile error.
|
|
41
|
+
*/
|
|
42
|
+
export type DataConnectionArgs<TTransfer extends TransferElement, TClient extends object> = TClient extends DataClientProtocol<TTransfer> ? [options?: DataConnectionOptions & Partial<DataConnectionOptionsWithMethods<TClient>>] : [options: DataConnectionOptionsWithMethods<TClient>];
|
|
43
|
+
/**
|
|
44
|
+
* A {@link RpcConnection} to the data head, carrying as many participants as
|
|
45
|
+
* the host has interested parties.
|
|
46
|
+
*
|
|
47
|
+
* Document operations live on the participants rather than here: they carry a
|
|
48
|
+
* `clientId`, which identifies a participant rather than a wire, and the server
|
|
49
|
+
* keys its holds and watches per `(uri, clientId)`. Two parties sharing one
|
|
50
|
+
* identity cannot tell each other's writes from their own echoes.
|
|
51
|
+
*
|
|
52
|
+
* Generic over the transfer root so this file names no grammar. An adopter
|
|
53
|
+
* binds the concrete root (or the union of them, for a multi-grammar head) at
|
|
54
|
+
* its own edge.
|
|
55
|
+
*/
|
|
56
|
+
export declare class DataConnection<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer> = DataServerProtocol<TTransfer>, TClient extends object = DataClientProtocol<TTransfer>> extends RpcConnection<TServer, TClient> {
|
|
57
|
+
protected readonly sessions: Set<DataSession<TTransfer, TServer>>;
|
|
58
|
+
constructor(port: DataPort, client: TClient, ...rest: DataConnectionArgs<TTransfer, TClient>);
|
|
59
|
+
/**
|
|
60
|
+
* Mint a participant on this connection under `clientId`.
|
|
61
|
+
*
|
|
62
|
+
* `clientId` must be distinct per participant and stable for its lifetime:
|
|
63
|
+
* it keys the server's per-`(uri, clientId)` hold and watch, and it is the
|
|
64
|
+
* echo key an inbound `onDocumentUpdated` is matched against. Avoid the
|
|
65
|
+
* three values the framework uses as sentinels — `'language-client'`,
|
|
66
|
+
* `'unknown'` and `'revert-on-close'`.
|
|
67
|
+
*/
|
|
68
|
+
createSession(clientId: string): DataSession<TTransfer, TServer>;
|
|
69
|
+
/**
|
|
70
|
+
* Sessions are detached rather than disposed: the server releases every hold
|
|
71
|
+
* on a connection it sees close, so closing each document first sends
|
|
72
|
+
* requests over a connection this call is about to dispose.
|
|
73
|
+
*/
|
|
74
|
+
dispose(): void;
|
|
75
|
+
}
|
|
76
|
+
//# 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;AAElF,OAAO,EAAyD,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAA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IAAI,EAAE,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC;IAY5F;;;;;;;;OAQG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC;IAUhE;;;;OAIG;IACM,OAAO,IAAI,IAAI;CAO1B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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.DataConnection = void 0;
|
|
12
|
+
const data_1 = require("../data");
|
|
13
|
+
const data_session_1 = require("./data-session");
|
|
14
|
+
const rpc_connection_1 = require("./rpc-connection");
|
|
15
|
+
/**
|
|
16
|
+
* A {@link RpcConnection} to the data head, carrying as many participants as
|
|
17
|
+
* the host has interested parties.
|
|
18
|
+
*
|
|
19
|
+
* Document operations live on the participants rather than here: they carry a
|
|
20
|
+
* `clientId`, which identifies a participant rather than a wire, and the server
|
|
21
|
+
* keys its holds and watches per `(uri, clientId)`. Two parties sharing one
|
|
22
|
+
* identity cannot tell each other's writes from their own echoes.
|
|
23
|
+
*
|
|
24
|
+
* Generic over the transfer root so this file names no grammar. An adopter
|
|
25
|
+
* binds the concrete root (or the union of them, for a multi-grammar head) at
|
|
26
|
+
* its own edge.
|
|
27
|
+
*/
|
|
28
|
+
class DataConnection extends rpc_connection_1.RpcConnection {
|
|
29
|
+
sessions = new Set();
|
|
30
|
+
constructor(port, client, ...rest) {
|
|
31
|
+
const [options = {}] = rest;
|
|
32
|
+
super(port, client, {
|
|
33
|
+
methodNamespace: options.methodNamespace ?? data_1.DATA_SERVER_WIRE_PREFIX,
|
|
34
|
+
// The default is reachable only where `TClient` satisfies
|
|
35
|
+
// `DataClientProtocol`, which the constructor's conditional enforces;
|
|
36
|
+
// the compiler cannot carry that through to the generic parameter.
|
|
37
|
+
clientMethods: options.clientMethods ?? data_1.DATA_CLIENT_PROTOCOL_METHODS,
|
|
38
|
+
lifecycle: options
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Mint a participant on this connection under `clientId`.
|
|
43
|
+
*
|
|
44
|
+
* `clientId` must be distinct per participant and stable for its lifetime:
|
|
45
|
+
* it keys the server's per-`(uri, clientId)` hold and watch, and it is the
|
|
46
|
+
* echo key an inbound `onDocumentUpdated` is matched against. Avoid the
|
|
47
|
+
* three values the framework uses as sentinels — `'language-client'`,
|
|
48
|
+
* `'unknown'` and `'revert-on-close'`.
|
|
49
|
+
*/
|
|
50
|
+
createSession(clientId) {
|
|
51
|
+
this.assertLive();
|
|
52
|
+
const session = new data_session_1.DataSession(clientId, {
|
|
53
|
+
connected: () => this.connected(),
|
|
54
|
+
releaseSession: released => this.sessions.delete(released)
|
|
55
|
+
});
|
|
56
|
+
this.sessions.add(session);
|
|
57
|
+
return session;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sessions are detached rather than disposed: the server releases every hold
|
|
61
|
+
* on a connection it sees close, so closing each document first sends
|
|
62
|
+
* requests over a connection this call is about to dispose.
|
|
63
|
+
*/
|
|
64
|
+
dispose() {
|
|
65
|
+
for (const session of [...this.sessions]) {
|
|
66
|
+
session.detach();
|
|
67
|
+
}
|
|
68
|
+
this.sessions.clear();
|
|
69
|
+
super.dispose();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.DataConnection = DataConnection;
|
|
73
|
+
//# 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;;;;;;;kFA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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,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EACT,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,UAAU,CACpB,SAAS,SAA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AI;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,14 +7,18 @@
|
|
|
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
|
|
@@ -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"}
|
|
@@ -6,81 +6,52 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import type {
|
|
10
|
-
import
|
|
11
|
-
import { type RpcProxy } from '../rpc';
|
|
9
|
+
import type { DataServerProtocol, TransferSaveDocumentArgs, TransferUpdateDocumentArgs } from '../data';
|
|
10
|
+
import type { RpcProxy } from '../rpc';
|
|
12
11
|
import type { TransferDocument } from '../transfer-document';
|
|
13
12
|
import type { TransferElement } from '../transfer-element';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
/** One connection generation: its connection, its proxy, and its readiness. */
|
|
27
|
-
interface Generation<TTransfer extends TransferElement> {
|
|
28
|
-
readonly connection: Promise<MessageConnection>;
|
|
29
|
-
readonly server: RpcProxy<DataServerProtocol<TTransfer>>;
|
|
30
|
-
/** Set on first use; the shared readiness gate for this generation. */
|
|
31
|
-
ready?: Promise<void>;
|
|
32
|
-
}
|
|
13
|
+
/** Update a document through a session; the session supplies `clientId`. */
|
|
14
|
+
export type DataSessionUpdateArgs<TTransfer> = Omit<TransferUpdateDocumentArgs<TTransfer>, 'clientId'>;
|
|
15
|
+
/** Persist a document through a session; the session supplies `clientId`. */
|
|
16
|
+
export type DataSessionSaveArgs<TTransfer> = Omit<TransferSaveDocumentArgs<TTransfer>, 'clientId'>;
|
|
33
17
|
/**
|
|
34
|
-
*
|
|
35
|
-
* {@link DataPort} that would otherwise be re-derived by every host
|
|
36
|
-
* adapter.
|
|
18
|
+
* What a {@link DataSession} needs from the connection that minted it.
|
|
37
19
|
*
|
|
38
|
-
*
|
|
20
|
+
* Narrower than the connection itself so the dependency points one way:
|
|
21
|
+
* `DataConnection` constructs sessions, and nothing here imports it back.
|
|
22
|
+
*/
|
|
23
|
+
export interface DataSessionHost<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer>> {
|
|
24
|
+
connected(): Promise<RpcProxy<TServer>>;
|
|
25
|
+
releaseSession(session: DataSession<TTransfer, TServer>): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One participant on a data connection: a properties panel, a tree, a
|
|
29
|
+
* form editor.
|
|
39
30
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* workspace walk finishes, and an early request is then answered correctly
|
|
45
|
-
* from an empty registry, which reads as a broken project tier rather than
|
|
46
|
-
* as a race.
|
|
47
|
-
* 3. **Own the reconnect policy**, by dropping its connection generation when
|
|
48
|
-
* the port disposes and building a fresh one on the next request.
|
|
31
|
+
* The server keys every hold and watch per `(uri, clientId)`, so the identity
|
|
32
|
+
* belongs to the participant rather than to the wire — several sessions share
|
|
33
|
+
* one connection, and two participants forced to share one identity cannot
|
|
34
|
+
* distinguish each other's writes from their own echoes.
|
|
49
35
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* its own doc.
|
|
36
|
+
* Every document operation stamps {@link clientId} itself. A caller that
|
|
37
|
+
* passed its own could pass another participant's, and the server would
|
|
38
|
+
* attribute the write and release the hold accordingly.
|
|
54
39
|
*
|
|
55
|
-
* Generic over the transfer root so this file names no grammar.
|
|
56
|
-
* binds the concrete root (or the union of them, for a multi-grammar head) at
|
|
57
|
-
* its own edge.
|
|
40
|
+
* Generic over the transfer root so this file names no grammar.
|
|
58
41
|
*/
|
|
59
|
-
export declare class DataSession<TTransfer extends TransferElement> {
|
|
60
|
-
|
|
61
|
-
protected readonly
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
protected generation?: Generation<TTransfer>;
|
|
42
|
+
export declare class DataSession<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer> = DataServerProtocol<TTransfer>> {
|
|
43
|
+
readonly clientId: string;
|
|
44
|
+
protected readonly host: DataSessionHost<TTransfer, TServer>;
|
|
45
|
+
/** URIs this session holds open, so {@link dispose} can release exactly those. */
|
|
46
|
+
protected readonly openUris: Set<string>;
|
|
65
47
|
protected disposed: boolean;
|
|
66
|
-
|
|
67
|
-
dispose(): void;
|
|
68
|
-
};
|
|
69
|
-
constructor(port: DataPort, client: DataClientProtocol<TTransfer>, options?: DataSessionOptions);
|
|
70
|
-
/** The identity every request is made under — the port's, not a second one. */
|
|
71
|
-
get clientId(): string;
|
|
48
|
+
constructor(clientId: string, host: DataSessionHost<TTransfer, TServer>);
|
|
72
49
|
/**
|
|
73
|
-
* The connected, READY server proxy
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* proxy, so a caller that cached one from an earlier call would go on
|
|
77
|
-
* addressing a dead connection with no error — handing it back per call
|
|
78
|
-
* makes the stale reference unrepresentable.
|
|
79
|
-
*
|
|
80
|
-
* Concurrent callers share one readiness promise, so `waitForReady` is
|
|
81
|
-
* awaited once per generation and not once per caller.
|
|
50
|
+
* The connected, READY server proxy, for protocol methods this session does
|
|
51
|
+
* not wrap — the ones carrying no `clientId`, so no identity can be got
|
|
52
|
+
* wrong through them.
|
|
82
53
|
*/
|
|
83
|
-
connected(): Promise<RpcProxy<
|
|
54
|
+
connected(): Promise<RpcProxy<TServer>>;
|
|
84
55
|
/**
|
|
85
56
|
* Open `uri` for editing and start watching it, in that order, returning
|
|
86
57
|
* the opened snapshot.
|
|
@@ -105,25 +76,36 @@ export declare class DataSession<TTransfer extends TransferElement> {
|
|
|
105
76
|
* {@link openDocument} and needs no separate unwatch.
|
|
106
77
|
*/
|
|
107
78
|
closeDocument(uri: string): Promise<void>;
|
|
79
|
+
/** Write `args.model` back as this session. */
|
|
80
|
+
updateDocument(args: DataSessionUpdateArgs<TTransfer>): Promise<TransferDocument<TTransfer>>;
|
|
81
|
+
/** Persist `args.model` to disk as this session. */
|
|
82
|
+
saveDocument(args: DataSessionSaveArgs<TTransfer>): Promise<TransferDocument<TTransfer>>;
|
|
108
83
|
/**
|
|
109
|
-
* Whether `
|
|
84
|
+
* Whether `sourceClientId` identifies this session's own write.
|
|
110
85
|
*
|
|
111
86
|
* Every watcher needs this and the check is one comparison, so getting it
|
|
112
87
|
* wrong is cheap to do and expensive to find: an unfiltered echo looks
|
|
113
88
|
* exactly like a concurrent third-party edit.
|
|
114
89
|
*/
|
|
115
90
|
isOwnEcho(sourceClientId: string): boolean;
|
|
116
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Release this session's holds and detach it from the connection.
|
|
93
|
+
* Idempotent, and leaves the connection usable by its other sessions.
|
|
94
|
+
*
|
|
95
|
+
* The closes are fired without being awaited, because a `Disposable` cannot
|
|
96
|
+
* be: a host disposing a widget has nowhere to put the promise. A close
|
|
97
|
+
* that fails is no worse than the leak this exists to prevent, so the
|
|
98
|
+
* rejection is swallowed rather than surfaced from a teardown.
|
|
99
|
+
*/
|
|
117
100
|
dispose(): void;
|
|
118
|
-
/** The live generation, building one if there is none. */
|
|
119
|
-
protected currentGeneration(): Generation<TTransfer>;
|
|
120
|
-
/** Await the connection and the server's startup gate for one generation. */
|
|
121
|
-
protected awaitReady(generation: Generation<TTransfer>): Promise<void>;
|
|
122
101
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
102
|
+
* Come off the connection because it is going away.
|
|
103
|
+
*
|
|
104
|
+
* Sends no close, unlike {@link dispose}: the server releases every hold on
|
|
105
|
+
* a connection it sees close, and the close would travel over the very
|
|
106
|
+
* connection being disposed.
|
|
125
107
|
*/
|
|
126
|
-
|
|
108
|
+
detach(): void;
|
|
109
|
+
protected assertLive(): void;
|
|
127
110
|
}
|
|
128
|
-
export {};
|
|
129
111
|
//# sourceMappingURL=data-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-session.d.ts","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"data-session.d.ts","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":"AAAA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