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

@iridium-editor/syntax-worker

v0.1.2

Published

Web Worker for tree-sitter syntax highlighting - moves parsing off the main thread

Readme

@iridium-editor/syntax-worker

The tree-sitter syntax worker for Iridium. It runs parsing and highlight queries on a Web Worker, so a large file being reparsed cannot drop a frame on the main thread.

Optional. @iridium-editor/core renders perfectly well without it — either unhighlighted, or with spans you supply yourself through setHighlightSpans().

Install

npm install @iridium-editor/syntax-worker @iridium-editor/core

@iridium-editor/core is a peer dependency: the grammars, the highlight queries and the client class all live there, and this package is the worker that drives them.

Use

Usually you do not touch this package directly — you turn the option on and the core resolves the worker itself:

await IridiumEditor.create(canvas, { enableSyntaxWorker: true });

That default finds this package as a sibling of @iridium-editor/core, which holds under npm, yarn and bun. Where it does not — pnpm's store layout, or a bundler that rewrites worker URLs — construct the worker yourself and hand it over:

await IridiumEditor.create(canvas, {
  enableSyntaxWorker: true,
  createSyntaxWorker: () =>
    new Worker(new URL("@iridium-editor/syntax-worker/worker", import.meta.url), {
      type: "module",
    }),
});

To drive it without the editor at all:

import { SyntaxHighlightClient } from "@iridium-editor/syntax-worker";

const client = new SyntaxHighlightClient(
  () => new Worker(new URL("@iridium-editor/syntax-worker/worker", import.meta.url), {
    type: "module",
  }),
);
const languages = await client.initialize("rust");
const result = await client.highlight(sourceText);

initialize resolves with the languages the worker loaded. Beyond highlight the client also offers highlightIncremental(content, editInfo) — which reuses the retained parse tree and is what the editor actually calls while you type — plus highlightRange, setLanguage, cancelPending and dispose.

⚠️ This package needs a bundler

dist/worker.js imports web-tree-sitter and @iridium-editor/core/syntax by bare specifier, and a module worker does not inherit the page's import map — there is no way to give a worker one. So on a page serving raw ES modules, no import map can make this worker load, whatever it says.

Your options on such a page are to leave the worker off and feed spans in through @iridium-editor/core's setHighlightSpans(), or to bundle a worker yourself and hand it over with createSyntaxWorker. Everything under a bundler — Vite, webpack, esbuild, Rollup — resolves both specifiers normally and needs none of this.

Exports

| specifier | what | |---|---| | @iridium-editor/syntax-worker | SyntaxHighlightClient and its types | | @iridium-editor/syntax-worker/worker | the worker entry point — the URL you pass to new Worker | | @iridium-editor/syntax-worker/protocol | the request/response message types |

Cost

Downloading and compiling a grammar takes 1–3 seconds on a large file, which is why the editor leaves this off by default. When highlighting can come from somewhere cheaper — a server, a language server, an existing index — prefer setHighlightSpans().

Offsets cross the boundary as UTF-8 byte offsets, matching the Rust core's rope. encoding.ts converts to and from the UTF-16 offsets JavaScript strings use; getting that wrong is the classic way to make highlighting drift on any line containing a non-ASCII character.

Licence

MIT. See LICENSE.