open-index/open-npm huggingface dataset:
npm package: @kataribe/browser
Description: Browser implementation for kataribe - WebSocket, WebRTC, WebTransport
Latest version: 0.4.0

# @kataribe/browser

`@kataribe/browser` ships the browser-friendly runtime layers for Kataribe. It
bundles the core contract DSL together with WebSocket and WebRTC transports that
run inside modern browsers without additional polyfills.

## Highlights

- Zero-`any` TypeScript bindings with first-class ESM support
- WebSocket client helper via `createWsClient`
- WebRTC DataChannel helpers (`createWebRtcTransport`, signaling utilities)
- Re-exports of the core runtime (`defineContract`, `rpc`, `event`, ...)

## Installation

```sh
pnpm add @kataribe/browser
# or
npm install @kataribe/browser
```

## WebSocket Quick Start

```ts
import { createWsClient, defineContract, event, rpc } from "@kataribe/browser";

const contract = defineContract({
    rpcToServer: {
        greet: rpc<{ name: string }, { message: string }>(),
    },
    rpcToClient: {
        ping: rpc<void, void>(),
    },
    events: {
        metrics: event<{ latencyMs: number }>(),
    },
});

const client = await createWsClient({
    url: "wss://example.com/ws",
    contract,
    handlersForServerCalls: {
        ping: async () => {
            console.log("received ping from server");
        },
    },
});

const { message } = await client.rpc.greet({ name: "Ada" });
client.emit.metrics({ latencyMs: 12 });
```

## WebRTC Data Channels

For peer-to-peer scenarios, this package exposes helpers under `./webrtc/` for
negotiating DataChannel transports. Pair them with your signalling layer to
build low-latency RTC flows while reusing the same contract.

## Development

- Build distributable artifacts with `pnpm build`
- Run the Vitest browser test harness with `pnpm test`
- Output is written to `dist/`
npm package: @kataribe/bun
Description: Bun implementation for kataribe - WebSocket, WebRTC
Latest version: 0.4.0

# @kataribe/bun

`@kataribe/bun` delivers Kataribe transports tailored for the Bun runtime. It
complements the core package with Bun-native WebSocket adapters so you can run
typed RPC servers and clients on Bun without custom glue code.

## Highlights

- Bun WebSocket server helper `createBunWsServer`
- WebSocket client bootstrapper `createBunWsClient`
- Shared runtime exports from `@kataribe/core`
- Bundled with Bun build tooling for minimal startup cost

## Installation

```sh
bun add @kataribe/bun
# or
pnpm add @kataribe/bun
```

## Example

```ts
import { createBunWsServer, defineContract, rpc } from "@kataribe/bun";

const contract = defineContract({
    rpcToServer: {
        greet: rpc<{ name: string }, { message: string }>(),
    },
});

await createBunWsServer({
    contract,
    handlers: {
        rpcToServer: {
            async greet({ name }) {
                return { message: `Hi from Bun, ${name}!` };
            },
        },
    },
    port: 8080,
});
```

Use `createBunWsClient` (or any other Kataribe client) to connect and exchange
typed RPC calls.

## Development

- Build with `pnpm build`
- Run Bun test suites with `pnpm test` (delegates to `bun test`)
- Emitted assets live in `dist/`
npm package: @kataribe/cloudflare
Description: Cloudflare Workers implementation for kataribe - WebSocket with Durable Objects
Latest version: 0.4.0

# @kataribe/cloudflare

`@kataribe/cloudflare` brings Kataribe to Cloudflare Workers and Durable
Objects. It wraps the core runtime with adapters for Cloudflare's WebSocket
upgrade flow so you can run typed RPC APIs at the edge.

## Highlights

- `createCloudflareWsHandler` for Worker WebSocket endpoints
- Durable Object helper `KataribeDurableObject` for sticky sessions
- Ships TypeScript declarations for the Workers runtime
- Re-exports `@kataribe/core` contract and runtime utilities

## Installation

```sh
pnpm add @kataribe/cloudflare
# or
npm install @kataribe/cloudflare
```

## Worker Example

```ts
import {
    createCloudflareWsHandler,
    defineContract,
    rpc,
} from "@kataribe/cloudflare";

const contract = defineContract({
    rpcToServer: {
        greet: rpc<{ name: string }, { message: string }>(),
    },
});

const handler = createCloudflareWsHandler({
    contract,
    handlers: {
        rpcToServer: {
            async greet({ name }) {
                return { message: `Hello from Workers, ${name}!` };
            },
        },
    },
});

export default {
    fetch(request: Request) {
        return handler(request);
    },
};
```

For sticky sessions, wrap the same adapter inside `KataribeDurableObject` and
forward WebSocket upgrade requests to the Durable Object instance.

## Development

- Generate Worker typings and declarations with `pnpm build`
- Run the Vitest suite with `pnpm test`
- Configure Wrangler using the provided `wrangler.toml`
npm package: @kataribe/core
Description: Core types and utilities for kataribe - bidirectional RPC + events
Latest version: 0.4.0

# @kataribe/core

`@kataribe/core` contains the transport-agnostic runtime, contract DSL, and
utility helpers that power every Kataribe distribution. It is responsible for
building strongly typed RPC callers, emitting fire-and-forget events,
coordinating middleware, and enforcing the shared envelope protocol.

## Highlights

- Typed contract authoring via `defineContract`, `rpc`, and `event`
- Runtime helpers for clients and servers (`createClientRuntime`,
  `createServerRuntime`)
- Envelope middleware, feature negotiation, and timeout handling
- Shared utilities for ID generation, schema validation, and logging

## Installation

```sh
pnpm add @kataribe/core
# or
npm install @kataribe/core
```

## Quick Start

```ts
import { createClientRuntime, defineContract, event, rpc } from "@kataribe/core";

const contract = defineContract({
  rpcToServer: {
    greet: rpc<{ name: string }, { message: string }>(),
  },
  events: {
    metrics: event<{ latencyMs: number }>(),
  },
});

const transport = /* implement the Transport interface */;
const client = createClientRuntime(transport, contract);

const { message } = await client.rpc.greet({ name: "Ada" });
client.emit.metrics({ latencyMs: 12 });
```

## Developing

- Build bundles with `pnpm build`
- Run the Vitest suite with `pnpm test`
- Generated artifacts live in `dist/`
npm package: @kataribe/deno
Description: Deno implementation for kataribe - WebSocket, WebRTC, WebTransport
Latest version: 0.4.0

# @kataribe/deno

`@kataribe/deno` adapts Kataribe for the Deno runtime. It exports WebSocket and
WebTransport helpers that plug directly into Deno Deploy or self-hosted Deno
servers while reusing the core contract DSL.

## Highlights

- WebSocket client/server adapters (`createWsClient`, `createWsServer`)
- WebTransport helpers for bidirectional streams
- Ships as a JSR module (`jsr:@kataribe/deno`) with strict TypeScript settings
- Re-exports the entire `@kataribe/core` runtime API

## Installation

```sh
deno add jsr:@kataribe/deno
```

## Quick Start

```ts
import { createWsServer, defineContract, rpc } from "jsr:@kataribe/deno";

const contract = defineContract({
    rpcToServer: {
        greet: rpc<{ name: string }, { message: string }>(),
    },
});

const server = await createWsServer({
    contract,
    handlers: {
        rpcToServer: {
            async greet({ name }) {
                return { message: `Hello from Deno, ${name}!` };
            },
        },
    },
    port: 8081,
});
```

Pair it with `createWsClient` (or WebTransport utilities) from the same package
or any other Kataribe distribution to exchange typed envelopes.

## Development

- Format and lint with `deno task fmt` / `deno task check`
- Run transport tests via `pnpm test` or `deno task test`
- Bundle artifacts land in `dist/`
npm package: @kataribe/internal
Description: `@kataribe/internal` houses non-public helpers shared across the Kataribe monorepo. The package is marked private and is used to support tests, examples, and other development tooling.
Latest version: 0.4.0

# @kataribe/internal

`@kataribe/internal` houses non-public helpers shared across the Kataribe
monorepo. The package is marked private and is used to support tests, examples,
and other development tooling.

## Contents

- `MockTransport` — a lightweight in-memory `Transport` implementation for unit
  tests
- `MockWebSocket` — a WebSocket shim for exercising runtime behaviour without a
  network stack

Because the package is private, it is not published to npm or JSR. Local
consumers inside the repository can import from `@kataribe/internal` via
workspace references.
npm package: @kataribe/nodejs
Description: Node.js implementation for kataribe - WebSocket, WebRTC
Latest version: 0.4.0

# @kataribe/nodejs

`@kataribe/nodejs` bundles the Kataribe runtime together with Node.js oriented
transports. It provides WebSocket client and server helpers built on top of `ws`
and also includes WebRTC DataChannel utilities for hybrid deployments.

## Highlights

- WebSocket helpers: `createWsClient` and `createWsServer`
- WebRTC transport wiring for Node-based peers
- Re-exports `@kataribe/core` contract builders and runtime APIs
- ESM-first build with CommonJS compatibility exports

## Installation

```sh
pnpm add @kataribe/nodejs
# or
npm install @kataribe/nodejs
```

## WebSocket Server Example

```ts
import { createWsServer, defineContract, rpc } from "@kataribe/nodejs";

const contract = defineContract({
    rpcToServer: {
        greet: rpc<{ name: string }, { message: string }>(),
    },
});

const server = await createWsServer({
    contract,
    handlers: {
        rpcToServer: {
            async greet({ name }) {
                return { message: `Hello, ${name}!` };
            },
        },
    },
    wssOptions: { port: 3333 },
});

console.log("Kataribe WebSocket server listening on :3333");
```

Pair the server with `createWsClient` from the same package (or
`@kataribe/browser`) to exchange typed RPC calls and fire-and-forget events.

## Development

- Build distributable bundles with `pnpm build`
- Run the Vitest suite with `pnpm test`
- Published artifacts are emitted to `dist/`