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

@hecto/svg

v3.0.0

Published

Typed procedural SVG nodes, paths, transforms, paint, filters, and rendering.

Readme

@hecto/svg

Typed procedural SVG nodes, paths, transforms, paint, filters, definition hoisting, and rendering.

pnpm add @hecto/svg
import { pipe } from '@hecto/fp'
import { rgb } from '@hecto/color'
import { circle, fill, render, translate, viewBox } from '@hecto/svg'

const base = circle(32)
const moved = translate(base, 50, 50)
const painted = fill(moved, rgb(1, 0, 0))
const directBadge = viewBox(painted, 0, 0, 100, 100)

const pipedBadge = pipe(base, translate(50, 50), fill(rgb(1, 0, 0)), viewBox(0, 0, 100, 100))

const markup = render(directBadge)
const sameMarkup = pipe(pipedBadge, render)

Data-taking operators support direct data-first and curried data-last calls under the same name. XML escaping, generated identifiers, and shared <defs> are owned by the renderer.

Resource identity across roots

Use a distinct stable idPrefix for each SVG that shares a document:

const leftMarkup = render(directBadge, { idPrefix: 'dashboard:left' })
const rightMarkup = render(pipedBadge, { idPrefix: 'dashboard:right' })

Pass the same prefix for the same root during server rendering and hydration. Prefixes are encoded without randomness or process-wide counters. Generated resources share one allocator that reserves authored attrs.id values throughout the render tree, including pattern, clip, mask and symbol contents. Repeated references to one resource object still share one definition.

Omitting idPrefix retains the standalone _g0/_s0 naming convention. It does not provide uniqueness across separate render calls. Authored IDs are preserved; callers must also keep their authored IDs unique across roots in one document. Separate calls cannot discover IDs authored in other roots. If authored IDs can fall inside another root's generated namespace, provide those IDs through reservedIds on every affected render:

const authoredDocumentIds = new Set(['svg-00720069006700680074-g0'])
const safeMarkup = render(directBadge, {
  idPrefix: 'right',
  reservedIds: authoredDocumentIds,
})

The renderer copies these reservations and does not mutate the caller's set. Alternatively, keep authored IDs in a distinct naming scheme from generated IDs.

Hit-test limits

hitTest from @hecto/svg/la does not implement path or line containment. These nodes return no hit even when the point appears inside a painted path. Text uses only its baseline, font size and starting x coordinate; it does not measure glyph width, so a point far to the right can still match. Use a measured rectangle for text interaction bounds or a browser geometry API when exact path or text hit testing is required. Existing transforms continue to use LA affine operations; these limits do not change rendering or matrix behavior.

Dual operation reference

toClip(node)                         / toClip()(node)
toMask(node)                         / toMask()(node)
fill(node, paint)                    / fill(paint)(node)
stroke(node, paint, width, options?) / stroke(paint, width, options?)(node)
opacity(node, alpha)                 / opacity(alpha)(node)
translate(node, dx, dy)              / translate(dx, dy)(node)
rotate(node, degrees, cx?, cy?)      / rotate(degrees, cx?, cy?)(node)
scale(node, sx, sy?)                 / scale(sx, sy?)(node)
skewX(node, degrees)                 / skewX(degrees)(node)
skewY(node, degrees)                 / skewY(degrees)(node)
clip(node, clipPath)                 / clip(clipPath)(node)
mask(node, maskValue)                / mask(maskValue)(node)
filter(node, filterValue)            / filter(filterValue)(node)
viewBox(node, x, y, width, height)   / viewBox(x, y, width, height)(node)

path.lineTo(pathValue, x, y)                         / path.lineTo(x, y)(pathValue)
path.curveTo(pathValue, x1, y1, x2, y2, x, y)       / path.curveTo(x1, y1, x2, y2, x, y)(pathValue)
path.quadTo(pathValue, x1, y1, x, y)                 / path.quadTo(x1, y1, x, y)(pathValue)
path.arcTo(pathValue, rx, ry, large, sweep, x, y)    / path.arcTo(rx, ry, large, sweep, x, y)(pathValue)
path.close(pathValue)                                / path.close()(pathValue)
path.toNode(pathValue)                               / path.toNode()(pathValue)

mul(a, b)                            / mul(b)(a)
render(node, options?)

lerpTransform(a, b, t)               / lerpTransform(b, t)(a)
toQuad(node, corners)                / toQuad(corners)(node)
hitTest(root, point)                 / hitTest(point)(root)
fitBezier(points)                    / fitBezier()(points)
alignToPrincipalAxis(node, points)   / alignToPrincipalAxis(points)(node)
symmetry(node, count, step)          / symmetry(count, step)(node)

Documentation