@hydranium/protocol 1.0.0-next.13 → 1.0.0-next.132

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 (172) hide show
  1. package/README.md +35 -1
  2. package/lib/client/data-connection.d.ts +145 -0
  3. package/lib/client/data-connection.d.ts.map +1 -0
  4. package/lib/client/data-connection.js +205 -0
  5. package/lib/client/data-connection.js.map +1 -0
  6. package/lib/client/data-events.d.ts +13 -1
  7. package/lib/client/data-events.d.ts.map +1 -1
  8. package/lib/client/data-events.js +21 -0
  9. package/lib/client/data-events.js.map +1 -1
  10. package/lib/client/data-port.d.ts +17 -22
  11. package/lib/client/data-port.d.ts.map +1 -1
  12. package/lib/client/data-session.d.ts +301 -80
  13. package/lib/client/data-session.d.ts.map +1 -1
  14. package/lib/client/data-session.js +425 -107
  15. package/lib/client/data-session.js.map +1 -1
  16. package/lib/client/index.d.ts +13 -8
  17. package/lib/client/index.d.ts.map +1 -1
  18. package/lib/client/index.js +13 -8
  19. package/lib/client/index.js.map +1 -1
  20. package/lib/client/message-relay.d.ts +9 -3
  21. package/lib/client/message-relay.d.ts.map +1 -1
  22. package/lib/client/message-relay.js +11 -5
  23. package/lib/client/message-relay.js.map +1 -1
  24. package/lib/client/post-message-transport.d.ts +64 -3
  25. package/lib/client/post-message-transport.d.ts.map +1 -1
  26. package/lib/client/post-message-transport.js +175 -1
  27. package/lib/client/post-message-transport.js.map +1 -1
  28. package/lib/client/rpc-connection.d.ts +149 -0
  29. package/lib/client/rpc-connection.d.ts.map +1 -0
  30. package/lib/client/rpc-connection.js +179 -0
  31. package/lib/client/rpc-connection.js.map +1 -0
  32. package/lib/client-ids.d.ts +41 -0
  33. package/lib/client-ids.d.ts.map +1 -0
  34. package/lib/client-ids.js +44 -0
  35. package/lib/client-ids.js.map +1 -0
  36. package/lib/clock.d.ts +38 -0
  37. package/lib/clock.d.ts.map +1 -1
  38. package/lib/clock.js +36 -1
  39. package/lib/clock.js.map +1 -1
  40. package/lib/data/data-protocol-methods.d.ts +4 -4
  41. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  42. package/lib/data/data-protocol-methods.js +11 -1
  43. package/lib/data/data-protocol-methods.js.map +1 -1
  44. package/lib/data/data-server-protocol.d.ts +110 -31
  45. package/lib/data/data-server-protocol.d.ts.map +1 -1
  46. package/lib/data/events.d.ts +84 -3
  47. package/lib/data/events.d.ts.map +1 -1
  48. package/lib/data/requests.d.ts +67 -11
  49. package/lib/data/requests.d.ts.map +1 -1
  50. package/lib/errors.d.ts +102 -12
  51. package/lib/errors.d.ts.map +1 -1
  52. package/lib/errors.js +136 -18
  53. package/lib/errors.js.map +1 -1
  54. package/lib/glsp-save-model-actions.d.ts +50 -0
  55. package/lib/glsp-save-model-actions.d.ts.map +1 -0
  56. package/lib/glsp-save-model-actions.js +28 -0
  57. package/lib/glsp-save-model-actions.js.map +1 -0
  58. package/lib/index.d.ts +3 -0
  59. package/lib/index.d.ts.map +1 -1
  60. package/lib/index.js +6 -0
  61. package/lib/index.js.map +1 -1
  62. package/lib/latency-collector.d.ts +8 -4
  63. package/lib/latency-collector.d.ts.map +1 -1
  64. package/lib/latency-collector.js.map +1 -1
  65. package/lib/messages/index.d.ts +29 -0
  66. package/lib/messages/index.d.ts.map +1 -0
  67. package/lib/messages/index.js +56 -0
  68. package/lib/messages/index.js.map +1 -0
  69. package/lib/messages/primitives.d.ts +188 -0
  70. package/lib/messages/primitives.d.ts.map +1 -0
  71. package/lib/messages/primitives.js +161 -0
  72. package/lib/messages/primitives.js.map +1 -0
  73. package/lib/model-server.d.ts +44 -13
  74. package/lib/model-server.d.ts.map +1 -1
  75. package/lib/model-server.js +4 -2
  76. package/lib/model-server.js.map +1 -1
  77. package/lib/model-service/based-on.d.ts +57 -0
  78. package/lib/model-service/based-on.d.ts.map +1 -0
  79. package/lib/model-service/based-on.js +37 -0
  80. package/lib/model-service/based-on.js.map +1 -0
  81. package/lib/model-service/index.d.ts +1 -1
  82. package/lib/model-service/index.d.ts.map +1 -1
  83. package/lib/model-service/index.js +4 -5
  84. package/lib/model-service/index.js.map +1 -1
  85. package/lib/patch-merge.d.ts +28 -27
  86. package/lib/patch-merge.d.ts.map +1 -1
  87. package/lib/patch-merge.js +66 -22
  88. package/lib/patch-merge.js.map +1 -1
  89. package/lib/profile-session.d.ts +8 -4
  90. package/lib/profile-session.d.ts.map +1 -1
  91. package/lib/profile-session.js.map +1 -1
  92. package/lib/rpc/bind-rpc-methods.d.ts +29 -3
  93. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  94. package/lib/rpc/bind-rpc-methods.js +22 -3
  95. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  96. package/lib/rpc/create-rpc-proxy.d.ts +7 -0
  97. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  98. package/lib/rpc/create-rpc-proxy.js +6 -1
  99. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  100. package/lib/testing/catalogue-audit.d.ts +80 -0
  101. package/lib/testing/catalogue-audit.d.ts.map +1 -0
  102. package/lib/testing/catalogue-audit.js +94 -0
  103. package/lib/testing/catalogue-audit.js.map +1 -0
  104. package/lib/testing/data-doubles.d.ts +13 -12
  105. package/lib/testing/data-doubles.d.ts.map +1 -1
  106. package/lib/testing/data-doubles.js +19 -5
  107. package/lib/testing/data-doubles.js.map +1 -1
  108. package/lib/testing/fake-clock.d.ts +9 -1
  109. package/lib/testing/fake-clock.d.ts.map +1 -1
  110. package/lib/testing/fake-clock.js +54 -45
  111. package/lib/testing/fake-clock.js.map +1 -1
  112. package/lib/testing/index.d.ts +1 -0
  113. package/lib/testing/index.d.ts.map +1 -1
  114. package/lib/testing/index.js +4 -1
  115. package/lib/testing/index.js.map +1 -1
  116. package/lib/testing/node/index.d.ts +1 -0
  117. package/lib/testing/node/index.d.ts.map +1 -1
  118. package/lib/testing/node/index.js +2 -2
  119. package/lib/testing/node/index.js.map +1 -1
  120. package/lib/testing/node/message-port-pair.d.ts +25 -0
  121. package/lib/testing/node/message-port-pair.d.ts.map +1 -0
  122. package/lib/testing/node/message-port-pair.js +26 -0
  123. package/lib/testing/node/message-port-pair.js.map +1 -0
  124. package/lib/transfer-diagnostic.d.ts +33 -0
  125. package/lib/transfer-diagnostic.d.ts.map +1 -1
  126. package/lib/transfer-diagnostic.js +23 -0
  127. package/lib/transfer-diagnostic.js.map +1 -1
  128. package/lib/transfer-document.d.ts +22 -5
  129. package/lib/transfer-document.d.ts.map +1 -1
  130. package/lib/transfer-document.js +14 -1
  131. package/lib/transfer-document.js.map +1 -1
  132. package/package.json +11 -2
  133. package/src/client/data-connection.ts +282 -0
  134. package/src/client/data-events.ts +33 -1
  135. package/src/client/data-port.ts +17 -23
  136. package/src/client/data-session.ts +549 -126
  137. package/src/client/index.ts +13 -8
  138. package/src/client/message-relay.ts +29 -7
  139. package/src/client/post-message-transport.ts +219 -4
  140. package/src/client/rpc-connection.ts +244 -0
  141. package/src/client-ids.ts +45 -0
  142. package/src/clock.ts +56 -0
  143. package/src/data/data-protocol-methods.ts +11 -3
  144. package/src/data/data-server-protocol.ts +131 -31
  145. package/src/data/events.ts +90 -3
  146. package/src/data/requests.ts +71 -11
  147. package/src/errors.ts +154 -20
  148. package/src/glsp-save-model-actions.ts +59 -0
  149. package/src/index.ts +6 -0
  150. package/src/latency-collector.ts +8 -3
  151. package/src/messages/index.ts +36 -0
  152. package/src/messages/primitives.ts +271 -0
  153. package/src/model-server.ts +47 -18
  154. package/src/model-service/based-on.ts +63 -0
  155. package/src/model-service/index.ts +4 -5
  156. package/src/patch-merge.ts +90 -37
  157. package/src/profile-session.ts +9 -4
  158. package/src/rpc/bind-rpc-methods.ts +49 -4
  159. package/src/rpc/create-rpc-proxy.ts +14 -1
  160. package/src/testing/catalogue-audit.ts +111 -0
  161. package/src/testing/data-doubles.ts +42 -17
  162. package/src/testing/fake-clock.ts +62 -47
  163. package/src/testing/index.ts +4 -1
  164. package/src/testing/node/index.ts +2 -2
  165. package/src/testing/node/message-port-pair.ts +40 -0
  166. package/src/transfer-diagnostic.ts +40 -0
  167. package/src/transfer-document.ts +29 -6
  168. package/lib/model-service/args.d.ts +0 -64
  169. package/lib/model-service/args.d.ts.map +0 -1
  170. package/lib/model-service/args.js +0 -11
  171. package/lib/model-service/args.js.map +0 -1
  172. package/src/model-service/args.ts +0 -67
@@ -0,0 +1,80 @@
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
+ * Audit a translation catalogue against the codes that actually exist.
11
+ *
12
+ * **The one failure mode a catalogue has, and the only one nothing else
13
+ * catches.** A key naming no declared code falls back to the English — which is
14
+ * byte-identical to a deliberate omission, so a typo is invisible at runtime and
15
+ * indistinguishable from the partial-catalogue behaviour every adopter relies
16
+ * on. Nothing on the render path can tell them apart, `theia nls-extract`
17
+ * reports what the SOURCE declares rather than whether a catalogue matches it,
18
+ * and the framework's own gates see only the framework's own files.
19
+ *
20
+ * Shipped as test support rather than as a runtime check on purpose: an
21
+ * orphaned key is an authoring mistake, and failing a server boot over one would
22
+ * take a running product down for a cosmetic defect.
23
+ */
24
+ /**
25
+ * Flatten a nested catalogue into the `/`-joined keys a message code is spelled
26
+ * with, dropping `_`-prefixed keys as notes to a human reader.
27
+ *
28
+ * Nesting is a HOST convention, not the framework's: Theia flattens a nested
29
+ * catalogue by joining keys with `/`, which is the separator a code already
30
+ * uses, so an adopter on that host writes the file nested and one handed
31
+ * straight to a `DefaultMessageRenderer` writes it flat. Both end up here.
32
+ *
33
+ * `_`-prefixed keys are dropped by PREFIX rather than by matching one literal
34
+ * name, so a second note added to a file cannot silently become a catalogue
35
+ * entry. A code is three `/`-separated segments, so no real entry can begin
36
+ * with `_`.
37
+ */
38
+ export declare function flattenCatalogue(catalogue: Record<string, unknown>, prefix?: string): Record<string, string>;
39
+ /** Options for {@link findUndeclaredCodes}. */
40
+ export interface CatalogueAuditOptions {
41
+ /**
42
+ * Key prefixes to skip, for entries whose codes are NOT declared through a
43
+ * `defineMessage` barrel.
44
+ *
45
+ * The real case is a host's own mechanism: Theia's `nls.localize` takes its
46
+ * key as an inline literal at the call site, so those keys exist only in
47
+ * source text and no barrel can enumerate them. Keep this as narrow as the
48
+ * host layer actually is — exempting a namespace is exempting every typo in
49
+ * it, which is what this function exists to find.
50
+ */
51
+ readonly exemptPrefixes?: readonly string[];
52
+ }
53
+ /**
54
+ * Every catalogue key that names no code any of `barrels` declares.
55
+ *
56
+ * Barrels are taken as opaque objects and read with {@link collectMessages},
57
+ * which is what lets a caller pass a `import * as messages` namespace directly:
58
+ * a barrel's value type is a union of its declarations AND its functions, and
59
+ * filtering that union will not narrow to a `MessageDefinition`.
60
+ *
61
+ * Returns the offending keys rather than a boolean, so a failing assertion names
62
+ * WHICH key is wrong — a count says only that something is.
63
+ */
64
+ export declare function findUndeclaredCodes(catalogueKeys: readonly string[], barrels: readonly object[], options?: CatalogueAuditOptions): string[];
65
+ /**
66
+ * Keys present in more than one catalogue — the shape a split catalogue rots
67
+ * into.
68
+ *
69
+ * Exactly one side renders a given message, so two catalogues holding one code
70
+ * are two authorities over one sentence and they diverge on the first reword.
71
+ * Nothing at runtime notices: both sides render, and whichever ran last wins on
72
+ * its own surface.
73
+ *
74
+ * Takes the key sets rather than a boolean answer for the same reason as
75
+ * {@link findUndeclaredCodes}, and reports NOTHING when a set is empty — an
76
+ * empty catalogue shares no key with anything, so a caller must assert
77
+ * non-emptiness separately or a failed read passes this vacuously.
78
+ */
79
+ export declare function findSharedCodes(first: readonly string[], second: readonly string[]): string[];
80
+ //# sourceMappingURL=catalogue-audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogue-audit.d.ts","sourceRoot":"","sources":["../../src/testing/catalogue-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,SAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcxG;AAED,+CAA+C;AAC/C,MAAM,WAAW,qBAAqB;IACnC;;;;;;;;;OASG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAChC,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,GAAE,qBAA0B,GACnC,MAAM,EAAE,CAIV;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAG7F"}
@@ -0,0 +1,94 @@
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.flattenCatalogue = flattenCatalogue;
12
+ exports.findUndeclaredCodes = findUndeclaredCodes;
13
+ exports.findSharedCodes = findSharedCodes;
14
+ const primitives_1 = require("../messages/primitives");
15
+ /**
16
+ * Audit a translation catalogue against the codes that actually exist.
17
+ *
18
+ * **The one failure mode a catalogue has, and the only one nothing else
19
+ * catches.** A key naming no declared code falls back to the English — which is
20
+ * byte-identical to a deliberate omission, so a typo is invisible at runtime and
21
+ * indistinguishable from the partial-catalogue behaviour every adopter relies
22
+ * on. Nothing on the render path can tell them apart, `theia nls-extract`
23
+ * reports what the SOURCE declares rather than whether a catalogue matches it,
24
+ * and the framework's own gates see only the framework's own files.
25
+ *
26
+ * Shipped as test support rather than as a runtime check on purpose: an
27
+ * orphaned key is an authoring mistake, and failing a server boot over one would
28
+ * take a running product down for a cosmetic defect.
29
+ */
30
+ /**
31
+ * Flatten a nested catalogue into the `/`-joined keys a message code is spelled
32
+ * with, dropping `_`-prefixed keys as notes to a human reader.
33
+ *
34
+ * Nesting is a HOST convention, not the framework's: Theia flattens a nested
35
+ * catalogue by joining keys with `/`, which is the separator a code already
36
+ * uses, so an adopter on that host writes the file nested and one handed
37
+ * straight to a `DefaultMessageRenderer` writes it flat. Both end up here.
38
+ *
39
+ * `_`-prefixed keys are dropped by PREFIX rather than by matching one literal
40
+ * name, so a second note added to a file cannot silently become a catalogue
41
+ * entry. A code is three `/`-separated segments, so no real entry can begin
42
+ * with `_`.
43
+ */
44
+ function flattenCatalogue(catalogue, prefix = '') {
45
+ const flat = {};
46
+ for (const [key, value] of Object.entries(catalogue)) {
47
+ if (key.startsWith('_')) {
48
+ continue;
49
+ }
50
+ const joined = prefix ? `${prefix}/${key}` : key;
51
+ if (typeof value === 'string') {
52
+ flat[joined] = value;
53
+ }
54
+ else if (typeof value === 'object' && value !== null) {
55
+ Object.assign(flat, flattenCatalogue(value, joined));
56
+ }
57
+ }
58
+ return flat;
59
+ }
60
+ /**
61
+ * Every catalogue key that names no code any of `barrels` declares.
62
+ *
63
+ * Barrels are taken as opaque objects and read with {@link collectMessages},
64
+ * which is what lets a caller pass a `import * as messages` namespace directly:
65
+ * a barrel's value type is a union of its declarations AND its functions, and
66
+ * filtering that union will not narrow to a `MessageDefinition`.
67
+ *
68
+ * Returns the offending keys rather than a boolean, so a failing assertion names
69
+ * WHICH key is wrong — a count says only that something is.
70
+ */
71
+ function findUndeclaredCodes(catalogueKeys, barrels, options = {}) {
72
+ const declared = new Set(barrels.flatMap(barrel => (0, primitives_1.collectMessages)(barrel).map(message => message.code)));
73
+ const exempt = options.exemptPrefixes ?? [];
74
+ return catalogueKeys.filter(key => !exempt.some(prefix => key.startsWith(prefix)) && !declared.has(key));
75
+ }
76
+ /**
77
+ * Keys present in more than one catalogue — the shape a split catalogue rots
78
+ * into.
79
+ *
80
+ * Exactly one side renders a given message, so two catalogues holding one code
81
+ * are two authorities over one sentence and they diverge on the first reword.
82
+ * Nothing at runtime notices: both sides render, and whichever ran last wins on
83
+ * its own surface.
84
+ *
85
+ * Takes the key sets rather than a boolean answer for the same reason as
86
+ * {@link findUndeclaredCodes}, and reports NOTHING when a set is empty — an
87
+ * empty catalogue shares no key with anything, so a caller must assert
88
+ * non-emptiness separately or a failed read passes this vacuously.
89
+ */
90
+ function findSharedCodes(first, second) {
91
+ const other = new Set(second);
92
+ return first.filter(key => other.has(key));
93
+ }
94
+ //# sourceMappingURL=catalogue-audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogue-audit.js","sourceRoot":"","sources":["../../src/testing/catalogue-audit.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;AAkClF,4CAcC;AA4BD,kDAQC;AAgBD,0CAGC;AArGD,uDAAyD;AAEzD;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAAC,SAAkC,EAAE,MAAM,GAAG,EAAE;IAC7E,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACpD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,SAAS;QACZ,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACtD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,KAAgC,EAAE,MAAM,CAAC,CAAC,CAAC;QACnF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACf,CAAC;AAiBD;;;;;;;;;;GAUG;AACH,SAAgB,mBAAmB,CAChC,aAAgC,EAChC,OAA0B,EAC1B,UAAiC,EAAE;IAEnC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAA,4BAAe,EAAC,MAAM,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1G,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;IAC5C,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5G,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,eAAe,CAAC,KAAwB,EAAE,MAAyB;IAChF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC"}
@@ -32,7 +32,8 @@
32
32
  import { type MessageConnection } from 'vscode-jsonrpc';
33
33
  import type { DataPort } from '../client/data-port';
34
34
  import type { DataClientProtocol } from '../data/data-server-protocol';
35
- import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from '../data/events';
35
+ import type { ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentDirtyChangedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from '../data/events';
36
+ import type { ResolvedMessage } from '../messages/primitives';
36
37
  import type { Project } from '../project';
37
38
  import type { TransferDiagnostic } from '../transfer-diagnostic';
38
39
  import type { TransferElement } from '../transfer-element';
@@ -48,13 +49,6 @@ export interface FakeDataPortOptions {
48
49
  * which the consumer surfaces through {@link FakeDataPort.reported}.
49
50
  */
50
51
  connect(): MessageConnection | Promise<MessageConnection>;
51
- /**
52
- * Stable client identity. Defaults to `'fake-data-port'`, which avoids the
53
- * three sentinels the framework reserves (`'language-client'`, `'unknown'`,
54
- * `'revert-on-close'`); override it when a test needs two distinguishable
55
- * clients on one server.
56
- */
57
- clientId?: string;
58
52
  }
59
53
  /** A {@link DataPort} that records what passed through it. */
60
54
  export interface FakeDataPort extends DataPort {
@@ -69,12 +63,13 @@ export interface FakeDataPort extends DataPort {
69
63
  /**
70
64
  * Every {@link DataPort.reportError} call, in order. Read from outside: this
71
65
  * is the only place a transport failure surfaces, so a test for the failure
72
- * path asserts on the `context` string here rather than on a rejection that
73
- * the consumer may legitimately swallow.
66
+ * path asserts here rather than on a rejection the consumer may legitimately
67
+ * swallow. Prefer asserting on `message.code`, which is stable, over
68
+ * `message.text`, which is the English default and may be reworded.
74
69
  */
75
70
  readonly reported: readonly {
76
71
  readonly error: unknown;
77
- readonly context: string;
72
+ readonly message: ResolvedMessage;
78
73
  }[];
79
74
  /**
80
75
  * Fire {@link DataPort.onDispose} — the host tearing the transport down, a
@@ -101,13 +96,19 @@ export interface CapturingDataClient<TTransfer extends TransferElement, TDiagnos
101
96
  readonly updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[];
102
97
  /** Every `onDocumentSaved` event, in arrival order. */
103
98
  readonly saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[];
99
+ /** Every `onDocumentDirtyChanged` event, in arrival order. */
100
+ readonly dirtyChanges: TransferDocumentDirtyChangedEvent[];
101
+ /** Every `onDocumentDeleted` event, in arrival order. */
102
+ readonly deletions: TransferDocumentDeletedEvent[];
103
+ /** Every `onDocumentsBuilt` event, in arrival order. */
104
+ readonly builds: TransferDocumentsBuiltEvent[];
104
105
  /** Every `onProjectsChanged` event, in arrival order. */
105
106
  readonly projectsChanges: ProjectsChangedEvent<TProject>[];
106
107
  }
107
108
  /**
108
109
  * A {@link DataClientProtocol} that records every notification it receives.
109
110
  *
110
- * Recording ALL THREE channels even when a suite reads one is deliberate: an
111
+ * Recording EVERY channel even when a suite reads one is deliberate: an
111
112
  * event delivered on the wrong channel is a real defect of the data head, and a
112
113
  * double that drops the other two turns it into silence on the one being
113
114
  * watched.
@@ -1 +1 @@
1
- {"version":3,"file":"data-doubles.d.ts","sourceRoot":"","sources":["../../src/testing/data-doubles.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AACrH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,0CAA0C;AAC1C,MAAM,WAAW,mBAAmB;IACjC;;;;;;;;OAQG;IACH,OAAO,IAAI,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC1D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 +46,6 @@ function makeFakeDataPort(options) {
46
46
  const reported = [];
47
47
  const disposeEmitter = new vscode_jsonrpc_1.Emitter();
48
48
  return {
49
- clientId: options.clientId ?? 'fake-data-port',
50
49
  connections,
51
50
  reported,
52
51
  onDispose: disposeEmitter.event,
@@ -55,8 +54,8 @@ function makeFakeDataPort(options) {
55
54
  connections.push(connection);
56
55
  return connection;
57
56
  },
58
- reportError(error, context) {
59
- reported.push({ error, context });
57
+ reportError(error, message) {
58
+ reported.push({ error, message });
60
59
  },
61
60
  fireDispose() {
62
61
  disposeEmitter.fire(undefined);
@@ -69,7 +68,7 @@ function makeFakeDataPort(options) {
69
68
  /**
70
69
  * A {@link DataClientProtocol} that records every notification it receives.
71
70
  *
72
- * Recording ALL THREE channels even when a suite reads one is deliberate: an
71
+ * Recording EVERY channel even when a suite reads one is deliberate: an
73
72
  * event delivered on the wrong channel is a real defect of the data head, and a
74
73
  * double that drops the other two turns it into silence on the one being
75
74
  * watched.
@@ -82,6 +81,9 @@ function makeFakeDataPort(options) {
82
81
  function makeCapturingDataClient(overrides = {}) {
83
82
  const updates = [];
84
83
  const saves = [];
84
+ const dirtyChanges = [];
85
+ const deletions = [];
86
+ const builds = [];
85
87
  const projectsChanges = [];
86
88
  const client = {
87
89
  onDocumentUpdated: overrides.onDocumentUpdated ??
@@ -92,11 +94,23 @@ function makeCapturingDataClient(overrides = {}) {
92
94
  (event => {
93
95
  saves.push(event);
94
96
  }),
97
+ onDocumentDirtyChanged: overrides.onDocumentDirtyChanged ??
98
+ (event => {
99
+ dirtyChanges.push(event);
100
+ }),
101
+ onDocumentDeleted: overrides.onDocumentDeleted ??
102
+ (event => {
103
+ deletions.push(event);
104
+ }),
105
+ onDocumentsBuilt: overrides.onDocumentsBuilt ??
106
+ (event => {
107
+ builds.push(event);
108
+ }),
95
109
  onProjectsChanged: overrides.onProjectsChanged ??
96
110
  (event => {
97
111
  projectsChanges.push(event);
98
112
  })
99
113
  };
100
- return { client, updates, saves, projectsChanges };
114
+ return { client, updates, saves, dirtyChanges, deletions, builds, projectsChanges };
101
115
  }
102
116
  //# sourceMappingURL=data-doubles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-doubles.js","sourceRoot":"","sources":["../../src/testing/data-doubles.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;AAyFlF,4CAwBC;AA+BD,0DA0BC;AAxKD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,mDAAiE;AAwDjE;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,OAA4B;IAC1D,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAA0C,EAAE,CAAC;IAC3D,MAAM,cAAc,GAAG,IAAI,wBAAO,EAAQ,CAAC;IAC3C,OAAO;QACJ,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,gBAAgB;QAC9C,WAAW;QACX,QAAQ;QACR,SAAS,EAAE,cAAc,CAAC,KAAK;QAC/B,KAAK,CAAC,OAAO;YACV,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YAC3C,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7B,OAAO,UAAU,CAAC;QACrB,CAAC;QACD,WAAW,CAAC,KAAc,EAAE,OAAe;YACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACrC,CAAC;QACD,WAAW;YACR,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;QACD,OAAO;YACJ,cAAc,CAAC,OAAO,EAAE,CAAC;QAC5B,CAAC;KACH,CAAC;AACL,CAAC;AAkBD;;;;;;;;;;;;GAYG;AACH,SAAgB,uBAAuB,CAIrC,YAA2E,EAAE;IAC5E,MAAM,OAAO,GAA2D,EAAE,CAAC;IAC3E,MAAM,KAAK,GAAyD,EAAE,CAAC;IACvE,MAAM,eAAe,GAAqC,EAAE,CAAC;IAC7D,MAAM,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AE;gBACN,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC,CAAC;KACP,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AACvF,CAAC"}
@@ -14,9 +14,13 @@ export interface FakeClock extends Clock {
14
14
  * whose deadline falls within the window — in chronological order, each at
15
15
  * its own deadline (so `now()` inside a callback reads the fire instant, not
16
16
  * the advance target). Timers scheduled by a callback fire too if they fall
17
- * within the same window.
17
+ * within the same window. A {@link Clock.raceTimer} over a promise that
18
+ * settles through a chain still pending loses to the timer, so let that
19
+ * chain settle before advancing.
18
20
  */
19
21
  advance(ms: number): void;
22
+ /** How many {@link Clock.setTimer} timers have neither fired nor been disposed. */
23
+ pendingTimers(): number;
20
24
  }
21
25
  /**
22
26
  * In-process {@link Clock} double for deterministic time. The real
@@ -28,6 +32,10 @@ export interface FakeClock extends Clock {
28
32
  *
29
33
  * Server-free and DI-free — lives in `@hydranium/protocol/testing` so every
30
34
  * head can bind it without pulling in a server package.
35
+ *
36
+ * The clock is a `SystemClock` with its time replaced, so its methods live on
37
+ * its prototype and a spread of it carries none of them. Replace one by
38
+ * assigning it onto the clock, or layer over the clock with `Object.create`.
31
39
  */
32
40
  export declare function makeFakeClock(options?: {
33
41
  now?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"fake-clock.d.ts","sourceRoot":"","sources":["../../src/testing/fake-clock.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAA8B,MAAM,UAAU,CAAC;AAGlE,2FAA2F;AAC3F,MAAM,WAAW,SAAU,SAAQ,KAAK;IACrC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AASD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,SAAS,CA+DvE"}
1
+ {"version":3,"file":"fake-clock.d.ts","sourceRoot":"","sources":["../../src/testing/fake-clock.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAA+B,MAAM,UAAU,CAAC;AAGnE,2FAA2F;AAC3F,MAAM,WAAW,SAAU,SAAQ,KAAK;IACrC;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,mFAAmF;IACnF,aAAa,IAAI,MAAM,CAAC;CAC1B;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,SAAS,CAEvE"}
@@ -9,6 +9,7 @@
9
9
  ********************************************************************************/
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.makeFakeClock = makeFakeClock;
12
+ const clock_1 = require("../clock");
12
13
  const util_1 = require("../util");
13
14
  /**
14
15
  * In-process {@link Clock} double for deterministic time. The real
@@ -20,67 +21,75 @@ const util_1 = require("../util");
20
21
  *
21
22
  * Server-free and DI-free — lives in `@hydranium/protocol/testing` so every
22
23
  * head can bind it without pulling in a server package.
24
+ *
25
+ * The clock is a `SystemClock` with its time replaced, so its methods live on
26
+ * its prototype and a spread of it carries none of them. Replace one by
27
+ * assigning it onto the clock, or layer over the clock with `Object.create`.
23
28
  */
24
29
  function makeFakeClock(options = {}) {
25
- let current = options.now ?? 0;
26
- const timers = [];
27
- const makeStopwatch = () => {
28
- const start = current;
29
- let lastLap = current;
30
+ return new VirtualClock(options.now ?? 0);
31
+ }
32
+ /**
33
+ * A `SystemClock` whose time, stopwatches and timers read one virtual axis, so
34
+ * the `measure` and `raceTimer` it inherits run on that axis too.
35
+ */
36
+ class VirtualClock extends clock_1.SystemClock {
37
+ current;
38
+ timers = [];
39
+ constructor(current) {
40
+ super();
41
+ this.current = current;
42
+ }
43
+ now() {
44
+ return this.current;
45
+ }
46
+ setTimer(callback, ms) {
47
+ const timer = { at: this.current + ms, callback, disposed: false, fired: false };
48
+ this.timers.push(timer);
49
+ return util_1.Disposable.create(() => {
50
+ timer.disposed = true;
51
+ });
52
+ }
53
+ stopwatch() {
54
+ const read = () => this.current;
55
+ const start = read();
56
+ let lastLap = start;
30
57
  let stopped;
31
58
  return {
32
59
  get elapsedMs() {
33
- return (stopped ?? current) - start;
60
+ return (stopped ?? read()) - start;
34
61
  },
35
62
  lap() {
36
- const at = stopped ?? current;
63
+ const at = stopped ?? read();
37
64
  const split = at - lastLap;
38
65
  lastLap = at;
39
66
  return split;
40
67
  },
41
68
  stop() {
42
- if (stopped === undefined) {
43
- stopped = current;
44
- }
69
+ stopped ??= read();
45
70
  return stopped - start;
46
71
  }
47
72
  };
48
- };
49
- return {
50
- now: () => current,
51
- setTimer(callback, ms) {
52
- const timer = { at: current + ms, callback, disposed: false, fired: false };
53
- timers.push(timer);
54
- return util_1.Disposable.create(() => {
55
- timer.disposed = true;
56
- });
57
- },
58
- stopwatch: makeStopwatch,
59
- measure: ((callback) => {
60
- const stopwatch = makeStopwatch();
61
- const result = callback();
62
- if (result instanceof Promise) {
63
- return result.then(value => ({ result: value, elapsedMs: stopwatch.elapsedMs }));
64
- }
65
- return { result: result, elapsedMs: stopwatch.elapsedMs };
66
- }),
67
- advance(ms) {
68
- const target = current + ms;
69
- // Fire due timers one at a time, re-scanning after each so a callback
70
- // that schedules a nearer timer still fires within this window.
71
- for (;;) {
72
- const next = timers
73
- .filter(timer => !timer.disposed && !timer.fired && timer.at <= target)
74
- .sort((left, right) => left.at - right.at)[0];
75
- if (!next) {
76
- break;
77
- }
78
- current = next.at;
79
- next.fired = true;
80
- next.callback();
73
+ }
74
+ pendingTimers() {
75
+ return this.timers.filter(timer => !timer.disposed && !timer.fired).length;
76
+ }
77
+ advance(ms) {
78
+ const target = this.current + ms;
79
+ // Fire due timers one at a time, re-scanning after each so a callback
80
+ // that schedules a nearer timer still fires within this window.
81
+ for (;;) {
82
+ const next = this.timers
83
+ .filter(timer => !timer.disposed && !timer.fired && timer.at <= target)
84
+ .sort((left, right) => left.at - right.at)[0];
85
+ if (!next) {
86
+ break;
81
87
  }
82
- current = target;
88
+ this.current = next.at;
89
+ next.fired = true;
90
+ next.callback();
83
91
  }
84
- };
92
+ this.current = target;
93
+ }
85
94
  }
86
95
  //# sourceMappingURL=fake-clock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fake-clock.js","sourceRoot":"","sources":["../../src/testing/fake-clock.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;AAmClF,sCA+DC;AA/FD,kCAAqC;AAqBrC;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAAC,UAA4B,EAAE;IACzD,IAAI,OAAO,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAgB,EAAE,CAAC;IAE/B,MAAM,aAAa,GAAG,GAAc,EAAE;QACnC,MAAM,KAAK,GAAG,OAAO,CAAC;QACtB,IAAI,OAAO,GAAG,OAAO,CAAC;QACtB,IAAI,OAA2B,CAAC;QAChC,OAAO;YACJ,IAAI,SAAS;gBACV,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,KAAK,CAAC;YACvC,CAAC;YACD,GAAG;gBACA,MAAM,EAAE,GAAG,OAAO,IAAI,OAAO,CAAC;gBAC9B,MAAM,KAAK,GAAG,EAAE,GAAG,OAAO,CAAC;gBAC3B,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,KAAK,CAAC;YAChB,CAAC;YACD,IAAI;gBACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;oBACzB,OAAO,GAAG,OAAO,CAAC;gBACrB,CAAC;gBACD,OAAO,OAAO,GAAG,KAAK,CAAC;YAC1B,CAAC;SACH,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACJ,GAAG,EAAE,G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ACT,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACzB,CAAC;CACH"}
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
+ export * from './catalogue-audit';
9
10
  export * from './data-doubles';
10
11
  export * from './fake-clock';
11
12
  export * from './harness';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAelF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAiBlF,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -25,7 +25,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  // Subpath barrel for `@hydranium/protocol/testing` — the BROWSER-NEUTRAL shared
26
26
  // primitives: `makeFakeClock` (deterministic `Clock` double on one virtual time
27
27
  // axis), `waitFor` / `tick`, the client-side data-head doubles
28
- // (`makeFakeDataPort` / `makeCapturingDataClient`), and the `Harness` marker
28
+ // (`makeFakeDataPort` / `makeCapturingDataClient`), the translation-catalogue
29
+ // audit (`flattenCatalogue` / `findUndeclaredCodes` / `findSharedCodes`), and
30
+ // the `Harness` marker
29
31
  // interface every framework harness extends. Kept out of the main barrel so production bundles don't pull
30
32
  // the test scaffolding in by default; adopters opt in by importing from
31
33
  // `@hydranium/protocol/testing`.
@@ -34,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
36
  // duplex transports are NOT here: a `PassThrough` pair is in their exported
35
37
  // type, so they cannot be made portable and live at `./testing/node` instead.
36
38
  // The same rule the package surface uses — the portable name is the short one.
39
+ __exportStar(require("./catalogue-audit"), exports);
37
40
  __exportStar(require("./data-doubles"), exports);
38
41
  __exportStar(require("./fake-clock"), exports);
39
42
  __exportStar(require("./harness"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,gFAAgF;AAChF,gFAAgF;AAChF,+DAA+D;AAC/D,6EAA6E;AAC7E,0GAA0G;AAC1G,wEAAwE;AACxE,iCAAiC;AACjC,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAE/E,iDAA+B;AAC/B,+CAA6B;AAC7B,4CAA0B;AAC1B,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,gFAAgF;AAChF,gFAAgF;AAChF,+DAA+D;AAC/D,8EAA8E;AAC9E,8EAA8E;AAC9E,uBAAuB;AACvB,0GAA0G;AAC1G,wEAAwE;AACxE,iCAAiC;AACjC,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAE/E,oDAAkC;AAClC,iDAA+B;AAC/B,+CAA6B;AAC7B,4CAA0B;AAC1B,6CAA2B"}
@@ -8,4 +8,5 @@
8
8
  ********************************************************************************/
9
9
  export * from './duplex-connection';
10
10
  export * from './duplex-stream';
11
+ export * from './message-port-pair';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAalF,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAYlF,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
@@ -23,8 +23,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  // Subpath barrel for `@hydranium/protocol/testing/node` — the test transports
26
- // that need a Node runtime: a crossed `PassThrough` pair and the in-process
27
- // `MessageConnection` bridge over it.
26
+ // that need a Node runtime.
28
27
  //
29
28
  // Separate from `./testing` because a `PassThrough` is in `DuplexStreamPair`'s
30
29
  // exported type and `StreamMessageReader` comes from `vscode-jsonrpc/node`, so
@@ -34,4 +33,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
33
  // their own.
35
34
  __exportStar(require("./duplex-connection"), exports);
36
35
  __exportStar(require("./duplex-stream"), exports);
36
+ __exportStar(require("./message-port-pair"), exports);
37
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/node/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,8EAA8E;AAC9E,4EAA4E;AAC5E,sCAAsC;AACtC,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,aAAa;AAEb,sDAAoC;AACpC,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/node/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,8EAA8E;AAC9E,4BAA4B;AAC5B,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,aAAa;AAEb,sDAAoC;AACpC,kDAAgC;AAChC,sDAAoC"}
@@ -0,0 +1,25 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2026 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 { TransferredMessagePort } from '../../client/post-message-transport';
10
+ /**
11
+ * The two ends of a `worker_threads` `MessageChannel`, typed as the transferred
12
+ * browser ports `createMessagePortTransport` takes. Node's port clones and keeps
13
+ * order as a browser's does, which is what lets a headless test stand in for a
14
+ * worker.
15
+ *
16
+ * `dispose` closes both ports. Node reports that as a close and a browser port
17
+ * reports nothing, so a test that asserts on a close does so before teardown.
18
+ */
19
+ export interface MessagePortPair {
20
+ readonly port1: TransferredMessagePort;
21
+ readonly port2: TransferredMessagePort;
22
+ dispose(): void;
23
+ }
24
+ export declare function makeMessagePortPair(): MessagePortPair;
25
+ //# sourceMappingURL=message-port-pair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-port-pair.d.ts","sourceRoot":"","sources":["../../../src/testing/node/message-port-pair.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAElF;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC7B,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC;IACvC,OAAO,IAAI,IAAI,CAAC;CAClB;AAED,wBAAgB,mBAAmB,IAAI,eAAe,CAYrD"}