@codingame/monaco-languageclient-wrapper 4.3.2 → 4.4.1
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/index.d.ts +2 -0
- package/dist/index2.js +41 -4
- package/package.json +1 -1
- package/stats.html +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9281,6 +9281,7 @@ interface Infrastructure {
|
|
|
9281
9281
|
* @param id The language server id
|
|
9282
9282
|
*/
|
|
9283
9283
|
openConnection(id: LanguageClientId): Promise<MessageTransports>;
|
|
9284
|
+
getInitializationOptions?(): LSPAny;
|
|
9284
9285
|
}
|
|
9285
9286
|
declare abstract class CodinGameInfrastructure implements Infrastructure {
|
|
9286
9287
|
/**
|
|
@@ -9320,6 +9321,7 @@ declare abstract class CodinGameInfrastructure implements Infrastructure {
|
|
|
9320
9321
|
*/
|
|
9321
9322
|
protected abstract getSecurityToken(): Promise<string>;
|
|
9322
9323
|
openConnection(id: LanguageClientId): Promise<MessageTransports>;
|
|
9324
|
+
getInitializationOptions(): LSPAny;
|
|
9323
9325
|
}
|
|
9324
9326
|
|
|
9325
9327
|
/**
|
package/dist/index2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toSocket,
|
|
1
|
+
import { toSocket, WebSocketMessageWriter, WebSocketMessageReader } from 'vscode-ws-jsonrpc';
|
|
2
2
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
3
3
|
import { loadConfigurationForExtension } from '@codingame/monaco-editor-wrapper/features/extensionConfigurations';
|
|
4
4
|
import { registerDefaultConfigurations, registerTextModelContentProvider } from '@codingame/monaco-editor-wrapper';
|
|
@@ -5718,10 +5718,16 @@ function getFile(uri, languageClient) {
|
|
|
5718
5718
|
}
|
|
5719
5719
|
});
|
|
5720
5720
|
}
|
|
5721
|
+
class CloseOnDisposeWebSocketMessageReader extends WebSocketMessageReader {
|
|
5722
|
+
dispose() {
|
|
5723
|
+
super.dispose();
|
|
5724
|
+
this.socket.dispose();
|
|
5725
|
+
}
|
|
5726
|
+
}
|
|
5721
5727
|
async function openWebsocketConnection(url) {
|
|
5722
5728
|
const webSocket = new WebSocket(url);
|
|
5723
5729
|
const socket = toSocket(webSocket);
|
|
5724
|
-
const reader = new
|
|
5730
|
+
const reader = new CloseOnDisposeWebSocketMessageReader(socket);
|
|
5725
5731
|
const writer = new WebSocketMessageWriter(socket);
|
|
5726
5732
|
await new Promise((resolve, reject) => {
|
|
5727
5733
|
webSocket.addEventListener('open', resolve);
|
|
@@ -5781,6 +5787,15 @@ class CodinGameInfrastructure {
|
|
|
5781
5787
|
throw new Error('Unable to connect to server');
|
|
5782
5788
|
}
|
|
5783
5789
|
}
|
|
5790
|
+
getInitializationOptions() {
|
|
5791
|
+
const files = monaco.editor.getModels().filter(model => model.uri.scheme === 'file').reduce((map, model) => {
|
|
5792
|
+
map[model.uri.toString(true)] = model.getValue();
|
|
5793
|
+
return map;
|
|
5794
|
+
}, {});
|
|
5795
|
+
return {
|
|
5796
|
+
files
|
|
5797
|
+
};
|
|
5798
|
+
}
|
|
5784
5799
|
}
|
|
5785
5800
|
async function loadExtensionConfigurations(clientOptions, useMutualizedProxy) {
|
|
5786
5801
|
const extensionConfigurationToLoad = new Set();
|
|
@@ -16452,7 +16467,29 @@ async function createLanguageClient(id, infrastructure, _ref, errorHandler, midd
|
|
|
16452
16467
|
initializationOptions,
|
|
16453
16468
|
createAdditionalFeatures
|
|
16454
16469
|
} = _ref;
|
|
16455
|
-
const
|
|
16470
|
+
const allInitializationOptions = () => {
|
|
16471
|
+
var _infrastructure$getIn;
|
|
16472
|
+
const infrastructureInitOptions = (_infrastructure$getIn = infrastructure.getInitializationOptions) === null || _infrastructure$getIn === void 0 ? void 0 : _infrastructure$getIn.call(infrastructure);
|
|
16473
|
+
const languageInitOptions = typeof initializationOptions === 'function' ? initializationOptions() : initializationOptions;
|
|
16474
|
+
if (infrastructureInitOptions != null || languageInitOptions != null) {
|
|
16475
|
+
return _objectSpread2(_objectSpread2({}, infrastructureInitOptions !== null && infrastructureInitOptions !== void 0 ? infrastructureInitOptions : {}), languageInitOptions !== null && languageInitOptions !== void 0 ? languageInitOptions : {});
|
|
16476
|
+
}
|
|
16477
|
+
return undefined;
|
|
16478
|
+
};
|
|
16479
|
+
class _MonacoLanguageClient extends MonacoLanguageClient {
|
|
16480
|
+
async stop(timeout) {
|
|
16481
|
+
const connection = this['_connection'];
|
|
16482
|
+
try {
|
|
16483
|
+
await super.stop(timeout);
|
|
16484
|
+
} finally {
|
|
16485
|
+
try {
|
|
16486
|
+
connection.dispose();
|
|
16487
|
+
} catch (err) {
|
|
16488
|
+
}
|
|
16489
|
+
}
|
|
16490
|
+
}
|
|
16491
|
+
}
|
|
16492
|
+
const client = new _MonacoLanguageClient({
|
|
16456
16493
|
id: "".concat(id, "-languageclient"),
|
|
16457
16494
|
name: "CodinGame ".concat(id, " Language Client"),
|
|
16458
16495
|
clientOptions: {
|
|
@@ -16460,7 +16497,7 @@ async function createLanguageClient(id, infrastructure, _ref, errorHandler, midd
|
|
|
16460
16497
|
errorHandler,
|
|
16461
16498
|
middleware,
|
|
16462
16499
|
synchronize,
|
|
16463
|
-
initializationOptions
|
|
16500
|
+
initializationOptions: allInitializationOptions
|
|
16464
16501
|
},
|
|
16465
16502
|
connectionProvider: new CGLSPConnectionProvider(id, infrastructure)
|
|
16466
16503
|
});
|