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

@theme-token/sdk

v0.0.12

Published

TypeScript SDK for Theme Token - validate, fetch, convert, and apply ShadCN themes from blockchain

Readme

@theme-token/sdk

The core library for Theme Token. Handles validation, parsing, and transformation of themes between raw CSS, on-chain storage format, and ShadCN Registry format.

Why This Exists

ShadCN CLI (bunx shadcn add <url>) expects a specific JSON format with resolved color values—not raw CSS. This SDK bridges that gap.

flowchart LR
    A[Raw CSS] -->|parseCss| B[ThemeToken JSON]
    B -->|inscribe| C[Bitcoin]
    C -->|fetch| D[Registry API]
    D -->|toShadcnRegistry| E[ShadCN Format]
    E -->|bunx shadcn add| F[Your Project]

Installation

bun add @theme-token/sdk

Usage

Parse CSS to ThemeToken

Convert raw CSS into structured JSON for inscription. Automatically resolves var() references.

import { parseCss } from "@theme-token/sdk";

const css = `
:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --primary: oklch(0.6 0.15 250);
  --primary-foreground: oklch(0.98 0 0);
  --radius: 0.5rem;
  /* ... */
}
.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.98 0 0);
  /* ... */
}
`;

const result = parseCss(css, "My Theme");
if (result.valid) {
  console.log(result.theme); // Ready to inscribe
}

Transform to ShadCN Registry

import { toShadcnRegistry } from "@theme-token/sdk";

const registryItem = toShadcnRegistry(theme);
// { $schema, name, type: "registry:style", cssVars: { light, dark } }

Fetch from Blockchain

import { fetchThemeByOrigin } from "@theme-token/sdk";

const published = await fetchThemeByOrigin("85702d92...cf_0");
if (published) {
  console.log(published.theme.name);
}

Apply at Runtime

import { applyThemeMode } from "@theme-token/sdk";

applyThemeMode(theme, "dark");

React Hook

For React applications, use the dedicated hook from the /react entry:

import { useThemeToken } from "@theme-token/sdk/react";

function ThemePicker({ ordinals }) {
  const {
    themeTokens,    // Filtered ThemeToken ordinals
    activeOrigin,   // Currently applied theme origin
    loadTheme,      // Load theme by origin
    resetTheme,     // Reset to default
    isLoading,      // Loading state
    error           // Error state
  } = useThemeToken(ordinals);

  return (
    <div>
      {themeTokens.map(t => (
        <button
          key={t.origin}
          onClick={() => loadTheme(t.origin)}
          disabled={isLoading}
        >
          {t.origin === activeOrigin ? "✓ " : ""}{t.origin.slice(0, 8)}...
        </button>
      ))}
      <button onClick={resetTheme}>Reset</button>
    </div>
  );
}

The hook automatically:

  • Filters ordinals for map.app === "ThemeToken"
  • Persists selection to localStorage
  • Restores saved theme on mount
  • Detects light/dark mode from document

Convert to CSS

import { toCss } from "@theme-token/sdk";

const css = toCss(theme);
// :root { --background: oklch(...); ... }
// .dark { --background: oklch(...); ... }

API Reference

Parsing and Validation

| Function | Description | |:---------|:------------| | parseCss(css, name?) | Parse CSS string to ThemeToken, resolving var() references | | validateThemeToken(data) | Validate unknown JSON against schema | | themeTokenSchema | Zod schema for direct validation |

Transformation

| Function | Description | |:---------|:------------| | toShadcnRegistry(theme) | Convert to ShadCN Registry format | | toCss(theme) | Convert to CSS string | | toJson(theme, pretty?) | Convert to JSON string |

Network

| Function | Description | |:---------|:------------| | fetchThemeByOrigin(origin) | Fetch theme from blockchain | | fetchPublishedThemes() | Fetch all published themes | | getRegistryUrl(origin) | Get registry URL for ShadCN CLI |

Runtime

| Function | Description | |:---------|:------------| | applyTheme(styles) | Apply style props to document | | applyThemeMode(theme, mode) | Apply light or dark mode | | getCurrentTheme() | Read current theme from DOM | | clearTheme() | Remove all theme variables |

React (@theme-token/sdk/react)

| Export | Description | |:-------|:------------| | useThemeToken(ordinals) | React hook for managing ThemeToken ordinals |


ThemeToken Format

interface ThemeToken {
  $schema: string;
  name: string;
  author?: string;
  styles: {
    light: ThemeStyleProps;
    dark: ThemeStyleProps;
  };
}

Colors use OKLCH: oklch(L C H) where L is lightness (0–1), C is chroma (0–0.4), H is hue (0–360).


License

MIT