Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vscode-ws-jsonrpc

Package Overview
Dependencies
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-ws-jsonrpc - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Changelog

## [3.2.0] - 2024-02-19
- Implement dispose method on WebSocketMessageReader [#602](https://github.com/TypeFox/monaco-languageclient/pull/602)
- Adjusted code to updated linting configuration
## [3.1.0] - 2023-11-02

@@ -7,0 +12,0 @@

7

lib/connection.js
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -23,4 +23,5 @@ * ------------------------------------------------------------------------------------------ */

onError: cb => {
webSocket.onerror = event => {
if ('message' in event) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
webSocket.onerror = (event) => {
if (Object.hasOwn(event, 'message')) {
cb(event.message);

@@ -27,0 +28,0 @@ }

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

@@ -9,3 +9,3 @@ import { MessageReader, MessageWriter, Disposable, Message } from 'vscode-jsonrpc';

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;
export declare function createConnection<T extends object>(reader: MessageReader, writer: MessageWriter, onDispose: () => void, extensions?: T): IConnection & T;
//# sourceMappingURL=connection.d.ts.map
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

@@ -8,8 +8,9 @@ import { Disposable } from 'vscode-jsonrpc';

protected callback: DataCallback | undefined;
protected readonly events: {
protected readonly events: Array<{
message?: any;
error?: any;
}[];
}>;
constructor(socket: IWebSocket);
listen(callback: DataCallback): Disposable;
dispose(): void;
protected readMessage(message: any): void;

@@ -16,0 +17,0 @@ protected fireError(error: any): void;

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -10,2 +10,3 @@ * ------------------------------------------------------------------------------------------ */

callback;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
events = [];

@@ -48,2 +49,3 @@ constructor(socket) {

if (this.callback === callback) {
this.state = 'initial';
this.callback = undefined;

@@ -54,2 +56,9 @@ }

}
dispose() {
super.dispose();
this.state = 'initial';
this.callback = undefined;
this.events.splice(0, this.events.length);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readMessage(message) {

@@ -67,2 +76,3 @@ if (this.state === 'initial') {

name: '' + 400,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
message: `Error during message parsing, reason = ${typeof err === 'object' ? err.message : 'unknown'}`

@@ -74,2 +84,3 @@ };

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fireError(error) {

@@ -76,0 +87,0 @@ if (this.state === 'initial') {

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

@@ -5,4 +5,4 @@ import { Message } from 'vscode-jsonrpc/lib/common/messages.js';

export declare class WebSocketMessageWriter extends AbstractMessageWriter implements MessageWriter {
protected errorCount: number;
protected readonly socket: IWebSocket;
protected errorCount: number;
constructor(socket: IWebSocket);

@@ -9,0 +9,0 @@ end(): void;

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -7,4 +7,4 @@ * ------------------------------------------------------------------------------------------ */

export class WebSocketMessageWriter extends AbstractMessageWriter {
errorCount = 0;
socket;
errorCount = 0;
constructor(socket) {

@@ -11,0 +11,0 @@ super();

@@ -1,2 +0,2 @@

Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io)
Copyright (c) 2018-2024 TypeFox GmbH (http://www.typefox.io)

@@ -3,0 +3,0 @@ All rights reserved.

{
"name": "vscode-ws-jsonrpc",
"version": "3.1.0",
"version": "3.2.0",
"description": "VSCode JSON RPC over WebSocket",

@@ -54,4 +54,4 @@ "author": {

"volta": {
"node": "18.18.2",
"npm": "9.9.0"
"node": "20.11.0",
"npm": "10.2.4"
},

@@ -74,2 +74,2 @@ "files": [

}
}
}
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -32,5 +32,6 @@ * ------------------------------------------------------------------------------------------ */

onError: cb => {
webSocket.onerror = event => {
if ('message' in event) {
cb((event as any).message);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
webSocket.onerror = (event: any) => {
if (Object.hasOwn(event, 'message')) {
cb(event.message);
}

@@ -37,0 +38,0 @@ };

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -23,3 +23,3 @@ * ------------------------------------------------------------------------------------------ */

export function createConnection<T extends {}>(reader: MessageReader, writer: MessageWriter, onDispose: () => void,
export function createConnection<T extends object>(reader: MessageReader, writer: MessageWriter, onDispose: () => void,
extensions: T = {} as T): IConnection & T {

@@ -26,0 +26,0 @@ const disposeOnClose = new DisposableCollection();

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -4,0 +4,0 @@ * ------------------------------------------------------------------------------------------ */

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -11,8 +11,11 @@ * ------------------------------------------------------------------------------------------ */

export class WebSocketMessageReader extends AbstractMessageReader implements MessageReader {
protected readonly socket: IWebSocket;
protected state: 'initial' | 'listening' | 'closed' = 'initial';
protected callback: DataCallback | undefined;
protected readonly events: { message?: any, error?: any }[] = [];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected readonly events: Array<{ message?: any, error?: any }> = [];
constructor(protected readonly socket: IWebSocket) {
constructor(socket: IWebSocket) {
super();
this.socket = socket;
this.socket.onMessage(message =>

@@ -54,2 +57,3 @@ this.readMessage(message)

if (this.callback === callback) {
this.state = 'initial';
this.callback = undefined;

@@ -61,2 +65,10 @@ }

override dispose() {
super.dispose();
this.state = 'initial';
this.callback = undefined;
this.events.splice(0, this.events.length);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected readMessage(message: any): void {

@@ -72,2 +84,3 @@ if (this.state === 'initial') {

name: '' + 400,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
message: `Error during message parsing, reason = ${typeof err === 'object' ? (err as any).message : 'unknown'}`

@@ -80,2 +93,3 @@ };

// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected override fireError(error: any): void {

@@ -82,0 +96,0 @@ if (this.state === 'initial') {

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -11,3 +11,5 @@ * ------------------------------------------------------------------------------------------ */

send(content: string): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onMessage(cb: (data: any) => void): void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onError(cb: (reason: any) => void): void;

@@ -14,0 +16,0 @@ onClose(cb: (code: number, reason: string) => void): void;

/* --------------------------------------------------------------------------------------------
* Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Copyright (c) 2024 TypeFox GmbH (http://www.typefox.io). All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.

@@ -12,5 +12,7 @@ * ------------------------------------------------------------------------------------------ */

protected errorCount = 0;
protected readonly socket: IWebSocket;
constructor(protected readonly socket: IWebSocket) {
constructor(socket: IWebSocket) {
super();
this.socket = socket;
}

@@ -17,0 +19,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc