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

@solid-gpui/shiki

v0.5.2

Published

Shiki syntax highlighting for native Solid GPUI code blocks.

Readme

@solid-gpui/shiki

Shiki highlighting for selectable native Solid GPUI code blocks. The Bun backend uses one persistent Worker and Shiki 4.4.2's Oniguruma engine. GPUI shapes and paints the text; no HTML, DOM or WebView is involved.

# Keep the SDK packages on the same npm release.
bun add --exact @solid-gpui/shiki @solid-gpui/core solid-js
import { CodeBlock } from "@solid-gpui/shiki";
import { createBunHighlighter } from "@solid-gpui/shiki/bun";
import { onCleanup } from "@solid-gpui/core/runtime";

// Initialize once before mounting the application, then share the service.
const highlighter = await createBunHighlighter({
  languages: ["typescript", "tsx", "rust"],
  themes: ["github-dark", "github-light"],
});

function App() {
  onCleanup(() => highlighter.dispose());
  return (
    <CodeBlock
      highlighter={highlighter}
      code={'const message = "Hello, GPUI — 你好😀";\n'}
      language="typescript"
      theme="github-dark"
      style={{ fontSize: 14, lineHeight: 22 }}
    />
  );
}

Compile JSX with the Solid GPUI universal transform. Run the application through the host (solid-gpui-host bun --conditions=browser app.js) or through Vite; tests run with solid-gpui test, which selects Solid's client build for you, so --conditions=browser is only needed for a raw bun test/bun run invocation that bypasses both. Wrap the component in ErrorBoundary from @solid-gpui/core/runtime to present highlighting errors. If initialization fails before mounting, handle that rejected promise in the application entrypoint. An application that never mounts must dispose its service.

Component

CodeBlock accepts highlighter, code, language, theme, optional style, selectable (default true), accessibilityLabel, and onLayout.

Code, language, theme and highlighter changes request a new result. Pending work shows the current source without syntax styles, using the surrounding/caller's text colors. Only a result for the current request is displayed. Errors reach the Solid error boundary; they do not silently select another grammar or engine. The resolved theme controls the completed block's foreground and background; style controls layout and typography. The default font family is monospace; choose an installed code font using style.fontFamily if needed.

Runs share one native paragraph, so selection and copying cross token and line boundaries. Original Unicode and line endings are preserved. Tokenization runs only when the highlighting inputs change, never during native scrolling or resizing. Adjacent identical styles are coalesced. This is a bounded code block, not a virtualized file editor: source is limited to 64 KiB of UTF-8 and output to 4,096 styled runs. The component does not add line numbers, folding, editing, semantic tokens or DOM transformer support.

Colors, bold, italic, underline and strikethrough map to existing native inline styles. A token combining underline and strikethrough, or requesting an inline background, rejects because the current core inline style contract cannot express it. Theme colors must resolve to hexadecimal values; CSS-variable themes are not supported. Source containing unpaired surrogates rejects instead of being changed by UTF-8 encoding.

Service and lifetime

For static documentation, compute results in Bun during the build and render <HighlightedCode highlighted={result} />. It accepts the same appearance props as CodeBlock and does no asynchronous work or runtime loading. The documentation website uses this path for every code example; browsers receive serialized results and the renderer, without Shiki's tokenizer or Oniguruma WASM.

createBunHighlighter({ languages, themes, timeoutMs? }) resolves after loading the selected bundled assets and their grammar dependencies. Load 1–32 languages and 1–8 themes. Unknown/unloaded language or theme requests reject. Shiki's loaded language aliases and plain-text language are accepted by the backend.

const result = await highlighter.highlight(
  { code, language: "typescript", theme: "github-dark" },
  { signal: abortController.signal },
);
// result: original request + foreground, background, runs
// run: { text, color, fontStyle } (resolved Shiki font flag bits)
highlighter.dispose();

The backend executes one request at a time and allows 32 queued requests. Cancelling a queued request removes it; cancelling an active request rejects that consumer immediately while the worker finishes its bounded slot. This does not terminate a shared service. The initialization/active-work deadline defaults to 30 seconds; timeoutMs accepts integers from 1 to 300,000. Expiry terminates the worker and rejects all requests. Create a new service explicitly after a terminal failure. Shiki's soft line timeout is disabled so incomplete tokens are not published as successful results. Worker termination supplies the hard deadline.

dispose() is idempotent, terminates the worker and rejects pending/future work. A CodeBlock cancels its own request on change/unmount, but never disposes the shared backend. The application owns backend disposal, including hot reload and transport shutdown. No process-global highlighter or unbounded result cache exists.

CodeHighlighter and CodeBlock have no Bun imports. A future QuickJS backend can implement the same asynchronous interface; QuickJS is not supported today. The current backend is qualified for Bun child-process applications. Embedded Bun and standalone compiled executables need separate runtime/asset qualification.

Packaging and example

The runtime resolves @solid-gpui/shiki/worker from the installed package. Deploy the package's dist directory and its Shiki dependencies with the application; copying only an application bundle is insufficient. Keep @solid-gpui/shiki as an installed application dependency even if the main application is bundled. The worker subpath is an internal asset entrypoint, not a component to import. Build tools supplying a separate Worker artifact can pass its URL as workerURL to createBunHighlighter. The repository website points this at the package's Worker source so its source-based Vite build needs no native package compilation.

From this repository:

bun run task package-build
cargo run -p solid-gpui --bin solid-gpui-host -- \
  bun --conditions=browser packages/solid-gpui-shiki/examples/code-block.ts
bun run task package-build
(cd packages/solid-gpui-shiki && bun pm pack --dry-run)

The example uses ordinary functions and needs no JSX compilation. It exercises TypeScript/Rust, dark/light themes and native selection. Tests cover the actual worker, Unicode/CRLF, the emoji/comment regression, invalid requests, cancellation, disposal, and stale component results.

This package's code is MIT. Shiki and its bundled languages/themes retain their own upstream notices; include those notices when distributing the selected assets.