@hydranium/protocol 1.0.0-next.27 → 1.0.0-next.271

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/README.md +44 -49
  2. package/lib/abstract-logger.d.ts +5 -0
  3. package/lib/abstract-logger.d.ts.map +1 -1
  4. package/lib/abstract-logger.js +7 -0
  5. package/lib/abstract-logger.js.map +1 -1
  6. package/lib/client/data-connection.d.ts +248 -0
  7. package/lib/client/data-connection.d.ts.map +1 -0
  8. package/lib/client/data-connection.js +439 -0
  9. package/lib/client/data-connection.js.map +1 -0
  10. package/lib/client/data-events.d.ts +13 -1
  11. package/lib/client/data-events.d.ts.map +1 -1
  12. package/lib/client/data-events.js +21 -0
  13. package/lib/client/data-events.js.map +1 -1
  14. package/lib/client/data-port.d.ts +34 -24
  15. package/lib/client/data-port.d.ts.map +1 -1
  16. package/lib/client/data-session.d.ts +571 -89
  17. package/lib/client/data-session.d.ts.map +1 -1
  18. package/lib/client/data-session.js +938 -113
  19. package/lib/client/data-session.js.map +1 -1
  20. package/lib/client/index.d.ts +14 -9
  21. package/lib/client/index.d.ts.map +1 -1
  22. package/lib/client/index.js +14 -9
  23. package/lib/client/index.js.map +1 -1
  24. package/lib/client/message-relay.d.ts +4 -4
  25. package/lib/client/message-relay.js +4 -4
  26. package/lib/client/message-relay.js.map +1 -1
  27. package/lib/client/post-message-transport.d.ts +64 -3
  28. package/lib/client/post-message-transport.d.ts.map +1 -1
  29. package/lib/client/post-message-transport.js +175 -1
  30. package/lib/client/post-message-transport.js.map +1 -1
  31. package/lib/client/rpc-connection.d.ts +157 -0
  32. package/lib/client/rpc-connection.d.ts.map +1 -0
  33. package/lib/client/rpc-connection.js +214 -0
  34. package/lib/client/rpc-connection.js.map +1 -0
  35. package/lib/client-ids.d.ts +45 -0
  36. package/lib/client-ids.d.ts.map +1 -0
  37. package/lib/client-ids.js +48 -0
  38. package/lib/client-ids.js.map +1 -0
  39. package/lib/clock.d.ts +50 -10
  40. package/lib/clock.d.ts.map +1 -1
  41. package/lib/clock.js +36 -1
  42. package/lib/clock.js.map +1 -1
  43. package/lib/console-logger.d.ts +23 -0
  44. package/lib/console-logger.d.ts.map +1 -0
  45. package/lib/console-logger.js +39 -0
  46. package/lib/console-logger.js.map +1 -0
  47. package/lib/data/data-protocol-methods.d.ts +4 -4
  48. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  49. package/lib/data/data-protocol-methods.js +12 -1
  50. package/lib/data/data-protocol-methods.js.map +1 -1
  51. package/lib/data/data-server-protocol.d.ts +132 -41
  52. package/lib/data/data-server-protocol.d.ts.map +1 -1
  53. package/lib/data/events.d.ts +117 -21
  54. package/lib/data/events.d.ts.map +1 -1
  55. package/lib/data/requests.d.ts +69 -11
  56. package/lib/data/requests.d.ts.map +1 -1
  57. package/lib/debouncer.d.ts +3 -3
  58. package/lib/debouncer.d.ts.map +1 -1
  59. package/lib/debouncer.js +6 -9
  60. package/lib/debouncer.js.map +1 -1
  61. package/lib/errors.d.ts +178 -30
  62. package/lib/errors.d.ts.map +1 -1
  63. package/lib/errors.js +263 -32
  64. package/lib/errors.js.map +1 -1
  65. package/lib/glsp-request-model-args.d.ts +16 -0
  66. package/lib/glsp-request-model-args.d.ts.map +1 -0
  67. package/lib/glsp-request-model-args.js +19 -0
  68. package/lib/glsp-request-model-args.js.map +1 -0
  69. package/lib/glsp-save-model-actions.d.ts +50 -0
  70. package/lib/glsp-save-model-actions.d.ts.map +1 -0
  71. package/lib/glsp-save-model-actions.js +28 -0
  72. package/lib/glsp-save-model-actions.js.map +1 -0
  73. package/lib/index.d.ts +6 -0
  74. package/lib/index.d.ts.map +1 -1
  75. package/lib/index.js +6 -0
  76. package/lib/index.js.map +1 -1
  77. package/lib/latency-collector.d.ts +8 -4
  78. package/lib/latency-collector.d.ts.map +1 -1
  79. package/lib/latency-collector.js.map +1 -1
  80. package/lib/logger.d.ts +27 -6
  81. package/lib/logger.d.ts.map +1 -1
  82. package/lib/logger.js +31 -3
  83. package/lib/logger.js.map +1 -1
  84. package/lib/messages/index.d.ts +4 -2
  85. package/lib/messages/index.d.ts.map +1 -1
  86. package/lib/messages/index.js +14 -4
  87. package/lib/messages/index.js.map +1 -1
  88. package/lib/messages/primitives.d.ts +71 -10
  89. package/lib/messages/primitives.d.ts.map +1 -1
  90. package/lib/messages/primitives.js +55 -3
  91. package/lib/messages/primitives.js.map +1 -1
  92. package/lib/model-server.d.ts +60 -13
  93. package/lib/model-server.d.ts.map +1 -1
  94. package/lib/model-server.js +4 -2
  95. package/lib/model-server.js.map +1 -1
  96. package/lib/model-service/base-version.d.ts +64 -0
  97. package/lib/model-service/base-version.d.ts.map +1 -0
  98. package/lib/model-service/base-version.js +43 -0
  99. package/lib/model-service/base-version.js.map +1 -0
  100. package/lib/model-service/index.d.ts +1 -1
  101. package/lib/model-service/index.d.ts.map +1 -1
  102. package/lib/model-service/index.js +4 -5
  103. package/lib/model-service/index.js.map +1 -1
  104. package/lib/model-service/reference-candidate.d.ts +5 -3
  105. package/lib/model-service/reference-candidate.d.ts.map +1 -1
  106. package/lib/{model-service/args.js → node/index.d.ts} +2 -3
  107. package/lib/node/index.d.ts.map +1 -0
  108. package/lib/node/index.js +29 -0
  109. package/lib/node/index.js.map +1 -0
  110. package/lib/node/process-memory.d.ts +66 -0
  111. package/lib/node/process-memory.d.ts.map +1 -0
  112. package/lib/node/process-memory.js +291 -0
  113. package/lib/node/process-memory.js.map +1 -0
  114. package/lib/noop-logger.d.ts.map +1 -1
  115. package/lib/noop-logger.js.map +1 -1
  116. package/lib/observable-value.js.map +1 -1
  117. package/lib/patch-merge.d.ts +35 -32
  118. package/lib/patch-merge.d.ts.map +1 -1
  119. package/lib/patch-merge.js +67 -23
  120. package/lib/patch-merge.js.map +1 -1
  121. package/lib/profile-session.d.ts +8 -4
  122. package/lib/profile-session.d.ts.map +1 -1
  123. package/lib/profile-session.js.map +1 -1
  124. package/lib/random-uuid.d.ts +14 -0
  125. package/lib/random-uuid.d.ts.map +1 -0
  126. package/lib/random-uuid.js +24 -0
  127. package/lib/random-uuid.js.map +1 -0
  128. package/lib/reconcile-write.d.ts +65 -0
  129. package/lib/reconcile-write.d.ts.map +1 -0
  130. package/lib/reconcile-write.js +67 -0
  131. package/lib/reconcile-write.js.map +1 -0
  132. package/lib/rpc/bind-rpc-methods.d.ts +33 -3
  133. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  134. package/lib/rpc/bind-rpc-methods.js +32 -3
  135. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  136. package/lib/rpc/create-rpc-proxy.d.ts +10 -0
  137. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  138. package/lib/rpc/create-rpc-proxy.js +12 -2
  139. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  140. package/lib/rpc/index.d.ts +1 -0
  141. package/lib/rpc/index.d.ts.map +1 -1
  142. package/lib/rpc/index.js +1 -0
  143. package/lib/rpc/index.js.map +1 -1
  144. package/lib/rpc/send-by-method-name.d.ts +76 -0
  145. package/lib/rpc/send-by-method-name.d.ts.map +1 -0
  146. package/lib/rpc/send-by-method-name.js +120 -0
  147. package/lib/rpc/send-by-method-name.js.map +1 -0
  148. package/lib/rpc/wire-prefix.js.map +1 -1
  149. package/lib/testing/catalogue-audit.d.ts +80 -0
  150. package/lib/testing/catalogue-audit.d.ts.map +1 -0
  151. package/lib/testing/catalogue-audit.js +94 -0
  152. package/lib/testing/catalogue-audit.js.map +1 -0
  153. package/lib/testing/data-doubles.d.ts +41 -12
  154. package/lib/testing/data-doubles.d.ts.map +1 -1
  155. package/lib/testing/data-doubles.js +56 -8
  156. package/lib/testing/data-doubles.js.map +1 -1
  157. package/lib/testing/fake-clock.d.ts +17 -2
  158. package/lib/testing/fake-clock.d.ts.map +1 -1
  159. package/lib/testing/fake-clock.js +61 -46
  160. package/lib/testing/fake-clock.js.map +1 -1
  161. package/lib/testing/index.d.ts +1 -0
  162. package/lib/testing/index.d.ts.map +1 -1
  163. package/lib/testing/index.js +5 -2
  164. package/lib/testing/index.js.map +1 -1
  165. package/lib/testing/node/duplex-connection.d.ts.map +1 -1
  166. package/lib/testing/node/duplex-connection.js +3 -2
  167. package/lib/testing/node/duplex-connection.js.map +1 -1
  168. package/lib/testing/node/duplex-stream.js.map +1 -1
  169. package/lib/testing/node/index.d.ts +1 -0
  170. package/lib/testing/node/index.d.ts.map +1 -1
  171. package/lib/testing/node/index.js +2 -2
  172. package/lib/testing/node/index.js.map +1 -1
  173. package/lib/testing/node/message-port-pair.d.ts +25 -0
  174. package/lib/testing/node/message-port-pair.d.ts.map +1 -0
  175. package/lib/testing/node/message-port-pair.js +26 -0
  176. package/lib/testing/node/message-port-pair.js.map +1 -0
  177. package/lib/testing/wait-for.d.ts +3 -2
  178. package/lib/testing/wait-for.d.ts.map +1 -1
  179. package/lib/testing/wait-for.js +40 -10
  180. package/lib/testing/wait-for.js.map +1 -1
  181. package/lib/tracer.d.ts.map +1 -1
  182. package/lib/tracer.js +5 -9
  183. package/lib/tracer.js.map +1 -1
  184. package/lib/transfer-diagnostic.d.ts +33 -0
  185. package/lib/transfer-diagnostic.d.ts.map +1 -1
  186. package/lib/transfer-diagnostic.js +23 -0
  187. package/lib/transfer-diagnostic.js.map +1 -1
  188. package/lib/transfer-document.d.ts +70 -32
  189. package/lib/transfer-document.d.ts.map +1 -1
  190. package/lib/transfer-document.js +17 -9
  191. package/lib/transfer-document.js.map +1 -1
  192. package/lib/uri.d.ts.map +1 -1
  193. package/lib/uri.js.map +1 -1
  194. package/lib/util.d.ts +8 -2
  195. package/lib/util.d.ts.map +1 -1
  196. package/lib/util.js +32 -4
  197. package/lib/util.js.map +1 -1
  198. package/package.json +24 -40
  199. package/src/abstract-logger.ts +8 -0
  200. package/src/client/data-connection.ts +535 -0
  201. package/src/client/data-events.ts +33 -1
  202. package/src/client/data-port.ts +36 -25
  203. package/src/client/data-session.ts +1198 -135
  204. package/src/client/index.ts +14 -9
  205. package/src/client/message-relay.ts +4 -4
  206. package/src/client/post-message-transport.ts +219 -4
  207. package/src/client/rpc-connection.ts +281 -0
  208. package/src/client-ids.ts +49 -0
  209. package/src/clock.ts +68 -10
  210. package/src/console-logger.ts +39 -0
  211. package/src/data/data-protocol-methods.ts +13 -4
  212. package/src/data/data-server-protocol.ts +157 -41
  213. package/src/data/events.ts +123 -21
  214. package/src/data/requests.ts +74 -11
  215. package/src/debouncer.ts +7 -10
  216. package/src/errors.ts +312 -40
  217. package/src/glsp-request-model-args.ts +16 -0
  218. package/src/glsp-save-model-actions.ts +59 -0
  219. package/src/index.ts +6 -0
  220. package/src/latency-collector.ts +8 -3
  221. package/src/logger.ts +33 -7
  222. package/src/messages/index.ts +4 -2
  223. package/src/messages/primitives.ts +102 -10
  224. package/src/model-server.ts +64 -19
  225. package/src/model-service/base-version.ts +72 -0
  226. package/src/model-service/index.ts +4 -5
  227. package/src/model-service/reference-candidate.ts +5 -3
  228. package/src/node/index.ts +14 -0
  229. package/src/node/process-memory.ts +299 -0
  230. package/src/patch-merge.ts +97 -42
  231. package/src/profile-session.ts +9 -4
  232. package/src/random-uuid.ts +21 -0
  233. package/src/reconcile-write.ts +124 -0
  234. package/src/rpc/README.md +6 -6
  235. package/src/rpc/bind-rpc-methods.ts +59 -4
  236. package/src/rpc/create-rpc-proxy.ts +20 -2
  237. package/src/rpc/index.ts +1 -0
  238. package/src/rpc/send-by-method-name.ts +140 -0
  239. package/src/testing/catalogue-audit.ts +111 -0
  240. package/src/testing/data-doubles.ts +141 -19
  241. package/src/testing/fake-clock.ts +76 -48
  242. package/src/testing/index.ts +5 -2
  243. package/src/testing/node/duplex-connection.ts +3 -2
  244. package/src/testing/node/index.ts +2 -2
  245. package/src/testing/node/message-port-pair.ts +40 -0
  246. package/src/testing/wait-for.ts +38 -11
  247. package/src/tracer.ts +5 -9
  248. package/src/transfer-diagnostic.ts +40 -0
  249. package/src/transfer-document.ts +87 -34
  250. package/src/util.ts +33 -6
  251. package/lib/model-service/args.d.ts +0 -64
  252. package/lib/model-service/args.d.ts.map +0 -1
  253. package/lib/model-service/args.js.map +0 -1
  254. package/src/model-service/args.ts +0 -67
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydranium/protocol",
3
- "version": "1.0.0-next.27",
3
+ "version": "1.0.0-next.271",
4
4
  "description": "Generic, language-agnostic types, constants, and pure utilities for the hydranium framework.",
5
5
  "keywords": [
6
6
  "hydranium",
@@ -14,16 +14,23 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/eclipse-emfcloud/hydranium/issues"
16
16
  },
17
+ "license": "MIT",
18
+ "author": {
19
+ "name": "Hydranium Team"
20
+ },
17
21
  "repository": {
18
22
  "type": "git",
19
23
  "url": "https://github.com/eclipse-emfcloud/hydranium.git",
20
24
  "directory": "packages/protocol"
21
25
  },
22
- "license": "MIT",
23
- "author": {
24
- "name": "Hydranium Team"
25
- },
26
+ "files": [
27
+ "lib",
28
+ "src",
29
+ "!lib/**/*.tsbuildinfo"
30
+ ],
26
31
  "sideEffects": false,
32
+ "main": "lib/index.js",
33
+ "types": "lib/index.d.ts",
27
34
  "exports": {
28
35
  ".": {
29
36
  "types": "./lib/index.d.ts",
@@ -33,10 +40,6 @@
33
40
  "types": "./lib/client/index.d.ts",
34
41
  "default": "./lib/client/index.js"
35
42
  },
36
- "./lib/client": {
37
- "types": "./lib/client/index.d.ts",
38
- "default": "./lib/client/index.js"
39
- },
40
43
  "./data": {
41
44
  "types": "./lib/data/index.d.ts",
42
45
  "default": "./lib/data/index.js"
@@ -45,9 +48,9 @@
45
48
  "types": "./lib/messages/index.d.ts",
46
49
  "default": "./lib/messages/index.js"
47
50
  },
48
- "./lib/messages": {
49
- "types": "./lib/messages/index.d.ts",
50
- "default": "./lib/messages/index.js"
51
+ "./node": {
52
+ "types": "./lib/node/index.d.ts",
53
+ "default": "./lib/node/index.js"
51
54
  },
52
55
  "./testing": {
53
56
  "types": "./lib/testing/index.d.ts",
@@ -56,31 +59,15 @@
56
59
  "./testing/node": {
57
60
  "types": "./lib/testing/node/index.d.ts",
58
61
  "default": "./lib/testing/node/index.js"
59
- },
60
- "./lib/data": {
61
- "types": "./lib/data/index.d.ts",
62
- "default": "./lib/data/index.js"
63
- },
64
- "./lib/testing": {
65
- "types": "./lib/testing/index.d.ts",
66
- "default": "./lib/testing/index.js"
67
- },
68
- "./lib/testing/node": {
69
- "types": "./lib/testing/node/index.d.ts",
70
- "default": "./lib/testing/node/index.js"
71
62
  }
72
63
  },
73
- "main": "lib/index.js",
74
- "types": "lib/index.d.ts",
75
- "files": [
76
- "lib",
77
- "src",
78
- "!lib/**/*.tsbuildinfo"
79
- ],
64
+ "publishConfig": {
65
+ "access": "public"
66
+ },
80
67
  "scripts": {
81
68
  "build": "tsc -b",
82
69
  "clean": "rimraf lib tsconfig.tsbuildinfo",
83
- "lint": "eslint src test --max-warnings 0",
70
+ "lint": "oxlint --format stylish --config ../../oxlint.config.cjs src test --max-warnings 0",
84
71
  "prepack": "node -e \"const m=require('./package.json'),fs=require('node:fs');const missing=[m.main,...Object.values(m.bin||{})].filter(entry=>entry&&!fs.existsSync(entry));if(missing.length){console.error('prepack '+m.name+': not built ('+missing.join(', ')+' missing). Run the build before packing: a files entry that matches nothing is skipped silently, so the tarball would ship src only.');process.exit(1);}\"",
85
72
  "test": "npm run typecheck:test && vitest run",
86
73
  "typecheck:test": "tsc --noEmit -p tsconfig.test.json",
@@ -92,18 +79,15 @@
92
79
  "devDependencies": {
93
80
  "fast-check": "^3.23.2",
94
81
  "rimraf": "^5.0.0",
95
- "typescript": "^5.8.0",
96
- "vscode-jsonrpc": "9.0.1"
82
+ "typescript": "^7.0.2",
83
+ "vscode-jsonrpc": "9.0.0"
97
84
  },
98
85
  "peerDependencies": {
99
- "vscode-jsonrpc": "9.0.1"
86
+ "vscode-jsonrpc": "^9.0.0"
100
87
  },
101
88
  "engines": {
102
89
  "node": ">=22.13"
103
90
  },
104
- "publishConfig": {
105
- "access": "public"
106
- },
107
- "//peerDependencies": "`vscode-jsonrpc` is EXACT rather than a range, because it is one link of an atomic chain with no independently movable link: `vscode-languageserver-protocol` depends on it at exactly 9.0.1, so any other value an adopter supplies is a SECOND physical copy rather than an upgrade. This wire stack breaks on copy identity rather than on structure — `ParameterStructures.auto` is a singleton compared by `===` in connection.js, so a request type built by one copy and sent over a connection owned by the other throws `Unknown parameter structure auto`. A caret or union range was rejected because npm then resolves a `vscode-jsonrpc@8.2.0` tree SILENTLY, with no diagnostic at all, and the failure surfaces only later at server init. Exact does not fail the install either — npm downgrades an unsatisfiable peer to a warning — but it is a NAMED ERESOLVE warning printing the required version beside the found one, and a hard error for anyone installing with `--strict-peer-deps`. It does NOT prevent a NESTED copy — `@eclipse-glsp/*` carries its own exact `vscode-jsonrpc@8.2.0` dependency and root `overrides` do not ship — so a consumer of the GLSP head must pin the chain in its own manifest.",
108
- "//prepack": "The publish guard, and it deliberately is NOT a `prepare`: npm runs a workspace `prepare` BEFORE the root `postinstall` that applies patches/vscode-jsonrpc+9.0.1.patch, so building there fails on a cold clone and npm rolls the entire install back. `prepack` runs only when a tarball is made (`npm pack`, `npm publish`) and never on install, so it cannot break the install it has no business touching. It FAILS rather than rebuilds, because the rebuild is exactly the part that ordering defeats. What it defends against: `files` lists `lib`, `lib` is gitignored, and a `files` entry matching nothing is skipped SILENTLY — so `npm publish` from an unbuilt tree emits a tarball of `src` and nothing else, with no error."
91
+ "//peerDependencies": "`vscode-jsonrpc` takes a caret, so the framework shares the transport the LSP connection resolves, which an `init` scaffold pins: each `vscode-languageserver-protocol` release pins its transport exactly, so an exact peer would name a copy a fresh install rarely holds. The caret excludes 8.x, so a tree whose top holds GLSP's copy fails the peer with a named ERESOLVE warning, an error under `--strict-peer-deps`, rather than resolving silently. No peer reaches a NESTED copy, such as GLSP's or one the LSP packages nest. The wire compares message types and `ResponseError`s by copy identity, so the framework sends typed messages by method name and recognises errors with `isResponseError` rather than `instanceof`.",
92
+ "//prepack": "The publish guard, a `prepack` rather than a `prepare`: `prepack` runs only when a tarball is made (`npm pack`, `npm publish`) and never on install, so it cannot break the install it has no business touching. What it defends against: `files` lists `lib`, `lib` is gitignored, and a `files` entry matching nothing is skipped SILENTLY — so `npm publish` from an unbuilt tree emits a tarball of `src` and nothing else, with no error."
109
93
  }
@@ -46,6 +46,14 @@ export abstract class AbstractLogger implements Logger {
46
46
  return Format.timestamp(new Date(this.clock().now()));
47
47
  }
48
48
 
49
+ /**
50
+ * The `[Label - HH:MM:SS.mmm] [component]` prefix every sink starts a line
51
+ * with. The label is padded to the widest, so timestamps line up across sinks.
52
+ */
53
+ protected formatLinePrefix(label: string): string {
54
+ return `[${label.padEnd(5)} - ${this.timestamp()}]${this.component ? ` [${this.component}]` : ''}`;
55
+ }
56
+
49
57
  error(message?: string, ...args: unknown[]): this {
50
58
  this.send('error', message, args);
51
59
  return this;
@@ -0,0 +1,535 @@
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
+ import { Disposable, Emitter, type Event } from 'vscode-jsonrpc';
11
+ import { FRAMEWORK_CLIENT_IDS } from '../client-ids';
12
+ import {
13
+ DATA_CLIENT_PROTOCOL_METHODS,
14
+ DATA_SERVER_WIRE_PREFIX,
15
+ type DataClientProtocol,
16
+ type DataServerProtocol,
17
+ type DiagnosticOf,
18
+ type ProjectOf,
19
+ type TransferDocumentDeletedEvent,
20
+ type TransferDocumentDirtyChangedEvent,
21
+ type TransferDocumentUpdatedEvent
22
+ } from '../data';
23
+ import { DuplicateClientIdError, ReservedClientIdError } from '../errors';
24
+ import type { Logger } from '../logger';
25
+ import { defineMessage, describeError, describeErrorWithStack, resolve } from '../messages/primitives';
26
+ import { NoopLogger } from '../noop-logger';
27
+ import { randomUuid } from '../random-uuid';
28
+ import type { TransferElement } from '../transfer-element';
29
+ import { DataEvents } from './data-events';
30
+ import type { DataPort } from './data-port';
31
+ import { DataSession, type DataSessionFactory } from './data-session';
32
+ import { RpcConnection, type RpcConnectionGeneration, type RpcConnectionLifecycle } from './rpc-connection';
33
+
34
+ /**
35
+ * A watch {@link DataConnection.watchDocument} keeps could not be sent again to
36
+ * a connection that became ready after a drop; the next one sends it again.
37
+ */
38
+ export const DATA_CONNECTION_WATCH_RESTORE_FAILED = defineMessage(
39
+ 'hydranium/protocol/data-connection-watch-restore-failed',
40
+ 'Could not watch {uri} again after reconnecting to the data server: {detail}'
41
+ );
42
+
43
+ /**
44
+ * A session's restore threw when its connection came back; the connection
45
+ * went on restoring the others.
46
+ */
47
+ export const DATA_CONNECTION_SESSION_RESTORE_FAILED = defineMessage(
48
+ 'hydranium/protocol/data-connection-session-restore-failed',
49
+ 'Could not restore a session after reconnecting to the data server: {detail}'
50
+ );
51
+
52
+ /** Options for {@link DataConnection}. */
53
+ export interface DataConnectionOptions<
54
+ TTransfer extends TransferElement = TransferElement,
55
+ TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>
56
+ > extends RpcConnectionLifecycle {
57
+ /**
58
+ * Wire namespace the server is addressed under. Defaults to the
59
+ * framework's {@link DATA_SERVER_WIRE_PREFIX}, which is what an unmodified
60
+ * `DataServer` binds. Override only alongside the server's own
61
+ * `methodNamespace` option — a mismatch turns every request into
62
+ * "Unhandled method" rather than failing at wire-up.
63
+ */
64
+ readonly methodNamespace?: string;
65
+ /** Builds the sessions `createSession` hands out. Defaults to a plain {@link DataSession}. */
66
+ readonly sessionFactory?: DataSessionFactory<TTransfer, TServer>;
67
+ }
68
+
69
+ /** {@link DataConnectionOptions} for a client that does not speak {@link DataClientProtocol}. */
70
+ export interface DataConnectionOptionsWithMethods<
71
+ TClient extends object,
72
+ TTransfer extends TransferElement = TransferElement,
73
+ TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>
74
+ > extends DataConnectionOptions<TTransfer, TServer> {
75
+ /**
76
+ * Method names of the client to bind as inbound handlers. Declare it
77
+ * `as const satisfies ReadonlyArray<keyof YourClient & string>` so the list
78
+ * cannot drift from the interface.
79
+ */
80
+ readonly clientMethods: readonly (keyof TClient & string)[];
81
+ }
82
+
83
+ /**
84
+ * Trailing constructor arguments, required only when the client cannot take
85
+ * the framework's default method list.
86
+ *
87
+ * `bindRpcMethods` throws for a name the target does not implement, so a
88
+ * request/response-only client binding the default list fails at wire-up. The
89
+ * conditional turns that into a compile error.
90
+ */
91
+ export type DataConnectionArgs<
92
+ TTransfer extends TransferElement,
93
+ TClient extends object,
94
+ TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>
95
+ > =
96
+ TClient extends DataClientProtocol<TTransfer>
97
+ ? [options?: DataConnectionOptions<TTransfer, TServer> & Partial<DataConnectionOptionsWithMethods<TClient, TTransfer, TServer>>]
98
+ : [options: DataConnectionOptionsWithMethods<TClient, TTransfer, TServer>];
99
+
100
+ /**
101
+ * A {@link RpcConnection} to the data head, carrying as many participants as
102
+ * the host has interested parties.
103
+ *
104
+ * Document operations live on the participants rather than here: they carry a
105
+ * `clientId`, which identifies a participant rather than a wire, and the server
106
+ * keys its opens and watches per `(uri, clientId)`. Two parties sharing one
107
+ * identity cannot tell each other's writes from their own echoes.
108
+ * {@link DataConnection.watchDocument} is the exception: it acts as no
109
+ * participant, under an id no session holds, and opens or writes nothing.
110
+ *
111
+ * Generic over the transfer root so this file names no grammar. An adopter
112
+ * binds the concrete root (or the union of them, for a multi-grammar head) at
113
+ * its own edge.
114
+ */
115
+ export class DataConnection<
116
+ TTransfer extends TransferElement,
117
+ TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>,
118
+ TClient extends object = DataClientProtocol<TTransfer>
119
+ > extends RpcConnection<TServer, TClient> {
120
+ protected readonly sessions = new Set<DataSession<TTransfer, TServer>>();
121
+ protected readonly sessionFactory: DataSessionFactory<TTransfer, TServer>;
122
+ protected readonly createSessionEmitter = new Emitter<DataSession<TTransfer, TServer>>();
123
+ /**
124
+ * Fires with each session {@link createSession} starts, before it returns,
125
+ * so a listener sees every session a caller can. A session started before
126
+ * the listener subscribed is in {@link liveSessions}.
127
+ */
128
+ readonly onDidCreateSession: Event<DataSession<TTransfer, TServer>> = this.createSessionEmitter.event;
129
+ /**
130
+ * Per URI, the `dirty` the client was last told, whether a session of this
131
+ * connection has it open or a watch follows it. A session's open or close
132
+ * of the URI forgets it; disposing a watch does not, since a watch knows
133
+ * only the caller's spelling of the URI, not the server's key. A
134
+ * session's restore and a watch sent again after a reconnect tell the
135
+ * client their answer where it differs, a forgotten URI included; see
136
+ * {@link restoreDirty}.
137
+ */
138
+ protected readonly dirtyStates = new Map<string, boolean>();
139
+ /** Backs each session's {@link DataSessionHost.onDidChangeDirty}. */
140
+ protected readonly dirtyChangedEmitter = new Emitter<TransferDocumentDirtyChangedEvent>();
141
+ /** Backs each session's {@link DataSessionHost.onDidUpdateDocument}. */
142
+ protected readonly documentUpdatedEmitter = new Emitter<TransferDocumentUpdatedEvent<TTransfer, DiagnosticOf<TServer>>>();
143
+ /** Backs each session's {@link DataSessionHost.onDidDeleteDocument}. */
144
+ protected readonly documentDeletedEmitter = new Emitter<TransferDocumentDeletedEvent>();
145
+ /**
146
+ * Per id {@link watchDocument} watches under, the URI it watches, which
147
+ * {@link generationReady} sends again to every later generation until the
148
+ * watch's handle is disposed.
149
+ */
150
+ protected readonly watches = new Map<string, string>();
151
+ /**
152
+ * Per id, the URI of a watch whose handle was disposed with no ready
153
+ * generation to unwatch on. {@link generationReady} sends the unwatch to the
154
+ * next ready one: a generation that failed its readiness check after its
155
+ * watches were sent leaves them on a connection the port may hand back.
156
+ */
157
+ protected readonly pendingUnwatches = new Map<string, string>();
158
+ /** The port's logger, or one that logs nothing. */
159
+ protected readonly logger: Logger;
160
+ /** Backs {@link onDidReconnect}. */
161
+ protected readonly reconnectEmitter = new Emitter<void>();
162
+ /**
163
+ * Fires on every reconnect: once a connection becomes ready after an
164
+ * earlier one was, and its watches have been sent. The server sends no
165
+ * event for a change made while the connection was down, so a watcher reads
166
+ * its document again on this; a read it sends now reaches the server after
167
+ * its watch.
168
+ */
169
+ readonly onDidReconnect: Event<void> = this.reconnectEmitter.event;
170
+ /** Whether a generation was ready before, which makes the next one a reconnect. */
171
+ protected readyBefore = false;
172
+
173
+ constructor(port: DataPort, client: TClient, ...rest: DataConnectionArgs<TTransfer, TClient, TServer>) {
174
+ const [options = {}] = rest as [
175
+ (DataConnectionOptions<TTransfer, TServer> & Partial<DataConnectionOptionsWithMethods<TClient, TTransfer, TServer>>)?
176
+ ];
177
+ super(port, client, {
178
+ methodNamespace: options.methodNamespace ?? DATA_SERVER_WIRE_PREFIX,
179
+ // The default is reachable only where `TClient` satisfies
180
+ // `DataClientProtocol`, which the constructor's conditional enforces;
181
+ // the compiler cannot carry that through to the generic parameter.
182
+ clientMethods: options.clientMethods ?? (DATA_CLIENT_PROTOCOL_METHODS as unknown as readonly (keyof TClient & string)[]),
183
+ lifecycle: options
184
+ });
185
+ this.sessionFactory =
186
+ options.sessionFactory ?? ((clientId, host, label) => new DataSession<TTransfer, TServer>(clientId, host, label));
187
+ this.logger = (port.logger ?? new NoopLogger()).for('DataConnection');
188
+ }
189
+
190
+ /**
191
+ * The sessions of this connection that have not ended, in the order they
192
+ * started. A session is listed until its `onDidDispose` fires, or until
193
+ * {@link dispose} clears the list.
194
+ */
195
+ get liveSessions(): readonly DataSession<TTransfer, TServer>[] {
196
+ return [...this.sessions];
197
+ }
198
+
199
+ /**
200
+ * Start a participant on this connection, registered with the server under a
201
+ * fresh id, `label` plus `#` plus a random UUID, or under `clientId` when
202
+ * given. Pass a `label` naming the participant; without one it is
203
+ * `session`. Synchronous: the registration is sent at once, and the
204
+ * session's calls wait for it. The server refuses an id live anywhere in
205
+ * its process, and every call of that session then rejects with an error
206
+ * `isDuplicateClientIdError` recognises; an id the server reserves beyond
207
+ * {@link FRAMEWORK_CLIENT_IDS}, such as the integrity author, with one
208
+ * `isReservedClientIdError` recognises. Only the code crosses the wire, so
209
+ * test with those guards rather than `instanceof`.
210
+ *
211
+ * Throws a {@link ReservedClientIdError} for an id in
212
+ * {@link FRAMEWORK_CLIENT_IDS} — those are authors the SERVER emits rather
213
+ * than participants, so a session holding one would read the framework's
214
+ * own broadcasts as its own echoes and drop them — and a
215
+ * {@link DuplicateClientIdError} for an id a live session on this
216
+ * connection already holds.
217
+ */
218
+ createSession(label = 'session', clientId?: string): DataSession<TTransfer, TServer> {
219
+ this.assertLive();
220
+ const id = clientId ?? `${label}#${randomUuid()}`;
221
+ if (FRAMEWORK_CLIENT_IDS.includes(id)) {
222
+ throw new ReservedClientIdError(id);
223
+ }
224
+ if ([...this.sessions].some(session => session.clientId === id)) {
225
+ throw new DuplicateClientIdError(id);
226
+ }
227
+ const session = this.sessionFactory(
228
+ id,
229
+ {
230
+ connected: () => this.connected(),
231
+ reportError: (error, reported) => this.reportError(error, reported),
232
+ restoreDirty: event => this.restoreDirty(event),
233
+ forgetDirty: uri => this.dirtyStates.delete(uri),
234
+ onDidChangeDirty: this.dirtyChangedEmitter.event,
235
+ onDidUpdateDocument: this.documentUpdatedEmitter.event,
236
+ onDidDeleteDocument: this.documentDeletedEmitter.event,
237
+ logger: this.logger.for('DataSession').with(id)
238
+ },
239
+ label
240
+ );
241
+ this.sessions.add(session);
242
+ // Subscribed before the session is handed out, so the id is free again
243
+ // on this connection by the time any caller's listener runs.
244
+ session.onDidDispose(() => this.sessions.delete(session));
245
+ // A failure reaches the session's own calls, which wait for the same
246
+ // registration; caught here only so it is not also reported unhandled.
247
+ session.connected().catch(() => undefined);
248
+ this.createSessionEmitter.fire(session);
249
+ return session;
250
+ }
251
+
252
+ /**
253
+ * Follow `uri` without opening it: its update events reach this
254
+ * connection's client once this resolves. An open would hold the document
255
+ * for as long as the caller follows it. The watch runs under an id of its
256
+ * own, `label` plus `#` plus a random UUID, and needs no session: a session
257
+ * closing the document would also end its own watch of it. Every later
258
+ * connection that becomes ready gets the watch again. Disposing the handle
259
+ * unwatches.
260
+ */
261
+ async watchDocument(uri: string, label = 'watch'): Promise<Disposable> {
262
+ const clientId = `${label}#${randomUuid()}`;
263
+ const server = await this.connected();
264
+ // Kept only from here: kept during the wait, a generation that became
265
+ // ready meanwhile would send the watch a second time.
266
+ this.watches.set(clientId, uri);
267
+ try {
268
+ await server.watchModelDocument({ uri, clientId });
269
+ } catch (error: unknown) {
270
+ this.watches.delete(clientId);
271
+ throw error;
272
+ }
273
+ this.logger.debug(`Watch ${uri} as ${clientId}`);
274
+ return Disposable.create(() => {
275
+ if (!this.watches.delete(clientId)) {
276
+ return;
277
+ }
278
+ // Without a ready generation the unwatch waits for the next one,
279
+ // rather than opening a connection only for it.
280
+ const unwatchLater = (): void => {
281
+ this.pendingUnwatches.set(clientId, uri);
282
+ };
283
+ const generation = this.generation;
284
+ if (!generation) {
285
+ unwatchLater();
286
+ return;
287
+ }
288
+ (generation.ready ??= this.awaitReady(generation)).then(() => {
289
+ if (this.generation === generation) {
290
+ this.unwatch(generation, clientId, uri);
291
+ } else {
292
+ unwatchLater();
293
+ }
294
+ }, unwatchLater);
295
+ });
296
+ }
297
+
298
+ /**
299
+ * The client, with its `onDocumentDirtyChanged` passing through
300
+ * {@link deliverDirty} first, so {@link dirtyStates} holds what the server
301
+ * told it, and every session hears it through {@link dirtyChangedEmitter};
302
+ * and with its `onDocumentUpdated` and `onDocumentDeleted` heard by every
303
+ * session through {@link documentUpdatedEmitter} and
304
+ * {@link documentDeletedEmitter} first. Every other bound method forwards
305
+ * to the client unchanged, and one the client lacks stays absent, so the
306
+ * binding still refuses it.
307
+ */
308
+ protected override localTarget(): TClient {
309
+ const client = this.client as unknown as Record<string, unknown>;
310
+ const hearsDirty = typeof client.onDocumentDirtyChanged === 'function';
311
+ const hearsUpdates = typeof client.onDocumentUpdated === 'function';
312
+ const hearsDeletions = typeof client.onDocumentDeleted === 'function';
313
+ if (!hearsDirty && !hearsUpdates && !hearsDeletions) {
314
+ return this.client;
315
+ }
316
+ const target: Record<string, unknown> = {};
317
+ for (const name of this.clientMethods) {
318
+ const method: unknown = client[name];
319
+ if (typeof method === 'function') {
320
+ target[name] = (params: unknown): unknown => (method as (params: unknown) => unknown).call(client, params);
321
+ }
322
+ }
323
+ if (hearsDirty) {
324
+ target.onDocumentDirtyChanged = (event: TransferDocumentDirtyChangedEvent): void => {
325
+ this.dirtyChangedEmitter.fire(event);
326
+ this.deliverDirty(event);
327
+ };
328
+ }
329
+ if (hearsUpdates) {
330
+ const forward = target.onDocumentUpdated as (event: TransferDocumentUpdatedEvent<TTransfer, DiagnosticOf<TServer>>) => void;
331
+ target.onDocumentUpdated = (event: TransferDocumentUpdatedEvent<TTransfer, DiagnosticOf<TServer>>): void => {
332
+ this.documentUpdatedEmitter.fire(event);
333
+ forward(event);
334
+ };
335
+ }
336
+ if (hearsDeletions) {
337
+ const forward = target.onDocumentDeleted as (event: TransferDocumentDeletedEvent) => void;
338
+ target.onDocumentDeleted = (event: TransferDocumentDeletedEvent): void => {
339
+ this.documentDeletedEmitter.fire(event);
340
+ forward(event);
341
+ };
342
+ }
343
+ return target as unknown as TClient;
344
+ }
345
+
346
+ /**
347
+ * Hand a dirty state a restore read to the client, unless it is what
348
+ * {@link dirtyStates} says the client was last told; a URI it holds
349
+ * nothing for counts as different.
350
+ */
351
+ protected restoreDirty(event: TransferDocumentDirtyChangedEvent): void {
352
+ if (this.dirtyStates.get(event.uri) !== (event.text?.dirty ?? false)) {
353
+ this.deliverDirty(event);
354
+ }
355
+ }
356
+
357
+ /** Record `event` in {@link dirtyStates} and hand it to the client. */
358
+ protected deliverDirty(event: TransferDocumentDirtyChangedEvent): void {
359
+ this.dirtyStates.set(event.uri, event.text?.dirty ?? false);
360
+ const client = this.client as unknown as Partial<Pick<DataClientProtocol<TTransfer>, 'onDocumentDirtyChanged'>>;
361
+ client.onDocumentDirtyChanged?.(event);
362
+ }
363
+
364
+ /**
365
+ * After the transport dropped, reconnect on the next macrotask for the
366
+ * sessions with documents open, so they re-watch and follow their documents
367
+ * again without waiting for a call of their own, and connect for what
368
+ * {@link watchDocument} watches, which {@link generationReady} places
369
+ * again; a session with nothing open restores on its next call. Nothing is
370
+ * scheduled once this connection is disposed, which drops its generation
371
+ * too.
372
+ */
373
+ protected override dropGeneration(): void {
374
+ const dropped = this.generation !== undefined;
375
+ super.dropGeneration();
376
+ if (dropped && !this.disposed) {
377
+ setTimeout(() => {
378
+ if (!this.disposed) {
379
+ this.reconnectSessions();
380
+ if (this.watches.size > 0) {
381
+ // One generation, not `connected`, which follows a drop to
382
+ // the next: that drop's own timer asks again whether
383
+ // anything is still kept. A failure is reported by the gate.
384
+ const generation = this.currentGeneration();
385
+ (generation.ready ??= this.awaitReady(generation)).catch(() => undefined);
386
+ }
387
+ }
388
+ }, 0);
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Call `reconnect()` on every session, reporting a throw instead of letting
394
+ * one session's restore stop the others and the watches after them, and,
395
+ * inside the readiness gate, fail the whole generation.
396
+ */
397
+ protected reconnectSessions(): void {
398
+ for (const session of this.sessions) {
399
+ try {
400
+ session.reconnect();
401
+ } catch (error: unknown) {
402
+ // Reported, so it reaches the user on a port without a logger;
403
+ // logged too, since only the log names the session.
404
+ this.reportError(error, resolve(DATA_CONNECTION_SESSION_RESTORE_FAILED, { detail: describeError(error) }));
405
+ this.logger.error(`Could not restore session ${session.clientId}: ${describeErrorWithStack(error)}`);
406
+ }
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Restore what the server lost with an earlier generation, whichever
412
+ * request brought this one up: the documents of sessions that have some
413
+ * open, and every watch {@link watchDocument} keeps.
414
+ */
415
+ protected override generationReady(generation: RpcConnectionGeneration<TServer>): void {
416
+ super.generationReady(generation);
417
+ this.reconnectSessions();
418
+ this.watches.forEach((uri, clientId) => this.watchAgain(generation, clientId, uri));
419
+ this.pendingUnwatches.forEach((uri, clientId) => this.unwatch(generation, clientId, uri));
420
+ this.pendingUnwatches.clear();
421
+ if (this.readyBefore) {
422
+ this.reconnectEmitter.fire(undefined);
423
+ }
424
+ this.readyBefore = true;
425
+ }
426
+
427
+ /** Take back the watch of `uri` under `clientId` on `generation`; the server ignores one it does not hold. */
428
+ protected unwatch(generation: RpcConnectionGeneration<TServer>, clientId: string, uri: string): void {
429
+ this.logger.debug(`Unwatch ${uri} as ${clientId}`);
430
+ generation.server.unwatchModelDocument({ uri, clientId }).catch(() => undefined);
431
+ }
432
+
433
+ /**
434
+ * Send the watch of `uri` under `clientId` to `generation`, which has just
435
+ * passed its readiness gate. Sent at once rather than after a wait, so no
436
+ * drop can come between choosing the generation and sending. A failure is
437
+ * reported, since no caller waits on it, only while the watch is kept and
438
+ * `generation` is still current: otherwise the next generation sends it
439
+ * again.
440
+ *
441
+ * Once the watch is in place, the document's dirty state is read and goes
442
+ * through {@link restoreDirty}, as a session's restore does: a flip while
443
+ * the connection was down reached no one.
444
+ */
445
+ protected watchAgain(generation: RpcConnectionGeneration<TServer>, clientId: string, uri: string): void {
446
+ generation.server.watchModelDocument({ uri, clientId }).then(
447
+ () => {
448
+ if (!this.watches.has(clientId)) {
449
+ return;
450
+ }
451
+ this.logger.debug(`Watch ${uri} again as ${clientId}`);
452
+ generation.server.getModelDocument({ uri }).then(
453
+ current => {
454
+ if (current.text && this.watches.has(clientId)) {
455
+ try {
456
+ this.restoreDirty({ uri: current.uri, text: current.text });
457
+ } catch {
458
+ // The client's listener failed, not the watch, which stays kept.
459
+ }
460
+ }
461
+ },
462
+ () => undefined
463
+ );
464
+ },
465
+ (error: unknown) => {
466
+ if (!this.watches.has(clientId)) {
467
+ return;
468
+ }
469
+ if (this.generation !== generation) {
470
+ this.logger.debug(`Watch of ${uri} as ${clientId} cut short by a lost connection; the next one sends it again`);
471
+ return;
472
+ }
473
+ this.reportError(error, resolve(DATA_CONNECTION_WATCH_RESTORE_FAILED, { uri, detail: describeError(error) }));
474
+ }
475
+ );
476
+ }
477
+
478
+ /**
479
+ * Sessions are detached rather than disposed: the server ends every session
480
+ * on a connection it sees close, so ending each one first sends requests
481
+ * over a connection this call is about to dispose.
482
+ */
483
+ override dispose(): void {
484
+ for (const session of [...this.sessions]) {
485
+ session.detach();
486
+ }
487
+ // For a factory's session whose `detach` does not fire.
488
+ this.sessions.clear();
489
+ this.watches.clear();
490
+ this.pendingUnwatches.clear();
491
+ this.createSessionEmitter.dispose();
492
+ this.reconnectEmitter.dispose();
493
+ this.dirtyChangedEmitter.dispose();
494
+ this.documentUpdatedEmitter.dispose();
495
+ this.documentDeletedEmitter.dispose();
496
+ super.dispose();
497
+ }
498
+ }
499
+
500
+ /**
501
+ * A {@link DataConnection} that brings its own {@link DataEvents}, so a host
502
+ * with several interested parties does not have to supply one.
503
+ *
504
+ * **The client slot holds exactly one object, and that is why this exists.**
505
+ * `createRpcProxy` binds a single `localTarget`, and underneath a method name
506
+ * maps to one handler — a second registration replaces the first silently. So a
507
+ * properties panel and a tree cannot both be the client; one fan-out sits in the
508
+ * slot and both subscribe to it.
509
+ *
510
+ * Use {@link DataConnection} directly instead when the client is yours: an
511
+ * adopter service that implements the protocol plus its own methods, a single
512
+ * consumer that IS the client, or a request/response-only client that binds
513
+ * nothing.
514
+ */
515
+ export class DataConnectionWithEvents<
516
+ TTransfer extends TransferElement,
517
+ TServer extends DataServerProtocol<TTransfer, DiagnosticOf<TServer>> = DataServerProtocol<TTransfer>
518
+ > extends DataConnection<TTransfer, TServer, DataEvents<TTransfer, DiagnosticOf<TServer>, ProjectOf<TServer>>> {
519
+ /** Server pushes, fanned out to as many local listeners as the host has. */
520
+ readonly events: DataEvents<TTransfer, DiagnosticOf<TServer>, ProjectOf<TServer>>;
521
+
522
+ constructor(port: DataPort, options?: DataConnectionOptions<TTransfer, TServer>) {
523
+ // Built as a local because `this` is unavailable before `super`, then
524
+ // read back onto the field.
525
+ const events = new DataEvents<TTransfer, DiagnosticOf<TServer>, ProjectOf<TServer>>();
526
+ super(port, events, options);
527
+ this.events = events;
528
+ }
529
+
530
+ /** Disposes the fan-out it created, which no caller else holds. */
531
+ override dispose(): void {
532
+ super.dispose();
533
+ this.events.dispose();
534
+ }
535
+ }