JSPM

vscode-jsonrpc

2.3.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4129611
  • Score
    100M100P100Q207058F
  • License MIT

A json rpc implementation over streams

Package Exports

  • vscode-jsonrpc
  • vscode-jsonrpc/lib/events
  • vscode-jsonrpc/lib/main
  • vscode-jsonrpc/lib/messageReader
  • vscode-jsonrpc/lib/messageWriter
  • vscode-jsonrpc/lib/messages

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vscode-jsonrpc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

VSCode JSON RPC

NPM Version NPM Downloads Build Status

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 channel between a client and a server. Below an example how to setup a JSON-RPC connection. First the client side.

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.createClientMessageConnection(
    new rpc.StreamMessageReader(childProcess.stdout),
    new rpc.StreamMessageWriter(childProcess.stdin));

let notification: rpc.NotificationType<string> = { method: 'testNotification' };

connection.listen();

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

The server side looks very symmetrical:

import * as rpc from 'vscode-jsonrpc';


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

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

connection.listen();