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

@oh-just-another/renderer-canvas

v0.59.0

Published

Canvas2D rendering backend: a RenderTarget over CanvasRenderingContext2D, built-in shape renderers, and hi-DPI multi-layer DOM helpers.

Readme

@oh-just-another/renderer-canvas

Canvas2D and WebGL2 backends for the diagram render kernel.

L2 package. Implements RenderTarget from @oh-just-another/renderer-core over CanvasRenderingContext2D and WebGL2, plus DOM helpers for hi-DPI, multi-layer composition, tiling, command recording, and offscreen/worker rendering. Browser-only — depends on HTMLCanvasElement, OffscreenCanvas and window.devicePixelRatio. For headless rendering (Node), use @oh-just-another/renderer-svg.

Quick start

import { renderScene } from "@oh-just-another/renderer-core";
import { createLayeredSurface, installBuiltinRenderers } from "@oh-just-another/renderer-canvas";

// Once per app: tell renderer-core how to draw each built-in shape type.
installBuiltinRenderers();

const host = document.getElementById("stage")!;
const surface = createLayeredSurface(host, 1000, 600);
renderScene(scene, surface.get("main"));

API

Render targets

| Name | Purpose | | ----------------- | --------------------------------------------------------------------------------- | | Canvas2DTarget | RenderTarget over CanvasRenderingContext2D. CSS-pixel coordinate space. | | WebGL2Target | RenderTarget backed by a WebGL2 context. | | RecordingTarget | RenderTarget that captures draw calls as RenderCommand[] instead of painting. | | replayCommands | Replays a recorded RenderCommand[] against another RenderTarget. | | RenderCommand | Serializable record of a single captured draw call. |

Layered surface

| Name | Purpose | | ---------------------------------- | --------------------------------------------------------------------------------------------------- | | createLayeredSurface | Builds a LayeredSurface over the chosen RendererBackend (CreateLayeredSurfaceOptions). | | createLayeredSurfaceWithFallback | Same, falling back to an available backend when the preferred one is unsupported. | | LayeredSurface | Stacked <canvas> per LayerName (background/main/overlay); get(name) returns its target. | | LayeredCanvas | Lower-level Canvas2D-only layer manager (LayeredCanvasOptions). |

Tiling and hi-DPI

| Name | Purpose | | ---------------- | ----------------------------------------------------------------------- | | renderViaTiles | Renders a scene in tiles and composites them (RenderViaTilesOptions). | | setupHiDpi | Configures bitmap size, CSS size and context transform for hi-DPI. |

Backend detection

| Name | Purpose | | ------------------------- | -------------------------------------------------------------- | | isWebGPUAvailable | Reports whether the runtime exposes WebGPU. | | isWebGL2Available | Reports whether a WebGL2 context can be created. | | pickAvailableBackend | Chooses a supported RendererBackend for the current runtime. | | supportsOffscreenCanvas | Reports whether OffscreenCanvas is available. |

Workers and offscreen

| Name | Purpose | | -------------------------------- | -------------------------------------------------------------------------- | | createRenderWorker | Worker entry point that renders an offscreen canvas off the main thread. | | createOffscreenCanvas2DTarget | Wraps an OffscreenCanvas as a Canvas2DTarget. | | transferCanvasToWorker | Transfers a canvas's control to a worker via transferControlToOffscreen. | | WorkerPool / LayerWorkerPool | Re-exported from @oh-just-another/renderer-workers. |

Shapes and text

| Name | Purpose | | ------------------------- | ----------------------------------------------------------------------------------------------------------------------- | | installBuiltinRenderers | Registers renderers for built-in shape types. Call once at startup. Re-exported from @oh-just-another/renderer-core. | | wrapText | Greedy word-wrap by measureText (WrapOptionsWrappedLine[]). Re-exported from @oh-just-another/renderer-core. | | Canvas2DTextShaper | Measures and shapes text via a CanvasRenderingContext2D. |

Design notes

  • Auto-install is intentionally absent. Calling installBuiltinRenderers() is a single line in the host entry. In exchange the package keeps sideEffects: false and tree-shaking stays predictable.
  • DPR handled at the canvas level, not on every draw. setupHiDpi scales the bitmap and sets a transform once; Canvas2DTarget operates entirely in CSS pixels.
  • One canvas per logical layer. Background and main canvases have pointer-events: none; the overlay receives input, keeping static content cached even when the overlay re-paints every frame.
  • Backend choice is explicit but guarded. Pick a RendererBackend directly, or let createLayeredSurfaceWithFallback / pickAvailableBackend select one supported by the runtime.
  • Scenes above LARGE_SCENE_WORKER_THRESHOLD are good candidates for offscreen/worker rendering via createRenderWorker and the WorkerPool re-exports.