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

ultimatedarktowerrelay-client

v0.2.0

Published

UltimateDarkTowerRelay consumer SDK — connect to a relay host over WebSocket, receive decoded tower state, and report participant player actions. Framework-agnostic; browser or Node.

Readme


What this is

A relay host advertises a tower-emulator the official Return to Dark Tower companion app connects to, decodes every 20-byte command, and broadcasts it over WebSocket. This package is what a consumer runs. It speaks the relay's WebSocket protocol so you don't have to: handshake, decoded TowerState events, participant actions, auto-reconnect with backoff, and protocol-version-mismatch handling.

It's isomorphic — use the browser's global WebSocket, or inject the ws package in Node. Consumers fall into two roles:

  • Observer / screen-only — render the decoded tower state (LEDs, drum positions, skull drops) without any hardware.
  • Participant — has a physical tower or reports player actions; pair RelayClient with PhysicalTowerReplay to mirror the host's tower onto a local one over Web Bluetooth.

Install

npm install ultimatedarktowerrelay-client

ultimatedarktower is installed alongside it (decoded TowerState types + the PhysicalTowerReplay tower interface).

Quick start

Observer (screen-only, browser)

import { RelayClient } from 'ultimatedarktowerrelay-client';

const client = new RelayClient({
  label: 'My Visualizer',
  observer: true,
  onEvent: (e) => {
    if (e.type === 'state') render(e.state); // decoded TowerState
  },
});

await client.connect('ws://192.168.1.5:8765');

Node consumer

In Node there is no global WebSocket, so inject one:

import { RelayClient } from 'ultimatedarktowerrelay-client';
import WebSocket from 'ws';

const client = new RelayClient({ observer: true, webSocketImpl: WebSocket, onEvent });
await client.connect('ws://192.168.1.5:8765');

Participant — mirror the host onto a local tower

import { RelayClient, PhysicalTowerReplay } from 'ultimatedarktowerrelay-client';
import UltimateDarkTower from 'ultimatedarktower';

const tower = new UltimateDarkTower();        // satisfies TowerWriter structurally
const replay = new PhysicalTowerReplay({ tower });

const client = new RelayClient({
  label: 'Player 2',
  onEvent: (e) => replay.handleEvent(e), // mirrors tower:command + sync:state onto my tower
});

await client.connect('ws://192.168.1.5:8765');

// Report a player action back to the host:
client.dropSkull();

Events

onEvent receives a discriminated union (RelayClientEvent). Common types:

| Type | Meaning | |---|---| | state | Decoded TowerState + the raw lastCommand. | | tower:command | Raw 20-byte command with a monotonic seq. | | sync:state | Late-join catch-up (last command). | | relay:connected · relay:disconnected · relay:reconnecting | Connection lifecycle. | | relay:version-mismatch | Host/client PROTOCOL_VERSION disagree. | | host:status · client:connected · client:disconnected | Room/host status. |

Documentation

License

MIT. Return to Dark Tower and its art, sounds, and likeness are © Restoration Games. This is an unofficial, fan-made project.