@hydranium/protocol 1.0.0-next.12 → 1.0.0-next.123

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 (142) hide show
  1. package/README.md +35 -1
  2. package/lib/client/data-connection.d.ts +114 -0
  3. package/lib/client/data-connection.d.ts.map +1 -0
  4. package/lib/client/data-connection.js +143 -0
  5. package/lib/client/data-connection.js.map +1 -0
  6. package/lib/client/data-events.d.ts +9 -1
  7. package/lib/client/data-events.d.ts.map +1 -1
  8. package/lib/client/data-events.js +14 -0
  9. package/lib/client/data-events.js.map +1 -1
  10. package/lib/client/data-port.d.ts +17 -22
  11. package/lib/client/data-port.d.ts.map +1 -1
  12. package/lib/client/data-session.d.ts +235 -82
  13. package/lib/client/data-session.d.ts.map +1 -1
  14. package/lib/client/data-session.js +337 -108
  15. package/lib/client/data-session.js.map +1 -1
  16. package/lib/client/index.d.ts +10 -7
  17. package/lib/client/index.d.ts.map +1 -1
  18. package/lib/client/index.js +10 -7
  19. package/lib/client/index.js.map +1 -1
  20. package/lib/client/message-relay.d.ts +8 -2
  21. package/lib/client/message-relay.d.ts.map +1 -1
  22. package/lib/client/message-relay.js +10 -4
  23. package/lib/client/message-relay.js.map +1 -1
  24. package/lib/client/rpc-connection.d.ts +143 -0
  25. package/lib/client/rpc-connection.d.ts.map +1 -0
  26. package/lib/client/rpc-connection.js +171 -0
  27. package/lib/client/rpc-connection.js.map +1 -0
  28. package/lib/client-ids.d.ts +41 -0
  29. package/lib/client-ids.d.ts.map +1 -0
  30. package/lib/client-ids.js +44 -0
  31. package/lib/client-ids.js.map +1 -0
  32. package/lib/data/data-protocol-methods.d.ts +4 -4
  33. package/lib/data/data-protocol-methods.d.ts.map +1 -1
  34. package/lib/data/data-protocol-methods.js +10 -1
  35. package/lib/data/data-protocol-methods.js.map +1 -1
  36. package/lib/data/data-server-protocol.d.ts +100 -31
  37. package/lib/data/data-server-protocol.d.ts.map +1 -1
  38. package/lib/data/events.d.ts +70 -3
  39. package/lib/data/events.d.ts.map +1 -1
  40. package/lib/data/requests.d.ts +67 -11
  41. package/lib/data/requests.d.ts.map +1 -1
  42. package/lib/errors.d.ts +91 -12
  43. package/lib/errors.d.ts.map +1 -1
  44. package/lib/errors.js +127 -18
  45. package/lib/errors.js.map +1 -1
  46. package/lib/index.d.ts +2 -0
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/index.js +5 -0
  49. package/lib/index.js.map +1 -1
  50. package/lib/latency-collector.d.ts +8 -4
  51. package/lib/latency-collector.d.ts.map +1 -1
  52. package/lib/latency-collector.js.map +1 -1
  53. package/lib/messages/index.d.ts +29 -0
  54. package/lib/messages/index.d.ts.map +1 -0
  55. package/lib/messages/index.js +55 -0
  56. package/lib/messages/index.js.map +1 -0
  57. package/lib/messages/primitives.d.ts +188 -0
  58. package/lib/messages/primitives.d.ts.map +1 -0
  59. package/lib/messages/primitives.js +161 -0
  60. package/lib/messages/primitives.js.map +1 -0
  61. package/lib/model-server.d.ts +44 -13
  62. package/lib/model-server.d.ts.map +1 -1
  63. package/lib/model-server.js +4 -2
  64. package/lib/model-server.js.map +1 -1
  65. package/lib/model-service/based-on.d.ts +57 -0
  66. package/lib/model-service/based-on.d.ts.map +1 -0
  67. package/lib/model-service/based-on.js +37 -0
  68. package/lib/model-service/based-on.js.map +1 -0
  69. package/lib/model-service/index.d.ts +1 -1
  70. package/lib/model-service/index.d.ts.map +1 -1
  71. package/lib/model-service/index.js +4 -5
  72. package/lib/model-service/index.js.map +1 -1
  73. package/lib/patch-merge.d.ts +28 -27
  74. package/lib/patch-merge.d.ts.map +1 -1
  75. package/lib/patch-merge.js +66 -22
  76. package/lib/patch-merge.js.map +1 -1
  77. package/lib/profile-session.d.ts +8 -4
  78. package/lib/profile-session.d.ts.map +1 -1
  79. package/lib/profile-session.js.map +1 -1
  80. package/lib/rpc/bind-rpc-methods.d.ts +29 -3
  81. package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
  82. package/lib/rpc/bind-rpc-methods.js +22 -3
  83. package/lib/rpc/bind-rpc-methods.js.map +1 -1
  84. package/lib/rpc/create-rpc-proxy.d.ts +7 -0
  85. package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
  86. package/lib/rpc/create-rpc-proxy.js +6 -1
  87. package/lib/rpc/create-rpc-proxy.js.map +1 -1
  88. package/lib/testing/catalogue-audit.d.ts +80 -0
  89. package/lib/testing/catalogue-audit.d.ts.map +1 -0
  90. package/lib/testing/catalogue-audit.js +94 -0
  91. package/lib/testing/catalogue-audit.js.map +1 -0
  92. package/lib/testing/data-doubles.d.ts +11 -12
  93. package/lib/testing/data-doubles.d.ts.map +1 -1
  94. package/lib/testing/data-doubles.js +14 -5
  95. package/lib/testing/data-doubles.js.map +1 -1
  96. package/lib/testing/index.d.ts +1 -0
  97. package/lib/testing/index.d.ts.map +1 -1
  98. package/lib/testing/index.js +4 -1
  99. package/lib/testing/index.js.map +1 -1
  100. package/lib/transfer-diagnostic.d.ts +33 -0
  101. package/lib/transfer-diagnostic.d.ts.map +1 -1
  102. package/lib/transfer-diagnostic.js +23 -0
  103. package/lib/transfer-diagnostic.js.map +1 -1
  104. package/lib/transfer-document.d.ts +14 -5
  105. package/lib/transfer-document.d.ts.map +1 -1
  106. package/lib/transfer-document.js +14 -1
  107. package/lib/transfer-document.js.map +1 -1
  108. package/package.json +11 -2
  109. package/src/client/data-connection.ts +216 -0
  110. package/src/client/data-events.ts +24 -1
  111. package/src/client/data-port.ts +17 -23
  112. package/src/client/data-session.ts +447 -128
  113. package/src/client/index.ts +10 -7
  114. package/src/client/message-relay.ts +28 -6
  115. package/src/client/rpc-connection.ts +235 -0
  116. package/src/client-ids.ts +45 -0
  117. package/src/data/data-protocol-methods.ts +10 -3
  118. package/src/data/data-server-protocol.ts +119 -31
  119. package/src/data/events.ts +74 -3
  120. package/src/data/requests.ts +71 -11
  121. package/src/errors.ts +139 -20
  122. package/src/index.ts +5 -0
  123. package/src/latency-collector.ts +8 -3
  124. package/src/messages/index.ts +36 -0
  125. package/src/messages/primitives.ts +271 -0
  126. package/src/model-server.ts +47 -18
  127. package/src/model-service/based-on.ts +63 -0
  128. package/src/model-service/index.ts +4 -5
  129. package/src/patch-merge.ts +90 -37
  130. package/src/profile-session.ts +9 -4
  131. package/src/rpc/bind-rpc-methods.ts +49 -4
  132. package/src/rpc/create-rpc-proxy.ts +14 -1
  133. package/src/testing/catalogue-audit.ts +111 -0
  134. package/src/testing/data-doubles.ts +33 -17
  135. package/src/testing/index.ts +4 -1
  136. package/src/transfer-diagnostic.ts +40 -0
  137. package/src/transfer-document.ts +21 -6
  138. package/lib/model-service/args.d.ts +0 -64
  139. package/lib/model-service/args.d.ts.map +0 -1
  140. package/lib/model-service/args.js +0 -11
  141. package/lib/model-service/args.js.map +0 -1
  142. package/src/model-service/args.ts +0 -67
package/lib/errors.js CHANGED
@@ -8,9 +8,22 @@
8
8
  * SPDX-License-Identifier: MIT
9
9
  ********************************************************************************/
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ConflictError = exports.CONFLICT_ERROR_CODE = void 0;
11
+ exports.DuplicateClientIdError = exports.DocumentNotOpenError = exports.SessionClosedError = exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.SESSION_CLOSED_ERROR_CODE = exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.STALE_BASED_UPDATE = void 0;
12
+ exports.isSessionClosedError = isSessionClosedError;
13
+ exports.isDocumentNotOpenError = isDocumentNotOpenError;
14
+ exports.isDuplicateClientIdError = isDuplicateClientIdError;
12
15
  exports.isConflictError = isConflictError;
13
16
  const vscode_jsonrpc_1 = require("vscode-jsonrpc");
17
+ const primitives_1 = require("./messages/primitives");
18
+ /**
19
+ * The catalogue declaration behind {@link ConflictError}'s sentence.
20
+ *
21
+ * Its English must keep containing {@link CONFLICT_ERROR_MESSAGE_MARKER}: the
22
+ * marker is tier 3 of {@link isConflictError}'s ladder, and it matches on text.
23
+ * That tier only ever works untranslated, which is why it is the last resort
24
+ * behind the numeric code rather than the primary check.
25
+ */
26
+ exports.STALE_BASED_UPDATE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-based-update', 'Stale-based update for {uri}: expected v{expectedVersion}, server is at v{actualVersion}');
14
27
  /**
15
28
  * Application-specific JSON-RPC error code for {@link ConflictError}.
16
29
  * Outside the reserved range (-32768 .. -32000) per JSON-RPC 2.0.
@@ -22,7 +35,7 @@ const vscode_jsonrpc_1 = require("vscode-jsonrpc");
22
35
  */
23
36
  exports.CONFLICT_ERROR_CODE = 1001;
24
37
  /**
25
- * Thrown by `ModelService.update` / `ModelService.save` when the caller-
38
+ * Thrown by a client session's `update` / `save` when the caller-
26
39
  * supplied based-on version no longer matches the server's current text-
27
40
  * document version for the same URI — i.e. the snapshot the caller
28
41
  * authored against has been superseded by an intervening edit.
@@ -35,11 +48,9 @@ exports.CONFLICT_ERROR_CODE = 1001;
35
48
  * `err.data` (the instance is reconstructed as a generic
36
49
  * `ResponseError`, so subclass getters / fields do not survive).
37
50
  *
38
- * Detection is opt-in via the optional `baseVersion` field on
39
- * `TransferUpdateArgs` / `TransferSaveArgs`; callers that omit the field get
40
- * no gating. This mirrors LSP's `OptionalVersionedTextDocumentIdentifier`
41
- * posture, so headless / CLI / batch tooling with no meaningful based-on
42
- * version can opt out explicitly.
51
+ * Detection is driven by the required `basedOn` field of every write
52
+ * request; a caller with no meaningful based-on version passes
53
+ * `'anything'` and gets no gating.
43
54
  *
44
55
  * Three reasonable adopter recovery strategies:
45
56
  *
@@ -53,31 +64,129 @@ exports.CONFLICT_ERROR_CODE = 1001;
53
64
  * No auto-retry or auto-merge ships by default.
54
65
  */
55
66
  class ConflictError extends vscode_jsonrpc_1.ResponseError {
56
- constructor(uri, expected, actual) {
57
- super(exports.CONFLICT_ERROR_CODE, `Stale-based update for ${uri}: expected v${expected}, server is at v${actual}`, {
58
- uri,
59
- expected,
60
- actual
61
- });
67
+ constructor(uri, expectedVersion, actualVersion) {
68
+ const params = { uri, expectedVersion, actualVersion };
69
+ // The identity rides alongside the typed payload rather than replacing
70
+ // it: `isConflictError`'s name check is surface an adopter may bind, so
71
+ // adding the identity widens the payload rather than reshaping it.
72
+ super(exports.CONFLICT_ERROR_CODE, exports.STALE_BASED_UPDATE.format(params), { ...params, ...(0, primitives_1.messageData)(exports.STALE_BASED_UPDATE, params) });
62
73
  this.name = 'ConflictError';
63
74
  // ResponseError's constructor calls `Object.setPrototypeOf(this,
64
75
  // ResponseError.prototype)` to keep its own prototype chain intact across
65
76
  // transpilation targets; that resets us to ResponseError, hiding the
66
77
  // ConflictError-specific getters. Restore the prototype here so
67
- // `err.uri` / `.expected` / `.actual` resolve through this class.
78
+ // `err.uri` / `.expectedVersion` / `.actualVersion` resolve through this
79
+ // class.
68
80
  Object.setPrototypeOf(this, ConflictError.prototype);
69
81
  }
70
82
  get uri() {
71
83
  return this.data.uri;
72
84
  }
73
- get expected() {
74
- return this.data.expected;
85
+ /**
86
+ * The based-on version the caller authored against.
87
+ *
88
+ * Must not be renamed to `expected`, nor its sibling to `actual`: a test
89
+ * reporter reads an error carrying both as an assertion failure, and
90
+ * vitest's formatter then ASSIGNS to them, which throws on an accessor and
91
+ * replaces the real failure with a `TypeError`.
92
+ */
93
+ get expectedVersion() {
94
+ return this.data.expectedVersion;
75
95
  }
76
- get actual() {
77
- return this.data.actual;
96
+ /** The server's version at the time of the throw. Not `actual` — see {@link expectedVersion}. */
97
+ get actualVersion() {
98
+ return this.data.actualVersion;
78
99
  }
79
100
  }
80
101
  exports.ConflictError = ConflictError;
102
+ /**
103
+ * JSON-RPC code for {@link SessionClosedError}, beside {@link CONFLICT_ERROR_CODE}
104
+ * and for the same reason: the code survives reconstruction, the class does not.
105
+ */
106
+ exports.SESSION_CLOSED_ERROR_CODE = 1004;
107
+ /** JSON-RPC code for {@link DocumentNotOpenError}. */
108
+ exports.DOCUMENT_NOT_OPEN_ERROR_CODE = 1005;
109
+ /** JSON-RPC code for {@link DuplicateClientIdError}. */
110
+ exports.DUPLICATE_CLIENT_ID_ERROR_CODE = 1006;
111
+ /**
112
+ * Thrown by every call on a client session after it ended, and by an open that
113
+ * was still in flight when its session ended.
114
+ *
115
+ * The message names the client id, so it is addressed to whoever composes the
116
+ * system rather than to an end user, and carries no message identity. A client
117
+ * recognises it after an RPC with {@link isSessionClosedError}.
118
+ */
119
+ class SessionClosedError extends vscode_jsonrpc_1.ResponseError {
120
+ /** `message` replaces the default sentence, for a caller that knows more than that the session is gone. */
121
+ constructor(clientId, message = `Client session ${clientId} is closed`) {
122
+ super(exports.SESSION_CLOSED_ERROR_CODE, message, { clientId });
123
+ this.name = 'SessionClosedError';
124
+ // `ResponseError` resets the prototype to its own; see `ConflictError`.
125
+ Object.setPrototypeOf(this, SessionClosedError.prototype);
126
+ }
127
+ get clientId() {
128
+ return this.data.clientId;
129
+ }
130
+ }
131
+ exports.SessionClosedError = SessionClosedError;
132
+ /**
133
+ * Thrown when a client session writes a document it does not have open.
134
+ *
135
+ * A session writes only what it has open, so this is the answer both to a write
136
+ * that never opened and to one whose open was closed underneath it — by the
137
+ * session itself, or by the document being deleted.
138
+ */
139
+ class DocumentNotOpenError extends vscode_jsonrpc_1.ResponseError {
140
+ constructor(uri, clientId) {
141
+ super(exports.DOCUMENT_NOT_OPEN_ERROR_CODE, `Document ${uri} is not open in client session ${clientId}`, { uri, clientId });
142
+ this.name = 'DocumentNotOpenError';
143
+ Object.setPrototypeOf(this, DocumentNotOpenError.prototype);
144
+ }
145
+ get uri() {
146
+ return this.data.uri;
147
+ }
148
+ get clientId() {
149
+ return this.data.clientId;
150
+ }
151
+ }
152
+ exports.DocumentNotOpenError = DocumentNotOpenError;
153
+ /**
154
+ * Thrown when a client session is started under an id that is already live in
155
+ * the process, or that the framework reserves for itself.
156
+ *
157
+ * Ids are unique process-wide because the id is also the author label on every
158
+ * version and the key a client recognises its own echoes by; two participants
159
+ * sharing one would each take the other's writes for their own.
160
+ */
161
+ class DuplicateClientIdError extends vscode_jsonrpc_1.ResponseError {
162
+ constructor(clientId) {
163
+ super(exports.DUPLICATE_CLIENT_ID_ERROR_CODE, `Client id ${clientId} is already in use`, { clientId });
164
+ this.name = 'DuplicateClientIdError';
165
+ Object.setPrototypeOf(this, DuplicateClientIdError.prototype);
166
+ }
167
+ get clientId() {
168
+ return this.data.clientId;
169
+ }
170
+ }
171
+ exports.DuplicateClientIdError = DuplicateClientIdError;
172
+ /**
173
+ * Whether `error` is a {@link SessionClosedError}: by name in-process, by code
174
+ * after an RPC, where it arrives as a plain `ResponseError`.
175
+ */
176
+ function isSessionClosedError(error) {
177
+ return hasErrorIdentity(error, 'SessionClosedError', exports.SESSION_CLOSED_ERROR_CODE);
178
+ }
179
+ /** Whether `error` is a {@link DocumentNotOpenError}; see {@link isSessionClosedError}. */
180
+ function isDocumentNotOpenError(error) {
181
+ return hasErrorIdentity(error, 'DocumentNotOpenError', exports.DOCUMENT_NOT_OPEN_ERROR_CODE);
182
+ }
183
+ /** Whether `error` is a {@link DuplicateClientIdError}; see {@link isSessionClosedError}. */
184
+ function isDuplicateClientIdError(error) {
185
+ return hasErrorIdentity(error, 'DuplicateClientIdError', exports.DUPLICATE_CLIENT_ID_ERROR_CODE);
186
+ }
187
+ function hasErrorIdentity(error, name, code) {
188
+ return error instanceof Error && (error.name === name || error.code === code);
189
+ }
81
190
  /** Marker substring present in every {@link ConflictError} message, used by
82
191
  * {@link isConflictError} as a fallback when a transport re-wraps the error
83
192
  * and drops the JSON-RPC code. */
package/lib/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AA2GlF,0CAYC;AArHD,mDAA+C;AAE/C;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAcxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAa,aAAc,SAAQ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AC;QAChC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACrG,CAAC"}
package/lib/index.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  ********************************************************************************/
9
9
  export * from './abstract-logger';
10
10
  export * from './client';
11
+ export * from './client-ids';
11
12
  export * from './clock';
12
13
  export * from './data';
13
14
  export * from './browser-runtime';
@@ -16,6 +17,7 @@ export * from './errors';
16
17
  export * from './host-diagnostics';
17
18
  export * from './logger';
18
19
  export * from './latency-collector';
20
+ export * from './messages/primitives';
19
21
  export * from './patch-merge';
20
22
  export * from './noop-logger';
21
23
  export * from './observable-value';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AASlF,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AASlF,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AAIpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC"}
package/lib/index.js CHANGED
@@ -30,6 +30,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
30
30
  // every production bundle that imports the root.
31
31
  __exportStar(require("./abstract-logger"), exports);
32
32
  __exportStar(require("./client"), exports);
33
+ __exportStar(require("./client-ids"), exports);
33
34
  __exportStar(require("./clock"), exports);
34
35
  __exportStar(require("./data"), exports);
35
36
  __exportStar(require("./browser-runtime"), exports);
@@ -38,6 +39,10 @@ __exportStar(require("./errors"), exports);
38
39
  __exportStar(require("./host-diagnostics"), exports);
39
40
  __exportStar(require("./logger"), exports);
40
41
  __exportStar(require("./latency-collector"), exports);
42
+ // The primitives only. The `./messages` subpath additionally enumerates this
43
+ // package's own declarations, which the root barrel already re-exports through
44
+ // the modules that raise them.
45
+ __exportStar(require("./messages/primitives"), exports);
41
46
  __exportStar(require("./patch-merge"), exports);
42
47
  __exportStar(require("./noop-logger"), exports);
43
48
  __exportStar(require("./observable-value"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,kFAAkF;AAClF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,iDAAiD;AAEjD,oDAAkC;AAClC,2CAAyB;AACzB,0CAAwB;AACxB,yCAAuB;AACvB,oDAAkC;AAClC,8CAA4B;AAC5B,2CAAyB;AACzB,qDAAmC;AACnC,2CAAyB;AACzB,sDAAoC;AACpC,gDAA8B;AAC9B,gDAA8B;AAC9B,qDAAmC;AACnC,oDAAkC;AAClC,8CAA4B;AAC5B,2CAAyB;AACzB,wDAAsC;AACtC,qDAAmC;AACnC,kDAAgC;AAChC,sDAAoC;AACpC,iDAA+B;AAC/B,4CAA0B;AAC1B,wCAAsB;AACtB,wCAAsB;AACtB,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,kFAAkF;AAClF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,iDAAiD;AAEjD,oDAAkC;AAClC,2CAAyB;AACzB,+CAA6B;AAC7B,0CAAwB;AACxB,yCAAuB;AACvB,oDAAkC;AAClC,8CAA4B;AAC5B,2CAAyB;AACzB,qDAAmC;AACnC,2CAAyB;AACzB,sDAAoC;AACpC,6EAA6E;AAC7E,+EAA+E;AAC/E,+BAA+B;AAC/B,wDAAsC;AACtC,gDAA8B;AAC9B,gDAA8B;AAC9B,qDAAmC;AACnC,oDAAkC;AAClC,8CAA4B;AAC5B,2CAAyB;AACzB,wDAAsC;AACtC,qDAAmC;AACnC,kDAAgC;AAChC,sDAAoC;AACpC,iDAA+B;AAC/B,4CAA0B;AAC1B,wCAAsB;AACtB,wCAAsB;AACtB,yCAAuB"}
@@ -76,8 +76,13 @@ export type LatencyRetention = {
76
76
  readonly kind: 'ring-buffer';
77
77
  readonly maxSamplesPerMethod: number;
78
78
  };
79
- /** Per-method state: retained samples (bounded in ring-buffer mode) plus lifetime totals. */
80
- interface MethodAccumulator {
79
+ /**
80
+ * Per-method state: retained samples (bounded in ring-buffer mode) plus lifetime
81
+ * totals. The mutable tally behind {@link MethodLatency}, which is the derived
82
+ * report row. Held by the `protected` {@link LatencyCollector.durations}, so a
83
+ * subclass recording its own samples has to name it.
84
+ */
85
+ export interface MethodLatencyTally {
81
86
  /** Retained durations for percentile estimation; capped in ring-buffer mode. Order is irrelevant (report sorts). */
82
87
  readonly samples: number[];
83
88
  /** Next slot to overwrite once the ring buffer is full (ring-buffer mode only). */
@@ -100,7 +105,7 @@ interface MethodAccumulator {
100
105
  export declare class LatencyCollector {
101
106
  protected readonly clock: Clock;
102
107
  protected readonly retention: LatencyRetention;
103
- protected readonly durations: Map<string, MethodAccumulator>;
108
+ protected readonly durations: Map<string, MethodLatencyTally>;
104
109
  protected window: Stopwatch;
105
110
  constructor(clock?: Clock, retention?: LatencyRetention);
106
111
  /** Record a pre-measured call duration (ms) for `method`. */
@@ -122,5 +127,4 @@ export declare class LatencyCollector {
122
127
  * command channel — the latency counterpart to `formatProfileReport`.
123
128
  */
124
129
  export declare function formatLatencyReport(report: LatencyReport, label?: string): string;
125
- export {};
126
130
  //# sourceMappingURL=latency-collector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"latency-collector.d.ts","sourceRoot":"","sources":["../src/latency-collector.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAalF,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAe,MAAM,YAAY,CAAC;AAErE,oEAAoE;AACpE,MAAM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C,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACtE,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,MAAM,aAAa,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1C,KAAK,CAAC,IAAI,CACP,KAAK,aAAa,CAAC,MAAM,OAAO,aAAa,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM;YAClG,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CACnI,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,29 @@
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
+ * The message-externalization mechanism, plus every user-facing message
11
+ * `@hydranium/protocol` itself raises.
12
+ *
13
+ * Declarations stay beside their call sites and are re-exported here, so this is
14
+ * enumeration rather than centralization: a code's package segment has to name
15
+ * the package that raises it, and a shared module would make that segment a lie
16
+ * for every message in it. Adding a message therefore touches the file that
17
+ * raises it and this list, and nothing else.
18
+ *
19
+ * A barrel makes every code and English default public API, so renaming a code
20
+ * is a breaking change. That was already true — an adopter's catalogue keys on
21
+ * these codes either way — but it is now in the type system rather than implicit.
22
+ * The English is a fallback, not a contract; the code is the contract.
23
+ */
24
+ export * from './primitives';
25
+ export { STALE_BASED_UPDATE } from '../errors';
26
+ export { DATA_SERVER_CONNECT_FAILED, DATA_SERVER_NOT_READY } from '../client/rpc-connection';
27
+ export { DATA_SESSION_RESTORE_FAILED, DATA_SESSION_UNSAVED_LOST } from '../client/data-session';
28
+ export { RELAY_REPLAY_FAILED, RELAY_TRANSPORT_OPEN_FAILED, RELAY_TRANSPORT_READ_FAILED, RELAY_TRANSPORT_WRITE_FAILED } from '../client/message-relay';
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;GAcG;AAEH,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EACJ,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC9B,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,55 @@
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
+ exports.RELAY_TRANSPORT_WRITE_FAILED = exports.RELAY_TRANSPORT_READ_FAILED = exports.RELAY_TRANSPORT_OPEN_FAILED = exports.RELAY_REPLAY_FAILED = exports.DATA_SESSION_UNSAVED_LOST = exports.DATA_SESSION_RESTORE_FAILED = exports.DATA_SERVER_NOT_READY = exports.DATA_SERVER_CONNECT_FAILED = exports.STALE_BASED_UPDATE = void 0;
26
+ /**
27
+ * The message-externalization mechanism, plus every user-facing message
28
+ * `@hydranium/protocol` itself raises.
29
+ *
30
+ * Declarations stay beside their call sites and are re-exported here, so this is
31
+ * enumeration rather than centralization: a code's package segment has to name
32
+ * the package that raises it, and a shared module would make that segment a lie
33
+ * for every message in it. Adding a message therefore touches the file that
34
+ * raises it and this list, and nothing else.
35
+ *
36
+ * A barrel makes every code and English default public API, so renaming a code
37
+ * is a breaking change. That was already true — an adopter's catalogue keys on
38
+ * these codes either way — but it is now in the type system rather than implicit.
39
+ * The English is a fallback, not a contract; the code is the contract.
40
+ */
41
+ __exportStar(require("./primitives"), exports);
42
+ var errors_1 = require("../errors");
43
+ Object.defineProperty(exports, "STALE_BASED_UPDATE", { enumerable: true, get: function () { return errors_1.STALE_BASED_UPDATE; } });
44
+ var rpc_connection_1 = require("../client/rpc-connection");
45
+ Object.defineProperty(exports, "DATA_SERVER_CONNECT_FAILED", { enumerable: true, get: function () { return rpc_connection_1.DATA_SERVER_CONNECT_FAILED; } });
46
+ Object.defineProperty(exports, "DATA_SERVER_NOT_READY", { enumerable: true, get: function () { return rpc_connection_1.DATA_SERVER_NOT_READY; } });
47
+ var data_session_1 = require("../client/data-session");
48
+ Object.defineProperty(exports, "DATA_SESSION_RESTORE_FAILED", { enumerable: true, get: function () { return data_session_1.DATA_SESSION_RESTORE_FAILED; } });
49
+ Object.defineProperty(exports, "DATA_SESSION_UNSAVED_LOST", { enumerable: true, get: function () { return data_session_1.DATA_SESSION_UNSAVED_LOST; } });
50
+ var message_relay_1 = require("../client/message-relay");
51
+ Object.defineProperty(exports, "RELAY_REPLAY_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_REPLAY_FAILED; } });
52
+ Object.defineProperty(exports, "RELAY_TRANSPORT_OPEN_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_OPEN_FAILED; } });
53
+ Object.defineProperty(exports, "RELAY_TRANSPORT_READ_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_READ_FAILED; } });
54
+ Object.defineProperty(exports, "RELAY_TRANSPORT_WRITE_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_WRITE_FAILED; } });
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;;AAElF;;;;;;;;;;;;;;GAcG;AAEH,+CAA6B;AAE7B,oCAA+C;AAAtC,4GAAA,kBAAkB,OAAA;AAC3B,2DAA6F;AAApF,4HAAA,0BAA0B,OAAA;AAAE,uHAAA,qBAAqB,OAAA;AAC1D,uDAAgG;AAAvF,2HAAA,2BAA2B,OAAA;AAAE,yHAAA,yBAAyB,OAAA;AAC/D,yDAKiC;AAJ9B,oHAAA,mBAAmB,OAAA;AACnB,4HAAA,2BAA2B,OAAA;AAC3B,4HAAA,2BAA2B,OAAA;AAC3B,6HAAA,4BAA4B,OAAA"}
@@ -0,0 +1,188 @@
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 { ResponseError } from 'vscode-jsonrpc';
10
+ /**
11
+ * The framework externalizes user-facing strings and SELECTS no locale: it
12
+ * relays the one its client declared and renders with whatever templates the
13
+ * adopter installed, defaulting to its English. Every such string carries a
14
+ * stable code beside that English, and exactly one side renders it — the side
15
+ * that knows the reading user's language.
16
+ *
17
+ * Which side that is depends on the message, not on the package. A server
18
+ * message is rendered by the server, at the one seam every carrier passes
19
+ * through, in the locale it was handed at init. A message the client tier raises
20
+ * is rendered there, because those fire when the server is unreachable. Nothing
21
+ * is rendered twice: two renders of one sentence are two authorities over it,
22
+ * and they diverge on the first reword.
23
+ *
24
+ * Codes are `hydranium/<unscoped-package>/<name>`. The package segment locates
25
+ * the declaration, so a message is declared in the package that raises it and a
26
+ * code never names a package it does not live in. `.` and `:` are forbidden in a
27
+ * segment: they are i18next's default key and namespace separators, where either
28
+ * silently becomes a nested lookup that misses.
29
+ */
30
+ export type MessageParams = Readonly<Record<string, string | number>>;
31
+ type Placeholder<S extends string> = S extends `${string}{${infer Name}}${infer Rest}` ? Name | Placeholder<Rest> : never;
32
+ export type ParamsOf<S extends string> = [Placeholder<S>] extends [never] ? Record<never, never> : Readonly<Record<Placeholder<S>, string | number>>;
33
+ /** Required exactly when the text has placeholders, absent when it does not. */
34
+ export type ParamsArg<S extends string> = [Placeholder<S>] extends [never] ? [] : [params: ParamsOf<S>];
35
+ /**
36
+ * Rejects a text argument already widened to `string`. Load-bearing rather than
37
+ * defensive: the whole compile-time guarantee is conditional on `S` inferring a
38
+ * literal, and for a concatenated or pre-widened text the placeholder set
39
+ * silently becomes empty, `format()` accepts no arguments, and the missing
40
+ * substitution surfaces only at runtime.
41
+ */
42
+ export type LiteralText<S extends string> = string extends S ? never : S;
43
+ export interface MessageDefinition<S extends string> {
44
+ readonly code: string;
45
+ readonly text: S;
46
+ format(...args: ParamsArg<S>): string;
47
+ }
48
+ /**
49
+ * Declare a message. Placeholder names are inferred from `text` rather than
50
+ * declared again in a type argument: a second spelling of every name is the
51
+ * repetition that drifts, since adding a placeholder to the sentence and not to
52
+ * the type compiles.
53
+ */
54
+ export declare function defineMessage<S extends string>(code: string, text: LiteralText<S>): MessageDefinition<S>;
55
+ /**
56
+ * Substitute `{name}` tokens, leaving an unfilled token in place.
57
+ *
58
+ * It must not throw. This runs over an adopter's translation as well as our own
59
+ * text, so a typo in a foreign catalogue has to degrade to a slightly wrong
60
+ * sentence rather than raise inside a toast render. Re-scanning the result to
61
+ * detect an unfilled token is what an earlier form did, and it cannot work:
62
+ * `String.replace` does not rescan replacement text, so the check could not tell
63
+ * an unfilled placeholder from user data shaped like one — an element literally
64
+ * named `{separator}` crashed at the authoring site.
65
+ */
66
+ export declare function interpolate(template: string, params: MessageParams): string;
67
+ export interface MessageIdentity {
68
+ readonly code: string;
69
+ readonly params: MessageParams;
70
+ }
71
+ /**
72
+ * Envelope for a protocol `data` field. Namespaced under one key so it co-exists
73
+ * with a carrier's own `data` conventions rather than occupying `data` itself.
74
+ */
75
+ export interface HydraniumMessageData {
76
+ readonly hydranium: MessageIdentity;
77
+ }
78
+ /** An identity plus its resolved English — everything a renderer needs, on any carrier. */
79
+ export interface ResolvedMessage extends MessageIdentity {
80
+ readonly text: string;
81
+ }
82
+ export declare function messageData<S extends string>(message: MessageDefinition<S>, ...args: ParamsArg<S>): HydraniumMessageData;
83
+ /**
84
+ * Identity plus resolved English, for a hand-off carrying a value rather than a
85
+ * protocol field. The result is structured-clone safe, so it survives a process
86
+ * hop where one intervenes and costs nothing where none does.
87
+ */
88
+ export declare function resolve<S extends string>(message: MessageDefinition<S>, ...args: ParamsArg<S>): ResolvedMessage;
89
+ /**
90
+ * Validates every field {@link MessageIdentity} declares, `params` included.
91
+ * A guard over foreign input that checks only `code` while declaring `params`
92
+ * non-optional hands `undefined` to the renderer, which fails with the worst
93
+ * polarity available: invisible in English, crashing only once a translation is
94
+ * loaded.
95
+ */
96
+ export declare function hasMessageIdentity(data: unknown): data is HydraniumMessageData;
97
+ /**
98
+ * A type alias rather than a subclass. Only `code`, `message` and `data` cross
99
+ * the wire, so a subclass buys nothing there: `instanceof` does not survive
100
+ * reconstruction, and the subclass costs an `Object.setPrototypeOf` in every
101
+ * constructor purely to undo what `ResponseError`'s own constructor does.
102
+ */
103
+ export type HydraniumResponseError = ResponseError<HydraniumMessageData>;
104
+ /**
105
+ * The numeric `code` and the message's catalogue code are unrelated and both are
106
+ * needed: `ResponseError.code` is an `integer`, so it cannot hold a
107
+ * `hydranium/…` key, and it is what a caller switches on after reconstruction.
108
+ */
109
+ export declare function messageError<S extends string>(code: number, message: MessageDefinition<S>, ...params: ParamsArg<S>): HydraniumResponseError;
110
+ /**
111
+ * The reading user's language, as the tag a client declared.
112
+ *
113
+ * Neither validated nor normalised anywhere: rejecting an unfamiliar tag would
114
+ * be selecting a locale, which the framework does not do.
115
+ *
116
+ * NOT a Langium language id, which names a grammar. The two are strings of the
117
+ * same shape reachable from the same services, so one used where the other
118
+ * belongs misses every lookup rather than failing.
119
+ */
120
+ export type Locale = string;
121
+ /**
122
+ * A host's templates for one locale, keyed by the whole message code.
123
+ *
124
+ * **Flat, not nested.** A code is one key here, `/` separators included; a host
125
+ * whose own catalogue format nests — Theia's does — flattens on the way in. A
126
+ * map that nests instead misses every lookup while type-checking, because the
127
+ * value this is indexed by is `ResolvedMessage.code`.
128
+ *
129
+ * **Partial by nature rather than by convention.** A code with no entry renders
130
+ * its English default, so a catalogue covering none of a package's codes is a
131
+ * valid catalogue and not a broken one — which is what lets an adopter translate
132
+ * as much or as little as they like.
133
+ *
134
+ * Deliberately NOT narrowed to the codes that exist, and a `Code extends string`
135
+ * parameter would not buy what it appears to: a catalogue is loaded as JSON, so
136
+ * it reaches a checked position as a variable rather than as an object literal,
137
+ * and excess-property checking — the only thing that would reject a mistyped
138
+ * key — does not run there. The gain is a compile error for a catalogue with no
139
+ * correct key at all; the cost is a code union to maintain by hand, since a
140
+ * declaration does not carry its code as a literal type.
141
+ */
142
+ export type MessageCatalogue = Readonly<Record<string, string>>;
143
+ export declare namespace MessageCatalogue {
144
+ /**
145
+ * One catalogue from several, for a renderer whose override supplies entries
146
+ * over the ones it inherits.
147
+ *
148
+ * **Later wins**, so a caller passes the inherited answer before its own.
149
+ *
150
+ * **No source at all answers `undefined`, not `{}`.** A renderer holds that
151
+ * answer as the locale having no catalogue and renders straight through; an
152
+ * empty object is a catalogue that misses every lookup, so returning one
153
+ * turns the opt-out into a per-message search that yields the same English.
154
+ */
155
+ function merge(...catalogues: ReadonlyArray<MessageCatalogue | undefined>): MessageCatalogue | undefined;
156
+ }
157
+ /**
158
+ * Render on the side that knows the reading user's locale. Omitting
159
+ * `translations` is how an adopter without i18n opts out, and yields the
160
+ * English.
161
+ */
162
+ export declare function renderFrameworkMessage(message: ResolvedMessage, translations?: MessageCatalogue): string;
163
+ export declare function resolvedFromResponseError(error: ResponseError<unknown>): ResolvedMessage | undefined;
164
+ /**
165
+ * The detail half of a `{detail}` placeholder. A technical error string is safe
166
+ * to pass as a parameter for the same reason a number is: it is not itself
167
+ * translatable text, so it needs no code of its own. A PROSE fragment is not,
168
+ * and must become one code per value instead.
169
+ */
170
+ export declare function describeError(error: unknown): string;
171
+ /**
172
+ * Recognises a declaration among a barrel's exports. The `format` check is what
173
+ * discriminates: a `code` + `text` pair alone admits any object that happens to
174
+ * carry both.
175
+ */
176
+ export declare function isMessageDeclaration(value: unknown): value is MessageDefinition<string>;
177
+ /**
178
+ * Every declaration a `./messages` barrel exports.
179
+ *
180
+ * A caller cannot get there with `Object.values(barrel).filter(isMessageDeclaration)`:
181
+ * a barrel's value type is a union of its declarations AND its functions, and
182
+ * `filter` will not narrow a function type down to a `MessageDefinition`, so the
183
+ * result stays the union and reading `.code` off it does not compile. Taking the
184
+ * barrel as an opaque object is what makes the one-liner work.
185
+ */
186
+ export declare function collectMessages(barrel: object): MessageDefinition<string>[];
187
+ export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