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

sockr-shared

v1.3.0

Published

Shared types for Sockr messaging system

Readme

sockr-shared

Shared TypeScript type definitions for the SOCKR WebSocket messaging framework. This package provides type-safe contracts used by both the server and client packages.

Installation

npm install sockr-shared

Overview

This package exports TypeScript interfaces, enums, and types that ensure consistent communication between SOCKR server and client implementations. It has zero runtime dependencies and ships with full TypeScript support (CommonJS, ES Modules, and .d.ts declarations).

Exports

Socket Events

The SocketEvent enum defines all events used in the messaging protocol:

import { SocketEvent } from 'sockr-shared';

// Connection lifecycle
SocketEvent.CONNECT
SocketEvent.DISCONNECT
SocketEvent.ERROR

// Authentication
SocketEvent.AUTHENTICATE
SocketEvent.AUTHENTICATED
SocketEvent.AUTH_ERROR

// User presence
SocketEvent.USER_ONLINE
SocketEvent.USER_OFFLINE
SocketEvent.GET_ONLINE_STATUS
SocketEvent.ONLINE_STATUS

// Messaging
SocketEvent.SEND_MESSAGE
SocketEvent.RECEIVE_MESSAGE
SocketEvent.MESSAGE_DELIVERED
SocketEvent.MESSAGE_ERROR

// Typing indicators
SocketEvent.TYPING_START
SocketEvent.TYPING_STOP

Event Payloads

The EventPayloads interface maps each event to its strictly-typed payload:

import { EventPayloads, SocketEvent } from 'sockr-shared';

// Type-safe event handling
type AuthPayload = EventPayloads[SocketEvent.AUTHENTICATE];
// { token: string }

type MessagePayload = EventPayloads[SocketEvent.SEND_MESSAGE];
// { to: string; content: string; metadata?: Record<string, any> }

Message Types

import { Message, MessageOptions } from 'sockr-shared';

const message: Message = {
  id: 'msg-1',
  from: 'user-a',
  to: 'user-b',
  content: 'Hello!',
  timestamp: Date.now(),
  delivered: false,
  metadata: { priority: 'high' },
};

const options: MessageOptions = {
  requireAcknowledgment: true,
  timeout: 5000,
};

User Types

import { User, UserConnection } from 'sockr-shared';

const user: User = {
  id: 'user-a',
  socketId: 'socket-123',
  connectedAt: Date.now(),
};

const connection: UserConnection = {
  userId: 'user-a',
  socketId: 'socket-123',
  isOnline: true,
};

Configuration Types

import { ServerConfig, ClientConfig } from 'sockr-shared';

const serverConfig: ServerConfig = {
  port: 3000,
  cors: { origin: 'http://localhost:5173', credentials: true },
  pingTimeout: 10000,
  pingInterval: 25000,
  transports: ['websocket', 'polling'],
};

const clientConfig: ClientConfig = {
  url: 'http://localhost:3000',
  autoConnect: true,
  reconnection: true,
  reconnectionAttempts: 5,
  reconnectionDelay: 1000,
  timeout: 10000,
  transports: ['websocket'],
};

Development

# Build the package
npm run build

# Watch mode
npm run dev

# Clean build artifacts
npm run clean

License

MIT