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

bonk-skin

v0.1.2

Published

Encode, decode, validate, and render bonk.io skins

Readme

bonk-skin

Encode, decode, validate, and render bonk.io skins.

Install

npm install bonk-skin

Browser bundlers automatically get a build that excludes the Node.js-only renderToBuffer function, so @napi-rs/canvas is never pulled into your browser bundle.

Encoding & Decoding

Convert between the bonk.io skin string format and a typed SkinData object.

import { decodeSkin, encodeSkin } from 'bonk-skin';

const skin = decodeSkin(skinString);
console.log(skin.bc);
console.log(skin.layers);

const encoded = encodeSkin(skin);

Skin Format

A skin consists of a base color and up to 16 layers. Each layer references one of 115 SVG shapes with positioning, scaling, rotation, flip, and color properties.

import type { SkinData, SkinLayer } from 'bonk-skin';

// SkinData
//   bc: number (base color, 0-16777215)
//   layers: SkinLayer[]
//     id: number (shape ID, 1-115)
//     scale: number (-10 to 10)
//     angle: number (-9999 to 9999)
//     x: number (-99999 to 99999)
//     y: number (-99999 to 99999)
//     flipX: boolean
//     flipY: boolean
//     color: number (0-16777215)

Validation

Validate a skin or its layers. Every validator returns a ValidationResult with valid and issues.

import { validateSkin, decodeAndValidate } from 'bonk-skin';

const result = validateSkin(skin);
if (!result.valid) {
	for (const issue of result.issues) {
		console.log(`${issue.path}: ${issue.message}`);
	}
}

// Decode and validate in one step
const { skin, validation } = decodeAndValidate(skinString);

Section-level validators are also available:

import { validateLayers } from 'bonk-skin';

validateLayers(skin.layers);

Rendering

Node / Bun

renderToBuffer uses @napi-rs/canvas to produce a PNG buffer without a browser. It is only available in Node.js/Bun.

import { decodeSkin, renderToBuffer } from 'bonk-skin';
import { writeFileSync } from 'fs';

const skin = decodeSkin(skinString);
const png = renderToBuffer(skin);
writeFileSync('skin.png', png);

// Custom size
const large = renderToBuffer(skin, { size: 200 });

You can also import it explicitly from the bonk-skin/node sub-path:

import { renderToBuffer } from 'bonk-skin/node';

Browser using PIXI.js

SkinRenderer wraps a PIXI renderer and provides a canvas element you can insert into the DOM.

import { decodeSkin, SkinRenderer } from 'bonk-skin';

const renderer = new SkinRenderer({ size: 100 });
document.body.appendChild(renderer.canvas);

const skin = decodeSkin(skinString);
renderer.render(skin);

// Resize
renderer.resize(200);
renderer.render(skin);

// Cleanup
renderer.destroy();

Templates

Create new skin objects defaults.

import { getBlankSkin, getNewLayer, DEFAULT_BASE_COLOR, DEFAULT_COLORS } from 'bonk-skin';

const skin = getBlankSkin();
// { layers: [], bc: 4492031 }

const layer = getNewLayer();
// { id: 1, scale: 0.25, angle: 0, x: 0, y: 0, flipX: false, flipY: false, color: 0 }

skin.layers.push(layer);

Types

All interfaces are exported for use in TypeScript:

import type {
	SkinData,
	SkinLayer,
	ValidationResult,
	ValidationIssue,
	SkinRendererOptions,
	RenderToBufferOptions,
} from 'bonk-skin';

License

GPL3