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

aispritejs

v0.6.0

Published

Input-driven, renderer-agnostic 2D sprite animation runtime — a tiny, Rive-like visual state machine driven by Number / Boolean / Trigger inputs. JSON transition graph, deterministic update(dt), zero runtime dependencies. Browser / Node / Bun / Deno / Web

Readme

aispritejs

Input-driven, renderer-agnostic 2D sprite animation runtime. A JSON graph maps Number/Boolean/Trigger inputs to visual states and frames; adapters bind the chosen frame to a renderer.

Status: 0.6.0 - stable family-aligned surface. Core, PixiJS adapter, atlas parser, and JSON Schema subpath are shipped.

Install

pnpm add aispritejs
pnpm add pixi.js # only when using aispritejs/pixi
import { createSpriteAnimator } from "aispritejs";

Quick Start - Core

const anim = createSpriteAnimator({
  inputs: {
    speed: { type: "number", default: 0 },
    jump: { type: "trigger" },
  },
  initial: "idle",
  states: {
    idle: { animation: "idle", loop: true },
    run: { animation: "run", loop: true, speed: 1 },
    jump: { animation: "jump", loop: false, onEnd: "idle" },
  },
  transitions: [
    { from: "idle", to: "run", when: [{ input: "speed", op: "GreaterThan", value: 0 }] },
    { from: "*", to: "jump", when: [{ input: "jump", op: "Trigger" }] },
  ],
  animations: {
    idle: ["idle_0"],
    run: ["run_0", "run_1"],
    jump: ["jump_0", "jump_1"],
  },
});

anim.setInput("speed", 1);
anim.fireTrigger("jump");
anim.update(16.7);
console.log(anim.activeState, anim.activeFrameKey);

PixiJS Adapter

import { createPixiSpriteAnimator } from "aispritejs/pixi";

const view = createPixiSpriteAnimator(sprite, graph, spritesheet);
view.update(deltaMs);
view.dispose(); // disposes core animator; does not destroy the Pixi sprite

pixi.js is an optional peer dependency and is imported type-only by the adapter. The root package never imports Pixi, DOM, or canvas APIs.

Atlas and Schema

  • parseAtlas(atlas, control?) converts a PixiJS-v8 style atlas plus control block into a SpriteGraph.
  • loadAtlas(atlas, control?) parses and creates a SpriteAnimator.
  • aispritejs/schema exports schemas/aispritejs-graph.schema.json for editor/CI validation.
  • Parser validation is structural (InvalidAtlasError); compiler validation is semantic (InvalidGraphError).
  • An explicit control gets the same structural checks as a control block inside the atlas, and its initial / defaultFrameDuration must be a string / number (an atlas's own block drops wrong-typed ones).

Core API

  • createSpriteAnimator(graph) returns a SpriteAnimator; a malformed or invalid graph throws InvalidGraphError and builds nothing.
  • setInput(name, value) accepts Number/Boolean inputs.
  • fireTrigger(name) consumes Trigger inputs on transition.
  • update(deltaMs) advances time, transitions, frame index, and onEnd. A negative, non-finite, or overflowing step is clamped to no progress.
  • reset() returns to the initial state.
  • dispose() is idempotent; mutators throw SpriteAnimatorDisposedError afterward.
  • onStateChange(handler, options?) and onComplete(handler, options?) support once and signal.

Sharp Edges

  • Non-looping states with onEnd transition during the same update() tick that completes the clip.
  • reset()/update() called from inside onStateChange/onComplete run after the current update finishes (including its onEnd auto-transition); a reset() from onComplete therefore yields onStateChange(onEndTarget, from) then onStateChange(initial, onEndTarget), ending in the initial state; dispose() from a listener stops the update immediately.
  • AnimatedSprite is accepted by the Pixi adapter because it extends Sprite, but playback is stopped on bind so it cannot fight the adapter.
  • Every frame key in every declared animation must exist in the texture map/spritesheet — including an animation no state references — or the adapter throws MissingTextureError at construction. A null / undefined entry counts as missing.
  • A texture map with an object under the key textures is read as a Spritesheet; if a frame is literally named textures, pass the Spritesheet (or { textures: map }) instead of the bare map.
  • duration, defaultFrameDuration, and state speed must be finite numbers greater than zero.
  • initial, state animation / onEnd, transition from / to, and condition input / op must be strings, and a transition priority must be an integer.

AI Context

License

MIT