@hydranium/protocol 1.0.0-next.29 → 1.0.0-next.299
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -49
- package/lib/abstract-logger.d.ts +5 -0
- package/lib/abstract-logger.d.ts.map +1 -1
- package/lib/abstract-logger.js +7 -0
- package/lib/abstract-logger.js.map +1 -1
- package/lib/client/data-connection.d.ts +302 -0
- package/lib/client/data-connection.d.ts.map +1 -0
- package/lib/client/data-connection.js +533 -0
- package/lib/client/data-connection.js.map +1 -0
- package/lib/client/data-events.d.ts +17 -1
- package/lib/client/data-events.d.ts.map +1 -1
- package/lib/client/data-events.js +25 -0
- package/lib/client/data-events.js.map +1 -1
- package/lib/client/data-port.d.ts +34 -24
- package/lib/client/data-port.d.ts.map +1 -1
- package/lib/client/data-session.d.ts +657 -89
- package/lib/client/data-session.d.ts.map +1 -1
- package/lib/client/data-session.js +1113 -115
- package/lib/client/data-session.js.map +1 -1
- package/lib/client/index.d.ts +15 -9
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +15 -9
- package/lib/client/index.js.map +1 -1
- package/lib/client/message-relay.d.ts +4 -4
- package/lib/client/message-relay.js +4 -4
- package/lib/client/message-relay.js.map +1 -1
- package/lib/client/post-message-transport.d.ts +64 -3
- package/lib/client/post-message-transport.d.ts.map +1 -1
- package/lib/client/post-message-transport.js +175 -1
- package/lib/client/post-message-transport.js.map +1 -1
- package/lib/client/rpc-connection.d.ts +157 -0
- package/lib/client/rpc-connection.d.ts.map +1 -0
- package/lib/client/rpc-connection.js +214 -0
- package/lib/client/rpc-connection.js.map +1 -0
- package/lib/client/worker-handshake.d.ts +72 -0
- package/lib/client/worker-handshake.d.ts.map +1 -0
- package/lib/client/worker-handshake.js +51 -0
- package/lib/client/worker-handshake.js.map +1 -0
- package/lib/client-ids.d.ts +45 -0
- package/lib/client-ids.d.ts.map +1 -0
- package/lib/client-ids.js +48 -0
- package/lib/client-ids.js.map +1 -0
- package/lib/clock.d.ts +50 -10
- package/lib/clock.d.ts.map +1 -1
- package/lib/clock.js +36 -1
- package/lib/clock.js.map +1 -1
- package/lib/console-logger.d.ts +23 -0
- package/lib/console-logger.d.ts.map +1 -0
- package/lib/console-logger.js +39 -0
- package/lib/console-logger.js.map +1 -0
- package/lib/data/data-protocol-methods.d.ts +4 -4
- package/lib/data/data-protocol-methods.d.ts.map +1 -1
- package/lib/data/data-protocol-methods.js +13 -1
- package/lib/data/data-protocol-methods.js.map +1 -1
- package/lib/data/data-server-protocol.d.ts +165 -48
- package/lib/data/data-server-protocol.d.ts.map +1 -1
- package/lib/data/events.d.ts +137 -21
- package/lib/data/events.d.ts.map +1 -1
- package/lib/data/requests.d.ts +71 -11
- package/lib/data/requests.d.ts.map +1 -1
- package/lib/debouncer.d.ts +3 -3
- package/lib/debouncer.d.ts.map +1 -1
- package/lib/debouncer.js +6 -9
- package/lib/debouncer.js.map +1 -1
- package/lib/errors.d.ts +175 -30
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +260 -32
- package/lib/errors.js.map +1 -1
- package/lib/glsp-request-model-args.d.ts +16 -0
- package/lib/glsp-request-model-args.d.ts.map +1 -0
- package/lib/glsp-request-model-args.js +19 -0
- package/lib/glsp-request-model-args.js.map +1 -0
- package/lib/glsp-save-model-actions.d.ts +50 -0
- package/lib/glsp-save-model-actions.d.ts.map +1 -0
- package/lib/glsp-save-model-actions.js +28 -0
- package/lib/glsp-save-model-actions.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -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 +14 -4
- package/lib/messages/index.js.map +1 -1
- package/lib/messages/primitives.d.ts +71 -10
- package/lib/messages/primitives.d.ts.map +1 -1
- package/lib/messages/primitives.js +55 -3
- package/lib/messages/primitives.js.map +1 -1
- package/lib/model-server.d.ts +60 -13
- package/lib/model-server.d.ts.map +1 -1
- package/lib/model-server.js +4 -2
- package/lib/model-server.js.map +1 -1
- package/lib/model-service/base-version.d.ts +67 -0
- package/lib/model-service/base-version.d.ts.map +1 -0
- package/lib/model-service/base-version.js +44 -0
- package/lib/model-service/base-version.js.map +1 -0
- package/lib/model-service/index.d.ts +1 -1
- package/lib/model-service/index.d.ts.map +1 -1
- package/lib/model-service/index.js +4 -5
- package/lib/model-service/index.js.map +1 -1
- package/lib/model-service/reference-candidate.d.ts +5 -3
- package/lib/model-service/reference-candidate.d.ts.map +1 -1
- package/lib/{model-service/args.js → node/index.d.ts} +2 -3
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +29 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/process-memory.d.ts +66 -0
- package/lib/node/process-memory.d.ts.map +1 -0
- package/lib/node/process-memory.js +291 -0
- package/lib/node/process-memory.js.map +1 -0
- package/lib/noop-logger.d.ts.map +1 -1
- package/lib/noop-logger.js.map +1 -1
- package/lib/observable-value.js.map +1 -1
- package/lib/patch-merge.d.ts +63 -35
- package/lib/patch-merge.d.ts.map +1 -1
- package/lib/patch-merge.js +171 -25
- package/lib/patch-merge.js.map +1 -1
- package/lib/profile-session.d.ts +8 -4
- package/lib/profile-session.d.ts.map +1 -1
- package/lib/profile-session.js.map +1 -1
- package/lib/project.d.ts +4 -1
- package/lib/project.d.ts.map +1 -1
- package/lib/project.js.map +1 -1
- package/lib/random-uuid.d.ts +14 -0
- package/lib/random-uuid.d.ts.map +1 -0
- package/lib/random-uuid.js +24 -0
- package/lib/random-uuid.js.map +1 -0
- package/lib/reconcile-write.d.ts +67 -0
- package/lib/reconcile-write.d.ts.map +1 -0
- package/lib/reconcile-write.js +69 -0
- package/lib/reconcile-write.js.map +1 -0
- package/lib/rpc/bind-rpc-methods.d.ts +33 -3
- package/lib/rpc/bind-rpc-methods.d.ts.map +1 -1
- package/lib/rpc/bind-rpc-methods.js +32 -3
- package/lib/rpc/bind-rpc-methods.js.map +1 -1
- package/lib/rpc/create-rpc-proxy.d.ts +10 -0
- package/lib/rpc/create-rpc-proxy.d.ts.map +1 -1
- package/lib/rpc/create-rpc-proxy.js +12 -2
- package/lib/rpc/create-rpc-proxy.js.map +1 -1
- package/lib/rpc/index.d.ts +1 -0
- package/lib/rpc/index.d.ts.map +1 -1
- package/lib/rpc/index.js +1 -0
- package/lib/rpc/index.js.map +1 -1
- package/lib/rpc/send-by-method-name.d.ts +76 -0
- package/lib/rpc/send-by-method-name.d.ts.map +1 -0
- package/lib/rpc/send-by-method-name.js +120 -0
- package/lib/rpc/send-by-method-name.js.map +1 -0
- package/lib/rpc/wire-prefix.js.map +1 -1
- package/lib/testing/catalogue-audit.d.ts +80 -0
- package/lib/testing/catalogue-audit.d.ts.map +1 -0
- package/lib/testing/catalogue-audit.js +94 -0
- package/lib/testing/catalogue-audit.js.map +1 -0
- package/lib/testing/data-doubles.d.ts +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 +5 -2
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/node/duplex-connection.d.ts.map +1 -1
- package/lib/testing/node/duplex-connection.js +3 -2
- package/lib/testing/node/duplex-connection.js.map +1 -1
- package/lib/testing/node/duplex-stream.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +2 -2
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/message-port-pair.d.ts +25 -0
- package/lib/testing/node/message-port-pair.d.ts.map +1 -0
- package/lib/testing/node/message-port-pair.js +26 -0
- package/lib/testing/node/message-port-pair.js.map +1 -0
- package/lib/testing/wait-for.d.ts +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/uri.d.ts.map +1 -1
- package/lib/uri.js.map +1 -1
- package/lib/util.d.ts +8 -2
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +32 -4
- package/lib/util.js.map +1 -1
- package/package.json +24 -40
- package/src/abstract-logger.ts +8 -0
- package/src/client/data-connection.ts +653 -0
- package/src/client/data-events.ts +37 -1
- package/src/client/data-port.ts +36 -25
- package/src/client/data-session.ts +1427 -137
- package/src/client/index.ts +15 -9
- package/src/client/message-relay.ts +4 -4
- package/src/client/post-message-transport.ts +219 -4
- package/src/client/rpc-connection.ts +281 -0
- package/src/client/worker-handshake.ts +98 -0
- package/src/client-ids.ts +49 -0
- package/src/clock.ts +68 -10
- package/src/console-logger.ts +39 -0
- package/src/data/data-protocol-methods.ts +14 -4
- package/src/data/data-server-protocol.ts +192 -48
- package/src/data/events.ts +143 -21
- package/src/data/requests.ts +77 -11
- package/src/debouncer.ts +7 -10
- package/src/errors.ts +309 -40
- package/src/glsp-request-model-args.ts +16 -0
- package/src/glsp-save-model-actions.ts +59 -0
- package/src/index.ts +6 -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 +102 -10
- package/src/model-server.ts +64 -19
- package/src/model-service/base-version.ts +75 -0
- package/src/model-service/index.ts +4 -5
- package/src/model-service/reference-candidate.ts +5 -3
- package/src/node/index.ts +14 -0
- package/src/node/process-memory.ts +299 -0
- package/src/patch-merge.ts +230 -45
- package/src/profile-session.ts +9 -4
- package/src/project.ts +4 -1
- package/src/random-uuid.ts +21 -0
- package/src/reconcile-write.ts +128 -0
- package/src/rpc/README.md +6 -6
- package/src/rpc/bind-rpc-methods.ts +59 -4
- package/src/rpc/create-rpc-proxy.ts +20 -2
- package/src/rpc/index.ts +1 -0
- package/src/rpc/send-by-method-name.ts +140 -0
- package/src/testing/catalogue-audit.ts +111 -0
- package/src/testing/data-doubles.ts +141 -19
- package/src/testing/fake-clock.ts +76 -48
- package/src/testing/index.ts +5 -2
- package/src/testing/node/duplex-connection.ts +3 -2
- package/src/testing/node/index.ts +2 -2
- package/src/testing/node/message-port-pair.ts +40 -0
- package/src/testing/wait-for.ts +61 -13
- package/src/tracer.ts +5 -9
- package/src/transfer-document.ts +115 -34
- 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/clock.d.ts
CHANGED
|
@@ -12,9 +12,11 @@ import { Disposable } from './util';
|
|
|
12
12
|
* there is no `start` — you create it at the moment timing begins.
|
|
13
13
|
*
|
|
14
14
|
* Backed by a monotonic source (`performance.now`), so it is sub-millisecond
|
|
15
|
-
* precise and immune to wall-clock
|
|
16
|
-
* `Date.now` delta go backwards; a stopwatch cannot).
|
|
17
|
-
*
|
|
15
|
+
* precise and immune to wall-clock steps (a time sync or a manual change can
|
|
16
|
+
* make a `Date.now` delta go backwards; a stopwatch cannot). In Node on Linux
|
|
17
|
+
* it also leaves out time the system spends suspended, so a duration spanning
|
|
18
|
+
* a suspend reads as the awake time only. Use this for every duration, a TTL
|
|
19
|
+
* included, and {@link Clock.now} for "what time is it".
|
|
18
20
|
*
|
|
19
21
|
* It holds no scheduled resource and is therefore NOT a {@link Disposable} —
|
|
20
22
|
* the disposable thing is a {@link Clock.setTimer}. Reads are lazy, so a fake
|
|
@@ -42,16 +44,16 @@ export interface Stopwatch {
|
|
|
42
44
|
* testable instead of waiting on real wall-clock. The {@link SystemClock}
|
|
43
45
|
* default delegates to the platform; tests bind `makeFakeClock`.
|
|
44
46
|
*
|
|
45
|
-
* Two distinct readings on purpose: {@link now} is wall-clock
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
47
|
+
* Two distinct readings on purpose: {@link now} is wall-clock, for a
|
|
48
|
+
* timestamp, while {@link stopwatch} measures durations off a monotonic
|
|
49
|
+
* source. They are different clocks; do not subtract two {@link now} readings
|
|
50
|
+
* to measure a duration. Framework code reads time only through a `Clock`, so
|
|
51
|
+
* a platform workaround lives in one place.
|
|
49
52
|
*
|
|
50
53
|
* A cross-head contract, so it carries no platform or DI-framework coupling.
|
|
51
54
|
*
|
|
52
|
-
* Note:
|
|
53
|
-
*
|
|
54
|
-
* measure would invert their meaning.
|
|
55
|
+
* Note: code that measures real CPU, heap or event-loop time never takes the
|
|
56
|
+
* bound `Clock`: faking the time it measures would invert its meaning.
|
|
55
57
|
*/
|
|
56
58
|
export interface Clock {
|
|
57
59
|
/** Current wall-clock time in milliseconds (the `Date.now` reading). */
|
|
@@ -73,7 +75,28 @@ export interface Clock {
|
|
|
73
75
|
*/
|
|
74
76
|
measure<T>(callback: () => Promise<T>): Promise<Timed<T>>;
|
|
75
77
|
measure<T>(callback: () => T): Timed<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Settle with `promise`, or with {@link TIMED_OUT} once `ms` have elapsed
|
|
80
|
+
* first. A promise that rejects first rejects this one; one that rejects
|
|
81
|
+
* after the timer is ignored. The timer is disposed the moment `promise`
|
|
82
|
+
* settles, so a won race leaves nothing scheduled, but `promise` itself
|
|
83
|
+
* runs on: nothing here can cancel it.
|
|
84
|
+
*
|
|
85
|
+
* Unlike VS Code's `raceTimeout`, this settles with a sentinel rather than
|
|
86
|
+
* `undefined`, so a promise resolving to `undefined` is not taken for a
|
|
87
|
+
* timeout; the caller branches on the result instead of passing an
|
|
88
|
+
* `onTimeout`.
|
|
89
|
+
*
|
|
90
|
+
* A custom implementation extends {@link SystemClock}, whose race runs over
|
|
91
|
+
* the subclass's {@link setTimer}.
|
|
92
|
+
*/
|
|
93
|
+
raceTimer<T>(promise: Promise<T>, ms: number): Promise<T | typeof TIMED_OUT>;
|
|
76
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* What {@link Clock.raceTimer} settles with when its timer fires first.
|
|
97
|
+
* Registered under a global key, so two copies of this package agree on it.
|
|
98
|
+
*/
|
|
99
|
+
export declare const TIMED_OUT: unique symbol;
|
|
77
100
|
/**
|
|
78
101
|
* The result of {@link Clock.measure}: a callback's return value paired with
|
|
79
102
|
* its elapsed wall-time in milliseconds. A plain value object — no methods, no
|
|
@@ -100,6 +123,10 @@ export interface Timed<T> {
|
|
|
100
123
|
* Default {@link Clock}: delegates to the platform's `Date.now`,
|
|
101
124
|
* `performance.now`, and `setTimeout`/`clearTimeout`. Bound everywhere in
|
|
102
125
|
* production; swapped for `makeFakeClock` in tests.
|
|
126
|
+
*
|
|
127
|
+
* {@link measure} and {@link raceTimer} run over {@link stopwatch} and
|
|
128
|
+
* {@link setTimer}, so a clock that extends this one and replaces those
|
|
129
|
+
* measures and races on its own time, as the test clock does.
|
|
103
130
|
*/
|
|
104
131
|
export declare class SystemClock implements Clock {
|
|
105
132
|
now(): number;
|
|
@@ -107,5 +134,18 @@ export declare class SystemClock implements Clock {
|
|
|
107
134
|
stopwatch(): Stopwatch;
|
|
108
135
|
measure<T>(callback: () => Promise<T>): Promise<Timed<T>>;
|
|
109
136
|
measure<T>(callback: () => T): Timed<T>;
|
|
137
|
+
/**
|
|
138
|
+
* The timer settles the race one microtask after it fires. A real timer
|
|
139
|
+
* runs only once pending resolutions are delivered, while a fake one fires
|
|
140
|
+
* inside its `advance`, so settling at once would let a promise already
|
|
141
|
+
* resolved when `advance` runs lose to a timer it beats in production. The
|
|
142
|
+
* deferral covers only that promise: one that settles through further
|
|
143
|
+
* chained reactions, such as a `.then` chain, an async function or
|
|
144
|
+
* `Promise.allSettled`, can still lose to an `advance` in the same turn,
|
|
145
|
+
* while it wins on the platform's timer. The handlers go on `promise`
|
|
146
|
+
* before {@link setTimer} runs, so a `setTimer` that throws still leaves
|
|
147
|
+
* `promise` observed.
|
|
148
|
+
*/
|
|
149
|
+
raceTimer<T>(promise: Promise<T>, ms: number): Promise<T | typeof TIMED_OUT>;
|
|
110
150
|
}
|
|
111
151
|
//# sourceMappingURL=clock.d.ts.map
|
package/lib/clock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC
|
|
1
|
+
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACvB,mFAAmF;IACnF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,GAAG,IAAI,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,IAAI,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,KAAK;IACnB,wEAAwE;IACxE,GAAG,IAAI,MAAM,CAAC;IACd;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC;IACvD,yDAAyD;IACzD,SAAS,IAAI,SAAS,CAAC;IACvB;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACxC;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,SAAS,CAAC,CAAC;CAC/E;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,eAA6C,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC;IACrB;;;;;OAKG;IACH,MAAM,EAAE,CAAC,CAAC;IACV;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;CACpB;AAyCD;;;;;;;;GAQG;AACH,qBAAa,WAAY,YAAW,KAAK;IACtC,GAAG,IAAI,MAAM,CAEZ;IAED,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAIrD;IAED,SAAS,IAAI,SAAS,CAErB;IAED,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAUxC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,SAAS,CAAC,CAgB3E;CACH"}
|
package/lib/clock.js
CHANGED
|
@@ -8,8 +8,13 @@
|
|
|
8
8
|
* SPDX-License-Identifier: MIT
|
|
9
9
|
********************************************************************************/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.SystemClock = void 0;
|
|
11
|
+
exports.SystemClock = exports.TIMED_OUT = void 0;
|
|
12
12
|
const util_1 = require("./util");
|
|
13
|
+
/**
|
|
14
|
+
* What {@link Clock.raceTimer} settles with when its timer fires first.
|
|
15
|
+
* Registered under a global key, so two copies of this package agree on it.
|
|
16
|
+
*/
|
|
17
|
+
exports.TIMED_OUT = Symbol.for('hydranium/protocol/timed-out');
|
|
13
18
|
class SystemStopwatch {
|
|
14
19
|
start = performance.now();
|
|
15
20
|
lastLap = this.start;
|
|
@@ -48,6 +53,10 @@ function unrefTimer(handle) {
|
|
|
48
53
|
* Default {@link Clock}: delegates to the platform's `Date.now`,
|
|
49
54
|
* `performance.now`, and `setTimeout`/`clearTimeout`. Bound everywhere in
|
|
50
55
|
* production; swapped for `makeFakeClock` in tests.
|
|
56
|
+
*
|
|
57
|
+
* {@link measure} and {@link raceTimer} run over {@link stopwatch} and
|
|
58
|
+
* {@link setTimer}, so a clock that extends this one and replaces those
|
|
59
|
+
* measures and races on its own time, as the test clock does.
|
|
51
60
|
*/
|
|
52
61
|
class SystemClock {
|
|
53
62
|
now() {
|
|
@@ -69,6 +78,32 @@ class SystemClock {
|
|
|
69
78
|
}
|
|
70
79
|
return { result: result, elapsedMs: stopwatch.elapsedMs };
|
|
71
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* The timer settles the race one microtask after it fires. A real timer
|
|
83
|
+
* runs only once pending resolutions are delivered, while a fake one fires
|
|
84
|
+
* inside its `advance`, so settling at once would let a promise already
|
|
85
|
+
* resolved when `advance` runs lose to a timer it beats in production. The
|
|
86
|
+
* deferral covers only that promise: one that settles through further
|
|
87
|
+
* chained reactions, such as a `.then` chain, an async function or
|
|
88
|
+
* `Promise.allSettled`, can still lose to an `advance` in the same turn,
|
|
89
|
+
* while it wins on the platform's timer. The handlers go on `promise`
|
|
90
|
+
* before {@link setTimer} runs, so a `setTimer` that throws still leaves
|
|
91
|
+
* `promise` observed.
|
|
92
|
+
*/
|
|
93
|
+
raceTimer(promise, ms) {
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
// eslint-disable-next-line prefer-const -- with a `const`, a `setTimer` that throws leaves it uninitialised, and the handlers' later read of it is an unhandled ReferenceError
|
|
96
|
+
let timer;
|
|
97
|
+
promise.then(value => {
|
|
98
|
+
timer?.dispose();
|
|
99
|
+
resolve(value);
|
|
100
|
+
}, (err) => {
|
|
101
|
+
timer?.dispose();
|
|
102
|
+
reject(err);
|
|
103
|
+
});
|
|
104
|
+
timer = this.setTimer(() => void Promise.resolve().then(() => resolve(exports.TIMED_OUT)), ms);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
72
107
|
}
|
|
73
108
|
exports.SystemClock = SystemClock;
|
|
74
109
|
//# sourceMappingURL=clock.js.map
|
package/lib/clock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,iCAAoC;
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,iCAAoC;AAyFpC;;;GAGG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAyBpE,MAAM,eAAe;IACC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACnC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;IACrB,OAAO,CAAqB;IAEtC,IAAI,SAAS;QACV,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IAC3D,CAAC;IAED,GAAG;QACA,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IAChB,CAAC;IAED,IAAI;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACpC,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;IACpC,CAAC;CACH;AAED;;;;;;;;;;GAUG;AACH,SAAS,UAAU,CAAC,MAA8B;IAC/C,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;AACpB,CAAC;AAED;;;;;;;;GAQG;AACH;IACG,GAAG;QACA,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC;IAED,QAAQ,CAAC,QAAoB,EAAE,EAAU;QACtC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACxC,UAAU,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,iBAAU,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,SAAS;QACN,OAAO,IAAI,eAAe,EAAE,CAAC;IAChC,CAAC;IAID,OAAO,CAAI,QAA8B;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;QAC1B,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC7B,OAAQ,MAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACpG,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,MAAW,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;IAClE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,SAAS,CAAI,OAAmB,EAAE,EAAU;QACzC,OAAO,IAAI,OAAO,CAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1D,+KAA+K;YAC/K,IAAI,KAA6B,CAAC;YAClC,OAAO,CAAC,IAAI,CACT,KAAK,CAAC,EAAE;gBACL,KAAK,EAAE,OAAO,EAAE,CAAC;gBACjB,OAAO,CAAC,KAAK,CAAC,CAAC;YAClB,CAAC,EACD,CAAC,GAAY,EAAE,EAAE;gBACd,KAAK,EAAE,OAAO,EAAE,CAAC;gBACjB,MAAM,CAAC,GAAG,CAAC,CAAC;YACf,CAAC,CACH,CAAC;YACF,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAA,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;IACN,CAAC;CACH"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
import { AbstractLogger } from './abstract-logger';
|
|
10
|
+
import { type LogLevel, type Logger } from './logger';
|
|
11
|
+
/**
|
|
12
|
+
* {@link Logger} that writes each line to `console`, at the method matching its
|
|
13
|
+
* level: the framework's `[Label - time] [component]` prefix and the message,
|
|
14
|
+
* then any trailing arguments as they are, so a browser console can expand
|
|
15
|
+
* them. For a browser page, webview or extension host, which has no other sink
|
|
16
|
+
* to hand. On Node, `info` and `debug` reach stdout, so a process whose stdout
|
|
17
|
+
* carries a protocol stream must not use it.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ConsoleLogger extends AbstractLogger implements Logger {
|
|
20
|
+
protected emit(level: LogLevel, label: string, message: string, args: readonly unknown[]): void;
|
|
21
|
+
protected derive(component: string): this;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=console-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-logger.d.ts","sourceRoot":"","sources":["../src/console-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAWtD;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,cAAe,YAAW,MAAM;IAChE,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAE9F;IAED,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGxC;CACH"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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.ConsoleLogger = void 0;
|
|
12
|
+
const abstract_logger_1 = require("./abstract-logger");
|
|
13
|
+
/** `console.trace` prints a stack with every line, so `trace` goes out at `debug`. */
|
|
14
|
+
const CONSOLE_METHODS = {
|
|
15
|
+
error: 'error',
|
|
16
|
+
warn: 'warn',
|
|
17
|
+
info: 'info',
|
|
18
|
+
debug: 'debug',
|
|
19
|
+
trace: 'debug'
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* {@link Logger} that writes each line to `console`, at the method matching its
|
|
23
|
+
* level: the framework's `[Label - time] [component]` prefix and the message,
|
|
24
|
+
* then any trailing arguments as they are, so a browser console can expand
|
|
25
|
+
* them. For a browser page, webview or extension host, which has no other sink
|
|
26
|
+
* to hand. On Node, `info` and `debug` reach stdout, so a process whose stdout
|
|
27
|
+
* carries a protocol stream must not use it.
|
|
28
|
+
*/
|
|
29
|
+
class ConsoleLogger extends abstract_logger_1.AbstractLogger {
|
|
30
|
+
emit(level, label, message, args) {
|
|
31
|
+
console[CONSOLE_METHODS[level]](`${this.formatLinePrefix(label)} ${message}`, ...args);
|
|
32
|
+
}
|
|
33
|
+
derive(component) {
|
|
34
|
+
const Subclass = this.constructor;
|
|
35
|
+
return new Subclass(component);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ConsoleLogger = ConsoleLogger;
|
|
39
|
+
//# sourceMappingURL=console-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-logger.js","sourceRoot":"","sources":["../src/console-logger.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAElF,uDAAmD;AAGnD,sFAAsF;AACtF,MAAM,eAAe,GAA0D;IAC5E,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,mBAA2B,SAAQ,gCAAc;IACpC,IAAI,CAAC,KAAe,EAAE,KAAa,EAAE,OAAe,EAAE,IAAwB;QACrF,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1F,CAAC;IAES,MAAM,CAAC,SAAiB;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAA+C,CAAC;QACtE,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;CACH"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
/** Request-method names on {@link DocumentServerProtocol}. */
|
|
10
|
-
export declare const DOCUMENT_SERVER_PROTOCOL_METHODS: readonly ["openModelDocument", "closeModelDocument", "getModelDocument", "updateModelDocument", "saveModelDocument", "watchModelDocument", "unwatchModelDocument", "waitForReady"];
|
|
10
|
+
export declare const DOCUMENT_SERVER_PROTOCOL_METHODS: readonly ["createSession", "closeSession", "createModelDocument", "updateModelDocuments", "openModelDocument", "closeModelDocument", "getModelDocument", "updateModelDocument", "saveModelDocument", "persistModelDocument", "deleteModelDocument", "watchModelDocument", "unwatchModelDocument", "waitForReady"];
|
|
11
11
|
/** Request-method names on {@link ProjectServerProtocol}. */
|
|
12
12
|
export declare const PROJECT_SERVER_PROTOCOL_METHODS: readonly ["getProjects", "getProjectForUri"];
|
|
13
13
|
/**
|
|
@@ -16,7 +16,7 @@ export declare const PROJECT_SERVER_PROTOCOL_METHODS: readonly ["getProjects", "
|
|
|
16
16
|
* constraint makes the array typed against the interface — stale names (typos,
|
|
17
17
|
* renamed methods) fail to typecheck.
|
|
18
18
|
*/
|
|
19
|
-
export declare const DATA_SERVER_PROTOCOL_METHODS: readonly ["openModelDocument", "closeModelDocument", "getModelDocument", "updateModelDocument", "saveModelDocument", "watchModelDocument", "unwatchModelDocument", "waitForReady", "getProjects", "getProjectForUri"];
|
|
19
|
+
export declare const DATA_SERVER_PROTOCOL_METHODS: readonly ["createSession", "closeSession", "createModelDocument", "updateModelDocuments", "openModelDocument", "closeModelDocument", "getModelDocument", "updateModelDocument", "saveModelDocument", "persistModelDocument", "deleteModelDocument", "watchModelDocument", "unwatchModelDocument", "waitForReady", "getProjects", "getProjectForUri"];
|
|
20
20
|
/**
|
|
21
21
|
* Request-method names on {@link ReferenceServerProtocol}. NOT part of
|
|
22
22
|
* {@link DATA_SERVER_PROTOCOL_METHODS} — adopters that compose the reference
|
|
@@ -25,7 +25,7 @@ export declare const DATA_SERVER_PROTOCOL_METHODS: readonly ["openModelDocument"
|
|
|
25
25
|
*/
|
|
26
26
|
export declare const REFERENCE_SERVER_PROTOCOL_METHODS: readonly ["findReferenceCandidates", "resolveReference", "findNextName"];
|
|
27
27
|
/** Notification-method names on {@link DocumentClientProtocol}. */
|
|
28
|
-
export declare const DOCUMENT_CLIENT_PROTOCOL_METHODS: readonly ["onDocumentUpdated", "onDocumentSaved"];
|
|
28
|
+
export declare const DOCUMENT_CLIENT_PROTOCOL_METHODS: readonly ["onDocumentUpdated", "onDocumentSaved", "onDocumentDirtyChanged", "onDocumentDeleted", "onDocumentsBuilt"];
|
|
29
29
|
/** Notification-method names on {@link ProjectClientProtocol}. */
|
|
30
30
|
export declare const PROJECT_CLIENT_PROTOCOL_METHODS: readonly ["onProjectsChanged"];
|
|
31
31
|
/**
|
|
@@ -35,5 +35,5 @@ export declare const PROJECT_CLIENT_PROTOCOL_METHODS: readonly ["onProjectsChang
|
|
|
35
35
|
* data head's connection routes `<methodNamespace>onDocumentUpdated` etc. to
|
|
36
36
|
* the bound client target.
|
|
37
37
|
*/
|
|
38
|
-
export declare const DATA_CLIENT_PROTOCOL_METHODS: readonly ["onDocumentUpdated", "onDocumentSaved", "onProjectsChanged"];
|
|
38
|
+
export declare const DATA_CLIENT_PROTOCOL_METHODS: readonly ["onDocumentUpdated", "onDocumentSaved", "onDocumentDirtyChanged", "onDocumentDeleted", "onDocumentsBuilt", "onProjectsChanged"];
|
|
39
39
|
//# sourceMappingURL=data-protocol-methods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-protocol-methods.d.ts","sourceRoot":"","sources":["../../src/data/data-protocol-methods.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAalF,8DAA8D;AAC9D,eAAO,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"data-protocol-methods.d.ts","sourceRoot":"","sources":["../../src/data/data-protocol-methods.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAalF,8DAA8D;AAC9D,eAAO,MAAM,gCAAgC,mTAe6C,CAAC;AAE3F,6DAA6D;AAC7D,eAAO,MAAM,+BAA+B,8CAE3C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,sVAG6C,CAAC;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,0EAI4B,CAAC;AAE3E,mEAAmE;AACnE,eAAO,MAAM,gCAAgC,sHAM6C,CAAC;AAE3F,kEAAkE;AAClE,eAAO,MAAM,+BAA+B,gCAA+F,CAAC;AAE5I;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,2IAG6C,CAAC"}
|
|
@@ -11,11 +11,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.DATA_CLIENT_PROTOCOL_METHODS = exports.PROJECT_CLIENT_PROTOCOL_METHODS = exports.DOCUMENT_CLIENT_PROTOCOL_METHODS = exports.REFERENCE_SERVER_PROTOCOL_METHODS = exports.DATA_SERVER_PROTOCOL_METHODS = exports.PROJECT_SERVER_PROTOCOL_METHODS = exports.DOCUMENT_SERVER_PROTOCOL_METHODS = void 0;
|
|
12
12
|
/** Request-method names on {@link DocumentServerProtocol}. */
|
|
13
13
|
exports.DOCUMENT_SERVER_PROTOCOL_METHODS = [
|
|
14
|
+
'createSession',
|
|
15
|
+
'closeSession',
|
|
16
|
+
'createModelDocument',
|
|
17
|
+
'updateModelDocuments',
|
|
14
18
|
'openModelDocument',
|
|
15
19
|
'closeModelDocument',
|
|
16
20
|
'getModelDocument',
|
|
17
21
|
'updateModelDocument',
|
|
18
22
|
'saveModelDocument',
|
|
23
|
+
'persistModelDocument',
|
|
24
|
+
'deleteModelDocument',
|
|
19
25
|
'watchModelDocument',
|
|
20
26
|
'unwatchModelDocument',
|
|
21
27
|
'waitForReady'
|
|
@@ -44,7 +50,13 @@ exports.REFERENCE_SERVER_PROTOCOL_METHODS = [
|
|
|
44
50
|
'findNextName'
|
|
45
51
|
];
|
|
46
52
|
/** Notification-method names on {@link DocumentClientProtocol}. */
|
|
47
|
-
exports.DOCUMENT_CLIENT_PROTOCOL_METHODS = [
|
|
53
|
+
exports.DOCUMENT_CLIENT_PROTOCOL_METHODS = [
|
|
54
|
+
'onDocumentUpdated',
|
|
55
|
+
'onDocumentSaved',
|
|
56
|
+
'onDocumentDirtyChanged',
|
|
57
|
+
'onDocumentDeleted',
|
|
58
|
+
'onDocumentsBuilt'
|
|
59
|
+
];
|
|
48
60
|
/** Notification-method names on {@link ProjectClientProtocol}. */
|
|
49
61
|
exports.PROJECT_CLIENT_PROTOCOL_METHODS = ['onProjectsChanged'];
|
|
50
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-protocol-methods.js","sourceRoot":"","sources":["../../src/data/data-protocol-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAalF,8DAA8D;AACjD,QAAA,gCAAgC,GAAG;IAC7C,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;IACtB,cAAc;CACyE,CAAC;AAE3F,6DAA6D;AAChD,QAAA,+BAA+B,GAAG,CAAC,aAAa,EAAE,kBAAkB,CAEhF,CAAC;AAEF;;;;;GAKG;AACU,QAAA,4BAA4B,GAAG;IACzC,GAAG,
|
|
1
|
+
{"version":3,"file":"data-protocol-methods.js","sourceRoot":"","sources":["../../src/data/data-protocol-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAalF,8DAA8D;AACjD,QAAA,gCAAgC,GAAG;IAC7C,eAAe;IACf,cAAc;IACd,qBAAqB;IACrB,sBAAsB;IACtB,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,sBAAsB;IACtB,qBAAqB;IACrB,oBAAoB;IACpB,sBAAsB;IACtB,cAAc;CACyE,CAAC;AAE3F,6DAA6D;AAChD,QAAA,+BAA+B,GAAG,CAAC,aAAa,EAAE,kBAAkB,CAEhF,CAAC;AAEF;;;;;GAKG;AACU,QAAA,4BAA4B,GAAG;IACzC,GAAG,QAAA,gCAAgC;IACnC,GAAG,QAAA,+BAA+B;CACiD,CAAC;AAEvF;;;;;GAKG;AACU,QAAA,iCAAiC,GAAG;IAC9C,yBAAyB;IACzB,kBAAkB;IAClB,cAAc;CACyD,CAAC;AAE3E,mEAAmE;AACtD,QAAA,gCAAgC,GAAG;IAC7C,mBAAmB;IACnB,iBAAiB;IACjB,wBAAwB;IACxB,mBAAmB;IACnB,kBAAkB;CACqE,CAAC;AAE3F,kEAAkE;AACrD,QAAA,+BAA+B,GAAG,CAAC,mBAAmB,CAAwE,CAAC;AAE5I;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG;IACzC,GAAG,QAAA,gCAAgC;IACnC,GAAG,QAAA,+BAA+B;CACiD,CAAC"}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
import type { TransferDiagnostic } from '../transfer-diagnostic';
|
|
10
10
|
import type { TransferElement } from '../transfer-element';
|
|
11
11
|
import type { Project } from '../project';
|
|
12
|
-
import type { TransferDocument } from '../transfer-document';
|
|
12
|
+
import type { TransferCreatedDocument, TransferDocument, TransferSavedDocument, TransferWatchedDocument } from '../transfer-document';
|
|
13
13
|
import type { CloseModelArgs, FindNextNameArgs, OpenModelArgs, ReferenceContext, ReferenceRequest } from '../model-server';
|
|
14
14
|
import type { ReferenceCandidate, ReferenceTarget } from '../model-service/reference-candidate';
|
|
15
|
-
import type { ProjectsChangedEvent, TransferDocumentSavedEvent, TransferDocumentUpdatedEvent } from './events';
|
|
16
|
-
import type { GetModelDocumentArgs, GetProjectForUriArgs, TransferSaveDocumentArgs, WatchModelDocumentArgs, TransferUpdateDocumentArgs } from './requests';
|
|
15
|
+
import type { ProjectsChangedEvent, TransferDocumentDeletedEvent, TransferDocumentDirtyChangedEvent, TransferDocumentSavedEvent, TransferDocumentsBuiltEvent, TransferDocumentUpdatedEvent } from './events';
|
|
16
|
+
import type { CloseSessionArgs, CreateModelDocumentArgs, CreateSessionArgs, GetModelDocumentArgs, GetProjectForUriArgs, TransferDeleteDocumentArgs, TransferPersistDocumentArgs, TransferSaveDocumentArgs, WatchModelDocumentArgs, TransferUpdateDocumentArgs, TransferUpdateDocumentsArgs } from './requests';
|
|
17
17
|
/**
|
|
18
18
|
* Document-scoped slice of the data-server wire contract: the per-document
|
|
19
19
|
* lifecycle (get / update / save), the per-`(uri, clientId)` watch
|
|
@@ -32,34 +32,72 @@ import type { GetModelDocumentArgs, GetProjectForUriArgs, TransferSaveDocumentAr
|
|
|
32
32
|
*/
|
|
33
33
|
export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic> {
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* {@link getModelDocument} returns, except that `version` is taken from
|
|
40
|
-
* the text-document store so the caller's first `baseVersion` write
|
|
41
|
-
* cannot self-conflict. Idempotent in registration terms: opening an
|
|
42
|
-
* already-open document refreshes the client registration. Note it does
|
|
43
|
-
* NOT avoid a rebuild — a second client attaching triggers
|
|
44
|
-
* `refreshContent`, which fires a change event, so mounting a form on a
|
|
45
|
-
* document already open in a text editor rebuilds it.
|
|
35
|
+
* Register `args.clientId` as a client session owned by this connection.
|
|
36
|
+
* Rejects with a `DuplicateClientIdError` code when the id is live anywhere
|
|
37
|
+
* in the server process, and with a `ReservedClientIdError` code when the
|
|
38
|
+
* framework reserves it.
|
|
46
39
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
40
|
+
* A request carrying a registered id acts as that session: it writes only
|
|
41
|
+
* what the session has open, failing with a `DocumentNotOpenError` code
|
|
42
|
+
* otherwise, and opens nothing implicitly; its open reads the file and takes
|
|
43
|
+
* no `languageId`, `version` or `text` seed. The session ends with
|
|
44
|
+
* {@link closeSession} or when the connection closes, and either closes
|
|
45
|
+
* every document it has open.
|
|
46
|
+
*
|
|
47
|
+
* A registration carrying the `resumeToken` an earlier registration of the
|
|
48
|
+
* same id carried ends that session first, from any connection, so a client
|
|
49
|
+
* whose connection dropped can register again before the server notices.
|
|
50
|
+
*/
|
|
51
|
+
createSession(args: CreateSessionArgs): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* End a session this connection registered: close every document it has
|
|
54
|
+
* open, drop its watches, and free its id. A no-op for an id this
|
|
55
|
+
* connection did not register.
|
|
51
56
|
*/
|
|
52
|
-
|
|
57
|
+
closeSession(args: CloseSessionArgs): Promise<void>;
|
|
53
58
|
/**
|
|
54
|
-
*
|
|
55
|
-
* {@link openModelDocument}
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
|
|
59
|
+
* Create a document with `args.text`, open for the session, and return it
|
|
60
|
+
* as {@link openModelDocument} does, with the version the create made in
|
|
61
|
+
* `created`. The answer is read after the create, so it can already hold
|
|
62
|
+
* another client's write or an integrity repair; a write based on
|
|
63
|
+
* `created.version` then conflicts. It reaches disk with the first save.
|
|
64
|
+
* Fails when the file exists or any client has the URI open, and with a
|
|
65
|
+
* `SessionClosedError` code when `args.clientId` is not a session
|
|
66
|
+
* registered on this connection.
|
|
67
|
+
*/
|
|
68
|
+
createModelDocument(args: CreateModelDocumentArgs): Promise<TransferCreatedDocument<TTransfer, TDiagnostic>>;
|
|
69
|
+
/**
|
|
70
|
+
* Write several documents the session has open, all or none: a conflict or
|
|
71
|
+
* a document not open fails the whole set before any text applies.
|
|
72
|
+
* Resolves to the documents in the order given. Only for a session
|
|
73
|
+
* registered on this connection.
|
|
74
|
+
*/
|
|
75
|
+
updateModelDocuments(args: TransferUpdateDocumentsArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Open a document for the client session `clientId` and return its current
|
|
78
|
+
* state. `clientId` must be a session this connection registered with
|
|
79
|
+
* {@link createSession}; any other id fails with the closed-session code,
|
|
80
|
+
* as every document request here does. The document is read from disk
|
|
81
|
+
* unless a client has it open already, so the request carries no
|
|
82
|
+
* `languageId`, `version` or `text` seed. Returns the document at
|
|
83
|
+
* the server's configured target phase, as {@link getModelDocument} does.
|
|
84
|
+
* A repeat open changes nothing.
|
|
85
|
+
*
|
|
86
|
+
* Pair with {@link watchModelDocument} to receive subsequent build-phase
|
|
87
|
+
* events (open returns a one-shot snapshot; later validation diagnostics
|
|
88
|
+
* arrive on the watch channel).
|
|
89
|
+
*/
|
|
90
|
+
openModelDocument(args: Pick<OpenModelArgs, 'uri' | 'clientId' | 'options'>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
91
|
+
/**
|
|
92
|
+
* Close the session's open of `uri`. Counterpart to
|
|
93
|
+
* {@link openModelDocument}; the document stays open until every client
|
|
94
|
+
* has closed it, and then the server releases it, by default reverting it
|
|
95
|
+
* to disk. The default
|
|
96
|
+
* `DataServer` impl ALSO releases any watch for the same
|
|
97
|
+
* `(uri, clientId)` (a forgotten {@link unwatchModelDocument} would
|
|
98
|
+
* otherwise leak dispatch; the implicit unwatch is idempotent).
|
|
99
|
+
* `watchModelDocument` is NOT coupled the other way: opening does not force
|
|
100
|
+
* a watch, so a snapshot reader can open without streaming.
|
|
63
101
|
*/
|
|
64
102
|
closeModelDocument(args: CloseModelArgs): Promise<void>;
|
|
65
103
|
/**
|
|
@@ -70,32 +108,65 @@ export interface DocumentServerProtocol<TTransfer extends TransferElement, TDiag
|
|
|
70
108
|
*/
|
|
71
109
|
getModelDocument(args: GetModelDocumentArgs): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
72
110
|
/**
|
|
73
|
-
* Update a document's content
|
|
74
|
-
*
|
|
75
|
-
* response.
|
|
111
|
+
* Update a document's content as the session `clientId`, which must have
|
|
112
|
+
* it open. The response carries the latest built state including
|
|
113
|
+
* diagnostics; callers observe convergence via that response.
|
|
76
114
|
*/
|
|
77
115
|
updateModelDocument(args: TransferUpdateDocumentArgs<TTransfer>): Promise<TransferDocument<TTransfer, TDiagnostic>>;
|
|
78
116
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
117
|
+
* Write a document as the session `clientId`, which must have it open, and
|
|
118
|
+
* persist it to disk. The response is the build of the text written, with
|
|
119
|
+
* its version in `persisted`, sent once the language client has answered
|
|
120
|
+
* the push of that text, applied or refused, or a server-side bound on
|
|
121
|
+
* that wait passes; it does not wait again for a push that wait already
|
|
122
|
+
* gave up on and the client has not answered since. Save semantics depend
|
|
123
|
+
* on the filesystem-provider wiring; rejection paths surface as awaited
|
|
82
124
|
* promise rejections.
|
|
83
125
|
*/
|
|
84
|
-
saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<
|
|
126
|
+
saveModelDocument(args: TransferSaveDocumentArgs<TTransfer>): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
|
|
127
|
+
/**
|
|
128
|
+
* Persist the text the server holds for a document the session `clientId`
|
|
129
|
+
* has open, as it is: no update and no serialisation, so another client's
|
|
130
|
+
* unsaved text keeps its formatting. `baseVersion` is checked in the step
|
|
131
|
+
* that takes the text, so text that moved on fails with a `ConflictError`
|
|
132
|
+
* code. The saved event names this session, whoever wrote the text.
|
|
133
|
+
* Answers after the same language-client wait as {@link saveModelDocument},
|
|
134
|
+
* with the document's latest build, read after that wait, so another
|
|
135
|
+
* session's write during it shows; `persisted` carries the version written.
|
|
136
|
+
*/
|
|
137
|
+
persistModelDocument(args: TransferPersistDocumentArgs): Promise<TransferSavedDocument<TTransfer, TDiagnostic>>;
|
|
138
|
+
/**
|
|
139
|
+
* Delete a document the session `clientId` has open, at once: its file,
|
|
140
|
+
* then the document, as a deletion a file watcher reports removes it. Every
|
|
141
|
+
* session's open of it closes and every client hears
|
|
142
|
+
* {@link DocumentClientProtocol.onDocumentDeleted} naming this session; the
|
|
143
|
+
* session's own watch is released, as {@link closeModelDocument} releases
|
|
144
|
+
* it. `baseVersion` is checked in the step that marks the document for
|
|
145
|
+
* deletion, so text that moved on fails with a `ConflictError` code. A file
|
|
146
|
+
* already gone deletes only the document; a file that cannot be removed
|
|
147
|
+
* fails the call and changes nothing. Resolves once the build that removes
|
|
148
|
+
* the document has run; a read then answers the URI without a model, unless
|
|
149
|
+
* an editor still has it open, whose buffer the document is built from.
|
|
150
|
+
*/
|
|
151
|
+
deleteModelDocument(args: TransferDeleteDocumentArgs): Promise<void>;
|
|
85
152
|
/**
|
|
86
153
|
* Start watching `(uri, clientId)`. The server starts dispatching
|
|
87
154
|
* {@link DocumentClientProtocol.onDocumentUpdated} on the paired wire
|
|
88
155
|
* for every build-phase event on `uri`.
|
|
89
156
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
157
|
+
* Answers with the key the watch's events name the document by, whether
|
|
158
|
+
* a document exists, taken once the watch is in place and the document
|
|
159
|
+
* is loaded as a read loads it, the text held at that moment, and the
|
|
160
|
+
* position of the last update or deletion event sent as of it, so an event
|
|
161
|
+
* the client heard while the watch was in flight tells by its own position
|
|
162
|
+
* whether it is newer than the answer. No handle: the event channel is the
|
|
163
|
+
* client interface. Callers fan out a single inbound `onDocumentUpdated` to
|
|
164
|
+
* multiple local listeners with their own `Emitter<T>` (matching Theia's
|
|
165
|
+
* pattern). Pair every `watchModelDocument` with
|
|
166
|
+
* {@link unwatchModelDocument} when no longer needed; the server holds the
|
|
167
|
+
* watch record until the matching unwatch lands.
|
|
97
168
|
*/
|
|
98
|
-
watchModelDocument(args: WatchModelDocumentArgs): Promise<
|
|
169
|
+
watchModelDocument(args: WatchModelDocumentArgs): Promise<TransferWatchedDocument>;
|
|
99
170
|
/**
|
|
100
171
|
* Stop watching `(uri, clientId)` previously started by
|
|
101
172
|
* {@link watchModelDocument}. Idempotent — unwatching twice is a no-op.
|
|
@@ -171,6 +242,19 @@ export interface ProjectServerProtocol<TProject extends Project = Project> {
|
|
|
171
242
|
*/
|
|
172
243
|
export interface DataServerProtocol<TTransfer extends TransferElement, TDiagnostic extends TransferDiagnostic = TransferDiagnostic, TProject extends Project = Project> extends DocumentServerProtocol<TTransfer, TDiagnostic>, ProjectServerProtocol<TProject> {
|
|
173
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* The diagnostic shape a server answers with, read back off its own
|
|
247
|
+
* declaration.
|
|
248
|
+
*
|
|
249
|
+
* This is what lets a client tier stay generic over the server alone and still
|
|
250
|
+
* describe what it hands back. Both parameters must be inferred: naming
|
|
251
|
+
* {@link TransferElement} for the transfer instead fails to match while that
|
|
252
|
+
* parameter is still generic, and a default declared against the constraint
|
|
253
|
+
* then stops satisfying it.
|
|
254
|
+
*/
|
|
255
|
+
export type DiagnosticOf<TServer> = TServer extends DocumentServerProtocol<infer _TTransfer, infer TDiagnostic> ? TDiagnostic : TransferDiagnostic;
|
|
256
|
+
/** The project shape a server answers with, read back off its own declaration. */
|
|
257
|
+
export type ProjectOf<TServer> = TServer extends ProjectServerProtocol<infer TProject> ? TProject : Project;
|
|
174
258
|
/**
|
|
175
259
|
* Cross-reference / naming slice of the server surface — scope-aware
|
|
176
260
|
* queries that resolve against the language's reference services. NOT part
|
|
@@ -181,11 +265,11 @@ export interface DataServerProtocol<TTransfer extends TransferElement, TDiagnost
|
|
|
181
265
|
* source/URI (an `ElementSource` with no URI resolves to the sole
|
|
182
266
|
* registered language; a multi-language workspace overrides).
|
|
183
267
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
268
|
+
* Not generic over a server's root type: {@link resolveReference} answers with
|
|
269
|
+
* a node a reference names, which is no document root, and candidates and
|
|
270
|
+
* names are diagnostic-free.
|
|
187
271
|
*/
|
|
188
|
-
export interface ReferenceServerProtocol
|
|
272
|
+
export interface ReferenceServerProtocol {
|
|
189
273
|
/**
|
|
190
274
|
* List the reference candidates reachable for the property named in `ctx`
|
|
191
275
|
* from its (possibly synthetic) source. Backed by the language's
|
|
@@ -197,8 +281,11 @@ export interface ReferenceServerProtocol<TTransfer extends TransferElement> {
|
|
|
197
281
|
* target's document URI, display fields, and the resolved node's encoded
|
|
198
282
|
* transfer subtree. Resolves via the language's reference services;
|
|
199
283
|
* `undefined` when the reference does not resolve.
|
|
284
|
+
*
|
|
285
|
+
* `TElement` is the caller's claim about the target node's type; nothing
|
|
286
|
+
* checks it, so leave it at the default unless the reference names one type.
|
|
200
287
|
*/
|
|
201
|
-
resolveReference(ref: ReferenceRequest): Promise<ReferenceTarget<
|
|
288
|
+
resolveReference<TElement extends TransferElement = TransferElement>(ref: ReferenceRequest): Promise<ReferenceTarget<TElement> | undefined>;
|
|
202
289
|
/**
|
|
203
290
|
* Compute the next free name for a new element of `args.type` based on
|
|
204
291
|
* `args.proposal`, unique within the `args.tier` scope (default
|
|
@@ -235,6 +322,36 @@ export interface DocumentClientProtocol<TTransfer extends TransferElement, TDiag
|
|
|
235
322
|
* codepath, not a subscription codepath).
|
|
236
323
|
*/
|
|
237
324
|
onDocumentSaved(event: TransferDocumentSavedEvent<TTransfer, TDiagnostic>): void;
|
|
325
|
+
/**
|
|
326
|
+
* Delivered when a subscribed document's text starts or stops differing
|
|
327
|
+
* from its file, as the server last knew it. Gated like
|
|
328
|
+
* {@link onDocumentSaved}; the answer at any one moment is the `dirty` of
|
|
329
|
+
* the documents the server sends. After a reconnect, a `DataSession`
|
|
330
|
+
* delivers here the answer of each document it restored, when that differs
|
|
331
|
+
* from the last this client was told: the flips while the connection was
|
|
332
|
+
* down reached no one.
|
|
333
|
+
*/
|
|
334
|
+
onDocumentDirtyChanged(event: TransferDocumentDirtyChangedEvent): void;
|
|
335
|
+
/**
|
|
336
|
+
* Delivered when a document's backing file was removed. Separate from
|
|
337
|
+
* {@link onDocumentUpdated} for the same reason as {@link onDocumentSaved},
|
|
338
|
+
* and more strongly: there is no built state to deliver, and the build-phase
|
|
339
|
+
* path cannot report a deletion at all.
|
|
340
|
+
*
|
|
341
|
+
* Ungated, because on a browser host — where the workspace lives behind the
|
|
342
|
+
* head — no other source can observe a file disappearing. Recipients that
|
|
343
|
+
* only care about their own documents filter by URI.
|
|
344
|
+
*/
|
|
345
|
+
onDocumentDeleted(event: TransferDocumentDeletedEvent): void;
|
|
346
|
+
/**
|
|
347
|
+
* Delivered once per build, naming the documents that reached the
|
|
348
|
+
* subscription phase and that
|
|
349
|
+
* nobody on this connection watches — chiefly the ones rebuilt as a cascade
|
|
350
|
+
* from a dependency's change, which no filesystem watcher can see because
|
|
351
|
+
* their own files did not change. The complement of
|
|
352
|
+
* {@link onDocumentUpdated}; carries URIs and no documents.
|
|
353
|
+
*/
|
|
354
|
+
onDocumentsBuilt(event: TransferDocumentsBuiltEvent): void;
|
|
238
355
|
}
|
|
239
356
|
/**
|
|
240
357
|
* Project-scoped slice of the client surface — the project-registry change
|