@lspeasy/client 3.0.2 → 3.1.0
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/dist/capability-guard.d.ts +78 -4
- package/dist/capability-guard.d.ts.map +1 -1
- package/dist/capability-guard.js +78 -4
- package/dist/capability-guard.js.map +1 -1
- package/dist/capability-proxy.js.map +1 -1
- package/dist/client.d.ts +166 -27
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +204 -18
- package/dist/client.js.map +1 -1
- package/dist/connection/health.d.ts +40 -0
- package/dist/connection/health.d.ts.map +1 -1
- package/dist/connection/health.js +40 -0
- package/dist/connection/health.js.map +1 -1
- package/dist/connection/heartbeat.d.ts +29 -0
- package/dist/connection/heartbeat.d.ts.map +1 -1
- package/dist/connection/heartbeat.js +29 -0
- package/dist/connection/heartbeat.js.map +1 -1
- package/dist/connection/partial-result-collector.js.map +1 -1
- package/dist/connection/registration-store.js.map +1 -1
- package/dist/connection/types.d.ts +46 -4
- package/dist/connection/types.d.ts.map +1 -1
- package/dist/connection/types.js +11 -3
- package/dist/connection/types.js.map +1 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -1
- package/dist/notifications/wait.d.ts +57 -2
- package/dist/notifications/wait.d.ts.map +1 -1
- package/dist/notifications/wait.js +44 -1
- package/dist/notifications/wait.js.map +1 -1
- package/dist/progress.js.map +1 -1
- package/dist/types.d.ts +70 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js.map +1 -1
- package/package.json +6 -7
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runs interval-based heartbeat checks for active transports.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Created internally by `LSPClient` when `ClientOptions.heartbeat` is
|
|
6
|
+
* configured. The monitor periodically sends a ping (via `onPing`) and checks
|
|
7
|
+
* whether a pong was received within `timeout` ms. If not, `onUnresponsive`
|
|
8
|
+
* is called so the client can close and attempt to reconnect.
|
|
9
|
+
*
|
|
10
|
+
* @useWhen
|
|
11
|
+
* You need to detect silent transport failures — for example, when the server
|
|
12
|
+
* process dies without closing the socket, leaving the client hanging
|
|
13
|
+
* indefinitely on pending requests.
|
|
14
|
+
*
|
|
15
|
+
* @avoidWhen
|
|
16
|
+
* The transport already provides its own keep-alive mechanism (e.g. WebSocket
|
|
17
|
+
* ping frames) — adding a heartbeat on top creates redundant round-trips and
|
|
18
|
+
* may interfere with the transport's own timeout logic.
|
|
19
|
+
*
|
|
20
|
+
* @never
|
|
21
|
+
* NEVER set `interval` shorter than the typical round-trip latency for your
|
|
22
|
+
* transport — doing so causes constant `onUnresponsive` callbacks on any
|
|
23
|
+
* non-local transport, triggering spurious reconnects.
|
|
24
|
+
*
|
|
25
|
+
* NEVER rely on heartbeat for authentication or access control. The heartbeat
|
|
26
|
+
* only confirms the transport is alive; it carries no identity information.
|
|
27
|
+
*
|
|
28
|
+
* @category Client
|
|
3
29
|
*/
|
|
4
30
|
export class HeartbeatMonitor {
|
|
5
31
|
options;
|
|
@@ -64,6 +90,9 @@ export class HeartbeatMonitor {
|
|
|
64
90
|
}
|
|
65
91
|
/**
|
|
66
92
|
* Returns the latest heartbeat status snapshot.
|
|
93
|
+
*
|
|
94
|
+
* @returns A shallow copy of the current {@link HeartbeatStatus}, including
|
|
95
|
+
* timing and responsiveness information.
|
|
67
96
|
*/
|
|
68
97
|
getStatus() {
|
|
69
98
|
return { ...this.status };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../src/connection/heartbeat.ts"],"names":[],"mappings":"AAYA
|
|
1
|
+
{"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../src/connection/heartbeat.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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I,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,IAAI,CAAC,MAAM;YACd,QAAQ,EAAE,IAAI,IAAI,EAAE;YACpB,YAAY,EAAE,IAAI;SACnB,CAAC;QAEF,IAAI,eAAe,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partial-result-collector.js","sourceRoot":"","sources":["../../src/connection/partial-result-collector.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,MAAM,OAAO,sBAAsB;IAChB,UAAU,GAAG,IAAI,GAAG,EAAqC,CAAC;IAE3E,KAAK,CAAW,KAAoB,EAAE,SAAoC
|
|
1
|
+
{"version":3,"file":"partial-result-collector.js","sourceRoot":"","sources":["../../src/connection/partial-result-collector.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,MAAM,OAAO,sBAAsB;IAChB,UAAU,GAAG,IAAI,GAAG,EAAqC,CAAC;IAE3E,KAAK,CAAW,KAAoB,EAAE,SAAoC;QACxE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE;YACzB,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,SAAqC;SACjD,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,KAAoB,EAAE,KAAc;QACvC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;QACf,CAAC;QAED,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAW,KAAoB;QACnC,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,SAAS,CAAC,QAAsB,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,KAAoB;QACxB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration-store.js","sourceRoot":"","sources":["../../src/connection/registration-store.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,MAAM,OAAO,iBAAiB;IACX,iBAAiB,GAAG,IAAI,GAAG,EAA+B,CAAC;IAE5E,MAAM,CAAC,YAAiC
|
|
1
|
+
{"version":3,"file":"registration-store.js","sourceRoot":"","sources":["../../src/connection/registration-store.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,MAAM,OAAO,iBAAiB;IACX,iBAAiB,GAAG,IAAI,GAAG,EAA+B,CAAC;IAE5E,MAAM,CAAC,YAAiC;QACtC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,EAAU;QACf,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAClC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Lifecycle state
|
|
2
|
+
* Lifecycle state of an `LSPClient` connection.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Transitions: `Disconnected` → `Connecting` (on `connect()`) → `Connected`
|
|
6
|
+
* (after `initialized`) → `Disconnecting` (on `disconnect()`) →
|
|
7
|
+
* `Disconnected`.
|
|
8
|
+
*
|
|
9
|
+
* Listen for state changes via `LSPClient.onConnectionStateChange`.
|
|
10
|
+
*
|
|
11
|
+
* @category Client
|
|
3
12
|
*/
|
|
4
13
|
export declare enum ConnectionState {
|
|
5
14
|
Connecting = "connecting",
|
|
@@ -9,39 +18,72 @@ export declare enum ConnectionState {
|
|
|
9
18
|
}
|
|
10
19
|
/**
|
|
11
20
|
* Configuration for optional heartbeat monitoring.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* When `enabled` is `true`, the client sends a `$/ping` request at each
|
|
24
|
+
* `interval` milliseconds. If no response arrives within `timeout`
|
|
25
|
+
* milliseconds, the connection is marked unresponsive.
|
|
26
|
+
*
|
|
27
|
+
* @config
|
|
28
|
+
* @category Client
|
|
12
29
|
*/
|
|
13
30
|
export interface HeartbeatConfig {
|
|
31
|
+
/** Whether heartbeat monitoring is active. */
|
|
14
32
|
enabled?: boolean;
|
|
33
|
+
/** Interval between pings in milliseconds. */
|
|
15
34
|
interval: number;
|
|
35
|
+
/** Time to wait for a pong response in milliseconds. */
|
|
16
36
|
timeout: number;
|
|
17
37
|
}
|
|
18
38
|
/**
|
|
19
|
-
*
|
|
39
|
+
* Snapshot of the current heartbeat monitoring status.
|
|
40
|
+
*
|
|
41
|
+
* @category Client
|
|
20
42
|
*/
|
|
21
43
|
export interface HeartbeatStatus {
|
|
44
|
+
/** Whether heartbeat monitoring is active. */
|
|
22
45
|
enabled: boolean;
|
|
46
|
+
/** Interval between pings in milliseconds. */
|
|
23
47
|
interval: number;
|
|
48
|
+
/** Timeout in milliseconds before a ping is considered unanswered. */
|
|
24
49
|
timeout: number;
|
|
50
|
+
/** Timestamp of the last outgoing ping, or `null` if no ping has been sent. */
|
|
25
51
|
lastPing: Date | null;
|
|
52
|
+
/** Timestamp of the last received pong, or `null` if no pong has been received. */
|
|
26
53
|
lastPong: Date | null;
|
|
54
|
+
/** Whether the server responded to the most recent ping within the timeout window. */
|
|
27
55
|
isResponsive: boolean;
|
|
28
56
|
}
|
|
29
57
|
/**
|
|
30
|
-
* Aggregated connection health
|
|
58
|
+
* Aggregated connection health snapshot returned by
|
|
59
|
+
* `LSPClient.getConnectionHealth()`.
|
|
60
|
+
*
|
|
61
|
+
* @category Client
|
|
31
62
|
*/
|
|
32
63
|
export interface ConnectionHealth {
|
|
64
|
+
/** Current lifecycle state of the connection. */
|
|
33
65
|
state: ConnectionState;
|
|
66
|
+
/** Timestamp of the last outgoing message, or `null` if none has been sent. */
|
|
34
67
|
lastMessageSent: Date | null;
|
|
68
|
+
/** Timestamp of the last incoming message, or `null` if none has been received. */
|
|
35
69
|
lastMessageReceived: Date | null;
|
|
70
|
+
/** Heartbeat monitoring snapshot, present only when heartbeat is configured. */
|
|
36
71
|
heartbeat?: HeartbeatStatus;
|
|
37
72
|
}
|
|
38
73
|
/**
|
|
39
|
-
*
|
|
74
|
+
* Payload emitted when the connection state changes.
|
|
75
|
+
* Subscribe via `LSPClient.onConnectionStateChange()`.
|
|
76
|
+
*
|
|
77
|
+
* @category Client
|
|
40
78
|
*/
|
|
41
79
|
export interface StateChangeEvent {
|
|
80
|
+
/** The state the connection was in before this transition. */
|
|
42
81
|
previous: ConnectionState;
|
|
82
|
+
/** The state the connection has transitioned into. */
|
|
43
83
|
current: ConnectionState;
|
|
84
|
+
/** Wall-clock time at which the state transition occurred. */
|
|
44
85
|
timestamp: Date;
|
|
86
|
+
/** Optional human-readable description of why the state changed. */
|
|
45
87
|
reason?: string;
|
|
46
88
|
}
|
|
47
89
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/connection/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/connection/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,oBAAY,eAAe;IACzB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;CAC9B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,mFAAmF;IACnF,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,sFAAsF;IACtF,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,KAAK,EAAE,eAAe,CAAC;IACvB,+EAA+E;IAC/E,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAC7B,mFAAmF;IACnF,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC;IACjC,gFAAgF;IAChF,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,QAAQ,EAAE,eAAe,CAAC;IAC1B,sDAAsD;IACtD,OAAO,EAAE,eAAe,CAAC;IACzB,8DAA8D;IAC9D,SAAS,EAAE,IAAI,CAAC;IAChB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/connection/types.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
export { ConnectionState };
|
|
2
1
|
/**
|
|
3
|
-
* Lifecycle state
|
|
2
|
+
* Lifecycle state of an `LSPClient` connection.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Transitions: `Disconnected` → `Connecting` (on `connect()`) → `Connected`
|
|
6
|
+
* (after `initialized`) → `Disconnecting` (on `disconnect()`) →
|
|
7
|
+
* `Disconnected`.
|
|
8
|
+
*
|
|
9
|
+
* Listen for state changes via `LSPClient.onConnectionStateChange`.
|
|
10
|
+
*
|
|
11
|
+
* @category Client
|
|
4
12
|
*/
|
|
5
|
-
var ConnectionState;
|
|
13
|
+
export var ConnectionState;
|
|
6
14
|
(function (ConnectionState) {
|
|
7
15
|
ConnectionState["Connecting"] = "connecting";
|
|
8
16
|
ConnectionState["Connected"] = "connected";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/connection/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/connection/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,4CAAyB,CAAA;IACzB,0CAAuB,CAAA;IACvB,kDAA+B,CAAA;IAC/B,gDAA6B,CAAA;AAC/B,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* LSP client package for connecting to language servers.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Use `@lspeasy/client` when you need to build the **consumer** side of the
|
|
6
|
+
* Language Server Protocol — an editor extension, a CLI analysis tool, a test
|
|
7
|
+
* harness, or any process that speaks to a language server process.
|
|
8
|
+
*
|
|
9
|
+
* The primary entry point is {@link LSPClient}. Construct it with
|
|
10
|
+
* {@link ClientOptions}, call `connect(transport)` to complete the LSP
|
|
11
|
+
* handshake, then use `expect<ServerCaps>()` to get typed access to
|
|
12
|
+
* capability-aware namespaces (e.g. `client.textDocument.hover(params)`).
|
|
13
|
+
*
|
|
14
|
+
* ### Transport Decision Tree
|
|
15
|
+
*
|
|
16
|
+
* **Stdio** (`StdioTransport` from `@lspeasy/core/node`)
|
|
17
|
+
* — Use when: spawning the language server as a child process (the canonical
|
|
18
|
+
* editor extension pattern). Zero network overhead; server and client share
|
|
19
|
+
* a lifespan. Failure mode: server process dies silently → stdout EOF fires
|
|
20
|
+
* `onClose`; pair with `HeartbeatMonitor` on long-lived processes.
|
|
21
|
+
*
|
|
22
|
+
* **WebSocket** (`WebSocketTransport` from `@lspeasy/core`)
|
|
23
|
+
* — Use when: the language server runs remotely (CI, container, cloud dev env)
|
|
24
|
+
* or must be browser-accessible. Supports reconnect with exponential back-off.
|
|
25
|
+
* Failure mode: network partition → `onError` fires without `onClose`;
|
|
26
|
+
* enable `enableReconnect` and subscribe to `ConnectionHealthTracker` events.
|
|
27
|
+
*
|
|
28
|
+
* **TCP** (`TcpTransport` from `@lspeasy/core/node`)
|
|
29
|
+
* — Use when: you need a persistent local socket and control both ends
|
|
30
|
+
* (e.g. a test harness or a daemon that outlives the client process).
|
|
31
|
+
* Failure mode: port conflict at startup; use `mode: 'client'` only after
|
|
32
|
+
* confirming the server is listening, or wrap in a retry loop.
|
|
33
|
+
*
|
|
34
|
+
* **DedicatedWorkerTransport** (`DedicatedWorkerTransport` from `@lspeasy/core`)
|
|
35
|
+
* — Use when: running the language server in a Web Worker for browser isolation.
|
|
36
|
+
* Zero latency (shared memory), no WebSocket overhead. Failure mode: worker
|
|
37
|
+
* uncaught exception terminates silently; subscribe to `worker.onerror`.
|
|
38
|
+
*
|
|
39
|
+
* ### Connection health
|
|
40
|
+
* Use {@link ConnectionHealthTracker} and {@link HeartbeatMonitor} to detect
|
|
41
|
+
* silent transport failures. Subscribe to state-change events via
|
|
42
|
+
* {@link ConnectionState}.
|
|
43
|
+
*
|
|
44
|
+
* ### Dynamic registration
|
|
45
|
+
* The client handles `client/registerCapability` and
|
|
46
|
+
* `client/unregisterCapability` requests from the server automatically,
|
|
47
|
+
* updating the typed namespaces at runtime.
|
|
48
|
+
*
|
|
49
|
+
* @packageDocumentation
|
|
3
50
|
*/
|
|
4
51
|
export { LSPClient } from './client.js';
|
|
5
52
|
export { CapabilityGuard, ClientCapabilityGuard } from './capability-guard.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACnG,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,YAAY,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAGxE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* LSP client package for connecting to language servers.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Use `@lspeasy/client` when you need to build the **consumer** side of the
|
|
6
|
+
* Language Server Protocol — an editor extension, a CLI analysis tool, a test
|
|
7
|
+
* harness, or any process that speaks to a language server process.
|
|
8
|
+
*
|
|
9
|
+
* The primary entry point is {@link LSPClient}. Construct it with
|
|
10
|
+
* {@link ClientOptions}, call `connect(transport)` to complete the LSP
|
|
11
|
+
* handshake, then use `expect<ServerCaps>()` to get typed access to
|
|
12
|
+
* capability-aware namespaces (e.g. `client.textDocument.hover(params)`).
|
|
13
|
+
*
|
|
14
|
+
* ### Transport Decision Tree
|
|
15
|
+
*
|
|
16
|
+
* **Stdio** (`StdioTransport` from `@lspeasy/core/node`)
|
|
17
|
+
* — Use when: spawning the language server as a child process (the canonical
|
|
18
|
+
* editor extension pattern). Zero network overhead; server and client share
|
|
19
|
+
* a lifespan. Failure mode: server process dies silently → stdout EOF fires
|
|
20
|
+
* `onClose`; pair with `HeartbeatMonitor` on long-lived processes.
|
|
21
|
+
*
|
|
22
|
+
* **WebSocket** (`WebSocketTransport` from `@lspeasy/core`)
|
|
23
|
+
* — Use when: the language server runs remotely (CI, container, cloud dev env)
|
|
24
|
+
* or must be browser-accessible. Supports reconnect with exponential back-off.
|
|
25
|
+
* Failure mode: network partition → `onError` fires without `onClose`;
|
|
26
|
+
* enable `enableReconnect` and subscribe to `ConnectionHealthTracker` events.
|
|
27
|
+
*
|
|
28
|
+
* **TCP** (`TcpTransport` from `@lspeasy/core/node`)
|
|
29
|
+
* — Use when: you need a persistent local socket and control both ends
|
|
30
|
+
* (e.g. a test harness or a daemon that outlives the client process).
|
|
31
|
+
* Failure mode: port conflict at startup; use `mode: 'client'` only after
|
|
32
|
+
* confirming the server is listening, or wrap in a retry loop.
|
|
33
|
+
*
|
|
34
|
+
* **DedicatedWorkerTransport** (`DedicatedWorkerTransport` from `@lspeasy/core`)
|
|
35
|
+
* — Use when: running the language server in a Web Worker for browser isolation.
|
|
36
|
+
* Zero latency (shared memory), no WebSocket overhead. Failure mode: worker
|
|
37
|
+
* uncaught exception terminates silently; subscribe to `worker.onerror`.
|
|
38
|
+
*
|
|
39
|
+
* ### Connection health
|
|
40
|
+
* Use {@link ConnectionHealthTracker} and {@link HeartbeatMonitor} to detect
|
|
41
|
+
* silent transport failures. Subscribe to state-change events via
|
|
42
|
+
* {@link ConnectionState}.
|
|
43
|
+
*
|
|
44
|
+
* ### Dynamic registration
|
|
45
|
+
* The client handles `client/registerCapability` and
|
|
46
|
+
* `client/unregisterCapability` requests from the server automatically,
|
|
47
|
+
* updating the typed namespaces at runtime.
|
|
48
|
+
*
|
|
49
|
+
* @packageDocumentation
|
|
3
50
|
*/
|
|
4
51
|
export { LSPClient } from './client.js';
|
|
5
52
|
export { CapabilityGuard, ClientCapabilityGuard } from './capability-guard.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAS/E,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAOnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,12 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Options for `NotificationWaiter` and `LSPClient.waitForNotification`.
|
|
3
|
+
*
|
|
4
|
+
* @config
|
|
5
|
+
* @typeParam TParams - The notification params type for the awaited method.
|
|
6
|
+
* @category Client
|
|
3
7
|
*/
|
|
4
8
|
export interface NotificationWaitOptions<TParams> {
|
|
9
|
+
/**
|
|
10
|
+
* Maximum time to wait in milliseconds before rejecting with a timeout error.
|
|
11
|
+
*/
|
|
5
12
|
timeout: number;
|
|
13
|
+
/**
|
|
14
|
+
* Optional predicate to skip notifications that don't match the expected
|
|
15
|
+
* content. The waiter continues listening until a matching notification
|
|
16
|
+
* arrives or the timeout expires.
|
|
17
|
+
*/
|
|
6
18
|
filter?: (params: TParams) => boolean;
|
|
7
19
|
}
|
|
8
20
|
/**
|
|
9
|
-
* Tracks a single wait-for-notification operation and timeout lifecycle.
|
|
21
|
+
* Tracks a single wait-for-notification operation and its timeout lifecycle.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Created internally by `LSPClient.waitForNotification`. Use
|
|
25
|
+
* `LSPClient.waitForNotification` rather than instantiating this class
|
|
26
|
+
* directly.
|
|
27
|
+
*
|
|
28
|
+
* @useWhen
|
|
29
|
+
* You need to await a specific server-to-client notification after triggering
|
|
30
|
+
* a server-side operation — for example, waiting for
|
|
31
|
+
* `textDocument/publishDiagnostics` after saving a document.
|
|
32
|
+
*
|
|
33
|
+
* @avoidWhen
|
|
34
|
+
* You need to listen for ongoing notifications (not a one-shot wait) — use
|
|
35
|
+
* `LSPClient.onNotification` for persistent subscriptions instead.
|
|
36
|
+
*
|
|
37
|
+
* @never
|
|
38
|
+
* NEVER create a `NotificationWaiter` without setting a timeout — an
|
|
39
|
+
* indefinite wait will leak the waiter permanently if the notification never
|
|
40
|
+
* arrives (e.g. the server suppresses it for certain file types).
|
|
41
|
+
*
|
|
42
|
+
* NEVER use `NotificationWaiter` to wait for notifications that arrive before
|
|
43
|
+
* the waiter is registered. The waiter only sees notifications emitted after
|
|
44
|
+
* `start()` is called; earlier notifications are silently missed.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* // Wait for diagnostics after saving
|
|
49
|
+
* const diags = await client.waitForNotification(
|
|
50
|
+
* 'textDocument/publishDiagnostics',
|
|
51
|
+
* {
|
|
52
|
+
* timeout: 5000,
|
|
53
|
+
* filter: (params) => params.uri === 'file:///src/main.ts',
|
|
54
|
+
* }
|
|
55
|
+
* );
|
|
56
|
+
* console.log(diags.diagnostics);
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @typeParam TParams - The notification params type.
|
|
60
|
+
* @category Client
|
|
10
61
|
*/
|
|
11
62
|
export declare class NotificationWaiter<TParams> {
|
|
12
63
|
private readonly method;
|
|
@@ -22,6 +73,10 @@ export declare class NotificationWaiter<TParams> {
|
|
|
22
73
|
start(): void;
|
|
23
74
|
/**
|
|
24
75
|
* Returns whether an incoming notification satisfies this waiter.
|
|
76
|
+
*
|
|
77
|
+
* @param method - The notification method string of the incoming message.
|
|
78
|
+
* @param params - The notification params to test against the optional filter predicate.
|
|
79
|
+
* @returns `true` when the method matches and the filter (if any) passes.
|
|
25
80
|
*/
|
|
26
81
|
matches(method: string, params: TParams): boolean;
|
|
27
82
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../src/notifications/wait.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../src/notifications/wait.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB,CAAC,OAAO;IAC9C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,kBAAkB,CAAC,OAAO;IAMnC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAGxB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAT5B,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAElD,YACmB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,CAAC,OAAO,CAAC,EAC1D,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EAClC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EACb,SAAS,EAAE,MAAM,IAAI,EAIvC;IAED;;OAEG;IACH,KAAK,IAAI,IAAI,CASZ;IAED;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAUhD;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAG7B;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAGzB;IAED;;OAEG;IACH,OAAO,IAAI,IAAI,CAOd;CACF"}
|
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tracks a single wait-for-notification operation and timeout lifecycle.
|
|
2
|
+
* Tracks a single wait-for-notification operation and its timeout lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Created internally by `LSPClient.waitForNotification`. Use
|
|
6
|
+
* `LSPClient.waitForNotification` rather than instantiating this class
|
|
7
|
+
* directly.
|
|
8
|
+
*
|
|
9
|
+
* @useWhen
|
|
10
|
+
* You need to await a specific server-to-client notification after triggering
|
|
11
|
+
* a server-side operation — for example, waiting for
|
|
12
|
+
* `textDocument/publishDiagnostics` after saving a document.
|
|
13
|
+
*
|
|
14
|
+
* @avoidWhen
|
|
15
|
+
* You need to listen for ongoing notifications (not a one-shot wait) — use
|
|
16
|
+
* `LSPClient.onNotification` for persistent subscriptions instead.
|
|
17
|
+
*
|
|
18
|
+
* @never
|
|
19
|
+
* NEVER create a `NotificationWaiter` without setting a timeout — an
|
|
20
|
+
* indefinite wait will leak the waiter permanently if the notification never
|
|
21
|
+
* arrives (e.g. the server suppresses it for certain file types).
|
|
22
|
+
*
|
|
23
|
+
* NEVER use `NotificationWaiter` to wait for notifications that arrive before
|
|
24
|
+
* the waiter is registered. The waiter only sees notifications emitted after
|
|
25
|
+
* `start()` is called; earlier notifications are silently missed.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Wait for diagnostics after saving
|
|
30
|
+
* const diags = await client.waitForNotification(
|
|
31
|
+
* 'textDocument/publishDiagnostics',
|
|
32
|
+
* {
|
|
33
|
+
* timeout: 5000,
|
|
34
|
+
* filter: (params) => params.uri === 'file:///src/main.ts',
|
|
35
|
+
* }
|
|
36
|
+
* );
|
|
37
|
+
* console.log(diags.diagnostics);
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @typeParam TParams - The notification params type.
|
|
41
|
+
* @category Client
|
|
3
42
|
*/
|
|
4
43
|
export class NotificationWaiter {
|
|
5
44
|
method;
|
|
@@ -26,6 +65,10 @@ export class NotificationWaiter {
|
|
|
26
65
|
}
|
|
27
66
|
/**
|
|
28
67
|
* Returns whether an incoming notification satisfies this waiter.
|
|
68
|
+
*
|
|
69
|
+
* @param method - The notification method string of the incoming message.
|
|
70
|
+
* @param params - The notification params to test against the optional filter predicate.
|
|
71
|
+
* @returns `true` when the method matches and the filter (if any) passes.
|
|
29
72
|
*/
|
|
30
73
|
matches(method, params) {
|
|
31
74
|
if (method !== this.method) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait.js","sourceRoot":"","sources":["../../src/notifications/wait.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wait.js","sourceRoot":"","sources":["../../src/notifications/wait.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAO,kBAAkB;IAMV,MAAM;IACN,OAAO;IAGP,SAAS;IATpB,aAAa,CAA6B;IACjC,SAAS,CAA4B;IACrC,QAAQ,CAAyB;IAElD,YACmB,MAAc,EACd,OAAyC,EAC1D,OAAkC,EAClC,MAA8B,EACb,SAAqB;sBAJrB,MAAM;uBACN,OAAO;yBAGP,SAAS;QAE1B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE;YACnC,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,QAAQ,CACX,IAAI,KAAK,CACP,uCAAuC,IAAI,CAAC,MAAM,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,CACtF,CACF,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,MAAc,EAAE,MAAe;QACrC,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,MAAe;QACrB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAY;QACjB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACjC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QACjC,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;CACF"}
|
package/dist/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoCH;;;GAGG;AACH,MAAM,OAAO,eAAe;IAClB,QAAQ,GAAG,IAAI,GAAG,EAAkC,CAAC;IACrD,cAAc,GAAsB,EAAE,CAAC;IAE/C;;OAEG;IACH,UAAU,CAAC,KAAoB,EAAE,OAAwB
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.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ts
CHANGED
|
@@ -10,7 +10,14 @@ import type { HeartbeatConfig } from './connection/types.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export type { Client } from '@lspeasy/core';
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Configuration for an `LSPClient` instance.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Passed to the `LSPClient` constructor. All fields are optional; the client
|
|
17
|
+
* works with zero configuration.
|
|
18
|
+
*
|
|
19
|
+
* @config
|
|
20
|
+
* @category Client
|
|
14
21
|
*/
|
|
15
22
|
export interface ClientOptions<ClientCaps extends Partial<ClientCapabilities> = ClientCapabilities> {
|
|
16
23
|
/**
|
|
@@ -25,6 +32,25 @@ export interface ClientOptions<ClientCaps extends Partial<ClientCapabilities> =
|
|
|
25
32
|
* Client capabilities to advertise
|
|
26
33
|
*/
|
|
27
34
|
capabilities?: ClientCaps;
|
|
35
|
+
/**
|
|
36
|
+
* Workspace root URI sent in the `initialize` request (`rootUri`).
|
|
37
|
+
*
|
|
38
|
+
* Defaults to `null`. Although `rootUri` is deprecated in the LSP spec in
|
|
39
|
+
* favour of `workspaceFolders`, many servers (e.g. typescript-language-server)
|
|
40
|
+
* still read it to locate the project root, so set it for reliable indexing.
|
|
41
|
+
*/
|
|
42
|
+
rootUri?: string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Workspace folders sent in the `initialize` request.
|
|
45
|
+
*
|
|
46
|
+
* The modern replacement for `rootUri`. When omitted and `rootUri` is set,
|
|
47
|
+
* the client does not synthesize folders — pass them explicitly if the server
|
|
48
|
+
* relies on `workspaceFolders`.
|
|
49
|
+
*/
|
|
50
|
+
workspaceFolders?: Array<{
|
|
51
|
+
uri: string;
|
|
52
|
+
name: string;
|
|
53
|
+
}> | null;
|
|
28
54
|
/**
|
|
29
55
|
* Logger instance for client logging
|
|
30
56
|
*/
|
|
@@ -61,43 +87,81 @@ export interface ClientOptions<ClientCaps extends Partial<ClientCapabilities> =
|
|
|
61
87
|
onValidationError?: (error: ZodError, response: ResponseMessage) => void;
|
|
62
88
|
}
|
|
63
89
|
/**
|
|
64
|
-
* Initialize result from server
|
|
90
|
+
* Initialize result from server.
|
|
91
|
+
*
|
|
92
|
+
* @category Client
|
|
65
93
|
*/
|
|
66
94
|
export interface InitializeResult {
|
|
95
|
+
/** Server capabilities advertised in the `initialize` response. */
|
|
67
96
|
capabilities: import('vscode-languageserver-protocol').ServerCapabilities;
|
|
97
|
+
/** Optional server identification returned by the language server. */
|
|
68
98
|
serverInfo?: {
|
|
99
|
+
/** Human-readable name of the language server. */
|
|
69
100
|
name: string;
|
|
101
|
+
/** Optional version string of the language server. */
|
|
70
102
|
version?: string;
|
|
71
103
|
};
|
|
72
104
|
}
|
|
73
105
|
/**
|
|
74
|
-
*
|
|
106
|
+
* Return value of `LSPClient.sendCancellableRequest`.
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* `promise` rejects with a cancellation error when `cancel()` is called.
|
|
110
|
+
* Always attach a `.catch()` handler to `promise` before calling `cancel()`
|
|
111
|
+
* to avoid unhandled promise rejections.
|
|
112
|
+
*
|
|
113
|
+
* @typeParam T - The expected response result type.
|
|
114
|
+
* @category Client
|
|
75
115
|
*/
|
|
76
116
|
export interface CancellableRequest<T> {
|
|
77
117
|
/**
|
|
78
|
-
* Promise that resolves with the request result
|
|
118
|
+
* Promise that resolves with the request result or rejects on cancellation.
|
|
79
119
|
*/
|
|
80
120
|
promise: Promise<T>;
|
|
81
121
|
/**
|
|
82
|
-
*
|
|
122
|
+
* Cancels the in-flight request and sends `$/cancelRequest` to the server.
|
|
83
123
|
*/
|
|
84
124
|
cancel: () => void;
|
|
85
125
|
}
|
|
86
126
|
/**
|
|
87
|
-
* Options for
|
|
127
|
+
* Options for `LSPClient.sendRequestWithPartialResults`.
|
|
128
|
+
*
|
|
129
|
+
* @config
|
|
130
|
+
* @typeParam TPartial - The partial result element type.
|
|
131
|
+
* @category Client
|
|
88
132
|
*/
|
|
89
133
|
export interface PartialRequestOptions<TPartial> {
|
|
134
|
+
/**
|
|
135
|
+
* Custom `partialResultToken` value; auto-generated when omitted.
|
|
136
|
+
*/
|
|
90
137
|
token?: string | number;
|
|
138
|
+
/**
|
|
139
|
+
* Called for each `$/progress` notification carrying a partial result.
|
|
140
|
+
*/
|
|
91
141
|
onPartial: (partial: TPartial) => void;
|
|
92
142
|
}
|
|
93
143
|
/**
|
|
94
144
|
* Result returned by partial-result enabled requests.
|
|
95
145
|
*/
|
|
96
146
|
export type PartialRequestResult<TPartial, TResult> = PartialRequestOutcome<TPartial, TResult>;
|
|
147
|
+
/**
|
|
148
|
+
* Namespace for sending notebook-document lifecycle notifications to a server.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* Available on `client.notebookDocument` after `connect()`. Mirrors the
|
|
152
|
+
* standard LSP `notebookDocument/*` notification methods for clients that
|
|
153
|
+
* declare `notebookDocumentSync` capability.
|
|
154
|
+
*
|
|
155
|
+
* @category Client
|
|
156
|
+
*/
|
|
97
157
|
export interface NotebookDocumentNamespace {
|
|
158
|
+
/** Notify the server that a notebook document was opened. */
|
|
98
159
|
didOpen(params: DidOpenNotebookDocumentParams): Promise<void>;
|
|
160
|
+
/** Notify the server that a notebook document changed. */
|
|
99
161
|
didChange(params: DidChangeNotebookDocumentParams): Promise<void>;
|
|
162
|
+
/** Notify the server that a notebook document was saved. */
|
|
100
163
|
didSave(params: DidSaveNotebookDocumentParams): Promise<void>;
|
|
164
|
+
/** Notify the server that a notebook document was closed. */
|
|
101
165
|
didClose(params: DidCloseNotebookDocumentParams): Promise<void>;
|
|
102
166
|
}
|
|
103
167
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAEV,kBAAkB,EAClB,2BAA2B,EAC3B,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AAI,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,QAAQ,EAAE,OAAO,IAAI,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAE/F;;;;;;;;;GASG;AACH,MAAM,WAAW,yBAAyB;IACxC,6DAA6D;IAC7D,OAAO,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,0DAA0D;IAC1D,SAAS,CAAC,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,4DAA4D;IAC5D,OAAO,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE"}
|
package/dist/validation.d.ts
CHANGED
|
@@ -39,5 +39,5 @@ export interface ValidationOptions {
|
|
|
39
39
|
/**
|
|
40
40
|
* Creates a response validator with custom options
|
|
41
41
|
*/
|
|
42
|
-
export declare function createValidator(options?: ValidationOptions): <T>(method:
|
|
42
|
+
export declare function createValidator(options?: ValidationOptions): <T>(method: LSPRequestMethod, schema: z.ZodSchema<T>, response: unknown) => T;
|
|
43
43
|
//# sourceMappingURL=validation.d.ts.map
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;aAE9B,MAAM,EAAE,MAAM;aACd,MAAM,EAAE,CAAC,CAAC,QAAQ;aAClB,QAAQ,EAAE,OAAO;IAHnC,YACkB,MA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