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

@peakk/cygnus

v1.0.0

Published

A lightweight HTML preprocessor for native '.html' component files.

Readme

What is Cygnus?

Cygnus is an HTML preprocessor (not a framework & not a PHP) that adds component reuse, CSS injection, and variable templating to native .html files. It runs as a Vite plugin via @peakk/cygnus.

Cygnus is a library. You import its helpers in your own vite.config.js there's no scaffolding CLI.

Installation

npm install @peakk/cygnus
npm install -D vite

Note: Vite is a peer dependency. Cygnus will print a warning at startup if Vite is not installed.

Get Started

1. Create your project's vite.config.js (see templates/vite.config.js):

import { defineConfig } from 'vite';
import { cygnusPlugin } from '@peakk/cygnus';

export default defineConfig({
    root: 'src',
    build: {
        outDir: '../dist',
        emptyOutDir: true
    },
    server: {
        fs: { strict: false }
    },
    plugins: [cygnusPlugin()]
});

2. Add scripts to your package.json:

{
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  }
}

3. Create src/index.html:

@name('My App')

<html lang="en">
<body>
    <h1>Hello Cygnus</h1>
</body>
</html>

4. Run:

npm run dev

That's it. A complete starter (vite.config.js, src/index.html, README) lives in the templates/ folder of the package copy it into your project and edit.

Syntax Reference

@name() : auto-generate <head>

@name('My App', './favicon.ico')

@using : inject component

@using "#nav" from "./components/nav.html"

@using CSS : inject stylesheet

@using CSS "dialog.css"

*name.create() : reusable variable

*badge.create(<span class="badge">New</span>)

@using "#item1" from *badge
@using "#item2" from *badge

Cross-file variable

<!-- card.html -->
*card.create(<div class="card"><h3>Hello</h3></div>)
<!-- index.html -->
@using "#x" from *card in "card.html"

toggle() : runtime class toggle

<button onclick="toggle('dialog')">Open</button>

API

The package exports two layers of helpers from @peakk/cygnus:

Vite plugin (high-level):

  • cygnusPlugin(opts) Vite plugin factory; the main thing you import
  • processCygnusHtml(html, opts) run a single HTML string through the pipeline
  • copyDirWithHtml(src, dest, isBuild) recursively copy a folder, processing .html files
  • safeResolve(base, request, root) path-traversal-safe resolver
  • HAS_DECL_RE regex detecting any Cygnus directive in HTML

Core pipeline (low-level):

  • extractCalls, extractCssLinks, extractName, strip (from parse.js)
  • extractVars, stripVars, interpolatePrimitives (from vars.js)
  • rebuild (from inject.js)
  • buildErrorOverlay (from error-overlay.js)

If you want to embed Cygnus in a non-Vite pipeline, use the low-level helpers directly.

License

MIT LICENSE.md