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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@berkide/js-client

v0.1.0

Published

JavaScript/TypeScript client for BerkIDE headless editor server

Readme

@berkide/js-client

No impositions.

JavaScript/TypeScript client for berkide-core headless editor server.

Zero dependencies. Works in browser and Node.js 18+.

Install

npm install @berkide/js-client

Quick Start

import { BerkideClient } from "@berkide/js-client";

const client = new BerkideClient({
  url: "http://127.0.0.1:1881",
  token: "my-secret-token",       // optional — required if server auth is enabled
});

// Health check
const alive = await client.server.ping(); // true

// Get editor state
const state = await client.state.get();
console.log(state.data.cursor);  // { line: 0, col: 0 }
console.log(state.data.mode);    // "normal"

// Execute a command (267 commands available)
await client.command.exec("file.save");
await client.command.exec("cursor.goto", { line: 10, col: 0 });
await client.command.exec("edit.undo");

API

HTTP — Request/Response

All HTTP methods return ApiResponse<T>:

interface ApiResponse<T> {
  ok: boolean;
  data: T;
  meta: Record<string, unknown> | null;
  error: string | null;
  message: string | null;
}

client.server

| Method | Description | |--------|-------------| | ping() | Health check — returns true if alive | | info() | Server info (version, ports, TLS, auth) | | endpoints() | List all registered HTTP endpoints |

client.command

| Method | Description | |--------|-------------| | exec(cmd, args?) | Execute any command (e.g. "file.save", "cursor.up") | | list() | List all 267 registered commands |

client.buffer

| Method | Description | |--------|-------------| | get() | Active buffer content + metadata | | line(n) | Get single line by number | | edit(req) | Edit buffer (insert, delete, insertLine, deleteLine) | | open(path) | Open a file | | save() | Save active buffer | | close() | Close active buffer |

client.buffers

| Method | Description | |--------|-------------| | list() | List all open buffers | | switchTo(index) | Switch to a buffer by index |

client.cursor

| Method | Description | |--------|-------------| | position() | Current cursor position (line, col) |

client.input

| Method | Description | |--------|-------------| | key(key) | Simulate key press (e.g. "Enter", "Ctrl+S") | | char(text) | Insert raw text at cursor |

client.state

| Method | Description | |--------|-------------| | get() | Full editor state (cursor, buffer, mode, tabs) |

client.help

| Method | Description | |--------|-------------| | list() | List all help topics | | search(query) | Search help by keyword | | topic(id) | Get full help article |

WebSocket — Real-Time Events

// Connect
client.connect();

// Listen for events
client.on("bufferChanged", (e) => {
  console.log("File changed:", e.filePath);
  console.log("Cursor:", e.cursor.line, e.cursor.col);
});

client.on("cursorMoved", (e) => {
  console.log("Cursor:", e.line, e.col);
});

client.on("tabChanged", (e) => {
  console.log("Active tab:", e.activeIndex);
});

client.on("fullSync", (state) => {
  console.log("Full state received:", state.mode);
});

// Connection lifecycle
client.on("connected", () => console.log("WS connected"));
client.on("disconnected", () => console.log("WS disconnected"));
client.on("error", (err) => console.error(err));

// Request full state sync
client.requestSync();

// Disconnect
client.disconnect();

Events

| Event | Payload | Description | |-------|---------|-------------| | fullSync | EditorState | Full state (on connect + manual sync) | | bufferChanged | { filePath, cursor } | Buffer content changed | | cursorMoved | { line, col } | Cursor position changed | | tabChanged | { activeIndex } | Active tab switched | | connected | void | WebSocket connected | | disconnected | void | WebSocket disconnected | | error | Error | WebSocket error |

Configuration

const client = new BerkideClient({
  url: "http://127.0.0.1:1881",   // HTTP base URL (required)
  wsUrl: "ws://127.0.0.1:1882",   // WebSocket URL (optional, derived from url)
  token: "my-token",               // Bearer token (optional)
  reconnect: true,                  // Auto-reconnect (default: true)
  reconnectInterval: 2000,          // Reconnect delay ms (default: 2000)
  maxReconnectAttempts: Infinity,   // Max attempts (default: Infinity)
});

Examples

Open a file and read its content

await client.buffer.open("/path/to/file.ts");
const buf = await client.buffer.get();
console.log(buf.data.lines.join("\n"));

Insert text at a specific position

await client.buffer.edit({
  action: "insert",
  text: "Hello, World!",
  line: 0,
  col: 0,
});

Simulate vim-style navigation

await client.input.key("j");     // move down
await client.input.key("j");     // move down
await client.input.key("l");     // move right
await client.input.key("i");     // enter insert mode
await client.input.char("x");    // type "x"
await client.input.key("Escape"); // back to normal mode

Build a live editor UI

client.connect();

// Initial state
const state = await client.state.get();
renderEditor(state.data);

// Live updates
client.on("bufferChanged", () => {
  client.state.get().then((s) => renderEditor(s.data));
});

client.on("cursorMoved", (e) => {
  updateCursorUI(e.line, e.col);
});

Build

npm install
npm run build     # ESM + CJS dual output → dist/

Related Projects

| Project | Description | |---------|-------------| | berkide-core | C++ headless editor engine | | berkide-plugins | Official plugin collection | | berkide-tui | Terminal UI client | | berkidectl | CLI management tool |

License

MIT