vscode-ws-jsonrpc
Advanced tools
Comparing version 0.5.0-dev.0 to 1.0.0
@@ -5,4 +5,7 @@ # Changelog | ||
## [0.5.0-dev.0] - 2022-06-17 | ||
## [1.0.0] - 2022-06-21 | ||
* Merged npm packages `@codingame/monaco-jsonrpc` and `vscode-ws-jsonrpc` into this package. | ||
* Integrate eslint with eslint-config-standard #[385](https://github.com/TypeFox/monaco-languageclient/pull/385) | ||
There was no CHANGELOG available in the previous repositories. |
"use strict"; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toSocket = exports.listen = void 0; | ||
const socket_1 = require("./socket"); | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
const logger_1 = require("./logger"); | ||
@@ -19,9 +27,15 @@ function listen(options) { | ||
send: content => webSocket.send(content), | ||
onMessage: cb => webSocket.onmessage = event => cb(event.data), | ||
onError: cb => webSocket.onerror = event => { | ||
if ('message' in event) { | ||
cb(event.message); | ||
} | ||
onMessage: cb => { | ||
webSocket.onmessage = event => cb(event.data); | ||
}, | ||
onClose: cb => webSocket.onclose = event => cb(event.code, event.reason), | ||
onError: cb => { | ||
webSocket.onerror = event => { | ||
if ('message' in event) { | ||
cb(event.message); | ||
} | ||
}; | ||
}, | ||
onClose: cb => { | ||
webSocket.onclose = event => cb(event.code, event.reason); | ||
}, | ||
dispose: () => webSocket.close() | ||
@@ -28,0 +42,0 @@ }; |
@@ -1,3 +0,2 @@ | ||
import { Disposable } from 'vscode-jsonrpc/lib/common/disposable'; | ||
export { Disposable }; | ||
import { Disposable } from 'vscode-jsonrpc'; | ||
export declare class DisposableCollection implements Disposable { | ||
@@ -8,2 +7,3 @@ protected readonly disposables: Disposable[]; | ||
} | ||
export { Disposable }; | ||
//# sourceMappingURL=disposable.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DisposableCollection = exports.Disposable = void 0; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
const disposable_1 = require("vscode-jsonrpc/lib/common/disposable"); | ||
Object.defineProperty(exports, "Disposable", { enumerable: true, get: function () { return disposable_1.Disposable; } }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Disposable = exports.DisposableCollection = void 0; | ||
const vscode_jsonrpc_1 = require("vscode-jsonrpc"); | ||
Object.defineProperty(exports, "Disposable", { enumerable: true, get: function () { return vscode_jsonrpc_1.Disposable; } }); | ||
class DisposableCollection { | ||
@@ -11,0 +11,0 @@ constructor() { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("vscode-jsonrpc"), exports); | ||
@@ -9,0 +9,0 @@ tslib_1.__exportStar(require("vscode-jsonrpc/lib/common/messages"), exports); |
@@ -1,2 +0,2 @@ | ||
import { Logger } from "vscode-jsonrpc"; | ||
import { Logger } from 'vscode-jsonrpc'; | ||
export declare class ConsoleLogger implements Logger { | ||
@@ -3,0 +3,0 @@ error(message: string): void; |
import { MessageReader, MessageWriter, Disposable, Message } from 'vscode-jsonrpc'; | ||
export declare function forward(clientConnection: IConnection, serverConnection: IConnection, map?: (message: Message) => Message): void; | ||
export interface IConnection extends Disposable { | ||
@@ -9,3 +8,4 @@ readonly reader: MessageReader; | ||
} | ||
export declare function forward(clientConnection: IConnection, serverConnection: IConnection, map?: (message: Message) => Message): void; | ||
export declare function createConnection<T extends {}>(reader: MessageReader, writer: MessageWriter, onDispose: () => void, extensions?: T): IConnection & T; | ||
//# sourceMappingURL=connection.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createConnection = exports.forward = void 0; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createConnection = exports.forward = void 0; | ||
const vscode_jsonrpc_1 = require("vscode-jsonrpc"); | ||
@@ -21,3 +21,4 @@ const disposable_1 = require("../disposable"); | ||
writer.onClose(() => disposeOnClose.dispose()); | ||
return Object.assign({ reader, writer, | ||
return Object.assign({ reader, | ||
writer, | ||
forward(to, map = (message) => message) { | ||
@@ -24,0 +25,0 @@ reader.listen(input => { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./connection"), exports); | ||
tslib_1.__exportStar(require("./launch"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ /// <reference types="node" /> | ||
import * as cp from 'child_process'; | ||
import { IConnection } from "./connection"; | ||
import { IConnection } from './connection'; | ||
import { IWebSocket, IWebSocketConnection } from '../socket'; | ||
@@ -10,0 +10,0 @@ export declare function createServerProcess(serverName: string, command: string, args?: string[], options?: cp.SpawnOptions): IConnection | undefined; |
"use strict"; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
@@ -5,0 +5,0 @@ * ------------------------------------------------------------------------------------------ */ |
@@ -1,4 +0,4 @@ | ||
import { MessageConnection, Logger } from "vscode-jsonrpc"; | ||
import { IWebSocket } from "./socket"; | ||
import { MessageConnection, Logger } from 'vscode-jsonrpc'; | ||
import { IWebSocket } from './socket'; | ||
export declare function createWebSocketConnection(socket: IWebSocket, logger: Logger): MessageConnection; | ||
//# sourceMappingURL=connection.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createWebSocketConnection = void 0; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createWebSocketConnection = void 0; | ||
const vscode_jsonrpc_1 = require("vscode-jsonrpc"); | ||
@@ -9,0 +9,0 @@ const reader_1 = require("./reader"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./socket"), exports); | ||
@@ -9,0 +9,0 @@ tslib_1.__exportStar(require("./reader"), exports); |
@@ -1,4 +0,4 @@ | ||
import { Disposable } from "vscode-jsonrpc"; | ||
import { DataCallback, AbstractMessageReader, MessageReader } from "vscode-jsonrpc/lib/common/messageReader"; | ||
import { IWebSocket } from "./socket"; | ||
import { Disposable } from 'vscode-jsonrpc'; | ||
import { DataCallback, AbstractMessageReader, MessageReader } from 'vscode-jsonrpc/lib/common/messageReader'; | ||
import { IWebSocket } from './socket'; | ||
export declare class WebSocketMessageReader extends AbstractMessageReader implements MessageReader { | ||
@@ -5,0 +5,0 @@ protected readonly socket: IWebSocket; |
"use strict"; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
@@ -5,0 +5,0 @@ * ------------------------------------------------------------------------------------------ */ |
@@ -1,3 +0,3 @@ | ||
import { Disposable } from "../disposable"; | ||
import { IConnection } from "../server/connection"; | ||
import { Disposable } from '../disposable'; | ||
import { IConnection } from '../server/connection'; | ||
export interface IWebSocket extends Disposable { | ||
@@ -4,0 +4,0 @@ send(content: string): void; |
"use strict"; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=socket.js.map |
@@ -1,4 +0,4 @@ | ||
import { Message } from "vscode-jsonrpc/lib/common/messages"; | ||
import { AbstractMessageWriter, MessageWriter } from "vscode-jsonrpc/lib/common/messageWriter"; | ||
import { IWebSocket } from "./socket"; | ||
import { Message } from 'vscode-jsonrpc/lib/common/messages'; | ||
import { AbstractMessageWriter, MessageWriter } from 'vscode-jsonrpc/lib/common/messageWriter'; | ||
import { IWebSocket } from './socket'; | ||
export declare class WebSocketMessageWriter extends AbstractMessageWriter implements MessageWriter { | ||
@@ -5,0 +5,0 @@ protected readonly socket: IWebSocket; |
"use strict"; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
@@ -5,0 +5,0 @@ * ------------------------------------------------------------------------------------------ */ |
{ | ||
"name": "vscode-ws-jsonrpc", | ||
"version": "0.5.0-dev.0", | ||
"version": "1.0.0", | ||
"description": "VSCode JSON RPC over WebSocket", | ||
@@ -31,2 +31,3 @@ "author": "TypeFox GmbH (http://www.typefox.io)", | ||
"clean": "npx shx rm -fr lib tsconfig.tsbuildinfo", | ||
"lint": "eslint src --ext .ts", | ||
"compile": "tsc", | ||
@@ -33,0 +34,0 @@ "watch": "tsc -w", |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { MessageConnection, Logger } from 'vscode-jsonrpc'; | ||
import { createWebSocketConnection, IWebSocket } from './socket'; | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { ConsoleLogger } from './logger'; | ||
export function listen(options: { | ||
export function listen (options: { | ||
webSocket: WebSocket; | ||
@@ -23,14 +29,20 @@ logger?: Logger; | ||
export function toSocket(webSocket: WebSocket): IWebSocket { | ||
export function toSocket (webSocket: WebSocket): IWebSocket { | ||
return { | ||
send: content => webSocket.send(content), | ||
onMessage: cb => webSocket.onmessage = event => cb(event.data), | ||
onError: cb => webSocket.onerror = event => { | ||
if ('message' in event) { | ||
cb((event as any).message) | ||
} | ||
onMessage: cb => { | ||
webSocket.onmessage = event => cb(event.data); | ||
}, | ||
onClose: cb => webSocket.onclose = event => cb(event.code, event.reason), | ||
onError: cb => { | ||
webSocket.onerror = event => { | ||
if ('message' in event) { | ||
cb((event as any).message); | ||
} | ||
}; | ||
}, | ||
onClose: cb => { | ||
webSocket.onclose = event => cb(event.code, event.reason); | ||
}, | ||
dispose: () => webSocket.close() | ||
} | ||
} | ||
}; | ||
} |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { Disposable } from 'vscode-jsonrpc/lib/common/disposable'; | ||
export { | ||
Disposable | ||
} | ||
import { Disposable } from 'vscode-jsonrpc'; | ||
@@ -14,3 +11,3 @@ export class DisposableCollection implements Disposable { | ||
dispose(): void { | ||
dispose (): void { | ||
while (this.disposables.length !== 0) { | ||
@@ -21,7 +18,7 @@ this.disposables.pop()!.dispose(); | ||
push(disposable: Disposable): Disposable { | ||
push (disposable: Disposable): Disposable { | ||
const disposables = this.disposables; | ||
disposables.push(disposable); | ||
return { | ||
dispose(): void { | ||
dispose (): void { | ||
const index = disposables.indexOf(disposable); | ||
@@ -32,5 +29,6 @@ if (index !== -1) { | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
export { Disposable }; |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
export * from 'vscode-jsonrpc'; | ||
@@ -10,2 +11,2 @@ export * from 'vscode-jsonrpc/lib/common/messages'; | ||
export * from './logger'; | ||
export * from './connection'; | ||
export * from './connection'; |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { Logger } from "vscode-jsonrpc"; | ||
import { Logger } from 'vscode-jsonrpc'; | ||
export class ConsoleLogger implements Logger { | ||
public error(message: string): void { | ||
public error (message: string): void { | ||
console.error(message); | ||
} | ||
public warn(message: string): void { | ||
public warn (message: string): void { | ||
console.warn(message); | ||
} | ||
public info(message: string): void { | ||
public info (message: string): void { | ||
console.info(message); | ||
} | ||
public log(message: string): void { | ||
public log (message: string): void { | ||
console.log(message); | ||
} | ||
public debug(message: string): void { | ||
public debug (message: string): void { | ||
console.debug(message); | ||
} | ||
} |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { MessageReader, MessageWriter, Disposable, Message } from 'vscode-jsonrpc'; | ||
import { DisposableCollection } from "../disposable"; | ||
import { DisposableCollection } from '../disposable'; | ||
export function forward(clientConnection: IConnection, serverConnection: IConnection, map?: (message: Message) => Message): void { | ||
clientConnection.forward(serverConnection, map); | ||
serverConnection.forward(clientConnection, map); | ||
clientConnection.onClose(() => serverConnection.dispose()); | ||
serverConnection.onClose(() => clientConnection.dispose()); | ||
} | ||
export interface IConnection extends Disposable { | ||
@@ -22,4 +16,11 @@ readonly reader: MessageReader; | ||
export function createConnection<T extends {}>(reader: MessageReader, writer: MessageWriter, onDispose: () => void, | ||
extensions: T = {} as T): IConnection & T { | ||
export function forward (clientConnection: IConnection, serverConnection: IConnection, map?: (message: Message) => Message): void { | ||
clientConnection.forward(serverConnection, map); | ||
serverConnection.forward(clientConnection, map); | ||
clientConnection.onClose(() => serverConnection.dispose()); | ||
serverConnection.onClose(() => clientConnection.dispose()); | ||
} | ||
export function createConnection<T extends {}> (reader: MessageReader, writer: MessageWriter, onDispose: () => void, | ||
extensions: T = {} as T): IConnection & T { | ||
const disposeOnClose = new DisposableCollection(); | ||
@@ -29,10 +30,11 @@ reader.onClose(() => disposeOnClose.dispose()); | ||
return { | ||
reader, writer, | ||
forward(to: IConnection, map: (message: Message) => Message = (message) => message): void { | ||
reader, | ||
writer, | ||
forward (to: IConnection, map: (message: Message) => Message = (message) => message): void { | ||
reader.listen(input => { | ||
const output = map(input); | ||
to.writer.write(output) | ||
to.writer.write(output); | ||
}); | ||
}, | ||
onClose(callback: () => void): Disposable { | ||
onClose (callback: () => void): Disposable { | ||
return disposeOnClose.push(Disposable.create(callback)); | ||
@@ -39,0 +41,0 @@ }, |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
export * from './connection'; | ||
export * from './launch'; | ||
export * from './launch'; |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
@@ -9,7 +9,7 @@ * ------------------------------------------------------------------------------------------ */ | ||
import * as cp from 'child_process'; | ||
import { StreamMessageReader, StreamMessageWriter, SocketMessageReader, SocketMessageWriter } from "vscode-jsonrpc/node"; | ||
import { IConnection, createConnection } from "./connection"; | ||
import { StreamMessageReader, StreamMessageWriter, SocketMessageReader, SocketMessageWriter } from 'vscode-jsonrpc/node'; | ||
import { IConnection, createConnection } from './connection'; | ||
import { IWebSocket, WebSocketMessageReader, WebSocketMessageWriter, IWebSocketConnection } from '../socket'; | ||
export function createServerProcess(serverName: string, command: string, args?: string[], options?: cp.SpawnOptions): IConnection | undefined { | ||
export function createServerProcess (serverName: string, command: string, args?: string[], options?: cp.SpawnOptions): IConnection | undefined { | ||
const serverProcess = cp.spawn(command, args || [], options || {}); | ||
@@ -27,3 +27,3 @@ serverProcess.on('error', error => | ||
export function createWebSocketConnection(socket: IWebSocket): IWebSocketConnection { | ||
export function createWebSocketConnection (socket: IWebSocket): IWebSocketConnection { | ||
const reader = new WebSocketMessageReader(socket); | ||
@@ -34,7 +34,7 @@ const writer = new WebSocketMessageWriter(socket); | ||
export function createProcessSocketConnection(process: cp.ChildProcess, outSocket: net.Socket, inSocket: net.Socket = outSocket): IConnection { | ||
export function createProcessSocketConnection (process: cp.ChildProcess, outSocket: net.Socket, inSocket: net.Socket = outSocket): IConnection { | ||
return createSocketConnection(outSocket, inSocket, () => process.kill()); | ||
} | ||
export function createSocketConnection(outSocket: net.Socket, inSocket: net.Socket, onDispose: () => void): IConnection { | ||
export function createSocketConnection (outSocket: net.Socket, inSocket: net.Socket, onDispose: () => void): IConnection { | ||
const reader = new SocketMessageReader(outSocket); | ||
@@ -45,3 +45,3 @@ const writer = new SocketMessageWriter(inSocket); | ||
export function createProcessStreamConnection(process: cp.ChildProcess): IConnection | undefined { | ||
export function createProcessStreamConnection (process: cp.ChildProcess): IConnection | undefined { | ||
if (process.stdout !== null && process.stdin !== null) { | ||
@@ -54,3 +54,3 @@ return createStreamConnection(process.stdout, process.stdin, () => process.kill()); | ||
export function createStreamConnection(outStream: stream.Readable, inStream: stream.Writable, onDispose: () => void): IConnection { | ||
export function createStreamConnection (outStream: stream.Readable, inStream: stream.Writable, onDispose: () => void): IConnection { | ||
const reader = new StreamMessageReader(outStream); | ||
@@ -60,2 +60,1 @@ const writer = new StreamMessageWriter(inStream); | ||
} | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { MessageConnection, createMessageConnection, Logger } from "vscode-jsonrpc"; | ||
import { IWebSocket } from "./socket"; | ||
import { WebSocketMessageReader } from "./reader"; | ||
import { WebSocketMessageWriter } from "./writer"; | ||
export function createWebSocketConnection(socket: IWebSocket, logger: Logger): MessageConnection { | ||
import { MessageConnection, createMessageConnection, Logger } from 'vscode-jsonrpc'; | ||
import { IWebSocket } from './socket'; | ||
import { WebSocketMessageReader } from './reader'; | ||
import { WebSocketMessageWriter } from './writer'; | ||
export function createWebSocketConnection (socket: IWebSocket, logger: Logger): MessageConnection { | ||
const messageReader = new WebSocketMessageReader(socket); | ||
@@ -12,0 +13,0 @@ const messageWriter = new WebSocketMessageWriter(socket); |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
export * from './socket'; | ||
@@ -6,0 +7,0 @@ export * from './reader'; |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { Disposable } from "vscode-jsonrpc"; | ||
import { DataCallback, AbstractMessageReader, MessageReader } from "vscode-jsonrpc/lib/common/messageReader"; | ||
import { IWebSocket } from "./socket"; | ||
import { Disposable } from 'vscode-jsonrpc'; | ||
import { DataCallback, AbstractMessageReader, MessageReader } from 'vscode-jsonrpc/lib/common/messageReader'; | ||
import { IWebSocket } from './socket'; | ||
export class WebSocketMessageReader extends AbstractMessageReader implements MessageReader { | ||
protected state: 'initial' | 'listening' | 'closed' = 'initial'; | ||
@@ -16,3 +15,3 @@ protected callback: DataCallback | undefined; | ||
constructor(protected readonly socket: IWebSocket) { | ||
constructor (protected readonly socket: IWebSocket) { | ||
super(); | ||
@@ -37,3 +36,3 @@ this.socket.onMessage(message => | ||
listen(callback: DataCallback): Disposable { | ||
listen (callback: DataCallback): Disposable { | ||
if (this.state === 'initial') { | ||
@@ -56,9 +55,9 @@ this.state = 'listening'; | ||
if (this.callback === callback) { | ||
this.callback = undefined | ||
this.callback = undefined; | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
protected readMessage(message: any): void { | ||
protected readMessage (message: any): void { | ||
if (this.state === 'initial') { | ||
@@ -72,3 +71,3 @@ this.events.splice(0, 0, { message }); | ||
protected fireError(error: any): void { | ||
protected fireError (error: any): void { | ||
if (this.state === 'initial') { | ||
@@ -81,3 +80,3 @@ this.events.splice(0, 0, { error }); | ||
protected fireClose(): void { | ||
protected fireClose (): void { | ||
if (this.state === 'initial') { | ||
@@ -90,3 +89,2 @@ this.events.splice(0, 0, {}); | ||
} | ||
} |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { Disposable } from "../disposable"; | ||
import { IConnection } from "../server/connection"; | ||
import { Disposable } from '../disposable'; | ||
import { IConnection } from '../server/connection'; | ||
export interface IWebSocket extends Disposable { | ||
@@ -9,0 +10,0 @@ send(content: string): void; |
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2018 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { Message } from "vscode-jsonrpc/lib/common/messages"; | ||
import { AbstractMessageWriter, MessageWriter } from "vscode-jsonrpc/lib/common/messageWriter"; | ||
import { IWebSocket } from "./socket"; | ||
import { Message } from 'vscode-jsonrpc/lib/common/messages'; | ||
import { AbstractMessageWriter, MessageWriter } from 'vscode-jsonrpc/lib/common/messageWriter'; | ||
import { IWebSocket } from './socket'; | ||
export class WebSocketMessageWriter extends AbstractMessageWriter implements MessageWriter { | ||
protected errorCount = 0; | ||
constructor(protected readonly socket: IWebSocket) { | ||
constructor (protected readonly socket: IWebSocket) { | ||
super(); | ||
} | ||
end(): void { | ||
end (): void { | ||
} | ||
async write(msg: Message): Promise<void> { | ||
async write (msg: Message): Promise<void> { | ||
try { | ||
@@ -30,3 +29,2 @@ const content = JSON.stringify(msg); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
57141
777
1
1