@typerighter/rpc-server 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +17 -5
  2. package/install.js +0 -4
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1,17 +1,29 @@
1
1
  import { existsSync } from "node:fs";
2
- import { spawn } from "node:child_process";
2
+ import { execFileSync, spawn } from "node:child_process";
3
3
  import { EventEmitter } from "node:events";
4
4
  import { binPath } from "./platform.js";
5
5
 
6
- const bin = binPath();
6
+ function resolveBin() {
7
+ // Prefer user's system binary
8
+ try {
9
+ const system = execFileSync("which", ["typedown-rpc"], { encoding: "utf-8" }).trim();
10
+ if (system) return system;
11
+ } catch {
12
+ // ignore
13
+ }
14
+
15
+ // Fall back to downloaded binary
16
+ const local = binPath();
17
+ if (existsSync(local)) return local;
7
18
 
8
- if (!existsSync(bin)) {
9
19
  throw new Error(
10
- `typedown-rpc binary not found at ${bin}. Run "pnpm install" to download it, ` +
11
- `or build manually with "cargo build --release -p typedown-server".`,
20
+ `typedown-rpc binary not found. Run "pnpm install" to download it, ` +
21
+ `install via Nix, or build manually with "cargo build --release -p typedown-server".`,
12
22
  );
13
23
  }
14
24
 
25
+ const bin = resolveBin();
26
+
15
27
  const DEFAULT_PORT = 4747;
16
28
 
17
29
  export class RpcServer extends EventEmitter {
package/install.js CHANGED
@@ -13,10 +13,6 @@ import {
13
13
 
14
14
  const bin = binPath();
15
15
 
16
- if (existsSync(bin)) {
17
- process.exit(0);
18
- }
19
-
20
16
  // In dev mode, we compile and `bin` will just automatically point to the artifact
21
17
  if (dev()) {
22
18
  console.log("[rpc-server] Development mode: building typedown-rpc with cargo");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@typerighter/rpc-server",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "description": "Typedown RPC server binary.",
6
6
  "repository": {
7
7
  "type": "git",