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

@homie-rocks/device

v0.1.0

Published

Device classification that survives iPadOS desktop mode, crash-proof per-field validation of stored preferences, and the measured maths and state machine for an on-screen thumb stick.

Readme

@homie-rocks/device

What the hardware is, and how to keep a person's settings without ever crashing on them. It classifies the device from pointer, touch and screen signals (so an iPad in desktop mode is still a tablet), validates stored preferences field by field, and holds the measured maths and state machine for an on-screen thumb stick. It never knows what a preference means: it supplies no field names, no defaults and no storage keys, and it does not decide what a stick steers.

Part of Homie's open game engine: the packages the Homie games are built on.

Install

npm install --save-exact @homie-rocks/[email protected]

Use

import { device } from '@homie-rocks/device/Device.js';
import { num, oneOf, parseRecord, readStored, writeStored } from '@homie-rocks/device/Prefs.js';
import { DEADZONE_PX, thumbCurve } from '@homie-rocks/device/Thumb.js';

const d = device(); // probed once, then memoised
const quality = d.handheld ? 'low' : 'high';

// Absent, corrupt or half-written storage falls to your defaults, per field.
const stored: Record<string, unknown> = parseRecord(readStored('my-game.controls.v1')) ?? {};
const prefs = {
  sensitivity: num(stored.sensitivity, 0.1, 3, 1),
  hand: oneOf(stored.hand, ['left', 'right'] as const, 'right'),
};
writeStored('my-game.controls.v1', prefs); // never throws

// A drag of 40 CSS px on a 96 px stick, as a -1..1 steering command.
const steer = thumbCurve(40, 96, DEADZONE_PX);

Every storage function is synchronous and never throws: Safari private mode, a sandboxed iframe and a file:// page all get a working game with defaults.

Modules

| module | what it does | |---|---| | Device.js | profileDevice() and the memoised device(): touch-primary, handheld, memory, cores, shortest edge, DPR | | Prefs.js | Per-field validators (num, bool, oneOf, strings, mapOf) and guarded readStored / writeStored / removeStored / parseRecord | | Thumb.js | Measured thumb-stick constants, thumbCurve and its exact inverse thumbTravel, spawn and grab rules, safe-area insets, tilt permission and screen-space roll | | ThumbPad.js | ThumbPad, an abstract on-screen pad: stick ownership, thumb-roll handover, release ramp, button hit resolution, tilt, and three-beat onboarding |

The touch code has been checked with synthetic touch events only, which bypass the browser's gesture handling. Treat how it feels under a real thumb as unverified until you have held it.

License

Apache-2.0. See LICENSE and NOTICE.