# @opensumi/vscode-jsonrpc

> A json rpc implementation over streams

Latest version **8.2.1** (published 2025-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @opensumi/vscode-jsonrpc
pnpm add @opensumi/vscode-jsonrpc
yarn add @opensumi/vscode-jsonrpc
bun add @opensumi/vscode-jsonrpc
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.2.1 |
| Published | 2025-02-28 |
| First published | 2021-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.0.0 |
| Dependencies | 0 |
| Unpacked size | 407.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Microsoft Corporation |
| Maintainers | ensorrow, jinboker, ricbet, hacke2, lengthmin, erha19, sakuraash, yantze |

## Links

- npm: https://www.npmjs.com/package/@opensumi/vscode-jsonrpc
- Repository: https://github.com/opensumi/vscode-jsonrpc
- Homepage: https://github.com/opensumi/vscode-jsonrpc#readme
- Issues: https://github.com/opensumi/vscode-jsonrpc/issues
- npm.io page: https://npm.io/package/@opensumi/vscode-jsonrpc

## Recent versions

- 8.2.1 (latest) — 2025-02-28
- 8.0.0-next.9 — 2023-03-16
- 8.0.0-next.7 — 2022-12-23
- 8.0.0-beta.7 — 2022-12-23
- 8.0.0-next.6 — 2022-09-23
- 8.0.0-next.5 — 2022-09-20
- 8.0.0-next.4 — 2022-09-15
- 8.0.0-next.3 — 2022-04-11
- 8.0.0-next.2 — 2022-04-01
- 8.0.0-next.1 — 2022-04-01
- 6.1.1-beta.5 — 2022-01-27
- 6.1.1-beta.4 — 2022-01-25
- 6.1.1-beta.3 — 2021-11-24

## README

## Changelogs

- Optimized compatibility of the code for a browser environment by adding `global` before the `setImmediate` and `clearImmediate` methods (8.0.0-next.9).
- Skip exceptions caused by non-standard Header content.
- Deprecate `WebSocketMessageWriter` and `WebSocketMessageReader` exported from `browser/main`, to be maintained by opensumi.
- Because of reliance on `TextEncoder` and `TextDecoder`, browser-related interfaces are no longer exported in `src/index`.
- Fix the issue of the stream possibly being destroyed when writing

Fork from `vscode-jsonrpc@6.1.0`.

## VSCode JSON RPC 

[![NPM Version](https://img.shields.io/npm/v/vscode-jsonrpc.svg)](https://npmjs.org/package/vscode-jsonrpc)
[![NPM Downloads](https://img.shields.io/npm/dm/vscode-jsonrpc.svg)](https://npmjs.org/package/vscode-jsonrpc)
[![Build Status](https://travis-ci.org/Microsoft/vscode-languageserver-node.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-languageserver-node)

This npm module implements the base messaging protocol spoken between a VSCode language server and a VSCode language client.

The npm module can also be used standalone to establish a [JSON-RPC](http://www.jsonrpc.org/) channel between
a client and a server. Below an example how to setup a JSON-RPC connection. First the client side.

```ts
import * as cp from 'child_process';
import * as rpc from 'vscode-jsonrpc';

let childProcess = cp.spawn(...);

// Use stdin and stdout for communication:
let connection = rpc.createMessageConnection(
	new rpc.StreamMessageReader(childProcess.stdout),
	new rpc.StreamMessageWriter(childProcess.stdin));

let notification = new rpc.NotificationType<string, void>('testNotification');

connection.listen();

connection.sendNotification(notification, 'Hello World');
```

The server side looks very symmetrical:

```ts
import * as rpc from 'vscode-jsonrpc';


let connection = rpc.createMessageConnection(
	new rpc.StreamMessageReader(process.stdin),
	new rpc.StreamMessageWriter(process.stdout));

let notification = new rpc.NotificationType<string, void>('testNotification');
connection.onNotification(notification, (param: string) => {
	console.log(param); // This prints Hello World
});

connection.listen();
```

# History

### 4.0.0

- move JS target to ES6.

### 3.0.0:

- converted the NPM module to use TypeScript 2.0.3.
- added strict null support.
- support for passing more than one parameter to a request or notification.
- Breaking changes:
  - due to the use of TypeScript 2.0.3 and differences in d.ts generation users of the new version need to move to
    TypeScript 2.0.3 as well.

## License
[MIT](https://github.com/Microsoft/vscode-languageserver-node/blob/master/License.txt)

---
_Source: https://npm.io/package/@opensumi/vscode-jsonrpc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
