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

@shiit/avatars

v0.1.1

Published

XState-powered avatar system with Zdog 3D rendering

Readme

@shiit/avatars

XState-powered avatar system with Zdog 3D rendering.

Installation

npm install @shiit/avatars gsap zdog

Quick Start

import { Avatar } from "@shiit/avatars";
import { baseAvatarConfig } from "@shiit/avatars/configs";

const canvas = document.getElementById("avatar-canvas");
const avatar = new Avatar(canvas, baseAvatarConfig, {
  body: "#74b9ff",
  eye: "#2d3436",
  mouth: "#2d3436",
  blush: "#fd79a8",
  dead: "#636e72",
});

// Change state
avatar.setState("speaking");

// Change expression
avatar.setExpression("happy");

Running the Demo

From the package root:

# 1. Build the package
pnpm build

# 2. Run the demo
pnpm demo

The demo lets you:

  • Switch between Mushroom, Cat, and Base avatars
  • Trigger all 13 expressions with emoji buttons
  • Change states (idle, speaking, thinking, listening, processing, error)
  • See social-sized avatar preview
  • Watch micro-movements when expressions change

React Usage

import { useAvatar } from "@shiit/avatars/hooks/useAvatar";

function MyAvatar() {
  const { avatarRef, setState, setExpression } = useAvatar(config, colors);

  return (
    <div>
      <canvas ref={avatarRef} width={400} height={400} />
      <button onClick={() => setState("speaking")}>Speak</button>
    </div>
  );
}

Available States

  • idle - Gentle bobbing animation
  • speaking - Mouth cycling animation
  • thinking - Head tilt animation
  • listening - Lean forward
  • processing - Surprised expression
  • error - Error state with custom geometry

Available Expressions

  • normal - Default face
  • happy - Smiling with blush
  • sad - Downcast eyes
  • angry - Furrowed brows
  • surprised - Wide eyes
  • dead - X X eyes
  • confused - Raised eyebrow
  • sleepy - Closed eyes
  • nervous - Sweat drop
  • shy - Sideways eyes
  • wink - Random eye wink
  • cute - Big shiny anime eyes
  • pleading - Kawaii pout face

Creating Custom Avatars

Using the Factory (Recommended)

import { createAvatar } from "@shiit/avatars";

const myConfig = createAvatar({
  name: "my-avatar",
  states: {
    idle: {
      motion: { translate: { y: 2 } },
    },
  },
});

Extending the Base Class

import { Avatar } from "@shiit/avatars";

class MyAvatar extends Avatar {
  buildBody() {
    // Add custom body geometry
  }
}

Usage with Ultravox (Voice AI)

When using the avatar with real-time voice agents like Ultravox, you need to handle state (animations) and expression (face) as separate layers:

import { useEffect, useRef, useState } from "react";
import { UltravoxSession } from "ultravox-client";
import {
  MushroomAvatar,
  mushroomConfig,
  MUSHROOM_COLORS,
} from "@shiit/avatars/mushroom";

function VoiceAvatar() {
  const canvasRef = useRef<HTMLCanvasElement>(null);
  const avatarRef = useRef<MushroomAvatar | null>(null);
  const [status, setStatus] = useState("idle"); // idle | speaking | listening | thinking
  const [emailCaptured, setEmailCaptured] = useState(false);

  // Initialize avatar
  useEffect(() => {
    if (!canvasRef.current) return;
    avatarRef.current = new MushroomAvatar(
      canvasRef.current,
      { ...mushroomConfig, zoom: 2 },
      MUSHROOM_COLORS,
    );
  }, []);

  // CRITICAL: Always set state AND expression separately
  useEffect(() => {
    if (!avatarRef.current) return;

    // 1. Set state for animations (speaking mouth, idle bobbing, etc.)
    const state = status === "idle" ? "idle" : status;
    avatarRef.current.setState(state);

    // 2. Set expression for face (layered on top of state)
    if (emailCaptured) {
      avatarRef.current.setExpression("happy"); // Happy face while talking
    } else if (status === "idle") {
      avatarRef.current.setExpression("sleepy"); // Sleepy when idle
    } else {
      avatarRef.current.setExpression("normal"); // Normal face during call
    }
  }, [status, emailCaptured]);

  // Connect to Ultravox
  useEffect(() => {
    const session = new UltravoxSession();

    session.addEventListener("status", () => {
      setStatus(session.status); // speaking | listening | thinking | idle
    });

    session.registerToolImplementation("captureEmail", () => {
      setEmailCaptured(true);
      return "Email captured";
    });

    session.joinCall(joinUrl);
  }, []);

  return <canvas ref={canvasRef} width={80} height={80} />;
}

Key Pattern:

  • setState() controls animations (mouth moving when speaking, head bobbing when idle)
  • setExpression() controls face geometry (happy eyes, sleepy eyes, etc.)
  • Always call both - they work as layers, not alternatives

Features

  • Micro-movements: Each expression has a tiny animation when triggered
  • Blush levels: 0-1 intensity (0.5 = medium, 1 = big)
  • Custom expressions: Add your own with createAvatar
  • Zod validation: Type-safe configs with validation
  • Social size: Built-in zoom support for profile pictures

License

MIT