npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@codingame/languageserver-mutualized

v2.1.2

Published

A tool to plug multiple clients over a single language server implementation

Downloads

210

Readme

@codingame/languageserver-mutualized · monthly downloads npm version PRs welcome

NPM module to plug multiple language clients on a single language server.

What you need to know:

  • Only initialization request of the first client will be used, so it's a good idea for all client to have the exact same capabilities and initialize params
  • Some features won't work (configuration requests, execute command server request...)

What it allows you to do:

  • Plug clients on different independant files
  • Plug clients on the same files, then you need to synchronize the content of the editor between clients

How it works:

  • If a file is open by at least one client, it's open on the server
  • Every time a client change the content of a file, we stack their changes and flush it after 500ms of inactivity
  • As soon a there is a request from this client, we flush their changes and then forward the request to the server
  • Every time the server sends a diagnostics notification, it's forwarded to the clients having this file open

Installation

npm install @codingame/languageserver-mutualized 

Usage

2 functions are exported:

  • createLanguageClient which create a LanguageClient from a language server connection
  • bindLanguageClient which bind a client connection on an existing LanguageClient and return a promise resolved when the client leaves or the server is shutdown

Examples

There is an example that demonstrate how the languageserver-mutualized can be used. It uses monaco-editor and monaco-languageclient.

The important file is json-server-launcher.ts

To run it:

npm ci
npm start

It will open a page in your browser with 2 editors to illustrate the 2 use-cases:

  • The first editor is synchronized between all clients and use the same file uri
  • The second editor use a random file uri and is not synchronized

Advanced users

Cache

After a change, most clients send some requests (SemanticTokens, CodeLens...). If a file is used by multiple clients, every client will send the request and the server will need to answer it multiple times.

To prevent this, a cache can be provided when creating the LanguageClient

Configuration

The configuration coming from the client cannot be used. However, some language servers requires some configuration to work.

The configuration can be provided using the getConfiguration LanguageClient option.

It will be called when:

  • The language server sends a workspace/configuration request (the scope will be ignored)
  • When providing the synchronizeConfigurationSections option (old deprecated way but still used by many language servers)