Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ridit/relay

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ridit/relay - npm Package Compare versions

Comparing version
0.1.2
to
0.1.4
+2
-2
package.json
{
"name": "@ridit/relay",
"version": "0.1.2",
"version": "0.1.4",
"description": "One port. Any language. Monaco-ready LSP bridge.",

@@ -22,3 +22,3 @@ "author": "Ridit Jangra <riditjangra09@gmail.com> (https://ridit.space)",

"typecheck": "tsc --noEmit",
"prepublishOnly": "bun run typecheck",
"prepublishOnly": "bun run typecheck && bun run build",
"release": "npm publish --access public"

@@ -25,0 +25,0 @@ },

@@ -45,2 +45,4 @@ # @ridit/relay

The simplest case — command known at startup:
```typescript

@@ -52,11 +54,11 @@ import { Server } from "@ridit/relay";

server.register({
languageId: "python",
command: "pyright-langserver",
args: ["--stdio"],
languageId: "python",
});
server.register({
languageId: "typescript",
command: "typescript-language-server",
args: ["--stdio"],
languageId: "typescript",
});

@@ -67,2 +69,25 @@

#### Runtime resolution
Use `resolve` when the command must be discovered at runtime — for example, finding a Python interpreter before locating pylsp. `resolve` is called per connection, so if the language server isn't available the connection fails cleanly without crashing the process.
```typescript
server.register({
languageId: "python",
resolve: () => {
const python = findPythonInterpreter(); // your own logic
if (!python) return null; // closes the WS with a clean error
const pylsp = findPylsp(python);
if (!pylsp) return null;
return { command: pylsp.command, args: pylsp.args };
},
});
```
If `resolve` returns `null`, the WebSocket is closed with code `1011` and a descriptive message — no process is spawned.
`command` and `resolve` are mutually exclusive. `command` takes priority if both are provided.
### Client (Browser)

@@ -119,2 +144,3 @@

server.start(port?: number): Promise<void> // default: 9721
server.stop(): Promise<void>
```

@@ -126,6 +152,11 @@

{
command: string; // binary name or full path
languageId: string; // e.g. "python", "typescript"
// Option A — static: command resolved at startup
command?: string; // binary name or full path
args?: string[]; // e.g. ["--stdio"]
cwd?: string; // working directory override
env?: Record<string, string>;
// Option B — dynamic: command resolved per connection
resolve?: () => { command: string; args?: string[] } | null;
}

@@ -161,4 +192,4 @@ ```

server.register({
languageId: "python",
command: "pyright-langserver",
languageId: "python",
args: ["--stdio"],

@@ -165,0 +196,0 @@ });

@@ -325,3 +325,3 @@ import type * as Monaco from "monaco-editor";

def: LspClientDefinition,
conn: LspConnection,
_: LspConnection,
model: Monaco.editor.ITextModel,

@@ -328,0 +328,0 @@ ): void {