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

@standardbeagle/ux-core

v0.1.0

Published

Shared types, validators, errors, and numerical helpers for the `@standardbeagle/*` UX MCP suite.

Downloads

19

Readme

@standardbeagle/ux-core

Shared types, validators, errors, and numerical helpers for the @standardbeagle/* UX MCP suite.

This package is a pure TypeScript library — not an MCP server. The color/a11y-audit/design-token/typography/image-processing servers depend on it for the canonical color types, error classes, validation predicates, reference fixtures, and k-means clustering.

Install

npm install @standardbeagle/ux-core

Exports

All exports are surfaced from src/index.ts:

export * from './color/types.js';
export * from './color/fixtures.js';
export * from './errors.js';
export * from './lib/kmeans.js';

Color types

ColorSpace is the discriminator union of supported spaces:

type ColorSpace = 'rgb' | 'hsl' | 'hsv' | 'lab' | 'oklch' | 'hex';

Per-space value shapes:

interface RGB   { r: number; g: number; b: number; a?: number; } // 0-255, alpha 0-1
interface HSL   { h: number; s: number; l: number; a?: number; } // h 0-360, s/l 0-100
interface HSV   { h: number; s: number; v: number; a?: number; }
interface LAB   { l: number; a: number; b: number; alpha?: number; } // l 0-100, a/b -128..127
interface OKLCH { l: number; c: number; h: number; alpha?: number; } // l 0-1, c 0-0.4, h 0-360
type Hex = string; // '#RRGGBB' or '#RRGGBBAA'

Tagged-union Color for cross-space carriage:

type Color =
  | { space: 'rgb';   value: RGB }
  | { space: 'hsl';   value: HSL }
  | { space: 'hsv';   value: HSV }
  | { space: 'lab';   value: LAB }
  | { space: 'oklch'; value: OKLCH }
  | { space: 'hex';   value: Hex };

Validators (color/validate.ts)

Predicates and assertions over the color types.

import { isHex, isRGB, clampChannel, assertColor } from '@standardbeagle/ux-core';

isHex('#ff0000');                    // true
isHex('#ggg');                       // false (rejects non-hex)
isRGB({ r: 255, g: 0, b: 0 });       // true
isRGB({ r: 300, g: 0, b: 0 });       // false (out of range)
clampChannel(300, 0, 255);           // 255
assertColor('#ff0000', 'hex');       // ok; throws InvalidColorError otherwise

assertColor(c, space) is a TypeScript assertion function — after the call, c is narrowed to Color.

Errors

All errors extend UXCoreError, which carries a stable string code:

class UXCoreError extends Error {
  code: string;
}

class InvalidColorError    extends UXCoreError { } // code: 'E_INVALID_COLOR'
class OutOfRangeError      extends UXCoreError { } // code: 'E_OUT_OF_RANGE'
class UnsupportedSpaceError extends UXCoreError { } // code: 'E_UNSUPPORTED_SPACE'

Example:

import { InvalidColorError } from '@standardbeagle/ux-core';

try {
  assertColor('not-a-color', 'hex');
} catch (e) {
  if (e instanceof InvalidColorError) {
    console.error(e.code); // 'E_INVALID_COLOR'
  }
}

Reference fixtures (color/fixtures.ts)

REFERENCE_COLORS is a frozen array of 12 cross-verified color records used for round-trip testing across spaces. Each entry carries the same color expressed as hex, rgb, hsl, hsv, lab, and oklch within 0.5-unit tolerance against colormine.org and oklch.com.

import { REFERENCE_COLORS, type ColorFixture } from '@standardbeagle/ux-core';

for (const fixture of REFERENCE_COLORS) {
  // fixture.name, fixture.hex, fixture.rgb, fixture.hsl, ...
}

Names included: pure red, pure green, pure blue, white, black, mid-gray, navy, teal, orange, magenta, yellow, cyan.

K-means (lib/kmeans.ts)

3D k-means clustering with k-means++ seeding and Lloyd iteration. Used by color.palette_extract and image-processing.palette_from_image for dominant-color extraction.

import { kmeans, type Point, type Cluster } from '@standardbeagle/ux-core';

const points: Point[] = [
  { x: 255, y: 0,   z: 0   },
  { x: 250, y: 5,   z: 5   },
  { x: 0,   y: 0,   z: 255 },
];

const clusters: Cluster[] = kmeans(points, 2);
// [{ centroid: { x, y, z }, points: [] }, ...]

Signature:

function kmeans(
  points: Point[],
  k: number,
  maxIterations?: number, // default 50
  tolerance?: number,     // default 1.0
): Cluster[];

Behavior:

  • Returns [] when points.length === 0 or k <= 0.
  • Clamps k to points.length when k > points.length.
  • Stops early once no centroid moves more than tolerance between iterations.
  • Returned clusters carry the final centroid; points is intentionally [] (the caller does the final assignment if it needs it).

License

MIT