@hydranium/protocol 1.0.0-next.7 → 1.0.0-next.70
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/README.md +35 -1
- package/lib/client/data-connection.d.ts +103 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +114 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +9 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +14 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +16 -21
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +56 -74
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +67 -101
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +10 -7
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +10 -7
- package/lib/client/index.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/client/rpc-connection.d.ts +131 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +171 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +41 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +44 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +2 -2
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +6 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +21 -1
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +70 -3
- package/lib/data/events.d.ts.map +1 -1
- package/lib/errors.d.ts +25 -6
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +32 -12
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -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 +141 -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/model-server.d.ts +2 -2
- package/lib/model-server.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.d.ts +29 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +22 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +7 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +6 -1
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +11 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +14 -5
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/index.d.ts +1 -0
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +4 -1
- package/lib/testing/index.js.map +1 -1
- package/lib/transfer-diagnostic.d.ts +33 -0
- package/lib/transfer-diagnostic.d.ts.map +1 -1
- package/lib/transfer-diagnostic.js +23 -0
- package/lib/transfer-diagnostic.js.map +1 -1
- package/package.json +11 -2
- package/src/client/data-connection.ts +160 -0
- package/src/client/data-events.ts +24 -1
- package/src/client/data-port.ts +16 -22
- package/src/client/data-session.ts +86 -124
- package/src/client/index.ts +10 -7
- package/src/client/message-relay.ts +28 -6
- package/src/client/rpc-connection.ts +222 -0
- package/src/client-ids.ts +45 -0
- package/src/data/data-protocol-methods.ts +6 -3
- package/src/data/data-server-protocol.ts +29 -1
- package/src/data/events.ts +74 -3
- package/src/errors.ts +38 -14
- package/src/index.ts +5 -0
- package/src/messages/index.ts +35 -0
- package/src/messages/primitives.ts +215 -0
- package/src/model-server.ts +2 -2
- package/src/rpc/bind-rpc-methods.ts +49 -4
- package/src/rpc/create-rpc-proxy.ts +14 -1
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +33 -17
- package/src/testing/index.ts +4 -1
- package/src/transfer-diagnostic.ts +40 -0
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,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"}
|
|
@@ -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/rpc-connection';
|
|
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,0BAA0B,CAAC;AAC7F,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 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 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,2DAA6F;AAApF,4HAAA,0BAA0B,OAAA;AAAE,uHAAA,qBAAqB,OAAA;AAC1D,yDAKiC;AAJ9B,oHAAA,mBAAmB,OAAA;AACnB,4HAAA,2BAA2B,OAAA;AAC3B,4HAAA,2BAA2B,OAAA;AAC3B,6HAAA,4BAA4B,OAAA"}
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
* Render on the side that knows the reading user's locale. `translations` is
|
|
112
|
+
* whatever flat `code → template` map the host exposes; omitting it is how an
|
|
113
|
+
* adopter without i18n opts out, and yields the English.
|
|
114
|
+
*/
|
|
115
|
+
export declare function renderFrameworkMessage(message: ResolvedMessage, translations?: Record<string, string>): string;
|
|
116
|
+
export declare function resolvedFromResponseError(error: ResponseError<unknown>): ResolvedMessage | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* The detail half of a `{detail}` placeholder. A technical error string is safe
|
|
119
|
+
* to pass as a parameter for the same reason a number is: it is not itself
|
|
120
|
+
* translatable text, so it needs no code of its own. A PROSE fragment is not,
|
|
121
|
+
* and must become one code per value instead.
|
|
122
|
+
*/
|
|
123
|
+
export declare function describeError(error: unknown): string;
|
|
124
|
+
/**
|
|
125
|
+
* Recognises a declaration among a barrel's exports. The `format` check is what
|
|
126
|
+
* discriminates: a `code` + `text` pair alone admits any object that happens to
|
|
127
|
+
* carry both.
|
|
128
|
+
*/
|
|
129
|
+
export declare function isMessageDeclaration(value: unknown): value is MessageDefinition<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Every declaration a `./messages` barrel exports.
|
|
132
|
+
*
|
|
133
|
+
* A caller cannot get there with `Object.values(barrel).filter(isMessageDeclaration)`:
|
|
134
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
135
|
+
* `filter` will not narrow a function type down to a `MessageDefinition`, so the
|
|
136
|
+
* result stays the union and reading `.code` off it does not compile. Taking the
|
|
137
|
+
* barrel as an opaque object is what makes the one-liner work.
|
|
138
|
+
*/
|
|
139
|
+
export declare function collectMessages(barrel: object): MessageDefinition<string>[];
|
|
140
|
+
export {};
|
|
141
|
+
//# 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,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAEtE,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,MAAM,IAAI,IAAI,MAAM,IAAI,EAAE,GAAG,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAE1H,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACpE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GACpB,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAEvD,gFAAgF;AACh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AAC,CAAC,GAAG,oBAAoB,CAExH;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,eAAe,CAE/G;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,oBAAoB,CAU9E;AAED;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAEzE;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC1C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC7B,GAAG,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GACvB,sBAAsB,CAExB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAG9G;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,GAAG,SAAS,CAEpG;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAAC,MAAM,CAAC,CASvF;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAE3E"}
|
|
@@ -0,0 +1,138 @@
|
|
|
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.defineMessage = defineMessage;
|
|
12
|
+
exports.interpolate = interpolate;
|
|
13
|
+
exports.messageData = messageData;
|
|
14
|
+
exports.resolve = resolve;
|
|
15
|
+
exports.hasMessageIdentity = hasMessageIdentity;
|
|
16
|
+
exports.messageError = messageError;
|
|
17
|
+
exports.renderFrameworkMessage = renderFrameworkMessage;
|
|
18
|
+
exports.resolvedFromResponseError = resolvedFromResponseError;
|
|
19
|
+
exports.describeError = describeError;
|
|
20
|
+
exports.isMessageDeclaration = isMessageDeclaration;
|
|
21
|
+
exports.collectMessages = collectMessages;
|
|
22
|
+
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
23
|
+
/**
|
|
24
|
+
* Declare a message. Placeholder names are inferred from `text` rather than
|
|
25
|
+
* declared again in a type argument: a second spelling of every name is the
|
|
26
|
+
* repetition that drifts, since adding a placeholder to the sentence and not to
|
|
27
|
+
* the type compiles.
|
|
28
|
+
*/
|
|
29
|
+
function defineMessage(code, text) {
|
|
30
|
+
const literal = text;
|
|
31
|
+
return { code, text: literal, format: (...args) => interpolate(literal, args[0] ?? {}) };
|
|
32
|
+
}
|
|
33
|
+
const PLACEHOLDER = /\{([^}]+)\}/g;
|
|
34
|
+
/**
|
|
35
|
+
* Substitute `{name}` tokens, leaving an unfilled token in place.
|
|
36
|
+
*
|
|
37
|
+
* It must not throw. This runs over an adopter's translation as well as our own
|
|
38
|
+
* text, so a typo in a foreign catalogue has to degrade to a slightly wrong
|
|
39
|
+
* sentence rather than raise inside a toast render. Re-scanning the result to
|
|
40
|
+
* detect an unfilled token is what an earlier form did, and it cannot work:
|
|
41
|
+
* `String.replace` does not rescan replacement text, so the check could not tell
|
|
42
|
+
* an unfilled placeholder from user data shaped like one — an element literally
|
|
43
|
+
* named `{separator}` crashed at the authoring site.
|
|
44
|
+
*/
|
|
45
|
+
function interpolate(template, params) {
|
|
46
|
+
// Indexed rather than `key in params`: a hand-built or version-skewed
|
|
47
|
+
// identity can arrive with no params at all, and `in` throws on a non-object
|
|
48
|
+
// where a lookup degrades.
|
|
49
|
+
const lookup = params;
|
|
50
|
+
return template.replace(PLACEHOLDER, (match, key) => {
|
|
51
|
+
const value = lookup?.[key];
|
|
52
|
+
return value === undefined ? match : String(value);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function messageData(message, ...args) {
|
|
56
|
+
return { hydranium: { code: message.code, params: args[0] ?? {} } };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Identity plus resolved English, for a hand-off carrying a value rather than a
|
|
60
|
+
* protocol field. The result is structured-clone safe, so it survives a process
|
|
61
|
+
* hop where one intervenes and costs nothing where none does.
|
|
62
|
+
*/
|
|
63
|
+
function resolve(message, ...args) {
|
|
64
|
+
return { code: message.code, text: message.format(...args), params: args[0] ?? {} };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validates every field {@link MessageIdentity} declares, `params` included.
|
|
68
|
+
* A guard over foreign input that checks only `code` while declaring `params`
|
|
69
|
+
* non-optional hands `undefined` to the renderer, which fails with the worst
|
|
70
|
+
* polarity available: invisible in English, crashing only once a translation is
|
|
71
|
+
* loaded.
|
|
72
|
+
*/
|
|
73
|
+
function hasMessageIdentity(data) {
|
|
74
|
+
if (typeof data !== 'object' || data === null || Array.isArray(data) || !('hydranium' in data)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
const identity = data.hydranium;
|
|
78
|
+
if (typeof identity !== 'object' || identity === null || Array.isArray(identity)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const candidate = identity;
|
|
82
|
+
return typeof candidate.code === 'string' && typeof candidate.params === 'object' && candidate.params !== null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The numeric `code` and the message's catalogue code are unrelated and both are
|
|
86
|
+
* needed: `ResponseError.code` is an `integer`, so it cannot hold a
|
|
87
|
+
* `hydranium/…` key, and it is what a caller switches on after reconstruction.
|
|
88
|
+
*/
|
|
89
|
+
function messageError(code, message, ...params) {
|
|
90
|
+
return new vscode_jsonrpc_1.ResponseError(code, message.format(...params), messageData(message, ...params));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Render on the side that knows the reading user's locale. `translations` is
|
|
94
|
+
* whatever flat `code → template` map the host exposes; omitting it is how an
|
|
95
|
+
* adopter without i18n opts out, and yields the English.
|
|
96
|
+
*/
|
|
97
|
+
function renderFrameworkMessage(message, translations) {
|
|
98
|
+
const template = translations?.[message.code];
|
|
99
|
+
return template ? interpolate(template, message.params) : message.text;
|
|
100
|
+
}
|
|
101
|
+
function resolvedFromResponseError(error) {
|
|
102
|
+
return hasMessageIdentity(error.data) ? { ...error.data.hydranium, text: error.message } : undefined;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The detail half of a `{detail}` placeholder. A technical error string is safe
|
|
106
|
+
* to pass as a parameter for the same reason a number is: it is not itself
|
|
107
|
+
* translatable text, so it needs no code of its own. A PROSE fragment is not,
|
|
108
|
+
* and must become one code per value instead.
|
|
109
|
+
*/
|
|
110
|
+
function describeError(error) {
|
|
111
|
+
return error instanceof Error ? error.message : String(error);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Recognises a declaration among a barrel's exports. The `format` check is what
|
|
115
|
+
* discriminates: a `code` + `text` pair alone admits any object that happens to
|
|
116
|
+
* carry both.
|
|
117
|
+
*/
|
|
118
|
+
function isMessageDeclaration(value) {
|
|
119
|
+
const candidate = value;
|
|
120
|
+
return (typeof candidate === 'object' &&
|
|
121
|
+
candidate !== null &&
|
|
122
|
+
typeof candidate.code === 'string' &&
|
|
123
|
+
typeof candidate.text === 'string' &&
|
|
124
|
+
typeof candidate.format === 'function');
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Every declaration a `./messages` barrel exports.
|
|
128
|
+
*
|
|
129
|
+
* A caller cannot get there with `Object.values(barrel).filter(isMessageDeclaration)`:
|
|
130
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
131
|
+
* `filter` will not narrow a function type down to a `MessageDefinition`, so the
|
|
132
|
+
* result stays the union and reading `.code` off it does not compile. Taking the
|
|
133
|
+
* barrel as an opaque object is what makes the one-liner work.
|
|
134
|
+
*/
|
|
135
|
+
function collectMessages(barrel) {
|
|
136
|
+
return Object.values(barrel).filter(isMessageDeclaration);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/messages/primitives.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;AAwDlF,sCAGC;AAeD,kCASC;AAoBD,kCAEC;AAOD,0BAEC;AASD,gDAUC;AAeD,oCAMC;AAOD,wDAGC;AAED,8DAEC;AAQD,sCAEC;AAOD,oDASC;AAWD,0CAEC;AA7MD,mDAA+C;AAgD/C;;;;;GAKG;AACH,SAAgB,aAAa,CAAmB,IAAY,EAAE,IAAoB;IAC/E,MAAM,OAAO,GAAG,IAAS,CAAC;IAC1B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;AAC5F,CAAC;AAED,MAAM,WAAW,GAAG,cAAc,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CAAC,QAAgB,EAAE,MAAqB;IAChE,sEAAsE;IACtE,6EAA6E;IAC7E,2BAA2B;IAC3B,MAAM,MAAM,GAAG,MAAiE,CAAC;IACj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AAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,MAAM,KAAK,UAAU,CACxC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAAC,MAAc;IAC3C,OAAQ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAe,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAC5E,CAAC"}
|
package/lib/model-server.d.ts
CHANGED
|
@@ -46,8 +46,8 @@ export interface CloseModelArgs extends TransferClientArgs {
|
|
|
46
46
|
export interface TransferUpdatedEvent<TDocument> {
|
|
47
47
|
document: TDocument;
|
|
48
48
|
sourceClientId: string;
|
|
49
|
-
/** See `
|
|
50
|
-
reason: 'changed' | '
|
|
49
|
+
/** See `TransferDocumentUpdateReason` in `./data/events` for the canonical reason set + semantics. */
|
|
50
|
+
reason: 'changed' | 'rebuilt' | 'saved';
|
|
51
51
|
}
|
|
52
52
|
export interface TransferSavedEvent<TDocument> {
|
|
53
53
|
/** The document as persisted — the state that reached disk, not the state at request time. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-server.d.ts","sourceRoot":"","sources":["../src/model-server.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAW9E,6CAA6C;AAC7C,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACtD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,yDAAyD;AAEzD,MAAM,WAAW,cAAe,SAAQ,kBAAkB;CAAG;AAM7D,M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AAC,KAAK,EAAE,MAAM,GAAG,0BAA0B,CAAC;CACnD;AAED,4CAA4C;AAC5C,MAAM,WAAW,0BAA0B;IACxC,KAAK,IAAI,gBAAgB,CAAC;CAC5B;AA8BD,yBAAiB,gBAAgB,CAAC;IAC/B,oEAAoE;IACpE,SAAgB,OAAO,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAE1E;CACH;AAED,yBAAiB,gBAAgB,CAAC;IAC/B,6EAA6E;IAC7E,SAAgB,OAAO,IAAI,oBAAoB,CAAC,0BAA0B,CAAC,CAI1E;IAED;;;;;;OAMG;IACH,SAAgB,IAAI,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,kBAAkB,GAAG,gBAAgB,CAE/F;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtD,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC9B;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;CAClB"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import type
|
|
9
|
+
import { ResponseError, type MessageConnection } from 'vscode-jsonrpc';
|
|
10
10
|
import type { LatencyCollector } from '../latency-collector';
|
|
11
11
|
import { type Disposable } from '../util';
|
|
12
12
|
/**
|
|
@@ -62,6 +62,30 @@ export interface BindRpcMethodsOptions {
|
|
|
62
62
|
* Requests and notifications are both timed. Absent by default (no overhead).
|
|
63
63
|
*/
|
|
64
64
|
readonly latency?: LatencyCollector;
|
|
65
|
+
/**
|
|
66
|
+
* Produce the `message` an outgoing rejection carries, so a user-facing
|
|
67
|
+
* error is rendered by the side that knows the reading user's language.
|
|
68
|
+
* Applied at this one chokepoint, which is what covers a caller's
|
|
69
|
+
* additional methods as well as the framework's own.
|
|
70
|
+
*
|
|
71
|
+
* Only a `ResponseError` is routed through it — a plain `Error` carries no
|
|
72
|
+
* identity to render from, and rewriting its message would relabel a
|
|
73
|
+
* developer-facing failure as a translated one. The rejection is
|
|
74
|
+
* RECONSTRUCTED rather than mutated, because the thrown value may be a
|
|
75
|
+
* shared constant; nothing is lost, since only `code`, `message` and `data`
|
|
76
|
+
* cross the wire and `instanceof` does not survive reconstruction anyway.
|
|
77
|
+
*
|
|
78
|
+
* Notifications are not covered, and "they have no reply channel" is only
|
|
79
|
+
* half the reason — a notification's own PAYLOAD can carry prose. What makes
|
|
80
|
+
* this sound is where that prose comes from: the only user-facing text on
|
|
81
|
+
* the data head's client surface is the diagnostics riding the
|
|
82
|
+
* document-updated and document-saved events, and those are read off
|
|
83
|
+
* `LangiumDocument.diagnostics`, which the document builder has already
|
|
84
|
+
* rendered at `Validated`. So they arrive rendered rather than escaping
|
|
85
|
+
* unrendered. A notification that ever carries prose of its OWN needs its
|
|
86
|
+
* own render at the raise site, as GLSP's actions do.
|
|
87
|
+
*/
|
|
88
|
+
readonly renderErrorMessage?: (error: ResponseError<unknown>) => string;
|
|
65
89
|
}
|
|
66
90
|
/**
|
|
67
91
|
* Register each named method on `target` as a handler on `connection`
|
|
@@ -82,8 +106,10 @@ export interface BindRpcMethodsOptions {
|
|
|
82
106
|
*
|
|
83
107
|
* Errors thrown synchronously from a request handler — or surfaced as a
|
|
84
108
|
* rejected promise — propagate back to the caller through vscode-jsonrpc's
|
|
85
|
-
* standard error envelope
|
|
86
|
-
*
|
|
109
|
+
* standard error envelope, with the message rendered when
|
|
110
|
+
* {@link BindRpcMethodsOptions.renderErrorMessage} is supplied. Errors from a
|
|
111
|
+
* notification handler cannot propagate, and are routed to
|
|
112
|
+
* {@link BindRpcMethodsOptions.onNotificationError} instead.
|
|
87
113
|
*
|
|
88
114
|
* Accepts either a ready connection or a `Promise<MessageConnection>` —
|
|
89
115
|
* registrations queue until the connection resolves, then attach. The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-rpc-methods.d.ts","sourceRoot":"","sources":["../../src/rpc/bind-rpc-methods.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"bind-rpc-methods.d.ts","sourceRoot":"","sources":["../../src/rpc/bind-rpc-methods.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,KAAK,UAAU,EAAwB,MAAM,SAAS,CAAC;AAIhE;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACnC;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAE1D;;;;;;;;;OASG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAE1E;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC;CAC1E;AAOD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC5C,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,EAC1D,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EAC1C,OAAO,GAAE,qBAA0B,GACnC,UAAU,CAgFZ"}
|
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.bindRpcMethods = bindRpcMethods;
|
|
12
|
+
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
12
13
|
const util_1 = require("../util");
|
|
13
14
|
const create_rpc_proxy_1 = require("./create-rpc-proxy");
|
|
14
15
|
const wire_prefix_1 = require("./wire-prefix");
|
|
16
|
+
/** The rejection to throw in place of `err`, with its message rendered. */
|
|
17
|
+
function renderRejection(err, render) {
|
|
18
|
+
return err instanceof vscode_jsonrpc_1.ResponseError ? new vscode_jsonrpc_1.ResponseError(err.code, render(err), err.data) : err;
|
|
19
|
+
}
|
|
15
20
|
/**
|
|
16
21
|
* Register each named method on `target` as a handler on `connection`
|
|
17
22
|
* under the wire-name `<prefix><methodName>`. Notification methods (by
|
|
@@ -31,8 +36,10 @@ const wire_prefix_1 = require("./wire-prefix");
|
|
|
31
36
|
*
|
|
32
37
|
* Errors thrown synchronously from a request handler — or surfaced as a
|
|
33
38
|
* rejected promise — propagate back to the caller through vscode-jsonrpc's
|
|
34
|
-
* standard error envelope
|
|
35
|
-
*
|
|
39
|
+
* standard error envelope, with the message rendered when
|
|
40
|
+
* {@link BindRpcMethodsOptions.renderErrorMessage} is supplied. Errors from a
|
|
41
|
+
* notification handler cannot propagate, and are routed to
|
|
42
|
+
* {@link BindRpcMethodsOptions.onNotificationError} instead.
|
|
36
43
|
*
|
|
37
44
|
* Accepts either a ready connection or a `Promise<MessageConnection>` —
|
|
38
45
|
* registrations queue until the connection resolves, then attach. The
|
|
@@ -84,7 +91,19 @@ function bindRpcMethods(connection, target, methodNames, options = {}) {
|
|
|
84
91
|
}));
|
|
85
92
|
}
|
|
86
93
|
else {
|
|
87
|
-
|
|
94
|
+
const render = options.renderErrorMessage;
|
|
95
|
+
disposables.push(resolved.onRequest(wireName, async (params) => {
|
|
96
|
+
if (!render) {
|
|
97
|
+
return dispatch(params);
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
// Awaited inside the try, or a rejected promise escapes it.
|
|
101
|
+
return await dispatch(params);
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
throw renderRejection(err, render);
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
88
107
|
}
|
|
89
108
|
}
|
|
90
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-rpc-methods.js","sourceRoot":"","sources":["../../src/rpc/bind-rpc-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;
|
|
1
|
+
{"version":3,"file":"bind-rpc-methods.js","sourceRoot":"","sources":["../../src/rpc/bind-rpc-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;AAoIlF,wCAqFC;AAvND,mDAAuE;AAEvE,kCAAgE;AAChE,yDAA2D;AAC3D,+CAA2D;AAsF3D,2EAA2E;AAC3E,SAAS,eAAe,CAAC,GAAY,EAAE,MAAiD;IACrF,OAAO,GAAG,YAAY,8BAAa,CAAC,CAAC,CAAC,IAAI,8BAAa,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAClG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,cAAc,CAC3B,UAA0D,EAC1D,MAAS,EACT,WAA0C,EAC1C,UAAiC,EAAE;IAEnC,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe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O;YACJ,SAAS,GAAG,IAAI,CAAC;YACjB,WAAW,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;KACH,CAAC;AACL,CAAC"}
|
|
@@ -127,6 +127,13 @@ export interface CreateRpcProxyOptions<TLocal extends object = never> {
|
|
|
127
127
|
* `bindRpcMethods` call) still capture per-method latency. Absent by default.
|
|
128
128
|
*/
|
|
129
129
|
readonly latency?: BindRpcMethodsOptions['latency'];
|
|
130
|
+
/**
|
|
131
|
+
* Forwarded to the inbound {@link localTarget} binding: renders the message
|
|
132
|
+
* an outgoing rejection carries. Only the inbound direction has rejections
|
|
133
|
+
* to render — the outbound proxy is this side making requests, and a
|
|
134
|
+
* rejection it receives was rendered by whoever answered.
|
|
135
|
+
*/
|
|
136
|
+
readonly renderErrorMessage?: BindRpcMethodsOptions['renderErrorMessage'];
|
|
130
137
|
}
|
|
131
138
|
/**
|
|
132
139
|
* Default notification discriminator — `on`-followed-by-an-uppercase-letter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-rpc-proxy.d.ts","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAW,KAAK,KAAK,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,KAAK,qBAAqB,EAAkB,MAAM,oBAAoB,CAAC;AAGhF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,iBAAiB;IAC/B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,oBAAoB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,qEAAqE;AACrE,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,iBAAiB,CAAC;AAE/D;;;;;;;;GAQG;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eAAe,CAAC,EAAE,MAAM,CAAC;IAElC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAE1D;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;;;;OASG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAE3D;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;CAC5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEjE;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,GAAG,KAAK,EAC3E,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,EAC1D,OAAO,GAAE,qBAAqB,CAAC,MAAM,CAAM,GAC3C,QAAQ,CAAC,CAAC,CAAC,CA+Eb"}
|
|
@@ -92,7 +92,12 @@ function createRpcProxy(connection, options = {}) {
|
|
|
92
92
|
// connection; see `localTarget` for why no `Disposable` is surfaced.
|
|
93
93
|
const { localTarget, localMethods } = options;
|
|
94
94
|
if (localTarget && localMethods && localMethods.length > 0) {
|
|
95
|
-
const binding = (0, bind_rpc_methods_1.bindRpcMethods)(connection, localTarget, localMethods, {
|
|
95
|
+
const binding = (0, bind_rpc_methods_1.bindRpcMethods)(connection, localTarget, localMethods, {
|
|
96
|
+
methodNamespace,
|
|
97
|
+
isNotification,
|
|
98
|
+
latency: options.latency,
|
|
99
|
+
renderErrorMessage: options.renderErrorMessage
|
|
100
|
+
});
|
|
96
101
|
resolvedConnection.then(conn => conn.onClose(() => binding.dispose())).catch(() => undefined);
|
|
97
102
|
}
|
|
98
103
|
const onDidOpenConnectionEmitter = new vscode_jsonrpc_1.Emitter();
|