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

@andrewshell/socklog

v0.2.2

Published

WebSocket-based logging web components using Lit

Downloads

20

Readme

Socklog

WebSocket-based logging web components built with Lit.

Installation

npm

npm install @andrewshell/socklog

CDN

esm.sh:

<script type="module">
  import 'https://esm.sh/@andrewshell/socklog'
</script>

<socklog-viewer url="ws://localhost:8080/logs"></socklog-viewer>

unpkg:

<script src="https://unpkg.com/@andrewshell/socklog"></script>

<socklog-viewer url="ws://localhost:8080/logs"></socklog-viewer>

jsdelivr:

<script src="https://cdn.jsdelivr.net/npm/@andrewshell/socklog"></script>

<socklog-viewer url="ws://localhost:8080/logs"></socklog-viewer>

Usage

Basic Example

<socklog-viewer url="ws://localhost:8080/logs"></socklog-viewer>

With Controls

<script type="module">
  import 'https://esm.sh/@andrewshell/socklog'

  const viewer = document.getElementById('viewer')
  const controls = document.getElementById('controls')

  // Connect controls to viewer's log store
  controls.store = viewer.getStore()
</script>

<div style="display: flex; flex-direction: column; height: 400px;">
  <socklog-controls id="controls"></socklog-controls>
  <socklog-viewer id="viewer" url="ws://localhost:8080/logs"></socklog-viewer>
</div>

Components

<socklog-viewer>

Main log display component with WebSocket connection and virtualized scrolling.

Attributes:

| Attribute | Type | Default | Description | | ---------- | -------- | ------- | -------------------------------- | | url | string | '' | WebSocket URL to connect to | | max-logs | number | 1000 | Maximum number of logs to retain |

Methods:

| Method | Returns | Description | | ------------ | ---------- | ---------------------------- | | connect() | void | Connect to the WebSocket | | clear() | void | Clear all logs | | getStore() | LogStore | Get the underlying log store |

<socklog-controls>

Filter, search, and pause controls for the log viewer.

Properties:

| Property | Type | Description | | -------- | ---------- | ----------------------------- | | store | LogStore | Log store instance to control |

Styling

Components use CSS custom properties for theming:

socklog-viewer {
  /* Typography */
  --socklog-font-family: 'Monaco', 'Menlo', monospace;
  --socklog-font-size: 13px;

  /* Colors */
  --socklog-bg: #1e1e1e;
  --socklog-color: #d4d4d4;
  --socklog-border-color: #333;
  --socklog-timestamp-color: #888;
  --socklog-muted-color: #666;

  /* Layout */
  --socklog-padding: 8px;
  --socklog-border-radius: 4px;
}

socklog-controls {
  /* Controls */
  --socklog-controls-bg: #252526;
  --socklog-input-bg: #3c3c3c;
  --socklog-input-border: #555;
  --socklog-input-color: #d4d4d4;
  --socklog-focus-color: #007acc;
  --socklog-hover-bg: #404040;

  /* Pause state */
  --socklog-pause-bg: #fff3cd;
  --socklog-pause-color: #856404;
}

Core Modules

For advanced usage, you can import the core modules directly:

import { WebSocketClient, LogStore } from '@andrewshell/socklog'

const client = new WebSocketClient({
  url: 'ws://localhost:8080/logs',
  reconnect: true,
  reconnectInterval: 3000,
  maxReconnectAttempts: 10
})

const store = new LogStore(1000)

client.addEventListener('log', (e) => {
  store.add(e.detail)
})

client.connect()

Types

interface LogEntry {
  id: string
  timestamp: Date
  data: unknown
  raw: string
}

interface WebSocketConfig {
  url: string
  reconnect?: boolean
  reconnectInterval?: number
  maxReconnectAttempts?: number
}

interface LogFilter {
  search?: string
}

type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error'

License

MIT