Support webWorker clients

This commit is contained in:
Christopher Schleiden
2023-01-20 17:20:21 -08:00
parent 675e8f1307
commit eab53474cb
2 changed files with 25 additions and 5 deletions
+23 -4
View File
@@ -1,7 +1,26 @@
import {createConnection} from "vscode-languageserver/node";
import {Connection} from "vscode-languageserver";
import {
BrowserMessageReader,
BrowserMessageWriter,
createConnection as createBrowserConnection
} from "vscode-languageserver/browser";
import {createConnection as createNodeConnection} from "vscode-languageserver/node";
import {initConnection} from "./connection";
// By default create node connection
const connection = createConnection();
initConnection(connection);
/** Helper function determining whether we are executing with node runtime */
function isNode(): boolean {
return typeof process !== "undefined" && process.versions?.node != null;
}
function getConnection(): Connection {
if (isNode()) {
return createNodeConnection();
} else {
const messageReader = new BrowserMessageReader(self);
const messageWriter = new BrowserMessageWriter(self);
return createBrowserConnection(messageReader, messageWriter);
}
}
initConnection(getConnection());
+2 -1
View File
@@ -7,7 +7,8 @@
"forceConsistentCasingInFileNames": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "node"
"moduleResolution": "node",
"lib": ["es6", "webworker"]
},
"watchOptions": {
"watchFile": "useFsEvents",