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

@socketry/live

v0.16.1

Published

Live HTML tags for Ruby.

Readme

Live.js

A JavaScript client library for building interactive web applications with Ruby Live framework.

Development Status

Features

  • Real-time Communication: WebSocket-based client-server communication.
  • DOM Manipulation: Efficient updating, replacing, and modifying HTML elements.
  • Event Forwarding: Forward client events to server for processing.
  • Controller Loading: Declarative JavaScript controller loading with data-live-controller.
  • Automatic Cleanup: Proper lifecycle management and memory cleanup.
  • Live Elements: Automatic binding and unbinding of live elements.

Usage

Installation

npm install @socketry/live

Basic Setup

import { Live } from '@socketry/live';

// Start the live connection
const live = Live.start({
  path: 'live',  // WebSocket endpoint
  base: window.location.href
});

Controller Loading

Live.js supports declarative controller loading using the data-live-controller attribute:

<div class="live" id="game" data-live-controller="/static/game_controller.mjs">
  <!-- Game content -->
</div>
// game_controller.mjs
export default function(element) {
  console.log('Controller loaded for:', element);
  
  // Setup your controller logic
  element.addEventListener('click', handleClick);
  
  // Return a controller object with cleanup
  return {
    dispose() {
      element.removeEventListener('click', handleClick);
    }
  };
}

API Reference

Live Class

Static Methods

  • Live.start(options) - Create and start a new Live instance
    • options.window - Window object (defaults to globalThis)
    • options.path - WebSocket path (defaults to 'live')
    • options.base - Base URL (defaults to window.location.href)

Instance Methods

Connection Management
  • connect() - Establish WebSocket connection
  • disconnect() - Close WebSocket connection
DOM Manipulation
  • update(id, html, options) - Update element content
  • replace(selector, html, options) - Replace elements
  • prepend(selector, html, options) - Prepend content
  • append(selector, html, options) - Append content
  • remove(selector, options) - Remove elements
Event Handling
  • forward(id, event) - Forward event to server
  • forwardEvent(id, event, detail, preventDefault) - Forward DOM event
  • forwardFormEvent(id, event, detail, preventDefault) - Forward form event
Script Execution
  • script(id, code, options) - Execute JavaScript code
  • loadController(id, path, options) - Load JavaScript controller
Event Dispatching
  • dispatchEvent(selector, type, options) - Dispatch custom events

Options Parameter

Most methods accept an options parameter with:

  • options.reply - If truthy, server will reply with {reply: options.reply}

Controller Pattern

Controllers are JavaScript modules that manage view-specific behavior:

// Simple controller
export default function(element) {
  // Setup code
  return {
    dispose() {
      // Cleanup code
    }
  };
}

// With options
export default function(element, options) {
  const config = options.config || {};
  // Use config...
}

Live Elements

Elements with the live CSS class are automatically managed:

<div class="live" id="my-element">
  Content that can be updated
</div>

Event Examples

Basic Event Forwarding

// Forward click events
element.addEventListener('click', (event) => {
  live.forwardEvent('my-element', event, { button: 'clicked' });
});

// Forward form submissions
form.addEventListener('submit', (event) => {
  live.forwardFormEvent('my-form', event, { action: 'submit' });
});

Contributing

We welcome contributions to this project.

  1. Fork it.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create new Pull Request.

Developer Certificate of Origin

In order to protect users of this project, we require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.

Community Guidelines

This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.

See Also

  • lively — Ruby framework for building interactive web applications.
  • live — Provides client-server communication using websockets.
  • live-audio-js — Web Audio API-based game audio synthesis library.