@hydranium/protocol 1.0.0-next.10

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 (254) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -0
  3. package/lib/abstract-logger.d.ts +66 -0
  4. package/lib/abstract-logger.d.ts.map +1 -0
  5. package/lib/abstract-logger.js +110 -0
  6. package/lib/abstract-logger.js.map +1 -0
  7. package/lib/browser-runtime.d.ts +124 -0
  8. package/lib/browser-runtime.d.ts.map +1 -0
  9. package/lib/browser-runtime.js +11 -0
  10. package/lib/browser-runtime.js.map +1 -0
  11. package/lib/client/data-events.d.ts +49 -0
  12. package/lib/client/data-events.d.ts.map +1 -0
  13. package/lib/client/data-events.js +60 -0
  14. package/lib/client/data-events.js.map +1 -0
  15. package/lib/client/data-port.d.ts +95 -0
  16. package/lib/client/data-port.d.ts.map +1 -0
  17. package/lib/client/data-port.js +11 -0
  18. package/lib/client/data-port.js.map +1 -0
  19. package/lib/client/data-session.d.ts +129 -0
  20. package/lib/client/data-session.d.ts.map +1 -0
  21. package/lib/client/data-session.js +179 -0
  22. package/lib/client/data-session.js.map +1 -0
  23. package/lib/client/index.d.ts +39 -0
  24. package/lib/client/index.d.ts.map +1 -0
  25. package/lib/client/index.js +55 -0
  26. package/lib/client/index.js.map +1 -0
  27. package/lib/client/message-relay.d.ts +111 -0
  28. package/lib/client/message-relay.d.ts.map +1 -0
  29. package/lib/client/message-relay.js +139 -0
  30. package/lib/client/message-relay.js.map +1 -0
  31. package/lib/client/post-message-transport.d.ts +77 -0
  32. package/lib/client/post-message-transport.d.ts.map +1 -0
  33. package/lib/client/post-message-transport.js +95 -0
  34. package/lib/client/post-message-transport.js.map +1 -0
  35. package/lib/clock.d.ts +111 -0
  36. package/lib/clock.d.ts.map +1 -0
  37. package/lib/clock.js +74 -0
  38. package/lib/clock.js.map +1 -0
  39. package/lib/data/data-protocol-methods.d.ts +39 -0
  40. package/lib/data/data-protocol-methods.d.ts.map +1 -0
  41. package/lib/data/data-protocol-methods.js +61 -0
  42. package/lib/data/data-protocol-methods.js.map +1 -0
  43. package/lib/data/data-server-protocol.d.ts +264 -0
  44. package/lib/data/data-server-protocol.d.ts.map +1 -0
  45. package/lib/data/data-server-protocol.js +11 -0
  46. package/lib/data/data-server-protocol.js.map +1 -0
  47. package/lib/data/diagnostics.d.ts +97 -0
  48. package/lib/data/diagnostics.d.ts.map +1 -0
  49. package/lib/data/diagnostics.js +25 -0
  50. package/lib/data/diagnostics.js.map +1 -0
  51. package/lib/data/events.d.ts +107 -0
  52. package/lib/data/events.d.ts.map +1 -0
  53. package/lib/data/events.js +11 -0
  54. package/lib/data/events.js.map +1 -0
  55. package/lib/data/index.d.ts +15 -0
  56. package/lib/data/index.d.ts.map +1 -0
  57. package/lib/data/index.js +38 -0
  58. package/lib/data/index.js.map +1 -0
  59. package/lib/data/methods.d.ts +57 -0
  60. package/lib/data/methods.d.ts.map +1 -0
  61. package/lib/data/methods.js +60 -0
  62. package/lib/data/methods.js.map +1 -0
  63. package/lib/data/requests.d.ts +65 -0
  64. package/lib/data/requests.d.ts.map +1 -0
  65. package/lib/data/requests.js +11 -0
  66. package/lib/data/requests.js.map +1 -0
  67. package/lib/debouncer.d.ts +75 -0
  68. package/lib/debouncer.d.ts.map +1 -0
  69. package/lib/debouncer.js +91 -0
  70. package/lib/debouncer.js.map +1 -0
  71. package/lib/errors.d.ts +84 -0
  72. package/lib/errors.d.ts.map +1 -0
  73. package/lib/errors.js +113 -0
  74. package/lib/errors.js.map +1 -0
  75. package/lib/host-diagnostics.d.ts +58 -0
  76. package/lib/host-diagnostics.d.ts.map +1 -0
  77. package/lib/host-diagnostics.js +18 -0
  78. package/lib/host-diagnostics.js.map +1 -0
  79. package/lib/index.d.ts +34 -0
  80. package/lib/index.d.ts.map +1 -0
  81. package/lib/index.js +56 -0
  82. package/lib/index.js.map +1 -0
  83. package/lib/latency-collector.d.ts +126 -0
  84. package/lib/latency-collector.d.ts.map +1 -0
  85. package/lib/latency-collector.js +137 -0
  86. package/lib/latency-collector.js.map +1 -0
  87. package/lib/logger.d.ts +119 -0
  88. package/lib/logger.d.ts.map +1 -0
  89. package/lib/logger.js +126 -0
  90. package/lib/logger.js.map +1 -0
  91. package/lib/model-server.d.ts +352 -0
  92. package/lib/model-server.d.ts.map +1 -0
  93. package/lib/model-server.js +160 -0
  94. package/lib/model-server.js.map +1 -0
  95. package/lib/model-service/args.d.ts +64 -0
  96. package/lib/model-service/args.d.ts.map +1 -0
  97. package/lib/model-service/args.js +11 -0
  98. package/lib/model-service/args.js.map +1 -0
  99. package/lib/model-service/index.d.ts +11 -0
  100. package/lib/model-service/index.d.ts.map +1 -0
  101. package/lib/model-service/index.js +31 -0
  102. package/lib/model-service/index.js.map +1 -0
  103. package/lib/model-service/reference-candidate.d.ts +56 -0
  104. package/lib/model-service/reference-candidate.d.ts.map +1 -0
  105. package/lib/model-service/reference-candidate.js +11 -0
  106. package/lib/model-service/reference-candidate.js.map +1 -0
  107. package/lib/noop-logger.d.ts +25 -0
  108. package/lib/noop-logger.d.ts.map +1 -0
  109. package/lib/noop-logger.js +36 -0
  110. package/lib/noop-logger.js.map +1 -0
  111. package/lib/observable-value.d.ts +72 -0
  112. package/lib/observable-value.d.ts.map +1 -0
  113. package/lib/observable-value.js +52 -0
  114. package/lib/observable-value.js.map +1 -0
  115. package/lib/patch-merge.d.ts +123 -0
  116. package/lib/patch-merge.d.ts.map +1 -0
  117. package/lib/patch-merge.js +104 -0
  118. package/lib/patch-merge.js.map +1 -0
  119. package/lib/profile-session.d.ts +87 -0
  120. package/lib/profile-session.d.ts.map +1 -0
  121. package/lib/profile-session.js +98 -0
  122. package/lib/profile-session.js.map +1 -0
  123. package/lib/profiling.d.ts +83 -0
  124. package/lib/profiling.d.ts.map +1 -0
  125. package/lib/profiling.js +20 -0
  126. package/lib/profiling.js.map +1 -0
  127. package/lib/project.d.ts +121 -0
  128. package/lib/project.d.ts.map +1 -0
  129. package/lib/project.js +34 -0
  130. package/lib/project.js.map +1 -0
  131. package/lib/rpc/bind-rpc-methods.d.ts +100 -0
  132. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -0
  133. package/lib/rpc/bind-rpc-methods.js +110 -0
  134. package/lib/rpc/bind-rpc-methods.js.map +1 -0
  135. package/lib/rpc/create-rpc-proxy.d.ts +188 -0
  136. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -0
  137. package/lib/rpc/create-rpc-proxy.js +158 -0
  138. package/lib/rpc/create-rpc-proxy.js.map +1 -0
  139. package/lib/rpc/index.d.ts +12 -0
  140. package/lib/rpc/index.d.ts.map +1 -0
  141. package/lib/rpc/index.js +31 -0
  142. package/lib/rpc/index.js.map +1 -0
  143. package/lib/rpc/wire-prefix.d.ts +37 -0
  144. package/lib/rpc/wire-prefix.d.ts.map +1 -0
  145. package/lib/rpc/wire-prefix.js +49 -0
  146. package/lib/rpc/wire-prefix.js.map +1 -0
  147. package/lib/testing/data-doubles.d.ts +121 -0
  148. package/lib/testing/data-doubles.d.ts.map +1 -0
  149. package/lib/testing/data-doubles.js +102 -0
  150. package/lib/testing/data-doubles.js.map +1 -0
  151. package/lib/testing/fake-clock.d.ts +35 -0
  152. package/lib/testing/fake-clock.d.ts.map +1 -0
  153. package/lib/testing/fake-clock.js +86 -0
  154. package/lib/testing/fake-clock.js.map +1 -0
  155. package/lib/testing/harness.d.ts +24 -0
  156. package/lib/testing/harness.d.ts.map +1 -0
  157. package/lib/testing/harness.js +11 -0
  158. package/lib/testing/harness.js.map +1 -0
  159. package/lib/testing/index.d.ts +13 -0
  160. package/lib/testing/index.d.ts.map +1 -0
  161. package/lib/testing/index.js +41 -0
  162. package/lib/testing/index.js.map +1 -0
  163. package/lib/testing/node/duplex-connection.d.ts +25 -0
  164. package/lib/testing/node/duplex-connection.d.ts.map +1 -0
  165. package/lib/testing/node/duplex-connection.js +34 -0
  166. package/lib/testing/node/duplex-connection.js.map +1 -0
  167. package/lib/testing/node/duplex-stream.d.ts +32 -0
  168. package/lib/testing/node/duplex-stream.d.ts.map +1 -0
  169. package/lib/testing/node/duplex-stream.js +35 -0
  170. package/lib/testing/node/duplex-stream.js.map +1 -0
  171. package/lib/testing/node/index.d.ts +11 -0
  172. package/lib/testing/node/index.d.ts.map +1 -0
  173. package/lib/testing/node/index.js +37 -0
  174. package/lib/testing/node/index.js.map +1 -0
  175. package/lib/testing/wait-for.d.ts +69 -0
  176. package/lib/testing/wait-for.d.ts.map +1 -0
  177. package/lib/testing/wait-for.js +67 -0
  178. package/lib/testing/wait-for.js.map +1 -0
  179. package/lib/tracer.d.ts +115 -0
  180. package/lib/tracer.d.ts.map +1 -0
  181. package/lib/tracer.js +205 -0
  182. package/lib/tracer.js.map +1 -0
  183. package/lib/transfer-diagnostic.d.ts +73 -0
  184. package/lib/transfer-diagnostic.d.ts.map +1 -0
  185. package/lib/transfer-diagnostic.js +45 -0
  186. package/lib/transfer-diagnostic.js.map +1 -0
  187. package/lib/transfer-document.d.ts +73 -0
  188. package/lib/transfer-document.d.ts.map +1 -0
  189. package/lib/transfer-document.js +46 -0
  190. package/lib/transfer-document.js.map +1 -0
  191. package/lib/transfer-element.d.ts +39 -0
  192. package/lib/transfer-element.d.ts.map +1 -0
  193. package/lib/transfer-element.js +11 -0
  194. package/lib/transfer-element.js.map +1 -0
  195. package/lib/uri.d.ts +62 -0
  196. package/lib/uri.d.ts.map +1 -0
  197. package/lib/uri.js +28 -0
  198. package/lib/uri.js.map +1 -0
  199. package/lib/util.d.ts +147 -0
  200. package/lib/util.d.ts.map +1 -0
  201. package/lib/util.js +211 -0
  202. package/lib/util.js.map +1 -0
  203. package/package.json +100 -0
  204. package/src/abstract-logger.ts +120 -0
  205. package/src/browser-runtime.ts +135 -0
  206. package/src/client/data-events.ts +71 -0
  207. package/src/client/data-port.ts +99 -0
  208. package/src/client/data-session.ts +209 -0
  209. package/src/client/index.ts +40 -0
  210. package/src/client/message-relay.ts +216 -0
  211. package/src/client/post-message-transport.ts +167 -0
  212. package/src/clock.ts +173 -0
  213. package/src/data/data-protocol-methods.ts +79 -0
  214. package/src/data/data-server-protocol.ts +296 -0
  215. package/src/data/diagnostics.ts +116 -0
  216. package/src/data/events.ts +127 -0
  217. package/src/data/index.ts +23 -0
  218. package/src/data/methods.ts +59 -0
  219. package/src/data/requests.ts +70 -0
  220. package/src/debouncer.ts +118 -0
  221. package/src/errors.ts +127 -0
  222. package/src/host-diagnostics.ts +63 -0
  223. package/src/index.ts +41 -0
  224. package/src/latency-collector.ts +231 -0
  225. package/src/logger.ts +172 -0
  226. package/src/model-server.ts +479 -0
  227. package/src/model-service/args.ts +67 -0
  228. package/src/model-service/index.ts +16 -0
  229. package/src/model-service/reference-candidate.ts +58 -0
  230. package/src/noop-logger.ts +36 -0
  231. package/src/observable-value.ts +92 -0
  232. package/src/patch-merge.ts +165 -0
  233. package/src/profile-session.ts +164 -0
  234. package/src/profiling.ts +113 -0
  235. package/src/project.ts +125 -0
  236. package/src/rpc/README.md +163 -0
  237. package/src/rpc/bind-rpc-methods.ts +180 -0
  238. package/src/rpc/create-rpc-proxy.ts +292 -0
  239. package/src/rpc/index.ts +16 -0
  240. package/src/rpc/wire-prefix.ts +48 -0
  241. package/src/testing/data-doubles.ts +178 -0
  242. package/src/testing/fake-clock.ts +106 -0
  243. package/src/testing/harness.ts +24 -0
  244. package/src/testing/index.ts +26 -0
  245. package/src/testing/node/duplex-connection.ts +50 -0
  246. package/src/testing/node/duplex-stream.ts +51 -0
  247. package/src/testing/node/index.ts +22 -0
  248. package/src/testing/wait-for.ts +94 -0
  249. package/src/tracer.ts +277 -0
  250. package/src/transfer-diagnostic.ts +92 -0
  251. package/src/transfer-document.ts +99 -0
  252. package/src/transfer-element.ts +43 -0
  253. package/src/uri.ts +61 -0
  254. package/src/util.ts +250 -0
@@ -0,0 +1,264 @@
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 { TransferDiagnostic } from '../transfer-diagnostic';
10
+ import type { TransferElement } from '../transfer-element';
11
+ import type { Project } from '../project';
12
+ import type { TransferDocument } from '../transfer-document';
13
+ import type { CloseModelArgs, FindNextNameArgs, OpenModelArgs, ReferenceContext, ReferenceRequest } from '../model-server';
14
+ import type { ReferenceCandidate, ReferenceTarget } from '../model-service/reference-candidate';
15
+ import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from './events';
16
+ import type { GetModelDocumentArgs, GetProjectForUriArgs, TransferSaveDocumentArgs, WatchModelDocumentArgs, TransferUpdateDocumentArgs } from './requests';
17
+ /**
18
+ * Document-scoped slice of the data-server wire contract: the per-document
19
+ * lifecycle (get / update / save), the per-`(uri, clientId)` watch
20
+ * pair, and the global `waitForReady` startup gate that callers await before
21
+ * the first document request.
22
+ *
23
+ * Generic over the transfer root type (`TTransfer`) and the diagnostic
24
+ * shape (`TDiagnostic`). `TTransfer extends TransferElement` constrains the
25
+ * root to the wire data shape (no `$container` cycles, references as
26
+ * strings — see `transfer-element.ts`) — the type-system bridge between the
27
+ * data-server's protocol surface and the transfer-model overlay each adopter
28
+ * declares.
29
+ *
30
+ * Composed into {@link DataServerProtocol} alongside {@link ProjectServerProtocol};
31
+ * a pure single-document consumer can compose only this fragment.
32
+ */
33
+ export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
34
+ /**
35
+ * Open a document for an editor session and return its current state.
36
+ * Registers `(uri, clientId)` with the multi-client document manager
37
+ * (so concurrent editors share one built document) and returns the
38
+ * document at the server's configured target phase — the same shape
39
+ * {@link getModelDocument} returns, except that `version` is taken from
40
+ * the text-document store so the caller's first `baseVersion` write
41
+ * cannot self-conflict. Idempotent in registration terms: opening an
42
+ * already-open document refreshes the client registration. Note it does
43
+ * NOT avoid a rebuild — a second client attaching triggers
44
+ * `refreshContent`, which fires a change event, so mounting a form on a
45
+ * document already open in a text editor rebuilds it.
46
+ *
47
+ * The default `DataServer` impl delegates to `ModelService.open` then
48
+ * reads the built state. Pair with {@link watchModelDocument} to receive
49
+ * subsequent build-phase events (open returns a one-shot snapshot;
50
+ * later validation diagnostics arrive on the watch channel).
51
+ */
52
+ openModelDocument(args: OpenModelArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
53
+ /**
54
+ * Close an editor session for `(uri, clientId)`. Counterpart to
55
+ * {@link openModelDocument}; the underlying document stays built until
56
+ * every registered client has closed. The default `DataServer` impl
57
+ * delegates to `ModelService.close` and ALSO releases any watch for the
58
+ * same `(uri, clientId)` (closing a session frees its own watch — a
59
+ * forgotten {@link unwatchModelDocument} would otherwise leak dispatch;
60
+ * the implicit unwatch is idempotent). `watchModelDocument` is NOT
61
+ * coupled the other way: opening does not force a watch, so a snapshot
62
+ * reader can open without streaming.
63
+ */
64
+ closeModelDocument(args: CloseModelArgs): Promise<void>;
65
+ /**
66
+ * Get the current state of a document. The server-side build is brought
67
+ * up to date before the response returns — callers don't need to await
68
+ * a separate "ready" gate per request, only the global
69
+ * {@link waitForReady} gate at startup.
70
+ */
71
+ getModelDocument(args: GetModelDocumentArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
72
+ /**
73
+ * Update a document's content. The response carries the latest built
74
+ * state including diagnostics; callers observe convergence via that
75
+ * response.
76
+ */
77
+ updateModelDocument(args: TransferUpdateDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
78
+ /**
79
+ * Persist a document to disk. The response is the post-save document
80
+ * state (matches the file on disk). Save semantics depend on the
81
+ * filesystem-provider wiring; rejection paths surface as awaited
82
+ * promise rejections.
83
+ */
84
+ saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
85
+ /**
86
+ * Start watching `(uri, clientId)`. The server starts dispatching
87
+ * {@link DocumentClientProtocol.onDocumentUpdated} on the paired wire
88
+ * for every build-phase event on `uri`.
89
+ *
90
+ * Returns `Promise<void>` — the bidirectional pattern means the event
91
+ * channel is the client interface, not a returned handle. Callers fan
92
+ * out a single inbound `onDocumentUpdated` to multiple local listeners
93
+ * with their own `Emitter<T>` (matching Theia's pattern). Pair every
94
+ * `watchModelDocument` with {@link unwatchModelDocument} when no longer
95
+ * needed; the server holds the watch record until the matching unwatch
96
+ * lands.
97
+ */
98
+ watchModelDocument(args: WatchModelDocumentArgs): Promise<void>;
99
+ /**
100
+ * Stop watching `(uri, clientId)` previously started by
101
+ * {@link watchModelDocument}. Idempotent — unwatching twice is a no-op.
102
+ */
103
+ unwatchModelDocument(args: WatchModelDocumentArgs): Promise<void>;
104
+ /**
105
+ * Resolve once the data-server is ready to serve requests. The default
106
+ * implementation in `DataServer` returns `Promise.resolve()`; adopters
107
+ * that need to warm-load services (workspace indexing, custom service
108
+ * initialisation) override this hook on their subclass.
109
+ *
110
+ * Callers SHOULD await `waitForReady` once at startup before the first
111
+ * `getModelDocument` / subscription call — Langium's document builder
112
+ * may otherwise miss documents added during the initial workspace
113
+ * walk.
114
+ */
115
+ waitForReady(): Promise<void>;
116
+ }
117
+ /**
118
+ * Project-scoped slice of the data-server wire contract: enumerate the
119
+ * workspace's projects and resolve the project owning a URI.
120
+ *
121
+ * Generic over the project shape (`TProject`); most adopters use the
122
+ * default {@link Project}. Composed into {@link DataServerProtocol}
123
+ * alongside {@link DocumentServerProtocol}.
124
+ */
125
+ export interface ProjectServerProtocol<TProject extends Project = Project> {
126
+ /**
127
+ * List projects exposed by the workspace. Returns an empty array when
128
+ * no project tier is wired (e.g. `SingleProjectManager` default with no
129
+ * descriptor discovery configured).
130
+ */
131
+ getProjects(): Promise<readonly TProject[]>;
132
+ /**
133
+ * Look up the project owning the given URI. Returns `undefined` when
134
+ * the URI does not belong to any registered project, or when no
135
+ * project tier is wired (the `SingleProjectManager` default returns
136
+ * its synthetic workspace project for every URI, so that case never
137
+ * resolves to `undefined`).
138
+ *
139
+ * Membership semantics are decided by the server's `ProjectManager`
140
+ * implementation — the default in `AbstractProjectManager` is closest-
141
+ * ancestor descriptor folder; adopters override for explicit URI
142
+ * listings, glob patterns, manifest-declared file lists, etc.
143
+ */
144
+ getProjectForUri(args: GetProjectForUriArgs): Promise<TProject | undefined>;
145
+ }
146
+ /**
147
+ * Typed RPC contract for the data-server protocol head — the server-exposed
148
+ * surface clients call. Composed from the role-explicit fragments
149
+ * {@link DocumentServerProtocol} (per-document lifecycle + subscriptions +
150
+ * the readiness gate) and {@link ProjectServerProtocol} (project tier).
151
+ * Implementations live in `@hydranium/data-server`; typed client proxies are
152
+ * produced by `createRpcProxy` (in this package's `./rpc` subpath). The
153
+ * wire-level method names are `DATA_SERVER_WIRE_PREFIX + methodName` for
154
+ * every method in `DATA_SERVER_PROTOCOL_METHODS` (request methods)
155
+ * and `DATA_CLIENT_PROTOCOL_METHODS` (notification methods).
156
+ *
157
+ * Most adopters parameterise only `TTransfer`; `TDiagnostic` defaults to
158
+ * {@link TransferDiagnostic} and `TProject` to {@link Project}.
159
+ *
160
+ * **Bidirectional pattern.** `DataServerProtocol` is the SERVER-EXPOSED
161
+ * surface — methods the client calls. The dual surface
162
+ * {@link DataClientProtocol} contains methods the server calls (delivered
163
+ * as JSON-RPC notifications). The pair composes via `createRpcProxy`
164
+ * (`localTarget`/`localMethods`) so server and client are typed end-to-end
165
+ * with no method-list drift.
166
+ *
167
+ * **Architectural placement.** The SOLE typed surface for the data-server
168
+ * peer. `lsp-server` and `glsp-server` define their own peer-equivalent
169
+ * surfaces and DO NOT extend this one; all three heads sit at the same tier,
170
+ * coordinating through shared services in `@hydranium/core`.
171
+ */
172
+ export interface DataServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> extends DocumentServerProtocol<TTransfer, TDiagnostic>, ProjectServerProtocol<TProject> {
173
+ }
174
+ /**
175
+ * Cross-reference / naming slice of the server surface — scope-aware
176
+ * queries that resolve against the language's reference services. NOT part
177
+ * of the {@link DataServerProtocol} composition: a pure data consumer
178
+ * doesn't need it, so adopters compose it onto their connection explicitly.
179
+ * The default `DataServer` impls delegate to
180
+ * the per-language `references` services, resolved from each request's
181
+ * source/URI (an `ElementSource` with no URI resolves to the sole
182
+ * registered language; a multi-language workspace overrides).
183
+ *
184
+ * Generic over the transfer root type only — the resolution result
185
+ * ({@link ReferenceTarget}) carries the resolved node's encoded subtree;
186
+ * candidates and names are diagnostic-free.
187
+ */
188
+ export interface ReferenceServerProtocol<TTransfer extends TransferElement> {
189
+ /**
190
+ * List the reference candidates reachable for the property named in `ctx`
191
+ * from its (possibly synthetic) source. Backed by the language's
192
+ * `ReferenceCandidateProvider`.
193
+ */
194
+ findReferenceCandidates(ctx: ReferenceContext): Promise<ReferenceCandidate[]>;
195
+ /**
196
+ * Resolve a concrete reference request to its target, returning the
197
+ * target's document URI, display fields, and the resolved node's encoded
198
+ * transfer subtree. Resolves via the language's reference services;
199
+ * `undefined` when the reference does not resolve.
200
+ */
201
+ resolveReference(ref: ReferenceRequest): Promise<ReferenceTarget<TTransfer> | undefined>;
202
+ /**
203
+ * Compute the next free name for a new element of `args.type` based on
204
+ * `args.proposal`, unique within the `args.tier` scope (default
205
+ * `'project'`). Backed by the language's `NameProvider`.
206
+ */
207
+ findNextName(args: FindNextNameArgs): Promise<string>;
208
+ }
209
+ /**
210
+ * Document-scoped slice of the client surface — notifications the server
211
+ * delivers about subscribed documents. The dual of
212
+ * {@link DocumentServerProtocol}.
213
+ *
214
+ * Notification methods are conventionally `on*`-prefixed so the generic
215
+ * `createRpcProxy` helper routes them as `sendNotification` calls.
216
+ * Multi-listener fan-out is the consumer's responsibility — wrap a local
217
+ * implementation with an `Emitter<T>` to fan a single inbound
218
+ * `onDocumentUpdated` call out to multiple local subscribers.
219
+ */
220
+ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
221
+ /**
222
+ * Delivered when a subscribed document reached one of the data-server's
223
+ * configured build phases. Subscribers filter incoming events by URI
224
+ * if they hold multiple subscriptions on the same wire.
225
+ */
226
+ onDocumentUpdated(event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>): void;
227
+ /**
228
+ * Delivered when a subscribed document was persisted to disk via
229
+ * {@link DocumentServerProtocol.saveModelDocument}. The persistence event
230
+ * is delivered on a separate channel from the build-phase update
231
+ * stream — subscribers tracking "saved" status (editor dirty-flag
232
+ * indicators, external sync drivers) listen here instead of filtering
233
+ * `onDocumentUpdated` for `reason: 'saved'` (the build-phase path
234
+ * never emits `'saved'` because saves take a synchronous RPC-response
235
+ * codepath, not a subscription codepath).
236
+ */
237
+ onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
238
+ }
239
+ /**
240
+ * Project-scoped slice of the client surface — the project-registry change
241
+ * notification. The dual of {@link ProjectServerProtocol}.
242
+ */
243
+ export interface ProjectClientProtocol<TProject extends Project = Project> {
244
+ /**
245
+ * Delivered when a project was added, updated, or removed from the
246
+ * registry. The data-server subscribes to its `ProjectManager`'s
247
+ * change channel and fans the internal `ProjectChangeEvent` (which
248
+ * carries arrays of added/updated/removed ids per registry diff) out
249
+ * to one wire notification per affected project — `'removed'` events
250
+ * carry the pre-removal snapshot so clients with no local cache can
251
+ * still read the project's metadata.
252
+ */
253
+ onProjectsChanged(event: ProjectsChangedEvent<TProject>): void;
254
+ }
255
+ /**
256
+ * Client-side surface — methods the data-server invokes on the client as
257
+ * JSON-RPC notifications. The bidirectional dual of {@link DataServerProtocol},
258
+ * composed from {@link DocumentClientProtocol} and {@link ProjectClientProtocol}.
259
+ * A `createRpcProxy` over the connection exposes the server surface outbound and
260
+ * binds an implementation of this interface inbound (`localTarget`).
261
+ */
262
+ export interface DataClientProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> extends DocumentClientProtocol<TTransfer, TDiagnostic>, ProjectClientProtocol<TProject> {
263
+ }
264
+ //# sourceMappingURL=data-server-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-server-protocol.d.ts","sourceRoot":"","sources":["../../src/data/data-server-protocol.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,11 @@
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
+ //# sourceMappingURL=data-server-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-server-protocol.js","sourceRoot":"","sources":["../../src/data/data-server-protocol.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF"}
@@ -0,0 +1,97 @@
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
+ /**
10
+ * Optional diagnostics slice of the data-server wire contract: capture memory /
11
+ * state snapshots of the running server process for OOM debugging (notably in a
12
+ * cloud pod). Kept OUT of `DataServerProtocol` so the core document /
13
+ * project contract stays lean, but the framework `DataServer` registers these
14
+ * BY DEFAULT (so every head gets them with no wiring); a head that does not want
15
+ * them drops the names via `DataServerOptions.excludedMethods`.
16
+ *
17
+ * Returns are plain formatted strings — the caller (a command, a log sink, the
18
+ * pod's stdout) decides how to surface them. The wire names are
19
+ * `DATA_SERVER_WIRE_PREFIX + methodName`, same as the core methods.
20
+ */
21
+ import type { LatencyReport } from '../latency-collector.js';
22
+ import type { ProfileCaptureOptions } from '../profiling.js';
23
+ /** Arguments for {@link DataServerDiagnosticsProtocol.dumpServerState}. */
24
+ export interface DumpServerStateArgs {
25
+ /** Optional label folded into the snapshot heading (e.g. an ISO timestamp). */
26
+ label?: string;
27
+ }
28
+ /**
29
+ * Arguments for {@link DataServerDiagnosticsProtocol.startProfiling} — the capture
30
+ * dimensions to sample over the window (all off unless named). The wire args are
31
+ * exactly the neutral {@link ProfileCaptureOptions}.
32
+ */
33
+ export type StartProfilingArgs = ProfileCaptureOptions;
34
+ /** Arguments for {@link DataServerDiagnosticsProtocol.stopProfiling}. */
35
+ export interface StopProfilingArgs {
36
+ /** Optional label folded into the profile filenames + report heading. */
37
+ label?: string;
38
+ /** Directory to write profile artefacts into; defaults to the OS temp dir when absent or not present on disk. */
39
+ directory?: string;
40
+ }
41
+ /** Arguments for {@link DataServerDiagnosticsProtocol.writeHeapSnapshot}. */
42
+ export interface WriteServerHeapSnapshotArgs {
43
+ /** Optional label folded into the snapshot filename. */
44
+ label?: string;
45
+ /** Directory to write into; defaults to the OS temp dir when absent or not present on disk. */
46
+ directory?: string;
47
+ }
48
+ /**
49
+ * Memory / state diagnostics the running server process exposes. Implemented by
50
+ * the framework `DataServer`; computed in the data-server process (the heavy
51
+ * model store), so the snapshots reflect the process that actually holds the
52
+ * workspace AST/CST — the one that OOMs.
53
+ */
54
+ export interface DataServerDiagnosticsProtocol {
55
+ /**
56
+ * Capture a server-process state snapshot — heap, rss, V8 stats, event-loop
57
+ * utilisation, CPU usage, and document counts — and return it formatted.
58
+ */
59
+ dumpServerState(args: DumpServerStateArgs): Promise<string>;
60
+ /**
61
+ * Write a V8 heap snapshot of the server process to disk (full GC first;
62
+ * briefly pauses the process) and return the absolute file path. Open it in
63
+ * Chrome DevTools > Memory > Load for retained-size analysis.
64
+ */
65
+ writeHeapSnapshot(args: WriteServerHeapSnapshotArgs): Promise<string>;
66
+ /**
67
+ * Capture a pod/container memory snapshot — cgroup v2/v1 current/peak/limit
68
+ * plus a per-process RSS tree, the figure the Kubernetes OOM-killer watches.
69
+ * Degrades to a "no cgroup controller" note outside a container.
70
+ */
71
+ dumpPodMemory(): Promise<string>;
72
+ /**
73
+ * Begin a windowed sampled-profile capture (CPU / allocation / GC / event-loop
74
+ * delay, per the named dimensions) of the server process. Sampling does NOT
75
+ * pause the process. Rejects if a capture is already active — one inspector
76
+ * session at a time. Pair with {@link stopProfiling}.
77
+ */
78
+ startProfiling(args: StartProfilingArgs): Promise<void>;
79
+ /**
80
+ * Stop the active capture, write the requested profile artefacts, and return
81
+ * the formatted profile report. Rejects if no capture is active.
82
+ */
83
+ stopProfiling(args: StopProfilingArgs): Promise<string>;
84
+ /**
85
+ * Return the per-method RPC/LSP latency + throughput collected so far (count,
86
+ * p50/p99/max, total per method). Empty when the head was not started with a
87
+ * latency collector. Read-only — does not reset the window.
88
+ */
89
+ getLatency(): Promise<LatencyReport>;
90
+ }
91
+ /**
92
+ * Request-method names on {@link DataServerDiagnosticsProtocol}. The framework
93
+ * `DataServer` appends these to its registered method set by default; the
94
+ * `as const satisfies` constraint keeps the array in lockstep with the interface.
95
+ */
96
+ export declare const DATA_SERVER_DIAGNOSTICS_METHODS: readonly ["dumpServerState", "writeHeapSnapshot", "dumpPodMemory", "startProfiling", "stopProfiling", "getLatency"];
97
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/data/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IACjC,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEvD,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAC/B,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iHAAiH;IACjH,SAAS,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,6EAA6E;AAC7E,MAAM,WAAW,2BAA2B;IACzC,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,WAAW,6BAA6B;IAC3C;;;OAGG;IACH,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5D;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtE;;;;OAIG;IACH,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjC;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExD;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,qHAOoC,CAAC"}
@@ -0,0 +1,25 @@
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.DATA_SERVER_DIAGNOSTICS_METHODS = void 0;
12
+ /**
13
+ * Request-method names on {@link DataServerDiagnosticsProtocol}. The framework
14
+ * `DataServer` appends these to its registered method set by default; the
15
+ * `as const satisfies` constraint keeps the array in lockstep with the interface.
16
+ */
17
+ exports.DATA_SERVER_DIAGNOSTICS_METHODS = [
18
+ 'dumpServerState',
19
+ 'writeHeapSnapshot',
20
+ 'dumpPodMemory',
21
+ 'startProfiling',
22
+ 'stopProfiling',
23
+ 'getLatency'
24
+ ];
25
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/data/diagnostics.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAgGlF;;;;GAIG;AACU,QAAA,+BAA+B,GAAG;IAC5C,iBAAiB;IACjB,mBAAmB;IACnB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,YAAY;CACiE,CAAC"}
@@ -0,0 +1,107 @@
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 { TransferDiagnostic } from '../transfer-diagnostic';
10
+ import type { TransferElement } from '../transfer-element';
11
+ import type { Project } from '../project';
12
+ import type { TransferDocument } from '../transfer-document';
13
+ /**
14
+ * Why an update event fired. Subscribers filter on reason for behaviour
15
+ * decisions (e.g. dirty-flag handling, undo-history grouping, telemetry):
16
+ *
17
+ * - `'changed'` — the URI appeared in `DocumentBuilder.onUpdate`'s
18
+ * `changed` list. The framework's underlying primitive is "this URI was
19
+ * passed to `documentBuilder.update(changed, deleted)`", which spans
20
+ * `didChange` text-document events, `notifyDidChangeTextDocument` calls,
21
+ * and any programmatic `documentBuilder.update([uri], [])` invocation.
22
+ * The name matches Langium's own `changed` parameter — it's vague-on-
23
+ * purpose because the underlying primitive is.
24
+ * - `'rebuilt'` — the URI was rebuilt as a cascade from another URI's
25
+ * build (dependency graph re-derivation), without itself being passed to
26
+ * `documentBuilder.update`. The complement of `'changed'`.
27
+ * - `'saved'` — emitted by adopters that synthesise a unified update stream
28
+ * from both `onDocumentUpdated` and `onDocumentSaved`. The framework's own
29
+ * `dispatchPhaseEvent` does NOT emit `'saved'` — saves take the dedicated
30
+ * `DataClientProtocol.onDocumentSaved` channel.
31
+ * - `'deleted'` — the URI appeared in `DocumentBuilder.onUpdate`'s
32
+ * `deleted` list. The backing file was removed.
33
+ */
34
+ export type TransferDocumentUpdateReason = 'changed' | 'rebuilt' | 'saved' | 'deleted';
35
+ /**
36
+ * Delivered on the data-server when a document's content (or existence)
37
+ * changed. Subscribers receive this via `DocumentServerProtocol.watchModelDocument`.
38
+ *
39
+ * The `document` field carries the latest built state — diagnostics + root
40
+ * are coherent with each other at the time the event fired.
41
+ */
42
+ export interface TransferDocumentUpdatedEvent<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
43
+ document: TransferDocument<TTransfer, TDiagnostic>;
44
+ /** Stable identifier of the client that triggered the update. */
45
+ sourceClientId: string;
46
+ reason: TransferDocumentUpdateReason;
47
+ }
48
+ /** Callback shape for `DataClientProtocol.onDocumentUpdated`. */
49
+ export type TransferDocumentUpdatedListener<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> = (event: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>) => void;
50
+ /**
51
+ * Delivered on the data-server when a document was persisted to disk via
52
+ * `DataServerProtocol.saveModelDocument`. Distinct from
53
+ * {@link TransferDocumentUpdatedEvent}: subscribers that only care about
54
+ * persistence (external sync, editor "saved" indicators, dirty-flag
55
+ * clear) listen for this event family instead of filtering an update
56
+ * stream for `reason: 'saved'`.
57
+ *
58
+ * The `document` field carries the post-save built state — same shape
59
+ * the synchronous `saveModelDocument` RPC response returns, delivered
60
+ * to subscribers (`DataClientProtocol.onDocumentSaved`) so non-caller
61
+ * clients see the persistence event too.
62
+ */
63
+ export interface TransferDocumentSavedEvent<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
64
+ document: TransferDocument<TTransfer, TDiagnostic>;
65
+ /**
66
+ * The client whose `saveModelDocument` call produced this. Every subscriber
67
+ * receives the event including the originator, which already had the same
68
+ * state as the RPC response — compare against your own id to drop the echo
69
+ * rather than re-rendering from it.
70
+ */
71
+ sourceClientId: string;
72
+ }
73
+ /** Callback shape for `DataClientProtocol.onDocumentSaved`. */
74
+ export type TransferDocumentSavedListener<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> = (event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>) => void;
75
+ /**
76
+ * Why a project-change event fired. `added` — the project was newly
77
+ * registered (descriptor discovered); `updated` — the project's
78
+ * descriptor content changed and its registry entry was refreshed
79
+ * (same id, possibly different version / dependencies / adopter-specific
80
+ * fields); `removed` — the project's descriptor disappeared and the
81
+ * registry entry was dropped.
82
+ */
83
+ export type ProjectChangeReason = 'added' | 'updated' | 'removed';
84
+ /**
85
+ * Delivered on the data-server when a project's lifecycle state changed
86
+ * (added / updated / removed in the registry). Subscribers receive this
87
+ * via `DataClientProtocol.onProjectsChanged`.
88
+ *
89
+ * Granularity is one event per affected project: an internal registry
90
+ * diff with three additions and one removal fans out to four wire
91
+ * notifications. This matches the typical client-side pattern of "react
92
+ * to one project at a time" (refresh a tree entry, update a tab badge,
93
+ * etc.) without forcing clients to walk arrays.
94
+ *
95
+ * For `reason: 'removed'`, the carried {@link project} is the pre-removal
96
+ * snapshot — by the time the event fires, the registry has already
97
+ * cleared the entry, so clients that need the removed project's metadata
98
+ * (id, version, dependencies, adopter-specific fields) read it here
99
+ * instead of maintaining their own snapshot.
100
+ */
101
+ export interface ProjectsChangedEvent<TProject extends Project = Project> {
102
+ readonly project: TProject;
103
+ readonly reason: ProjectChangeReason;
104
+ }
105
+ /** Callback shape for `DataClientProtocol.onProjectsChanged`. */
106
+ export type ProjectsChangedListener<TProject extends Project = Project> = (event: ProjectsChangedEvent<TProject>) => void;
107
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/data/events.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,4BAA4B,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEvF;;;;;;GAMG;AACH,MAAM,WAAW,4BAA4B,CAC1C,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB;IAE3D,QAAQ,EAAE,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACnD,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,4BAA4B,CAAC;CACvC;AAED,iEAAiE;AACjE,MAAM,MAAM,+BAA+B,CACxC,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,IAC1D,CAAC,KAAK,EAAE,4BAA4B,CAAC,SAAS,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC;AAE1E;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,0BAA0B,CACxC,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB;IAE3D,QAAQ,EAAE,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACnD;;;;;OAKG;IACH,cAAc,EAAE,MAAM,CAAC;CACzB;AAED,+DAA+D;AAC/D,MAAM,MAAM,6BAA6B,CACtC,SAAS,SAAS,eAAe,EACjC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,IAC1D,CAAC,KAAK,EAAE,0BAA0B,CAAC,SAAS,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAElE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,oBAAoB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO;IACrE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;CACvC;AAED,iEAAiE;AACjE,MAAM,MAAM,uBAAuB,CAAC,QAAQ,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,KAAK,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC"}
@@ -0,0 +1,11 @@
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
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/data/events.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF"}
@@ -0,0 +1,15 @@
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
+ export * from './data-protocol-methods';
10
+ export * from './data-server-protocol';
11
+ export * from './diagnostics';
12
+ export * from './events';
13
+ export * from './methods';
14
+ export * from './requests';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAUlF,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,38 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ var desc = Object.getOwnPropertyDescriptor(m, k);
13
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
+ }
16
+ Object.defineProperty(o, k2, desc);
17
+ }) : (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ o[k2] = m[k];
20
+ }));
21
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ // Subpath barrel for `@hydranium/protocol/data` — typed bidirectional
26
+ // contract for the data-server protocol head, split into composable
27
+ // `*ServerProtocol` / `*ClientProtocol` fragments. Implementations live in
28
+ // `@hydranium/data-server`; typed proxies are produced by the
29
+ // direction-neutral `createRpcProxy` (in `../rpc`) with the data-server
30
+ // method-name lists + wire prefix exported here from
31
+ // `./data-protocol-methods.ts`.
32
+ __exportStar(require("./data-protocol-methods"), exports);
33
+ __exportStar(require("./data-server-protocol"), exports);
34
+ __exportStar(require("./diagnostics"), exports);
35
+ __exportStar(require("./events"), exports);
36
+ __exportStar(require("./methods"), exports);
37
+ __exportStar(require("./requests"), exports);
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,8DAA8D;AAC9D,wEAAwE;AACxE,qDAAqD;AACrD,gCAAgC;AAEhC,0DAAwC;AACxC,yDAAuC;AACvC,gDAA8B;AAC9B,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B"}