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

ultimatedarktower

v2.3.0

Published

This library provides functions to communicate with the bluetooth le enabled Tower that comes with Restoration Games Return To Dark Tower board game.

Readme

UltimateDarkTower

npm version npm downloads license TypeScript node

A JavaScript/TypeScript library for controlling the Bluetooth-enabled tower from Restoration Games' Return to Dark Tower board game. Control lights, sounds, drum rotation, and track game state via Bluetooth - works in browsers (Web Bluetooth), Node.js, Electron, and React Native.

I have spent many hours reverse engineering the Tower's protocol in order to create this library, I look forward to what others will create using this! - Chris

Table of Contents

Features

  • Multi-Platform Bluetooth - Works in browsers (Web Bluetooth), Node.js (@stoprocent/noble), Electron, and React Native via custom adapters
  • Bluetooth Connection Management - Reliable connection with automatic monitoring and disconnect detection
  • Tower Control - Complete control over lights, sounds, and drum rotation
  • Game State Tracking - Track glyph positions, broken seals, and skull counts
  • Event System - Callback-based event handling for tower events
  • ESM + CJS - Ships both an ES Module build and a CommonJS build; works with import and require without configuration
  • TypeScript Support - Full TypeScript definitions and type safety
  • Comprehensive Logging - Multi-output logging system for debugging
  • Battery Monitoring - Real-time battery level tracking and low battery warnings
  • Extensible Adapter Pattern - Implement IBluetoothAdapter for custom platforms

Live Examples

Try the library in action! Just power on your Tower and visit:

  • Tower Controller - Replicates official app functionality and gives examples of library functionality.

  • Tower Game - "The Tower's Challenge" - a complete game using just the tower

Requires Web Bluetooth support (Chrome, Edge, Samsung Internet). For iOS, use the Bluefy app.

Installation

Browser / Web Applications

npm install ultimatedarktower

Node.js Applications

npm install ultimatedarktower @stoprocent/noble

@stoprocent/noble is an optional peer dependency for BLE support in Node.js environments.

Platform requirements: macOS works out of the box. Linux requires BlueZ (sudo apt install bluetooth bluez libbluetooth-dev). Windows requires Windows 10+ with BLE support.

Quick Start

Browser (auto-detected)

import UltimateDarkTower from 'ultimatedarktower';

const tower = new UltimateDarkTower();
await tower.connect(); // Opens browser device picker
await tower.calibrate();
await tower.playSound(1);
await tower.cleanup();

Node.js (auto-detected)

import UltimateDarkTower from 'ultimatedarktower';

const tower = new UltimateDarkTower();
await tower.connect(); // Scans for device automatically
await tower.calibrate();
await tower.playSound(1);
await tower.cleanup();

Explicit Platform Selection

import UltimateDarkTower, { BluetoothPlatform } from 'ultimatedarktower';

const tower = new UltimateDarkTower({ platform: BluetoothPlatform.NODE });

Custom Adapter (React Native, etc.)

import UltimateDarkTower, { IBluetoothAdapter } from 'ultimatedarktower';

class MyCustomAdapter implements IBluetoothAdapter {
    // Implement all IBluetoothAdapter methods
    // See Reference.md for the full interface
}

const tower = new UltimateDarkTower({ adapter: new MyCustomAdapter() });

Documentation

📖 Complete API Reference

Comprehensive documentation with TypeScript examples, best practices, and troubleshooting guides.

Key Topics Covered:

  • Multi-Platform Setup - Configuration for Web, Node.js, Electron, and React Native
  • Connection Management - Connecting, disconnecting, and monitoring connection health
  • Bluetooth Adapters - Custom adapter interface for extending platform support
  • Tower Control - Detailed coverage of all tower commands (lights, sounds, rotation)
  • Glyph System - Automatic tracking of glyph positions as towers rotate
  • Seal Management - Breaking seals and tracking game state
  • Event Handling - Callback system for tower events
  • Logging System - Multi-output logging for debugging and monitoring
  • Best Practices - Performance tips, error handling, and common patterns
  • Troubleshooting - Solutions for common issues and debugging techniques

Integration Testing

Integration tests that require real hardware are located in tests/integration/ and are not run by default with the main test suite. These tests use the Node.js Bluetooth adapter and require a physical Return to Dark Tower device in range.

To run the calibration integration test:

npm run test:integration
  • This will connect to the tower, perform a full calibration sequence, and print the resulting glyph positions.
  • The test will fail if the tower is not available or calibration does not complete within 60 seconds.
  • Integration tests are not included in automated test runs or npm publish.

Prerequisites:

  • Tower must be powered on and in Bluetooth range
  • @stoprocent/noble must be installed (it is a peer dependency)

Development

Building and Testing

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Lint code
npm run lint

# Watch mode for development
npm run watch

Project Structure

src/
├── index.ts                  # Main exports
├── UltimateDarkTower.ts      # Main class
├── udtBluetoothAdapter.ts    # Bluetooth adapter interface & error types
├── udtBluetoothAdapterFactory.ts  # Platform auto-detection factory
├── udtBleConnection.ts       # Bluetooth connection management
├── udtTowerCommands.ts       # Tower command implementations
├── udtCommandFactory.ts      # Command creation utilities
├── udtCommandQueue.ts        # Command queue management
├── udtTowerResponse.ts       # Response handling
├── udtTowerState.ts          # Tower state management
├── udtHelpers.ts             # Utility helper functions
├── udtLogger.ts              # Logging system
├── udtConstants.ts           # Constants and type definitions
└── adapters/
    ├── WebBluetoothAdapter.ts    # Browser Web Bluetooth implementation
    └── NodeBluetoothAdapter.ts   # Node.js @stoprocent/noble BLE implementation

examples/
├── controller/               # Tower controller web app
├── game/                     # Tower game web app
├── node/                     # Node.js CLI example
└── assets/                   # Shared assets (images, fonts, etc.)

Platform Support

Built-in Support (auto-detected)

| Platform | Bluetooth Library | Notes | | -------------------------------- | ------------------------------------ | ---------------------------------------- | | Chrome / Edge / Samsung Internet | Web Bluetooth API | Desktop and Android | | Node.js | @stoprocent/noble | Requires npm install @stoprocent/noble | | Electron | Web Bluetooth or @stoprocent/noble | Auto-detects renderer vs main process |

Custom Adapter Support

| Platform | Recommended Library | Notes | | -------------------------- | ---------------------- | ----------------------------- | | React Native | react-native-ble-plx | Implement IBluetoothAdapter | | iOS (via React Native) | react-native-ble-plx | Same as React Native | | Android (via React Native) | react-native-ble-plx | Same as React Native | | Cordova / Capacitor | Platform BLE plugin | Implement IBluetoothAdapter |

Browser Support

iOS: Use the Bluefy app as Chrome/Safari does not support Web Bluetooth on Apple platforms.

Not Supported: Firefox, Safari (compatibility details)

Known Issues

  • Sounds - Sounds show as command complete which is true even though the sound itself has not completed. This is just the way the tower works. I'll have to add time lengths to each at some point, just don't use the command complete response as a way of thinking the associated sound has finished playing and you can play another sound.
  • Light Sequences - Same as sound for lights that play for a duration.

See Reference.md for performance best practices and workarounds.

Community

Questions? Ideas? Join us on our Discord Server!