@hydranium/protocol 1.0.0-next.36 → 1.0.0-next.360
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 +11 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +16 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +303 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +534 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +18 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +26 -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 +691 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1155 -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 +6 -4
- package/lib/client/message-relay.d.ts.map +1 -1
- 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 +69 -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 +173 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +225 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client/worker-handshake.d.ts +90 -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 +171 -48
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +144 -33
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +76 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts +7 -4
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js +10 -10
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +188 -30
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +269 -32
- package/lib/errors.js.map +1 -1
- package/lib/format-log-arg.d.ts +33 -0
- package/lib/format-log-arg.d.ts.map +1 -0
- package/lib/format-log-arg.js +158 -0
- package/lib/format-log-arg.js.map +1 -0
- package/lib/glsp-edits-settled-actions.d.ts +54 -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 +55 -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 +11 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -1
- package/lib/latency-collector.d.ts +10 -4
- package/lib/latency-collector.d.ts.map +1 -1
- package/lib/latency-collector.js +2 -0
- 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 +30 -0
- package/lib/pending-work-tracker.d.ts.map +1 -0
- package/lib/pending-work-tracker.js +47 -0
- package/lib/pending-work-tracker.js.map +1 -0
- package/lib/profile-session.d.ts +19 -5
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js +10 -1
- package/lib/profile-session.js.map +1 -1
- package/lib/profiling.d.ts +15 -2
- package/lib/profiling.d.ts.map +1 -1
- package/lib/profiling.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 +70 -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 +96 -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 +18 -0
- package/src/client/data-connection.ts +654 -0
- package/src/client/data-events.ts +38 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1476 -137
- package/src/client/index.ts +15 -9
- package/src/client/message-relay.ts +6 -4
- package/src/client/post-message-transport.ts +224 -4
- package/src/client/rpc-connection.ts +302 -0
- package/src/client/worker-handshake.ts +117 -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 +198 -48
- package/src/data/events.ts +150 -33
- package/src/data/requests.ts +82 -11
- package/src/debouncer.ts +11 -11
- package/src/errors.ts +331 -40
- package/src/format-log-arg.ts +176 -0
- package/src/glsp-edits-settled-actions.ts +62 -0
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +64 -0
- package/src/index.ts +11 -0
- package/src/latency-collector.ts +10 -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 +47 -0
- package/src/profile-session.ts +20 -5
- package/src/profiling.ts +15 -2
- package/src/project.ts +4 -1
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +131 -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 +116 -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
package/lib/errors.js
CHANGED
|
@@ -8,48 +8,91 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.
|
|
11
|
+
exports.ReservedClientIdError = exports.DuplicateClientIdError = exports.DUPLICATE_CLIENT_ID = exports.DocumentNotOpenError = exports.DOCUMENT_NOT_OPEN = exports.SessionClosedError = exports.SESSION_CLOSED = exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.SESSION_CLOSED_ERROR_CODE = exports.ConflictError = exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES = exports.STALE_BASE_VERSION_SAVE = exports.STALE_BASE_VERSION_UPDATE = void 0;
|
|
12
|
+
exports.isResponseError = isResponseError;
|
|
13
|
+
exports.reviveProtocolError = reviveProtocolError;
|
|
14
|
+
exports.isSessionClosedError = isSessionClosedError;
|
|
15
|
+
exports.isDocumentNotOpenError = isDocumentNotOpenError;
|
|
16
|
+
exports.isDuplicateClientIdError = isDuplicateClientIdError;
|
|
17
|
+
exports.isReservedClientIdError = isReservedClientIdError;
|
|
12
18
|
exports.isConflictError = isConflictError;
|
|
13
19
|
const vscode_jsonrpc_1 = require("vscode-jsonrpc");
|
|
14
20
|
const primitives_1 = require("./messages/primitives");
|
|
21
|
+
const base_version_1 = require("./model-service/base-version");
|
|
22
|
+
/*
|
|
23
|
+
* Every error here is a typed error: a caller reacts to it, so it has a class,
|
|
24
|
+
* a JSON-RPC code and an `is*` guard, and an English message. A typed error
|
|
25
|
+
* also carries a message identity where the framework can write an end-user
|
|
26
|
+
* sentence that needs no context. A URI may stay in that sentence; a client id
|
|
27
|
+
* or a raw version stays out of it, worded or left to `data`.
|
|
28
|
+
*
|
|
29
|
+
* An error nothing reacts to does not belong here: it stays a plain `Error`, or
|
|
30
|
+
* a named subclass without a code, at its throw site, since a code and a guard
|
|
31
|
+
* are public API that no caller would use.
|
|
32
|
+
*/
|
|
15
33
|
/**
|
|
16
|
-
* The catalogue declaration behind {@link ConflictError}'s sentence.
|
|
34
|
+
* The catalogue declaration behind {@link ConflictError}'s sentence. It words
|
|
35
|
+
* the version mismatch rather than stating it: the two numbers mean nothing to
|
|
36
|
+
* an end user, and they stay in {@link ConflictErrorData}.
|
|
17
37
|
*
|
|
18
38
|
* Its English must keep containing {@link CONFLICT_ERROR_MESSAGE_MARKER}: the
|
|
19
39
|
* marker is tier 3 of {@link isConflictError}'s ladder, and it matches on text.
|
|
20
40
|
* That tier only ever works untranslated, which is why it is the last resort
|
|
21
41
|
* behind the numeric code rather than the primary check.
|
|
22
42
|
*/
|
|
23
|
-
exports.
|
|
43
|
+
exports.STALE_BASE_VERSION_UPDATE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-base-version-update', 'The edit to {uri} was not applied: it was made to an older version of the document.');
|
|
44
|
+
/**
|
|
45
|
+
* {@link STALE_BASE_VERSION_UPDATE}'s counterpart for an editor's save the
|
|
46
|
+
* server refused, since the editor's buffer is not the text it holds. Its
|
|
47
|
+
* English keeps the same marker.
|
|
48
|
+
*/
|
|
49
|
+
exports.STALE_BASE_VERSION_SAVE = (0, primitives_1.defineMessage)('hydranium/protocol/stale-base-version-save', 'The save of {uri} was not applied: it was made to an older version of the document.');
|
|
50
|
+
/**
|
|
51
|
+
* Every JSON-RPC error code the framework raises, from any package, keyed by
|
|
52
|
+
* the error it identifies.
|
|
53
|
+
*
|
|
54
|
+
* The framework reserves the block 42000 to 42999 for these, and an adopter's
|
|
55
|
+
* own codes stay outside it: after an RPC a guard matches on the code alone, so
|
|
56
|
+
* an adopter's error carrying one of these reads as the framework's. A new code
|
|
57
|
+
* takes the next unused number in the block, whichever package raises it, and
|
|
58
|
+
* is declared here, where tests hold every code distinct and inside the block.
|
|
59
|
+
* The block sits clear of the range JSON-RPC 2.0 reserves for itself, -32768
|
|
60
|
+
* to -32000.
|
|
61
|
+
*/
|
|
62
|
+
exports.HYDRANIUM_ERROR_CODES = {
|
|
63
|
+
conflict: 42001,
|
|
64
|
+
noActiveProfile: 42002,
|
|
65
|
+
referenceSettleTimeout: 42003,
|
|
66
|
+
sessionClosed: 42004,
|
|
67
|
+
documentNotOpen: 42005,
|
|
68
|
+
duplicateClientId: 42006,
|
|
69
|
+
reservedClientId: 42007
|
|
70
|
+
};
|
|
24
71
|
/**
|
|
25
|
-
*
|
|
26
|
-
* Outside the reserved range (-32768 .. -32000) per JSON-RPC 2.0.
|
|
72
|
+
* JSON-RPC error code for {@link ConflictError}.
|
|
27
73
|
*
|
|
28
74
|
* The code is the load-bearing identifier across realm boundaries —
|
|
29
75
|
* `code` is a first-class field on the JSON-RPC error envelope and
|
|
30
76
|
* survives wire reconstruction; the custom `Error` subclass name does
|
|
31
77
|
* not.
|
|
32
78
|
*/
|
|
33
|
-
exports.CONFLICT_ERROR_CODE =
|
|
79
|
+
exports.CONFLICT_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.conflict;
|
|
34
80
|
/**
|
|
35
|
-
* Thrown by `
|
|
36
|
-
* supplied
|
|
81
|
+
* Thrown by a client session's `update` / `save` when the caller-
|
|
82
|
+
* supplied base version no longer matches the server's current text-
|
|
37
83
|
* document version for the same URI — i.e. the snapshot the caller
|
|
38
84
|
* authored against has been superseded by an intervening edit.
|
|
39
85
|
*
|
|
40
86
|
* Extends vscode-jsonrpc's {@link ResponseError} so the typed
|
|
41
87
|
* {@link ConflictErrorData} payload rides on the standard JSON-RPC
|
|
42
88
|
* error envelope (`code`, `message`, `data`) — all three fields are
|
|
43
|
-
* preserved by RPC reconstruction.
|
|
44
|
-
* the receiving side
|
|
45
|
-
* `err.data`
|
|
46
|
-
* `ResponseError`, so subclass getters / fields do not survive).
|
|
89
|
+
* preserved by RPC reconstruction. `createRpcProxy` revives it into
|
|
90
|
+
* this class on the receiving side; a path that does not leaves a
|
|
91
|
+
* plain `ResponseError`, readable through `err.data` only.
|
|
47
92
|
*
|
|
48
|
-
* Detection is
|
|
49
|
-
*
|
|
50
|
-
* no gating.
|
|
51
|
-
* posture, so headless / CLI / batch tooling with no meaningful based-on
|
|
52
|
-
* version can opt out explicitly.
|
|
93
|
+
* Detection is driven by the required `baseVersion` field of every write
|
|
94
|
+
* request; a caller with no meaningful base version passes
|
|
95
|
+
* `'any'` and gets no gating.
|
|
53
96
|
*
|
|
54
97
|
* Three reasonable adopter recovery strategies:
|
|
55
98
|
*
|
|
@@ -63,35 +106,227 @@ exports.CONFLICT_ERROR_CODE = 1001;
|
|
|
63
106
|
* No auto-retry or auto-merge ships by default.
|
|
64
107
|
*/
|
|
65
108
|
class ConflictError extends vscode_jsonrpc_1.ResponseError {
|
|
66
|
-
|
|
67
|
-
|
|
109
|
+
/** `message` words what was refused: an edit, or with {@link STALE_BASE_VERSION_SAVE} a save. */
|
|
110
|
+
constructor(uri, baseVersion, actualVersion, message = exports.STALE_BASE_VERSION_UPDATE) {
|
|
68
111
|
// The identity rides alongside the typed payload rather than replacing
|
|
69
|
-
// it:
|
|
70
|
-
//
|
|
71
|
-
super(exports.CONFLICT_ERROR_CODE,
|
|
112
|
+
// it: `isConflictError`'s name check is surface an adopter may bind, so
|
|
113
|
+
// adding the identity widens the payload rather than reshaping it.
|
|
114
|
+
super(exports.CONFLICT_ERROR_CODE, message.format({ uri }), {
|
|
115
|
+
uri,
|
|
116
|
+
baseVersion,
|
|
117
|
+
actualVersion,
|
|
118
|
+
...(0, primitives_1.messageData)(message, { uri })
|
|
119
|
+
});
|
|
72
120
|
this.name = 'ConflictError';
|
|
73
121
|
// ResponseError's constructor calls `Object.setPrototypeOf(this,
|
|
74
122
|
// ResponseError.prototype)` to keep its own prototype chain intact across
|
|
75
123
|
// transpilation targets; that resets us to ResponseError, hiding the
|
|
76
124
|
// ConflictError-specific getters. Restore the prototype here so
|
|
77
|
-
// `err.uri` / `.
|
|
125
|
+
// `err.uri` / `.baseVersion` / `.actualVersion` resolve through this
|
|
126
|
+
// class.
|
|
78
127
|
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
79
128
|
}
|
|
129
|
+
/** The document whose version moved, see {@link ConflictErrorData.uri}. */
|
|
80
130
|
get uri() {
|
|
81
131
|
return this.data.uri;
|
|
82
132
|
}
|
|
83
|
-
|
|
84
|
-
|
|
133
|
+
/**
|
|
134
|
+
* The base version the caller authored against. Not `expected`, and its
|
|
135
|
+
* sibling not `actual`: a test reporter reads that pair as an assertion
|
|
136
|
+
* failure and reports nothing of the real one.
|
|
137
|
+
*/
|
|
138
|
+
get baseVersion() {
|
|
139
|
+
return this.data.baseVersion;
|
|
85
140
|
}
|
|
86
|
-
|
|
87
|
-
|
|
141
|
+
/** The server's version at the time of the throw. Not `actual`, see {@link baseVersion}. */
|
|
142
|
+
get actualVersion() {
|
|
143
|
+
return this.data.actualVersion;
|
|
88
144
|
}
|
|
89
145
|
}
|
|
90
146
|
exports.ConflictError = ConflictError;
|
|
147
|
+
/**
|
|
148
|
+
* JSON-RPC code for {@link SessionClosedError}, beside {@link CONFLICT_ERROR_CODE}
|
|
149
|
+
* and for the same reason: the code survives reconstruction, the class does not.
|
|
150
|
+
*/
|
|
151
|
+
exports.SESSION_CLOSED_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.sessionClosed;
|
|
152
|
+
/** JSON-RPC code for {@link DocumentNotOpenError}. */
|
|
153
|
+
exports.DOCUMENT_NOT_OPEN_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.documentNotOpen;
|
|
154
|
+
/** JSON-RPC code for {@link DuplicateClientIdError}. */
|
|
155
|
+
exports.DUPLICATE_CLIENT_ID_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.duplicateClientId;
|
|
156
|
+
/** JSON-RPC code for {@link ReservedClientIdError}. */
|
|
157
|
+
exports.RESERVED_CLIENT_ID_ERROR_CODE = exports.HYDRANIUM_ERROR_CODES.reservedClientId;
|
|
158
|
+
/**
|
|
159
|
+
* The catalogue declaration behind {@link SessionClosedError}'s default
|
|
160
|
+
* sentence. It names no client id: the sentence can reach an end user, and the
|
|
161
|
+
* id stays in {@link SessionClosedErrorData.clientId} for whoever needs it.
|
|
162
|
+
*/
|
|
163
|
+
exports.SESSION_CLOSED = (0, primitives_1.defineMessage)('hydranium/protocol/session-closed', 'The editing session has ended.');
|
|
164
|
+
/**
|
|
165
|
+
* Thrown by every call on a client session after it ended, and by an open that
|
|
166
|
+
* was still in flight when its session ended: by the server for its sessions,
|
|
167
|
+
* and by a client-side `DataSession` once disposed, so a caller handles both
|
|
168
|
+
* the same way. A caller recognises it with {@link isSessionClosedError}, never
|
|
169
|
+
* by its sentence.
|
|
170
|
+
*/
|
|
171
|
+
class SessionClosedError extends vscode_jsonrpc_1.ResponseError {
|
|
172
|
+
/**
|
|
173
|
+
* `message` replaces the default English, for a caller that knows more than
|
|
174
|
+
* that the session is gone. The identity stays {@link SESSION_CLOSED}'s, so a
|
|
175
|
+
* translating renderer renders the catalogue sentence in its place.
|
|
176
|
+
*/
|
|
177
|
+
constructor(clientId, message = exports.SESSION_CLOSED.format()) {
|
|
178
|
+
super(exports.SESSION_CLOSED_ERROR_CODE, message, { clientId, ...(0, primitives_1.messageData)(exports.SESSION_CLOSED) });
|
|
179
|
+
this.name = 'SessionClosedError';
|
|
180
|
+
// `ResponseError` resets the prototype to its own; see `ConflictError`.
|
|
181
|
+
Object.setPrototypeOf(this, SessionClosedError.prototype);
|
|
182
|
+
}
|
|
183
|
+
get clientId() {
|
|
184
|
+
return this.data.clientId;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.SessionClosedError = SessionClosedError;
|
|
188
|
+
/**
|
|
189
|
+
* The catalogue declaration behind {@link DocumentNotOpenError}'s sentence. The
|
|
190
|
+
* client id stays in {@link DocumentNotOpenErrorData.clientId}.
|
|
191
|
+
*/
|
|
192
|
+
exports.DOCUMENT_NOT_OPEN = (0, primitives_1.defineMessage)('hydranium/protocol/document-not-open', 'The document {uri} is not open in this editing session.');
|
|
193
|
+
/**
|
|
194
|
+
* Thrown when a client session writes a document it does not have open.
|
|
195
|
+
*
|
|
196
|
+
* A session writes only what it has open, so this is the answer both to a write
|
|
197
|
+
* that never opened and to one whose open was closed underneath it — by the
|
|
198
|
+
* session itself, or by the document being deleted.
|
|
199
|
+
*/
|
|
200
|
+
class DocumentNotOpenError extends vscode_jsonrpc_1.ResponseError {
|
|
201
|
+
constructor(uri, clientId) {
|
|
202
|
+
super(exports.DOCUMENT_NOT_OPEN_ERROR_CODE, exports.DOCUMENT_NOT_OPEN.format({ uri }), {
|
|
203
|
+
uri,
|
|
204
|
+
clientId,
|
|
205
|
+
...(0, primitives_1.messageData)(exports.DOCUMENT_NOT_OPEN, { uri })
|
|
206
|
+
});
|
|
207
|
+
this.name = 'DocumentNotOpenError';
|
|
208
|
+
Object.setPrototypeOf(this, DocumentNotOpenError.prototype);
|
|
209
|
+
}
|
|
210
|
+
get uri() {
|
|
211
|
+
return this.data.uri;
|
|
212
|
+
}
|
|
213
|
+
get clientId() {
|
|
214
|
+
return this.data.clientId;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.DocumentNotOpenError = DocumentNotOpenError;
|
|
218
|
+
/**
|
|
219
|
+
* The catalogue declaration behind {@link DuplicateClientIdError}'s sentence.
|
|
220
|
+
* The client id stays in {@link DuplicateClientIdErrorData.clientId}.
|
|
221
|
+
*/
|
|
222
|
+
exports.DUPLICATE_CLIENT_ID = (0, primitives_1.defineMessage)('hydranium/protocol/duplicate-client-id', 'Could not start an editing session: its identifier is still in use by another editor.');
|
|
223
|
+
/**
|
|
224
|
+
* Thrown when a client session is started under an id that is already live in
|
|
225
|
+
* the process. The id frees up once its holder ends or closes its last
|
|
226
|
+
* document, so a caller may retry.
|
|
227
|
+
*
|
|
228
|
+
* Ids are unique process-wide because the id is also the author label on every
|
|
229
|
+
* version and the key a client recognises its own echoes by; two participants
|
|
230
|
+
* sharing one would each take the other's writes for their own.
|
|
231
|
+
*/
|
|
232
|
+
class DuplicateClientIdError extends vscode_jsonrpc_1.ResponseError {
|
|
233
|
+
constructor(clientId) {
|
|
234
|
+
super(exports.DUPLICATE_CLIENT_ID_ERROR_CODE, exports.DUPLICATE_CLIENT_ID.format(), { clientId, ...(0, primitives_1.messageData)(exports.DUPLICATE_CLIENT_ID) });
|
|
235
|
+
this.name = 'DuplicateClientIdError';
|
|
236
|
+
Object.setPrototypeOf(this, DuplicateClientIdError.prototype);
|
|
237
|
+
}
|
|
238
|
+
get clientId() {
|
|
239
|
+
return this.data.clientId;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
exports.DuplicateClientIdError = DuplicateClientIdError;
|
|
243
|
+
/**
|
|
244
|
+
* Thrown when a client session is started under an id the framework reserves
|
|
245
|
+
* for one of its own participants. A reserved id never frees up, so a caller
|
|
246
|
+
* that retries on {@link DuplicateClientIdError} stops on this one.
|
|
247
|
+
*
|
|
248
|
+
* It carries no message identity: a host that picks a reserved id has a bug,
|
|
249
|
+
* and no sentence addressed to an end user is true for it.
|
|
250
|
+
*/
|
|
251
|
+
class ReservedClientIdError extends vscode_jsonrpc_1.ResponseError {
|
|
252
|
+
constructor(clientId) {
|
|
253
|
+
super(exports.RESERVED_CLIENT_ID_ERROR_CODE, `Client id ${clientId} is reserved for a framework participant`, { clientId });
|
|
254
|
+
this.name = 'ReservedClientIdError';
|
|
255
|
+
Object.setPrototypeOf(this, ReservedClientIdError.prototype);
|
|
256
|
+
}
|
|
257
|
+
get clientId() {
|
|
258
|
+
return this.data.clientId;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.ReservedClientIdError = ReservedClientIdError;
|
|
262
|
+
/** One entry per typed error class, keyed by its code; a class without one reaches a caller as a plain `ResponseError`. */
|
|
263
|
+
const PROTOCOL_ERROR_REVIVERS = new Map([
|
|
264
|
+
[
|
|
265
|
+
exports.CONFLICT_ERROR_CODE,
|
|
266
|
+
({ uri, baseVersion, actualVersion }) => typeof uri === 'string' && typeof baseVersion === 'number' && typeof actualVersion === 'number'
|
|
267
|
+
? new ConflictError(uri, (0, base_version_1.asModelVersion)(baseVersion), actualVersion)
|
|
268
|
+
: undefined
|
|
269
|
+
],
|
|
270
|
+
[exports.SESSION_CLOSED_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new SessionClosedError(clientId) : undefined)],
|
|
271
|
+
[
|
|
272
|
+
exports.DOCUMENT_NOT_OPEN_ERROR_CODE,
|
|
273
|
+
({ uri, clientId }) => (typeof uri === 'string' && typeof clientId === 'string' ? new DocumentNotOpenError(uri, clientId) : undefined)
|
|
274
|
+
],
|
|
275
|
+
[exports.DUPLICATE_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new DuplicateClientIdError(clientId) : undefined)],
|
|
276
|
+
[exports.RESERVED_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new ReservedClientIdError(clientId) : undefined)]
|
|
277
|
+
]);
|
|
278
|
+
/**
|
|
279
|
+
* Whether `error` is a `ResponseError` from any copy of `vscode-jsonrpc`. An
|
|
280
|
+
* install holds several copies, and `instanceof` recognises only its own. An
|
|
281
|
+
* error that merely carries an integer `code` has no `toJson`, and is not one.
|
|
282
|
+
*/
|
|
283
|
+
function isResponseError(error) {
|
|
284
|
+
return (error instanceof Error && 'code' in error && Number.isInteger(error.code) && 'toJson' in error && typeof error.toJson === 'function');
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* `error` as an instance of the typed error class its code names, with its
|
|
288
|
+
* message, data and stack kept, or `error` itself when its code names none or
|
|
289
|
+
* its data lacks the fields that class reads.
|
|
290
|
+
* An RPC reconstructs every rejection as a plain `ResponseError`, which has
|
|
291
|
+
* none of the class getters.
|
|
292
|
+
*/
|
|
293
|
+
function reviveProtocolError(error) {
|
|
294
|
+
if (!isResponseError(error) || error.data === null || typeof error.data !== 'object') {
|
|
295
|
+
return error;
|
|
296
|
+
}
|
|
297
|
+
const revived = PROTOCOL_ERROR_REVIVERS.get(error.code)?.({ ...error.data });
|
|
298
|
+
if (!revived) {
|
|
299
|
+
return error;
|
|
300
|
+
}
|
|
301
|
+
return Object.assign(revived, { message: error.message, data: error.data, stack: error.stack });
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
305
|
+
* when it arrives as a plain `ResponseError`, through a path that does not
|
|
306
|
+
* {@link reviveProtocolError revive} it.
|
|
307
|
+
*/
|
|
308
|
+
function isSessionClosedError(error) {
|
|
309
|
+
return hasErrorIdentity(error, 'SessionClosedError', exports.SESSION_CLOSED_ERROR_CODE);
|
|
310
|
+
}
|
|
311
|
+
/** Whether `error` is a {@link DocumentNotOpenError}; see {@link isSessionClosedError}. */
|
|
312
|
+
function isDocumentNotOpenError(error) {
|
|
313
|
+
return hasErrorIdentity(error, 'DocumentNotOpenError', exports.DOCUMENT_NOT_OPEN_ERROR_CODE);
|
|
314
|
+
}
|
|
315
|
+
/** Whether `error` is a {@link DuplicateClientIdError}; see {@link isSessionClosedError}. */
|
|
316
|
+
function isDuplicateClientIdError(error) {
|
|
317
|
+
return hasErrorIdentity(error, 'DuplicateClientIdError', exports.DUPLICATE_CLIENT_ID_ERROR_CODE);
|
|
318
|
+
}
|
|
319
|
+
/** Whether `error` is a {@link ReservedClientIdError}; see {@link isSessionClosedError}. */
|
|
320
|
+
function isReservedClientIdError(error) {
|
|
321
|
+
return hasErrorIdentity(error, 'ReservedClientIdError', exports.RESERVED_CLIENT_ID_ERROR_CODE);
|
|
322
|
+
}
|
|
323
|
+
function hasErrorIdentity(error, name, code) {
|
|
324
|
+
return error instanceof Error && (error.name === name || error.code === code);
|
|
325
|
+
}
|
|
91
326
|
/** Marker substring present in every {@link ConflictError} message, used by
|
|
92
327
|
* {@link isConflictError} as a fallback when a transport re-wraps the error
|
|
93
328
|
* and drops the JSON-RPC code. */
|
|
94
|
-
const CONFLICT_ERROR_MESSAGE_MARKER = '
|
|
329
|
+
const CONFLICT_ERROR_MESSAGE_MARKER = ': it was made to an older version of the document';
|
|
95
330
|
/**
|
|
96
331
|
* Type guard for {@link ConflictError}. Detection ladder:
|
|
97
332
|
*
|
|
@@ -101,11 +336,13 @@ const CONFLICT_ERROR_MESSAGE_MARKER = 'Stale-based update for ';
|
|
|
101
336
|
* canonical wire-side check; the JSON-RPC `code` field is preserved
|
|
102
337
|
* across reconstruction, so any adopter catching after an RPC call
|
|
103
338
|
* hits this branch.
|
|
104
|
-
* 3. `error.message
|
|
105
|
-
*
|
|
339
|
+
* 3. `error.message` contains the marker the English of
|
|
340
|
+
* {@link STALE_BASE_VERSION_UPDATE} and
|
|
341
|
+
* {@link STALE_BASE_VERSION_SAVE} carries — fallback for transports
|
|
342
|
+
* that re-wrap the message and drop the code (rare).
|
|
106
343
|
*
|
|
107
|
-
* `instanceof ConflictError` alone
|
|
108
|
-
*
|
|
344
|
+
* `instanceof ConflictError` alone returns `false` on a rejection that was
|
|
345
|
+
* not {@link reviveProtocolError revived}, so callers do not use it.
|
|
109
346
|
*/
|
|
110
347
|
function isConflictError(error) {
|
|
111
348
|
if (!(error instanceof Error)) {
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;;;;;;;;AAElF,mDAA+C;AAC/C,sDAA8F;AAC9F,+DAAmG;AAEnG;;;;;;;;;;GAUG;AAEH;;;;;;;;;GASG;AACU,QAAA,yBAAyB,GAAG,IAAA,0BAAa,EACnD,8CAA8C,EAC9C,qFAAqF,CACvF,CAAC;AAEF;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,IAAA,0BAAa,EACjD,4CAA4C,EAC5C,qFAAqF,CACvF,CAAC;AAEF;;;;;;;;;;;GAWG;AACU,QAAA,qBAAqB,GAAG;IAClC,QAAQ,EAAE,KAAK;IACf,eAAe,EAAE,KAAK;IACtB,sBAAsB,EAAE,KAAK;IAC7B,aAAa,EAAE,KAAK;IACpB,eAAe,EAAE,KAAK;IACtB,iBAAiB,EAAE,KAAK;IACxB,gBAAgB,EAAE,KAAK;CAChB,CAAC;AAEX;;;;;;;GAOG;AACU,QAAA,mBAAmB,GAAG,QAAA,qBAAqB,CAAC,QAAQ,CAAC;AAelE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,mBAA2B,SAAQ,8BAAgC;IAChE,iGAAiG;IACjG,YACG,GAAW,EACX,WAAyB,EACzB,aAA0B,EAC1B,OAAO,GAAsE,QAAA,yBAAyB;QAEtG,uEAAuE;QACvE,wEAAwE;QACxE,mEAAmE;QACnE,KAAK,CAAC,QAAA,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG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AAO,IAAI,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAI,KAAyC,CAAC,IAAI,CAAC;IAC7D,IAAI,IAAI,KAAK,QAAA,mBAAmB,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACf,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
/** Options of {@link formatLogArg}. An object, so that a `map` index cannot be passed as one. */
|
|
10
|
+
export interface FormatLogArgOptions {
|
|
11
|
+
/** The `space` argument of `JSON.stringify`; compact where omitted. */
|
|
12
|
+
readonly indent?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Render a log argument as text for a log line:
|
|
16
|
+
* - a string as it is;
|
|
17
|
+
* - an error by its stack and causes;
|
|
18
|
+
* - another object as JSON, cut to a bounded size;
|
|
19
|
+
* - anything else by its description, as is an object JSON renders as nothing
|
|
20
|
+
* or cannot render.
|
|
21
|
+
*
|
|
22
|
+
* The cut is needed because the log call serialises synchronously and every
|
|
23
|
+
* Langium AST node is cyclic. The JSON stops at `LOG_ARG_DEPTH` levels,
|
|
24
|
+
* `LOG_ARG_ITEMS` items or keys and `LOG_ARG_STRING_LENGTH` characters per
|
|
25
|
+
* string or key, and at about `LOG_ARG_LENGTH` in all. A reference back to an
|
|
26
|
+
* object that contains it reads `[Circular]`, and a BigInt its digits; the
|
|
27
|
+
* markers are JSON strings. `util.inspect` would cut too, but is Node-only.
|
|
28
|
+
*
|
|
29
|
+
* Never throws, since a log call that throws loses the line and interrupts its
|
|
30
|
+
* caller. A `%s`-style specifier is not substituted.
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatLogArg(value: unknown, options?: FormatLogArgOptions): string;
|
|
33
|
+
//# sourceMappingURL=format-log-arg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-log-arg.d.ts","sourceRoot":"","sources":["../src/format-log-arg.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAgBlF,iGAAiG;AACjG,MAAM,WAAW,mBAAmB;IACjC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,CAiBtF"}
|
|
@@ -0,0 +1,158 @@
|
|
|
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.formatLogArg = formatLogArg;
|
|
12
|
+
const primitives_1 = require("./messages/primitives");
|
|
13
|
+
/** How deep an object argument is rendered; a deeper object reads `[Object]` or `[Array]`. */
|
|
14
|
+
const LOG_ARG_DEPTH = 2;
|
|
15
|
+
/** How many items or keys of one array or object are rendered. */
|
|
16
|
+
const LOG_ARG_ITEMS = 100;
|
|
17
|
+
/** How many characters of one string or key inside an object argument are rendered. */
|
|
18
|
+
const LOG_ARG_STRING_LENGTH = 10_000;
|
|
19
|
+
/**
|
|
20
|
+
* About how many characters one argument renders, since the limits above
|
|
21
|
+
* multiply. The entry that would pass it reads `...`; later ones are left out.
|
|
22
|
+
*/
|
|
23
|
+
const LOG_ARG_LENGTH = 100_000;
|
|
24
|
+
/**
|
|
25
|
+
* Render a log argument as text for a log line:
|
|
26
|
+
* - a string as it is;
|
|
27
|
+
* - an error by its stack and causes;
|
|
28
|
+
* - another object as JSON, cut to a bounded size;
|
|
29
|
+
* - anything else by its description, as is an object JSON renders as nothing
|
|
30
|
+
* or cannot render.
|
|
31
|
+
*
|
|
32
|
+
* The cut is needed because the log call serialises synchronously and every
|
|
33
|
+
* Langium AST node is cyclic. The JSON stops at `LOG_ARG_DEPTH` levels,
|
|
34
|
+
* `LOG_ARG_ITEMS` items or keys and `LOG_ARG_STRING_LENGTH` characters per
|
|
35
|
+
* string or key, and at about `LOG_ARG_LENGTH` in all. A reference back to an
|
|
36
|
+
* object that contains it reads `[Circular]`, and a BigInt its digits; the
|
|
37
|
+
* markers are JSON strings. `util.inspect` would cut too, but is Node-only.
|
|
38
|
+
*
|
|
39
|
+
* Never throws, since a log call that throws loses the line and interrupts its
|
|
40
|
+
* caller. A `%s`-style specifier is not substituted.
|
|
41
|
+
*/
|
|
42
|
+
function formatLogArg(value, options = {}) {
|
|
43
|
+
if (typeof value === 'string') {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
if (typeof value === 'object' && value !== null) {
|
|
47
|
+
try {
|
|
48
|
+
// `undefined` where `toJSON` returns nothing.
|
|
49
|
+
const json = value instanceof Error ? undefined : JSON.stringify(value, boundedReplacer(options.indent), options.indent);
|
|
50
|
+
if (json !== undefined) {
|
|
51
|
+
return json;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// A throwing getter or `toJSON`, or a revoked proxy; described below instead.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return (0, primitives_1.describeErrorWithStack)(value);
|
|
59
|
+
}
|
|
60
|
+
function boundedReplacer(indent) {
|
|
61
|
+
// Keyed by the object last entered; JSON is written depth first, so its entry is on the path being written.
|
|
62
|
+
const visits = new Map();
|
|
63
|
+
const isOnPath = (value, holder) => holder !== undefined && ((visits.get(holder)?.source ?? holder) === value || isOnPath(value, visits.get(holder)?.parent));
|
|
64
|
+
// As `JSON.stringify` clamps its `space`.
|
|
65
|
+
const space = Math.min(10, Math.max(0, Math.floor(indent ?? 0)));
|
|
66
|
+
let remaining = LOG_ARG_LENGTH;
|
|
67
|
+
let exhausted = false;
|
|
68
|
+
return function (key, raw) {
|
|
69
|
+
if (exhausted) {
|
|
70
|
+
// In an object the entry is left out; in an array it reads `null`.
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
// A boxed primitive is written as its value, so it is cut as one.
|
|
74
|
+
const value = raw instanceof String || raw instanceof Number || raw instanceof Boolean || raw instanceof BigInt ? raw.valueOf() : raw;
|
|
75
|
+
const depth = (visits.get(this)?.depth ?? -1) + 1;
|
|
76
|
+
const rendered = render(value, depth, this);
|
|
77
|
+
const isObject = typeof rendered === 'object' && rendered !== null;
|
|
78
|
+
// What this entry writes: its value, its key unless it is an item, and the punctuation and indent around them.
|
|
79
|
+
const written = isObject ? undefined : JSON.stringify(rendered);
|
|
80
|
+
// A value JSON cannot write is left out of an object, key and all, and written as `null` in an array.
|
|
81
|
+
const leftOut = !isObject && written === undefined && !Array.isArray(this);
|
|
82
|
+
const valueLength = isObject ? 2 : (written?.length ?? 4);
|
|
83
|
+
const keyLength = depth === 0 || Array.isArray(this) ? 0 : JSON.stringify(key).length + 1 + (space > 0 ? 1 : 0);
|
|
84
|
+
const layoutLength = 1 + (space > 0 ? (1 + space * depth) * (isObject ? 2 : 1) : 0);
|
|
85
|
+
const length = leftOut ? 0 : valueLength + keyLength + layoutLength;
|
|
86
|
+
if (length > remaining) {
|
|
87
|
+
exhausted = true;
|
|
88
|
+
return '...';
|
|
89
|
+
}
|
|
90
|
+
remaining -= length;
|
|
91
|
+
if (isObject) {
|
|
92
|
+
visits.set(rendered, { parent: this, depth, source: value });
|
|
93
|
+
}
|
|
94
|
+
return rendered;
|
|
95
|
+
};
|
|
96
|
+
function render(value, depth, holder) {
|
|
97
|
+
if (typeof value === 'string') {
|
|
98
|
+
return cutString(value);
|
|
99
|
+
}
|
|
100
|
+
if (typeof value === 'bigint') {
|
|
101
|
+
return String(value);
|
|
102
|
+
}
|
|
103
|
+
if (typeof value !== 'object' || value === null) {
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
if (isOnPath(value, holder)) {
|
|
107
|
+
return '[Circular]';
|
|
108
|
+
}
|
|
109
|
+
if (depth > LOG_ARG_DEPTH) {
|
|
110
|
+
return Array.isArray(value) || isTypedArray(value) ? '[Array]' : '[Object]';
|
|
111
|
+
}
|
|
112
|
+
return cut(value);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function cutString(value) {
|
|
116
|
+
const more = value.length - LOG_ARG_STRING_LENGTH;
|
|
117
|
+
return more > 0 ? `${value.slice(0, LOG_ARG_STRING_LENGTH)}... ${more} more characters` : value;
|
|
118
|
+
}
|
|
119
|
+
function isTypedArray(value) {
|
|
120
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* `value`, or a copy of its first {@link LOG_ARG_ITEMS} items or keys, keys cut
|
|
124
|
+
* as strings are, with a note of how many more there are. A typed array is
|
|
125
|
+
* copied to an array, which reads its items without listing its keys.
|
|
126
|
+
*/
|
|
127
|
+
function cut(value) {
|
|
128
|
+
if (Array.isArray(value) || isTypedArray(value)) {
|
|
129
|
+
const more = value.length - LOG_ARG_ITEMS;
|
|
130
|
+
const items = Array.from({ length: Math.min(value.length, LOG_ARG_ITEMS) }, (_, i) => value[i]);
|
|
131
|
+
return more > 0 ? [...items, `... ${more} more items`] : Array.isArray(value) ? value : items;
|
|
132
|
+
}
|
|
133
|
+
// Linear in the keys: no API lists the first few alone, and `JSON.stringify` would list them all too.
|
|
134
|
+
const keys = Object.keys(value);
|
|
135
|
+
const more = keys.length - LOG_ARG_ITEMS;
|
|
136
|
+
const kept = keys.slice(0, LOG_ARG_ITEMS);
|
|
137
|
+
if (more <= 0 && kept.every(key => key.length <= LOG_ARG_STRING_LENGTH)) {
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
140
|
+
// No prototype, so a `__proto__` key is an entry like any other.
|
|
141
|
+
const copy = Object.create(null);
|
|
142
|
+
// A cut key or the note can equal a key already written; numbered, so neither entry is lost.
|
|
143
|
+
const add = (key, entry) => {
|
|
144
|
+
let unique = key;
|
|
145
|
+
for (let i = 2; unique in copy; i++) {
|
|
146
|
+
unique = `${key} (${i})`;
|
|
147
|
+
}
|
|
148
|
+
copy[unique] = entry;
|
|
149
|
+
};
|
|
150
|
+
for (const key of kept) {
|
|
151
|
+
add(cutString(key), value[key]);
|
|
152
|
+
}
|
|
153
|
+
if (more > 0) {
|
|
154
|
+
add(`... ${more} more keys`, '...');
|
|
155
|
+
}
|
|
156
|
+
return copy;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=format-log-arg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-log-arg.js","sourceRoot":"","sources":["../src/format-log-arg.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,sDAA+D;AAE/D,8FAA8F;AAC9F,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,kEAAkE;AAClE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,uFAAuF;AACvF,MAAM,qBAAqB,GAAG,MAAM,CAAC;AACrC;;;GAGG;AACH,MAAM,cAAc,GAAG,OAAO,CAAC;AAQ/B;;;;;;;;;;;;;;;;;GAiBG;AACH,sBAA6B,KAAc,EAAE,OAAO,GAAwB,EAAE;IAC3E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,E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AAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IAC1C,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,qBAAqB,CAAC,EAAE,CAAC;QACvE,OAAO,KAAK,CAAC;IAChB,CAAC;IACD,iEAAiE;IACjE,MAAM,IAAI,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1D,6FAA6F;IAC7F,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,KAAc,EAAQ,EAAE;QAC/C,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IACxB,CAAC,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACtB,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAG,KAAiC,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACZ,GAAG,CAAC,OAAO,IAAI,YAAY,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
* A request the server answers, with an {@link EditsSettledAction}, once every
|
|
11
|
+
* edit the client sent before it has been handled and its text has reached
|
|
12
|
+
* the language client, so the client knows those edits are answered.
|
|
13
|
+
*
|
|
14
|
+
* An operation has no answer of its own: the server replies with a model
|
|
15
|
+
* update and a dirty state, with a message, or with nothing at all when the
|
|
16
|
+
* operation changed nothing. The server handles a client's actions one at a
|
|
17
|
+
* time, so a request sent after the edits is answered after them, whatever
|
|
18
|
+
* each one answered. A server that fails it answers with a GLSP
|
|
19
|
+
* `RejectAction`, which ends the wait too.
|
|
20
|
+
*/
|
|
21
|
+
export interface RequestEditsSettledAction {
|
|
22
|
+
/** Answered only by a server that advertises this kind. The framework's dispatcher sends none to a server that does not. */
|
|
23
|
+
kind: typeof RequestEditsSettledAction.KIND;
|
|
24
|
+
/** The id the response echoes as its `responseId`. Empty until the dispatcher assigns one. */
|
|
25
|
+
requestId: string;
|
|
26
|
+
/**
|
|
27
|
+
* How long the server waits before it rejects the request, as it does any
|
|
28
|
+
* request; a rejection then means not settled, and the answer that follows
|
|
29
|
+
* is dropped. GLSP's `requestUntil` sets one; `request` leaves it unset.
|
|
30
|
+
*/
|
|
31
|
+
timeout?: number;
|
|
32
|
+
/** GLSP's typing marker for the response. Never set. */
|
|
33
|
+
readonly _?: EditsSettledAction;
|
|
34
|
+
}
|
|
35
|
+
export declare namespace RequestEditsSettledAction {
|
|
36
|
+
const KIND = "hydraniumRequestEditsSettled";
|
|
37
|
+
function create(options?: {
|
|
38
|
+
requestId?: string;
|
|
39
|
+
}): RequestEditsSettledAction;
|
|
40
|
+
}
|
|
41
|
+
/** The server's answer to a {@link RequestEditsSettledAction}. */
|
|
42
|
+
export interface EditsSettledAction {
|
|
43
|
+
/** No client handler takes this kind: the dispatcher settles the request by {@link responseId} instead. */
|
|
44
|
+
kind: typeof EditsSettledAction.KIND;
|
|
45
|
+
/** The `requestId` of the request this answers. The server's dispatcher sets it. */
|
|
46
|
+
responseId: string;
|
|
47
|
+
}
|
|
48
|
+
export declare namespace EditsSettledAction {
|
|
49
|
+
const KIND = "hydraniumEditsSettled";
|
|
50
|
+
function create(options?: {
|
|
51
|
+
responseId?: string;
|
|
52
|
+
}): EditsSettledAction;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=glsp-edits-settled-actions.d.ts.map
|