@ridit/relay
Advanced tools
+2
-2
| { | ||
| "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 @@ }, |
+36
-5
@@ -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 { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
99389
1.15%198
18.56%0
-100%