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

vscode-shiki-bridge

v0.5.2

Published

Embed Shiki code blocks in VS Code, inheriting the user's themes and languages

Readme

vscode-shiki-bridge

🌉 Extracts the user's VS Code theme and language grammars for Shiki

Why?

VS Code doesn't provide a built-in way to render syntax-highlighted code blocks in webviews that match the user's current theme and installed language extensions. This library solves that by extracting the user's VS Code configuration (themes & language grammars) and passing it to Shiki, so you can render code blocks that look exactly like the editor.

Installation

npm install vscode-shiki-bridge shiki

Usage

import { createHighlighter } from "shiki";
import { getUserTheme, getUserLangs } from "vscode-shiki-bridge";

const [theme, themes] = await getUserTheme();
const langs = await getUserLangs(["graphql"]);
// Create Shiki highlighter with the extracted themes and langs
const highlighter = await createHighlighter({ themes, langs });

// Highlight GraphQL code with the user's theme
const html = highlighter.codeToHtml(
  `type User {
    name: String
    age: Int
}`,
  {
    lang: "graphql",
    theme,
  }
);

Results

VS Code Shiki Bridge Example

API

Themes

UserThemeResult

A tuple containing a theme id, and an array containing the ThemeRegistration.

export type UserThemeResult = [id: string, themes: [ThemeRegistration]];

getUserTheme

Get a UserThemeResult for the currently active theme.

async function getUserTheme(): Promise<UserThemeResult>;

getTheme

Get a UserThemeResult for the given themeName. The themeName can be its label or id. VS Code themes will define at least on of these (usually the label), vscode-shiki-bridge will resolve it to the correct theme.

async function getTheme(themeName: string): Promise<UserThemeResult>;

Languages

LanguageRegistrationExtended

The LanguageRegistration interface from shiki with the following VS Code specific properties preserved:

getUserLangs

Collect the LanguageRegistrationExtended objects for the languages supported by VS Code extensions. If languageIds is provided only those language ids will be collected.

async function getUserLangs(languageIds?: string[]): Promise<LanguageRegistrationExtended[]>;

LanguagesResult

The same result from getUserLangs but with some utility methods to resolve aliases and file extensions.

Also check the languages namespace of the vscode api for how documents are resolved to its programming language.

interface LanguagesResult {
  langs: LanguageRegistrationExtended[];
  /**
   * Get the language registration for the given language id.
   * Will resolve language id if it is an alias.
   *
   * Returns `undefined` if there is no language registration for the given language id.
   *
   * @example
   * ```ts
   * const result = getUserLangs(['tsx']);
   *
   * const resolvedLanguageId = result.get('tsx');
   * //    ^? LanguageRegistration { name: 'typescriptreact', ... }
   * ```
   */
  get(languageId: string): LanguageRegistrationExtended | undefined;
  /**
   * A helper function to resolve a possible alias to its language id.
   * The language registrations always use the resolved alias as its `name` property.
   * All its aliases can be found under the `aliases` property.
   *
   * @example
   * ```ts
   * const result = getUserLangs(['tsx']);
   *
   * const resolvedLanguageId = result.resolveAlias('tsx');
   * //    ^? 'typescriptreact'
   * ```
   */
  resolveAlias(languageId: string): string;
  /**
   * A helper function to resolve an `.ext` extension to its language id.
   * @example
   * ```ts
   * const result = getUserLangs(['handlebars']);
   *
   * const resolvedLanguageId = result.resolveExtension('.hbs');
   * //    ^? 'handlebars'
   */
  resolveExtension(extension: string): string;
}

Examples

Check the example/ directory for complete examples on how to use vscode-shiki-bridge. To test the library, check out the repository and follow the instructions below

Development and Debug

  1. Open the project in VS Code / Cursor
  2. install dependencies with npm i
  3. Press F5 to start debugging (opens a new VS Code window with the example extension)
  4. Run the "Shiki Preview" command from the Command Palette to see your highlighted code blocks
  5. Make changes and reload the window to test

Documentation

See the docs/ directory for documentation on how this library bridges the gap from VS Code Highlighting to Shikis Custom Themes and Custom Languages.

License

MIT