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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cable-client

v0.1.1

Published

client api for building chat clients ontop of the cable protocol

Downloads

5

Readme

cable-client

Status: alpha (api surface still in flux)

cable-client is a client library for implementing chat clients running the cable protocol

New chat clients may be implemented using solely this library, without having to interface directly with the lower level cable-core library.

Responsibilities:

  • Provides networking primitives (currently: tcp, hyperswarm (experimental), lan transport (experimental))
  • Provides a clean api for implementing a chat client, including causal message ordering using cable's links concept
  • Internally manages all messages needed for synchronizing over cable

Non-responsibilities:

  • Does not handle serializing & deserializing cable's binary buffers (cable.js does that)
  • Does not provide lower-level methods for cable message/post creation nor interacting with database indexes (cable-core does that)

Some of its features:

  • Consolidates logic common to all chat clients, like retrieving and ordering a range of posts for a particular channel
  • Leaving and joining of channels, setting topics
  • Deletion of one's own posts
  • Virtual messages, such as status messages or rendering usage instructions for different commands

Usage

See cabal@cable for an example client implementation.

// shim.js is an adaptor between the new cable-client (which has slight changes) and the old cabal-client api
// to facilitate an interim transition period for cabal clients as they update to the cable wire protocol
var Client = require('cable-client/shim.js').Client

const client = new Client({
  config: {
  config: {
    keypair,        // the keypair to use
    dbdir: "/tmp/cabals",
    temp: true,
    serve: true,    // set to true if serving / listening for connections over tcp
    disableDHT: true,
    disableTCP: false,
    disableLAN: true,
    ip: "",         // only needed when connecting to a serving tcp instance; set ip or domain name
    dhtPort: null,  // default port is 13331
    lanPort: null,  // default lan port is 13332
    tcpPort: null   // default tcp port is 13333
  },
  }
})

client.createCabal()
  .then((cabal) => {
    // resolves when the cabal is ready, returns a CableClient instance
  })

Concepts

cable-client has two abstractions: CableClient and ChannelDetails.

CableClient is the instance that clients mostly operate on, as it encapsulates all information for a particular cabal. (joined channels, users in that channel, the topic). It also emits events.

When a change has happened, a CableClient instance will emit an update event. When a client receives this event, they should update their state & rerender.

ChannelDetails encapsulates everything channels (mentions in that channel, status messages for the channel (like having called a command eg /names, when it was last read, if it's currently being viewed, if it's joined and so on). It also has a barebones implementation for virtual channels, channels which can contain status messages that are not replicated outside the local client.

Transitioning from the old cabal-client library

Clients that have yet to transition from the old cabal-client library may start their refactor to running cable-client by opting to use the adaptor shim.js:

require('cable-client/shim.js').Client
const client = new Client({..})

The shim acts as a translation layer between the two APIs as well as a guide to what has been changed, check out the code.

Install

With npm installed, run

$ npm install cable-client

License

AGPL-3.0-or-later