@hydranium/protocol 1.0.0-next.32 → 1.0.0-next.320
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 -83
- 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 +302 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +533 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +17 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +25 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +34 -24
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +657 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1113 -115
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +15 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +15 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +4 -4
- package/lib/client/message-relay.js +4 -4
- 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/worker-handshake.d.ts +86 -0
- package/lib/client/worker-handshake.d.ts.map +1 -0
- package/lib/client/worker-handshake.js +51 -0
- package/lib/client/worker-handshake.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 +50 -10
- 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 +13 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +165 -48
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +137 -21
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +71 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts +3 -3
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js +6 -9
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +183 -30
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +268 -32
- 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 +8 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -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 +38 -7
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +42 -4
- package/lib/logger.js.map +1 -1
- package/lib/messages/index.d.ts +4 -2
- package/lib/messages/index.d.ts.map +1 -1
- package/lib/messages/index.js +15 -4
- package/lib/messages/index.js.map +1 -1
- package/lib/messages/primitives.d.ts +59 -4
- package/lib/messages/primitives.d.ts.map +1 -1
- package/lib/messages/primitives.js +55 -3
- package/lib/messages/primitives.js.map +1 -1
- 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 +67 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/base-version.js +44 -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/node/index.d.ts +10 -0
- 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 +63 -35
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +171 -25
- 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/project.d.ts +4 -1
- package/lib/project.d.ts.map +1 -1
- package/lib/project.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 +67 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +69 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/bind-rpc-methods.d.ts +6 -2
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +17 -7
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +3 -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/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/save-text-document.d.ts +40 -0
- package/lib/save-text-document.d.ts.map +1 -0
- package/lib/save-text-document.js +34 -0
- package/lib/save-text-document.js.map +1 -0
- package/lib/testing/catalogue-audit.d.ts +1 -1
- package/lib/testing/catalogue-audit.js +1 -1
- package/lib/testing/catalogue-audit.js.map +1 -1
- package/lib/testing/data-doubles.d.ts +41 -12
- package/lib/testing/data-doubles.d.ts.map +1 -1
- package/lib/testing/data-doubles.js +56 -8
- package/lib/testing/data-doubles.js.map +1 -1
- package/lib/testing/fake-clock.d.ts +17 -2
- package/lib/testing/fake-clock.d.ts.map +1 -1
- package/lib/testing/fake-clock.js +61 -46
- 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 +4 -3
- 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/transfer-node-builder.d.ts +81 -0
- package/lib/testing/transfer-node-builder.d.ts.map +1 -0
- package/lib/testing/transfer-node-builder.js +47 -0
- package/lib/testing/transfer-node-builder.js.map +1 -0
- package/lib/testing/wait-for.d.ts +9 -3
- package/lib/testing/wait-for.d.ts.map +1 -1
- package/lib/testing/wait-for.js +57 -11
- package/lib/testing/wait-for.js.map +1 -1
- package/lib/tracer.d.ts.map +1 -1
- package/lib/tracer.js +5 -9
- package/lib/tracer.js.map +1 -1
- package/lib/transfer-diagnostic.js.map +1 -1
- package/lib/transfer-document.d.ts +95 -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/transfer-element.d.ts +4 -4
- package/lib/types.d.ts +32 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/{model-service/args.js → types.js} +2 -2
- package/lib/types.js.map +1 -0
- package/lib/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -2
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -4
- package/lib/util.js.map +1 -1
- package/package.json +24 -40
- package/src/abstract-logger.ts +8 -0
- package/src/client/data-connection.ts +653 -0
- package/src/client/data-events.ts +37 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1427 -137
- package/src/client/index.ts +15 -9
- package/src/client/message-relay.ts +4 -4
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +281 -0
- package/src/client/worker-handshake.ts +113 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +68 -10
- package/src/console-logger.ts +39 -0
- package/src/data/data-protocol-methods.ts +14 -4
- package/src/data/data-server-protocol.ts +192 -48
- package/src/data/events.ts +143 -21
- package/src/data/requests.ts +77 -11
- package/src/debouncer.ts +7 -10
- package/src/errors.ts +326 -40
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +8 -0
- package/src/latency-collector.ts +8 -3
- package/src/logger.ts +44 -8
- package/src/messages/index.ts +4 -2
- package/src/messages/primitives.ts +90 -4
- package/src/model-server.ts +64 -19
- package/src/model-service/base-version.ts +75 -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 +230 -45
- package/src/profile-session.ts +9 -4
- package/src/project.ts +4 -1
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +128 -0
- package/src/rpc/README.md +6 -6
- package/src/rpc/bind-rpc-methods.ts +18 -8
- package/src/rpc/create-rpc-proxy.ts +6 -1
- package/src/rpc/index.ts +1 -0
- package/src/rpc/send-by-method-name.ts +140 -0
- package/src/save-text-document.ts +39 -0
- package/src/testing/catalogue-audit.ts +1 -1
- package/src/testing/data-doubles.ts +141 -19
- package/src/testing/fake-clock.ts +76 -48
- package/src/testing/index.ts +4 -3
- 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/transfer-node-builder.ts +107 -0
- package/src/testing/wait-for.ts +61 -13
- package/src/tracer.ts +5 -9
- package/src/transfer-document.ts +115 -34
- package/src/transfer-element.ts +4 -4
- package/src/types.ts +30 -0
- package/src/util.ts +33 -6
- 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
|
@@ -10,12 +10,21 @@
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.bindRpcMethods = bindRpcMethods;
|
|
12
12
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
13
|
+
const errors_1 = require("../errors");
|
|
13
14
|
const util_1 = require("../util");
|
|
14
15
|
const create_rpc_proxy_1 = require("./create-rpc-proxy");
|
|
15
16
|
const wire_prefix_1 = require("./wire-prefix");
|
|
16
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* The rejection to throw in place of `err`. A `ResponseError` from another copy
|
|
19
|
+
* of `vscode-jsonrpc` is rebuilt on this package's, since a connection keeps the
|
|
20
|
+
* code only of its own copy's errors; one from this copy is thrown as is, so a
|
|
21
|
+
* subclass keeps its `toJson`, unless `render` rewrites its message.
|
|
22
|
+
*/
|
|
17
23
|
function renderRejection(err, render) {
|
|
18
|
-
|
|
24
|
+
if (!(0, errors_1.isResponseError)(err) || (!render && err instanceof vscode_jsonrpc_1.ResponseError)) {
|
|
25
|
+
return err;
|
|
26
|
+
}
|
|
27
|
+
return new vscode_jsonrpc_1.ResponseError(err.code, render ? render(err) : err.message, err.data);
|
|
19
28
|
}
|
|
20
29
|
/**
|
|
21
30
|
* Register each named method on `target` as a handler on `connection`
|
|
@@ -36,8 +45,12 @@ function renderRejection(err, render) {
|
|
|
36
45
|
*
|
|
37
46
|
* Errors thrown synchronously from a request handler — or surfaced as a
|
|
38
47
|
* rejected promise — propagate back to the caller through vscode-jsonrpc's
|
|
39
|
-
* standard error envelope,
|
|
40
|
-
* {@link BindRpcMethodsOptions.renderErrorMessage} is supplied.
|
|
48
|
+
* standard error envelope, its message rendered when
|
|
49
|
+
* {@link BindRpcMethodsOptions.renderErrorMessage} is supplied. A
|
|
50
|
+
* `ResponseError` from another copy of `vscode-jsonrpc` is rebuilt on this
|
|
51
|
+
* package's copy, so its code and data reach the caller when `connection` comes
|
|
52
|
+
* from that copy too, as the framework's own connections do; over a connection
|
|
53
|
+
* from another copy the caller receives a generic `InternalError`. Errors from a
|
|
41
54
|
* notification handler cannot propagate, and are routed to
|
|
42
55
|
* {@link BindRpcMethodsOptions.onNotificationError} instead.
|
|
43
56
|
*
|
|
@@ -93,9 +106,6 @@ function bindRpcMethods(connection, target, methodNames, options = {}) {
|
|
|
93
106
|
else {
|
|
94
107
|
const render = options.renderErrorMessage;
|
|
95
108
|
disposables.push(resolved.onRequest(wireName, async (params) => {
|
|
96
|
-
if (!render) {
|
|
97
|
-
return dispatch(params);
|
|
98
|
-
}
|
|
99
109
|
try {
|
|
100
110
|
// Awaited inside the try, or a rejected promise escapes it.
|
|
101
111
|
return await dispatch(params);
|
|
@@ -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;;;AAElF,mDAAuE;AACvE,sCAA4C;AAE5C,kCAAgE;AAChE,yDAA2D;AAC3D,+CAA2D;AAsF3D;;;;;GAKG;AACH,SAAS,eAAe,CAAC,GAAY,EAAE,MAAkD;IACtF,IAAI,CAAC,IAAA,wBAAe,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,YAAY,8BAAa,CAAC,EAAE,CAAC;QACtE,OAAO,GAAG,CAAC;IACd,CAAC;IACD,OAAO,IAAI,8BAAa,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;AACpF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBACG,UAA0D,EAC1D,MAAS,EACT,WA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IAAI,CAAC;YACjB,WAAW,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;KACH,CAAC;AACL,CAAC"}
|
|
@@ -169,6 +169,9 @@ export declare function defaultIsNotification(methodName: string): boolean;
|
|
|
169
169
|
* params, results and errors, and a second layer here would double every
|
|
170
170
|
* traced line.
|
|
171
171
|
*
|
|
172
|
+
* A rejection whose code names one of the framework's typed errors is rethrown
|
|
173
|
+
* as that class, through {@link reviveProtocolError}.
|
|
174
|
+
*
|
|
172
175
|
* Accepts either a ready connection or a `Promise<MessageConnection>` —
|
|
173
176
|
* proxy methods called before the promise resolves queue until it does,
|
|
174
177
|
* then dispatch, so adopters can wire the proxy before its underlying
|
|
@@ -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;
|
|
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;AAE7E,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;AACH,MAAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,MAAM,GAAG,KAAK;IACjE;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;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,CAgFb"}
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.defaultIsNotification = defaultIsNotification;
|
|
12
12
|
exports.createRpcProxy = createRpcProxy;
|
|
13
13
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
14
|
+
const errors_1 = require("../errors");
|
|
14
15
|
const bind_rpc_methods_1 = require("./bind-rpc-methods");
|
|
15
16
|
const wire_prefix_1 = require("./wire-prefix");
|
|
16
17
|
/**
|
|
@@ -61,6 +62,9 @@ function assertSingleArg(wireName, args) {
|
|
|
61
62
|
* params, results and errors, and a second layer here would double every
|
|
62
63
|
* traced line.
|
|
63
64
|
*
|
|
65
|
+
* A rejection whose code names one of the framework's typed errors is rethrown
|
|
66
|
+
* as that class, through {@link reviveProtocolError}.
|
|
67
|
+
*
|
|
64
68
|
* Accepts either a ready connection or a `Promise<MessageConnection>` —
|
|
65
69
|
* proxy methods called before the promise resolves queue until it does,
|
|
66
70
|
* then dispatch, so adopters can wire the proxy before its underlying
|
|
@@ -150,7 +154,8 @@ function createRpcProxy(connection, options = {}) {
|
|
|
150
154
|
const capturedError = new Error(`RPC request '${wireName}' failed`);
|
|
151
155
|
return resolvedConnection
|
|
152
156
|
.then(connection => connection.sendRequest(wireName, args[0]))
|
|
153
|
-
.catch((
|
|
157
|
+
.catch((rejection) => {
|
|
158
|
+
const err = (0, errors_1.reviveProtocolError)(rejection);
|
|
154
159
|
if (err instanceof Error && capturedError.stack) {
|
|
155
160
|
err.stack = `${err.stack ?? err.message}\nCaused by request from:\n${capturedError.stack}`;
|
|
156
161
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-rpc-proxy.js","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"create-rpc-proxy.js","sourceRoot":"","sources":["../../src/rpc/create-rpc-proxy.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;AAElF,mDAA6E;AAC7E,sCAAgD;AAChD,yDAAgF;AAChF,+CAA2D;AAyI3D;;;;;;;;;;;;;;;GAeG;AACH,+BAAsC,UAAkB;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED;;;;;GAKG;A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C,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;gBACrH,CAAC,CAAC;YACL,CAAC;YACD,OAAO,CAAC,GAAG,IAAe,EAAoB,EAAE;gBAC7C,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;gBAChC,qEAAqE;gBACrE,qEAAqE;gBACrE,sEAAsE;gBACtE,kEAAkE;gBAClE,4DAA4D;gBAC5D,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,gBAAgB,QAAQ,UAAU,CAAC,CAAC;gBACpE,OAAO,kBAAkB;qBACrB,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;qBAC7D,KAAK,CAAC,CAAC,SAAkB,EAAE,EAAE;oBAC3B,MAAM,GAAG,GAAG,IAAA,4BAAmB,EAAC,SAAS,CAAC,CAAC;oBAC3C,IAAI,GAAG,YAAY,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;wBAC/C,GAAG,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,8BAA8B,aAAa,CAAC,KAAK,EAAE,CAAC;oBAC9F,CAAC;oBACD,MAAM,GAAG,CAAC;gBACb,CAAC,CAAC,CAAC;YACT,CAAC,CAAC;QACL,CAAC;KACH,CAAgB,CAAC;AACrB,CAAC"}
|
package/lib/rpc/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
export * from './bind-rpc-methods';
|
|
10
10
|
export * from './create-rpc-proxy';
|
|
11
|
+
export * from './send-by-method-name';
|
|
11
12
|
export * from './wire-prefix';
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/rpc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAMlF,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAMlF,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC"}
|
package/lib/rpc/index.js
CHANGED
|
@@ -27,5 +27,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
// specialised composition.
|
|
28
28
|
__exportStar(require("./bind-rpc-methods"), exports);
|
|
29
29
|
__exportStar(require("./create-rpc-proxy"), exports);
|
|
30
|
+
__exportStar(require("./send-by-method-name"), exports);
|
|
30
31
|
__exportStar(require("./wire-prefix"), exports);
|
|
31
32
|
//# sourceMappingURL=index.js.map
|
package/lib/rpc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,kEAAkE;AAClE,+DAA+D;AAC/D,2BAA2B;AAE3B,qDAAmC;AACnC,qDAAmC;AACnC,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,kEAAkE;AAClE,+DAA+D;AAC/D,2BAA2B;AAE3B,qDAAmC;AACnC,qDAAmC;AACnC,wDAAsC;AACtC,gDAA8B"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
/**
|
|
10
|
+
* `connection` with `sendRequest` and `sendNotification` sending a typed message
|
|
11
|
+
* by its method name, so it survives a message type built by another copy of
|
|
12
|
+
* `vscode-jsonrpc`. Wrap a connection wherever it is handed to code that sends
|
|
13
|
+
* another copy's typed messages, GLSP's clients and launchers in particular.
|
|
14
|
+
*
|
|
15
|
+
* **Why an install holds several copies.** Upstream pins exactly:
|
|
16
|
+
* - `@eclipse-glsp/*` 2.x pin `vscode-jsonrpc` `8.2.0`, and npm can nest a copy
|
|
17
|
+
* under each GLSP package, so GLSP's packages can split from each other: a
|
|
18
|
+
* connection one of them creates rejects the typed messages another builds.
|
|
19
|
+
* GLSP's upgrade to 9.x, which could let it share the framework's copy, is
|
|
20
|
+
* open as https://github.com/eclipse-glsp/glsp/issues/1720.
|
|
21
|
+
* - `vscode-languageserver@10.0.1` pins `vscode-languageserver-protocol`
|
|
22
|
+
* `3.18.1`, which pins `vscode-jsonrpc` `9.0.0`.
|
|
23
|
+
* - Theia brings protocol `3.17.5` and with it `vscode-jsonrpc` 8.
|
|
24
|
+
*
|
|
25
|
+
* npm hoists one version per name and nests the rest. `overrides` are read from
|
|
26
|
+
* the root manifest alone and never ship with a package, so the framework cannot
|
|
27
|
+
* collapse an adopter's tree.
|
|
28
|
+
*
|
|
29
|
+
* **What breaks across copies.**
|
|
30
|
+
* - Sending: a connection compares a typed message's parameter structure with
|
|
31
|
+
* its own copy's `ParameterStructures.auto` singleton by identity, so a
|
|
32
|
+
* `RequestType` or `NotificationType` built by another copy throws
|
|
33
|
+
* `Unknown parameter structure auto`. GLSP sends typed messages, in
|
|
34
|
+
* `BaseJsonrpcGLSPClient` and in `JsonrpcClientProxy.process`.
|
|
35
|
+
* `vscode-languageserver`'s connection resends by method name already, which
|
|
36
|
+
* is why LSP sends are unaffected.
|
|
37
|
+
* - Types: `ParameterStructures` has a private member, so TypeScript treats each
|
|
38
|
+
* copy's `MessageConnection` as a different type.
|
|
39
|
+
* - Errors: a connection keeps a thrown `ResponseError`'s code and data only
|
|
40
|
+
* when the error is an instance of its own copy's class, and sends a returned
|
|
41
|
+
* one of another copy as a successful result.
|
|
42
|
+
*
|
|
43
|
+
* **What is copy-safe.** Receiving a typed message from another copy, since the
|
|
44
|
+
* receive path compares only against its own `byName` and `byPosition`. With
|
|
45
|
+
* sends by method name, the LSP, data and GLSP heads run over a tree whose GLSP
|
|
46
|
+
* packages keep `vscode-jsonrpc` `8.2.0`.
|
|
47
|
+
*
|
|
48
|
+
* **How it works.** A `Proxy` whose `sendRequest` and `sendNotification` pass the
|
|
49
|
+
* typed message's `method` string; every other member is the connection's own.
|
|
50
|
+
* The parameters go out as the typed send packs them: the first
|
|
51
|
+
* `numberOfParams`, missing ones `null`, and a request's cancellation token
|
|
52
|
+
* from the position after them. Sent by method name, a single parameter goes by
|
|
53
|
+
* name when it is an object and by position otherwise, which matches `auto` and
|
|
54
|
+
* `byName` with an object, as `vscode-languageserver-protocol`'s types use it. A
|
|
55
|
+
* `byPosition` object or a `byName` non-object throws rather than going out in
|
|
56
|
+
* another shape, the packing read from the type's `toString()` since it cannot
|
|
57
|
+
* be compared by identity. So wrapping narrows what a connection accepts: its
|
|
58
|
+
* own copy sends such a type unwrapped. The result is typed as whichever copy's
|
|
59
|
+
* connection its context expects, or as `connection`'s own type without one.
|
|
60
|
+
* That type is the caller's assertion: it holds for the members both copies
|
|
61
|
+
* share, since the sends go by name and the receives are copy-safe.
|
|
62
|
+
*
|
|
63
|
+
* **Where it stops.** Errors: a rejection it produces is still its own copy's
|
|
64
|
+
* `ResponseError`, so recognise errors with `isResponseError`, and build a
|
|
65
|
+
* connection whose errors must keep their code from the framework's copy.
|
|
66
|
+
*
|
|
67
|
+
* See https://github.com/eclipse-emfcloud/hydranium/issues/279.
|
|
68
|
+
*/
|
|
69
|
+
export declare function sendByMethodName<In extends {
|
|
70
|
+
sendRequest<R>(method: string, ...params: unknown[]): Promise<R>;
|
|
71
|
+
sendNotification(method: string, ...params: unknown[]): Promise<void>;
|
|
72
|
+
}, Out extends {
|
|
73
|
+
sendRequest<R>(method: string, ...params: unknown[]): Promise<R>;
|
|
74
|
+
sendNotification(method: string, ...params: unknown[]): Promise<void>;
|
|
75
|
+
} = In>(connection: In): Out;
|
|
76
|
+
//# sourceMappingURL=send-by-method-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-by-method-name.d.ts","sourceRoot":"","sources":["../../src/rpc/send-by-method-name.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAgB,gBAAgB,CAC7B,EAAE,SAAS;IACR,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjE,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE,EACD,GAAG,SAAS;IACT,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjE,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE,GAAG,EAAE,EACP,UAAU,EAAE,EAAE,GAAG,GAAG,CAsBrB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 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.sendByMethodName = sendByMethodName;
|
|
12
|
+
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
13
|
+
/**
|
|
14
|
+
* `connection` with `sendRequest` and `sendNotification` sending a typed message
|
|
15
|
+
* by its method name, so it survives a message type built by another copy of
|
|
16
|
+
* `vscode-jsonrpc`. Wrap a connection wherever it is handed to code that sends
|
|
17
|
+
* another copy's typed messages, GLSP's clients and launchers in particular.
|
|
18
|
+
*
|
|
19
|
+
* **Why an install holds several copies.** Upstream pins exactly:
|
|
20
|
+
* - `@eclipse-glsp/*` 2.x pin `vscode-jsonrpc` `8.2.0`, and npm can nest a copy
|
|
21
|
+
* under each GLSP package, so GLSP's packages can split from each other: a
|
|
22
|
+
* connection one of them creates rejects the typed messages another builds.
|
|
23
|
+
* GLSP's upgrade to 9.x, which could let it share the framework's copy, is
|
|
24
|
+
* open as https://github.com/eclipse-glsp/glsp/issues/1720.
|
|
25
|
+
* - `vscode-languageserver@10.0.1` pins `vscode-languageserver-protocol`
|
|
26
|
+
* `3.18.1`, which pins `vscode-jsonrpc` `9.0.0`.
|
|
27
|
+
* - Theia brings protocol `3.17.5` and with it `vscode-jsonrpc` 8.
|
|
28
|
+
*
|
|
29
|
+
* npm hoists one version per name and nests the rest. `overrides` are read from
|
|
30
|
+
* the root manifest alone and never ship with a package, so the framework cannot
|
|
31
|
+
* collapse an adopter's tree.
|
|
32
|
+
*
|
|
33
|
+
* **What breaks across copies.**
|
|
34
|
+
* - Sending: a connection compares a typed message's parameter structure with
|
|
35
|
+
* its own copy's `ParameterStructures.auto` singleton by identity, so a
|
|
36
|
+
* `RequestType` or `NotificationType` built by another copy throws
|
|
37
|
+
* `Unknown parameter structure auto`. GLSP sends typed messages, in
|
|
38
|
+
* `BaseJsonrpcGLSPClient` and in `JsonrpcClientProxy.process`.
|
|
39
|
+
* `vscode-languageserver`'s connection resends by method name already, which
|
|
40
|
+
* is why LSP sends are unaffected.
|
|
41
|
+
* - Types: `ParameterStructures` has a private member, so TypeScript treats each
|
|
42
|
+
* copy's `MessageConnection` as a different type.
|
|
43
|
+
* - Errors: a connection keeps a thrown `ResponseError`'s code and data only
|
|
44
|
+
* when the error is an instance of its own copy's class, and sends a returned
|
|
45
|
+
* one of another copy as a successful result.
|
|
46
|
+
*
|
|
47
|
+
* **What is copy-safe.** Receiving a typed message from another copy, since the
|
|
48
|
+
* receive path compares only against its own `byName` and `byPosition`. With
|
|
49
|
+
* sends by method name, the LSP, data and GLSP heads run over a tree whose GLSP
|
|
50
|
+
* packages keep `vscode-jsonrpc` `8.2.0`.
|
|
51
|
+
*
|
|
52
|
+
* **How it works.** A `Proxy` whose `sendRequest` and `sendNotification` pass the
|
|
53
|
+
* typed message's `method` string; every other member is the connection's own.
|
|
54
|
+
* The parameters go out as the typed send packs them: the first
|
|
55
|
+
* `numberOfParams`, missing ones `null`, and a request's cancellation token
|
|
56
|
+
* from the position after them. Sent by method name, a single parameter goes by
|
|
57
|
+
* name when it is an object and by position otherwise, which matches `auto` and
|
|
58
|
+
* `byName` with an object, as `vscode-languageserver-protocol`'s types use it. A
|
|
59
|
+
* `byPosition` object or a `byName` non-object throws rather than going out in
|
|
60
|
+
* another shape, the packing read from the type's `toString()` since it cannot
|
|
61
|
+
* be compared by identity. So wrapping narrows what a connection accepts: its
|
|
62
|
+
* own copy sends such a type unwrapped. The result is typed as whichever copy's
|
|
63
|
+
* connection its context expects, or as `connection`'s own type without one.
|
|
64
|
+
* That type is the caller's assertion: it holds for the members both copies
|
|
65
|
+
* share, since the sends go by name and the receives are copy-safe.
|
|
66
|
+
*
|
|
67
|
+
* **Where it stops.** Errors: a rejection it produces is still its own copy's
|
|
68
|
+
* `ResponseError`, so recognise errors with `isResponseError`, and build a
|
|
69
|
+
* connection whose errors must keep their code from the framework's copy.
|
|
70
|
+
*
|
|
71
|
+
* See https://github.com/eclipse-emfcloud/hydranium/issues/279.
|
|
72
|
+
*/
|
|
73
|
+
function sendByMethodName(connection) {
|
|
74
|
+
const sendRequest = (type, ...params) => typeof type === 'string'
|
|
75
|
+
? connection.sendRequest(type, ...params)
|
|
76
|
+
: connection.sendRequest(type.method, ...argsOf(type, params, true));
|
|
77
|
+
const sendNotification = (type, ...params) => typeof type === 'string'
|
|
78
|
+
? connection.sendNotification(type, ...params)
|
|
79
|
+
: connection.sendNotification(type.method, ...argsOf(type, params, false));
|
|
80
|
+
const wrapped = new Proxy(connection, {
|
|
81
|
+
get(target, property, receiver) {
|
|
82
|
+
if (property === 'sendRequest') {
|
|
83
|
+
return sendRequest;
|
|
84
|
+
}
|
|
85
|
+
if (property === 'sendNotification') {
|
|
86
|
+
return sendNotification;
|
|
87
|
+
}
|
|
88
|
+
return Reflect.get(target, property, receiver);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
// Typed as the connection its context expects, which the doc above justifies.
|
|
92
|
+
return wrapped;
|
|
93
|
+
}
|
|
94
|
+
/** Whether `vscode-jsonrpc` sends `param` by name under `auto`. */
|
|
95
|
+
function isNamedParam(param) {
|
|
96
|
+
return param !== undefined && param !== null && !Array.isArray(param) && typeof param === 'object';
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The arguments that send `type` by method name with the typed send's params:
|
|
100
|
+
* the first `numberOfParams` of `params`, missing ones `null`, then a request's
|
|
101
|
+
* cancellation token, which the typed send takes from that position. A request
|
|
102
|
+
* always ends in a token, `CancellationToken.None` when it has none, since a
|
|
103
|
+
* send by method name takes a token-shaped last argument for its token. Throws
|
|
104
|
+
* for the one-parameter packing a send by method name cannot express.
|
|
105
|
+
*/
|
|
106
|
+
function argsOf(type, params, isRequest) {
|
|
107
|
+
const args = Array.from({ length: type.numberOfParams }, (_, i) => (i < params.length ? params[i] : null));
|
|
108
|
+
if (type.numberOfParams === 1) {
|
|
109
|
+
const packing = String(type.parameterStructures);
|
|
110
|
+
if ((packing === 'byPosition' && isNamedParam(args[0])) || (packing === 'byName' && !isNamedParam(args[0]))) {
|
|
111
|
+
throw new Error(`sendByMethodName cannot send '${type.method}' ${packing}: by method name, a single object goes by name and anything else by position.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (!isRequest) {
|
|
115
|
+
return args;
|
|
116
|
+
}
|
|
117
|
+
const token = params[type.numberOfParams];
|
|
118
|
+
return [...args, vscode_jsonrpc_1.CancellationToken.is(token) ? token : vscode_jsonrpc_1.CancellationToken.None];
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=send-by-method-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-by-method-name.js","sourceRoot":"","sources":["../../src/rpc/send-by-method-name.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,0BASE,UAAc;IACb,MAAM,WAAW,GAAG,CAAC,IAA2B,EAAE,GAAG,MAAiB,EAAE,EAAE,CACvE,OAAO,IAAI,KAAK,QAAQ;QACrB,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC;QACzC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAC3E,MAAM,gBAAgB,GAAG,CAAC,IAA2B,EAAE,GAAG,MAAiB,EAAE,EAAE,CAC5E,OAAO,IAAI,KAAK,QAAQ;QACrB,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,EAAE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AC,CAAC;QACjD,IAAI,CAAC,OAAO,KAAK,YAAY,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3G,MAAM,IAAI,KAAK,CACZ,iCAAiC,IAAI,CAAC,MAAM,KAAK,OAAO,+EAA+E,CACzI,CAAC;QACL,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,SAAS,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,IAAI,EAAE,kCAAiB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,kCAAiB,CAAC,IAAI,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-prefix.js","sourceRoot":"","sources":["../../src/rpc/wire-prefix.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"wire-prefix.js","sourceRoot":"","sources":["../../src/rpc/wire-prefix.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,oCAA2C,eAAuB,EAAE,MAAc;IAC/E,IAAI,eAAe,KAAK,EAAE,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3D,OAAO;IACV,CAAC;IACD,MAAM,IAAI,SAAS,CAChB,GAAG,MAAM,sBAAsB,eAAe,qCAAqC;QAChF,qFAAqF;QACrF,yDAAyD,eAAe,cAAc;QACtF,6CAA6C,eAAe,gBAAgB;QAC5E,gBAAgB,eAAe,2CAA2C,CAC/E,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import { RequestType } from 'vscode-jsonrpc';
|
|
10
|
+
/**
|
|
11
|
+
* LSP's `VersionedTextDocumentIdentifier`, declared field by field: this
|
|
12
|
+
* package carries no LSP dependency, and the fields are LSP's own.
|
|
13
|
+
*/
|
|
14
|
+
export interface SaveTextDocumentParams {
|
|
15
|
+
readonly textDocument: {
|
|
16
|
+
readonly uri: string;
|
|
17
|
+
readonly version: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Ask the LSP head to persist the text it holds for a document, which it
|
|
22
|
+
* answers with `null` once the text is written. LSP itself has none: its
|
|
23
|
+
* `didSave` reports a write the editor made, so a host whose files only the
|
|
24
|
+
* server holds saves through this.
|
|
25
|
+
*
|
|
26
|
+
* It travels the connection the `didChange`s travel, so it arrives after
|
|
27
|
+
* them. The server refuses it with a `ConflictError` unless the version is the
|
|
28
|
+
* one the editor last declared and its buffer holds the server's current
|
|
29
|
+
* text, which a `workspace/applyEdit` still in flight breaks.
|
|
30
|
+
*
|
|
31
|
+
* A server that answers it advertises it as
|
|
32
|
+
* `ServerCapabilities.experimental[SaveTextDocumentRequest.method] = true`;
|
|
33
|
+
* a client checks that before sending, since a server without a handler
|
|
34
|
+
* answers `MethodNotFound`.
|
|
35
|
+
*/
|
|
36
|
+
export declare namespace SaveTextDocumentRequest {
|
|
37
|
+
const method = "hydranium/saveTextDocument";
|
|
38
|
+
const type: RequestType<SaveTextDocumentParams, null, void>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=save-text-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-text-document.d.ts","sourceRoot":"","sources":["../src/save-text-document.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACpC,QAAQ,CAAC,YAAY,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,yBAAiB,uBAAuB,CAAC;IAC/B,MAAM,MAAM,+BAA+B,CAAC;IAC5C,MAAM,IAAI,iDAA8D,CAAC;CAClF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 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.SaveTextDocumentRequest = void 0;
|
|
12
|
+
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
13
|
+
/**
|
|
14
|
+
* Ask the LSP head to persist the text it holds for a document, which it
|
|
15
|
+
* answers with `null` once the text is written. LSP itself has none: its
|
|
16
|
+
* `didSave` reports a write the editor made, so a host whose files only the
|
|
17
|
+
* server holds saves through this.
|
|
18
|
+
*
|
|
19
|
+
* It travels the connection the `didChange`s travel, so it arrives after
|
|
20
|
+
* them. The server refuses it with a `ConflictError` unless the version is the
|
|
21
|
+
* one the editor last declared and its buffer holds the server's current
|
|
22
|
+
* text, which a `workspace/applyEdit` still in flight breaks.
|
|
23
|
+
*
|
|
24
|
+
* A server that answers it advertises it as
|
|
25
|
+
* `ServerCapabilities.experimental[SaveTextDocumentRequest.method] = true`;
|
|
26
|
+
* a client checks that before sending, since a server without a handler
|
|
27
|
+
* answers `MethodNotFound`.
|
|
28
|
+
*/
|
|
29
|
+
var SaveTextDocumentRequest;
|
|
30
|
+
(function (SaveTextDocumentRequest) {
|
|
31
|
+
SaveTextDocumentRequest.method = 'hydranium/saveTextDocument';
|
|
32
|
+
SaveTextDocumentRequest.type = new vscode_jsonrpc_1.RequestType(SaveTextDocumentRequest.method);
|
|
33
|
+
})(SaveTextDocumentRequest || (exports.SaveTextDocumentRequest = SaveTextDocumentRequest = {}));
|
|
34
|
+
//# sourceMappingURL=save-text-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-text-document.js","sourceRoot":"","sources":["../src/save-text-document.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mDAA6C;AAU7C;;;;;;;;;;;;;;;GAeG;AACH,IAAiB,uBAAuB,CAGvC;AAHD,WAAiB,uBAAuB;IACxB,8BAAM,GAAG,4BAA4B,CAAC;IACtC,4BAAI,GAAG,IAAI,4BAAW,CAAqC,8BAAM,CAAC,CAAC;AACnF,CAAC,EAHgB,uBAAuB,aAAvB,uBAAuB,GAAvB,uBAAuB,QAGvC"}
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* Nesting is a HOST convention, not the framework's: Theia flattens a nested
|
|
29
29
|
* catalogue by joining keys with `/`, which is the separator a code already
|
|
30
30
|
* uses, so an adopter on that host writes the file nested and one handed
|
|
31
|
-
* straight to a `
|
|
31
|
+
* straight to a `DefaultMessageRenderer` writes it flat. Both end up here.
|
|
32
32
|
*
|
|
33
33
|
* `_`-prefixed keys are dropped by PREFIX rather than by matching one literal
|
|
34
34
|
* name, so a second note added to a file cannot silently become a catalogue
|
|
@@ -34,7 +34,7 @@ const primitives_1 = require("../messages/primitives");
|
|
|
34
34
|
* Nesting is a HOST convention, not the framework's: Theia flattens a nested
|
|
35
35
|
* catalogue by joining keys with `/`, which is the separator a code already
|
|
36
36
|
* uses, so an adopter on that host writes the file nested and one handed
|
|
37
|
-
* straight to a `
|
|
37
|
+
* straight to a `DefaultMessageRenderer` writes it flat. Both end up here.
|
|
38
38
|
*
|
|
39
39
|
* `_`-prefixed keys are dropped by PREFIX rather than by matching one literal
|
|
40
40
|
* name, so a second note added to a file cannot silently become a catalogue
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogue-audit.js","sourceRoot":"","sources":["../../src/testing/catalogue-audit.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"catalogue-audit.js","sourceRoot":"","sources":["../../src/testing/catalogue-audit.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;AAElF,uDAAyD;AAEzD;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AACH,0BAAiC,SAAkC,EAAE,MAAM,GAAG,EAAE;IAC7E,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACpD,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,SAAS;QACZ,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACtD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,KAAgC,EAAE,MAAM,CAAC,CAAC,CAAC;QACnF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACf,CAAC;AAiBD;;;;;;;;;;GAUG;AACH,6BACG,aAAgC,EAChC,OAA0B,EAC1B,OAAO,GAA0B,EAAE;IAEnC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAA,4BAAe,EAAC,MAAM,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1G,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;IAC5C,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5G,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,yBAAgC,KAAwB,EAAE,MAAyB;IAChF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -32,8 +32,10 @@
|
|
|
32
32
|
import { type MessageConnection } from 'vscode-jsonrpc';
|
|
33
33
|
import type { DataPort } from '../client/data-port';
|
|
34
34
|
import type { DataClientProtocol } from '../data/data-server-protocol';
|
|
35
|
-
import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from '../data/events';
|
|
35
|
+
import type { ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentDirtyChangedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from '../data/events';
|
|
36
|
+
import type { Logger } from '../logger';
|
|
36
37
|
import type { ResolvedMessage } from '../messages/primitives';
|
|
38
|
+
import type { RpcProxyLifecycle } from '../rpc/create-rpc-proxy';
|
|
37
39
|
import type { Project } from '../project';
|
|
38
40
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
39
41
|
import type { TransferElement } from '../transfer-element';
|
|
@@ -47,15 +49,14 @@ export interface FakeDataPortOptions {
|
|
|
47
49
|
*
|
|
48
50
|
* Throwing (or rejecting) here is the transport-construction failure path,
|
|
49
51
|
* which the consumer surfaces through {@link FakeDataPort.reported}.
|
|
52
|
+
*
|
|
53
|
+
* The double disposes none of these connections and goes on connecting
|
|
54
|
+
* after its dispose, where a real port releases its connection and refuses:
|
|
55
|
+
* the test owns them.
|
|
50
56
|
*/
|
|
51
57
|
connect(): MessageConnection | Promise<MessageConnection>;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
* three sentinels the framework reserves (`'language-client'`, `'unknown'`,
|
|
55
|
-
* `'revert-on-close'`); override it when a test needs two distinguishable
|
|
56
|
-
* clients on one server.
|
|
57
|
-
*/
|
|
58
|
-
clientId?: string;
|
|
58
|
+
/** The port's {@link DataPort.logger}. */
|
|
59
|
+
logger?: Logger;
|
|
59
60
|
}
|
|
60
61
|
/** A {@link DataPort} that records what passed through it. */
|
|
61
62
|
export interface FakeDataPort extends DataPort {
|
|
@@ -95,21 +96,43 @@ export interface FakeDataPort extends DataPort {
|
|
|
95
96
|
* connection with no server behind it, a different one per generation.
|
|
96
97
|
*/
|
|
97
98
|
export declare function makeFakeDataPort(options: FakeDataPortOptions): FakeDataPort;
|
|
99
|
+
type UpperLetter = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
|
|
100
|
+
/**
|
|
101
|
+
* A notification name `TClient` adds to {@link DataClientProtocol}. Limited to
|
|
102
|
+
* `on` plus a letter A–Z, the names the proxy sends as notifications; any other
|
|
103
|
+
* name would be bound as a request. The {@link RpcProxyLifecycle} names are
|
|
104
|
+
* excluded too: the proxy returns its own events for them and sends nothing.
|
|
105
|
+
*/
|
|
106
|
+
export type AdditionalClientMethod<TClient> = Exclude<keyof TClient, keyof DataClientProtocol<TransferElement> | keyof RpcProxyLifecycle> & `on${UpperLetter}${string}`;
|
|
98
107
|
/** A {@link DataClientProtocol} plus the arrays it records into. */
|
|
99
|
-
export interface CapturingDataClient<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> {
|
|
108
|
+
export interface CapturingDataClient<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project, TClient extends DataClientProtocol<TTransfer, TDiagnostic, TProject> = DataClientProtocol<TTransfer, TDiagnostic, TProject>> {
|
|
100
109
|
/** The client to hand to a `DataSession` or bind as an RPC `localTarget`. */
|
|
101
|
-
readonly client:
|
|
110
|
+
readonly client: TClient;
|
|
102
111
|
/** Every `onDocumentUpdated` event, in arrival order. */
|
|
103
112
|
readonly updates: TransferDocumentUpdatedEvent<TTransfer, TDiagnostic>[];
|
|
104
113
|
/** Every `onDocumentSaved` event, in arrival order. */
|
|
105
114
|
readonly saves: TransferDocumentSavedEvent<TTransfer, TDiagnostic>[];
|
|
115
|
+
/** Every `onDocumentDirtyChanged` event, in arrival order. */
|
|
116
|
+
readonly dirtyChanges: TransferDocumentDirtyChangedEvent[];
|
|
117
|
+
/** Every `onDocumentDeleted` event, in arrival order. */
|
|
118
|
+
readonly deletions: TransferDocumentDeletedEvent[];
|
|
119
|
+
/** Every `onDocumentsBuilt` event, in arrival order. */
|
|
120
|
+
readonly builds: TransferDocumentsBuiltEvent[];
|
|
106
121
|
/** Every `onProjectsChanged` event, in arrival order. */
|
|
107
122
|
readonly projectsChanges: ProjectsChangedEvent<TProject>[];
|
|
123
|
+
/**
|
|
124
|
+
* Every event of each additional client method, keyed by method, in arrival
|
|
125
|
+
* order. A method of `TClient` left out of `additionalClientMethods` has no
|
|
126
|
+
* entry.
|
|
127
|
+
*/
|
|
128
|
+
readonly additionalNotifications: {
|
|
129
|
+
readonly [K in AdditionalClientMethod<TClient>]: TClient[K] extends (event: infer TEvent) => void ? TEvent[] : never;
|
|
130
|
+
};
|
|
108
131
|
}
|
|
109
132
|
/**
|
|
110
133
|
* A {@link DataClientProtocol} that records every notification it receives.
|
|
111
134
|
*
|
|
112
|
-
* Recording
|
|
135
|
+
* Recording EVERY channel even when a suite reads one is deliberate: an
|
|
113
136
|
* event delivered on the wrong channel is a real defect of the data head, and a
|
|
114
137
|
* double that drops the other two turns it into silence on the one being
|
|
115
138
|
* watched.
|
|
@@ -118,6 +141,12 @@ export interface CapturingDataClient<TTransfer extends TransferElement, TDiagnos
|
|
|
118
141
|
* the corresponding array stays empty — that is what makes an override usable
|
|
119
142
|
* as a barrier (rejecting, counting differently, throwing) rather than only as
|
|
120
143
|
* a spy.
|
|
144
|
+
*
|
|
145
|
+
* `additionalClientMethods` names the notifications `TClient` adds to
|
|
146
|
+
* {@link DataClientProtocol}. Each is recorded and overridable the same way;
|
|
147
|
+
* one left out is not on the client at all, and overriding it throws, since
|
|
148
|
+
* nothing would call the override.
|
|
121
149
|
*/
|
|
122
|
-
export declare function makeCapturingDataClient<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project>
|
|
150
|
+
export declare function makeCapturingDataClient<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project, TClient extends DataClientProtocol<TTransfer, TDiagnostic, TProject> = DataClientProtocol<TTransfer, TDiagnostic, TProject>>(overrides?: Partial<TClient>, additionalClientMethods?: readonly AdditionalClientMethod<TClient>[]): CapturingDataClient<TTransfer, TDiagnostic, TProject, TClient>;
|
|
151
|
+
export {};
|
|
123
152
|
//# sourceMappingURL=data-doubles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-doubles.d.ts","sourceRoot":"","sources":["../../src/testing/data-doubles.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"data-doubles.d.ts","sourceRoot":"","sources":["../../src/testing/data-doubles.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EACT,oBAAoB,EACpB,4BAA4B,EAC5B,iCAAiC,EACjC,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,0CAA0C;AAC1C,MAAM,WAAW,mBAAmB;IACjC;;;;;;;;;;;;OAYG;IACH,OAAO,IAAI,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC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