@hydranium/protocol 1.0.0-next.35 → 1.0.0-next.350
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 +684 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1148 -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 +170 -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-edits-settled-actions.d.ts +52 -0
- package/lib/glsp-edits-settled-actions.d.ts.map +1 -0
- package/lib/glsp-edits-settled-actions.js +28 -0
- package/lib/glsp-edits-settled-actions.js.map +1 -0
- 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 +10 -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 +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 +97 -4
- 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/pending-work-tracker.d.ts +29 -0
- package/lib/pending-work-tracker.d.ts.map +1 -0
- package/lib/pending-work-tracker.js +46 -0
- package/lib/pending-work-tracker.js.map +1 -0
- 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 +1469 -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 +197 -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-edits-settled-actions.ts +60 -0
- 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 +44 -8
- package/src/messages/index.ts +4 -2
- package/src/messages/primitives.ts +129 -5
- 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/pending-work-tracker.ts +46 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAYlF,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
@@ -23,8 +23,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
// Subpath barrel for `@hydranium/protocol/testing/node` — the test transports
|
|
26
|
-
// that need a Node runtime
|
|
27
|
-
// `MessageConnection` bridge over it.
|
|
26
|
+
// that need a Node runtime.
|
|
28
27
|
//
|
|
29
28
|
// Separate from `./testing` because a `PassThrough` is in `DuplexStreamPair`'s
|
|
30
29
|
// exported type and `StreamMessageReader` comes from `vscode-jsonrpc/node`, so
|
|
@@ -34,4 +33,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
33
|
// their own.
|
|
35
34
|
__exportStar(require("./duplex-connection"), exports);
|
|
36
35
|
__exportStar(require("./duplex-stream"), exports);
|
|
36
|
+
__exportStar(require("./message-port-pair"), exports);
|
|
37
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/node/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,8EAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/node/index.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;;;;;;;AAElF,8EAA8E;AAC9E,4BAA4B;AAC5B,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,aAAa;AAEb,sDAAoC;AACpC,kDAAgC;AAChC,sDAAoC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 type { TransferredMessagePort } from '../../client/post-message-transport';
|
|
10
|
+
/**
|
|
11
|
+
* The two ends of a `worker_threads` `MessageChannel`, typed as the transferred
|
|
12
|
+
* browser ports `createMessagePortTransport` takes. Node's port clones and keeps
|
|
13
|
+
* order as a browser's does, which is what lets a headless test stand in for a
|
|
14
|
+
* worker.
|
|
15
|
+
*
|
|
16
|
+
* `dispose` closes both ports. Node reports that as a close and a browser port
|
|
17
|
+
* reports nothing, so a test that asserts on a close does so before teardown.
|
|
18
|
+
*/
|
|
19
|
+
export interface MessagePortPair {
|
|
20
|
+
readonly port1: TransferredMessagePort;
|
|
21
|
+
readonly port2: TransferredMessagePort;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function makeMessagePortPair(): MessagePortPair;
|
|
25
|
+
//# sourceMappingURL=message-port-pair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-port-pair.d.ts","sourceRoot":"","sources":["../../../src/testing/node/message-port-pair.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAElF;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC7B,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC;IACvC,OAAO,IAAI,IAAI,CAAC;CAClB;AAED,wBAAgB,mBAAmB,IAAI,eAAe,CAYrD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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.makeMessagePortPair = makeMessagePortPair;
|
|
12
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
13
|
+
function makeMessagePortPair() {
|
|
14
|
+
const channel = new node_worker_threads_1.MessageChannel();
|
|
15
|
+
return {
|
|
16
|
+
// Node's port satisfies the structural type at runtime; the cast records
|
|
17
|
+
// one platform's port standing in for the other's.
|
|
18
|
+
port1: channel.port1,
|
|
19
|
+
port2: channel.port2,
|
|
20
|
+
dispose() {
|
|
21
|
+
channel.port1.close();
|
|
22
|
+
channel.port2.close();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=message-port-pair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-port-pair.js","sourceRoot":"","sources":["../../../src/testing/node/message-port-pair.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,6DAAqD;AAkBrD;IACG,MAAM,OAAO,GAAG,IAAI,oCAAc,EAAE,CAAC;IACrC,OAAO;QACJ,yEAAyE;QACzE,mDAAmD;QACnD,KAAK,EAAE,OAAO,CAAC,KAA0C;QACzD,KAAK,EAAE,OAAO,CAAC,KAA0C;QACzD,OAAO;YACJ,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;KACH,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 type { TransferElement } from '../transfer-element';
|
|
10
|
+
import type { ConcreteTypeName, SingleTypeName } from '../types';
|
|
11
|
+
/**
|
|
12
|
+
* The per-type constant the generated transfer model emits under each type's
|
|
13
|
+
* name, as Langium does for the AST. Its `$type` literal picks the interface
|
|
14
|
+
* out of the builder's type map.
|
|
15
|
+
*/
|
|
16
|
+
export interface TransferTypeConstant<TType extends string = string> {
|
|
17
|
+
readonly $type: TType;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* What {@link makeTransferNodeBuilder} reads from a reflection: each type's
|
|
21
|
+
* grammar properties and their defaults. The generated
|
|
22
|
+
* `<LanguageId>TransferReflection` satisfies it without importing it, and
|
|
23
|
+
* keeps the literal type of its `types` so the builder can tell which fields
|
|
24
|
+
* the grammar defaults.
|
|
25
|
+
*/
|
|
26
|
+
export interface TransferReflection {
|
|
27
|
+
getTypeMetaData(type: string): {
|
|
28
|
+
readonly properties: Readonly<Record<string, {
|
|
29
|
+
readonly defaultValue?: unknown;
|
|
30
|
+
}>>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** The properties of `TType` that `TReflection`'s literal `types` gives a `defaultValue`; none for a reflection typed only as the interface. */
|
|
34
|
+
type DefaultedKeys<TReflection, TType> = TReflection extends {
|
|
35
|
+
readonly types: infer Types;
|
|
36
|
+
} ? TType extends keyof Types ? Types[TType] extends {
|
|
37
|
+
readonly properties: infer Properties;
|
|
38
|
+
} ? {
|
|
39
|
+
[K in keyof Properties]: Properties[K] extends {
|
|
40
|
+
readonly defaultValue: unknown;
|
|
41
|
+
} ? K : never;
|
|
42
|
+
}[keyof Properties] : never : never : never;
|
|
43
|
+
/**
|
|
44
|
+
* Init payload of a {@link TransferNodeBuilder}: every field of `T` as its
|
|
45
|
+
* interface declares it, except that the fields named by `TDefaulted`, which
|
|
46
|
+
* the grammar defaults, are optional. `$type` comes from the constant.
|
|
47
|
+
*/
|
|
48
|
+
export type TransferNodeInit<T extends TransferElement, TDefaulted extends PropertyKey = never> = Omit<T, '$type' | TDefaulted> & Partial<Pick<T, Extract<TDefaulted, keyof T>>>;
|
|
49
|
+
/**
|
|
50
|
+
* Transfer-node factory bound to a grammar's type map, the transfer twin of
|
|
51
|
+
* core's `AstNodeBuilder`. `TMap` is the generated `<LanguageId>TransferTypes`,
|
|
52
|
+
* `TReflection` the type of the generated reflection.
|
|
53
|
+
*/
|
|
54
|
+
export interface TransferNodeBuilder<TMap, TReflection extends TransferReflection = TransferReflection> {
|
|
55
|
+
/** A complete node: the grammar's defaults, then `init`. */
|
|
56
|
+
<TType extends ConcreteTypeName<TMap>>(typeConstant: TransferTypeConstant<TType> & SingleTypeName<TType>, init: TransferNodeInit<Extract<TMap[TType], TransferElement>, DefaultedKeys<TReflection, TType>>): Extract<TMap[TType], TransferElement>;
|
|
57
|
+
/**
|
|
58
|
+
* A node holding only `init`, with no defaults filled, typed as the
|
|
59
|
+
* incomplete node it is.
|
|
60
|
+
*/
|
|
61
|
+
partial<TType extends ConcreteTypeName<TMap>>(typeConstant: TransferTypeConstant<TType> & SingleTypeName<TType>, init?: Partial<Omit<Extract<TMap[TType], TransferElement>, '$type'>>): Partial<Extract<TMap[TType], TransferElement>> & TransferTypeConstant<TType>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Bind a {@link TransferNodeBuilder} to a grammar's reflection, so a test names
|
|
65
|
+
* only the fields it cares about and a containment field the grammar gains
|
|
66
|
+
* later needs no change at the call site.
|
|
67
|
+
*
|
|
68
|
+
* Defaults come from the reflection's grammar metadata alone, so a derived
|
|
69
|
+
* field the overlay adds is never defaulted, and stays required. An array
|
|
70
|
+
* default is a fresh `[]` per node. An init field named as `undefined` keeps
|
|
71
|
+
* its default, since the init type cannot refuse `undefined` for an optional
|
|
72
|
+
* field and a plain assign would leave the node typed complete without it.
|
|
73
|
+
*
|
|
74
|
+
* The constant's `$type` is written after `init`, because the init type keeps
|
|
75
|
+
* out only a `$type` written in the call: a spread of another node passes the
|
|
76
|
+
* check and would otherwise hand back a node typed as one type and tagged as
|
|
77
|
+
* another.
|
|
78
|
+
*/
|
|
79
|
+
export declare function makeTransferNodeBuilder<TMap, TReflection extends TransferReflection = TransferReflection>(reflection: TReflection): TransferNodeBuilder<TMap, TReflection>;
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=transfer-node-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer-node-builder.d.ts","sourceRoot":"","sources":["../../src/testing/transfer-node-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,oBAAoB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM;IAChE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACxB;AAED;;;;;;GAMG;A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,IAAI,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,EAAE,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,GAChG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC;IACzC;;;OAGG;IACH,OAAO,CAAC,KAAK,SAAS,gBAAgB,CAAC,IAAI,CAAC,EACzC,YAAY,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,EACjE,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC,GACpE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;CAClF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EACtG,UAAU,EAAE,WAAW,GACvB,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAC,CAkBxC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
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.makeTransferNodeBuilder = makeTransferNodeBuilder;
|
|
12
|
+
/**
|
|
13
|
+
* Bind a {@link TransferNodeBuilder} to a grammar's reflection, so a test names
|
|
14
|
+
* only the fields it cares about and a containment field the grammar gains
|
|
15
|
+
* later needs no change at the call site.
|
|
16
|
+
*
|
|
17
|
+
* Defaults come from the reflection's grammar metadata alone, so a derived
|
|
18
|
+
* field the overlay adds is never defaulted, and stays required. An array
|
|
19
|
+
* default is a fresh `[]` per node. An init field named as `undefined` keeps
|
|
20
|
+
* its default, since the init type cannot refuse `undefined` for an optional
|
|
21
|
+
* field and a plain assign would leave the node typed complete without it.
|
|
22
|
+
*
|
|
23
|
+
* The constant's `$type` is written after `init`, because the init type keeps
|
|
24
|
+
* out only a `$type` written in the call: a spread of another node passes the
|
|
25
|
+
* check and would otherwise hand back a node typed as one type and tagged as
|
|
26
|
+
* another.
|
|
27
|
+
*/
|
|
28
|
+
function makeTransferNodeBuilder(reflection) {
|
|
29
|
+
const build = (typeConstant, init) => {
|
|
30
|
+
const node = { $type: typeConstant.$type };
|
|
31
|
+
for (const [name, property] of Object.entries(reflection.getTypeMetaData(typeConstant.$type).properties)) {
|
|
32
|
+
if (property.defaultValue !== undefined) {
|
|
33
|
+
node[name] = Array.isArray(property.defaultValue) ? [...property.defaultValue] : property.defaultValue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const [name, value] of Object.entries(init)) {
|
|
37
|
+
if (value !== undefined || !Object.hasOwn(node, name)) {
|
|
38
|
+
node[name] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
node.$type = typeConstant.$type;
|
|
42
|
+
return node;
|
|
43
|
+
};
|
|
44
|
+
const partial = (typeConstant, init = {}) => ({ ...init, $type: typeConstant.$type });
|
|
45
|
+
return Object.assign(build, { partial });
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=transfer-node-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer-node-builder.js","sourceRoot":"","sources":["../../src/testing/transfer-node-builder.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AA+DlF;;;;;;;;;;;;;;;GAeG;AACH,iCACG,UAAuB;IAEvB,MAAM,KAAK,GAAG,CAAC,YAAkC,EAAE,IAAY,EAAU,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 5. */
|
|
33
33
|
readonly intervalMs?: number;
|
|
34
|
-
/**
|
|
35
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Error message on timeout, and when the predicate throws. A function is
|
|
36
|
+
* called only then, so it can report the state the wait ended on; when it
|
|
37
|
+
* throws, the default text is used, with its throw as the error's `cause`
|
|
38
|
+
* unless the predicate threw. Default a generic phrasing.
|
|
39
|
+
*/
|
|
40
|
+
readonly message?: string | (() => string);
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
38
43
|
* Resolve once `predicate()` returns true, polling at `intervalMs`; reject with
|
|
39
|
-
* `message` once `timeoutMs` elapses
|
|
44
|
+
* `message` once `timeoutMs` elapses, or at once when the predicate throws, with
|
|
45
|
+
* the throw as the error's `cause`. The **non-racy** alternative to a fixed
|
|
40
46
|
* sleep for awaiting an asynchronous side effect that lands on an observable
|
|
41
47
|
* value.
|
|
42
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait-for.d.ts","sourceRoot":"","sources":["../../src/testing/wait-for.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;GAkBG;AAEH,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B
|
|
1
|
+
{"version":3,"file":"wait-for.d.ts","sourceRoot":"","sources":["../../src/testing/wait-for.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;GAkBG;AAEH,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,OAAO,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8D7F;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,EAAE,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3C"}
|
package/lib/testing/wait-for.js
CHANGED
|
@@ -12,7 +12,8 @@ exports.waitFor = waitFor;
|
|
|
12
12
|
exports.tick = tick;
|
|
13
13
|
/**
|
|
14
14
|
* Resolve once `predicate()` returns true, polling at `intervalMs`; reject with
|
|
15
|
-
* `message` once `timeoutMs` elapses
|
|
15
|
+
* `message` once `timeoutMs` elapses, or at once when the predicate throws, with
|
|
16
|
+
* the throw as the error's `cause`. The **non-racy** alternative to a fixed
|
|
16
17
|
* sleep for awaiting an asynchronous side effect that lands on an observable
|
|
17
18
|
* value.
|
|
18
19
|
*
|
|
@@ -29,20 +30,65 @@ exports.tick = tick;
|
|
|
29
30
|
function waitFor(predicate, options = {}) {
|
|
30
31
|
const timeoutMs = options.timeoutMs ?? 2000;
|
|
31
32
|
const intervalMs = options.intervalMs ?? 5;
|
|
32
|
-
const
|
|
33
|
-
if (predicate()) {
|
|
34
|
-
return Promise.resolve();
|
|
35
|
-
}
|
|
33
|
+
const defaultMessage = `Timed out after ${timeoutMs}ms waiting for a condition`;
|
|
36
34
|
return new Promise((resolve, reject) => {
|
|
37
|
-
|
|
35
|
+
// A throw from the predicate or the message function would leave the
|
|
36
|
+
// promise unsettled from the poll's or the deadline's timer, or escape
|
|
37
|
+
// `waitFor` itself on the first check; it rejects instead, with the
|
|
38
|
+
// predicate's throw, else the message function's, as cause. True once
|
|
39
|
+
// the promise is settled.
|
|
40
|
+
const settle = (timedOut) => {
|
|
41
|
+
let met = false;
|
|
42
|
+
let threw = false;
|
|
43
|
+
let cause;
|
|
44
|
+
try {
|
|
45
|
+
met = predicate();
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
threw = true;
|
|
49
|
+
cause = error;
|
|
50
|
+
}
|
|
51
|
+
if (met) {
|
|
52
|
+
resolve();
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
if (!timedOut && !threw) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
let message = defaultMessage;
|
|
59
|
+
try {
|
|
60
|
+
if (typeof options.message === 'function') {
|
|
61
|
+
message = options.message();
|
|
62
|
+
}
|
|
63
|
+
else if (options.message !== undefined) {
|
|
64
|
+
message = options.message;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (!threw) {
|
|
69
|
+
threw = true;
|
|
70
|
+
cause = error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
reject(new Error(message, threw ? { cause } : undefined));
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
76
|
+
if (settle(false)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const stop = () => {
|
|
38
80
|
clearInterval(poll);
|
|
39
|
-
|
|
81
|
+
clearTimeout(deadline);
|
|
82
|
+
};
|
|
83
|
+
// A stalled loop can run the deadline after the condition came true but
|
|
84
|
+
// before the next poll saw it, so the deadline checks once more.
|
|
85
|
+
const deadline = setTimeout(() => {
|
|
86
|
+
settle(true);
|
|
87
|
+
stop();
|
|
40
88
|
}, timeoutMs);
|
|
41
89
|
const poll = setInterval(() => {
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
clearTimeout(deadline);
|
|
45
|
-
resolve();
|
|
90
|
+
if (settle(false)) {
|
|
91
|
+
stop();
|
|
46
92
|
}
|
|
47
93
|
}, intervalMs);
|
|
48
94
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait-for.js","sourceRoot":"","sources":["../../src/testing/wait-for.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"wait-for.js","sourceRoot":"","sources":["../../src/testing/wait-for.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;AAqClF;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAwB,SAAwB,EAAE,OAAO,GAAmB,EAAE;IAC3E,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;IAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,mBAAmB,SAAS,4BAA4B,CAAC;IAChF,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,qEAAqE;QACrE,uEAAuE;QACvE,oEAAoE;QACpE,sEAAsE;QACtE,0BAA0B;QAC1B,MAAM,MAAM,GAAG,CAAC,QAAiB,EAAW,EAAE;YAC3C,IAAI,GAAG,GAAG,KAAK,CAAC;YAChB,IAAI,KAAK,GAAG,KAAK,CAAC;YAClB,IAAI,KAAc,CAAC;YACnB,IAAI,CAAC;gBACF,GAAG,GAAG,SAAS,EAAE,CAAC;YACrB,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACvB,KAAK,GAAG,IAAI,CAAC;gBACb,KAAK,GAAG,KAAK,CAAC;YACjB,CAAC;YACD,IAAI,GAAG,EAAE,CAAC;gBACP,OAAO,EAAE,CAAC;gBACV,OAAO,IAAI,CAAC;YACf,CAAC;YACD,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC;YAChB,CAAC;YACD,IAAI,OAAO,GAAG,cAAc,CAAC;YAC7B,IAAI,CAAC;gBACF,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;oBACzC,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;gBAC/B,CAAC;qBAAM,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@
|
|
|
1
|
-
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../src/tracer.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,SAAS,CAAC;AAClD,OAAO,EAAU,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../src/tracer.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,SAAS,CAAC;AAClD,OAAO,EAAU,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAMpC,2GAA2G;AAC3G,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,iDAAiD;AACjD,MAAM,WAAW,WAAW;IACzB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,8FAA8F;IAC9F,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,4GAA4G;IAC5G,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,+GAA+G;AAC/G,MAAM,WAAW,UAAU;IACxB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,iGAAiG;AACjG,MAAM,MAAM,YAAY,GAAG,MAAM,UAAU,GAAG,SAAS,CAAC;AAExD;;;;;;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CAErC;IAED,oFAAoF;IACpF,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM,CAElH;IAED,kGAAkG;IAClG,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,CAEjE;CACH"}
|
package/lib/tracer.js
CHANGED
|
@@ -14,6 +14,7 @@ const logger_1 = require("./logger");
|
|
|
14
14
|
const noop_logger_1 = require("./noop-logger");
|
|
15
15
|
const profile_session_1 = require("./profile-session");
|
|
16
16
|
const util_1 = require("./util");
|
|
17
|
+
const primitives_1 = require("./messages/primitives");
|
|
17
18
|
/** Module-global so nested timers don't reuse ids. */
|
|
18
19
|
let nextTimerId = 0;
|
|
19
20
|
/** Ops completing before this threshold are silent on success — only failures emit a retroactive start. */
|
|
@@ -114,15 +115,10 @@ class DefaultTracer {
|
|
|
114
115
|
const suffix = this.timingSuffix(status, elapsed, options);
|
|
115
116
|
this.logger[logLevel](`${label} [#${id} ${status}, ${logger_1.Format.elapsed(elapsed)}${currentExtras()}${suffix}]`);
|
|
116
117
|
if (status === 'failed') {
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
122
|
-
this.logger.warn(`${label} [#${id}] failed: ${detail}`);
|
|
123
|
-
if (error instanceof Error && error.stack) {
|
|
124
|
-
this.logger.debug(error.stack);
|
|
125
|
-
}
|
|
118
|
+
// Reporting the failure is the caller's, who receives it: a line at
|
|
119
|
+
// warn here would exist only while `logLevel` is enabled.
|
|
120
|
+
const detail = (0, primitives_1.describeErrorWithStack)(error);
|
|
121
|
+
this.logger.debug(`${label} [#${id}] failed: ${detail}`);
|
|
126
122
|
}
|
|
127
123
|
};
|
|
128
124
|
let result;
|
package/lib/tracer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracer.js","sourceRoot":"","sources":["../src/tracer.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mCAAkD;AAClD,qCAA6D;AAC7D,+CAA2C;AAC3C,uDAA+E;AAC/E,iCAAoC;
|
|
1
|
+
{"version":3,"file":"tracer.js","sourceRoot":"","sources":["../src/tracer.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,mCAAkD;AAClD,qCAA6D;AAC7D,+CAA2C;AAC3C,uDAA+E;AAC/E,iCAAoC;AACpC,sDAA+D;AAE/D,sDAAsD;AACtD,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB,2GAA2G;AAC9F,QAAA,cAAc,GAAG,CAAC,CAAC;AAqEhC;;;;;;;;;GASG;AACH;IAEyB,MAAM;IACN,KAAK;IACL,UAAU;IAHhC,YACsB,MAAM,GAAW,IAAI,wBAAU,EAAE,EACjC,KAAK,GAAU,IAAI,mBAAW,EAAE,EAChC,UAAU,GAAiB,GAAG,EAAE,CAAC,SAAS;sBAF1C,MAAM;qBACN,KAAK;0BACL,UAAU;IAC7B,CAAC;IAEJ,4EAA4E;IAC5E,4EAA4E;IAC5E,2DAA2D;IAC3D,KAAK,CAAC,OAAgB,EAAE,GAAG,IAAe;QACvC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,IAAI,CAAC,OAAgB,EAAE,GAAG,IAAe;QACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,IAAI,CAAC,OAAgB,EAAE,GAAG,IAAe;QACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,KAA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ostic.js","sourceRoot":"","sources":["../src/transfer-diagnostic.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAsElF,IAAiB,kBAAkB,CAsDlC;AAtDD,WAAiB,kBAAkB;IAChC,mEAAmE;IACtD,4CAAyB,GAAG,GAAG,CAAC;IAC7C,wDAAwD;IAC3C,0CAAuB,GAAG,GAAG,CAAC;IAC3C,sFAAsF;IACzE,6CAA0B,GAAG,GAAG,CAAC;IAE9C,SAAgB,OAAO,CAAC,UAA8B;QACnD,OAAO,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC;IAC1C,CAAC;IAFe,
|
|
1
|
+
{"version":3,"file":"transfer-diagnostic.js","sourceRoot":"","sources":["../src/transfer-diagnostic.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAsElF,IAAiB,kBAAkB,CAsDlC;AAtDD,WAAiB,kBAAkB;IAChC,mEAAmE;IACtD,4CAAyB,GAAG,GAAG,CAAC;IAC7C,wDAAwD;IAC3C,0CAAuB,GAAG,GAAG,CAAC;IAC3C,sFAAsF;IACzE,6CAA0B,GAAG,GAAG,CAAC;IAE9C,SAAgB,OAAO,CAAC,UAA8B;QACnD,OAAO,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC;IAC1C,CAAC;IAFe,mBAAA,OAAO,UAEtB,CAAA;IAED,SAAgB,YAAY,CAAC,UAA8B;QACxD,OAAO,UAAU,CAAC,IAAI,KAAK,eAAe,CAAC;IAC9C,CAAC;IAFe,mBAAA,YAAY,eAE3B,CAAA;IAED;;;;;;;;;;;;;;;OAeG;IACH,SAAgB,QAAQ,CAAC,UAA8B;QACpD,IAAI,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1E,OAAO,SAAS,CAAC;QACpB,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC;IACzF,CAAC;IALe,mBAAA,QAAQ,WAKvB,CAAA;IAED,SAAgB,OAAO,CAAC,UAA8B;QACnD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,OAAO,GAAG,6CAA0B,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;IAChI,CAAC;IAFe,mBAAA,OAAO,UAEtB,CAAA;IAED,SAAgB,MAAM,CAAC,WAAiC;QACrD,OAAO,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAFe,mBAAA,MAAM,SAErB,CAAA;IAED,SAAgB,SAAS,CAAC,WAAiC;QACxD,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAFe,mBAAA,SAAS,YAExB,CAAA;IAED,SAAgB,cAAc,CAAC,WAAiC;QAC7D,OAAO,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzC,CAAC;IAFe,mBAAA,cAAc,iBAE7B,CAAA;AACJ,CAAC,EAtDgB,kBAAkB,aAAlB,kBAAkB,GAAlB,kBAAkB,QAsDlC"}
|
|
@@ -8,47 +8,110 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import type { TransferDiagnostic } from './transfer-diagnostic';
|
|
10
10
|
import type { TransferElement } from './transfer-element';
|
|
11
|
+
import { type ModelVersion, type TextVersion } from './model-service/base-version';
|
|
12
|
+
/** The model a data server built for a document, encoded for the wire. */
|
|
13
|
+
export interface TransferModelSnapshot<TRoot extends TransferElement, TDiagnostic = TransferDiagnostic> {
|
|
14
|
+
root: TRoot;
|
|
15
|
+
/** Absent until the document is validated; `[]` once it is and nothing was found. */
|
|
16
|
+
diagnostics?: TDiagnostic[];
|
|
17
|
+
/**
|
|
18
|
+
* The version of the text `root` was parsed from. A caller that mutates the
|
|
19
|
+
* model sends this back as the `baseVersion` of its write, and the server
|
|
20
|
+
* rejects the write with `ConflictError` once its text has moved past it.
|
|
21
|
+
*/
|
|
22
|
+
version: ModelVersion;
|
|
23
|
+
/**
|
|
24
|
+
* The data server's fingerprint of `root` and `diagnostics`, or under its
|
|
25
|
+
* `'text-diagnostics'` strategy of the text `root` was parsed from and
|
|
26
|
+
* `diagnostics`.
|
|
27
|
+
* Independent of `version`; an equal hash also means equally validated.
|
|
28
|
+
*/
|
|
29
|
+
hash: string;
|
|
30
|
+
}
|
|
31
|
+
/** The text a data server held for a document when it sent it. */
|
|
32
|
+
export interface TextState {
|
|
33
|
+
/**
|
|
34
|
+
* The server's version of that text. A `TransferModelSnapshot.version` below it
|
|
35
|
+
* means the model was parsed from older text, and an update at this version
|
|
36
|
+
* or a later one follows.
|
|
37
|
+
*/
|
|
38
|
+
version: TextVersion;
|
|
39
|
+
/**
|
|
40
|
+
* What `textHash` makes of the text alone: equal texts hash equal whatever
|
|
41
|
+
* their version or dirty state, across a revert or a server restart that
|
|
42
|
+
* numbers versions afresh.
|
|
43
|
+
*/
|
|
44
|
+
hash: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the text differs from the file, as the server last knew the file.
|
|
47
|
+
* A later change arrives as `onDocumentDirtyChanged` to a client watching
|
|
48
|
+
* the document.
|
|
49
|
+
*/
|
|
50
|
+
dirty: boolean;
|
|
51
|
+
}
|
|
11
52
|
/**
|
|
12
53
|
* Wire envelope exchanged between the model-server's data-server head and
|
|
13
|
-
* its clients
|
|
14
|
-
*
|
|
54
|
+
* its clients: the server's model of a document and the text it holds for it,
|
|
55
|
+
* each absent where the server has none.
|
|
15
56
|
*
|
|
16
57
|
* The constraint `TTransfer extends TransferElement` pins the type system
|
|
17
58
|
* to the wire data shape (no `$container` cycles, references as strings;
|
|
18
|
-
* see {@link TransferElement}).
|
|
19
|
-
* `AstDocument<TAst extends AstNode, TDiagnostic>` in
|
|
20
|
-
* `@hydranium/core` — same structural shape, different generic
|
|
21
|
-
* constraint, used at the AST layer before the `TransferEncoder`
|
|
22
|
-
* translation produces a {@link TransferDocument}.
|
|
59
|
+
* see {@link TransferElement}).
|
|
23
60
|
*/
|
|
24
61
|
export interface TransferDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> {
|
|
25
62
|
uri: string;
|
|
26
63
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* (or `TransferSaveArgs.baseVersion`) so the server can detect stale-based
|
|
31
|
-
* updates and reject them with `ConflictError`.
|
|
32
|
-
*
|
|
33
|
-
* See `@hydranium/protocol#errors` for the conflict-detection contract.
|
|
34
|
-
*/
|
|
35
|
-
version: number;
|
|
36
|
-
/**
|
|
37
|
-
* Absent when the document does not exist — the server answers an unknown URI
|
|
38
|
-
* with a shaped envelope rather than an error, so absence is an ordinary
|
|
39
|
-
* branch and not a catch. Declared required it reads as a guarantee, and
|
|
40
|
-
* every `root.x` compiles into a throw.
|
|
64
|
+
* Absent when the document does not exist: the server answers an unknown
|
|
65
|
+
* URI with a shaped envelope rather than an error, so absence is an
|
|
66
|
+
* ordinary branch and not a catch.
|
|
41
67
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
68
|
+
model?: TransferModelSnapshot<TTransfer, TDiagnostic>;
|
|
69
|
+
/** Absent when the server holds no text for the document. */
|
|
70
|
+
text?: TextState;
|
|
44
71
|
}
|
|
45
72
|
/**
|
|
46
|
-
* A {@link TransferDocument} the server actually had, so `
|
|
73
|
+
* A {@link TransferDocument} the server actually had, so `model` is present.
|
|
47
74
|
* Narrowed to by {@link TransferDocument.isLoaded} / {@link TransferDocument.assertLoaded}.
|
|
48
75
|
*/
|
|
49
76
|
export type LoadedTransferDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> = TransferDocument<TTransfer, TDiagnostic> & {
|
|
50
|
-
|
|
77
|
+
model: TransferModelSnapshot<TTransfer, TDiagnostic>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* What a save or a persist answers: the document, and in `persisted` the
|
|
81
|
+
* version of the text it wrote to the file. That can differ from
|
|
82
|
+
* `model.version` either way, since writes land between the build and the
|
|
83
|
+
* take, so a client marking a version saved takes it from here.
|
|
84
|
+
*/
|
|
85
|
+
export type TransferSavedDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> = TransferDocument<TTransfer, TDiagnostic> & {
|
|
86
|
+
persisted: {
|
|
87
|
+
version: TextVersion;
|
|
88
|
+
};
|
|
51
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* What a create answers: the document as a read after the create finds it,
|
|
92
|
+
* and in `created` the version the create's text took. Another client's write
|
|
93
|
+
* or an integrity repair can land between the create and that read, so
|
|
94
|
+
* `model.version` can be past it, and a write based on it would carry that
|
|
95
|
+
* text as the creator's; a write based on `created.version` conflicts instead.
|
|
96
|
+
* A model version, not a text version, because the creator holds the text at
|
|
97
|
+
* that version: it sent it.
|
|
98
|
+
*/
|
|
99
|
+
export type TransferCreatedDocument<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic> = TransferDocument<TTransfer, TDiagnostic> & {
|
|
100
|
+
created: {
|
|
101
|
+
version: ModelVersion;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/** What a watch answers, once it is in place. */
|
|
105
|
+
export interface TransferWatchedDocument {
|
|
106
|
+
/** The key the watch's events name the document by, which a symlinked URI does not spell. */
|
|
107
|
+
readonly uri: string;
|
|
108
|
+
/** Whether a document exists there; one the server fails to load counts, only a missing one does not. */
|
|
109
|
+
readonly exists: boolean;
|
|
110
|
+
/** The position of the last update or deletion event sent before `exists` was taken; an event past it was sent after. */
|
|
111
|
+
readonly sequence: number;
|
|
112
|
+
/** The text the server held when `exists` was taken, as a read answers it; absent when it held none. */
|
|
113
|
+
readonly text?: TextState;
|
|
114
|
+
}
|
|
52
115
|
export declare namespace TransferDocument {
|
|
53
116
|
/**
|
|
54
117
|
* Whether the server had this document. Branch on it where absence is an
|
|
@@ -56,18 +119,18 @@ export declare namespace TransferDocument {
|
|
|
56
119
|
*/
|
|
57
120
|
function isLoaded<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(document: TransferDocument<TTransfer, TDiagnostic>): document is LoadedTransferDocument<TTransfer, TDiagnostic>;
|
|
58
121
|
/**
|
|
59
|
-
* The same document with `
|
|
122
|
+
* The same document with `model` no longer optional, or a throw. For call
|
|
60
123
|
* sites where absence is a bug rather than a branch; the whole envelope is
|
|
61
|
-
* returned because a caller needing `
|
|
124
|
+
* returned because a caller needing `model` usually needs `uri` or `text`
|
|
62
125
|
* with it.
|
|
63
126
|
*/
|
|
64
127
|
function assertLoaded<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(document: TransferDocument<TTransfer, TDiagnostic>): LoadedTransferDocument<TTransfer, TDiagnostic>;
|
|
128
|
+
/** The envelope for a document the server does not have. */
|
|
129
|
+
function absent<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(uri: string): TransferDocument<TTransfer, TDiagnostic>;
|
|
65
130
|
/**
|
|
66
|
-
* Construct a {@link TransferDocument} envelope
|
|
67
|
-
*
|
|
68
|
-
* "no diagnostics yet" code paths don't need to repeat the empty array
|
|
69
|
-
* at every call site.
|
|
131
|
+
* Construct a {@link TransferDocument} envelope with a model, its version
|
|
132
|
+
* marked as coming from a read. `diagnostics` absent means not validated.
|
|
70
133
|
*/
|
|
71
|
-
function create<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(uri: string, version: number, root: TTransfer, diagnostics?: TDiagnostic[]): TransferDocument<TTransfer, TDiagnostic>;
|
|
134
|
+
function create<TTransfer extends TransferElement, TDiagnostic = TransferDiagnostic>(uri: string, version: number, root: TTransfer, hash: string, diagnostics?: TDiagnostic[], text?: TextState): TransferDocument<TTransfer, TDiagnostic>;
|
|
72
135
|
}
|
|
73
136
|
//# sourceMappingURL=transfer-document.d.ts.map
|