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

@dpup/meshcore-ts

v0.1.1

Published

Typed, ergonomic TypeScript wrapper around @liamcottle/meshcore.js for talking to MeshCore Companion Radio devices over TCP or USB serial.

Downloads

56

Readme

meshcore-ts

A typed, ergonomic TypeScript client for MeshCore Companion Radio devices.

License: MIT Types: included Node Module: ESM

meshcore-ts is a thin, typed wrapper over the official @liamcottle/meshcore.js — it does not reimplement the protocol. That library does the wire work; this one delegates to it and adds a first-class TypeScript surface: typed methods, named events, normalized values, and proper errors. So you talk to a MeshCore node over WiFi or USB without wrangling raw numeric byte codes and Uint8Arrays — and you get upstream protocol updates for free.

import { MeshCoreClient } from "@dpup/meshcore-ts";

const client = MeshCoreClient.tcp("192.168.1.50", 5000);
client.on("contactMessage", (msg) => console.log(`${msg.pubKeyPrefix}: ${msg.text}`));

await client.connect();
const contacts = await client.getContacts();

Features

  • 🧩 Fully typed — typed methods, events, and data models (Contact, Channel, SelfInfo, RepeaterStats, …).
  • 📡 Named eventsclient.on("contactMessage", …) instead of connection.on(0x83, …).
  • 🔤 Normalized data — hex-string keys & paths, Date timestamps, real boolean flags.
  • 🛡️ Safe by default — typed errors (MeshCoreError / …DeviceError / …TimeoutError) and request timeouts so a silent device never hangs your program.
  • 🔌 Node transports — TCP/WiFi and USB serial, with simple factories.
  • 🪝 Escape hatch — the raw meshcore.js connection stays reachable via client.raw.

Install

npm install @dpup/meshcore-ts      # or: bun add @dpup/meshcore-ts / pnpm add @dpup/meshcore-ts

ESM-only, Node.js ≥ 18. The @liamcottle/meshcore.js dependency is installed automatically.

Quick start

import { MeshCoreClient, TxtType } from "@dpup/meshcore-ts";

// Connect over TCP/WiFi …
const client = MeshCoreClient.tcp("192.168.1.50", 5000);
// … or USB serial:
// const client = MeshCoreClient.serial("/dev/ttyACM0");

await client.connect();

const self = await client.getSelfInfo();
console.log(`Connected to "${self.name}" — ${self.publicKey}`);

const alice = await client.findContactByName("alice");
if (alice) {
  await client.sendTextMessage(alice, "hello from typescript", TxtType.Plain);
}

await client.close();

Any method that takes a contact accepts a Contact, a hex public-key string, or raw Uint8Array bytes.

Events

By default the client auto-drains the device's message queue on msgWaiting and emits typed events. Set { autoSync: false } to pull manually with getWaitingMessages().

| Event | Payload | When | | --- | --- | --- | | connected / disconnected | — | connection lifecycle | | contactMessage / channelMessage | ContactMessage / ChannelMessage | an incoming message | | channelData | ChannelData | a channel datagram | | advert / newAdvert | Advert / NewAdvert | a node advertised | | pathUpdated | { publicKey } | a contact's path changed | | rawData / logRxData | RawData / LogRxData | received packets (with SNR/RSSI) | | traceData | TraceData | a path trace returned | | telemetryResponse / statusResponse / binaryResponse | typed payloads | server responses | | sendConfirmed / loginSuccess | typed payloads | send ack / login | | error | Error | a surfaced async failure (e.g. a failed auto-sync) |

const client = MeshCoreClient.tcp(host, port, {
  requestTimeoutMs: 10_000, // timeout for requests a device might never answer
  autoSync: true,           // auto-drain + emit on msgWaiting
});

API

MeshCoreClient provides typed wrappers across the full companion API. All are fully typed — your editor's autocomplete is the canonical reference.

  • Device
    • getSelfInfo()
    • getDeviceTime(), setDeviceTime(), syncDeviceTime()
    • getBatteryVoltage(), deviceQuery(), reboot()
    • exportPrivateKey(), importPrivateKey()
  • Contacts
    • getContacts(), findContactByName(), findContactByPublicKeyPrefix()
    • importContact(), exportContact(), shareContact(), removeContact()
    • addOrUpdateContact(), setContactPath(), resetPath()
    • setAutoAddContacts(), setManualAddContacts()
  • Messaging
    • sendTextMessage(), sendChannelTextMessage()
    • syncNextMessage(), getWaitingMessages()
  • Channels
    • getChannel(), getChannels()
    • setChannel(), deleteChannel()
    • findChannelByName(), findChannelBySecret()
  • Radio & adverts
    • sendAdvert(), sendFloodAdvert(), sendZeroHopAdvert()
    • setAdvertName(), setAdvertLatLong()
    • setTxPower(), setRadioParams()
  • Remote nodes
    • login(), getStatus(), getTelemetry()
    • getNeighbours(), sendBinaryRequest()
  • Stats, signing & tracing
    • getStats(), getStatsCore(), getStatsRadio(), getStatsPackets()
    • sign(), tracePath()

Examples

bun examples/monitor.ts 172.16.0.23 5000        # monitor until Ctrl-C
bun examples/monitor.ts 172.16.0.23 5000 30     # …for 30 seconds

Design & notes

  • A wrapper, not a reimplementation. All protocol logic lives in @liamcottle/meshcore.js; this package delegates to it and layers on types, normalization, and safety — so it tracks upstream automatically. The raw connection is always reachable via client.raw for anything unwrapped.
  • Node-focused, ESM-only. Transports are TCP/WiFi and USB serial. ESM-only mirrors meshcore.js and keeps the serialport dependency out of browser bundles; browser BLE/WebSerial transports are intentionally not exposed.
  • Values are normalized. Keys/paths/secrets are hex strings and timestamps are Dates; the wrapper converts back when sending.

Development

bun install
bun run typecheck   # tsc --noEmit (strict)
bun run test        # vitest unit tests (no hardware needed)
bun run build       # emit dist/ (ESM + .d.ts)

See AGENTS.md for architecture and contribution notes.

License

MIT © Dan Pupius