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

canvacord-gif

v1.0.0

Published

Render GIFs for Canvacord using worker threads.

Downloads

107

Readme

canvacord-gif

🚀 High-performance GIF renderer for Canvacord using Worker Threads — zero blocking, scalable, production-ready.

npm license node


✨ Features

  • Worker Threads + Worker Pool → No event-loop blocking
  • 🎞️ Render Canvacord JSX → PNG → Animated GIF
  • 🧠 Smart job queue + concurrency control
  • 🧩 Plug & play for Discord bots
  • 🛡️ Type-safe (TypeScript)
  • 📦 Ready for production & scaling

📦 Installation

npm install canvacord-gif

or

yarn add canvacord-gif

🚀 Quick Start

Example: Render Welcome GIF

import { GifRenderer } from "canvacord-gif";
import path from "path";

const renderer = new GifRenderer({
  workers: 4,
  background: path.join(__dirname, "bg.gif"),
  delay: 120,
});

const buffer = await renderer.render({
  template: path.join(__dirname, "WelcomeCard"),
  props: {
    avatar: "https://cdn.discordapp.com/avatars/...",
    displayName: "Ziji",
    type: "welcome",
    message: "Welcome to the server!",
  },
  width: 930,
  height: 280,
});

await renderer.close();

🧩 Template Example

WelcomeCard.tsx

import { JSX, Builder, loadImage, FontFactory, Font } from "canvacord";

/** @jsx JSX.createElement */
/** @jsxFrag JSX.Fragment */

export default class WelcomeCard extends Builder {
  constructor(width = 930, height = 280) {
    super(width, height);

    this.bootstrap({
      displayName: "",
      type: "welcome",
      avatar: "",
      message: "",
    });

    if (!FontFactory.size) Font.loadDefault();
  }

  setDisplayName(v: string) {
    this.options.set("displayName", v);
    return this;
  }

  setType(v: "welcome" | "goodbye") {
    this.options.set("type", v);
    return this;
  }

  setAvatar(v: string) {
    this.options.set("avatar", v);
    return this;
  }

  setMessage(v: string) {
    this.options.set("message", v);
    return this;
  }

  async render() {
    const { displayName, avatar, message, type } =
      this.options.getOptions();

    const image = await loadImage(avatar);

    return (
      <img className="w-full h-full bg-[#23272A] flex items-center">
        <div className="flex items-center px-10">
          <img
            src={image.toDataURL()}
            className="w-[96] h-[96] rounded-full"
          />

          <div className="flex flex-col ml-8">
            <h1 className="text-white text-5xl font-bold">
              {type === "welcome" ? "Welcome" : "Goodbye"}{" "}
              <span className="text-blue-400">{displayName}</span>
            </h1>

            <p className="text-gray-300 text-3xl mt-2">
              {message}
            </p>
          </div>
        </div>
      </img>
    );
  }
}

⚙️ API

new GifRenderer(options)

interface RendererOptions {
  workers?: number;   // default: 2
  background: string;
  delay?: number;    // frame delay in ms, default: 200
}

renderer.render(payload)

interface RenderPayload<T = any> {
  template: string;  // absolute path to JSX template
  props: T;
  width: number;
  height: number;
}

Returns:

Promise<Buffer>

renderer.close()

Gracefully terminates worker pool.


🧠 Why Worker Threads?

Without workers:

main thread → build image → encode gif → BLOCKED

With canvacord-gif:

main thread → send job → workers → encode gif → return buffer

✅ Benefits:

  • Zero Discord bot lag
  • Handles burst joins smoothly
  • Scales across CPU cores
  • Stable under heavy workloads

📊 Performance

| Mode | 10 renders | | ----------------------- | ---------- | | Single-thread | ~4200ms | | Worker Pool (4 threads) | ~680ms |

~6× faster under load ⚡


🏗 Architecture

Main Thread
   ↓
 Worker Pool (N threads)
   ↓
 Canvacord JSX → PNG
   ↓
 GIF Encoder
   ↓
 Buffer → Discord

🛠 Best Practices

  • Use 2–4 workers for most bots
  • Do NOT spawn a worker per request
  • Reuse one GifRenderer instance
  • Close pool on shutdown

📌 Roadmap

  • [ ] Template Registry
  • [ ] Preset Templates (welcome / goodbye / rank / level)
  • [ ] CLI Renderer
  • [ ] Benchmark Suite
  • [ ] Dynamic Video → GIF backgrounds

🤝 Contributing

PRs are welcome! Feel free to open issues or feature requests.

👉 https://github.com/zijipia/canvacord-gif/issues


📜 License

ISC © 2026 Ziji


⭐ Support

If this package helped you, please give it a star ⭐ It helps the project grow ❤️