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

@myatthirikhin/chat-core

v0.1.0

Published

Backend-agnostic chat types, the IMessagingProvider contract, and the ChatClient facade.

Readme

@myatthirikhin/chat-core

The backend-agnostic half of the chat SDK: domain types, the IMessagingProvider contract, and the ChatClient facade.

Zero dependencies. No React, no React Native, no vendor SDK. That is what lets an adapter, a React Native UI, a Node server and a plain unit test all share one vocabulary.

pnpm add @myatthirikhin/chat-core @myatthirikhin/chat-supabase

Quickstart

import { ChatClient } from '@myatthirikhin/chat-core';
import { createSupabaseChatProvider } from '@myatthirikhin/chat-supabase';

const client = new ChatClient({
  provider: createSupabaseChatProvider(supabase),
});

await client.connect({ id: userId, name: 'Ana' });

const conversation = await client.createConversation({ type: 'dm', memberIds: [peerId] });
await client.sendMessage(conversation.id, { text: 'Hello' });

const off = client.on('message.new', (message) => console.log(message.text));

API

// connection
client.connect(user)                  client.disconnect()
client.user                           client.connectionState

// conversations
client.createConversation({ type: 'dm', memberIds })
client.createConversation({ type: 'group', name, memberIds })
client.getConversations({ limit })    client.getConversation(id)
client.openConversation(id, onReady)  // returns an unsubscribe

// messages — newest first, keyset pagination
client.getMessages(id, { cursor, limit })
client.sendMessage(id, { text, attachments, replyToId, clientId? })
client.editMessage(id, messageId, text)
client.deleteMessage(id, messageId)   // soft delete
client.markAsRead(id, messageId)      // monotonic
client.uploadAttachment(id, file)

// typing + presence
client.startTyping(id)                client.stopTyping(id)
client.getPresence(userIds)

// events
client.on('message.new' | 'message.updated' | 'conversation.updated'
        | 'typing' | 'presence' | 'connection', cb)

Three behaviours worth knowing:

  • sendMessage generates a clientId, so a retry after a timeout returns the original message rather than posting twice. Pass your own if you need idempotency to survive an app restart.
  • createConversation adds you to the member list. Every backend requires the creator to be a member; there is no reason for each app to remember that.
  • on() works before connect(). The client wires provider subscriptions on connect and re-wires them across reconnects, so a listener registered at mount time keeps working.

Pagination

getMessages returns newest-first with a nextCursor. Stop when the cursor is nullnever when a page comes back shorter than limit, which backends are allowed to do at any time.

let cursor: string | null | undefined;
do {
  const page = await client.getMessages(id, { cursor: cursor ?? undefined });
  render(page.messages);
  cursor = page.nextCursor;
} while (cursor);

Reconnection

openConversation(id, onReady) fires onReady when the subscription goes live and again after every reconnect. Most backends do not replay what was missed while the socket was down, so that callback is where you re-read recent history.

Always open before fetching. The other order loses any message that lands between the query's snapshot and the subscription starting — permanently.

Writing an adapter

Implement IMessagingProvider, then prove it:

import { describeMessagingContract } from '@myatthirikhin/chat-core/testing';

describeMessagingContract('my backend', async () => ({
  provider: createMyProvider(),
  me: { id: 'user-a' },
  peer: { id: 'user-b' },
}));

The suite checks the behaviours that actually differ between vendors: DM dedupe ignoring member order, groups NOT being deduped, a repeated clientId returning the original message, pagination terminating without duplicates across page boundaries, delete being soft, markRead being monotonic, and an unknown user being absent from presence rather than reported offline.

@myatthirikhin/chat-core/testing also exports createFakeMessagingProvider() — a complete in-memory implementation, useful for building UI before a backend exists.

License

MIT