vscode-languageclient
Advanced tools
Comparing version 8.0.0-next.1 to 8.0.0-next.2
@@ -10,19 +10,2 @@ /// <reference types="node" /> | ||
export * from '../common/api'; | ||
export interface ExecutableOptions { | ||
cwd?: string; | ||
env?: any; | ||
detached?: boolean; | ||
shell?: boolean; | ||
} | ||
export interface Executable { | ||
command: string; | ||
args?: string[]; | ||
options?: ExecutableOptions; | ||
} | ||
export interface ForkOptions { | ||
cwd?: string; | ||
env?: any; | ||
encoding?: string; | ||
execArgv?: string[]; | ||
} | ||
export declare enum TransportKind { | ||
@@ -50,2 +33,20 @@ stdio = 0, | ||
export declare type Transport = TransportKind | SocketTransport; | ||
export interface ExecutableOptions { | ||
cwd?: string; | ||
env?: any; | ||
detached?: boolean; | ||
shell?: boolean; | ||
} | ||
export interface Executable { | ||
command: string; | ||
transport?: Transport; | ||
args?: string[]; | ||
options?: ExecutableOptions; | ||
} | ||
export interface ForkOptions { | ||
cwd?: string; | ||
env?: any; | ||
encoding?: string; | ||
execArgv?: string[]; | ||
} | ||
export interface NodeModule { | ||
@@ -75,4 +76,4 @@ module: string; | ||
export declare class LanguageClient extends CommonLanguageClient { | ||
private _serverOptions; | ||
private _forceDebug; | ||
private readonly _serverOptions; | ||
private readonly _forceDebug; | ||
private _serverProcess; | ||
@@ -79,0 +80,0 @@ private _isDetached; |
@@ -31,9 +31,2 @@ "use strict"; | ||
const REQUIRED_VSCODE_VERSION = '^1.58.0'; // do not change format, updated by `updateVSCode` script | ||
var Executable; | ||
(function (Executable) { | ||
function is(value) { | ||
return Is.string(value.command); | ||
} | ||
Executable.is = is; | ||
})(Executable || (Executable = {})); | ||
var TransportKind; | ||
@@ -49,3 +42,3 @@ (function (TransportKind) { | ||
function isSocket(value) { | ||
let candidate = value; | ||
const candidate = value; | ||
return candidate && candidate.kind === TransportKind.socket && Is.number(candidate.port); | ||
@@ -55,2 +48,9 @@ } | ||
})(Transport || (Transport = {})); | ||
var Executable; | ||
(function (Executable) { | ||
function is(value) { | ||
return Is.string(value.command); | ||
} | ||
Executable.is = is; | ||
})(Executable || (Executable = {})); | ||
var NodeModule; | ||
@@ -118,3 +118,3 @@ (function (NodeModule) { | ||
checkVersion() { | ||
let codeVersion = SemVer.parse(vscode_1.version); | ||
const codeVersion = SemVer.parse(vscode_1.version); | ||
if (!codeVersion) { | ||
@@ -137,3 +137,3 @@ throw new Error(`No valid VS Code version detected. Version string is: ${vscode_1.version}`); | ||
if (this._serverProcess) { | ||
let toCheck = this._serverProcess; | ||
const toCheck = this._serverProcess; | ||
this._serverProcess = undefined; | ||
@@ -177,3 +177,3 @@ if (this._isDetached === undefined || !this._isDetached) { | ||
} | ||
let result = Object.create(null); | ||
const result = Object.create(null); | ||
Object.keys(process.env).forEach(key => result[key] = process.env[key]); | ||
@@ -206,3 +206,3 @@ if (fork) { | ||
} | ||
let server = this._serverOptions; | ||
const server = this._serverOptions; | ||
// We got a function. | ||
@@ -250,2 +250,3 @@ if (Is.func(server)) { | ||
return this._getServerWorkingDir(json.options).then(serverWorkingDir => { | ||
var _a; | ||
if (NodeModule.is(json) && json.module) { | ||
@@ -255,4 +256,4 @@ let node = json; | ||
if (node.runtime) { | ||
let args = []; | ||
let options = node.options || Object.create(null); | ||
const args = []; | ||
const options = (_a = node.options) !== null && _a !== void 0 ? _a : Object.create(null); | ||
if (options.execArgv) { | ||
@@ -287,3 +288,3 @@ options.execArgv.forEach(element => args.push(element)); | ||
if (transport === TransportKind.ipc || transport === TransportKind.stdio) { | ||
let serverProcess = cp.spawn(runtime, args, execOptions); | ||
const serverProcess = cp.spawn(runtime, args, execOptions); | ||
if (!serverProcess || !serverProcess.pid) { | ||
@@ -304,3 +305,3 @@ return Promise.reject(`Launching server using runtime ${runtime} failed.`); | ||
return node_1.createClientPipeTransport(pipeName).then((transport) => { | ||
let process = cp.spawn(runtime, args, execOptions); | ||
const process = cp.spawn(runtime, args, execOptions); | ||
if (!process || !process.pid) { | ||
@@ -319,3 +320,3 @@ return Promise.reject(`Launching server using runtime ${runtime} failed.`); | ||
return node_1.createClientSocketTransport(transport.port).then((transport) => { | ||
let process = cp.spawn(runtime, args, execOptions); | ||
const process = cp.spawn(runtime, args, execOptions); | ||
if (!process || !process.pid) { | ||
@@ -336,3 +337,4 @@ return Promise.reject(`Launching server using runtime ${runtime} failed.`); | ||
return new Promise((resolve, reject) => { | ||
let args = node.args && node.args.slice() || []; | ||
var _a, _b; | ||
const args = (_a = (node.args && node.args.slice())) !== null && _a !== void 0 ? _a : []; | ||
if (transport === TransportKind.ipc) { | ||
@@ -352,3 +354,3 @@ args.push('--node-ipc'); | ||
args.push(`--clientProcessId=${process.pid.toString()}`); | ||
let options = node.options || Object.create(null); | ||
const options = (_b = node.options) !== null && _b !== void 0 ? _b : Object.create(null); | ||
options.env = getEnvironment(options.env, true); | ||
@@ -359,3 +361,3 @@ options.execArgv = options.execArgv || []; | ||
if (transport === TransportKind.ipc || transport === TransportKind.stdio) { | ||
let sp = cp.fork(node.module, args || [], options); | ||
const sp = cp.fork(node.module, args || [], options); | ||
assertStdio(sp); | ||
@@ -374,3 +376,3 @@ this._serverProcess = sp; | ||
node_1.createClientPipeTransport(pipeName).then((transport) => { | ||
let sp = cp.fork(node.module, args || [], options); | ||
const sp = cp.fork(node.module, args || [], options); | ||
assertStdio(sp); | ||
@@ -387,3 +389,3 @@ this._serverProcess = sp; | ||
node_1.createClientSocketTransport(transport.port).then((transport) => { | ||
let sp = cp.fork(node.module, args || [], options); | ||
const sp = cp.fork(node.module, args || [], options); | ||
assertStdio(sp); | ||
@@ -402,14 +404,61 @@ this._serverProcess = sp; | ||
else if (Executable.is(json) && json.command) { | ||
let command = json; | ||
let args = command.args || []; | ||
let options = Object.assign({}, command.options); | ||
const command = json; | ||
const args = json.args !== undefined ? json.args.slice(0) : []; | ||
let pipeName = undefined; | ||
const transport = json.transport; | ||
if (transport === TransportKind.stdio) { | ||
args.push('--stdio'); | ||
} | ||
else if (transport === TransportKind.pipe) { | ||
pipeName = node_1.generateRandomPipeName(); | ||
args.push(`--pipe=${pipeName}`); | ||
} | ||
else if (Transport.isSocket(transport)) { | ||
args.push(`--socket=${transport.port}`); | ||
} | ||
else if (transport === TransportKind.ipc) { | ||
throw new Error(`Transport kind ipc is not support for command executable`); | ||
} | ||
const options = Object.assign({}, command.options); | ||
options.cwd = options.cwd || serverWorkingDir; | ||
let serverProcess = cp.spawn(command.command, args, options); | ||
if (!serverProcess || !serverProcess.pid) { | ||
return Promise.reject(`Launching server using command ${command.command} failed.`); | ||
if (transport === undefined || transport === TransportKind.stdio) { | ||
const serverProcess = cp.spawn(command.command, args, options); | ||
if (!serverProcess || !serverProcess.pid) { | ||
return Promise.reject(`Launching server using command ${command.command} failed.`); | ||
} | ||
serverProcess.stderr.on('data', data => this.outputChannel.append(Is.string(data) ? data : data.toString(encoding))); | ||
this._serverProcess = serverProcess; | ||
this._isDetached = !!options.detached; | ||
return Promise.resolve({ reader: new node_1.StreamMessageReader(serverProcess.stdout), writer: new node_1.StreamMessageWriter(serverProcess.stdin) }); | ||
} | ||
serverProcess.stderr.on('data', data => this.outputChannel.append(Is.string(data) ? data : data.toString(encoding))); | ||
this._serverProcess = serverProcess; | ||
this._isDetached = !!options.detached; | ||
return Promise.resolve({ reader: new node_1.StreamMessageReader(serverProcess.stdout), writer: new node_1.StreamMessageWriter(serverProcess.stdin) }); | ||
else if (transport === TransportKind.pipe) { | ||
return node_1.createClientPipeTransport(pipeName).then((transport) => { | ||
const serverProcess = cp.spawn(command.command, args, options); | ||
if (!serverProcess || !serverProcess.pid) { | ||
throw new Error(`Launching server using command ${command.command} failed.`); | ||
} | ||
this._serverProcess = serverProcess; | ||
this._isDetached = !!options.detached; | ||
serverProcess.stderr.on('data', data => this.outputChannel.append(Is.string(data) ? data : data.toString(encoding))); | ||
serverProcess.stdout.on('data', data => this.outputChannel.append(Is.string(data) ? data : data.toString(encoding))); | ||
return transport.onConnected().then((protocol) => { | ||
return { reader: protocol[0], writer: protocol[1] }; | ||
}); | ||
}); | ||
} | ||
else if (Transport.isSocket(transport)) { | ||
return node_1.createClientSocketTransport(transport.port).then((transport) => { | ||
const serverProcess = cp.spawn(command.command, args, options); | ||
if (!serverProcess || !serverProcess.pid) { | ||
throw new Error(`Launching server using command ${command.command} failed.`); | ||
} | ||
this._serverProcess = serverProcess; | ||
this._isDetached = !!options.detached; | ||
serverProcess.stderr.on('data', data => this.outputChannel.append(Is.string(data) ? data : data.toString(encoding))); | ||
serverProcess.stdout.on('data', data => this.outputChannel.append(Is.string(data) ? data : data.toString(encoding))); | ||
return transport.onConnected().then((protocol) => { | ||
return { reader: protocol[0], writer: protocol[1] }; | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -416,0 +465,0 @@ return Promise.reject(new Error(`Unsupported server configuration ` + JSON.stringify(server, null, 4))); |
{ | ||
"name": "vscode-languageclient", | ||
"description": "VSCode Language client implementation", | ||
"version": "8.0.0-next.1", | ||
"version": "8.0.0-next.2", | ||
"author": "Microsoft Corporation", | ||
@@ -32,3 +32,3 @@ "license": "MIT", | ||
"semver": "^7.3.4", | ||
"vscode-languageserver-protocol": "3.17.0-next.7" | ||
"vscode-languageserver-protocol": "3.17.0-next.8" | ||
}, | ||
@@ -42,3 +42,3 @@ "scripts": { | ||
"watch": "node ../build/bin/tsc -b ./tsconfig-watch.json -w", | ||
"lint": "node ../node_modules/eslint/bin/eslint.js ./src/**/*.ts", | ||
"lint": "node ../node_modules/eslint/bin/eslint.js --ext ts src", | ||
"test": "cd ../client-node-tests && npm test && cd ../client", | ||
@@ -45,0 +45,0 @@ "clean": "node ../node_modules/rimraf/bin.js lib", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
437200
8822
+ Addedvscode-jsonrpc@8.0.0-next.2(transitive)
+ Addedvscode-languageserver-protocol@3.17.0-next.8(transitive)
- Removedvscode-jsonrpc@8.0.0-next.1(transitive)
- Removedvscode-languageserver-protocol@3.17.0-next.7(transitive)