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-svg

v0.57.5

Published

Headless SVG rendering backend: turns a Scene into an SVG-string snapshot, running identically in Node and the browser.

Readme

@oh-just-another/renderer-svg

npm version

SVG rendering backend — turns a Scene into an SVG-string snapshot. Pure TS, no DOM, runs identically in Node and the browser. Designed for headless rendering, file export, and pixel-parity testing against the Canvas backend.

L2 backend for @oh-just-another/renderer-core. Depends only on @oh-just-another/types, @oh-just-another/math, @oh-just-another/scene, @oh-just-another/renderer-core.

Quick start

import { renderSceneToSvg } from "@oh-just-another/renderer-svg";
import { writeFile } from "node:fs/promises";

await writeFile("diagram.svg", renderSceneToSvg(scene));

For lower-level access — composing several scenes, controlling each draw call — instantiate SvgTarget directly and call renderScene(scene, target) followed by target.toSvg().

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

installBuiltinRenderers();
const target = new SvgTarget({ width: 800, height: 600 });
renderScene(scene, target);
const svg = target.toSvg();

API

| Name | Purpose | | --------------------------------------------- | ------------------------------------------------------------------------------------------------- | | SvgTarget | RenderTarget implementation backed by a string buffer. | | renderSceneToSvg(scene, options?) | One-shot helper: instantiates SvgTarget, runs renderScene, returns the SVG string. | | RenderSceneToSvgOptions | Options: width, height, measureText, skipInstall, plus the standard RenderSceneOptions. | | approxTextWidth(text, fontFamily, fontSize) | Char-ratio-based text measurer for environments without a text engine. |

Design notes

  • Coordinates are pre-baked into path data. Every moveTo / lineTo / quadraticCurveTo / bezierCurveTo call is multiplied by the current transform before being written. The emitted SVG has no nested <g transform> elements — output is flat, smaller, and easier to diff.
  • Path elements are flushed on fill() / stroke(). A single subpath can be both filled and stroked — those emit two <path> elements with different paint attributes, mirroring Canvas2D semantics.
  • ellipse() decomposes into 4 cubic Bezier curves (kappa ≈ 0.5523). SVG's native <ellipse> would be more compact, but every other shape goes through <path> already; the uniformity is worth the few extra bytes.
  • Text measurement is pluggable. Default approxTextWidth ratios match a system-ui sans-serif at 16px and are decent for ASCII; pixel-perfect callers supply their own measurer (typically wrapped around node-canvas or opentype.js).
  • clear() without bounds wipes the element buffer (matches "erase the surface" semantics); bounded clears emit a white <rect> so callers don't have to special-case the backend.