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

@svjeez/code

v0.6.1

Published

Syntax highlighting for svjeez: source text to role-tagged runs that code() and terminal() color from the scene's theme.

Readme

@svjeez/code

Syntax highlighting for svjeez scenes. highlight() tokenizes source text with Shiki while the scene compiles and gives back runs tagged with a role, such as keyword, string or fn. code() and terminal() color those roles from the scene's theme, so a highlighted snippet follows adaptive() and variables() between light and dark, and the SVG it ends up in is still one file with no JavaScript.

Shiki's own tokens carry fixed hex colors. Those ignore the scene's theme, which is why this package emits roles instead.

Install

npm i -D @svjeez/code svjeez

Use

import { highlight } from "@svjeez/code";
import { render } from "svjeez";
import { code, defaultDark } from "svjeez/extras";

const source = `export const greet = (name: string) => \`hello \${name}\`;`;
const snippet = code(highlight(source, "ts"), { x: 24, y: 24, fontSize: 20, theme: defaultDark });

export default () =>
  render({ width: 640, height: 72, duration: 1, title: "Greeting" }, snippet.node);

highlight(source, lang, options) returns CodeTokens: one array per line, each piece either a bare string for plain text or a [role, text] pair. Neighbouring runs of the same role are merged. highlight() is synchronous, so a scene stays export default () => render(...).

The options are:

  • tabSize, the spaces per tab stop. code() lays out one column per character, so tabs become spaces. It defaults to 2.
  • grammars, extra Shiki grammars for languages the package does not bundle.

Languages

These names, and their aliases, work out of the box: ts, tsx, js, jsx, json, css, html, bash (also sh, shell, zsh), python, rust, go, sql, yaml, md and diff. HTML highlights its embedded CSS and JavaScript, and Markdown highlights the fenced code blocks it can resolve.

For any other language, import its grammar from Shiki and pass it in:

import toml from "shiki/langs/toml.mjs";

highlight('name = "svjeez"', "toml", { grammars: [toml] });

A name that is neither bundled nor passed throws highlight() does not know the language "…". It knows: ….

Roles

src/scopes.ts is one table from TextMate scope prefix to role, and the longest matching prefix wins. A token that no row matches is plain. The roles are the ones svjeez/extras defines: plain, comment, punct, keyword, fn, string, number, constant, type, variable and tag, plus red, green, yellow and cyan for diffs. A theme that wants a different look changes the colors of its slots, and a theme cannot tell the roles apart if it gives two slots one color.

Notes

The package runs Shiki's JavaScript regex engine, so there is no WebAssembly to load, and it works on Node 20 and later and in bundlers. Importing it loads the default grammars, which takes a few hundred milliseconds once.