@hydranium/protocol 1.0.0-next.24 → 1.0.0-next.27
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.
- package/lib/client/data-port.d.ts +10 -3
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +8 -0
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +12 -3
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/message-relay.d.ts +8 -2
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +10 -4
- package/lib/client/message-relay.js.map +1 -1
- package/lib/errors.d.ts +11 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +16 -6
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/messages/index.d.ts +28 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +52 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +135 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +138 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +5 -3
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +2 -2
- package/lib/testing/data-doubles.js.map +1 -1
- package/package.json +9 -1
- package/src/client/data-port.ts +10 -3
- package/src/client/data-session.ts +21 -2
- package/src/client/message-relay.ts +28 -6
- package/src/errors.ts +20 -6
- package/src/index.ts +4 -0
- package/src/messages/index.ts +35 -0
- package/src/messages/primitives.ts +209 -0
- package/src/testing/data-doubles.ts +8 -6
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import type { Event, MessageConnection } from 'vscode-jsonrpc';
|
|
10
|
+
import type { ResolvedMessage } from '../messages/primitives';
|
|
10
11
|
/**
|
|
11
12
|
* The one thing a host has to supply for the data head: a live JSON-RPC
|
|
12
13
|
* connection to the data server, plus the identity and failure sink that go
|
|
@@ -73,10 +74,16 @@ export interface DataPort {
|
|
|
73
74
|
*
|
|
74
75
|
* It exists because the alternative is worse in both directions: this tier
|
|
75
76
|
* cannot import a host's UI, and swallowing the error makes a dead
|
|
76
|
-
* connection look like an empty model.
|
|
77
|
-
*
|
|
77
|
+
* connection look like an empty model.
|
|
78
|
+
*
|
|
79
|
+
* `reported` is a complete sentence plus the identity needed to render it in
|
|
80
|
+
* another language. It carries a value rather than using a protocol field
|
|
81
|
+
* because this tier does not know whether a process hop intervenes — in a
|
|
82
|
+
* webview host the render happens across one — and a `ResolvedMessage` is
|
|
83
|
+
* structured-clone safe either way. Render it with `renderFrameworkMessage`;
|
|
84
|
+
* passing no translation map yields the English.
|
|
78
85
|
*/
|
|
79
|
-
reportError(error: unknown,
|
|
86
|
+
reportError(error: unknown, reported: ResolvedMessage): void;
|
|
80
87
|
/**
|
|
81
88
|
* Fires when the host tears the transport down and the current connection
|
|
82
89
|
* is no longer usable — a language-server restart being the case that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-port.d.ts","sourceRoot":"","sources":["../../src/client/data-port.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"data-port.d.ts","sourceRoot":"","sources":["../../src/client/data-port.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,WAAW,QAAQ;IACtB;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;;;;OAOG;IACH,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEtC;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAE7D;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAClC"}
|
|
@@ -12,6 +12,14 @@ import { type RpcProxy } from '../rpc';
|
|
|
12
12
|
import type { TransferDocument } from '../transfer-document';
|
|
13
13
|
import type { TransferElement } from '../transfer-element';
|
|
14
14
|
import type { DataPort } from './data-port';
|
|
15
|
+
/**
|
|
16
|
+
* The transport never opened. A complete sentence rather than a fragment: a
|
|
17
|
+
* fragment is nested inside a sentence the framework does not own, so no
|
|
18
|
+
* translator controls the whole and the composition cannot be made to read
|
|
19
|
+
* correctly in every language.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DATA_SERVER_CONNECT_FAILED: import("../messages/primitives").MessageDefinition<"Could not connect to the data server: {detail}">;
|
|
22
|
+
export declare const DATA_SERVER_NOT_READY: import("../messages/primitives").MessageDefinition<"The data server did not become ready: {detail}">;
|
|
15
23
|
/** Options for {@link DataSession}. */
|
|
16
24
|
export interface DataSessionOptions {
|
|
17
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-session.d.ts","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAyD,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"data-session.d.ts","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":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SAAS,CAAC,QAAQ,UAAS;IAC3B,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE;QAAE,OAAO,IAAI,IAAI,CAAA;KAAE,CAAC;gBAGtC,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,kBAAkB,CAAC,SAAS,CAAC,EACxD,OAAO,GAAE,kBAAuB;IAMnC,+EAA+E;IAC/E,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;;;;;;;;OAUG;IACG,SAAS,IAAI,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;IAYnE;;;;;;;;;;;;;;;;;OAiBG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAOrE;;;OAGG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C;;;;;;OAMG;IACH,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO;IAI1C,+EAA+E;IAC/E,OAAO,IAAI,IAAI;IASf,0DAA0D;IAC1D,SAAS,CAAC,iBAAiB,IAAI,UAAU,CAAC,SAAS,CAAC;IAoBpD,6EAA6E;cAC7D,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5E;;;OAGG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;CAQlC"}
|
|
@@ -8,9 +8,18 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.DataSession = void 0;
|
|
11
|
+
exports.DataSession = exports.DATA_SERVER_NOT_READY = exports.DATA_SERVER_CONNECT_FAILED = void 0;
|
|
12
12
|
const data_1 = require("../data");
|
|
13
|
+
const primitives_1 = require("../messages/primitives");
|
|
13
14
|
const rpc_1 = require("../rpc");
|
|
15
|
+
/**
|
|
16
|
+
* The transport never opened. A complete sentence rather than a fragment: a
|
|
17
|
+
* fragment is nested inside a sentence the framework does not own, so no
|
|
18
|
+
* translator controls the whole and the composition cannot be made to read
|
|
19
|
+
* correctly in every language.
|
|
20
|
+
*/
|
|
21
|
+
exports.DATA_SERVER_CONNECT_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/data-server-connect-failed', 'Could not connect to the data server: {detail}');
|
|
22
|
+
exports.DATA_SERVER_NOT_READY = (0, primitives_1.defineMessage)('hydranium/protocol/data-server-not-ready', 'The data server did not become ready: {detail}');
|
|
14
23
|
/**
|
|
15
24
|
* The host-invariant half of talking to the data head: everything above
|
|
16
25
|
* {@link DataPort} that would otherwise be re-derived by every host
|
|
@@ -137,7 +146,7 @@ class DataSession {
|
|
|
137
146
|
// Rejection is reported here rather than left to float: an unhandled
|
|
138
147
|
// rejection on a connection promise is the failure mode that reads as
|
|
139
148
|
// "the model is empty" instead of "the transport never opened".
|
|
140
|
-
connection.catch((error) => this.port.reportError(error,
|
|
149
|
+
connection.catch((error) => this.port.reportError(error, (0, primitives_1.resolve)(exports.DATA_SERVER_CONNECT_FAILED, { detail: (0, primitives_1.describeError)(error) })));
|
|
141
150
|
const server = (0, rpc_1.createRpcProxy)(connection, {
|
|
142
151
|
methodNamespace: this.methodNamespace,
|
|
143
152
|
localTarget: this.client,
|
|
@@ -158,7 +167,7 @@ class DataSession {
|
|
|
158
167
|
if (this.generation === generation) {
|
|
159
168
|
this.generation = undefined;
|
|
160
169
|
}
|
|
161
|
-
this.port.reportError(error,
|
|
170
|
+
this.port.reportError(error, (0, primitives_1.resolve)(exports.DATA_SERVER_NOT_READY, { detail: (0, primitives_1.describeError)(error) }));
|
|
162
171
|
throw error;
|
|
163
172
|
}
|
|
164
173
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-session.js","sourceRoot":"","sources":["../../src/client/data-session.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOk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,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,EAAE,CAAC;YACf,OAAO;QACV,CAAC;QACD,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACzF,CAAC;CACH;AApJD,kCAoJC"}
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type Disposable, type Event, type MessageReader, type MessageWriter } from 'vscode-jsonrpc';
|
|
10
|
+
import { type ResolvedMessage } from '../messages/primitives';
|
|
10
11
|
import type { PostMessageChannel } from './post-message-transport';
|
|
12
|
+
export declare const RELAY_TRANSPORT_OPEN_FAILED: import("../messages/primitives").MessageDefinition<"Could not open the transport to relay: {detail}">;
|
|
13
|
+
export declare const RELAY_TRANSPORT_READ_FAILED: import("../messages/primitives").MessageDefinition<"Could not read from the relayed transport: {detail}">;
|
|
14
|
+
export declare const RELAY_TRANSPORT_WRITE_FAILED: import("../messages/primitives").MessageDefinition<"Could not write to the relayed transport: {detail}">;
|
|
15
|
+
export declare const RELAY_REPLAY_FAILED: import("../messages/primitives").MessageDefinition<"Could not replay a buffered message to the relayed transport: {detail}">;
|
|
11
16
|
/**
|
|
12
17
|
* The framed side of a relay: the reader/writer pair over whatever transport the
|
|
13
18
|
* host actually holds — a TCP socket to the data-server, a child process' stdio,
|
|
@@ -27,13 +32,14 @@ export interface RelayTransport {
|
|
|
27
32
|
export interface MessageRelayOptions {
|
|
28
33
|
/**
|
|
29
34
|
* Surface a failure the way the host does. Same contract as
|
|
30
|
-
* `DataPort.reportError`: `
|
|
35
|
+
* `DataPort.reportError`: `reported` is a complete sentence plus the identity
|
|
36
|
+
* needed to render it in another language.
|
|
31
37
|
*
|
|
32
38
|
* A relay has no other way to report — it sits between two transports and
|
|
33
39
|
* owns neither, so a swallowed error here presents as a form that never
|
|
34
40
|
* populates.
|
|
35
41
|
*/
|
|
36
|
-
readonly reportError?: (error: unknown,
|
|
42
|
+
readonly reportError?: (error: unknown, reported: ResolvedMessage) => void;
|
|
37
43
|
}
|
|
38
44
|
/** A live relay. Dispose to tear both directions down. */
|
|
39
45
|
export interface MessageRelay extends Disposable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-relay.d.ts","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,KAAK,EAAgB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,gEAAgE;IAChE,OAAO,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IACjC
|
|
1
|
+
{"version":3,"file":"message-relay.d.ts","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAW,KAAK,UAAU,EAAE,KAAK,KAAK,EAAgB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5H,OAAO,EAAyC,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,eAAO,MAAM,2BAA2B,uGAGvC,CAAC;AAEF,eAAO,MAAM,2BAA2B,2GAGvC,CAAC;AAEF,eAAO,MAAM,4BAA4B,0GAGxC,CAAC;AAEF,eAAO,MAAM,mBAAmB,8HAG/B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,gEAAgE;IAChE,OAAO,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IACjC;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;CAC7E;AAED,0DAA0D;AAC1D,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC7C;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,yBAAyB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,aAAa,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,EAC5C,OAAO,GAAE,mBAAwB,GACjC,YAAY,CAgGd"}
|
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.RELAY_REPLAY_FAILED = exports.RELAY_TRANSPORT_WRITE_FAILED = exports.RELAY_TRANSPORT_READ_FAILED = exports.RELAY_TRANSPORT_OPEN_FAILED = void 0;
|
|
11
12
|
exports.relayToPostMessageChannel = relayToPostMessageChannel;
|
|
12
13
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
14
|
+
const primitives_1 = require("../messages/primitives");
|
|
15
|
+
exports.RELAY_TRANSPORT_OPEN_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/relay-transport-open-failed', 'Could not open the transport to relay: {detail}');
|
|
16
|
+
exports.RELAY_TRANSPORT_READ_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/relay-transport-read-failed', 'Could not read from the relayed transport: {detail}');
|
|
17
|
+
exports.RELAY_TRANSPORT_WRITE_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/relay-transport-write-failed', 'Could not write to the relayed transport: {detail}');
|
|
18
|
+
exports.RELAY_REPLAY_FAILED = (0, primitives_1.defineMessage)('hydranium/protocol/relay-replay-failed', 'Could not replay a buffered message to the relayed transport: {detail}');
|
|
13
19
|
/**
|
|
14
20
|
* Pump JSON-RPC messages between a framed transport and a structured-clone
|
|
15
21
|
* {@link PostMessageChannel}, decoding neither.
|
|
@@ -78,7 +84,7 @@ function relayToPostMessageChannel(channel, openTransport, options = {}) {
|
|
|
78
84
|
bufferSubscription?.dispose();
|
|
79
85
|
bufferSubscription = undefined;
|
|
80
86
|
buffered.length = 0;
|
|
81
|
-
options.reportError?.(error,
|
|
87
|
+
options.reportError?.(error, (0, primitives_1.resolve)(exports.RELAY_TRANSPORT_OPEN_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
82
88
|
closeFramedSide();
|
|
83
89
|
return false;
|
|
84
90
|
}
|
|
@@ -95,11 +101,11 @@ function relayToPostMessageChannel(channel, openTransport, options = {}) {
|
|
|
95
101
|
bufferSubscription?.dispose();
|
|
96
102
|
bufferSubscription = undefined;
|
|
97
103
|
subscriptions.push(opened.reader.listen(message => channel.post(message)), opened.reader.onClose(() => closeFramedSide()), opened.reader.onError(error => {
|
|
98
|
-
options.reportError?.(error,
|
|
104
|
+
options.reportError?.(error, (0, primitives_1.resolve)(exports.RELAY_TRANSPORT_READ_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
99
105
|
closeFramedSide();
|
|
100
106
|
}), channel.onMessage(message => {
|
|
101
107
|
void opened.writer.write(message).catch((error) => {
|
|
102
|
-
options.reportError?.(error,
|
|
108
|
+
options.reportError?.(error, (0, primitives_1.resolve)(exports.RELAY_TRANSPORT_WRITE_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
103
109
|
});
|
|
104
110
|
}));
|
|
105
111
|
const onChannelClose = channel.onClose?.(() => dispose());
|
|
@@ -108,7 +114,7 @@ function relayToPostMessageChannel(channel, openTransport, options = {}) {
|
|
|
108
114
|
}
|
|
109
115
|
for (const message of buffered) {
|
|
110
116
|
void opened.writer.write(message).catch((error) => {
|
|
111
|
-
options.reportError?.(error,
|
|
117
|
+
options.reportError?.(error, (0, primitives_1.resolve)(exports.RELAY_REPLAY_FAILED, { detail: (0, primitives_1.describeError)(error) }));
|
|
112
118
|
});
|
|
113
119
|
}
|
|
114
120
|
buffered.length = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-relay.js","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"message-relay.js","sourceRoot":"","sources":["../../src/client/message-relay.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAkIlF,8DAoGC;AApOD,mDAA4H;AAC5H,uDAAqG;AAGxF,QAAA,2BAA2B,GAAG,IAAA,0BAAa,EACrD,gDAAgD,EAChD,iDAAiD,CACnD,CAAC;AAEW,QAAA,2BAA2B,GAAG,IAAA,0BAAa,EACrD,gDAAgD,EAChD,qDAAqD,CACvD,CAAC;AAEW,QAAA,4BAA4B,GAAG,IAAA,0BAAa,EACtD,iDAAiD,EACjD,oDAAoD,CACtD,CAAC;AAEW,QAAA,mBAAmB,GAAG,IAAA,0BAAa,EAC7C,wCAAwC,EACxC,wEAAwE,CAC1E,CAAC;AA8DF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,SAAgB,yBAAyB,CACtC,OAA2B,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AAC,KAAc,EAAE,EAAE;gBACxD,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,IAAA,oBAAO,EAAC,2BAAmB,EAAE,EAAE,MAAM,EAAE,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YAChG,CAAC,CAAC,CAAC;QACN,CAAC;QACD,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QAEpB,OAAO,IAAI,CAAC;IACf,CAAC,CAAC,EAAE,CAAC;IAEL,SAAS,OAAO;QACb,IAAI,QAAQ,EAAE,CAAC;YACZ,OAAO;QACV,CAAC;QACD,QAAQ,GAAG,IAAI,CAAC;QAChB,kBAAkB,EAAE,OAAO,EAAE,CAAC;QAC9B,kBAAkB,GAAG,SAAS,CAAC;QAC/B,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACpB,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;YACxC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC1B,CAAC;QACD,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QACzB,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC;QACvB,SAAS,GAAG,SAAS,CAAC;QACtB,YAAY,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO;QACJ,KAAK;QACL,OAAO,EAAE,YAAY,CAAC,KAAK;QAC3B,OAAO;KACT,CAAC;AACL,CAAC"}
|
package/lib/errors.d.ts
CHANGED
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { ResponseError } from 'vscode-jsonrpc';
|
|
10
|
+
import { type HydraniumMessageData } from './messages/primitives';
|
|
11
|
+
/**
|
|
12
|
+
* The catalogue declaration behind {@link ConflictError}'s sentence.
|
|
13
|
+
*
|
|
14
|
+
* Its English must keep containing {@link CONFLICT_ERROR_MESSAGE_MARKER}: the
|
|
15
|
+
* marker is tier 3 of {@link isConflictError}'s ladder, and it matches on text.
|
|
16
|
+
* That tier only ever works untranslated, which is why it is the last resort
|
|
17
|
+
* behind the numeric code rather than the primary check.
|
|
18
|
+
*/
|
|
19
|
+
export declare const STALE_BASED_UPDATE: import("./messages/primitives").MessageDefinition<"Stale-based update for {uri}: expected v{expected}, server is at v{actual}">;
|
|
10
20
|
/**
|
|
11
21
|
* Application-specific JSON-RPC error code for {@link ConflictError}.
|
|
12
22
|
* Outside the reserved range (-32768 .. -32000) per JSON-RPC 2.0.
|
|
@@ -21,7 +31,7 @@ export declare const CONFLICT_ERROR_CODE = 1001;
|
|
|
21
31
|
* Structured payload carried in {@link ConflictError.data}, and the only place
|
|
22
32
|
* a post-RPC caller can read the version mismatch from.
|
|
23
33
|
*/
|
|
24
|
-
export interface ConflictErrorData {
|
|
34
|
+
export interface ConflictErrorData extends HydraniumMessageData {
|
|
25
35
|
readonly uri: string;
|
|
26
36
|
/** The based-on version the caller authored against. */
|
|
27
37
|
readonly expected: number;
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAiB,KAAK,oBAAoB,EAAe,MAAM,uBAAuB,CAAC;AAE9F;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,iIAG9B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC5D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,aAAc,SAAQ,aAAa,CAAC,iBAAiB,CAAC;gBACpD,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAezD,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;CACH;AAOD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAYtE"}
|
package/lib/errors.js
CHANGED
|
@@ -8,9 +8,19 @@
|
|
|
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.ConflictError = exports.CONFLICT_ERROR_CODE = exports.STALE_BASED_UPDATE = void 0;
|
|
12
12
|
exports.isConflictError = isConflictError;
|
|
13
13
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
14
|
+
const primitives_1 = require("./messages/primitives");
|
|
15
|
+
/**
|
|
16
|
+
* The catalogue declaration behind {@link ConflictError}'s sentence.
|
|
17
|
+
*
|
|
18
|
+
* Its English must keep containing {@link CONFLICT_ERROR_MESSAGE_MARKER}: the
|
|
19
|
+
* marker is tier 3 of {@link isConflictError}'s ladder, and it matches on text.
|
|
20
|
+
* That tier only ever works untranslated, which is why it is the last resort
|
|
21
|
+
* behind the numeric code rather than the primary check.
|
|
22
|
+
*/
|
|
23
|
+
exports.STALE_BASED_UPDATE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-based-update', 'Stale-based update for {uri}: expected v{expected}, server is at v{actual}');
|
|
14
24
|
/**
|
|
15
25
|
* Application-specific JSON-RPC error code for {@link ConflictError}.
|
|
16
26
|
* Outside the reserved range (-32768 .. -32000) per JSON-RPC 2.0.
|
|
@@ -54,11 +64,11 @@ exports.CONFLICT_ERROR_CODE = 1001;
|
|
|
54
64
|
*/
|
|
55
65
|
class ConflictError extends vscode_jsonrpc_1.ResponseError {
|
|
56
66
|
constructor(uri, expected, actual) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
67
|
+
const params = { uri, expected, actual };
|
|
68
|
+
// The identity rides alongside the typed payload rather than replacing
|
|
69
|
+
// it: this class's getters and `isConflictError`'s name check are surface
|
|
70
|
+
// an adopter may bind, so the payload widens rather than changing shape.
|
|
71
|
+
super(exports.CONFLICT_ERROR_CODE, exports.STALE_BASED_UPDATE.format(params), { ...params, ...(0, primitives_1.messageData)(exports.STALE_BASED_UPDATE, params) });
|
|
62
72
|
this.name = 'ConflictError';
|
|
63
73
|
// ResponseError's constructor calls `Object.setPrototypeOf(this,
|
|
64
74
|
// ResponseError.prototype)` to keep its own prototype chain intact across
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAyHlF,0CAYC;AAnID,mDAA+C;AAC/C,sDAA8F;AAE9F;;;;;;;GAOG;AACU,QAAA,kBAAkB,GAAG,IAAA,0BAAa,EAC5C,uCAAuC,EACvC,4EAA4E,CAC9E,CAAC;AAEF;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAG,IAAI,CAAC;AAcxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,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
|
@@ -16,6 +16,7 @@ export * from './errors';
|
|
|
16
16
|
export * from './host-diagnostics';
|
|
17
17
|
export * from './logger';
|
|
18
18
|
export * from './latency-collector';
|
|
19
|
+
export * from './messages/primitives';
|
|
19
20
|
export * from './patch-merge';
|
|
20
21
|
export * from './noop-logger';
|
|
21
22
|
export * from './observable-value';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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;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
|
@@ -38,6 +38,10 @@ __exportStar(require("./errors"), exports);
|
|
|
38
38
|
__exportStar(require("./host-diagnostics"), exports);
|
|
39
39
|
__exportStar(require("./logger"), exports);
|
|
40
40
|
__exportStar(require("./latency-collector"), exports);
|
|
41
|
+
// The primitives only. The `./messages` subpath additionally enumerates this
|
|
42
|
+
// package's own declarations, which the root barrel already re-exports through
|
|
43
|
+
// the modules that raise them.
|
|
44
|
+
__exportStar(require("./messages/primitives"), exports);
|
|
41
45
|
__exportStar(require("./patch-merge"), exports);
|
|
42
46
|
__exportStar(require("./noop-logger"), exports);
|
|
43
47
|
__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,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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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/data-session';
|
|
27
|
+
export { RELAY_REPLAY_FAILED, RELAY_TRANSPORT_OPEN_FAILED, RELAY_TRANSPORT_READ_FAILED, RELAY_TRANSPORT_WRITE_FAILED } from '../client/message-relay';
|
|
28
|
+
//# 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,wBAAwB,CAAC;AAC3F,OAAO,EACJ,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC9B,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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_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 data_session_1 = require("../client/data-session");
|
|
45
|
+
Object.defineProperty(exports, "DATA_SERVER_CONNECT_FAILED", { enumerable: true, get: function () { return data_session_1.DATA_SERVER_CONNECT_FAILED; } });
|
|
46
|
+
Object.defineProperty(exports, "DATA_SERVER_NOT_READY", { enumerable: true, get: function () { return data_session_1.DATA_SERVER_NOT_READY; } });
|
|
47
|
+
var message_relay_1 = require("../client/message-relay");
|
|
48
|
+
Object.defineProperty(exports, "RELAY_REPLAY_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_REPLAY_FAILED; } });
|
|
49
|
+
Object.defineProperty(exports, "RELAY_TRANSPORT_OPEN_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_OPEN_FAILED; } });
|
|
50
|
+
Object.defineProperty(exports, "RELAY_TRANSPORT_READ_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_READ_FAILED; } });
|
|
51
|
+
Object.defineProperty(exports, "RELAY_TRANSPORT_WRITE_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_WRITE_FAILED; } });
|
|
52
|
+
//# 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,uDAA2F;AAAlF,0HAAA,0BAA0B,OAAA;AAAE,qHAAA,qBAAqB,OAAA;AAC1D,yDAKiC;AAJ9B,oHAAA,mBAAmB,OAAA;AACnB,4HAAA,2BAA2B,OAAA;AAC3B,4HAAA,2BAA2B,OAAA;AAC3B,6HAAA,4BAA4B,OAAA"}
|
|
@@ -0,0 +1,135 @@
|
|
|
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 never translates them: it
|
|
12
|
+
* holds no locale, so it cannot know what the reading user reads. Every such
|
|
13
|
+
* string carries a stable code beside its English text, and whoever owns the
|
|
14
|
+
* surface renders it. A framework-held locale would give one toast two
|
|
15
|
+
* authorities — an adopter sentence in one language wrapping a framework clause
|
|
16
|
+
* in another.
|
|
17
|
+
*
|
|
18
|
+
* Codes are `hydranium/<unscoped-package>/<name>`. The package segment locates
|
|
19
|
+
* the declaration, so a message is declared in the package that raises it and a
|
|
20
|
+
* code never names a package it does not live in. `.` and `:` are forbidden in a
|
|
21
|
+
* segment: they are i18next's default key and namespace separators, where either
|
|
22
|
+
* silently becomes a nested lookup that misses.
|
|
23
|
+
*/
|
|
24
|
+
export type MessageParams = Readonly<Record<string, string | number>>;
|
|
25
|
+
type Placeholder<S extends string> = S extends `${string}{${infer Name}}${infer Rest}` ? Name | Placeholder<Rest> : never;
|
|
26
|
+
export type ParamsOf<S extends string> = [Placeholder<S>] extends [never] ? Record<never, never> : Readonly<Record<Placeholder<S>, string | number>>;
|
|
27
|
+
/** Required exactly when the text has placeholders, absent when it does not. */
|
|
28
|
+
export type ParamsArg<S extends string> = [Placeholder<S>] extends [never] ? [] : [params: ParamsOf<S>];
|
|
29
|
+
/**
|
|
30
|
+
* Rejects a text argument already widened to `string`. Load-bearing rather than
|
|
31
|
+
* defensive: the whole compile-time guarantee is conditional on `S` inferring a
|
|
32
|
+
* literal, and for a concatenated or pre-widened text the placeholder set
|
|
33
|
+
* silently becomes empty, `format()` accepts no arguments, and the missing
|
|
34
|
+
* substitution surfaces only at runtime.
|
|
35
|
+
*/
|
|
36
|
+
export type LiteralText<S extends string> = string extends S ? never : S;
|
|
37
|
+
export interface MessageDefinition<S extends string> {
|
|
38
|
+
readonly code: string;
|
|
39
|
+
readonly text: S;
|
|
40
|
+
format(...args: ParamsArg<S>): string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Declare a message. Placeholder names are inferred from `text` rather than
|
|
44
|
+
* declared again in a type argument: a second spelling of every name is the
|
|
45
|
+
* repetition that drifts, since adding a placeholder to the sentence and not to
|
|
46
|
+
* the type compiles.
|
|
47
|
+
*/
|
|
48
|
+
export declare function defineMessage<S extends string>(code: string, text: LiteralText<S>): MessageDefinition<S>;
|
|
49
|
+
/**
|
|
50
|
+
* Substitute `{name}` tokens, leaving an unfilled token in place.
|
|
51
|
+
*
|
|
52
|
+
* It must not throw. This runs over an adopter's translation as well as our own
|
|
53
|
+
* text, so a typo in a foreign catalogue has to degrade to a slightly wrong
|
|
54
|
+
* sentence rather than raise inside a toast render. Re-scanning the result to
|
|
55
|
+
* detect an unfilled token is what an earlier form did, and it cannot work:
|
|
56
|
+
* `String.replace` does not rescan replacement text, so the check could not tell
|
|
57
|
+
* an unfilled placeholder from user data shaped like one — an element literally
|
|
58
|
+
* named `{separator}` crashed at the authoring site.
|
|
59
|
+
*/
|
|
60
|
+
export declare function interpolate(template: string, params: MessageParams): string;
|
|
61
|
+
export interface MessageIdentity {
|
|
62
|
+
readonly code: string;
|
|
63
|
+
readonly params: MessageParams;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Envelope for a protocol `data` field. Namespaced under one key so it co-exists
|
|
67
|
+
* with a carrier's own `data` conventions rather than occupying `data` itself.
|
|
68
|
+
*/
|
|
69
|
+
export interface HydraniumMessageData {
|
|
70
|
+
readonly hydranium: MessageIdentity;
|
|
71
|
+
}
|
|
72
|
+
/** An identity plus its resolved English — everything a renderer needs, on any carrier. */
|
|
73
|
+
export interface ResolvedMessage extends MessageIdentity {
|
|
74
|
+
readonly text: string;
|
|
75
|
+
}
|
|
76
|
+
export declare function messageData<S extends string>(message: MessageDefinition<S>, ...args: ParamsArg<S>): HydraniumMessageData;
|
|
77
|
+
/**
|
|
78
|
+
* Identity plus resolved English, for a hand-off carrying a value rather than a
|
|
79
|
+
* protocol field. The result is structured-clone safe, so it survives a process
|
|
80
|
+
* hop where one intervenes and costs nothing where none does.
|
|
81
|
+
*/
|
|
82
|
+
export declare function resolve<S extends string>(message: MessageDefinition<S>, ...args: ParamsArg<S>): ResolvedMessage;
|
|
83
|
+
/**
|
|
84
|
+
* Validates every field {@link MessageIdentity} declares, `params` included.
|
|
85
|
+
* A guard over foreign input that checks only `code` while declaring `params`
|
|
86
|
+
* non-optional hands `undefined` to the renderer, which fails with the worst
|
|
87
|
+
* polarity available: invisible in English, crashing only once a translation is
|
|
88
|
+
* loaded.
|
|
89
|
+
*/
|
|
90
|
+
export declare function hasMessageIdentity(data: unknown): data is HydraniumMessageData;
|
|
91
|
+
/**
|
|
92
|
+
* A type alias rather than a subclass. Only `code`, `message` and `data` cross
|
|
93
|
+
* the wire, so a subclass buys nothing there: `instanceof` does not survive
|
|
94
|
+
* reconstruction, and the subclass costs an `Object.setPrototypeOf` in every
|
|
95
|
+
* constructor purely to undo what `ResponseError`'s own constructor does.
|
|
96
|
+
*/
|
|
97
|
+
export type HydraniumResponseError = ResponseError<HydraniumMessageData>;
|
|
98
|
+
/**
|
|
99
|
+
* The numeric `code` and the message's catalogue code are unrelated and both are
|
|
100
|
+
* needed: `ResponseError.code` is an `integer`, so it cannot hold a
|
|
101
|
+
* `hydranium/…` key, and it is what a caller switches on after reconstruction.
|
|
102
|
+
*/
|
|
103
|
+
export declare function messageError<S extends string>(code: number, message: MessageDefinition<S>, ...params: ParamsArg<S>): HydraniumResponseError;
|
|
104
|
+
/**
|
|
105
|
+
* Render on the side that knows the reading user's locale. `translations` is
|
|
106
|
+
* whatever flat `code → template` map the host exposes; omitting it is how an
|
|
107
|
+
* adopter without i18n opts out, and yields the English.
|
|
108
|
+
*/
|
|
109
|
+
export declare function renderFrameworkMessage(message: ResolvedMessage, translations?: Record<string, string>): string;
|
|
110
|
+
export declare function resolvedFromResponseError(error: ResponseError<unknown>): ResolvedMessage | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* The detail half of a `{detail}` placeholder. A technical error string is safe
|
|
113
|
+
* to pass as a parameter for the same reason a number is: it is not itself
|
|
114
|
+
* translatable text, so it needs no code of its own. A PROSE fragment is not,
|
|
115
|
+
* and must become one code per value instead.
|
|
116
|
+
*/
|
|
117
|
+
export declare function describeError(error: unknown): string;
|
|
118
|
+
/**
|
|
119
|
+
* Recognises a declaration among a barrel's exports. The `format` check is what
|
|
120
|
+
* discriminates: a `code` + `text` pair alone admits any object that happens to
|
|
121
|
+
* carry both.
|
|
122
|
+
*/
|
|
123
|
+
export declare function isMessageDeclaration(value: unknown): value is MessageDefinition<string>;
|
|
124
|
+
/**
|
|
125
|
+
* Every declaration a `./messages` barrel exports.
|
|
126
|
+
*
|
|
127
|
+
* A caller cannot get there with `Object.values(barrel).filter(isMessageDeclaration)`:
|
|
128
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
129
|
+
* `filter` will not narrow a function type down to a `MessageDefinition`, so the
|
|
130
|
+
* result stays the union and reading `.code` off it does not compile. Taking the
|
|
131
|
+
* barrel as an opaque object is what makes the one-liner work.
|
|
132
|
+
*/
|
|
133
|
+
export declare function collectMessages(barrel: object): MessageDefinition<string>[];
|
|
134
|
+
export {};
|
|
135
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/messages/primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO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