@singapore-editor/lsp 0.1.1 → 0.2.10
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/LICENSE +22 -0
- package/README.md +37 -10
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +1 -2
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +124 -46
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/performanceDiagnostics.js +1 -2
- package/dist/positions.d.ts.map +1 -1
- package/dist/positions.js +1 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -2
- package/dist/semanticTokens.js +1 -2
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +36 -8
- package/dist/transports.js.map +1 -1
- package/dist/types.d.ts +18 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/workspace.d.ts +14 -3
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +109 -29
- package/dist/workspace.js.map +1 -1
- package/dist/workspaceFactory.js +1 -2
- package/package.json +23 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shaul Lavo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# @singapore-editor/lsp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Language Server Protocol client with WebSocket and worker transports.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
an editor plugin that connects these primitives to `@singapore-editor/core`.
|
|
5
|
+
Part of [Singapore](https://singapore.shaulavo.dev/). A code editor for the browser that keeps every version.
|
|
7
6
|
|
|
8
7
|
## Install
|
|
9
8
|
|
|
@@ -13,14 +12,42 @@ npm install @singapore-editor/lsp
|
|
|
13
12
|
|
|
14
13
|
## Usage
|
|
15
14
|
|
|
15
|
+
Run a language server that accepts LSP JSON-RPC over WebSocket at the example URL.
|
|
16
|
+
|
|
16
17
|
```ts
|
|
17
|
-
import { LspClient, createWebSocketLspTransport } from '@singapore-editor/lsp'
|
|
18
|
+
import { LspClient, createWebSocketLspTransport, offsetToLspPosition } from '@singapore-editor/lsp'
|
|
19
|
+
|
|
20
|
+
const client = new LspClient({ rootUri: 'file:///project' })
|
|
21
|
+
await client.connect(await createWebSocketLspTransport('ws://localhost:3001/lsp'))
|
|
22
|
+
|
|
23
|
+
const uri = 'file:///project/main.ts'
|
|
24
|
+
const text = 'const value = 1\nvalue.toFixed()\n'
|
|
25
|
+
await client.notify('textDocument/didOpen', {
|
|
26
|
+
textDocument: { uri, languageId: 'typescript', version: 1, text },
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const hover = await client.request('textDocument/hover', {
|
|
30
|
+
textDocument: { uri },
|
|
31
|
+
position: offsetToLspPosition(text, 18),
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
await client.shutdown()
|
|
18
35
|
```
|
|
19
36
|
|
|
20
|
-
##
|
|
37
|
+
## API highlights
|
|
38
|
+
|
|
39
|
+
- `LspClient.connect()` initializes a server connection.
|
|
40
|
+
- `request()` sends a request with cancellation and timeout options.
|
|
41
|
+
- `createWorkerLspTransport()` connects a worker.
|
|
42
|
+
|
|
43
|
+
[Generated API reference](https://singapore.shaulavo.dev/docs/reference/api/lsp/overview/)
|
|
44
|
+
|
|
45
|
+
## In the Singapore family
|
|
46
|
+
|
|
47
|
+
You can use this package on its own. `@singapore-editor/core` owns editor views; optional packages add syntax, search, gutters, and language features.
|
|
48
|
+
|
|
49
|
+
[Singapore README](https://github.com/ShaulLavo/singapore/blob/main/README.md) · [Documentation](https://singapore.shaulavo.dev/docs/start-here/introduction/)
|
|
50
|
+
|
|
51
|
+
## License
|
|
21
52
|
|
|
22
|
-
|
|
23
|
-
- `createWebSocketLspTransport` and `createWorkerLspTransport` create managed transports.
|
|
24
|
-
- Position helpers convert between editor offsets and LSP positions.
|
|
25
|
-
- Protocol error helpers expose LSP response and cancellation errors.
|
|
26
|
-
- `lsp` re-exports `vscode-languageserver-protocol` types.
|
|
53
|
+
MIT. [License](https://github.com/ShaulLavo/singapore/blob/main/LICENSE)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAA;AAC1D,OAAO,KAAK,EAAuB,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AA4B/F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,QAAO,GAAG,CAAC,kBA+E/C,CAAA;AAEF,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAA;AAC1D,OAAO,KAAK,EAAuB,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AA4B/F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,QAAO,GAAG,CAAC,kBA+E/C,CAAA;AAEF,eAAO,MAAM,uBAAuB,SAC5B,GAAG,CAAC,kBAAkB,YAClB,GAAG,CAAC,kBAAkB,GAAG,SAAS,KAC3C,GAAG,CAAC,kBAA4E,CAAA;AAYnF;;;GAGG;AACH,eAAO,MAAM,sCAAsC,iBACnC,GAAG,CAAC,kBAAkB,GAAG,SAAS,aACrC,OAAO,KACjB,GAAG,CAAC,kBAAkB,GAAG,SAuB3B,CAAA;AAED,eAAO,MAAM,gCAAgC,iBAC7B,GAAG,CAAC,kBAAkB,GAAG,IAAI,KAC1C,mBAEF,CAAA;AAED,eAAO,MAAM,mCAAmC,iBAChC,GAAG,CAAC,kBAAkB,GAAG,IAAI,KAC1C,sBAUF,CAAA;AAED,eAAO,MAAM,qBAAqB,iBAAkB,GAAG,CAAC,kBAAkB,KAAG,OACf,CAAA"}
|
package/dist/capabilities.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/capabilities.ts
|
|
2
2
|
var TEXT_DOCUMENT_SYNC_NONE = 0;
|
|
3
3
|
var TEXT_DOCUMENT_SYNC_FULL = 1;
|
|
4
4
|
var TEXT_DOCUMENT_SYNC_INCREMENTAL = 2;
|
|
@@ -185,7 +185,6 @@ var cloneValue = (value) => {
|
|
|
185
185
|
for (const key of Object.keys(value)) result[key] = cloneValue(value[key]);
|
|
186
186
|
return result;
|
|
187
187
|
};
|
|
188
|
-
//#endregion
|
|
189
188
|
export { clientSupportsDidSave, composeWorkspaceEditClientCapabilities, defaultClientCapabilities, documentSyncModeFromCapabilities, documentSyncOptionsFromCapabilities, mergeClientCapabilities };
|
|
190
189
|
|
|
191
190
|
//# sourceMappingURL=capabilities.js.map
|
package/dist/client.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export declare class LspClient {
|
|
|
37
37
|
private state;
|
|
38
38
|
private nextRequestId;
|
|
39
39
|
private initializePromise;
|
|
40
|
+
private connectionEpoch;
|
|
40
41
|
private syncMode;
|
|
41
42
|
private syncOpenClose;
|
|
42
43
|
private syncSave;
|
|
@@ -58,6 +59,7 @@ export declare class LspClient {
|
|
|
58
59
|
didChangeDocument(document: LspDocument, change: LspDocumentChange): void;
|
|
59
60
|
didSaveDocument(document: LspDocument): void;
|
|
60
61
|
didCloseDocument(document: LspDocument): void;
|
|
62
|
+
private requireDocumentSyncReady;
|
|
61
63
|
private initialize;
|
|
62
64
|
private initializeParams;
|
|
63
65
|
private applyInitializeResult;
|
|
@@ -68,6 +70,7 @@ export declare class LspClient {
|
|
|
68
70
|
private sendHandledRequest;
|
|
69
71
|
private sendReadyHandledRequest;
|
|
70
72
|
private requestInnerWithId;
|
|
73
|
+
private sendEncodedRequest;
|
|
71
74
|
private allocateRequestId;
|
|
72
75
|
private createPendingRequest;
|
|
73
76
|
private sendMessage;
|
|
@@ -85,6 +88,7 @@ export declare class LspClient {
|
|
|
85
88
|
private abortRequest;
|
|
86
89
|
private deletePendingRequest;
|
|
87
90
|
private rejectPendingRequests;
|
|
91
|
+
private isCurrentConnection;
|
|
88
92
|
private handleTransportSendError;
|
|
89
93
|
private awaitInitialization;
|
|
90
94
|
private requireTransport;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAA;AAsB1D,OAAO,KAAK,E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AAC,YAAY;IAQpB,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,uBAAuB;IAiC/B,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,gBAAgB;CAIzB"}
|
package/dist/client.js
CHANGED
|
@@ -3,7 +3,7 @@ import { LspRequestCancelledError, createInternalErrorResponse, createMethodNotF
|
|
|
3
3
|
import { measureLspPerformance } from "./performanceDiagnostics.js";
|
|
4
4
|
import { createLspContentChangesInSnapshot } from "./positions.js";
|
|
5
5
|
import { createDefaultLspWorkspace } from "./workspaceFactory.js";
|
|
6
|
-
|
|
6
|
+
// src/client.ts
|
|
7
7
|
var LspClient = class {
|
|
8
8
|
workspace;
|
|
9
9
|
serverCapabilities = null;
|
|
@@ -15,6 +15,7 @@ var LspClient = class {
|
|
|
15
15
|
state = "disconnected";
|
|
16
16
|
nextRequestId = 1;
|
|
17
17
|
initializePromise = null;
|
|
18
|
+
connectionEpoch = 0;
|
|
18
19
|
syncMode = "none";
|
|
19
20
|
syncOpenClose = false;
|
|
20
21
|
syncSave = {
|
|
@@ -45,10 +46,11 @@ var LspClient = class {
|
|
|
45
46
|
this.transport = transport;
|
|
46
47
|
this.state = "initializing";
|
|
47
48
|
transport.subscribe(this.receiveMessage);
|
|
48
|
-
this.initializePromise = this.initialize();
|
|
49
|
+
this.initializePromise = this.initialize(this.connectionEpoch);
|
|
49
50
|
return this.initializePromise;
|
|
50
51
|
}
|
|
51
52
|
disconnect() {
|
|
53
|
+
this.connectionEpoch++;
|
|
52
54
|
const transport = this.transport;
|
|
53
55
|
if (transport) transport.unsubscribe(this.receiveMessage);
|
|
54
56
|
this.transport = null;
|
|
@@ -77,20 +79,29 @@ var LspClient = class {
|
|
|
77
79
|
}
|
|
78
80
|
requestHandle(method, params, options = {}) {
|
|
79
81
|
const id = this.allocateRequestId();
|
|
80
|
-
|
|
82
|
+
const cancellation = new AbortController();
|
|
83
|
+
const signal = options.signal ? AbortSignal.any([options.signal, cancellation.signal]) : cancellation.signal;
|
|
81
84
|
return {
|
|
82
85
|
id,
|
|
83
|
-
response: this.sendHandledRequest(id, method, params,
|
|
86
|
+
response: this.sendHandledRequest(id, method, params, {
|
|
87
|
+
...options,
|
|
88
|
+
signal
|
|
89
|
+
}, () => signal.aborted),
|
|
84
90
|
cancel: () => {
|
|
85
|
-
|
|
91
|
+
cancellation.abort(new LspRequestCancelledError());
|
|
86
92
|
this.abortRequest(id);
|
|
87
93
|
}
|
|
88
94
|
};
|
|
89
95
|
}
|
|
90
96
|
notify(method, params) {
|
|
91
97
|
if (!this.transport) return Promise.reject(/* @__PURE__ */ new Error("LSP client is not connected"));
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
const connection = {
|
|
99
|
+
transport: this.transport,
|
|
100
|
+
epoch: this.connectionEpoch
|
|
101
|
+
};
|
|
102
|
+
const send = () => this.notifyReady(method, params, connection);
|
|
103
|
+
if (this.state === "ready") return send();
|
|
104
|
+
return this.awaitInitialization().then(send);
|
|
94
105
|
}
|
|
95
106
|
notification(method, params) {
|
|
96
107
|
return this.notify(method, params);
|
|
@@ -100,23 +111,26 @@ var LspClient = class {
|
|
|
100
111
|
return Boolean(this.serverCapabilities[name]);
|
|
101
112
|
}
|
|
102
113
|
didOpenDocument(document) {
|
|
103
|
-
|
|
114
|
+
this.requireDocumentSyncReady();
|
|
104
115
|
if (this.syncedDocuments.has(document.uri)) return;
|
|
105
116
|
if (!this.shouldTrackDocumentSync()) return;
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
if (!this.syncOpenClose) {
|
|
118
|
+
this.syncedDocuments.add(document.uri);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.sendNotification("textDocument/didOpen", { textDocument: {
|
|
109
122
|
uri: document.uri,
|
|
110
123
|
languageId: document.languageId,
|
|
111
124
|
version: document.version,
|
|
112
125
|
text: documentPayloadText(document)
|
|
113
126
|
} });
|
|
127
|
+
this.syncedDocuments.add(document.uri);
|
|
114
128
|
}
|
|
115
129
|
didChangeDocument(document, change) {
|
|
116
|
-
|
|
130
|
+
this.requireDocumentSyncReady();
|
|
117
131
|
if (this.syncMode === "none") return;
|
|
118
132
|
if (!this.syncedDocuments.has(document.uri)) return;
|
|
119
|
-
this.
|
|
133
|
+
this.sendNotification("textDocument/didChange", {
|
|
120
134
|
textDocument: {
|
|
121
135
|
uri: document.uri,
|
|
122
136
|
version: document.version
|
|
@@ -125,28 +139,38 @@ var LspClient = class {
|
|
|
125
139
|
});
|
|
126
140
|
}
|
|
127
141
|
didSaveDocument(document) {
|
|
128
|
-
|
|
142
|
+
this.requireDocumentSyncReady();
|
|
129
143
|
if (!this.syncSave.enabled) return;
|
|
130
144
|
if (!this.syncedDocuments.has(document.uri)) return;
|
|
131
|
-
this.
|
|
145
|
+
this.sendNotification("textDocument/didSave", {
|
|
132
146
|
textDocument: { uri: document.uri },
|
|
133
147
|
...this.syncSave.includeText ? { text: documentPayloadText(document) } : {}
|
|
134
148
|
});
|
|
135
149
|
}
|
|
136
150
|
didCloseDocument(document) {
|
|
137
151
|
if (this.state !== "ready") return;
|
|
138
|
-
if (!this.syncedDocuments.
|
|
139
|
-
if (!this.syncOpenClose)
|
|
140
|
-
|
|
152
|
+
if (!this.syncedDocuments.has(document.uri)) return;
|
|
153
|
+
if (!this.syncOpenClose || this.transport?.isClosed?.()) {
|
|
154
|
+
this.syncedDocuments.delete(document.uri);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this.sendNotification("textDocument/didClose", { textDocument: { uri: document.uri } });
|
|
158
|
+
this.syncedDocuments.delete(document.uri);
|
|
159
|
+
}
|
|
160
|
+
requireDocumentSyncReady() {
|
|
161
|
+
if (this.state === "ready") return;
|
|
162
|
+
throw new DOMException("Language-server document synchronization requires readiness", "InvalidStateError");
|
|
141
163
|
}
|
|
142
|
-
async initialize() {
|
|
164
|
+
async initialize(epoch) {
|
|
165
|
+
const transport = this.transport;
|
|
143
166
|
try {
|
|
144
167
|
const result = await this.requestInner("initialize", this.initializeParams());
|
|
168
|
+
if (this.connectionEpoch !== epoch || this.transport !== transport) throw new LspRequestCancelledError();
|
|
145
169
|
this.applyInitializeResult(result);
|
|
146
170
|
this.sendNotification("initialized", {});
|
|
147
171
|
this.workspace.connected();
|
|
148
172
|
} catch (error) {
|
|
149
|
-
this.state = "failed";
|
|
173
|
+
if (this.connectionEpoch === epoch && this.transport === transport) this.state = "failed";
|
|
150
174
|
throw error;
|
|
151
175
|
}
|
|
152
176
|
}
|
|
@@ -194,16 +218,47 @@ var LspClient = class {
|
|
|
194
218
|
}
|
|
195
219
|
sendHandledRequest(id, method, params, options, isCancelled) {
|
|
196
220
|
if (!this.transport) return Promise.reject(/* @__PURE__ */ new Error("LSP client is not connected"));
|
|
197
|
-
|
|
198
|
-
|
|
221
|
+
const transport = this.transport;
|
|
222
|
+
const initialization = this.initializePromise;
|
|
223
|
+
const epoch = this.connectionEpoch;
|
|
224
|
+
let message;
|
|
225
|
+
try {
|
|
226
|
+
message = JSON.stringify(createRequestMessage(id, method, params));
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return Promise.reject(error);
|
|
229
|
+
}
|
|
230
|
+
const captured = JSON.parse(message);
|
|
231
|
+
const uri = typeof captured === "object" && captured !== null && "params" in captured ? textDocumentRequestUri(method, captured.params) : null;
|
|
232
|
+
const send = () => {
|
|
233
|
+
if (this.connectionEpoch !== epoch || this.transport !== transport || this.initializePromise !== initialization) return Promise.reject(new LspRequestCancelledError());
|
|
234
|
+
return this.sendReadyHandledRequest(id, method, message, uri, options, isCancelled);
|
|
235
|
+
};
|
|
236
|
+
if (this.state === "ready") return send();
|
|
237
|
+
return this.awaitInitialization().then(send);
|
|
199
238
|
}
|
|
200
|
-
sendReadyHandledRequest(id, method,
|
|
239
|
+
sendReadyHandledRequest(id, method, message, uri, options, isCancelled) {
|
|
201
240
|
if (isCancelled()) return Promise.reject(new LspRequestCancelledError());
|
|
202
|
-
|
|
241
|
+
const transport = this.transport;
|
|
242
|
+
const initialization = this.initializePromise;
|
|
243
|
+
const epoch = this.connectionEpoch;
|
|
244
|
+
const prepared = uri ? this.workspace.prepareDocumentRequest(uri, options.signal) : void 0;
|
|
245
|
+
const send = () => {
|
|
246
|
+
if (isCancelled() || this.connectionEpoch !== epoch || this.transport !== transport || this.initializePromise !== initialization) return Promise.reject(new LspRequestCancelledError());
|
|
247
|
+
return this.sendEncodedRequest(id, method, message, options);
|
|
248
|
+
};
|
|
249
|
+
if (prepared?.kind === "pending") return prepared.ready.then((read) => {
|
|
250
|
+
if (!read.isCurrent()) throw new LspRequestCancelledError();
|
|
251
|
+
return send();
|
|
252
|
+
});
|
|
253
|
+
if (prepared?.kind === "ready" && !prepared.read.isCurrent()) return Promise.reject(new LspRequestCancelledError());
|
|
254
|
+
return send();
|
|
203
255
|
}
|
|
204
256
|
requestInnerWithId(id, method, params, options) {
|
|
205
|
-
const transport = this.requireTransport();
|
|
206
257
|
const message = createRequestMessage(id, method, params);
|
|
258
|
+
return this.sendEncodedRequest(id, method, JSON.stringify(message), options);
|
|
259
|
+
}
|
|
260
|
+
sendEncodedRequest(id, method, message, options) {
|
|
261
|
+
const transport = this.requireTransport();
|
|
207
262
|
return new Promise((resolve, reject) => {
|
|
208
263
|
const pending = this.createPendingRequest(id, method, (result) => resolve(result), reject, options);
|
|
209
264
|
this.pendingRequests.set(id, pending);
|
|
@@ -232,26 +287,35 @@ var LspClient = class {
|
|
|
232
287
|
};
|
|
233
288
|
}
|
|
234
289
|
sendMessage(transport, message, pending) {
|
|
290
|
+
const connection = {
|
|
291
|
+
transport,
|
|
292
|
+
epoch: this.connectionEpoch
|
|
293
|
+
};
|
|
235
294
|
try {
|
|
236
|
-
transport.send(
|
|
295
|
+
transport.send(message);
|
|
237
296
|
} catch (error) {
|
|
238
297
|
this.deletePendingRequest(pending.id);
|
|
239
|
-
this.handleTransportSendError(
|
|
298
|
+
this.handleTransportSendError(connection);
|
|
240
299
|
pending.reject(error);
|
|
241
300
|
}
|
|
242
301
|
}
|
|
243
|
-
sendNotification(method, params
|
|
244
|
-
|
|
302
|
+
sendNotification(method, params, connection = {
|
|
303
|
+
transport: this.requireTransport(),
|
|
304
|
+
epoch: this.connectionEpoch
|
|
305
|
+
}) {
|
|
245
306
|
try {
|
|
246
|
-
|
|
307
|
+
if (!this.isCurrentConnection(connection)) throw new LspRequestCancelledError();
|
|
308
|
+
const message = JSON.stringify(createNotificationMessage(method, params));
|
|
309
|
+
if (!this.isCurrentConnection(connection)) throw new LspRequestCancelledError();
|
|
310
|
+
connection.transport.send(message);
|
|
247
311
|
} catch (error) {
|
|
248
|
-
this.handleTransportSendError(
|
|
312
|
+
this.handleTransportSendError(connection);
|
|
249
313
|
throw error;
|
|
250
314
|
}
|
|
251
315
|
}
|
|
252
|
-
notifyReady(method, params) {
|
|
316
|
+
notifyReady(method, params, connection) {
|
|
253
317
|
try {
|
|
254
|
-
this.sendNotification(method, params);
|
|
318
|
+
this.sendNotification(method, params, connection);
|
|
255
319
|
return Promise.resolve();
|
|
256
320
|
} catch (error) {
|
|
257
321
|
return Promise.reject(error);
|
|
@@ -309,27 +373,33 @@ var LspClient = class {
|
|
|
309
373
|
return true;
|
|
310
374
|
}
|
|
311
375
|
handleRequest(message) {
|
|
376
|
+
if (!this.transport) return;
|
|
377
|
+
const connection = {
|
|
378
|
+
transport: this.transport,
|
|
379
|
+
epoch: this.connectionEpoch
|
|
380
|
+
};
|
|
312
381
|
const handler = this.config.serverRequestHandlers?.[message.method];
|
|
313
382
|
if (!handler) {
|
|
314
|
-
this.sendServerResponse(createMethodNotFoundResponse(message.id, message.method));
|
|
383
|
+
this.sendServerResponse(createMethodNotFoundResponse(message.id, message.method), connection);
|
|
315
384
|
return;
|
|
316
385
|
}
|
|
317
386
|
let result;
|
|
318
387
|
try {
|
|
319
388
|
result = handler(this, message.params, message);
|
|
320
389
|
} catch (error) {
|
|
321
|
-
this.sendServerResponse(createInternalErrorResponse(message.id, error));
|
|
390
|
+
this.sendServerResponse(createInternalErrorResponse(message.id, error), connection);
|
|
322
391
|
return;
|
|
323
392
|
}
|
|
324
|
-
Promise.resolve(result).then((result) => this.sendServerResponse(createResponseMessage(message.id, result)), (error) => this.sendServerResponse(createInternalErrorResponse(message.id, error)));
|
|
393
|
+
Promise.resolve(result).then((result) => this.sendServerResponse(createResponseMessage(message.id, result), connection), (error) => this.sendServerResponse(createInternalErrorResponse(message.id, error), connection));
|
|
325
394
|
}
|
|
326
|
-
sendServerResponse(message) {
|
|
327
|
-
|
|
328
|
-
if (!transport) return;
|
|
395
|
+
sendServerResponse(message, connection) {
|
|
396
|
+
if (!this.isCurrentConnection(connection)) return;
|
|
329
397
|
try {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
398
|
+
const encoded = JSON.stringify(message);
|
|
399
|
+
if (!this.isCurrentConnection(connection)) return;
|
|
400
|
+
connection.transport.send(encoded);
|
|
401
|
+
} catch {
|
|
402
|
+
this.handleTransportSendError(connection);
|
|
333
403
|
}
|
|
334
404
|
}
|
|
335
405
|
timeoutRequest(id) {
|
|
@@ -360,9 +430,11 @@ var LspClient = class {
|
|
|
360
430
|
}
|
|
361
431
|
this.pendingRequests.clear();
|
|
362
432
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
433
|
+
isCurrentConnection(connection) {
|
|
434
|
+
return this.connectionEpoch === connection.epoch && this.transport === connection.transport;
|
|
435
|
+
}
|
|
436
|
+
handleTransportSendError(connection) {
|
|
437
|
+
if (this.isCurrentConnection(connection)) this.disconnect();
|
|
366
438
|
}
|
|
367
439
|
awaitInitialization() {
|
|
368
440
|
if (this.initializePromise) return this.initializePromise;
|
|
@@ -373,6 +445,13 @@ var LspClient = class {
|
|
|
373
445
|
throw new Error("LSP client is not connected");
|
|
374
446
|
}
|
|
375
447
|
};
|
|
448
|
+
function textDocumentRequestUri(method, params) {
|
|
449
|
+
if (!method.startsWith("textDocument/") || typeof params !== "object" || params === null) return null;
|
|
450
|
+
if (!("textDocument" in params)) return null;
|
|
451
|
+
const document = params.textDocument;
|
|
452
|
+
if (typeof document !== "object" || document === null || !("uri" in document)) return null;
|
|
453
|
+
return typeof document.uri === "string" ? document.uri : null;
|
|
454
|
+
}
|
|
376
455
|
function documentPayloadText(document) {
|
|
377
456
|
return document.textSnapshot.readRange(0, document.textSnapshot.length);
|
|
378
457
|
}
|
|
@@ -385,7 +464,6 @@ var messageType = (params) => {
|
|
|
385
464
|
return typeof params.type === "number" ? params.type : 3;
|
|
386
465
|
};
|
|
387
466
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
388
|
-
//#endregion
|
|
389
467
|
export { LspClient };
|
|
390
468
|
|
|
391
469
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type * as lsp from 'vscode-languageserver-protocol'\nimport {\n clientSupportsDidSave,\n defaultClientCapabilities,\n documentSyncOptionsFromCapabilities,\n mergeClientCapabilities,\n} from './capabilities'\nimport {\n createMethodNotFoundResponse,\n createNotificationMessage,\n createInternalErrorResponse,\n createRequestMessage,\n createResponseMessage,\n isNotificationMessage,\n isRequestMessage,\n isResponseMessage,\n LspRequestCancelledError,\n responseResult,\n type LspRequestId,\n} from './protocol'\nimport { createLspContentChangesInSnapshot } from './positions'\nimport { measureLspPerformance } from './performanceDiagnostics'\nimport type {\n LspDocumentChange,\n LspDocumentSaveSync,\n LspDocument,\n LspDocumentSyncMode,\n LspNotificationHandler,\n LspRequestHandle,\n LspServerMessageHandler,\n LspServerRequestHandler,\n LspClientWorkspace,\n LspTransport,\n LspUnhandledNotificationHandler,\n} from './types'\nimport { createDefaultLspWorkspace } from './workspaceFactory'\n\nexport type LspClientState = 'disconnected' | 'initializing' | 'ready' | 'failed'\n\nexport type LspClientConfig = {\n readonly rootUri?: lsp.DocumentUri | null\n readonly workspaceFolders?: readonly lsp.WorkspaceFolder[] | null\n readonly clientInfo?: lsp.InitializeParams['clientInfo']\n readonly initializationOptions?: unknown\n readonly capabilities?: lsp.ClientCapabilities\n readonly timeoutMs?: number\n readonly processId?: number | null\n readonly locale?: string\n readonly workspace?: LspClientWorkspace\n readonly notificationHandlers?: Readonly<Record<string, LspNotificationHandler<LspClient>>>\n readonly unhandledNotification?: LspUnhandledNotificationHandler<LspClient>\n readonly serverMessageHandler?: LspServerMessageHandler<LspClient>\n readonly serverRequestHandlers?: Readonly<Record<string, LspServerRequestHandler<LspClient>>>\n}\n\ntype PendingRequest = {\n readonly id: LspRequestId\n readonly method: string\n readonly timeout: ReturnType<typeof setTimeout>\n readonly resolve: (result: unknown) => void\n readonly reject: (error: unknown) => void\n readonly abortCleanup?: () => void\n}\n\n/**\n * Per-request overrides. Both matter to a caller the default was not written for: `timeoutMs`\n * because a cold server on a large project will blow past the 3s default on its first answer, and\n * `signal` because aborting sends `$/cancelRequest` on the wire — a server that honours it abandons\n * real work, which is not the same thing as suppressing a response that was already computed.\n */\nexport type RequestOptions = {\n readonly timeoutMs?: number\n readonly signal?: AbortSignal\n}\n\nexport class LspClient {\n public readonly workspace: LspClientWorkspace\n public serverCapabilities: lsp.ServerCapabilities | null = null\n public initializeResult: lsp.InitializeResult | null = null\n\n private readonly config: LspClientConfig\n private readonly timeoutMs: number\n private readonly clientCapabilities: lsp.ClientCapabilities\n private transport: LspTransport | null = null\n private state: LspClientState = 'disconnected'\n private nextRequestId = 1\n private initializePromise: Promise<void> | null = null\n private syncMode: LspDocumentSyncMode = 'none'\n private syncOpenClose = false\n private syncSave: LspDocumentSaveSync = { enabled: false, includeText: false }\n private readonly pendingRequests = new Map<LspRequestId, PendingRequest>()\n private readonly syncedDocuments = new Set<lsp.DocumentUri>()\n\n public constructor(config: LspClientConfig = {}) {\n this.config = config\n this.timeoutMs = config.timeoutMs ?? 3000\n this.clientCapabilities = mergeClientCapabilities(\n defaultClientCapabilities(),\n this.config.capabilities,\n )\n this.workspace = config.workspace ?? createDefaultLspWorkspace()\n this.workspace.attachClient(this)\n this.receiveMessage = this.receiveMessage.bind(this)\n }\n\n public get connected(): boolean {\n return this.transport !== null\n }\n\n public get initialized(): boolean {\n return this.state === 'ready'\n }\n\n public get initialization(): Promise<void> | null {\n return this.initializePromise\n }\n\n public connect(transport: LspTransport): Promise<void> {\n this.disconnect()\n this.transport = transport\n this.state = 'initializing'\n transport.subscribe(this.receiveMessage)\n this.initializePromise = this.initialize()\n return this.initializePromise\n }\n\n public disconnect(): void {\n const transport = this.transport\n if (transport) transport.unsubscribe(this.receiveMessage)\n\n this.transport = null\n this.state = 'disconnected'\n this.initializePromise = null\n this.initializeResult = null\n this.serverCapabilities = null\n this.syncMode = 'none'\n this.syncOpenClose = false\n this.syncSave = { enabled: false, includeText: false }\n this.syncedDocuments.clear()\n this.rejectPendingRequests(new Error('LSP client disconnected'))\n this.workspace.disconnected()\n }\n\n public async shutdown(): Promise<void> {\n if (!this.transport) return\n\n await this.request('shutdown')\n this.sendNotification('exit')\n this.disconnect()\n }\n\n public request<TResult = unknown, TParams = unknown>(\n method: string,\n params?: TParams,\n options: RequestOptions = {},\n ): Promise<TResult> {\n return this.requestHandle<TResult, TParams>(method, params, options).response\n }\n\n public requestHandle<TResult = unknown, TParams = unknown>(\n method: string,\n params?: TParams,\n options: RequestOptions = {},\n ): LspRequestHandle<TResult> {\n const id = this.allocateRequestId()\n let cancelled = false\n const response = this.sendHandledRequest<TResult>(id, method, params, options, () => cancelled)\n\n return {\n id,\n response,\n cancel: () => {\n cancelled = true\n this.abortRequest(id)\n },\n }\n }\n\n public notify<TParams = unknown>(method: string, params?: TParams): Promise<void> {\n if (!this.transport) return Promise.reject(new Error('LSP client is not connected'))\n if (this.state === 'ready') return this.notifyReady(method, params)\n\n return this.awaitInitialization().then(() => this.notifyReady(method, params))\n }\n\n public notification<TParams = unknown>(method: string, params?: TParams): Promise<void> {\n return this.notify(method, params)\n }\n\n public hasCapability(name: keyof lsp.ServerCapabilities): boolean | null {\n if (!this.serverCapabilities) return null\n return Boolean(this.serverCapabilities[name])\n }\n\n public didOpenDocument(document: LspDocument): void {\n if (this.state !== 'ready') return\n if (this.syncedDocuments.has(document.uri)) return\n if (!this.shouldTrackDocumentSync()) return\n\n this.syncedDocuments.add(document.uri)\n if (!this.syncOpenClose) return\n\n this.trySendNotification('textDocument/didOpen', {\n textDocument: {\n uri: document.uri,\n languageId: document.languageId,\n version: document.version,\n text: documentPayloadText(document),\n },\n })\n }\n\n public didChangeDocument(document: LspDocument, change: LspDocumentChange): void {\n if (this.state !== 'ready') return\n if (this.syncMode === 'none') return\n if (!this.syncedDocuments.has(document.uri)) return\n\n this.trySendNotification('textDocument/didChange', {\n textDocument: { uri: document.uri, version: document.version },\n contentChanges: this.contentChangesForDocumentChange(document, change),\n })\n }\n\n public didSaveDocument(document: LspDocument): void {\n if (this.state !== 'ready') return\n if (!this.syncSave.enabled) return\n if (!this.syncedDocuments.has(document.uri)) return\n\n this.trySendNotification('textDocument/didSave', {\n textDocument: { uri: document.uri },\n ...(this.syncSave.includeText ? { text: documentPayloadText(document) } : {}),\n })\n }\n\n public didCloseDocument(document: LspDocument): void {\n if (this.state !== 'ready') return\n if (!this.syncedDocuments.delete(document.uri)) return\n if (!this.syncOpenClose) return\n\n this.trySendNotification('textDocument/didClose', {\n textDocument: { uri: document.uri },\n })\n }\n\n private async initialize(): Promise<void> {\n try {\n const result = await this.requestInner<lsp.InitializeResult>(\n 'initialize',\n this.initializeParams(),\n )\n this.applyInitializeResult(result)\n this.sendNotification('initialized', {})\n this.workspace.connected()\n } catch (error) {\n this.state = 'failed'\n throw error\n }\n }\n\n private initializeParams(): lsp.InitializeParams {\n return {\n processId: this.config.processId ?? null,\n clientInfo: this.config.clientInfo ?? { name: '@singapore-editor/lsp' },\n locale: this.config.locale,\n rootUri: this.config.rootUri ?? null,\n capabilities: this.clientCapabilities,\n initializationOptions: this.config.initializationOptions,\n workspaceFolders: this.config.workspaceFolders ? [...this.config.workspaceFolders] : null,\n }\n }\n\n private applyInitializeResult(result: lsp.InitializeResult): void {\n this.initializeResult = result\n this.serverCapabilities = result.capabilities\n const sync = documentSyncOptionsFromCapabilities(result.capabilities)\n this.syncMode = sync.change\n this.syncOpenClose = sync.openClose\n this.syncSave = clientSupportsDidSave(this.clientCapabilities)\n ? sync.save\n : { enabled: false, includeText: false }\n this.state = 'ready'\n }\n\n private shouldTrackDocumentSync(): boolean {\n return this.syncOpenClose || this.syncMode !== 'none' || this.syncSave.enabled\n }\n\n private contentChangesForDocumentChange(\n document: LspDocument,\n change: LspDocumentChange,\n ): readonly lsp.TextDocumentContentChangeEvent[] {\n return measureLspPerformance(\n 'lsp.createContentChanges',\n () => this.createContentChanges(document, change),\n () => ({\n syncMode: this.syncMode,\n editCount: change.edits.length,\n length: document.textSnapshot.length,\n }),\n )\n }\n\n private createContentChanges(\n document: LspDocument,\n change: LspDocumentChange,\n ): readonly lsp.TextDocumentContentChangeEvent[] {\n return createLspContentChangesInSnapshot(change.previousSnapshot, document, {\n incremental: this.syncMode === 'incremental',\n edits: change.edits,\n })\n }\n\n private requestInner<TResult>(\n method: string,\n params: unknown,\n options: RequestOptions = {},\n ): Promise<TResult> {\n return this.requestInnerWithId(this.allocateRequestId(), method, params, options)\n }\n\n private sendHandledRequest<TResult>(\n id: LspRequestId,\n method: string,\n params: unknown,\n options: RequestOptions,\n isCancelled: () => boolean,\n ): Promise<TResult> {\n if (!this.transport) return Promise.reject(new Error('LSP client is not connected'))\n if (this.state === 'ready')\n return this.sendReadyHandledRequest(id, method, params, options, isCancelled)\n return this.awaitInitialization().then(() =>\n this.sendReadyHandledRequest(id, method, params, options, isCancelled),\n )\n }\n\n private sendReadyHandledRequest<TResult>(\n id: LspRequestId,\n method: string,\n params: unknown,\n options: RequestOptions,\n isCancelled: () => boolean,\n ): Promise<TResult> {\n if (isCancelled()) return Promise.reject(new LspRequestCancelledError())\n return this.requestInnerWithId<TResult>(id, method, params, options)\n }\n\n private requestInnerWithId<TResult>(\n id: LspRequestId,\n method: string,\n params: unknown,\n options: RequestOptions,\n ): Promise<TResult> {\n const transport = this.requireTransport()\n const message = createRequestMessage(id, method, params)\n\n return new Promise<TResult>((resolve, reject) => {\n const pending = this.createPendingRequest(\n id,\n method,\n (result) => resolve(result as TResult),\n reject,\n options,\n )\n this.pendingRequests.set(id, pending)\n this.sendMessage(transport, message, pending)\n })\n }\n\n private allocateRequestId(): LspRequestId {\n const id = this.nextRequestId\n this.nextRequestId += 1\n return id\n }\n\n private createPendingRequest(\n id: LspRequestId,\n method: string,\n resolve: (result: unknown) => void,\n reject: (error: unknown) => void,\n options: RequestOptions,\n ): PendingRequest {\n const timeout = setTimeout(() => this.timeoutRequest(id), options.timeoutMs ?? this.timeoutMs)\n const pending: PendingRequest = { id, method, timeout, resolve, reject }\n if (!options.signal) return pending\n\n const abort = () => this.abortRequest(id)\n options.signal.addEventListener('abort', abort, { once: true })\n return { ...pending, abortCleanup: () => options.signal?.removeEventListener('abort', abort) }\n }\n\n private sendMessage(\n transport: LspTransport,\n message: lsp.RequestMessage,\n pending: PendingRequest,\n ): void {\n try {\n transport.send(JSON.stringify(message))\n } catch (error) {\n this.deletePendingRequest(pending.id)\n this.handleTransportSendError(error)\n pending.reject(error)\n }\n }\n\n private sendNotification(method: string, params?: unknown): void {\n const transport = this.requireTransport()\n try {\n transport.send(JSON.stringify(createNotificationMessage(method, params)))\n } catch (error) {\n this.handleTransportSendError(error)\n throw error\n }\n }\n\n private notifyReady(method: string, params?: unknown): Promise<void> {\n try {\n this.sendNotification(method, params)\n return Promise.resolve()\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private trySendNotification(method: string, params?: unknown): boolean {\n try {\n this.sendNotification(method, params)\n return true\n } catch {\n return false\n }\n }\n\n private receiveMessage(message: string): void {\n const parsed = JSON.parse(message) as unknown\n if (isResponseMessage(parsed)) {\n this.handleResponse(parsed)\n return\n }\n if (isNotificationMessage(parsed)) {\n this.handleNotification(parsed)\n return\n }\n if (isRequestMessage(parsed)) {\n this.handleRequest(parsed)\n }\n }\n\n private handleResponse(message: lsp.ResponseMessage): void {\n if (message.id === null) return\n\n const pending = this.pendingRequests.get(message.id)\n if (!pending) return\n\n this.deletePendingRequest(message.id)\n try {\n pending.resolve(responseResult(message))\n } catch (error) {\n pending.reject(error)\n }\n }\n\n private handleNotification(message: lsp.NotificationMessage): void {\n const handler = this.config.notificationHandlers?.[message.method]\n if (handler?.(this, message.params, message)) return\n if (this.handleDefaultNotification(message)) return\n this.config.unhandledNotification?.(this, message.method, message.params, message)\n }\n\n private handleDefaultNotification(message: lsp.NotificationMessage): boolean {\n if (message.method === 'window/logMessage') return this.handleServerMessage(message)\n if (message.method === 'window/showMessage') return this.handleServerMessage(message)\n return false\n }\n\n private handleServerMessage(message: lsp.NotificationMessage): boolean {\n this.config.serverMessageHandler?.(this, {\n method: message.method as 'window/logMessage' | 'window/showMessage',\n type: messageType(message.params),\n message: messageText(message.params),\n params: message.params,\n })\n return true\n }\n\n private handleRequest(message: lsp.RequestMessage): void {\n const handler = this.config.serverRequestHandlers?.[message.method]\n if (!handler) {\n this.sendServerResponse(createMethodNotFoundResponse(message.id, message.method))\n return\n }\n\n let result: unknown\n try {\n result = handler(this, message.params, message)\n } catch (error) {\n this.sendServerResponse(createInternalErrorResponse(message.id, error))\n return\n }\n\n void Promise.resolve(result).then(\n (result) => this.sendServerResponse(createResponseMessage(message.id, result)),\n (error) => this.sendServerResponse(createInternalErrorResponse(message.id, error)),\n )\n }\n\n private sendServerResponse(message: lsp.ResponseMessage): void {\n const transport = this.transport\n if (!transport) return\n\n try {\n transport.send(JSON.stringify(message))\n } catch (error) {\n this.handleTransportSendError(error)\n }\n }\n\n private timeoutRequest(id: LspRequestId): void {\n const pending = this.pendingRequests.get(id)\n if (!pending) return\n\n this.deletePendingRequest(id)\n pending.reject(new Error(`LSP request timed out: ${pending.method}`))\n }\n\n private abortRequest(id: LspRequestId): void {\n const pending = this.pendingRequests.get(id)\n if (!pending) return\n\n this.trySendNotification('$/cancelRequest', { id })\n this.deletePendingRequest(id)\n pending.reject(new LspRequestCancelledError())\n }\n\n private deletePendingRequest(id: LspRequestId): void {\n const pending = this.pendingRequests.get(id)\n if (!pending) return\n\n clearTimeout(pending.timeout)\n pending.abortCleanup?.()\n this.pendingRequests.delete(id)\n }\n\n private rejectPendingRequests(error: Error): void {\n for (const pending of this.pendingRequests.values()) {\n clearTimeout(pending.timeout)\n pending.abortCleanup?.()\n pending.reject(error)\n }\n\n this.pendingRequests.clear()\n }\n\n private handleTransportSendError(_error: unknown): void {\n if (!this.transport) return\n\n this.disconnect()\n }\n\n private awaitInitialization(): Promise<void> {\n if (this.initializePromise) return this.initializePromise\n return Promise.reject(new Error('LSP client is not initialized'))\n }\n\n private requireTransport(): LspTransport {\n if (this.transport) return this.transport\n throw new Error('LSP client is not connected')\n }\n}\n\n// didOpen and didSave with text carry the whole document by protocol definition.\nfunction documentPayloadText(document: LspDocument): string {\n return document.textSnapshot.readRange(0, document.textSnapshot.length)\n}\n\nconst messageText = (params: unknown): string | null => {\n if (!isRecord(params)) return null\n return typeof params.message === 'string' ? params.message : null\n}\n\nconst messageType = (params: unknown): number => {\n if (!isRecord(params)) return 3\n return typeof params.type === 'number' ? params.type : 3\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n"],"mappings":";;;;;;AA2EA,IAAa,YAAb,MAAuB;CACrB;CACA,qBAA2D;CAC3D,mBAAuD;CAEvD;CACA;CACA;CACA,YAAyC;CACzC,QAAgC;CAChC,gBAAwB;CACxB,oBAAkD;CAClD,WAAwC;CACxC,gBAAwB;CACxB,WAAwC;EAAE,SAAS;EAAO,aAAa;CAAM;CAC7E,kCAAmC,IAAI,IAAkC;CACzE,kCAAmC,IAAI,IAAqB;CAE5D,YAAmB,SAA0B,CAAC,GAAG;EAC/C,KAAK,SAAS;EACd,KAAK,YAAY,OAAO,aAAa;EACrC,KAAK,qBAAqB,wBACxB,0BAA0B,GAC1B,KAAK,OAAO,YACd;EACA,KAAK,YAAY,OAAO,aAAa,0BAA0B;EAC/D,KAAK,UAAU,aAAa,IAAI;EAChC,KAAK,iBAAiB,KAAK,eAAe,KAAK,IAAI;CACrD;CAEA,IAAW,YAAqB;EAC9B,OAAO,KAAK,cAAc;CAC5B;CAEA,IAAW,cAAuB;EAChC,OAAO,KAAK,UAAU;CACxB;CAEA,IAAW,iBAAuC;EAChD,OAAO,KAAK;CACd;CAEA,QAAe,WAAwC;EACrD,KAAK,WAAW;EAChB,KAAK,YAAY;EACjB,KAAK,QAAQ;EACb,UAAU,UAAU,KAAK,cAAc;EACvC,KAAK,oBAAoB,KAAK,WAAW;EACzC,OAAO,KAAK;CACd;CAEA,aAA0B;EACxB,MAAM,YAAY,KAAK;EACvB,IAAI,WAAW,UAAU,YAAY,KAAK,cAAc;EAExD,KAAK,YAAY;EACjB,KAAK,QAAQ;EACb,KAAK,oBAAoB;EACzB,KAAK,mBAAmB;EACxB,KAAK,qBAAqB;EAC1B,KAAK,WAAW;EAChB,KAAK,gBAAgB;EACr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AAQ,KAAK"}
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type * as lsp from 'vscode-languageserver-protocol'\nimport {\n clientSupportsDidSave,\n defaultClientCapabilities,\n documentSyncOptionsFromCapabilities,\n mergeClientCapabilities,\n} from './capabilities'\nimport {\n createMethodNotFoundResponse,\n createNotificationMessage,\n createInternalErrorResponse,\n createRequestMessage,\n createResponseMessage,\n isNotificationMessage,\n isRequestMessage,\n isResponseMessage,\n LspRequestCancelledError,\n responseResult,\n type LspRequestId,\n} from './protocol'\nimport { createLspContentChangesInSnapshot } from './positions'\nimport { measureLspPerformance } from './performanceDiagnostics'\nimport type {\n LspDocumentChange,\n LspDocumentSaveSync,\n LspDocument,\n LspDocumentSyncMode,\n LspNotificationHandler,\n LspRequestHandle,\n LspServerMessageHandler,\n LspServerRequestHandler,\n LspClientWorkspace,\n LspTransport,\n LspUnhandledNotificationHandler,\n} from './types'\nimport { createDefaultLspWorkspace } from './workspaceFactory'\n\nexport type LspClientState = 'disconnected' | 'initializing' | 'ready' | 'failed'\n\nexport type LspClientConfig = {\n readonly rootUri?: lsp.DocumentUri | null\n readonly workspaceFolders?: readonly lsp.WorkspaceFolder[] | null\n readonly clientInfo?: lsp.InitializeParams['clientInfo']\n readonly initializationOptions?: unknown\n readonly capabilities?: lsp.ClientCapabilities\n readonly timeoutMs?: number\n readonly processId?: number | null\n readonly locale?: string\n readonly workspace?: LspClientWorkspace\n readonly notificationHandlers?: Readonly<Record<string, LspNotificationHandler<LspClient>>>\n readonly unhandledNotification?: LspUnhandledNotificationHandler<LspClient>\n readonly serverMessageHandler?: LspServerMessageHandler<LspClient>\n readonly serverRequestHandlers?: Readonly<Record<string, LspServerRequestHandler<LspClient>>>\n}\n\ntype Connection = {\n readonly transport: LspTransport\n readonly epoch: number\n}\n\ntype PendingRequest = {\n readonly id: LspRequestId\n readonly method: string\n readonly timeout: ReturnType<typeof setTimeout>\n readonly resolve: (result: unknown) => void\n readonly reject: (error: unknown) => void\n readonly abortCleanup?: () => void\n}\n\n/**\n * Per-request overrides. Both matter to a caller the default was not written for: `timeoutMs`\n * because a cold server on a large project will blow past the 3s default on its first answer, and\n * `signal` because aborting sends `$/cancelRequest` on the wire — a server that honours it abandons\n * real work, which is not the same thing as suppressing a response that was already computed.\n */\nexport type RequestOptions = {\n readonly timeoutMs?: number\n readonly signal?: AbortSignal\n}\n\nexport class LspClient {\n public readonly workspace: LspClientWorkspace\n public serverCapabilities: lsp.ServerCapabilities | null = null\n public initializeResult: lsp.InitializeResult | null = null\n\n private readonly config: LspClientConfig\n private readonly timeoutMs: number\n private readonly clientCapabilities: lsp.ClientCapabilities\n private transport: LspTransport | null = null\n private state: LspClientState = 'disconnected'\n private nextRequestId = 1\n private initializePromise: Promise<void> | null = null\n private connectionEpoch = 0\n private syncMode: LspDocumentSyncMode = 'none'\n private syncOpenClose = false\n private syncSave: LspDocumentSaveSync = { enabled: false, includeText: false }\n private readonly pendingRequests = new Map<LspRequestId, PendingRequest>()\n private readonly syncedDocuments = new Set<lsp.DocumentUri>()\n\n public constructor(config: LspClientConfig = {}) {\n this.config = config\n this.timeoutMs = config.timeoutMs ?? 3000\n this.clientCapabilities = mergeClientCapabilities(\n defaultClientCapabilities(),\n this.config.capabilities,\n )\n this.workspace = config.workspace ?? createDefaultLspWorkspace()\n this.workspace.attachClient(this)\n this.receiveMessage = this.receiveMessage.bind(this)\n }\n\n public get connected(): boolean {\n return this.transport !== null\n }\n\n public get initialized(): boolean {\n return this.state === 'ready'\n }\n\n public get initialization(): Promise<void> | null {\n return this.initializePromise\n }\n\n public connect(transport: LspTransport): Promise<void> {\n this.disconnect()\n this.transport = transport\n this.state = 'initializing'\n transport.subscribe(this.receiveMessage)\n this.initializePromise = this.initialize(this.connectionEpoch)\n return this.initializePromise\n }\n\n public disconnect(): void {\n this.connectionEpoch++\n const transport = this.transport\n if (transport) transport.unsubscribe(this.receiveMessage)\n\n this.transport = null\n this.state = 'disconnected'\n this.initializePromise = null\n this.initializeResult = null\n this.serverCapabilities = null\n this.syncMode = 'none'\n this.syncOpenClose = false\n this.syncSave = { enabled: false, includeText: false }\n this.syncedDocuments.clear()\n this.rejectPendingRequests(new Error('LSP client disconnected'))\n this.workspace.disconnected()\n }\n\n public async shutdown(): Promise<void> {\n if (!this.transport) return\n\n await this.request('shutdown')\n this.sendNotification('exit')\n this.disconnect()\n }\n\n public request<TResult = unknown, TParams = unknown>(\n method: string,\n params?: TParams,\n options: RequestOptions = {},\n ): Promise<TResult> {\n return this.requestHandle<TResult, TParams>(method, params, options).response\n }\n\n public requestHandle<TResult = unknown, TParams = unknown>(\n method: string,\n params?: TParams,\n options: RequestOptions = {},\n ): LspRequestHandle<TResult> {\n const id = this.allocateRequestId()\n const cancellation = new AbortController()\n const signal = options.signal\n ? AbortSignal.any([options.signal, cancellation.signal])\n : cancellation.signal\n const response = this.sendHandledRequest<TResult>(\n id,\n method,\n params,\n { ...options, signal },\n () => signal.aborted,\n )\n\n return {\n id,\n response,\n cancel: () => {\n cancellation.abort(new LspRequestCancelledError())\n this.abortRequest(id)\n },\n }\n }\n\n public notify<TParams = unknown>(method: string, params?: TParams): Promise<void> {\n if (!this.transport) return Promise.reject(new Error('LSP client is not connected'))\n const connection = { transport: this.transport, epoch: this.connectionEpoch }\n const send = () => this.notifyReady(method, params, connection)\n if (this.state === 'ready') return send()\n\n return this.awaitInitialization().then(send)\n }\n\n public notification<TParams = unknown>(method: string, params?: TParams): Promise<void> {\n return this.notify(method, params)\n }\n\n public hasCapability(name: keyof lsp.ServerCapabilities): boolean | null {\n if (!this.serverCapabilities) return null\n return Boolean(this.serverCapabilities[name])\n }\n\n public didOpenDocument(document: LspDocument): void {\n this.requireDocumentSyncReady()\n if (this.syncedDocuments.has(document.uri)) return\n if (!this.shouldTrackDocumentSync()) return\n\n if (!this.syncOpenClose) {\n this.syncedDocuments.add(document.uri)\n return\n }\n\n this.sendNotification('textDocument/didOpen', {\n textDocument: {\n uri: document.uri,\n languageId: document.languageId,\n version: document.version,\n text: documentPayloadText(document),\n },\n })\n this.syncedDocuments.add(document.uri)\n }\n\n public didChangeDocument(document: LspDocument, change: LspDocumentChange): void {\n this.requireDocumentSyncReady()\n if (this.syncMode === 'none') return\n if (!this.syncedDocuments.has(document.uri)) return\n\n this.sendNotification('textDocument/didChange', {\n textDocument: { uri: document.uri, version: document.version },\n contentChanges: this.contentChangesForDocumentChange(document, change),\n })\n }\n\n public didSaveDocument(document: LspDocument): void {\n this.requireDocumentSyncReady()\n if (!this.syncSave.enabled) return\n if (!this.syncedDocuments.has(document.uri)) return\n\n this.sendNotification('textDocument/didSave', {\n textDocument: { uri: document.uri },\n ...(this.syncSave.includeText ? { text: documentPayloadText(document) } : {}),\n })\n }\n\n public didCloseDocument(document: LspDocument): void {\n if (this.state !== 'ready') return\n if (!this.syncedDocuments.has(document.uri)) return\n if (!this.syncOpenClose || this.transport?.isClosed?.()) {\n this.syncedDocuments.delete(document.uri)\n return\n }\n\n this.sendNotification('textDocument/didClose', {\n textDocument: { uri: document.uri },\n })\n this.syncedDocuments.delete(document.uri)\n }\n\n private requireDocumentSyncReady(): void {\n if (this.state === 'ready') return\n throw new DOMException(\n 'Language-server document synchronization requires readiness',\n 'InvalidStateError',\n )\n }\n\n private async initialize(epoch: number): Promise<void> {\n const transport = this.transport\n try {\n const result = await this.requestInner<lsp.InitializeResult>(\n 'initialize',\n this.initializeParams(),\n )\n if (this.connectionEpoch !== epoch || this.transport !== transport)\n throw new LspRequestCancelledError()\n this.applyInitializeResult(result)\n this.sendNotification('initialized', {})\n this.workspace.connected()\n } catch (error) {\n if (this.connectionEpoch === epoch && this.transport === transport) this.state = 'failed'\n throw error\n }\n }\n\n private initializeParams(): lsp.InitializeParams {\n return {\n processId: this.config.processId ?? null,\n clientInfo: this.config.clientInfo ?? { name: '@singapore-editor/lsp' },\n locale: this.config.locale,\n rootUri: this.config.rootUri ?? null,\n capabilities: this.clientCapabilities,\n initializationOptions: this.config.initializationOptions,\n workspaceFolders: this.config.workspaceFolders ? [...this.config.workspaceFolders] : null,\n }\n }\n\n private applyInitializeResult(result: lsp.InitializeResult): void {\n this.initializeResult = result\n this.serverCapabilities = result.capabilities\n const sync = documentSyncOptionsFromCapabilities(result.capabilities)\n this.syncMode = sync.change\n this.syncOpenClose = sync.openClose\n this.syncSave = clientSupportsDidSave(this.clientCapabilities)\n ? sync.save\n : { enabled: false, includeText: false }\n this.state = 'ready'\n }\n\n private shouldTrackDocumentSync(): boolean {\n return this.syncOpenClose || this.syncMode !== 'none' || this.syncSave.enabled\n }\n\n private contentChangesForDocumentChange(\n document: LspDocument,\n change: LspDocumentChange,\n ): readonly lsp.TextDocumentContentChangeEvent[] {\n return measureLspPerformance(\n 'lsp.createContentChanges',\n () => this.createContentChanges(document, change),\n () => ({\n syncMode: this.syncMode,\n editCount: change.edits.length,\n length: document.textSnapshot.length,\n }),\n )\n }\n\n private createContentChanges(\n document: LspDocument,\n change: LspDocumentChange,\n ): readonly lsp.TextDocumentContentChangeEvent[] {\n return createLspContentChangesInSnapshot(change.previousSnapshot, document, {\n incremental: this.syncMode === 'incremental',\n edits: change.edits,\n })\n }\n\n private requestInner<TResult>(\n method: string,\n params: unknown,\n options: RequestOptions = {},\n ): Promise<TResult> {\n return this.requestInnerWithId(this.allocateRequestId(), method, params, options)\n }\n\n private sendHandledRequest<TResult>(\n id: LspRequestId,\n method: string,\n params: unknown,\n options: RequestOptions,\n isCancelled: () => boolean,\n ): Promise<TResult> {\n if (!this.transport) return Promise.reject(new Error('LSP client is not connected'))\n const transport = this.transport\n const initialization = this.initializePromise\n const epoch = this.connectionEpoch\n let message: string\n try {\n message = JSON.stringify(createRequestMessage(id, method, params))\n } catch (error) {\n return Promise.reject(error)\n }\n const captured: unknown = JSON.parse(message)\n const uri =\n typeof captured === 'object' && captured !== null && 'params' in captured\n ? textDocumentRequestUri(method, captured.params)\n : null\n const send = () => {\n if (\n this.connectionEpoch !== epoch ||\n this.transport !== transport ||\n this.initializePromise !== initialization\n )\n return Promise.reject(new LspRequestCancelledError())\n return this.sendReadyHandledRequest<TResult>(id, method, message, uri, options, isCancelled)\n }\n if (this.state === 'ready') return send()\n return this.awaitInitialization().then(send)\n }\n\n private sendReadyHandledRequest<TResult>(\n id: LspRequestId,\n method: string,\n message: string,\n uri: string | null,\n options: RequestOptions,\n isCancelled: () => boolean,\n ): Promise<TResult> {\n if (isCancelled()) return Promise.reject(new LspRequestCancelledError())\n const transport = this.transport\n const initialization = this.initializePromise\n const epoch = this.connectionEpoch\n const prepared = uri ? this.workspace.prepareDocumentRequest(uri, options.signal) : undefined\n const send = () => {\n if (\n isCancelled() ||\n this.connectionEpoch !== epoch ||\n this.transport !== transport ||\n this.initializePromise !== initialization\n )\n return Promise.reject(new LspRequestCancelledError())\n return this.sendEncodedRequest<TResult>(id, method, message, options)\n }\n if (prepared?.kind === 'pending')\n return prepared.ready.then((read) => {\n if (!read.isCurrent()) throw new LspRequestCancelledError()\n return send()\n })\n if (prepared?.kind === 'ready' && !prepared.read.isCurrent())\n return Promise.reject(new LspRequestCancelledError())\n return send()\n }\n\n private requestInnerWithId<TResult>(\n id: LspRequestId,\n method: string,\n params: unknown,\n options: RequestOptions,\n ): Promise<TResult> {\n const message = createRequestMessage(id, method, params)\n return this.sendEncodedRequest<TResult>(id, method, JSON.stringify(message), options)\n }\n\n private sendEncodedRequest<TResult>(\n id: LspRequestId,\n method: string,\n message: string,\n options: RequestOptions,\n ): Promise<TResult> {\n const transport = this.requireTransport()\n\n return new Promise<TResult>((resolve, reject) => {\n const pending = this.createPendingRequest(\n id,\n method,\n (result) => resolve(result as TResult),\n reject,\n options,\n )\n this.pendingRequests.set(id, pending)\n this.sendMessage(transport, message, pending)\n })\n }\n\n private allocateRequestId(): LspRequestId {\n const id = this.nextRequestId\n this.nextRequestId += 1\n return id\n }\n\n private createPendingRequest(\n id: LspRequestId,\n method: string,\n resolve: (result: unknown) => void,\n reject: (error: unknown) => void,\n options: RequestOptions,\n ): PendingRequest {\n const timeout = setTimeout(() => this.timeoutRequest(id), options.timeoutMs ?? this.timeoutMs)\n const pending: PendingRequest = { id, method, timeout, resolve, reject }\n if (!options.signal) return pending\n\n const abort = () => this.abortRequest(id)\n options.signal.addEventListener('abort', abort, { once: true })\n return { ...pending, abortCleanup: () => options.signal?.removeEventListener('abort', abort) }\n }\n\n private sendMessage(transport: LspTransport, message: string, pending: PendingRequest): void {\n const connection = { transport, epoch: this.connectionEpoch }\n try {\n transport.send(message)\n } catch (error) {\n this.deletePendingRequest(pending.id)\n this.handleTransportSendError(connection)\n pending.reject(error)\n }\n }\n\n private sendNotification(\n method: string,\n params?: unknown,\n connection: Connection = { transport: this.requireTransport(), epoch: this.connectionEpoch },\n ): void {\n try {\n if (!this.isCurrentConnection(connection)) throw new LspRequestCancelledError()\n const message = JSON.stringify(createNotificationMessage(method, params))\n if (!this.isCurrentConnection(connection)) throw new LspRequestCancelledError()\n connection.transport.send(message)\n } catch (error) {\n this.handleTransportSendError(connection)\n throw error\n }\n }\n\n private notifyReady(method: string, params: unknown, connection: Connection): Promise<void> {\n try {\n this.sendNotification(method, params, connection)\n return Promise.resolve()\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n private trySendNotification(method: string, params?: unknown): boolean {\n try {\n this.sendNotification(method, params)\n return true\n } catch {\n return false\n }\n }\n\n private receiveMessage(message: string): void {\n const parsed = JSON.parse(message) as unknown\n if (isResponseMessage(parsed)) {\n this.handleResponse(parsed)\n return\n }\n if (isNotificationMessage(parsed)) {\n this.handleNotification(parsed)\n return\n }\n if (isRequestMessage(parsed)) {\n this.handleRequest(parsed)\n }\n }\n\n private handleResponse(message: lsp.ResponseMessage): void {\n if (message.id === null) return\n\n const pending = this.pendingRequests.get(message.id)\n if (!pending) return\n\n this.deletePendingRequest(message.id)\n try {\n pending.resolve(responseResult(message))\n } catch (error) {\n pending.reject(error)\n }\n }\n\n private handleNotification(message: lsp.NotificationMessage): void {\n const handler = this.config.notificationHandlers?.[message.method]\n if (handler?.(this, message.params, message)) return\n if (this.handleDefaultNotification(message)) return\n this.config.unhandledNotification?.(this, message.method, message.params, message)\n }\n\n private handleDefaultNotification(message: lsp.NotificationMessage): boolean {\n if (message.method === 'window/logMessage') return this.handleServerMessage(message)\n if (message.method === 'window/showMessage') return this.handleServerMessage(message)\n return false\n }\n\n private handleServerMessage(message: lsp.NotificationMessage): boolean {\n this.config.serverMessageHandler?.(this, {\n method: message.method as 'window/logMessage' | 'window/showMessage',\n type: messageType(message.params),\n message: messageText(message.params),\n params: message.params,\n })\n return true\n }\n\n private handleRequest(message: lsp.RequestMessage): void {\n if (!this.transport) return\n const connection = { transport: this.transport, epoch: this.connectionEpoch }\n const handler = this.config.serverRequestHandlers?.[message.method]\n if (!handler) {\n this.sendServerResponse(createMethodNotFoundResponse(message.id, message.method), connection)\n return\n }\n\n let result: unknown\n try {\n result = handler(this, message.params, message)\n } catch (error) {\n this.sendServerResponse(createInternalErrorResponse(message.id, error), connection)\n return\n }\n\n void Promise.resolve(result).then(\n (result) => this.sendServerResponse(createResponseMessage(message.id, result), connection),\n (error) =>\n this.sendServerResponse(createInternalErrorResponse(message.id, error), connection),\n )\n }\n\n private sendServerResponse(message: lsp.ResponseMessage, connection: Connection): void {\n if (!this.isCurrentConnection(connection)) return\n\n try {\n const encoded = JSON.stringify(message)\n if (!this.isCurrentConnection(connection)) return\n connection.transport.send(encoded)\n } catch {\n this.handleTransportSendError(connection)\n }\n }\n\n private timeoutRequest(id: LspRequestId): void {\n const pending = this.pendingRequests.get(id)\n if (!pending) return\n\n this.deletePendingRequest(id)\n pending.reject(new Error(`LSP request timed out: ${pending.method}`))\n }\n\n private abortRequest(id: LspRequestId): void {\n const pending = this.pendingRequests.get(id)\n if (!pending) return\n\n this.trySendNotification('$/cancelRequest', { id })\n this.deletePendingRequest(id)\n pending.reject(new LspRequestCancelledError())\n }\n\n private deletePendingRequest(id: LspRequestId): void {\n const pending = this.pendingRequests.get(id)\n if (!pending) return\n\n clearTimeout(pending.timeout)\n pending.abortCleanup?.()\n this.pendingRequests.delete(id)\n }\n\n private rejectPendingRequests(error: Error): void {\n for (const pending of this.pendingRequests.values()) {\n clearTimeout(pending.timeout)\n pending.abortCleanup?.()\n pending.reject(error)\n }\n\n this.pendingRequests.clear()\n }\n\n private isCurrentConnection(connection: Connection): boolean {\n return this.connectionEpoch === connection.epoch && this.transport === connection.transport\n }\n\n private handleTransportSendError(connection: Connection): void {\n if (this.isCurrentConnection(connection)) this.disconnect()\n }\n\n private awaitInitialization(): Promise<void> {\n if (this.initializePromise) return this.initializePromise\n return Promise.reject(new Error('LSP client is not initialized'))\n }\n\n private requireTransport(): LspTransport {\n if (this.transport) return this.transport\n throw new Error('LSP client is not connected')\n }\n}\n\nfunction textDocumentRequestUri(method: string, params: unknown): string | null {\n if (!method.startsWith('textDocument/') || typeof params !== 'object' || params === null)\n return null\n if (!('textDocument' in params)) return null\n const document = params.textDocument\n if (typeof document !== 'object' || document === null || !('uri' in document)) return null\n return typeof document.uri === 'string' ? document.uri : null\n}\n\n// didOpen and didSave with text carry the whole document by protocol definition.\nfunction documentPayloadText(document: LspDocument): string {\n return document.textSnapshot.readRange(0, document.textSnapshot.length)\n}\n\nconst messageText = (params: unknown): string | null => {\n if (!isRecord(params)) return null\n return typeof params.message === 'string' ? params.message : null\n}\n\nconst messageType = (params: unknown): number => {\n if (!isRecord(params)) return 3\n return typeof params.type === 'number' ? params.type : 3\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n"],"mappings":";;;;;;AAgFA,IAAa,YAAb,MAAuB;CACrB;CACA,qBAA2D;CAC3D,mBAAuD;CAEvD;CACA;CACA;CACA,YAAyC;CACzC,QAAgC;CAChC,gBAAwB;CACxB,oBAAkD;CAClD,kBAA0B;CAC1B,WAAwC;CACxC,gBAAwB;CACxB,WAAwC;EAAE,SAAS;EAAO,aAAa;CAAM;CAC7E,kCAAmC,IAAI,IAAkC;CACzE,kCA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C;EAC3C,IAAI,KAAK,mBAAmB,OAAO,KAAK;EACxC,OAAO,QAAQ,uBAAO,IAAI,MAAM,+BAA+B,CAAC;CAClE;CAEA,mBAAyC;EACvC,IAAI,KAAK,WAAW,OAAO,KAAK;EAChC,MAAM,IAAI,MAAM,6BAA6B;CAC/C;AACF;AAEA,SAAS,uBAAuB,QAAgB,QAAgC;CAC9E,IAAI,CAAC,OAAO,WAAW,eAAe,KAAK,OAAO,WAAW,YAAY,WAAW,MAClF,OAAO;CACT,IAAI,EAAE,kBAAkB,SAAS,OAAO;CACxC,MAAM,WAAW,OAAO;CACxB,IAAI,OAAO,aAAa,YAAY,aAAa,QAAQ,EAAE,SAAS,WAAW,OAAO;CACtF,OAAO,OAAO,SAAS,QAAQ,WAAW,SAAS,MAAM;AAC3D;AAGA,SAAS,oBAAoB,UAA+B;CAC1D,OAAO,SAAS,aAAa,UAAU,GAAG,SAAS,aAAa,MAAM;AACxE;AAEA,IAAM,eAAe,WAAmC;CACtD,IAAI,CAAC,SAAS,MAAM,GAAG,OAAO;CAC9B,OAAO,OAAO,OAAO,YAAY,WAAW,OAAO,UAAU;AAC/D;AAEA,IAAM,eAAe,WAA4B;CAC/C,IAAI,CAAC,SAAS,MAAM,GAAG,OAAO;CAC9B,OAAO,OAAO,OAAO,SAAS,WAAW,OAAO,OAAO;AACzD;AAEA,IAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { LspClient, type LspClientConfig, type LspClientState, type RequestOptio
|
|
|
4
4
|
export { createLspContentChanges, createLspContentChangesInSnapshot, lspPositionToOffset, lspPositionToOffsetInSnapshot, offsetToLspPosition, offsetToLspPositionInSnapshot, textEditsToLspContentChanges, textEditsToLspContentChangesInSnapshot, textEditToLspContentChange, textEditToLspContentChangeInSnapshot, type LspContentChangeOptions, } from './positions';
|
|
5
5
|
export { LSP_SERVER_EXITED, LspRequestCancelledError, LspResponseError, LspServerExitedError, METHOD_NOT_FOUND, REQUEST_CANCELLED, type LspServerExitedParams, } from './protocol';
|
|
6
6
|
export { LspTransportClosedError, createWebSocketLspTransport, createWorkerLspTransport, type LspManagedTransport, type LspWebSocketConstructor, type LspWebSocketLike, type LspWebSocketTransportOptions, type LspWorkerLike, type LspWorkerMessageFormat, type LspWorkerTransportOptions, } from './transports';
|
|
7
|
-
export type { LspLineStarts, LspDocument, LspDocumentChange, LspDocumentOpenSnapshotOptions, LspDocumentOpenSnapshotResult, LspDocumentSaveSync, LspDocumentSyncMode, LspDocumentSyncOptions, LspDocumentTransitionOptions, LspDocumentTransitionNotification, LspDocumentTransitionResult, LspClientWorkspace, LspNotificationHandler, LspRequestHandle, LspServerRequestHandler, LspServerMessageHandler, LspServerMessageNotification, PublishDiagnosticsNotificationParams, LspTextDocumentSnapshot, LspTextEdit, LspTextSnapshot, LspTransport, LspTransportHandler, LspUnhandledNotificationHandler, LspWorkspaceSyncTarget, LspWorkspaceDocumentAttachment, LspWorkspaceFactory, LspWorkspaceSnapshotEditOptions, LspWorkspaceUnchangedSourceOptions, } from './types';
|
|
7
|
+
export type { LspLineStarts, LspDocument, LspPreparedDocumentSource, LspDocumentSourcePreparation, LspDocumentChange, LspDocumentOpenSnapshotOptions, LspDocumentOpenSnapshotResult, LspDocumentSaveSync, LspDocumentSyncMode, LspDocumentSyncOptions, LspDocumentTransitionOptions, LspDocumentTransitionNotification, LspDocumentTransitionResult, LspClientWorkspace, LspNotificationHandler, LspRequestHandle, LspServerRequestHandler, LspServerMessageHandler, LspServerMessageNotification, PublishDiagnosticsNotificationParams, LspTextDocumentSnapshot, LspTextEdit, LspTextSnapshot, LspTransport, LspTransportHandler, LspUnhandledNotificationHandler, LspWorkspaceSyncTarget, LspWorkspaceDocumentAttachment, LspWorkspaceFactory, LspWorkspaceSnapshotEditOptions, LspWorkspaceUnchangedSourceOptions, } from './types';
|
|
8
8
|
export { LspWorkspace, arrayLspLineStarts } from './workspace';
|
|
9
9
|
export type * as lsp from 'vscode-languageserver-protocol';
|
|
10
10
|
export { recordLspPerformanceDiagnostic } from './performanceDiagnostics';
|