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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@toolkit-p2p/transport-ble

v0.1.0

Published

Bluetooth LE transport layer for toolkit-p2p

Downloads

3

Readme

@toolkit-p2p/transport-ble

Bluetooth Low Energy (BLE) transport for toolkit-p2p.

Features

  • ✅ Web Bluetooth API (Android Chrome 56+, macOS/Linux Chrome 70+)
  • ✅ Automatic fragmentation for payloads >MTU
  • ✅ Exponential backoff retry on failures
  • ✅ Heartbeat keepalive & auto-reconnect
  • ✅ Rate limiting (100 pkt/s per peer)
  • ⚠️ Not supported on iOS (Safari doesn't expose Web Bluetooth)

Installation

pnpm add @toolkit-p2p/transport-ble @toolkit-p2p/core

Usage

import { bleTransport } from '@toolkit-p2p/transport-ble';
import { createEngine } from '@toolkit-p2p/core';

// Create transport
const transport = bleTransport({ mtu: 20 });

// Client: discover nearby peers
const peers = await transport.discover();
const connection = await transport.connect(peers[0]);

// Send/receive
connection.send(new Uint8Array([1, 2, 3]));
connection.onMessage((payload, from) => {
  console.log('Received:', payload);
});

// Integrate with game engine
const engine = createEngine({
  initialState: { score: 0 },
  reducer: (state, input) => state,
  authority: 'host',
});

Browser Support

| Browser | Platform | Supported | Version | |---------|----------|-----------|---------| | Chrome | Android | ✅ Yes | 56+ | | Chrome | macOS | ✅ Yes | 70+ | | Chrome | Linux | ✅ Yes | 70+ | | Chrome | Windows | ⚠️ Partial | 70+ (experimental) | | Safari | iOS | ❌ No | Not exposed | | Safari | macOS | ❌ No | Not exposed | | Firefox | All | ❌ No | Not implemented |

Configuration

bleTransport({
  mtu: 20,              // Max bytes per packet (default: 20)
  retryMs: 100,         // Base retry delay (default: 100ms)
  serviceUUID: '...',   // Custom service UUID (optional)
  txCharUUID: '...',    // Custom TX char UUID (optional)
  rxCharUUID: '...',    // Custom RX char UUID (optional)
});

Architecture

GATT Service

  • Service UUID: a8729501-559d-46d4-967e-15be95e5d108
  • TX Characteristic: 5f34567b-2de5-482e-a88a-25569e15a516 (write)
  • RX Characteristic: 94d284a3-41a1-4518-9736-bcda10c66cbc (notify)

Packet Format

[seq: u8][len: u8][payload: u8[]]
  • seq: Sequence number (for fragmentation)
  • len: Payload length
  • payload: Data (≤MTU-2 bytes)

Fragmentation

Payloads >MTU are automatically split:

// 200-byte snapshot → 10 fragments (at MTU=20)
send(new Uint8Array(200)); // Automatically fragmented

Reliability

  • Heartbeat: 1-byte ping every 5s
  • Timeout: Reconnect if no pong in 15s
  • Exponential Backoff: 100ms, 200ms, 400ms, ...

Limitations

  1. iOS not supported: Safari doesn't expose Web Bluetooth API
    • Workaround: Use QR code / audio fallback (v0.2+)
  2. No peripheral mode: Web Bluetooth only supports central (client) role
    • Host must use native app (Android/macOS) to advertise
  3. MTU variance: Some devices cap at 23 bytes (design for 20)
  4. Android Doze: Background BLE may be throttled (document workaround)

Testing

# Unit tests (mocked Web Bluetooth API)
pnpm test

# Manual test (requires 2 physical devices)
pnpm --filter examples/racer dev

License

MIT © Aaron Rosenthal