Support webWorker clients
This commit is contained in:
@@ -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";
|
import {initConnection} from "./connection";
|
||||||
|
|
||||||
// By default create node connection
|
/** Helper function determining whether we are executing with node runtime */
|
||||||
const connection = createConnection();
|
function isNode(): boolean {
|
||||||
initConnection(connection);
|
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());
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"moduleResolution": "node"
|
"moduleResolution": "node",
|
||||||
|
"lib": ["es6", "webworker"]
|
||||||
},
|
},
|
||||||
"watchOptions": {
|
"watchOptions": {
|
||||||
"watchFile": "useFsEvents",
|
"watchFile": "useFsEvents",
|
||||||
|
|||||||
Reference in New Issue
Block a user