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

@hudhod/core

v1.1.0

Published

Headless runtime for hudhod — file system, search, diff, process, command, and extension host services for an in-browser IDE.

Readme

@hudhod/core

The headless runtime behind hudhod, an in-browser IDE built on WebContainers.

This package implements the API described by @hudhod/sdk: file system, search, diff, process, command, and extension-host services. It contains no UI and no framework code — no React, no state library — so it can be driven by any front end and unit tested in plain Node.

Install

pnpm add @hudhod/core @hudhod/sdk

Use @hudhod/webcontainer when a browser host needs WebContainer adapters.

Entry points

| Import | Environment | Contents | | ---------------------- | ----------- | -------------------------------------------- | | @hudhod/core | Any | Services, runtime factory, extension host | | @hudhod/webcontainer | Browser | WebContainer filesystem and process adapters |

The split is deliberate. @webcontainer/api requires SharedArrayBuffer and cross-origin isolation, so it cannot load in Node. Keeping those adapters in a separate package means the main entry stays importable from tests, scripts, and server code — which is what makes the runtime testable without a browser.

// Safe anywhere.
import { DisposableStore, Emitter } from "@hudhod/core";

// Browser only.
import { createWebContainerServices } from "@hudhod/webcontainer";

Base primitives

Disposable and DisposableStore

Every subscription returns a Disposable. DisposableStore collects them and releases them together, newest-first:

import { DisposableStore, toDisposable } from "@hudhod/core";

const store = new DisposableStore();
store.add(emitter.event(handler));
store.add(toDisposable(() => socket.close()));
store.dispose();

Two behaviours are worth knowing:

  • Adding to an already-disposed store disposes the argument immediately, so a late registration cannot leak.
  • If one disposable throws, the rest still run; the failures are collected and rethrown together as an AggregateError.

Emitter

The Event<T> producer:

import { Emitter } from "@hudhod/core";

const emitter = new Emitter<string>();
const sub = emitter.event((name) => console.log(name));
emitter.fire("world");
sub.dispose();

fire() iterates a snapshot of the listener set, so subscribing or unsubscribing during dispatch cannot disturb the in-flight delivery. A throwing listener is reported to onListenerError rather than propagating to whoever called fire() — a producer usually cannot do anything useful about a consumer's bug.

CancellationTokenSource

import { CancellationTokenSource } from "@hudhod/core";

const source = new CancellationTokenSource();
const results = await search(query, source.token);
source.cancel();

Listeners registered after cancellation are invoked immediately, so a late subscriber cannot miss the signal. tokenFromAbortSignal() adapts a standard AbortSignal if you already have one.

Paths

hudhod paths are always absolute and POSIX-style, rooted at the workspace root. These helpers are deliberately independent of Node's path so behaviour is identical in the browser and free of platform separator quirks.

import { basename, dirname, isSubPath, joinPath, normalizePath } from "@hudhod/core";

normalizePath("/src//lib/../index.ts"); // "/src/index.ts"
joinPath("/src", "lib", "index.ts"); // "/src/lib/index.ts"
isSubPath("/src", "/src-old"); // false — whole segments only

normalizePath() throws InvalidPath for relative paths, null bytes, and any path traversing above the root. Every service normalises its inputs, so path traversal is rejected at the boundary rather than reaching the file system.

Errors

import { fileNotFound } from "@hudhod/core";

throw fileNotFound("/missing.ts"); // code: "FileNotFound", path: "/missing.ts"

Consumers should branch on error.code via isHudhodError() from @hudhod/sdk. Message text is not part of the contract.

Extensions

InProcessExtensionHost loads the curated, first-party extension modules used by hudhod. It validates each manifest with Zod before registration, supports onStartup, onCommand:*, onFileOpen:*, and onView:* activation events, and automatically disposes resources pushed onto context.subscriptions when an extension deactivates.

import { createHudhodRuntime } from "@hudhod/core";

const runtime = createHudhodRuntime({
  fileSystemProvider,
  processSpawner,
  windowUiProvider,
});
runtime.extensions.register(extension);
await runtime.extensions.activateByEvent("onStartup");

Concurrent activation triggers are deduplicated, so an extension's activate() hook runs once even if a view and command arrive together.

For a React/Dockview host, use createHudhodReactHost() and HudhodWorkbench from @hudhod/react. See COMPOSABLE-IDE-DEVELOPMENT.md.

Development

pnpm test          # run the suite
pnpm test:watch    # watch mode
pnpm test:coverage # coverage, enforced at 80%
pnpm typecheck

Tests run in Node against the in-memory file system provider — no browser and no WebContainer required.

License

MIT