@hydranium/protocol 1.0.0-next.35 → 1.0.0-next.351
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
package/src/debouncer.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import { type Clock } from './clock';
|
|
10
|
+
import { type Clock, type Stopwatch } from './clock';
|
|
11
11
|
import { ObservableValue, type MaybeObservableValue } from './observable-value';
|
|
12
12
|
import { type Disposable } from './util';
|
|
13
13
|
|
|
@@ -53,8 +53,8 @@ export class Debouncer implements Disposable {
|
|
|
53
53
|
protected readonly delay: ObservableValue<number>;
|
|
54
54
|
protected readonly maxWaitMs?: number;
|
|
55
55
|
protected timer?: Disposable;
|
|
56
|
-
/**
|
|
57
|
-
protected
|
|
56
|
+
/** Running since the first {@link schedule} of the current pending window; drives {@link DebouncerOptions.maxWaitMs}. */
|
|
57
|
+
protected sinceFirstSchedule?: Stopwatch;
|
|
58
58
|
|
|
59
59
|
constructor(
|
|
60
60
|
protected readonly clock: Clock,
|
|
@@ -77,13 +77,10 @@ export class Debouncer implements Disposable {
|
|
|
77
77
|
* elapses since the first pending call.
|
|
78
78
|
*/
|
|
79
79
|
schedule(): void {
|
|
80
|
-
|
|
81
|
-
if (this.firstScheduledAt === undefined) {
|
|
82
|
-
this.firstScheduledAt = now;
|
|
83
|
-
}
|
|
80
|
+
this.sinceFirstSchedule ??= this.clock.stopwatch();
|
|
84
81
|
let wait = Math.max(0, this.delay.value);
|
|
85
82
|
if (this.maxWaitMs !== undefined) {
|
|
86
|
-
const untilCeiling = this.
|
|
83
|
+
const untilCeiling = this.maxWaitMs - this.sinceFirstSchedule.elapsedMs;
|
|
87
84
|
wait = Math.min(wait, Math.max(0, untilCeiling));
|
|
88
85
|
}
|
|
89
86
|
this.timer?.dispose();
|
|
@@ -101,7 +98,7 @@ export class Debouncer implements Disposable {
|
|
|
101
98
|
cancel(): void {
|
|
102
99
|
this.timer?.dispose();
|
|
103
100
|
this.timer = undefined;
|
|
104
|
-
this.
|
|
101
|
+
this.sinceFirstSchedule = undefined;
|
|
105
102
|
}
|
|
106
103
|
|
|
107
104
|
/** Cancel any pending fire and release. */
|
|
@@ -112,7 +109,7 @@ export class Debouncer implements Disposable {
|
|
|
112
109
|
protected fire(): void {
|
|
113
110
|
this.timer?.dispose();
|
|
114
111
|
this.timer = undefined;
|
|
115
|
-
this.
|
|
112
|
+
this.sinceFirstSchedule = undefined;
|
|
116
113
|
this.fn();
|
|
117
114
|
}
|
|
118
115
|
}
|
package/src/errors.ts
CHANGED
|
@@ -9,62 +9,102 @@
|
|
|
9
9
|
|
|
10
10
|
import { ResponseError } from 'vscode-jsonrpc';
|
|
11
11
|
import { defineMessage, type HydraniumMessageData, messageData } from './messages/primitives';
|
|
12
|
+
import { asModelVersion, type ModelVersion, type TextVersion } from './model-service/base-version';
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Every error here is a typed error: a caller reacts to it, so it has a class,
|
|
16
|
+
* a JSON-RPC code and an `is*` guard, and an English message. A typed error
|
|
17
|
+
* also carries a message identity where the framework can write an end-user
|
|
18
|
+
* sentence that needs no context. A URI may stay in that sentence; a client id
|
|
19
|
+
* or a raw version stays out of it, worded or left to `data`.
|
|
20
|
+
*
|
|
21
|
+
* An error nothing reacts to does not belong here: it stays a plain `Error`, or
|
|
22
|
+
* a named subclass without a code, at its throw site, since a code and a guard
|
|
23
|
+
* are public API that no caller would use.
|
|
24
|
+
*/
|
|
12
25
|
|
|
13
26
|
/**
|
|
14
|
-
* The catalogue declaration behind {@link ConflictError}'s sentence.
|
|
27
|
+
* The catalogue declaration behind {@link ConflictError}'s sentence. It words
|
|
28
|
+
* the version mismatch rather than stating it: the two numbers mean nothing to
|
|
29
|
+
* an end user, and they stay in {@link ConflictErrorData}.
|
|
15
30
|
*
|
|
16
31
|
* Its English must keep containing {@link CONFLICT_ERROR_MESSAGE_MARKER}: the
|
|
17
32
|
* marker is tier 3 of {@link isConflictError}'s ladder, and it matches on text.
|
|
18
33
|
* That tier only ever works untranslated, which is why it is the last resort
|
|
19
34
|
* behind the numeric code rather than the primary check.
|
|
20
35
|
*/
|
|
21
|
-
export const
|
|
22
|
-
'hydranium/protocol/stale-
|
|
23
|
-
'
|
|
36
|
+
export const STALE_BASE_VERSION_UPDATE = defineMessage(
|
|
37
|
+
'hydranium/protocol/stale-base-version-update',
|
|
38
|
+
'The edit to {uri} was not applied: it was made to an older version of the document.'
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* {@link STALE_BASE_VERSION_UPDATE}'s counterpart for an editor's save the
|
|
43
|
+
* server refused, since the editor's buffer is not the text it holds. Its
|
|
44
|
+
* English keeps the same marker.
|
|
45
|
+
*/
|
|
46
|
+
export const STALE_BASE_VERSION_SAVE = defineMessage(
|
|
47
|
+
'hydranium/protocol/stale-base-version-save',
|
|
48
|
+
'The save of {uri} was not applied: it was made to an older version of the document.'
|
|
24
49
|
);
|
|
25
50
|
|
|
26
51
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
52
|
+
* Every JSON-RPC error code the framework raises, from any package, keyed by
|
|
53
|
+
* the error it identifies.
|
|
54
|
+
*
|
|
55
|
+
* The framework reserves the block 42000 to 42999 for these, and an adopter's
|
|
56
|
+
* own codes stay outside it: after an RPC a guard matches on the code alone, so
|
|
57
|
+
* an adopter's error carrying one of these reads as the framework's. A new code
|
|
58
|
+
* takes the next unused number in the block, whichever package raises it, and
|
|
59
|
+
* is declared here, where tests hold every code distinct and inside the block.
|
|
60
|
+
* The block sits clear of the range JSON-RPC 2.0 reserves for itself, -32768
|
|
61
|
+
* to -32000.
|
|
62
|
+
*/
|
|
63
|
+
export const HYDRANIUM_ERROR_CODES = {
|
|
64
|
+
conflict: 42001,
|
|
65
|
+
noActiveProfile: 42002,
|
|
66
|
+
referenceSettleTimeout: 42003,
|
|
67
|
+
sessionClosed: 42004,
|
|
68
|
+
documentNotOpen: 42005,
|
|
69
|
+
duplicateClientId: 42006,
|
|
70
|
+
reservedClientId: 42007
|
|
71
|
+
} as const;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* JSON-RPC error code for {@link ConflictError}.
|
|
29
75
|
*
|
|
30
76
|
* The code is the load-bearing identifier across realm boundaries —
|
|
31
77
|
* `code` is a first-class field on the JSON-RPC error envelope and
|
|
32
78
|
* survives wire reconstruction; the custom `Error` subclass name does
|
|
33
79
|
* not.
|
|
34
80
|
*/
|
|
35
|
-
export const CONFLICT_ERROR_CODE =
|
|
81
|
+
export const CONFLICT_ERROR_CODE = HYDRANIUM_ERROR_CODES.conflict;
|
|
36
82
|
|
|
37
|
-
/**
|
|
38
|
-
* Structured payload carried in {@link ConflictError.data}, and the only place
|
|
39
|
-
* a post-RPC caller can read the version mismatch from.
|
|
40
|
-
*/
|
|
83
|
+
/** Structured payload carried in {@link ConflictError.data}. */
|
|
41
84
|
export interface ConflictErrorData extends HydraniumMessageData {
|
|
42
85
|
readonly uri: string;
|
|
43
|
-
/** The
|
|
44
|
-
readonly
|
|
86
|
+
/** The base version the caller authored against. */
|
|
87
|
+
readonly baseVersion: ModelVersion;
|
|
45
88
|
/** The server's current text-document version at the time of the throw. */
|
|
46
|
-
readonly
|
|
89
|
+
readonly actualVersion: TextVersion;
|
|
47
90
|
}
|
|
48
91
|
|
|
49
92
|
/**
|
|
50
|
-
* Thrown by `
|
|
51
|
-
* supplied
|
|
93
|
+
* Thrown by a client session's `update` / `save` when the caller-
|
|
94
|
+
* supplied base version no longer matches the server's current text-
|
|
52
95
|
* document version for the same URI — i.e. the snapshot the caller
|
|
53
96
|
* authored against has been superseded by an intervening edit.
|
|
54
97
|
*
|
|
55
98
|
* Extends vscode-jsonrpc's {@link ResponseError} so the typed
|
|
56
99
|
* {@link ConflictErrorData} payload rides on the standard JSON-RPC
|
|
57
100
|
* error envelope (`code`, `message`, `data`) — all three fields are
|
|
58
|
-
* preserved by RPC reconstruction.
|
|
59
|
-
* the receiving side
|
|
60
|
-
* `err.data`
|
|
61
|
-
* `ResponseError`, so subclass getters / fields do not survive).
|
|
101
|
+
* preserved by RPC reconstruction. `createRpcProxy` revives it into
|
|
102
|
+
* this class on the receiving side; a path that does not leaves a
|
|
103
|
+
* plain `ResponseError`, readable through `err.data` only.
|
|
62
104
|
*
|
|
63
|
-
* Detection is
|
|
64
|
-
*
|
|
65
|
-
* no gating.
|
|
66
|
-
* posture, so headless / CLI / batch tooling with no meaningful based-on
|
|
67
|
-
* version can opt out explicitly.
|
|
105
|
+
* Detection is driven by the required `baseVersion` field of every write
|
|
106
|
+
* request; a caller with no meaningful base version passes
|
|
107
|
+
* `'any'` and gets no gating.
|
|
68
108
|
*
|
|
69
109
|
* Three reasonable adopter recovery strategies:
|
|
70
110
|
*
|
|
@@ -78,18 +118,29 @@ export interface ConflictErrorData extends HydraniumMessageData {
|
|
|
78
118
|
* No auto-retry or auto-merge ships by default.
|
|
79
119
|
*/
|
|
80
120
|
export class ConflictError extends ResponseError<ConflictErrorData> {
|
|
81
|
-
|
|
82
|
-
|
|
121
|
+
/** `message` words what was refused: an edit, or with {@link STALE_BASE_VERSION_SAVE} a save. */
|
|
122
|
+
constructor(
|
|
123
|
+
uri: string,
|
|
124
|
+
baseVersion: ModelVersion,
|
|
125
|
+
actualVersion: TextVersion,
|
|
126
|
+
message: typeof STALE_BASE_VERSION_UPDATE | typeof STALE_BASE_VERSION_SAVE = STALE_BASE_VERSION_UPDATE
|
|
127
|
+
) {
|
|
83
128
|
// The identity rides alongside the typed payload rather than replacing
|
|
84
|
-
// it:
|
|
85
|
-
//
|
|
86
|
-
super(CONFLICT_ERROR_CODE,
|
|
129
|
+
// it: `isConflictError`'s name check is surface an adopter may bind, so
|
|
130
|
+
// adding the identity widens the payload rather than reshaping it.
|
|
131
|
+
super(CONFLICT_ERROR_CODE, message.format({ uri }), {
|
|
132
|
+
uri,
|
|
133
|
+
baseVersion,
|
|
134
|
+
actualVersion,
|
|
135
|
+
...messageData(message, { uri })
|
|
136
|
+
});
|
|
87
137
|
this.name = 'ConflictError';
|
|
88
138
|
// ResponseError's constructor calls `Object.setPrototypeOf(this,
|
|
89
139
|
// ResponseError.prototype)` to keep its own prototype chain intact across
|
|
90
140
|
// transpilation targets; that resets us to ResponseError, hiding the
|
|
91
141
|
// ConflictError-specific getters. Restore the prototype here so
|
|
92
|
-
// `err.uri` / `.
|
|
142
|
+
// `err.uri` / `.baseVersion` / `.actualVersion` resolve through this
|
|
143
|
+
// class.
|
|
93
144
|
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
94
145
|
}
|
|
95
146
|
|
|
@@ -97,19 +148,252 @@ export class ConflictError extends ResponseError<ConflictErrorData> {
|
|
|
97
148
|
return this.data!.uri;
|
|
98
149
|
}
|
|
99
150
|
|
|
100
|
-
|
|
101
|
-
|
|
151
|
+
/**
|
|
152
|
+
* The base version the caller authored against. Not `expected`, and its
|
|
153
|
+
* sibling not `actual`: a test reporter reads that pair as an assertion
|
|
154
|
+
* failure and reports nothing of the real one.
|
|
155
|
+
*/
|
|
156
|
+
get baseVersion(): ModelVersion {
|
|
157
|
+
return this.data!.baseVersion;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** The server's version at the time of the throw. Not `actual`, see {@link baseVersion}. */
|
|
161
|
+
get actualVersion(): TextVersion {
|
|
162
|
+
return this.data!.actualVersion;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* JSON-RPC code for {@link SessionClosedError}, beside {@link CONFLICT_ERROR_CODE}
|
|
168
|
+
* and for the same reason: the code survives reconstruction, the class does not.
|
|
169
|
+
*/
|
|
170
|
+
export const SESSION_CLOSED_ERROR_CODE = HYDRANIUM_ERROR_CODES.sessionClosed;
|
|
171
|
+
/** JSON-RPC code for {@link DocumentNotOpenError}. */
|
|
172
|
+
export const DOCUMENT_NOT_OPEN_ERROR_CODE = HYDRANIUM_ERROR_CODES.documentNotOpen;
|
|
173
|
+
/** JSON-RPC code for {@link DuplicateClientIdError}. */
|
|
174
|
+
export const DUPLICATE_CLIENT_ID_ERROR_CODE = HYDRANIUM_ERROR_CODES.duplicateClientId;
|
|
175
|
+
/** JSON-RPC code for {@link ReservedClientIdError}. */
|
|
176
|
+
export const RESERVED_CLIENT_ID_ERROR_CODE = HYDRANIUM_ERROR_CODES.reservedClientId;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The catalogue declaration behind {@link SessionClosedError}'s default
|
|
180
|
+
* sentence. It names no client id: the sentence can reach an end user, and the
|
|
181
|
+
* id stays in {@link SessionClosedErrorData.clientId} for whoever needs it.
|
|
182
|
+
*/
|
|
183
|
+
export const SESSION_CLOSED = defineMessage('hydranium/protocol/session-closed', 'The editing session has ended.');
|
|
184
|
+
|
|
185
|
+
/** Structured payload carried in {@link SessionClosedError.data}. */
|
|
186
|
+
export interface SessionClosedErrorData extends HydraniumMessageData {
|
|
187
|
+
readonly clientId: string;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Thrown by every call on a client session after it ended, and by an open that
|
|
192
|
+
* was still in flight when its session ended: by the server for its sessions,
|
|
193
|
+
* and by a client-side `DataSession` once disposed, so a caller handles both
|
|
194
|
+
* the same way. A caller recognises it with {@link isSessionClosedError}, never
|
|
195
|
+
* by its sentence.
|
|
196
|
+
*/
|
|
197
|
+
export class SessionClosedError extends ResponseError<SessionClosedErrorData> {
|
|
198
|
+
/**
|
|
199
|
+
* `message` replaces the default English, for a caller that knows more than
|
|
200
|
+
* that the session is gone. The identity stays {@link SESSION_CLOSED}'s, so a
|
|
201
|
+
* translating renderer renders the catalogue sentence in its place.
|
|
202
|
+
*/
|
|
203
|
+
constructor(clientId: string, message = SESSION_CLOSED.format()) {
|
|
204
|
+
super(SESSION_CLOSED_ERROR_CODE, message, { clientId, ...messageData(SESSION_CLOSED) });
|
|
205
|
+
this.name = 'SessionClosedError';
|
|
206
|
+
// `ResponseError` resets the prototype to its own; see `ConflictError`.
|
|
207
|
+
Object.setPrototypeOf(this, SessionClosedError.prototype);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
get clientId(): string {
|
|
211
|
+
return this.data!.clientId;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The catalogue declaration behind {@link DocumentNotOpenError}'s sentence. The
|
|
217
|
+
* client id stays in {@link DocumentNotOpenErrorData.clientId}.
|
|
218
|
+
*/
|
|
219
|
+
export const DOCUMENT_NOT_OPEN = defineMessage(
|
|
220
|
+
'hydranium/protocol/document-not-open',
|
|
221
|
+
'The document {uri} is not open in this editing session.'
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
/** Structured payload carried in {@link DocumentNotOpenError.data}. */
|
|
225
|
+
export interface DocumentNotOpenErrorData extends HydraniumMessageData {
|
|
226
|
+
readonly uri: string;
|
|
227
|
+
readonly clientId: string;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Thrown when a client session writes a document it does not have open.
|
|
232
|
+
*
|
|
233
|
+
* A session writes only what it has open, so this is the answer both to a write
|
|
234
|
+
* that never opened and to one whose open was closed underneath it — by the
|
|
235
|
+
* session itself, or by the document being deleted.
|
|
236
|
+
*/
|
|
237
|
+
export class DocumentNotOpenError extends ResponseError<DocumentNotOpenErrorData> {
|
|
238
|
+
constructor(uri: string, clientId: string) {
|
|
239
|
+
super(DOCUMENT_NOT_OPEN_ERROR_CODE, DOCUMENT_NOT_OPEN.format({ uri }), {
|
|
240
|
+
uri,
|
|
241
|
+
clientId,
|
|
242
|
+
...messageData(DOCUMENT_NOT_OPEN, { uri })
|
|
243
|
+
});
|
|
244
|
+
this.name = 'DocumentNotOpenError';
|
|
245
|
+
Object.setPrototypeOf(this, DocumentNotOpenError.prototype);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
get uri(): string {
|
|
249
|
+
return this.data!.uri;
|
|
102
250
|
}
|
|
103
251
|
|
|
104
|
-
get
|
|
105
|
-
return this.data!.
|
|
252
|
+
get clientId(): string {
|
|
253
|
+
return this.data!.clientId;
|
|
106
254
|
}
|
|
107
255
|
}
|
|
108
256
|
|
|
257
|
+
/**
|
|
258
|
+
* The catalogue declaration behind {@link DuplicateClientIdError}'s sentence.
|
|
259
|
+
* The client id stays in {@link DuplicateClientIdErrorData.clientId}.
|
|
260
|
+
*/
|
|
261
|
+
export const DUPLICATE_CLIENT_ID = defineMessage(
|
|
262
|
+
'hydranium/protocol/duplicate-client-id',
|
|
263
|
+
'Could not start an editing session: its identifier is still in use by another editor.'
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
/** Structured payload carried in {@link DuplicateClientIdError.data}. */
|
|
267
|
+
export interface DuplicateClientIdErrorData extends HydraniumMessageData {
|
|
268
|
+
readonly clientId: string;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Thrown when a client session is started under an id that is already live in
|
|
273
|
+
* the process. The id frees up once its holder ends or closes its last
|
|
274
|
+
* document, so a caller may retry.
|
|
275
|
+
*
|
|
276
|
+
* Ids are unique process-wide because the id is also the author label on every
|
|
277
|
+
* version and the key a client recognises its own echoes by; two participants
|
|
278
|
+
* sharing one would each take the other's writes for their own.
|
|
279
|
+
*/
|
|
280
|
+
export class DuplicateClientIdError extends ResponseError<DuplicateClientIdErrorData> {
|
|
281
|
+
constructor(clientId: string) {
|
|
282
|
+
super(DUPLICATE_CLIENT_ID_ERROR_CODE, DUPLICATE_CLIENT_ID.format(), { clientId, ...messageData(DUPLICATE_CLIENT_ID) });
|
|
283
|
+
this.name = 'DuplicateClientIdError';
|
|
284
|
+
Object.setPrototypeOf(this, DuplicateClientIdError.prototype);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
get clientId(): string {
|
|
288
|
+
return this.data!.clientId;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Thrown when a client session is started under an id the framework reserves
|
|
294
|
+
* for one of its own participants. A reserved id never frees up, so a caller
|
|
295
|
+
* that retries on {@link DuplicateClientIdError} stops on this one.
|
|
296
|
+
*
|
|
297
|
+
* It carries no message identity: a host that picks a reserved id has a bug,
|
|
298
|
+
* and no sentence addressed to an end user is true for it.
|
|
299
|
+
*/
|
|
300
|
+
export class ReservedClientIdError extends ResponseError<{ readonly clientId: string }> {
|
|
301
|
+
constructor(clientId: string) {
|
|
302
|
+
super(RESERVED_CLIENT_ID_ERROR_CODE, `Client id ${clientId} is reserved for a framework participant`, { clientId });
|
|
303
|
+
this.name = 'ReservedClientIdError';
|
|
304
|
+
Object.setPrototypeOf(this, ReservedClientIdError.prototype);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
get clientId(): string {
|
|
308
|
+
return this.data!.clientId;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Rebuilds one typed error from the `data` that crossed the wire, or
|
|
314
|
+
* `undefined` when `data` lacks the fields the class reads.
|
|
315
|
+
*/
|
|
316
|
+
type ProtocolErrorReviver = (data: Readonly<Record<string, unknown>>) => ResponseError<unknown> | undefined;
|
|
317
|
+
|
|
318
|
+
/** One entry per typed error class, keyed by its code; a class without one reaches a caller as a plain `ResponseError`. */
|
|
319
|
+
const PROTOCOL_ERROR_REVIVERS: ReadonlyMap<number, ProtocolErrorReviver> = new Map<number, ProtocolErrorReviver>([
|
|
320
|
+
[
|
|
321
|
+
CONFLICT_ERROR_CODE,
|
|
322
|
+
({ uri, baseVersion, actualVersion }) =>
|
|
323
|
+
typeof uri === 'string' && typeof baseVersion === 'number' && typeof actualVersion === 'number'
|
|
324
|
+
? new ConflictError(uri, asModelVersion(baseVersion), actualVersion)
|
|
325
|
+
: undefined
|
|
326
|
+
],
|
|
327
|
+
[SESSION_CLOSED_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new SessionClosedError(clientId) : undefined)],
|
|
328
|
+
[
|
|
329
|
+
DOCUMENT_NOT_OPEN_ERROR_CODE,
|
|
330
|
+
({ uri, clientId }) => (typeof uri === 'string' && typeof clientId === 'string' ? new DocumentNotOpenError(uri, clientId) : undefined)
|
|
331
|
+
],
|
|
332
|
+
[DUPLICATE_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new DuplicateClientIdError(clientId) : undefined)],
|
|
333
|
+
[RESERVED_CLIENT_ID_ERROR_CODE, ({ clientId }) => (typeof clientId === 'string' ? new ReservedClientIdError(clientId) : undefined)]
|
|
334
|
+
]);
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Whether `error` is a `ResponseError` from any copy of `vscode-jsonrpc`. An
|
|
338
|
+
* install holds several copies, and `instanceof` recognises only its own. An
|
|
339
|
+
* error that merely carries an integer `code` has no `toJson`, and is not one.
|
|
340
|
+
*/
|
|
341
|
+
export function isResponseError(error: unknown): error is ResponseError<unknown> {
|
|
342
|
+
return (
|
|
343
|
+
error instanceof Error && 'code' in error && Number.isInteger(error.code) && 'toJson' in error && typeof error.toJson === 'function'
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* `error` as an instance of the typed error class its code names, with its
|
|
349
|
+
* message, data and stack kept, or `error` itself when its code names none or
|
|
350
|
+
* its data lacks the fields that class reads.
|
|
351
|
+
* An RPC reconstructs every rejection as a plain `ResponseError`, which has
|
|
352
|
+
* none of the class getters.
|
|
353
|
+
*/
|
|
354
|
+
export function reviveProtocolError(error: unknown): unknown {
|
|
355
|
+
if (!isResponseError(error) || error.data === null || typeof error.data !== 'object') {
|
|
356
|
+
return error;
|
|
357
|
+
}
|
|
358
|
+
const revived = PROTOCOL_ERROR_REVIVERS.get(error.code)?.({ ...error.data });
|
|
359
|
+
if (!revived) {
|
|
360
|
+
return error;
|
|
361
|
+
}
|
|
362
|
+
return Object.assign(revived, { message: error.message, data: error.data, stack: error.stack });
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Whether `error` is a {@link SessionClosedError}: by name in-process, by code
|
|
367
|
+
* when it arrives as a plain `ResponseError`, through a path that does not
|
|
368
|
+
* {@link reviveProtocolError revive} it.
|
|
369
|
+
*/
|
|
370
|
+
export function isSessionClosedError(error: unknown): error is SessionClosedError {
|
|
371
|
+
return hasErrorIdentity(error, 'SessionClosedError', SESSION_CLOSED_ERROR_CODE);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Whether `error` is a {@link DocumentNotOpenError}; see {@link isSessionClosedError}. */
|
|
375
|
+
export function isDocumentNotOpenError(error: unknown): error is DocumentNotOpenError {
|
|
376
|
+
return hasErrorIdentity(error, 'DocumentNotOpenError', DOCUMENT_NOT_OPEN_ERROR_CODE);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** Whether `error` is a {@link DuplicateClientIdError}; see {@link isSessionClosedError}. */
|
|
380
|
+
export function isDuplicateClientIdError(error: unknown): error is DuplicateClientIdError {
|
|
381
|
+
return hasErrorIdentity(error, 'DuplicateClientIdError', DUPLICATE_CLIENT_ID_ERROR_CODE);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** Whether `error` is a {@link ReservedClientIdError}; see {@link isSessionClosedError}. */
|
|
385
|
+
export function isReservedClientIdError(error: unknown): error is ReservedClientIdError {
|
|
386
|
+
return hasErrorIdentity(error, 'ReservedClientIdError', RESERVED_CLIENT_ID_ERROR_CODE);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function hasErrorIdentity(error: unknown, name: string, code: number): boolean {
|
|
390
|
+
return error instanceof Error && (error.name === name || (error as Partial<ResponseError<unknown>>).code === code);
|
|
391
|
+
}
|
|
392
|
+
|
|
109
393
|
/** Marker substring present in every {@link ConflictError} message, used by
|
|
110
394
|
* {@link isConflictError} as a fallback when a transport re-wraps the error
|
|
111
395
|
* and drops the JSON-RPC code. */
|
|
112
|
-
const CONFLICT_ERROR_MESSAGE_MARKER = '
|
|
396
|
+
const CONFLICT_ERROR_MESSAGE_MARKER = ': it was made to an older version of the document';
|
|
113
397
|
|
|
114
398
|
/**
|
|
115
399
|
* Type guard for {@link ConflictError}. Detection ladder:
|
|
@@ -120,11 +404,13 @@ const CONFLICT_ERROR_MESSAGE_MARKER = 'Stale-based update for ';
|
|
|
120
404
|
* canonical wire-side check; the JSON-RPC `code` field is preserved
|
|
121
405
|
* across reconstruction, so any adopter catching after an RPC call
|
|
122
406
|
* hits this branch.
|
|
123
|
-
* 3. `error.message
|
|
124
|
-
*
|
|
407
|
+
* 3. `error.message` contains the marker the English of
|
|
408
|
+
* {@link STALE_BASE_VERSION_UPDATE} and
|
|
409
|
+
* {@link STALE_BASE_VERSION_SAVE} carries — fallback for transports
|
|
410
|
+
* that re-wrap the message and drop the code (rare).
|
|
125
411
|
*
|
|
126
|
-
* `instanceof ConflictError` alone
|
|
127
|
-
*
|
|
412
|
+
* `instanceof ConflictError` alone returns `false` on a rejection that was
|
|
413
|
+
* not {@link reviveProtocolError revived}, so callers do not use it.
|
|
128
414
|
*/
|
|
129
415
|
export function isConflictError(error: unknown): error is ConflictError {
|
|
130
416
|
if (!(error instanceof Error)) {
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
// Declared field by field rather than extending GLSP's action types, as the
|
|
11
|
+
// save actions are: this package carries no GLSP dependency.
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A request the server answers, with an {@link EditsSettledAction}, once every
|
|
15
|
+
* edit the client sent before it has been handled and its text has reached
|
|
16
|
+
* the language client, so the client knows those edits are answered.
|
|
17
|
+
*
|
|
18
|
+
* An operation has no answer of its own: the server replies with a model
|
|
19
|
+
* update and a dirty state, with a message, or with nothing at all when the
|
|
20
|
+
* operation changed nothing. The server handles a client's actions one at a
|
|
21
|
+
* time, so a request sent after the edits is answered after them, whatever
|
|
22
|
+
* each one answered. A server that fails it answers with a GLSP
|
|
23
|
+
* `RejectAction`, which ends the wait too.
|
|
24
|
+
*/
|
|
25
|
+
export interface RequestEditsSettledAction {
|
|
26
|
+
kind: typeof RequestEditsSettledAction.KIND;
|
|
27
|
+
/** The id the response echoes as its `responseId`. Empty until the dispatcher assigns one. */
|
|
28
|
+
requestId: string;
|
|
29
|
+
/**
|
|
30
|
+
* How long the server waits before it rejects the request, as it does any
|
|
31
|
+
* request; a rejection then means not settled, and the answer that follows
|
|
32
|
+
* is dropped. GLSP's `requestUntil` sets one; `request` leaves it unset.
|
|
33
|
+
*/
|
|
34
|
+
timeout?: number;
|
|
35
|
+
/** GLSP's typing marker for the response. Never set. */
|
|
36
|
+
readonly _?: EditsSettledAction;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export namespace RequestEditsSettledAction {
|
|
40
|
+
export const KIND = 'hydraniumRequestEditsSettled';
|
|
41
|
+
|
|
42
|
+
export function create(options: { requestId?: string } = {}): RequestEditsSettledAction {
|
|
43
|
+
return { kind: KIND, requestId: '', ...options };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The server's answer to a {@link RequestEditsSettledAction}. */
|
|
48
|
+
export interface EditsSettledAction {
|
|
49
|
+
kind: typeof EditsSettledAction.KIND;
|
|
50
|
+
/** The `requestId` of the request this answers. The server's dispatcher sets it. */
|
|
51
|
+
responseId: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export namespace EditsSettledAction {
|
|
55
|
+
export const KIND = 'hydraniumEditsSettled';
|
|
56
|
+
|
|
57
|
+
export function create(options: { responseId?: string } = {}): EditsSettledAction {
|
|
58
|
+
return { kind: KIND, responseId: '', ...options };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The `RequestModelAction` option carrying a diagram's resume token. A load
|
|
12
|
+
* whose token matches the one the live session under its client id was started
|
|
13
|
+
* with takes that session over, so a diagram that reconnects or reloads keeps
|
|
14
|
+
* its unsaved text; without it, the id held by another session is refused.
|
|
15
|
+
*/
|
|
16
|
+
export const RESUME_TOKEN_ARG = 'hydraniumResumeToken';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
|
|
10
|
+
// Declared field by field rather than extending GLSP's action types: this
|
|
11
|
+
// package carries no GLSP dependency, and both GLSP heads already depend on it.
|
|
12
|
+
// The fields are GLSP's own, so both actions are assignable to GLSP's
|
|
13
|
+
// `RequestAction` and `ResponseAction`.
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A save of a diagram's model that the server answers, with a
|
|
17
|
+
* {@link ModelSavedAction} once the save has finished or a GLSP
|
|
18
|
+
* `RejectAction` when it fails.
|
|
19
|
+
*
|
|
20
|
+
* It carries what GLSP's `SaveModelAction` carries, and the server saves it the
|
|
21
|
+
* same way. GLSP's `SaveModelAction` is not answered: the server's only
|
|
22
|
+
* reply is a dirty-state change, which the client drops when the dirty flag
|
|
23
|
+
* does not change, so a client cannot tell which save an answer belongs to or
|
|
24
|
+
* whether a save failed.
|
|
25
|
+
*/
|
|
26
|
+
export interface RequestSaveModelAction {
|
|
27
|
+
kind: typeof RequestSaveModelAction.KIND;
|
|
28
|
+
/** The id the response echoes as its `responseId`. Empty until the dispatcher assigns one. */
|
|
29
|
+
requestId: string;
|
|
30
|
+
/** How long the receiver waits for its own handler, in milliseconds. */
|
|
31
|
+
timeout?: number;
|
|
32
|
+
/** The file to save to, as in GLSP's `SaveModelAction`; absent saves to the diagram's source. */
|
|
33
|
+
fileUri?: string;
|
|
34
|
+
/** GLSP's typing marker for the response. Never set. */
|
|
35
|
+
readonly _?: ModelSavedAction;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export namespace RequestSaveModelAction {
|
|
39
|
+
export const KIND = 'hydraniumRequestSaveModel';
|
|
40
|
+
|
|
41
|
+
export function create(options: { fileUri?: string; requestId?: string } = {}): RequestSaveModelAction {
|
|
42
|
+
return { kind: KIND, requestId: '', ...options };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The server's answer to a {@link RequestSaveModelAction} that saved. */
|
|
47
|
+
export interface ModelSavedAction {
|
|
48
|
+
kind: typeof ModelSavedAction.KIND;
|
|
49
|
+
/** The `requestId` of the save this answers. The server's dispatcher sets it. */
|
|
50
|
+
responseId: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export namespace ModelSavedAction {
|
|
54
|
+
export const KIND = 'hydraniumModelSaved';
|
|
55
|
+
|
|
56
|
+
export function create(options: { responseId?: string } = {}): ModelSavedAction {
|
|
57
|
+
return { kind: KIND, responseId: '', ...options };
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -15,11 +15,16 @@
|
|
|
15
15
|
// every production bundle that imports the root.
|
|
16
16
|
|
|
17
17
|
export * from './abstract-logger';
|
|
18
|
+
export * from './console-logger';
|
|
18
19
|
export * from './client';
|
|
20
|
+
export * from './client-ids';
|
|
19
21
|
export * from './clock';
|
|
20
22
|
export * from './data';
|
|
21
23
|
export * from './browser-runtime';
|
|
22
24
|
export * from './debouncer';
|
|
25
|
+
export * from './glsp-edits-settled-actions';
|
|
26
|
+
export * from './glsp-request-model-args';
|
|
27
|
+
export * from './glsp-save-model-actions';
|
|
23
28
|
export * from './errors';
|
|
24
29
|
export * from './host-diagnostics';
|
|
25
30
|
export * from './logger';
|
|
@@ -29,17 +34,22 @@ export * from './latency-collector';
|
|
|
29
34
|
// the modules that raise them.
|
|
30
35
|
export * from './messages/primitives';
|
|
31
36
|
export * from './patch-merge';
|
|
37
|
+
export * from './reconcile-write';
|
|
32
38
|
export * from './noop-logger';
|
|
33
39
|
export * from './observable-value';
|
|
40
|
+
export * from './pending-work-tracker';
|
|
34
41
|
export * from './profile-session';
|
|
35
42
|
export * from './profiling';
|
|
36
43
|
export * from './tracer';
|
|
37
44
|
export * from './transfer-diagnostic';
|
|
38
45
|
export * from './transfer-element';
|
|
46
|
+
export * from './types';
|
|
39
47
|
export * from './model-service';
|
|
40
48
|
export * from './transfer-document';
|
|
41
49
|
export * from './model-server';
|
|
42
50
|
export * from './project';
|
|
51
|
+
export * from './random-uuid';
|
|
52
|
+
export * from './save-text-document';
|
|
43
53
|
export * from './rpc';
|
|
44
54
|
export * from './uri';
|
|
45
55
|
export * from './util';
|