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

@reference-ui/core

v0.0.3

Published

Reference UI core

Readme

@reference-ui/core

Reference UI CLI – design system build pipeline.

Commands

ref sync (default)

Build and sync the design system. Uses workers and the event bus.

ref clean

Removes the output directory (.reference-ui by default, or config.outDir). Runs in the main thread only. Use before tests for a fresh state.

Architecture

Workers run in separate threads (Piscina); they communicate via BroadcastChannel. The main thread wires flow; workers map events to handlers.

Principle: Logic in handler functions; worker file is wiring only.

Event registry

src/events.ts – type union of all events. Each domain defines its slice; the event bus imports for typed emit/on.

// events.ts
export type Events = SyncEvents & VirtualEvents & WatchEvents

workers.json ↔ Thread pool

The pool exposes workers (registry of all possible workers). Manifest keys map to dist/cli/${name}/worker.mjs. workerEntries feeds tsup. Keys only – values exist for tsup paths.

Flow

  1. Main thread bootstraps, wires flow in an events module.
  2. Module inits spawn workers via workers.runWorker(name, payload).
  3. Workers subscribe with on(...), return KEEP_ALIVE to stay alive.
  4. Events flow via BroadcastChannel; all threads react.

Module pattern

Worker = flat on(event, handler) list. Logic = handler functions in one file. Orchestration = events module (routing, emit).

Layout: init.ts (spawns worker), worker.ts (wiring only), events.ts (module event types).

Worker

Flat list only. No conditionals, no branching. Multiple handlers per event is fine.

import { emit, on } from '../lib/event-bus'
import { KEEP_ALIVE } from '../lib/thread-pool'
import { copyAll } from './copy-all'

export default async function runVirtual(payload: VirtualWorkerPayload): Promise<never> {
  const handler = () => {
    copyAll(payload).catch((err) => console.error('[virtual] Copy failed:', err))
  }

  on('run:virtual:copy:all', handler)
  emit('virtual:ready')

  return KEEP_ALIVE
}

Logic

Pure handler functions. They receive payloads; they emit events. No on here.

import { emit } from '../lib/event-bus'

export async function copyAll(payload: VirtualWorkerPayload): Promise<void> {
  // ... do work ...
  emit('virtual:complete')
}

Event wiring (orchestration)

on('virtual:ready', () => emit('run:virtual:copy:all'))
on('watch:change', () => emit('run:virtual:copy:all'))
on('virtual:complete', () => emit('sync:complete'))

Adding a module

  1. Add to workers.json.
  2. Create worker.ts (flat on list), logic file (handlers), init.ts (spawn).
  3. Wire init in the command entry point.
  4. Define new events in registry if needed.

See src/virtual/ for a working example.