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

gan2x2ui

v0.1.1

Published

Open-source Web Bluetooth driver for GAN 251 UI (2×2 smart cube)

Readme

gan2x2UI

Français · English

Driver Web Bluetooth open-source pour le GAN 251 UI (smart 2×2).

Lib complète : connect, crypto, moves, état CP/CO, gyro, battery, scramble URF, MAC auto.
À toi de brancher timer / UI / training dans ton app.

Chrome / Edge desktop · localhost ou HTTPS · ESM natif · zéro dépendance.

import { Gan2x2UI, scramble2x2Official, mergeMoves } from "gan2x2ui";

const cube = await Gan2x2UI.connect(); // MAC auto (flag Chrome — voir plus bas)
cube.on("move", ({ move, solved }) => console.log(move, solved));
cube.on("gyro", ({ quaternion }) => {});
cube.on("battery", ({ level }) => console.log(level));

const { scramble, dist } = scramble2x2Official();

Install

npm i gan2x2ui
pnpm add gan2x2ui

https://www.npmjs.com/package/gan2x2ui

Clone local :

import { Gan2x2UI } from "./src/index.js";

MAC auto — flag Chrome obligatoire

WebBT ne donne pas la MAC au GATT. La crypto GAN en a besoin → Manufacturer Specific Data des ads BLE.

const cube = await Gan2x2UI.connect();
console.log(cube.mac, cube.macSource); // "aa:bb:…" · "advertisement"
  1. chrome://flags/#enable-experimental-web-platform-features → Enabled
  2. Relance Chrome
  3. Si KO : aussi chrome://flags/#enable-web-bluetooth-new-permissions-backend

Bluefy iOS : Enable BLE Advertisements.

Fallback : opts.mac → nom 12-hex → localStorage → sinon saisie (chrome://bluetooth-internals/#devices).
Ne commit jamais une vraie MAC.

Quick start

npm test
npm run serve
# → http://localhost:8080/examples/minimal.html
# → http://localhost:8080/examples/timer.html
  1. Chrome + flag (MAC auto)
  2. Cube allumé, blanc ↑ / vert →
  3. Connect → tourne

Docs

| | FR | EN | |--|----|----| | Intégration site | INTEGRATION.fr | EN | | Protocole BLE | PROTOCOL.fr | EN | | Roadmap | ROADMAP.fr | EN | | Contribuer | CONTRIBUTING | EN |

API

Gan2x2UI.connect(opts)

| Option | Défaut | | |--------|--------|--| | mac | auto | omis = advertisements | | autoMac | true | | | macTimeoutMs | 10000 | | | cacheMac | true | localStorage | | resetOnConnect | true | RESET + modèle résolu | | requestFacelets | true | si pas de reset | | preferAltTx | false | write fff7 | | device | — | device déjà choisi |

Events

| Event | Payload | |-------|---------| | connect | { name, mac, macSource, key, solved } | | move | { move, hwMove, serial, state, solved, q, … } | | gyro | { quaternion, vx, vy, vz } | | facelets | { CP, CO, state, solved } | | battery | { level } | | disconnect | {} | | error | { error, ct } |

const off = cube.on("move", handler);
off();
await cube.send("BATTERY"); // FACELETS | BATTERY | HARDWARE | RESET
await cube.markSolved();
cube.applyMoves = false; // scramble piloté par l’UI
await cube.disconnect();

Helpers

| Export | | |--------|--| | Cube2x2 | modèle CP/CO | | scramble2x2Official() | scramble URF | | mergeMoves | reco HTM | | parseAlg / invertAlg / applyAlg | | | OrientationTracker | gyro → display | | resolveMac / deriveKeyIv / decodePacket | bas niveau |

Limites firmware (comme CubeStation)

  • MOVE = U / R / F seulement
  • L / D / B physiques → one-hot face opposée
  • Gyro = orientation, pas discrimination de face
  • Scrambles officiels = URF

Compat

  • Navigateur : Chromium + Web Bluetooth
  • Node : crypto / scramble / cube OK ; connect = navigateur only

Auteur

Créé et maintenu par Thomas Lekieffre — reverse du protocole GAN 251 UI (ProtocolV3-2) et driver Web Bluetooth open-source.

License

MIT — LICENSE · © 2026 Thomas Lekieffre

Non affilié à GAN Cube / CubeStation.