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

@gwenjs/renderer-core

v0.4.2

Published

Contract package for Gwen renderer plugins. Zero graphical dependencies — only TypeScript interfaces, the `LayerManager`, stats utilities, and error types.

Downloads

433

Readme

@gwenjs/renderer-core

Contract package for Gwen renderer plugins. Zero graphical dependencies — only TypeScript interfaces, the LayerManager, stats utilities, and error types.

Installation

npm install @gwenjs/renderer-core

What's included

| Export | Description | | -------------------------------- | ------------------------------------------------------- | | RendererService | Interface every renderer plugin must implement | | RENDERER_CONTRACT_VERSION | Version constant used for compatibility validation | | LayerManager | Sorts and mounts renderer DOM layers, propagates resize | | RendererStatsCollectorImpl | Ring-buffer stats collector (dev/debug only) | | RendererAlreadyRegisteredError | Thrown on duplicate renderer registration | | RendererContractVersionError | Thrown on contract version mismatch | | UnknownLayerError | Thrown when accessing an undeclared layer |

Testing utilities are available under a separate entry point:

import { runConformanceTests } from "@gwenjs/renderer-core/testing";

Building a renderer plugin

A renderer plugin exports a RendererService and installs it into the engine via LayerManager.

import type { RendererService } from "@gwenjs/renderer-core";
import { RENDERER_CONTRACT_VERSION } from "@gwenjs/renderer-core";

export const canvasService: RendererService = {
  name: "renderer:canvas",
  contractVersion: RENDERER_CONTRACT_VERSION,
  layers: {
    game: { order: 10 },
  },
  mount(root) {
    /* attach canvas to root */
  },
  unmount() {
    /* cleanup */
  },
  resize(w, h) {
    /* resize canvas */
  },
  getLayerElement(layerName) {
    return canvasEl;
  },
};

Use runConformanceTests in your plugin's test suite to verify your service implements the contract correctly:

import { runConformanceTests } from "@gwenjs/renderer-core/testing";

// Throws with a descriptive message on the first violation — use inside a test:
it("satisfies the RendererService contract", () => {
  expect(() => runConformanceTests(myService)).not.toThrow();
});

See docs/kit/custom-renderer.md for the full step-by-step guide.

Layer ordering

Each layer has an order number. LayerManager sorts all layers from all registered renderers by order ascending and inserts their DOM elements with matching z-index. Lower order = further back.

order  0  →  background  (world space)
order 10  →  game canvas (world space)
order 100 →  HUD overlay (screen space, pointer-events: none)

Duplicate order values trigger a console.warn — they are not an error, but you should resolve conflicts.

Stats (dev only)

Stats collection is disabled by default. Enable it via LayerManager.enableStats() (called by the engine in dev/debug mode):

manager.enableStats();
manager.mount();

const stats = manager.getStats();
// stats.renderers['renderer:canvas'].frameTimeMs  — scalar for this frame
// stats.totalDrawCalls                            — accumulated total draw calls
// stats.history.drawCalls[0]                      — draw calls for one frame in the 60-frame ring buffer