@hydranium/protocol 1.0.0-next.16 → 1.0.0-next.160

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 (177) hide show
  1. package/README.md +35 -1
  2. package/lib/client/data-connection.d.ts +157 -0
  3. package/lib/client/data-connection.d.ts.map +1 -0
  4. package/lib/client/data-connection.js +236 -0
  5. package/lib/client/data-connection.js.map +1 -0
  6. package/lib/client/data-events.d.ts +13 -1
  7. package/lib/client/data-events.d.ts.map +1 -1
  8. package/lib/client/data-events.js +21 -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 +440 -78
  13. package/lib/client/data-session.d.ts.map +1 -1
  14. package/lib/client/data-session.js +697 -106
  15. package/lib/client/data-session.js.map +1 -1
  16. package/lib/client/index.d.ts +13 -8
  17. package/lib/client/index.d.ts.map +1 -1
  18. package/lib/client/index.js +13 -8
  19. package/lib/client/index.js.map +1 -1
  20. package/lib/client/message-relay.d.ts +9 -3
  21. package/lib/client/message-relay.d.ts.map +1 -1
  22. package/lib/client/message-relay.js +11 -5
  23. package/lib/client/message-relay.js.map +1 -1
  24. package/lib/client/post-message-transport.d.ts +64 -3
  25. package/lib/client/post-message-transport.d.ts.map +1 -1
  26. package/lib/client/post-message-transport.js +175 -1
  27. package/lib/client/post-message-transport.js.map +1 -1
  28. package/lib/client/rpc-connection.d.ts +149 -0
  29. package/lib/client/rpc-connection.d.ts.map +1 -0
  30. package/lib/client/rpc-connection.js +179 -0
  31. package/lib/client/rpc-connection.js.map +1 -0
  32. package/lib/client-ids.d.ts +45 -0
  33. package/lib/client-ids.d.ts.map +1 -0
  34. package/lib/client-ids.js +48 -0
  35. package/lib/client-ids.js.map +1 -0
  36. package/lib/clock.d.ts +38 -0
  37. package/lib/clock.d.ts.map +1 -1
  38. package/lib/clock.js +36 -1
  39. package/lib/clock.js.map +1 -1
  40. package/lib/data/data-protocol-methods.d.ts +4 -4
  41. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  42. package/lib/data/data-protocol-methods.js +11 -1
  43. package/lib/data/data-protocol-methods.js.map +1 -1
  44. package/lib/data/data-server-protocol.d.ts +111 -31
  45. package/lib/data/data-server-protocol.d.ts.map +1 -1
  46. package/lib/data/events.d.ts +103 -14
  47. package/lib/data/events.d.ts.map +1 -1
  48. package/lib/data/requests.d.ts +67 -11
  49. package/lib/data/requests.d.ts.map +1 -1
  50. package/lib/errors.d.ts +163 -17
  51. package/lib/errors.d.ts.map +1 -1
  52. package/lib/errors.js +219 -22
  53. package/lib/errors.js.map +1 -1
  54. package/lib/glsp-save-model-actions.d.ts +50 -0
  55. package/lib/glsp-save-model-actions.d.ts.map +1 -0
  56. package/lib/glsp-save-model-actions.js +28 -0
  57. package/lib/glsp-save-model-actions.js.map +1 -0
  58. package/lib/index.d.ts +3 -0
  59. package/lib/index.d.ts.map +1 -1
  60. package/lib/index.js +6 -0
  61. package/lib/index.js.map +1 -1
  62. package/lib/latency-collector.d.ts +8 -4
  63. package/lib/latency-collector.d.ts.map +1 -1
  64. package/lib/latency-collector.js.map +1 -1
  65. package/lib/messages/index.d.ts +29 -0
  66. package/lib/messages/index.d.ts.map +1 -0
  67. package/lib/messages/index.js +58 -0
  68. package/lib/messages/index.js.map +1 -0
  69. package/lib/messages/primitives.d.ts +188 -0
  70. package/lib/messages/primitives.d.ts.map +1 -0
  71. package/lib/messages/primitives.js +161 -0
  72. package/lib/messages/primitives.js.map +1 -0
  73. package/lib/model-server.d.ts +60 -13
  74. package/lib/model-server.d.ts.map +1 -1
  75. package/lib/model-server.js +4 -2
  76. package/lib/model-server.js.map +1 -1
  77. package/lib/model-service/based-on.d.ts +57 -0
  78. package/lib/model-service/based-on.d.ts.map +1 -0
  79. package/lib/model-service/based-on.js +37 -0
  80. package/lib/model-service/based-on.js.map +1 -0
  81. package/lib/model-service/index.d.ts +1 -1
  82. package/lib/model-service/index.d.ts.map +1 -1
  83. package/lib/model-service/index.js +4 -5
  84. package/lib/model-service/index.js.map +1 -1
  85. package/lib/patch-merge.d.ts +28 -27
  86. package/lib/patch-merge.d.ts.map +1 -1
  87. package/lib/patch-merge.js +66 -22
  88. package/lib/patch-merge.js.map +1 -1
  89. package/lib/profile-session.d.ts +8 -4
  90. package/lib/profile-session.d.ts.map +1 -1
  91. package/lib/profile-session.js.map +1 -1
  92. package/lib/rpc/bind-rpc-methods.d.ts +29 -3
  93. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  94. package/lib/rpc/bind-rpc-methods.js +22 -3
  95. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  96. package/lib/rpc/create-rpc-proxy.d.ts +7 -0
  97. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  98. package/lib/rpc/create-rpc-proxy.js +6 -1
  99. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  100. package/lib/testing/catalogue-audit.d.ts +80 -0
  101. package/lib/testing/catalogue-audit.d.ts.map +1 -0
  102. package/lib/testing/catalogue-audit.js +94 -0
  103. package/lib/testing/catalogue-audit.js.map +1 -0
  104. package/lib/testing/data-doubles.d.ts +13 -12
  105. package/lib/testing/data-doubles.d.ts.map +1 -1
  106. package/lib/testing/data-doubles.js +19 -5
  107. package/lib/testing/data-doubles.js.map +1 -1
  108. package/lib/testing/fake-clock.d.ts +9 -1
  109. package/lib/testing/fake-clock.d.ts.map +1 -1
  110. package/lib/testing/fake-clock.js +54 -45
  111. package/lib/testing/fake-clock.js.map +1 -1
  112. package/lib/testing/index.d.ts +1 -0
  113. package/lib/testing/index.d.ts.map +1 -1
  114. package/lib/testing/index.js +4 -1
  115. package/lib/testing/index.js.map +1 -1
  116. package/lib/testing/node/index.d.ts +1 -0
  117. package/lib/testing/node/index.d.ts.map +1 -1
  118. package/lib/testing/node/index.js +2 -2
  119. package/lib/testing/node/index.js.map +1 -1
  120. package/lib/testing/node/message-port-pair.d.ts +25 -0
  121. package/lib/testing/node/message-port-pair.d.ts.map +1 -0
  122. package/lib/testing/node/message-port-pair.js +26 -0
  123. package/lib/testing/node/message-port-pair.js.map +1 -0
  124. package/lib/transfer-diagnostic.d.ts +33 -0
  125. package/lib/transfer-diagnostic.d.ts.map +1 -1
  126. package/lib/transfer-diagnostic.js +23 -0
  127. package/lib/transfer-diagnostic.js.map +1 -1
  128. package/lib/transfer-document.d.ts +34 -5
  129. package/lib/transfer-document.d.ts.map +1 -1
  130. package/lib/transfer-document.js +14 -1
  131. package/lib/transfer-document.js.map +1 -1
  132. package/lib/util.d.ts +8 -0
  133. package/lib/util.d.ts.map +1 -1
  134. package/lib/util.js +32 -0
  135. package/lib/util.js.map +1 -1
  136. package/package.json +11 -2
  137. package/src/client/data-connection.ts +314 -0
  138. package/src/client/data-events.ts +33 -1
  139. package/src/client/data-port.ts +17 -23
  140. package/src/client/data-session.ts +880 -123
  141. package/src/client/index.ts +13 -8
  142. package/src/client/message-relay.ts +29 -7
  143. package/src/client/post-message-transport.ts +219 -4
  144. package/src/client/rpc-connection.ts +244 -0
  145. package/src/client-ids.ts +49 -0
  146. package/src/clock.ts +56 -0
  147. package/src/data/data-protocol-methods.ts +11 -3
  148. package/src/data/data-server-protocol.ts +132 -31
  149. package/src/data/events.ts +109 -14
  150. package/src/data/requests.ts +71 -11
  151. package/src/errors.ts +259 -24
  152. package/src/glsp-save-model-actions.ts +59 -0
  153. package/src/index.ts +6 -0
  154. package/src/latency-collector.ts +8 -3
  155. package/src/messages/index.ts +36 -0
  156. package/src/messages/primitives.ts +271 -0
  157. package/src/model-server.ts +63 -18
  158. package/src/model-service/based-on.ts +63 -0
  159. package/src/model-service/index.ts +4 -5
  160. package/src/patch-merge.ts +90 -37
  161. package/src/profile-session.ts +9 -4
  162. package/src/rpc/bind-rpc-methods.ts +49 -4
  163. package/src/rpc/create-rpc-proxy.ts +14 -1
  164. package/src/testing/catalogue-audit.ts +111 -0
  165. package/src/testing/data-doubles.ts +42 -17
  166. package/src/testing/fake-clock.ts +62 -47
  167. package/src/testing/index.ts +4 -1
  168. package/src/testing/node/index.ts +2 -2
  169. package/src/testing/node/message-port-pair.ts +40 -0
  170. package/src/transfer-diagnostic.ts +40 -0
  171. package/src/transfer-document.ts +41 -6
  172. package/src/util.ts +33 -0
  173. package/lib/model-service/args.d.ts +0 -64
  174. package/lib/model-service/args.d.ts.map +0 -1
  175. package/lib/model-service/args.js +0 -11
  176. package/lib/model-service/args.js.map +0 -1
  177. package/src/model-service/args.ts +0 -67
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,157 @@
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 { Emitter, type Event } from 'vscode-jsonrpc';
10
+ import { type DataClientProtocol, type DataServerProtocol, type DiagnosticOf, type ProjectOf, type TransferDocumentDirtyChangedEvent, type TransferDocumentUpdatedEvent } from '../data';
11
+ import type { TransferElement } from '../transfer-element';
12
+ import { DataEvents } from './data-events';
13
+ import type { DataPort } from './data-port';
14
+ import { DataSession, type DataSessionFactory } from './data-session';
15
+ import { RpcConnection, type RpcConnectionLifecycle } from './rpc-connection';
16
+ /** Options for {@link DataConnection}. */
17
+ export interface DataConnectionOptions<TTransfer extends TransferElement = TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> extends RpcConnectionLifecycle {
18
+ /**
19
+ * Wire namespace the server is addressed under. Defaults to the
20
+ * framework's {@link DATA_SERVER_WIRE_PREFIX}, which is what an unmodified
21
+ * `DataServer` binds. Override only alongside the server's own
22
+ * `methodNamespace` option — a mismatch turns every request into
23
+ * "Unhandled method" rather than failing at wire-up.
24
+ */
25
+ readonly methodNamespace?: string;
26
+ /** Builds the sessions `createSession` hands out. Defaults to a plain {@link DataSession}. */
27
+ readonly sessionFactory?: DataSessionFactory<TTransfer, TServer>;
28
+ }
29
+ /** {@link DataConnectionOptions} for a client that does not speak {@link DataClientProtocol}. */
30
+ export interface DataConnectionOptionsWithMethods<TClient extends object, TTransfer extends TransferElement = TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> extends DataConnectionOptions<TTransfer, TServer> {
31
+ /**
32
+ * Method names of the client to bind as inbound handlers. Declare it
33
+ * `as const satisfies ReadonlyArray<keyof YourClient & string>` so the list
34
+ * cannot drift from the interface.
35
+ */
36
+ readonly clientMethods: readonly (keyof TClient & string)[];
37
+ }
38
+ /**
39
+ * Trailing constructor arguments, required only when the client cannot take
40
+ * the framework's default method list.
41
+ *
42
+ * `bindRpcMethods` throws for a name the target does not implement, so a
43
+ * request/response-only client binding the default list fails at wire-up. The
44
+ * conditional turns that into a compile error.
45
+ */
46
+ export type DataConnectionArgs<TTransfer extends TransferElement, TClient extends object, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>> = TClient extends DataClientProtocol<TTransfer> ? [options?: DataConnectionOptions<TTransfer, TServer> & Partial<DataConnectionOptionsWithMethods<TClient, TTransfer, TServer>>] : [options: DataConnectionOptionsWithMethods<TClient, TTransfer, TServer>];
47
+ /**
48
+ * A {@link RpcConnection} to the data head, carrying as many participants as
49
+ * the host has interested parties.
50
+ *
51
+ * Document operations live on the participants rather than here: they carry a
52
+ * `clientId`, which identifies a participant rather than a wire, and the server
53
+ * keys its opens and watches per `(uri, clientId)`. Two parties sharing one
54
+ * identity cannot tell each other's writes from their own echoes.
55
+ *
56
+ * Generic over the transfer root so this file names no grammar. An adopter
57
+ * binds the concrete root (or the union of them, for a multi-grammar head) at
58
+ * its own edge.
59
+ */
60
+ export declare class DataConnection<TTransfer extends TransferElement, TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>, TClient extends object = DataClientProtocol<TTransfer>> extends RpcConnection<TServer, TClient> {
61
+ protected readonly sessions: Set<DataSession<TTransfer, TServer>>;
62
+ protected readonly sessionFactory: DataSessionFactory<TTransfer, TServer>;
63
+ protected readonly createSessionEmitter: Emitter<DataSession<TTransfer, TServer>>;
64
+ /**
65
+ * Fires with each session {@link createSession} starts, before it returns,
66
+ * so a listener sees every session a caller can. A session started before
67
+ * the listener subscribed is in {@link liveSessions}.
68
+ */
69
+ readonly onDidCreateSession: Event<DataSession<TTransfer, TServer>>;
70
+ /**
71
+ * Per URI, the `dirty` the client was last told since a session of this
72
+ * connection last opened the URI. A restore tells the client its answer
73
+ * only where it differs, so the client hears changes and nothing else; see
74
+ * {@link DataSessionHost.restoreDirty}.
75
+ */
76
+ protected readonly dirtyStates: Map<string, boolean>;
77
+ /** Backs each session's {@link DataSessionHost.onDidChangeDirty}. */
78
+ protected readonly dirtyChangedEmitter: Emitter<TransferDocumentDirtyChangedEvent>;
79
+ /** Backs each session's {@link DataSessionHost.onDidUpdateDocument}. */
80
+ protected readonly documentUpdatedEmitter: Emitter<TransferDocumentUpdatedEvent<TTransfer, DiagnosticOf<TServer>>>;
81
+ constructor(port: DataPort, client: TClient, ...rest: DataConnectionArgs<TTransfer, TClient, TServer>);
82
+ /**
83
+ * The sessions of this connection that have not ended, in the order they
84
+ * started. A session is listed until its `onDidDispose` fires, or until
85
+ * {@link dispose} clears the list.
86
+ */
87
+ get liveSessions(): readonly DataSession<TTransfer, TServer>[];
88
+ /**
89
+ * Start a participant on this connection, registered with the server under a
90
+ * fresh id, `label` plus `#` plus a random UUID, or under `clientId` when
91
+ * given. Pass a `label` naming the participant; without one it is
92
+ * `session`. Synchronous: the registration is sent at once, and the
93
+ * session's calls wait for it. The server refuses an id live anywhere in
94
+ * its process, and every call of that session then rejects with an error
95
+ * `isDuplicateClientIdError` recognises; an id the server reserves beyond
96
+ * {@link FRAMEWORK_CLIENT_IDS}, such as the integrity author, with one
97
+ * `isReservedClientIdError` recognises. Only the code crosses the wire, so
98
+ * test with those guards rather than `instanceof`.
99
+ *
100
+ * Throws a {@link ReservedClientIdError} for an id in
101
+ * {@link FRAMEWORK_CLIENT_IDS} — those are authors the SERVER emits rather
102
+ * than participants, so a session holding one would read the framework's
103
+ * own broadcasts as its own echoes and drop them — and a
104
+ * {@link DuplicateClientIdError} for an id a live session on this
105
+ * connection already holds.
106
+ */
107
+ createSession(label?: string, clientId?: string): DataSession<TTransfer, TServer>;
108
+ /**
109
+ * The client, with its `onDocumentDirtyChanged` passing through
110
+ * {@link deliverDirty} first, so {@link dirtyStates} holds what the server
111
+ * told it, and every session hears it through {@link dirtyChangedEmitter};
112
+ * and with its `onDocumentUpdated` heard by every session through
113
+ * {@link documentUpdatedEmitter} first. Every other bound method forwards
114
+ * to the client unchanged, and one the client lacks stays absent, so the
115
+ * binding still refuses it.
116
+ */
117
+ protected localTarget(): TClient;
118
+ /** Record `event` in {@link dirtyStates} and hand it to the client. */
119
+ protected deliverDirty(event: TransferDocumentDirtyChangedEvent): void;
120
+ /**
121
+ * After the transport dropped, reconnect on the next macrotask for the
122
+ * sessions with documents open, so they re-watch and follow their documents
123
+ * again without waiting for a call of their own; a session with nothing
124
+ * open restores on its next call. Nothing is scheduled once this connection
125
+ * is disposed, which drops its generation too.
126
+ */
127
+ protected dropGeneration(): void;
128
+ /**
129
+ * Sessions are detached rather than disposed: the server ends every session
130
+ * on a connection it sees close, so ending each one first sends requests
131
+ * over a connection this call is about to dispose.
132
+ */
133
+ dispose(): void;
134
+ }
135
+ /**
136
+ * A {@link DataConnection} that brings its own {@link DataEvents}, so a host
137
+ * with several interested parties does not have to supply one.
138
+ *
139
+ * **The client slot holds exactly one object, and that is why this exists.**
140
+ * `createRpcProxy` binds a single `localTarget`, and underneath a method name
141
+ * maps to one handler — a second registration replaces the first silently. So a
142
+ * properties panel and a tree cannot both be the client; one fan-out sits in the
143
+ * slot and both subscribe to it.
144
+ *
145
+ * Use {@link DataConnection} directly instead when the client is yours: an
146
+ * adopter service that implements the protocol plus its own methods, a single
147
+ * consumer that IS the client, or a request/response-only client that binds
148
+ * nothing.
149
+ */
150
+ 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>>> {
151
+ /** Server pushes, fanned out to as many local listeners as the host has. */
152
+ readonly events: DataEvents<TTransfer, DiagnosticOf<TServer>, ProjectOf<TServer>>;
153
+ constructor(port: DataPort, options?: DataConnectionOptions<TTransfer, TServer>);
154
+ /** Disposes the fan-out it created, which no caller else holds. */
155
+ dispose(): void;
156
+ }
157
+ //# 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,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAGJ,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,EACnC,MAAM,SAAS,CAAC;AAEjB,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,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,KAAK,sBAAsB,EAAE,MAAM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,EAAE,iCAAiC,GAAG,IAAI;IAMtE;;;;;;OAMG;cACgB,cAAc,IAAI,IAAI;IAYzC;;;;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,CAAC,SAAS,EAAE,OAAO,CAAC;IAQ/E,mEAAmE;IAC1D,OAAO,IAAI,IAAI;CAI1B"}
@@ -0,0 +1,236 @@
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 vscode_jsonrpc_1 = require("vscode-jsonrpc");
13
+ const client_ids_1 = require("../client-ids");
14
+ const data_1 = require("../data");
15
+ const errors_1 = require("../errors");
16
+ const data_events_1 = require("./data-events");
17
+ const data_session_1 = require("./data-session");
18
+ const rpc_connection_1 = require("./rpc-connection");
19
+ /**
20
+ * A {@link RpcConnection} to the data head, carrying as many participants as
21
+ * the host has interested parties.
22
+ *
23
+ * Document operations live on the participants rather than here: they carry a
24
+ * `clientId`, which identifies a participant rather than a wire, and the server
25
+ * keys its opens and watches per `(uri, clientId)`. Two parties sharing one
26
+ * identity cannot tell each other's writes from their own echoes.
27
+ *
28
+ * Generic over the transfer root so this file names no grammar. An adopter
29
+ * binds the concrete root (or the union of them, for a multi-grammar head) at
30
+ * its own edge.
31
+ */
32
+ class DataConnection extends rpc_connection_1.RpcConnection {
33
+ sessions = new Set();
34
+ sessionFactory;
35
+ createSessionEmitter = new vscode_jsonrpc_1.Emitter();
36
+ /**
37
+ * Fires with each session {@link createSession} starts, before it returns,
38
+ * so a listener sees every session a caller can. A session started before
39
+ * the listener subscribed is in {@link liveSessions}.
40
+ */
41
+ onDidCreateSession = this.createSessionEmitter.event;
42
+ /**
43
+ * Per URI, the `dirty` the client was last told since a session of this
44
+ * connection last opened the URI. A restore tells the client its answer
45
+ * only where it differs, so the client hears changes and nothing else; see
46
+ * {@link DataSessionHost.restoreDirty}.
47
+ */
48
+ dirtyStates = new Map();
49
+ /** Backs each session's {@link DataSessionHost.onDidChangeDirty}. */
50
+ dirtyChangedEmitter = new vscode_jsonrpc_1.Emitter();
51
+ /** Backs each session's {@link DataSessionHost.onDidUpdateDocument}. */
52
+ documentUpdatedEmitter = new vscode_jsonrpc_1.Emitter();
53
+ constructor(port, client, ...rest) {
54
+ const [options = {}] = rest;
55
+ super(port, client, {
56
+ methodNamespace: options.methodNamespace ?? data_1.DATA_SERVER_WIRE_PREFIX,
57
+ // The default is reachable only where `TClient` satisfies
58
+ // `DataClientProtocol`, which the constructor's conditional enforces;
59
+ // the compiler cannot carry that through to the generic parameter.
60
+ clientMethods: options.clientMethods ?? data_1.DATA_CLIENT_PROTOCOL_METHODS,
61
+ lifecycle: options
62
+ });
63
+ this.sessionFactory =
64
+ options.sessionFactory ?? ((clientId, host, label) => new data_session_1.DataSession(clientId, host, label));
65
+ }
66
+ /**
67
+ * The sessions of this connection that have not ended, in the order they
68
+ * started. A session is listed until its `onDidDispose` fires, or until
69
+ * {@link dispose} clears the list.
70
+ */
71
+ get liveSessions() {
72
+ return [...this.sessions];
73
+ }
74
+ /**
75
+ * Start a participant on this connection, registered with the server under a
76
+ * fresh id, `label` plus `#` plus a random UUID, or under `clientId` when
77
+ * given. Pass a `label` naming the participant; without one it is
78
+ * `session`. Synchronous: the registration is sent at once, and the
79
+ * session's calls wait for it. The server refuses an id live anywhere in
80
+ * its process, and every call of that session then rejects with an error
81
+ * `isDuplicateClientIdError` recognises; an id the server reserves beyond
82
+ * {@link FRAMEWORK_CLIENT_IDS}, such as the integrity author, with one
83
+ * `isReservedClientIdError` recognises. Only the code crosses the wire, so
84
+ * test with those guards rather than `instanceof`.
85
+ *
86
+ * Throws a {@link ReservedClientIdError} for an id in
87
+ * {@link FRAMEWORK_CLIENT_IDS} — those are authors the SERVER emits rather
88
+ * than participants, so a session holding one would read the framework's
89
+ * own broadcasts as its own echoes and drop them — and a
90
+ * {@link DuplicateClientIdError} for an id a live session on this
91
+ * connection already holds.
92
+ */
93
+ createSession(label = 'session', clientId) {
94
+ this.assertLive();
95
+ const id = clientId ?? `${label}#${globalThis.crypto.randomUUID()}`;
96
+ if (client_ids_1.FRAMEWORK_CLIENT_IDS.includes(id)) {
97
+ throw new errors_1.ReservedClientIdError(id);
98
+ }
99
+ if ([...this.sessions].some(session => session.clientId === id)) {
100
+ throw new errors_1.DuplicateClientIdError(id);
101
+ }
102
+ const session = this.sessionFactory(id, {
103
+ connected: () => this.connected(),
104
+ reportError: (error, reported) => this.reportError(error, reported),
105
+ restoreDirty: event => {
106
+ if (this.dirtyStates.get(event.uri) !== event.dirty) {
107
+ this.deliverDirty(event);
108
+ }
109
+ },
110
+ forgetDirty: uri => this.dirtyStates.delete(uri),
111
+ onDidChangeDirty: this.dirtyChangedEmitter.event,
112
+ onDidUpdateDocument: this.documentUpdatedEmitter.event
113
+ }, label);
114
+ this.sessions.add(session);
115
+ // Subscribed before the session is handed out, so the id is free again
116
+ // on this connection by the time any caller's listener runs.
117
+ session.onDidDispose(() => this.sessions.delete(session));
118
+ // A failure reaches the session's own calls, which wait for the same
119
+ // registration; caught here only so it is not also reported unhandled.
120
+ session.connected().catch(() => undefined);
121
+ this.createSessionEmitter.fire(session);
122
+ return session;
123
+ }
124
+ /**
125
+ * The client, with its `onDocumentDirtyChanged` passing through
126
+ * {@link deliverDirty} first, so {@link dirtyStates} holds what the server
127
+ * told it, and every session hears it through {@link dirtyChangedEmitter};
128
+ * and with its `onDocumentUpdated` heard by every session through
129
+ * {@link documentUpdatedEmitter} first. Every other bound method forwards
130
+ * to the client unchanged, and one the client lacks stays absent, so the
131
+ * binding still refuses it.
132
+ */
133
+ localTarget() {
134
+ const client = this.client;
135
+ const hearsDirty = typeof client.onDocumentDirtyChanged === 'function';
136
+ const hearsUpdates = typeof client.onDocumentUpdated === 'function';
137
+ if (!hearsDirty && !hearsUpdates) {
138
+ return this.client;
139
+ }
140
+ const target = {};
141
+ for (const name of this.clientMethods) {
142
+ const method = client[name];
143
+ if (typeof method === 'function') {
144
+ target[name] = (params) => method.call(client, params);
145
+ }
146
+ }
147
+ if (hearsDirty) {
148
+ target.onDocumentDirtyChanged = (event) => {
149
+ this.dirtyChangedEmitter.fire(event);
150
+ this.deliverDirty(event);
151
+ };
152
+ }
153
+ if (hearsUpdates) {
154
+ const forward = target.onDocumentUpdated;
155
+ target.onDocumentUpdated = (event) => {
156
+ this.documentUpdatedEmitter.fire(event);
157
+ forward(event);
158
+ };
159
+ }
160
+ return target;
161
+ }
162
+ /** Record `event` in {@link dirtyStates} and hand it to the client. */
163
+ deliverDirty(event) {
164
+ this.dirtyStates.set(event.uri, event.dirty);
165
+ const client = this.client;
166
+ client.onDocumentDirtyChanged?.(event);
167
+ }
168
+ /**
169
+ * After the transport dropped, reconnect on the next macrotask for the
170
+ * sessions with documents open, so they re-watch and follow their documents
171
+ * again without waiting for a call of their own; a session with nothing
172
+ * open restores on its next call. Nothing is scheduled once this connection
173
+ * is disposed, which drops its generation too.
174
+ */
175
+ dropGeneration() {
176
+ const dropped = this.generation !== undefined;
177
+ super.dropGeneration();
178
+ if (dropped && !this.disposed) {
179
+ setTimeout(() => {
180
+ if (!this.disposed) {
181
+ this.sessions.forEach(session => session.reconnect());
182
+ }
183
+ }, 0);
184
+ }
185
+ }
186
+ /**
187
+ * Sessions are detached rather than disposed: the server ends every session
188
+ * on a connection it sees close, so ending each one first sends requests
189
+ * over a connection this call is about to dispose.
190
+ */
191
+ dispose() {
192
+ for (const session of [...this.sessions]) {
193
+ session.detach();
194
+ }
195
+ // For a factory's session whose `detach` does not fire.
196
+ this.sessions.clear();
197
+ this.createSessionEmitter.dispose();
198
+ this.dirtyChangedEmitter.dispose();
199
+ this.documentUpdatedEmitter.dispose();
200
+ super.dispose();
201
+ }
202
+ }
203
+ exports.DataConnection = DataConnection;
204
+ /**
205
+ * A {@link DataConnection} that brings its own {@link DataEvents}, so a host
206
+ * with several interested parties does not have to supply one.
207
+ *
208
+ * **The client slot holds exactly one object, and that is why this exists.**
209
+ * `createRpcProxy` binds a single `localTarget`, and underneath a method name
210
+ * maps to one handler — a second registration replaces the first silently. So a
211
+ * properties panel and a tree cannot both be the client; one fan-out sits in the
212
+ * slot and both subscribe to it.
213
+ *
214
+ * Use {@link DataConnection} directly instead when the client is yours: an
215
+ * adopter service that implements the protocol plus its own methods, a single
216
+ * consumer that IS the client, or a request/response-only client that binds
217
+ * nothing.
218
+ */
219
+ class DataConnectionWithEvents extends DataConnection {
220
+ /** Server pushes, fanned out to as many local listeners as the host has. */
221
+ events;
222
+ constructor(port, options) {
223
+ // Built as a local because `this` is unavailable before `super`, then
224
+ // read back onto the field.
225
+ const events = new data_events_1.DataEvents();
226
+ super(port, events, options);
227
+ this.events = events;
228
+ }
229
+ /** Disposes the fan-out it created, which no caller else holds. */
230
+ dispose() {
231
+ super.dispose();
232
+ this.events.dispose();
233
+ }
234
+ }
235
+ exports.DataConnectionWithEvents = DataConnectionWithEvents;
236
+ //# 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,mDAAqD;AACrD,8CAAqD;AACrD,kCASiB;AACjB,sCAA0E;AAE1E,+CAA2C;AAE3C,iDAAsE;AACtE,qDAA8E;AAkD9E;;;;;;;;;;;;GAYG;AACH,MAAa,cAIX,SAAQ,8BAA+B;IACnB,QAAQ,GAAG,IAAI,GAAG,EAAmC,CAAC;IACtD,cAAc,CAAyC;IACvD,oBAAoB,GAAG,IAAI,wBAAO,EAAmC,CAAC;IACzF;;;;OAIG;IACM,kBAAkB,GAA2C,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;IACtG;;;;;OAKG;IACgB,WAAW,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC5D,qEAAqE;IAClD,mBAAmB,GAAG,IAAI,wBAAO,EAAqC,CAAC;IAC1F,wEAAwE;IACrD,sBAAsB,GAAG,IAAI,wBAAO,EAAkE,CAAC;IAE1H,YAAY,IAAc,EAAE,MAAe,EAAE,GAAG,IAAqD;QAClG,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,IAEtB,CAAC;QACF,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;QACH,IAAI,CAAC,cAAc;YAChB,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,0BAAW,CAAqB,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACxH,CAAC;IAED;;;;OAIG;IACH,IAAI,YAA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AQ,CAAC,EAAE,CAAC;YACxC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,CAAC;QACD,wDAAwD;QACxD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,KAAK,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;CACH;AA3LD,wCA2LC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAa,wBAGX,SAAQ,cAAoG;IAC3G,4EAA4E;IACnE,MAAM,CAAmE;IAElF,YAAY,IAAc,EAAE,OAAmD;QAC5E,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, TransferDocumentDirtyChangedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from '../data';
11
11
  import type { Project } from '../project';
12
12
  import type { TransferDiagnostic } from '../transfer-diagnostic';
13
13
  import type { TransferElement } from '../transfer-element';
@@ -34,15 +34,27 @@ import type { TransferElement } from '../transfer-element';
34
34
  export declare class DataEvents<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> implements DataClientProtocol<TTransfer, TDiagnostic, TProject> {
35
35
  protected readonly documentUpdatedEmitter: Emitter<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
36
36
  protected readonly documentSavedEmitter: Emitter<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
37
+ protected readonly documentDirtyChangedEmitter: Emitter<TransferDocumentDirtyChangedEvent>;
38
+ protected readonly documentDeletedEmitter: Emitter<TransferDocumentDeletedEvent>;
39
+ protected readonly documentsBuiltEmitter: Emitter<TransferDocumentsBuiltEvent>;
37
40
  protected readonly projectsChangedEmitter: Emitter<ProjectsChangedEvent<TProject>>;
38
41
  /** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
39
42
  readonly onDidUpdateDocument: Event<TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>>;
40
43
  /** A watched document was persisted to disk. */
41
44
  readonly onDidSaveDocument: Event<TransferDocumentSavedEvent<TTransfer, TDiagnostic>>;
45
+ /** A watched document's text started or stopped differing from its file. */
46
+ readonly onDidChangeDocumentDirty: Event<TransferDocumentDirtyChangedEvent>;
47
+ /** A document's backing file was removed, watched or not. Any watch survives. */
48
+ readonly onDidDeleteDocument: Event<TransferDocumentDeletedEvent>;
49
+ /** Documents built that nobody watches — re-read anything derived from them. */
50
+ readonly onDidBuildDocuments: Event<TransferDocumentsBuiltEvent>;
42
51
  /** The project set changed. */
43
52
  readonly onDidChangeProjects: Event<ProjectsChangedEvent<TProject>>;
44
53
  onDocumentUpdated(event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>): void;
45
54
  onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
55
+ onDocumentDirtyChanged(event: TransferDocumentDirtyChangedEvent): void;
56
+ onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
57
+ onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
46
58
  onProjectsChanged(event: ProjectsChangedEvent<TProject>): void;
47
59
  dispose(): void;
48
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"data-events.d.ts","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,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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C;IACtF,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,4EAA4E;IAC5E,QAAQ,CAAC,wBAAwB,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAA0C;IACrH,iFAAiF;IACjF,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAqC;IACtG,gFAAgF;IAChF,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAoC;IACpG,+BAA+B;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAqC;IAIxG,iBAAiB,CAAC,KAAK,EAAE,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;IAIpF,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG,IAAI;IAIhF,sBAAsB,CAAC,KAAK,EAAE,iCAAiC,GAAG,IAAI;IAItE,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;CAQjB"}
@@ -33,11 +33,20 @@ const vscode_jsonrpc_1 = require("vscode-jsonrpc");
33
33
  class DataEvents {
34
34
  documentUpdatedEmitter = new vscode_jsonrpc_1.Emitter();
35
35
  documentSavedEmitter = new vscode_jsonrpc_1.Emitter();
36
+ documentDirtyChangedEmitter = new vscode_jsonrpc_1.Emitter();
37
+ documentDeletedEmitter = new vscode_jsonrpc_1.Emitter();
38
+ documentsBuiltEmitter = new vscode_jsonrpc_1.Emitter();
36
39
  projectsChangedEmitter = new vscode_jsonrpc_1.Emitter();
37
40
  /** A build-phase event for a watched document. Carries the originating `sourceClientId`. */
38
41
  onDidUpdateDocument = this.documentUpdatedEmitter.event;
39
42
  /** A watched document was persisted to disk. */
40
43
  onDidSaveDocument = this.documentSavedEmitter.event;
44
+ /** A watched document's text started or stopped differing from its file. */
45
+ onDidChangeDocumentDirty = this.documentDirtyChangedEmitter.event;
46
+ /** A document's backing file was removed, watched or not. Any watch survives. */
47
+ onDidDeleteDocument = this.documentDeletedEmitter.event;
48
+ /** Documents built that nobody watches — re-read anything derived from them. */
49
+ onDidBuildDocuments = this.documentsBuiltEmitter.event;
41
50
  /** The project set changed. */
42
51
  onDidChangeProjects = this.projectsChangedEmitter.event;
43
52
  // --- DataClientProtocol (wire names) ---
@@ -47,12 +56,24 @@ class DataEvents {
47
56
  onDocumentSaved(event) {
48
57
  this.documentSavedEmitter.fire(event);
49
58
  }
59
+ onDocumentDirtyChanged(event) {
60
+ this.documentDirtyChangedEmitter.fire(event);
61
+ }
62
+ onDocumentDeleted(event) {
63
+ this.documentDeletedEmitter.fire(event);
64
+ }
65
+ onDocumentsBuilt(event) {
66
+ this.documentsBuiltEmitter.fire(event);
67
+ }
50
68
  onProjectsChanged(event) {
51
69
  this.projectsChangedEmitter.fire(event);
52
70
  }
53
71
  dispose() {
54
72
  this.documentUpdatedEmitter.dispose();
55
73
  this.documentSavedEmitter.dispose();
74
+ this.documentDirtyChangedEmitter.dispose();
75
+ this.documentDeletedEmitter.dispose();
76
+ this.documentsBuiltEmitter.dispose();
56
77
  this.projectsChangedEmitter.dispose();
57
78
  }
58
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"data-events.js","sourceRoot":"","sources":["../../src/client/data-events.ts"],"names":[],"mappings":";AAAA;;;;;;;kF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C,CAAC;IAC3C,CAAC;IAED,OAAO;QACJ,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,CAAC;QAC3C,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACH;AA3DD,gCA2DC"}
@@ -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"}