@hydranium/protocol 1.0.0-next.9 → 1.0.0-next.91

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.
Files changed (124) hide show
  1. package/README.md +35 -1
  2. package/lib/client/data-connection.d.ts +114 -0
  3. package/lib/client/data-connection.d.ts.map +1 -0
  4. package/lib/client/data-connection.js +128 -0
  5. package/lib/client/data-connection.js.map +1 -0
  6. package/lib/client/data-events.d.ts +9 -1
  7. package/lib/client/data-events.d.ts.map +1 -1
  8. package/lib/client/data-events.js +14 -0
  9. package/lib/client/data-events.js.map +1 -1
  10. package/lib/client/data-port.d.ts +17 -22
  11. package/lib/client/data-port.d.ts.map +1 -1
  12. package/lib/client/data-session.d.ts +95 -78
  13. package/lib/client/data-session.d.ts.map +1 -1
  14. package/lib/client/data-session.js +115 -108
  15. package/lib/client/data-session.js.map +1 -1
  16. package/lib/client/index.d.ts +10 -7
  17. package/lib/client/index.d.ts.map +1 -1
  18. package/lib/client/index.js +10 -7
  19. package/lib/client/index.js.map +1 -1
  20. package/lib/client/message-relay.d.ts +8 -2
  21. package/lib/client/message-relay.d.ts.map +1 -1
  22. package/lib/client/message-relay.js +10 -4
  23. package/lib/client/message-relay.js.map +1 -1
  24. package/lib/client/rpc-connection.d.ts +139 -0
  25. package/lib/client/rpc-connection.d.ts.map +1 -0
  26. package/lib/client/rpc-connection.js +171 -0
  27. package/lib/client/rpc-connection.js.map +1 -0
  28. package/lib/client-ids.d.ts +41 -0
  29. package/lib/client-ids.d.ts.map +1 -0
  30. package/lib/client-ids.js +44 -0
  31. package/lib/client-ids.js.map +1 -0
  32. package/lib/data/data-protocol-methods.d.ts +2 -2
  33. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  34. package/lib/data/data-protocol-methods.js +6 -1
  35. package/lib/data/data-protocol-methods.js.map +1 -1
  36. package/lib/data/data-server-protocol.d.ts +35 -2
  37. package/lib/data/data-server-protocol.d.ts.map +1 -1
  38. package/lib/data/events.d.ts +70 -3
  39. package/lib/data/events.d.ts.map +1 -1
  40. package/lib/errors.d.ts +28 -11
  41. package/lib/errors.d.ts.map +1 -1
  42. package/lib/errors.js +35 -17
  43. package/lib/errors.js.map +1 -1
  44. package/lib/index.d.ts +2 -0
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/index.js +5 -0
  47. package/lib/index.js.map +1 -1
  48. package/lib/messages/index.d.ts +28 -0
  49. package/lib/messages/index.d.ts.map +1 -0
  50. package/lib/messages/index.js +52 -0
  51. package/lib/messages/index.js.map +1 -0
  52. package/lib/messages/primitives.d.ts +141 -0
  53. package/lib/messages/primitives.d.ts.map +1 -0
  54. package/lib/messages/primitives.js +138 -0
  55. package/lib/messages/primitives.js.map +1 -0
  56. package/lib/model-server.d.ts +27 -10
  57. package/lib/model-server.d.ts.map +1 -1
  58. package/lib/model-server.js +4 -2
  59. package/lib/model-server.js.map +1 -1
  60. package/lib/model-service/args.d.ts +14 -13
  61. package/lib/model-service/args.d.ts.map +1 -1
  62. package/lib/model-service/based-on.d.ts +55 -0
  63. package/lib/model-service/based-on.d.ts.map +1 -0
  64. package/lib/model-service/based-on.js +34 -0
  65. package/lib/model-service/based-on.js.map +1 -0
  66. package/lib/model-service/index.d.ts +1 -0
  67. package/lib/model-service/index.d.ts.map +1 -1
  68. package/lib/model-service/index.js +1 -0
  69. package/lib/model-service/index.js.map +1 -1
  70. package/lib/rpc/bind-rpc-methods.d.ts +29 -3
  71. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  72. package/lib/rpc/bind-rpc-methods.js +22 -3
  73. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  74. package/lib/rpc/create-rpc-proxy.d.ts +7 -0
  75. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  76. package/lib/rpc/create-rpc-proxy.js +6 -1
  77. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  78. package/lib/testing/catalogue-audit.d.ts +80 -0
  79. package/lib/testing/catalogue-audit.d.ts.map +1 -0
  80. package/lib/testing/catalogue-audit.js +94 -0
  81. package/lib/testing/catalogue-audit.js.map +1 -0
  82. package/lib/testing/data-doubles.d.ts +11 -12
  83. package/lib/testing/data-doubles.d.ts.map +1 -1
  84. package/lib/testing/data-doubles.js +14 -5
  85. package/lib/testing/data-doubles.js.map +1 -1
  86. package/lib/testing/index.d.ts +1 -0
  87. package/lib/testing/index.d.ts.map +1 -1
  88. package/lib/testing/index.js +4 -1
  89. package/lib/testing/index.js.map +1 -1
  90. package/lib/transfer-diagnostic.d.ts +33 -0
  91. package/lib/transfer-diagnostic.d.ts.map +1 -1
  92. package/lib/transfer-diagnostic.js +23 -0
  93. package/lib/transfer-diagnostic.js.map +1 -1
  94. package/lib/transfer-document.d.ts +15 -5
  95. package/lib/transfer-document.d.ts.map +1 -1
  96. package/lib/transfer-document.js +14 -1
  97. package/lib/transfer-document.js.map +1 -1
  98. package/package.json +11 -2
  99. package/src/client/data-connection.ts +181 -0
  100. package/src/client/data-events.ts +24 -1
  101. package/src/client/data-port.ts +17 -23
  102. package/src/client/data-session.ts +172 -131
  103. package/src/client/index.ts +10 -7
  104. package/src/client/message-relay.ts +28 -6
  105. package/src/client/rpc-connection.ts +230 -0
  106. package/src/client-ids.ts +45 -0
  107. package/src/data/data-protocol-methods.ts +6 -3
  108. package/src/data/data-server-protocol.ts +46 -2
  109. package/src/data/events.ts +74 -3
  110. package/src/errors.ts +41 -19
  111. package/src/index.ts +5 -0
  112. package/src/messages/index.ts +35 -0
  113. package/src/messages/primitives.ts +215 -0
  114. package/src/model-server.ts +30 -11
  115. package/src/model-service/args.ts +15 -13
  116. package/src/model-service/based-on.ts +60 -0
  117. package/src/model-service/index.ts +1 -0
  118. package/src/rpc/bind-rpc-methods.ts +49 -4
  119. package/src/rpc/create-rpc-proxy.ts +14 -1
  120. package/src/testing/catalogue-audit.ts +111 -0
  121. package/src/testing/data-doubles.ts +33 -17
  122. package/src/testing/index.ts +4 -1
  123. package/src/transfer-diagnostic.ts +40 -0
  124. 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 and waiters
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,114 @@
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
+ constructor(port: DataPort, client: TClient, ...rest: DataConnectionArgs<TTransfer, TClient>);
60
+ /**
61
+ * Mint a participant on this connection under `clientId`.
62
+ *
63
+ * `clientId` must be distinct per participant and stable for its lifetime:
64
+ * it keys the server's per-`(uri, clientId)` hold and watch, and it is the
65
+ * echo key an inbound `onDocumentUpdated` is matched against.
66
+ *
67
+ * Throws for an id in {@link FRAMEWORK_CLIENT_IDS} — those are authors the
68
+ * SERVER emits rather than participants, so a session holding one would read
69
+ * the framework's own broadcasts as its own echoes and drop them. Nothing
70
+ * about that fails on its own: the document simply stops following, which
71
+ * looks like a dead connection.
72
+ *
73
+ * Throws, too, for an id a LIVE session on this connection already holds.
74
+ * Per-document membership is a set of client ids, so two participants
75
+ * sharing one collapse to a single hold and the first close releases it
76
+ * under the survivor, which then stops receiving updates for a document it
77
+ * is still showing. A constant bound once per participant KIND — one per
78
+ * widget class rather than per instance — satisfies the type and violates
79
+ * this.
80
+ *
81
+ * The check spans this connection only, so a head several connections reach
82
+ * can still be addressed twice under one id.
83
+ */
84
+ createSession(clientId: string): DataSession<TTransfer, TServer>;
85
+ /**
86
+ * Sessions are detached rather than disposed: the server releases every hold
87
+ * on a connection it sees close, so closing each document first sends
88
+ * requests over a connection this call is about to dispose.
89
+ */
90
+ dispose(): void;
91
+ }
92
+ /**
93
+ * A {@link DataConnection} that brings its own {@link DataEvents}, so a host
94
+ * with several interested parties does not have to supply one.
95
+ *
96
+ * **The client slot holds exactly one object, and that is why this exists.**
97
+ * `createRpcProxy` binds a single `localTarget`, and underneath a method name
98
+ * maps to one handler — a second registration replaces the first silently. So a
99
+ * properties panel and a tree cannot both be the client; one fan-out sits in the
100
+ * slot and both subscribe to it.
101
+ *
102
+ * Use {@link DataConnection} directly instead when the client is yours: an
103
+ * adopter service that implements the protocol plus its own methods, a single
104
+ * consumer that IS the client, or a request/response-only client that binds
105
+ * nothing.
106
+ */
107
+ 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>>> {
108
+ /** Server pushes, fanned out to as many local listeners as the host has. */
109
+ readonly events: DataEvents<TTransfer, DiagnosticOf<TServer>, ProjectOf<TServer>>;
110
+ constructor(port: DataPort, options?: DataConnectionOptions);
111
+ /** Disposes the fan-out it created, which no caller else holds. */
112
+ dispose(): void;
113
+ }
114
+ //# 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,CA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8C;gBAE7D,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC;IAY5F;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC;IAgBhE;;;;OAIG;IACM,OAAO,IAAI,IAAI;CAO1B;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,128 @@
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
+ constructor(port, client, ...rest) {
33
+ const [options = {}] = rest;
34
+ super(port, client, {
35
+ methodNamespace: options.methodNamespace ?? data_1.DATA_SERVER_WIRE_PREFIX,
36
+ // The default is reachable only where `TClient` satisfies
37
+ // `DataClientProtocol`, which the constructor's conditional enforces;
38
+ // the compiler cannot carry that through to the generic parameter.
39
+ clientMethods: options.clientMethods ?? data_1.DATA_CLIENT_PROTOCOL_METHODS,
40
+ lifecycle: options
41
+ });
42
+ }
43
+ /**
44
+ * Mint a participant on this connection under `clientId`.
45
+ *
46
+ * `clientId` must be distinct per participant and stable for its lifetime:
47
+ * it keys the server's per-`(uri, clientId)` hold and watch, and it is the
48
+ * echo key an inbound `onDocumentUpdated` is matched against.
49
+ *
50
+ * Throws for an id in {@link FRAMEWORK_CLIENT_IDS} — those are authors the
51
+ * SERVER emits rather than participants, so a session holding one would read
52
+ * the framework's own broadcasts as its own echoes and drop them. Nothing
53
+ * about that fails on its own: the document simply stops following, which
54
+ * looks like a dead connection.
55
+ *
56
+ * Throws, too, for an id a LIVE session on this connection already holds.
57
+ * Per-document membership is a set of client ids, so two participants
58
+ * sharing one collapse to a single hold and the first close releases it
59
+ * under the survivor, which then stops receiving updates for a document it
60
+ * is still showing. A constant bound once per participant KIND — one per
61
+ * widget class rather than per instance — satisfies the type and violates
62
+ * this.
63
+ *
64
+ * The check spans this connection only, so a head several connections reach
65
+ * can still be addressed twice under one id.
66
+ */
67
+ createSession(clientId) {
68
+ this.assertLive();
69
+ if (client_ids_1.FRAMEWORK_CLIENT_IDS.includes(clientId)) {
70
+ throw new Error(`clientId '${clientId}' is reserved by the framework and cannot identify a participant`);
71
+ }
72
+ if ([...this.sessions].some(session => session.clientId === clientId)) {
73
+ throw new Error(`clientId '${clientId}' already identifies a live participant on this connection`);
74
+ }
75
+ const session = new data_session_1.DataSession(clientId, {
76
+ connected: () => this.connected(),
77
+ releaseSession: released => this.sessions.delete(released)
78
+ });
79
+ this.sessions.add(session);
80
+ return session;
81
+ }
82
+ /**
83
+ * Sessions are detached rather than disposed: the server releases every hold
84
+ * on a connection it sees close, so closing each document first sends
85
+ * requests over a connection this call is about to dispose.
86
+ */
87
+ dispose() {
88
+ for (const session of [...this.sessions]) {
89
+ session.detach();
90
+ }
91
+ this.sessions.clear();
92
+ super.dispose();
93
+ }
94
+ }
95
+ exports.DataConnection = DataConnection;
96
+ /**
97
+ * A {@link DataConnection} that brings its own {@link DataEvents}, so a host
98
+ * with several interested parties does not have to supply one.
99
+ *
100
+ * **The client slot holds exactly one object, and that is why this exists.**
101
+ * `createRpcProxy` binds a single `localTarget`, and underneath a method name
102
+ * maps to one handler — a second registration replaces the first silently. So a
103
+ * properties panel and a tree cannot both be the client; one fan-out sits in the
104
+ * slot and both subscribe to it.
105
+ *
106
+ * Use {@link DataConnection} directly instead when the client is yours: an
107
+ * adopter service that implements the protocol plus its own methods, a single
108
+ * consumer that IS the client, or a request/response-only client that binds
109
+ * nothing.
110
+ */
111
+ class DataConnectionWithEvents extends DataConnection {
112
+ /** Server pushes, fanned out to as many local listeners as the host has. */
113
+ events;
114
+ constructor(port, options) {
115
+ // Built as a local because `this` is unavailable before `super`, then
116
+ // read back onto the field.
117
+ const events = new data_events_1.DataEvents();
118
+ super(port, events, options);
119
+ this.events = events;
120
+ }
121
+ /** Disposes the fan-out it created, which no caller else holds. */
122
+ dispose() {
123
+ super.dispose();
124
+ this.events.dispose();
125
+ }
126
+ }
127
+ exports.DataConnectionWithEvents = DataConnectionWithEvents;
128
+ //# 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,8CAAqD;AACrD,kCAOiB;AAEjB,+CAA2C;AAE3C,iDAA6C;AAC7C,qDAA8E;AAqC9E;;;;;;;;;;;;GAYG;AACH,MAAa,cAIX,SAAQ,8BAA+B;IACnB,QAAQ,GAAG,IAAI,GAAG,EAAmC,CAAC;IAEzE,YAAY,IAAc,EAAE,MAAe,EAAE,GAAG,IAA4C;QACzF,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,IAAuF,CAAC;QAC/G,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE;YACjB,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,8BAAuB;YACnE,0DAA0D;YAC1D,sEAAsE;YACtE,mEAAmE;YACnE,aAAa,EAAE,OAAO,CAAC,aAAa,IAAK,mCAA+E;YACxH,SAAS,EAAE,OAAO;SACpB,CAAC,CAAC;IACN,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,aAAa,CAAC,QAAgB;QAC3B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,iCAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,kEAAkE,CAAC,CAAC;QAC5G,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,4DAA4D,CAAC,CAAC;QACtG,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,0BAAW,CAAqB,QAAQ,EAAE;YAC3D,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE;YACjC,cAAc,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC5D,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,OAAO,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACM,OAAO;QACb,KAAK,MAAM,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;CACH;AAvED,wCAuEC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAa,wBAGX,SAAQ,cAAoG;IAC3G,4EAA4E;IACnE,MAAM,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,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAClI,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,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,QAAQ,SAAS,OAAO,GAAG,OAAO,CACnC,YAAW,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC;IAC9D,SAAS,CAAC,QAAQ,CAAC,sBAAsB,gEAAuE;IAChH,SAAS,CAAC,QAAQ,CAAC,oBAAoB,8DAAqE;IAC5G,SAAS,CAAC,QAAQ,CAAC,sBAAsB,0CAAiD;IAE1F,4FAA4F;IAC5F,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAqC;IAC9H,gDAAgD;IAChD,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAmC;IACxH,+BAA+B;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAA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QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAqC;IAC9H,gDAAgD;IAChD,QAAQ,CAAC,iBAAiB,EAAE,KAAK,CAAC,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAmC;IACxH,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;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;AAMrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,UAAU;IAKD,sBAAsB,GAAG,IAAI,wBAAO,EAAwD,CAAC;IAC7F,oBAAoB,GAAG,IAAI,wBAAO,EAAsD,CAAC;IACzF,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,+BAA+B;IACtB,mBAAmB,GAA0C,IAAI,CAAC,sBAAs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AC;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 identity and failure sink that go
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, `DataSession`
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, `baseVersion`
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. `context` names what was being
77
- * attempted, not where in the code it happened.
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, context: string): void;
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;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,QAAQ;IACtB;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;;;;OAOG;IACH,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC;;;;;;;;OAQG;IACH,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnD;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAClC"}
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"}