@hydranium/protocol 1.0.0-next.25 → 1.0.0-next.251
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 +44 -49
- package/lib/abstract-logger.d.ts +5 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +7 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +245 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +425 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +13 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +21 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +44 -27
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +473 -81
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +743 -108
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +14 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +14 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +10 -4
- package/lib/client/message-relay.d.ts.map +1 -1
- package/lib/client/message-relay.js +12 -6
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/post-message-transport.d.ts +64 -3
- package/lib/client/post-message-transport.d.ts.map +1 -1
- package/lib/client/post-message-transport.js +175 -1
- package/lib/client/post-message-transport.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +157 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +214 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client-ids.d.ts +45 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +48 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/clock.d.ts +38 -0
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- package/lib/console-logger.d.ts +23 -0
- package/lib/console-logger.d.ts.map +1 -0
- package/lib/console-logger.js +39 -0
- package/lib/console-logger.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +4 -4
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +12 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +132 -41
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +117 -21
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +69 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +187 -29
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +270 -29
- package/lib/errors.js.map +1 -1
- package/lib/glsp-request-model-args.d.ts +16 -0
- package/lib/glsp-request-model-args.d.ts.map +1 -0
- package/lib/glsp-request-model-args.js +19 -0
- package/lib/glsp-request-model-args.js.map +1 -0
- package/lib/glsp-save-model-actions.d.ts +50 -0
- package/lib/glsp-save-model-actions.d.ts.map +1 -0
- package/lib/glsp-save-model-actions.js +28 -0
- package/lib/glsp-save-model-actions.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -1
- package/lib/latency-collector.d.ts +8 -4
- package/lib/latency-collector.d.ts.map +1 -1
- package/lib/latency-collector.js.map +1 -1
- package/lib/logger.d.ts +22 -1
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +31 -3
- package/lib/logger.js.map +1 -1
- package/lib/messages/index.d.ts +30 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +62 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/primitives.d.ts +188 -0
- package/lib/messages/primitives.d.ts.map +1 -0
- package/lib/messages/primitives.js +161 -0
- package/lib/messages/primitives.js.map +1 -0
- package/lib/model-server.d.ts +60 -13
- package/lib/model-server.d.ts.map +1 -1
- package/lib/model-server.js +4 -2
- package/lib/model-server.js.map +1 -1
- package/lib/model-service/base-version.d.ts +64 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/base-version.js +43 -0
- package/lib/model-service/base-version.js.map +1 -0
- package/lib/model-service/index.d.ts +1 -1
- package/lib/model-service/index.d.ts.map +1 -1
- package/lib/model-service/index.js +4 -5
- package/lib/model-service/index.js.map +1 -1
- package/lib/model-service/reference-candidate.d.ts +5 -3
- package/lib/model-service/reference-candidate.d.ts.map +1 -1
- package/lib/{model-service/args.js → node/index.d.ts} +2 -3
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +29 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/process-memory.d.ts +66 -0
- package/lib/node/process-memory.d.ts.map +1 -0
- package/lib/node/process-memory.js +291 -0
- package/lib/node/process-memory.js.map +1 -0
- package/lib/noop-logger.d.ts.map +1 -1
- package/lib/noop-logger.js.map +1 -1
- package/lib/observable-value.js.map +1 -1
- package/lib/patch-merge.d.ts +35 -32
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +67 -23
- package/lib/patch-merge.js.map +1 -1
- package/lib/profile-session.d.ts +8 -4
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js.map +1 -1
- package/lib/random-uuid.d.ts +14 -0
- package/lib/random-uuid.d.ts.map +1 -0
- package/lib/random-uuid.js +24 -0
- package/lib/random-uuid.js.map +1 -0
- package/lib/reconcile-write.d.ts +65 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +67 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/bind-rpc-methods.d.ts +33 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +32 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +10 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +12 -2
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/rpc/index.d.ts +1 -0
- package/lib/rpc/index.d.ts.map +1 -1
- package/lib/rpc/index.js +1 -0
- package/lib/rpc/index.js.map +1 -1
- package/lib/rpc/send-by-method-name.d.ts +76 -0
- package/lib/rpc/send-by-method-name.d.ts.map +1 -0
- package/lib/rpc/send-by-method-name.js +120 -0
- package/lib/rpc/send-by-method-name.js.map +1 -0
- package/lib/rpc/wire-prefix.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 +46 -15
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +58 -10
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +9 -1
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +54 -45
- package/lib/testing/fake-clock.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 +5 -2
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/node/duplex-connection.d.ts.map +1 -1
- package/lib/testing/node/duplex-connection.js +3 -2
- package/lib/testing/node/duplex-connection.js.map +1 -1
- package/lib/testing/node/duplex-stream.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +2 -2
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/message-port-pair.d.ts +25 -0
- package/lib/testing/node/message-port-pair.d.ts.map +1 -0
- package/lib/testing/node/message-port-pair.js +26 -0
- package/lib/testing/node/message-port-pair.js.map +1 -0
- package/lib/testing/wait-for.d.ts +3 -2
- package/lib/testing/wait-for.d.ts.map +1 -1
- package/lib/testing/wait-for.js +40 -10
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.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/lib/transfer-document.d.ts +70 -32
- package/lib/transfer-document.d.ts.map +1 -1
- package/lib/transfer-document.js +17 -9
- package/lib/transfer-document.js.map +1 -1
- package/lib/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -0
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -0
- package/lib/util.js.map +1 -1
- package/package.json +29 -37
- package/src/abstract-logger.ts +8 -0
- package/src/client/data-connection.ts +520 -0
- package/src/client/data-events.ts +33 -1
- package/src/client/data-port.ts +46 -28
- package/src/client/data-session.ts +951 -126
- package/src/client/index.ts +14 -9
- package/src/client/message-relay.ts +30 -8
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +281 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +56 -0
- package/src/console-logger.ts +39 -0
- package/src/data/data-protocol-methods.ts +13 -4
- package/src/data/data-server-protocol.ts +157 -41
- package/src/data/events.ts +123 -21
- package/src/data/requests.ts +74 -11
- package/src/errors.ts +322 -36
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +10 -0
- package/src/latency-collector.ts +8 -3
- package/src/logger.ts +28 -2
- package/src/messages/index.ts +37 -0
- package/src/messages/primitives.ts +271 -0
- package/src/model-server.ts +64 -19
- package/src/model-service/base-version.ts +72 -0
- package/src/model-service/index.ts +4 -5
- package/src/model-service/reference-candidate.ts +5 -3
- package/src/node/index.ts +14 -0
- package/src/node/process-memory.ts +299 -0
- package/src/patch-merge.ts +97 -42
- package/src/profile-session.ts +9 -4
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +124 -0
- package/src/rpc/README.md +4 -5
- package/src/rpc/bind-rpc-methods.ts +59 -4
- package/src/rpc/create-rpc-proxy.ts +20 -2
- package/src/rpc/index.ts +1 -0
- package/src/rpc/send-by-method-name.ts +140 -0
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +149 -25
- package/src/testing/fake-clock.ts +62 -47
- package/src/testing/index.ts +5 -2
- package/src/testing/node/duplex-connection.ts +3 -2
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/testing/wait-for.ts +38 -11
- package/src/transfer-diagnostic.ts +40 -0
- package/src/transfer-document.ts +87 -34
- package/src/util.ts +33 -0
- package/lib/model-service/args.d.ts +0 -64
- package/lib/model-service/args.d.ts.map +0 -1
- package/lib/model-service/args.js.map +0 -1
- package/src/model-service/args.ts +0 -67
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latency-collector.js","sourceRoot":"","sources":["../src/latency-collector.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"latency-collector.js","sourceRoot":"","sources":["../src/latency-collector.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;AAElF;;;;;;;;;GASG;AAEH,yCAAqE;AAwFrE,wEAAwE;AACxE,SAAS,UAAU,CAAC,eAAkC,EAAE,OAAe;IACpE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,CAAC;IACZ,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACjE,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,IAA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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"}
|
package/lib/logger.d.ts
CHANGED
|
@@ -74,7 +74,23 @@ export declare namespace Logger {
|
|
|
74
74
|
/** Read the current process-wide log threshold. */
|
|
75
75
|
function getLevel(): LogThreshold;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* Set the log file's own threshold, which {@link setLevel} does not move;
|
|
78
|
+
* `undefined` makes the file follow {@link getLevel}. A file sink compares
|
|
79
|
+
* against `getFileLevel() ?? getLevel()`, every other sink against
|
|
80
|
+
* {@link getLevel}.
|
|
81
|
+
*
|
|
82
|
+
* Set it through the file sink's own configuration, which clears it with
|
|
83
|
+
* the file: set here with no file configured, it widens
|
|
84
|
+
* {@link isLevelEnabled} for lines nothing writes.
|
|
85
|
+
*/
|
|
86
|
+
function setFileLevel(level: LogThreshold | undefined): void;
|
|
87
|
+
/** Read the log file's own threshold, `undefined` while it follows {@link getLevel}. */
|
|
88
|
+
function getFileLevel(): LogThreshold | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Whether any sink takes a message at `level`: the more verbose of
|
|
91
|
+
* {@link getLevel} and {@link getFileLevel} decides. A sink that admits less
|
|
92
|
+
* re-checks its own threshold before writing.
|
|
93
|
+
*
|
|
78
94
|
* Use to guard expensive log-line construction:
|
|
79
95
|
* `if (Logger.isLevelEnabled('trace')) logger.trace(buildPayload())`.
|
|
80
96
|
*/
|
|
@@ -105,6 +121,11 @@ export declare function parseLogLevel(value: unknown): LogThreshold | undefined;
|
|
|
105
121
|
export declare const DEFAULT_LOG_LEVEL_ENV = "HYDRANIUM_LOG_LEVEL";
|
|
106
122
|
/** Env var the server reads its log file-tee target from. See {@link DEFAULT_LOG_LEVEL_ENV}. */
|
|
107
123
|
export declare const DEFAULT_LOG_FILE_ENV = "HYDRANIUM_LOG_FILE";
|
|
124
|
+
/**
|
|
125
|
+
* Env var the server reads the file tee's own threshold from, which the LSP
|
|
126
|
+
* log-level setting does not change. See {@link Logger.setFileLevel}.
|
|
127
|
+
*/
|
|
128
|
+
export declare const DEFAULT_LOG_FILE_LEVEL_ENV = "HYDRANIUM_LOG_FILE_LEVEL";
|
|
108
129
|
/**
|
|
109
130
|
* Human-readable formatting helpers used in log lines and diagnostic output.
|
|
110
131
|
*/
|
package/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AACrE,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE5C,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAA8D,CAAC;AAEpH,uGAAuG;AACvG,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAMjD,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AACrE,MAAM,MAAM,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|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.Format = exports.DEFAULT_LOG_FILE_ENV = exports.DEFAULT_LOG_LEVEL_ENV = exports.Logger = exports.LEVEL_LABELS = exports.LEVEL_ORDER = void 0;
|
|
11
|
+
exports.Format = exports.DEFAULT_LOG_FILE_LEVEL_ENV = exports.DEFAULT_LOG_FILE_ENV = exports.DEFAULT_LOG_LEVEL_ENV = exports.Logger = exports.LEVEL_LABELS = exports.LEVEL_ORDER = void 0;
|
|
12
12
|
exports.isLogThreshold = isLogThreshold;
|
|
13
13
|
exports.parseLogLevel = parseLogLevel;
|
|
14
14
|
exports.LEVEL_ORDER = { off: 0, error: 1, warn: 2, info: 3, debug: 4, trace: 5 };
|
|
@@ -23,6 +23,7 @@ exports.LEVEL_LABELS = {
|
|
|
23
23
|
/** Module-global threshold; shared by every `AbstractLogger` instance so derived child
|
|
24
24
|
* loggers pick up live updates without each having to subscribe to a configuration source. */
|
|
25
25
|
let currentLevel = 'info';
|
|
26
|
+
let fileLevel;
|
|
26
27
|
/**
|
|
27
28
|
* Companion namespace for the {@link Logger} interface holding global
|
|
28
29
|
* threshold configuration.
|
|
@@ -46,12 +47,34 @@ var Logger;
|
|
|
46
47
|
}
|
|
47
48
|
Logger.getLevel = getLevel;
|
|
48
49
|
/**
|
|
49
|
-
*
|
|
50
|
+
* Set the log file's own threshold, which {@link setLevel} does not move;
|
|
51
|
+
* `undefined` makes the file follow {@link getLevel}. A file sink compares
|
|
52
|
+
* against `getFileLevel() ?? getLevel()`, every other sink against
|
|
53
|
+
* {@link getLevel}.
|
|
54
|
+
*
|
|
55
|
+
* Set it through the file sink's own configuration, which clears it with
|
|
56
|
+
* the file: set here with no file configured, it widens
|
|
57
|
+
* {@link isLevelEnabled} for lines nothing writes.
|
|
58
|
+
*/
|
|
59
|
+
function setFileLevel(level) {
|
|
60
|
+
fileLevel = level;
|
|
61
|
+
}
|
|
62
|
+
Logger.setFileLevel = setFileLevel;
|
|
63
|
+
/** Read the log file's own threshold, `undefined` while it follows {@link getLevel}. */
|
|
64
|
+
function getFileLevel() {
|
|
65
|
+
return fileLevel;
|
|
66
|
+
}
|
|
67
|
+
Logger.getFileLevel = getFileLevel;
|
|
68
|
+
/**
|
|
69
|
+
* Whether any sink takes a message at `level`: the more verbose of
|
|
70
|
+
* {@link getLevel} and {@link getFileLevel} decides. A sink that admits less
|
|
71
|
+
* re-checks its own threshold before writing.
|
|
72
|
+
*
|
|
50
73
|
* Use to guard expensive log-line construction:
|
|
51
74
|
* `if (Logger.isLevelEnabled('trace')) logger.trace(buildPayload())`.
|
|
52
75
|
*/
|
|
53
76
|
function isLevelEnabled(level) {
|
|
54
|
-
return exports.LEVEL_ORDER[level] <= exports.LEVEL_ORDER[currentLevel];
|
|
77
|
+
return exports.LEVEL_ORDER[level] <= Math.max(exports.LEVEL_ORDER[currentLevel], fileLevel ? exports.LEVEL_ORDER[fileLevel] : 0);
|
|
55
78
|
}
|
|
56
79
|
Logger.isLevelEnabled = isLevelEnabled;
|
|
57
80
|
/**
|
|
@@ -88,6 +111,11 @@ function parseLogLevel(value) {
|
|
|
88
111
|
exports.DEFAULT_LOG_LEVEL_ENV = 'HYDRANIUM_LOG_LEVEL';
|
|
89
112
|
/** Env var the server reads its log file-tee target from. See {@link DEFAULT_LOG_LEVEL_ENV}. */
|
|
90
113
|
exports.DEFAULT_LOG_FILE_ENV = 'HYDRANIUM_LOG_FILE';
|
|
114
|
+
/**
|
|
115
|
+
* Env var the server reads the file tee's own threshold from, which the LSP
|
|
116
|
+
* log-level setting does not change. See {@link Logger.setFileLevel}.
|
|
117
|
+
*/
|
|
118
|
+
exports.DEFAULT_LOG_FILE_LEVEL_ENV = 'HYDRANIUM_LOG_FILE_LEVEL';
|
|
91
119
|
/**
|
|
92
120
|
* Human-readable formatting helpers used in log lines and diagnostic output.
|
|
93
121
|
*/
|
package/lib/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;AAKrE,QAAA,WAAW,GAAiC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAEpH,uGAAuG;AAC1F,QAAA,YAAY,GAA6B;IACnD,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;CAChB,CAAC;AAEF;+FAC+F;AAC/F,IAAI,YAAY,GAAiB,MAAM,CAAC;AACxC,IAAI,SAAmC,CAAC;AAkDxC;;;;;;;;;GASG;AACH,IAAiB,MAAM,CA6CtB;AA7CD,WAAiB,MAAM;IACpB,qGAAqG;IACrG,SAAgB,QAAQ,CAAC,KAAmB;QACzC,YAAY,GAAG,KAAK,CAAC;IACxB,CAAC;IAFe,OAAA,QAAQ,WAEvB,CAAA;IACD,mDAAmD;IACnD,SAAgB,QAAQ;QACrB,OAAO,YAAY,CAAC;IACvB,CAAC;IAFe,OAAA,QAAQ,WAEvB,CAAA;IACD;;;;;;;;;OASG;IACH,SAAgB,YAAY,CAAC,KAA+B;QACzD,SAAS,GAAG,KAAK,CAAC;IACrB,CAAC;IAFe,OAAA,YAAY,eAE3B,CAAA;IACD,wFAAwF;IACxF,SAAgB,YAAY;QACzB,OAAO,SAAS,CAAC;IACpB,CAAC;IAFe,OAAA,YAAY,eAE3B,CAAA;IACD;;;;;;;OAOG;IACH,SAAgB,cAAc,CAAC,KAAe;QAC3C,OA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CAAC;QACD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;IACnF,CAAC;IAZe,OAAA,KAAK,QAYpB,CAAA;AACJ,CAAC,EA7BgB,MAAM,aAAN,MAAM,GAAN,MAAM,QA6BtB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { DOCUMENT_NOT_OPEN, DUPLICATE_CLIENT_ID, SESSION_CLOSED, STALE_BASE_VERSION_UPDATE } from '../errors';
|
|
26
|
+
export { DATA_CONNECTION_SESSION_RESTORE_FAILED, DATA_CONNECTION_WATCH_RESTORE_FAILED } from '../client/data-connection';
|
|
27
|
+
export { DATA_SERVER_CONNECT_FAILED, DATA_SERVER_NOT_READY } from '../client/rpc-connection';
|
|
28
|
+
export { DATA_SESSION_ANSWER_WITHOUT_MODEL, DATA_SESSION_RESTORE_FAILED, DATA_SESSION_UNSAVED_LOST } from '../client/data-session';
|
|
29
|
+
export { RELAY_REPLAY_FAILED, RELAY_TRANSPORT_OPEN_FAILED, RELAY_TRANSPORT_READ_FAILED, RELAY_TRANSPORT_WRITE_FAILED } from '../client/message-relay';
|
|
30
|
+
//# 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,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAC9G,OAAO,EAAE,sCAAsC,EAAE,oCAAoC,EAAE,MAAM,2BAA2B,CAAC;AACzH,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,iCAAiC,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnI,OAAO,EACJ,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC9B,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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_SESSION_ANSWER_WITHOUT_MODEL = exports.DATA_SERVER_NOT_READY = exports.DATA_SERVER_CONNECT_FAILED = exports.DATA_CONNECTION_WATCH_RESTORE_FAILED = exports.DATA_CONNECTION_SESSION_RESTORE_FAILED = exports.STALE_BASE_VERSION_UPDATE = exports.SESSION_CLOSED = exports.DUPLICATE_CLIENT_ID = exports.DOCUMENT_NOT_OPEN = 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, "DOCUMENT_NOT_OPEN", { enumerable: true, get: function () { return errors_1.DOCUMENT_NOT_OPEN; } });
|
|
44
|
+
Object.defineProperty(exports, "DUPLICATE_CLIENT_ID", { enumerable: true, get: function () { return errors_1.DUPLICATE_CLIENT_ID; } });
|
|
45
|
+
Object.defineProperty(exports, "SESSION_CLOSED", { enumerable: true, get: function () { return errors_1.SESSION_CLOSED; } });
|
|
46
|
+
Object.defineProperty(exports, "STALE_BASE_VERSION_UPDATE", { enumerable: true, get: function () { return errors_1.STALE_BASE_VERSION_UPDATE; } });
|
|
47
|
+
var data_connection_1 = require("../client/data-connection");
|
|
48
|
+
Object.defineProperty(exports, "DATA_CONNECTION_SESSION_RESTORE_FAILED", { enumerable: true, get: function () { return data_connection_1.DATA_CONNECTION_SESSION_RESTORE_FAILED; } });
|
|
49
|
+
Object.defineProperty(exports, "DATA_CONNECTION_WATCH_RESTORE_FAILED", { enumerable: true, get: function () { return data_connection_1.DATA_CONNECTION_WATCH_RESTORE_FAILED; } });
|
|
50
|
+
var rpc_connection_1 = require("../client/rpc-connection");
|
|
51
|
+
Object.defineProperty(exports, "DATA_SERVER_CONNECT_FAILED", { enumerable: true, get: function () { return rpc_connection_1.DATA_SERVER_CONNECT_FAILED; } });
|
|
52
|
+
Object.defineProperty(exports, "DATA_SERVER_NOT_READY", { enumerable: true, get: function () { return rpc_connection_1.DATA_SERVER_NOT_READY; } });
|
|
53
|
+
var data_session_1 = require("../client/data-session");
|
|
54
|
+
Object.defineProperty(exports, "DATA_SESSION_ANSWER_WITHOUT_MODEL", { enumerable: true, get: function () { return data_session_1.DATA_SESSION_ANSWER_WITHOUT_MODEL; } });
|
|
55
|
+
Object.defineProperty(exports, "DATA_SESSION_RESTORE_FAILED", { enumerable: true, get: function () { return data_session_1.DATA_SESSION_RESTORE_FAILED; } });
|
|
56
|
+
Object.defineProperty(exports, "DATA_SESSION_UNSAVED_LOST", { enumerable: true, get: function () { return data_session_1.DATA_SESSION_UNSAVED_LOST; } });
|
|
57
|
+
var message_relay_1 = require("../client/message-relay");
|
|
58
|
+
Object.defineProperty(exports, "RELAY_REPLAY_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_REPLAY_FAILED; } });
|
|
59
|
+
Object.defineProperty(exports, "RELAY_TRANSPORT_OPEN_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_OPEN_FAILED; } });
|
|
60
|
+
Object.defineProperty(exports, "RELAY_TRANSPORT_READ_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_READ_FAILED; } });
|
|
61
|
+
Object.defineProperty(exports, "RELAY_TRANSPORT_WRITE_FAILED", { enumerable: true, get: function () { return message_relay_1.RELAY_TRANSPORT_WRITE_FAILED; } });
|
|
62
|
+
//# 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,oCAA8G;AAArG,2GAAA,iBAAiB,OAAA;AAAE,6GAAA,mBAAmB,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,mHAAA,yBAAyB,OAAA;AAC1F,6DAAyH;AAAhH,yIAAA,sCAAsC,OAAA;AAAE,uIAAA,oCAAoC,OAAA;AACrF,2DAA6F;AAApF,4HAAA,0BAA0B,OAAA;AAAE,uHAAA,qBAAqB,OAAA;AAC1D,uDAAmI;AAA1H,iIAAA,iCAAiC,OAAA;AAAE,2HAAA,2BAA2B,OAAA;AAAE,yHAAA,yBAAyB,OAAA;AAClG,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 {};
|
|
188
|
+
//# 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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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,161 @@
|
|
|
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.MessageCatalogue = void 0;
|
|
12
|
+
exports.defineMessage = defineMessage;
|
|
13
|
+
exports.interpolate = interpolate;
|
|
14
|
+
exports.messageData = messageData;
|
|
15
|
+
exports.resolve = resolve;
|
|
16
|
+
exports.hasMessageIdentity = hasMessageIdentity;
|
|
17
|
+
exports.messageError = messageError;
|
|
18
|
+
exports.renderFrameworkMessage = renderFrameworkMessage;
|
|
19
|
+
exports.resolvedFromResponseError = resolvedFromResponseError;
|
|
20
|
+
exports.describeError = describeError;
|
|
21
|
+
exports.isMessageDeclaration = isMessageDeclaration;
|
|
22
|
+
exports.collectMessages = collectMessages;
|
|
23
|
+
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
24
|
+
/**
|
|
25
|
+
* Declare a message. Placeholder names are inferred from `text` rather than
|
|
26
|
+
* declared again in a type argument: a second spelling of every name is the
|
|
27
|
+
* repetition that drifts, since adding a placeholder to the sentence and not to
|
|
28
|
+
* the type compiles.
|
|
29
|
+
*/
|
|
30
|
+
function defineMessage(code, text) {
|
|
31
|
+
const literal = text;
|
|
32
|
+
return { code, text: literal, format: (...args) => interpolate(literal, args[0] ?? {}) };
|
|
33
|
+
}
|
|
34
|
+
const PLACEHOLDER = /\{([^}]+)\}/g;
|
|
35
|
+
/**
|
|
36
|
+
* Substitute `{name}` tokens, leaving an unfilled token in place.
|
|
37
|
+
*
|
|
38
|
+
* It must not throw. This runs over an adopter's translation as well as our own
|
|
39
|
+
* text, so a typo in a foreign catalogue has to degrade to a slightly wrong
|
|
40
|
+
* sentence rather than raise inside a toast render. Re-scanning the result to
|
|
41
|
+
* detect an unfilled token is what an earlier form did, and it cannot work:
|
|
42
|
+
* `String.replace` does not rescan replacement text, so the check could not tell
|
|
43
|
+
* an unfilled placeholder from user data shaped like one — an element literally
|
|
44
|
+
* named `{separator}` crashed at the authoring site.
|
|
45
|
+
*/
|
|
46
|
+
function interpolate(template, params) {
|
|
47
|
+
// Indexed rather than `key in params`: a hand-built or version-skewed
|
|
48
|
+
// identity can arrive with no params at all, and `in` throws on a non-object
|
|
49
|
+
// where a lookup degrades.
|
|
50
|
+
const lookup = params;
|
|
51
|
+
return template.replace(PLACEHOLDER, (match, key) => {
|
|
52
|
+
const value = lookup?.[key];
|
|
53
|
+
return value === undefined ? match : String(value);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function messageData(message, ...args) {
|
|
57
|
+
return { hydranium: { code: message.code, params: args[0] ?? {} } };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Identity plus resolved English, for a hand-off carrying a value rather than a
|
|
61
|
+
* protocol field. The result is structured-clone safe, so it survives a process
|
|
62
|
+
* hop where one intervenes and costs nothing where none does.
|
|
63
|
+
*/
|
|
64
|
+
function resolve(message, ...args) {
|
|
65
|
+
return { code: message.code, text: message.format(...args), params: args[0] ?? {} };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Validates every field {@link MessageIdentity} declares, `params` included.
|
|
69
|
+
* A guard over foreign input that checks only `code` while declaring `params`
|
|
70
|
+
* non-optional hands `undefined` to the renderer, which fails with the worst
|
|
71
|
+
* polarity available: invisible in English, crashing only once a translation is
|
|
72
|
+
* loaded.
|
|
73
|
+
*/
|
|
74
|
+
function hasMessageIdentity(data) {
|
|
75
|
+
if (typeof data !== 'object' || data === null || Array.isArray(data) || !('hydranium' in data)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const identity = data.hydranium;
|
|
79
|
+
if (typeof identity !== 'object' || identity === null || Array.isArray(identity)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const candidate = identity;
|
|
83
|
+
return typeof candidate.code === 'string' && typeof candidate.params === 'object' && candidate.params !== null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The numeric `code` and the message's catalogue code are unrelated and both are
|
|
87
|
+
* needed: `ResponseError.code` is an `integer`, so it cannot hold a
|
|
88
|
+
* `hydranium/…` key, and it is what a caller switches on after reconstruction.
|
|
89
|
+
*/
|
|
90
|
+
function messageError(code, message, ...params) {
|
|
91
|
+
return new vscode_jsonrpc_1.ResponseError(code, message.format(...params), messageData(message, ...params));
|
|
92
|
+
}
|
|
93
|
+
var MessageCatalogue;
|
|
94
|
+
(function (MessageCatalogue) {
|
|
95
|
+
/**
|
|
96
|
+
* One catalogue from several, for a renderer whose override supplies entries
|
|
97
|
+
* over the ones it inherits.
|
|
98
|
+
*
|
|
99
|
+
* **Later wins**, so a caller passes the inherited answer before its own.
|
|
100
|
+
*
|
|
101
|
+
* **No source at all answers `undefined`, not `{}`.** A renderer holds that
|
|
102
|
+
* answer as the locale having no catalogue and renders straight through; an
|
|
103
|
+
* empty object is a catalogue that misses every lookup, so returning one
|
|
104
|
+
* turns the opt-out into a per-message search that yields the same English.
|
|
105
|
+
*/
|
|
106
|
+
function merge(...catalogues) {
|
|
107
|
+
const present = catalogues.filter((catalogue) => catalogue !== undefined);
|
|
108
|
+
if (present.length <= 1) {
|
|
109
|
+
return present[0];
|
|
110
|
+
}
|
|
111
|
+
return Object.assign({}, ...present);
|
|
112
|
+
}
|
|
113
|
+
MessageCatalogue.merge = merge;
|
|
114
|
+
})(MessageCatalogue || (exports.MessageCatalogue = MessageCatalogue = {}));
|
|
115
|
+
/**
|
|
116
|
+
* Render on the side that knows the reading user's locale. Omitting
|
|
117
|
+
* `translations` is how an adopter without i18n opts out, and yields the
|
|
118
|
+
* English.
|
|
119
|
+
*/
|
|
120
|
+
function renderFrameworkMessage(message, translations) {
|
|
121
|
+
const template = translations?.[message.code];
|
|
122
|
+
return template ? interpolate(template, message.params) : message.text;
|
|
123
|
+
}
|
|
124
|
+
function resolvedFromResponseError(error) {
|
|
125
|
+
return hasMessageIdentity(error.data) ? { ...error.data.hydranium, text: error.message } : undefined;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The detail half of a `{detail}` placeholder. A technical error string is safe
|
|
129
|
+
* to pass as a parameter for the same reason a number is: it is not itself
|
|
130
|
+
* translatable text, so it needs no code of its own. A PROSE fragment is not,
|
|
131
|
+
* and must become one code per value instead.
|
|
132
|
+
*/
|
|
133
|
+
function describeError(error) {
|
|
134
|
+
return error instanceof Error ? error.message : String(error);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Recognises a declaration among a barrel's exports. The `format` check is what
|
|
138
|
+
* discriminates: a `code` + `text` pair alone admits any object that happens to
|
|
139
|
+
* carry both.
|
|
140
|
+
*/
|
|
141
|
+
function isMessageDeclaration(value) {
|
|
142
|
+
const candidate = value;
|
|
143
|
+
return (typeof candidate === 'object' &&
|
|
144
|
+
candidate !== null &&
|
|
145
|
+
typeof candidate.code === 'string' &&
|
|
146
|
+
typeof candidate.text === 'string' &&
|
|
147
|
+
typeof candidate.format === 'function');
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Every declaration a `./messages` barrel exports.
|
|
151
|
+
*
|
|
152
|
+
* A caller cannot get there with `Object.values(barrel).filter(isMessageDeclaration)`:
|
|
153
|
+
* a barrel's value type is a union of its declarations AND its functions, and
|
|
154
|
+
* `filter` will not narrow a function type down to a `MessageDefinition`, so the
|
|
155
|
+
* result stays the union and reading `.code` off it does not compile. Taking the
|
|
156
|
+
* barrel as an opaque object is what makes the one-liner work.
|
|
157
|
+
*/
|
|
158
|
+
function collectMessages(barrel) {
|
|
159
|
+
return Object.values(barrel).filter(isMessageDeclaration);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/messages/primitives.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;AAElF,mDAA+C;AAgD/C;;;;;GAKG;AACH,uBAAgD,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,qBAA4B,QAAgB,EAAE,MAAqB;IAChE,sEAAsE;IACtE,6EAA6E;IAC7E,2BAA2B;IAC3B,MAAM,MAAM,GAAG,MAAiE,CAAC;IACjF,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,GAAW,EAAE,EAAE;QACzD,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACN,CAAC;AAoBD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