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

bugcat-devtools

v0.1.0

Published

A 3D animated cat that catches, explains and source-maps your JavaScript errors right inside the page.

Downloads

375

Readme

BugCat

A 3D cat that catches your JavaScript errors — right inside the page.

BugCat sits in the corner of your app while you develop. When something throws, the cat reacts, and one click shows you the error, where it happened in your original source (via source maps), a real code frame and the stack trace — without opening the browser console.

BugCat panel showing a source-mapped TypeError with a code frame

The cat's six states: idle, alert, error, success, thinking, sleeping

Screenshots are taken from the bundled React + Vite playground (npm run example:react).

  • Real debugging engine: uncaught errors and unhandled promise rejections, normalised, grouped and counted.
  • Original locations: resolves source maps in the browser and shows the true file, line, column and code.
  • Framework adapters: React error boundary with component stacks; Vite plugin for compile errors.
  • Zero interference: never overrides window.onerror, never calls preventDefault, never swallows an error.
  • Isolated UI: Shadow DOM, no global CSS, CSP-friendly, keyboard accessible.
  • Private by design: no network calls to third parties, no telemetry, nothing persisted.
  • Lightweight cat: Three.js loads lazily, renders at low power, pauses in hidden tabs, respects reduced motion, and falls back to a 2D cat without WebGL.

Contents

Install

npm install --save-dev bugcat-devtools
pnpm add -D bugcat-devtools
# or
yarn add -D bugcat-devtools

three and @jridgewell/trace-mapping are installed automatically. react and vite are optional peer dependencies — only needed if you use those adapters.

Quick start

The fastest path with Vite — add the plugin and you're done. It only runs during vite dev, so nothing reaches production builds:

// vite.config.ts
import { defineConfig } from "vite";
import bugCat from "bugcat-devtools/vite";

export default defineConfig({
  plugins: [bugCat()],
});

Without Vite, initialise it yourself in development:

import { initBugCat } from "bugcat-devtools";

if (process.env.NODE_ENV !== "production") {
  initBugCat();
}

Trigger an error (undefinedFunction() in a click handler works) and watch the corner of the page.

Integrations

Vanilla JavaScript / TypeScript

import { initBugCat } from "bugcat-devtools";

const bugcat = initBugCat({
  position: "bottom-right",
  theme: "dark",
  maxErrors: 50,
  captureConsoleErrors: false,
  showCodeFrame: true,
});

// Report something you caught yourself:
try {
  riskyThing();
} catch (err) {
  bugcat.reportError(err, { severity: "warning" });
}

initBugCat() is idempotent: calling it again returns the existing instance. All types are exported:

import type { BugCatError, BugCatInstance, BugCatOptions } from "bugcat-devtools";

Vite

import bugCat from "bugcat-devtools/vite";

export default defineConfig({
  plugins: [
    bugCat({
      autoInit: true, // inject the client and call initBugCat() (default: true)
      options: { theme: "system" }, // forwarded to initBugCat() — JSON-serialisable fields only
      reportCompileErrors: true, // forward Vite compile/transform errors (default: true)
      disableViteOverlay: false, // hide Vite's own overlay so only BugCat shows them (default: false)
    }),
  ],
});

The plugin uses only documented Vite APIs: transformIndexHtml to inject a small client module, and the vite:error / vite:beforeUpdate HMR events. Compile errors appear with file, line, column, the failing plugin and Vite's code frame. When you save a file, the next HMR update clears them; if the file is still broken, Vite reports it again immediately.

Other plugins (for example a type checker) can push errors to BugCat through the plugin's API, which sends a custom HMR event:

const cat = bugCat();
// later, inside another plugin's hook:
cat.api.reportError({ message: "Type error", loc: { file: "/src/a.ts", line: 3, column: 4 } });
cat.api.clear();

The Vite plugin does not run a TypeScript type checker and cannot show anything when vite build fails — there is no page running in that case. See limitations.

React

import { BugCatErrorBoundary } from "bugcat-devtools/react";

function App() {
  return (
    <BugCatErrorBoundary>
      <MyApplication />
    </BugCatErrorBoundary>
  );
}

The boundary forwards render errors to BugCat with the React component stack, then renders a fallback.

| Prop | Type | Description | | ----------- | ---------------------------------------------- | --------------------------------------------------------------------------- | | fallback | ReactNode \| ({ error, reset }) => ReactNode | UI after a crash. Defaults to a small message with a "Try again" button. | | rethrow | boolean | Report, then re-throw so your existing boundary renders the UI instead. | | onError | (error: Error, info: ErrorInfo) => void | Called after reporting. | | resetKeys | unknown[] | Changing any value resets the boundary. |

Keep the cat outside the subtree you protect so a crash can't take it down. The Vite plugin and initBugCat() already mount it outside React. If you prefer a component:

import { BugCatWidget } from "bugcat-devtools/react";

<>
  <BugCatWidget options={{ theme: "dark" }} />
  <BugCatErrorBoundary>
    <App />
  </BugCatErrorBoundary>
</>;

Boundaries can report before the widget exists — those reports are queued in memory and appear once BugCat initialises.

React error boundaries do not catch errors in event handlers, asynchronous code (timers, promises), server-side rendering, or the boundary itself. BugCat's global listeners still capture uncaught event-handler and async errors at the window level.

Automatic entry

import "bugcat-devtools/auto";

This side-effect entry initialises BugCat once in the browser and does nothing in Node or during SSR. Importing it twice still creates a single cat. It stays off when your bundler sets process.env.NODE_ENV to "production", but only include it in development builds — for example with Vite:

if (import.meta.env.DEV) {
  import("bugcat-devtools/auto");
}

Options can be provided before it loads:

<script>
  window.BUGCAT_OPTIONS = { theme: "light", position: "bottom-left" };
</script>

API reference

initBugCat(options?): BugCatInstance

Creates (or returns the existing) instance. Returns an inert instance during SSR or with enabled: false — every method is a safe no-op.

BugCatInstance

| Method | Description | | --------------------------------- | ---------------------------------------------------------------------- | | show() / hide() | Show or hide the widget. Errors are still captured while hidden. | | open() / close() / toggle() | Control the debugging panel. | | reportError(error, options?) | Report any value. Returns the stored BugCatError (or undefined). | | getErrors() | Current errors, newest first (copies). | | subscribe(listener) | Called with the error list on every change. Returns an unsubscribe fn. | | dismiss(id) | Remove one error group. | | clear() | Remove everything. | | clearSource(source) | Remove errors from one source, e.g. "vite". | | destroy() | Remove all listeners, DOM, timers and the WebGL context. | | destroyed | true after destroy() (and for inert instances). |

Other exports

import { getBugCat, reportError, parseStack, formatErrorForCopy } from "bugcat-devtools";
  • getBugCat() — the active instance or undefined.
  • reportError(error, options?) — report to the active instance, or queue it until one exists.
  • parseStack(stack) — the stack parser (Chromium, Firefox, Safari formats).
  • formatErrorForCopy(error) — the plain-text format used by "Copy details".

ReportOptions

{
  severity?: "error" | "warning" | "info";
  source?: "runtime" | "promise" | "react" | "vite" | "console" | "manual";
  componentStack?: string;
  filename?: string; line?: number; column?: number;
  codeFrame?: string;
  plugin?: string;
}

BugCatError

interface BugCatError {
  id: string;
  type: string; // "TypeError", "UnhandledRejection", ...
  message: string;
  stack?: string;
  frames: StackFrame[]; // parsed stack
  filename?: string;
  line?: number;
  column?: number; // generated location
  originalFilename?: string;
  originalLine?: number;
  originalColumn?: number; // only when a source map resolved
  codeFrame?: string; // only from real source text
  componentStack?: string; // React
  plugin?: string; // Vite plugin that failed
  fingerprint: string;
  timestamp: number;
  firstSeen: number;
  count: number;
  severity: "error" | "warning" | "info";
  source: "runtime" | "promise" | "react" | "vite" | "console" | "manual";
}

Configuration

| Option | Type | Default | Description | | -------------------------- | -------------------------------------------------------------- | ---------------- | ------------------------------------------------------------------------ | | enabled | boolean | true | false attaches nothing and returns an inert instance. | | position | "bottom-right" \| "bottom-left" \| "top-right" \| "top-left" | "bottom-right" | Corner of the widget. | | theme | "dark" \| "light" \| "system" | "dark" | Panel theme. | | maxErrors | number | 50 | Distinct error groups kept; the oldest is dropped first. | | captureRuntimeErrors | boolean | true | Listen for uncaught errors. | | capturePromiseRejections | boolean | true | Listen for unhandled rejections. | | captureConsoleErrors | boolean | false | Also report console.error calls (the original is always called first). | | sourceMaps | boolean | true | Resolve original locations (same-origin scripts only). | | showCodeFrame | boolean | true | Show code frames when real source text is available. | | initialState | "idle" \| "sleeping" | "idle" | How the cat starts. | | hotkey | string | "alt+shift+b" | Toggle the panel. "" disables it. | | openOnError | boolean | false | Open the panel automatically on new errors. | | render3D | boolean | true | false always uses the lightweight 2D cat (three is never loaded). | | sleepAfterMinutes | number | 5 | The cat naps when nothing happens. 0 disables. | | zIndex | number | 2147483000 | Stacking order of the widget. | | filter | (error) => boolean | — | Return false to drop an error. | | onError | (error) => void | — | Called whenever an error is stored or its count increases. |

What gets captured

| Situation | Captured? | How | | ------------------------------------------------------------------------ | ------------------------------- | ------------------------------------------------- | | Uncaught error in event handlers, timers, top-level code | ✅ Automatically | window error event | | TypeError, ReferenceError, RangeError, custom errors | ✅ Automatically | window error event | | SyntaxError in a loaded classic script | ✅ Automatically | window error event | | Unhandled promise rejection (Error, string, object, null, undefined) | ✅ Automatically | unhandledrejection event | | Errors thrown in async functions nobody awaited | ✅ Automatically | unhandledrejection event | | React render / lifecycle errors with component stack | ✅ With <BugCatErrorBoundary> | Error boundary | | Vite transform / syntax errors during vite dev | ✅ With the Vite plugin | vite:error HMR event | | console.error(...) calls | ⚙️ Opt-in | captureConsoleErrors: true | | Errors you catch yourself | ✋ Manual | reportError() | | Errors caught by your own try/catch or .catch() | ❌ Not visible to any listener | Report them with reportError() | | Cross-origin scripts without CORS headers | ⚠️ Only "Script error." | Browser security; serve with crossorigin + CORS | | TypeScript type errors | ❌ | No type checker is included | | vite build / production build failures | ❌ | No page is running | | Server-side rendering errors | ❌ | BugCat runs only in the browser | | Errors inside Web Workers / iframes | ❌ | Separate global scopes | | Network failures (failed fetch, 404 images) | ❌ Unless they reject unhandled | Not exceptions |

The same exception arriving through several channels (for example React re-dispatching a render error to window) is merged into one entry rather than shown twice. Repeats of the same error are grouped and counted.

Source maps

When an error points at a same-origin http(s) script, BugCat fetches that script once, reads its sourceMappingURL (inline data: maps or an external .map file, also the SourceMap header) and maps the position back with @jridgewell/trace-mapping.

  • A location is labelled source-mapped only when mapping succeeded. Otherwise the generated location is shown and labelled generated.
  • A code frame is shown only when the map contains sourcesContent. BugCat never invents or reconstructs source code.
  • Missing, inaccessible (404, CORS) or invalid maps are handled silently — the engine never crashes.
  • Each script is fetched at most once; requests time out after 4 s; nothing is sent anywhere else.
  • Cross-origin scripts and maps on other origins are never requested.
  • Vite's dev server serves inline source maps, so original locations work out of the box. Production bundles only resolve if you publish source maps — most don't, which is fine.

Set sourceMaps: false to make BugCat perform no requests at all.

Known limitations

  • BugCat observes errors; it cannot see errors your code already catches. Use reportError() for those.
  • Location accuracy depends on the browser's stack format and on source maps. If neither gives a position, none is shown.
  • React (development mode) replays failed renders, so a render error can be counted more than once — the count reflects every time it was actually thrown.
  • React error boundaries don't cover event handlers, async code or SSR (that's React's design); the window listeners cover the first two.
  • The Vite plugin works with vite dev only. It cannot report build failures, and it does not type-check.
  • The Vite plugin's options must be JSON-serialisable (no filter / onError). Call initBugCat() yourself (with autoInit: false) for function options.
  • Compile errors are cleared at the start of the next HMR update, mirroring Vite's own overlay.
  • Errors in other global scopes (workers, iframes) are not captured.

Performance and privacy

  • Lazy 3D: three is loaded only after the widget mounts, in a separate chunk. Nothing heavy runs at import time.
  • Low power: calm states render at ~30 fps, reactions at full rate; rendering stops while the tab is hidden or the widget is hidden.
  • Reduced motion: with prefers-reduced-motion, the cat changes pose without animating and stops drawing between changes.
  • Clean teardown: destroy() removes every listener, timer, DOM node, geometry, material and the WebGL context.
  • No interference: listeners are added with addEventListener; window.onerror, window.onunhandledrejection and console are untouched (unless you opt into console capture, which still calls the original).
  • Isolation: all UI lives in a Shadow DOM; styles use constructable stylesheets where available (compatible with strict style-src CSP).
  • Safe rendering: error text is only ever inserted with textContent — messages containing HTML are shown, never executed. No eval, no innerHTML.
  • Private: no telemetry, no analytics, no third-party requests. Errors stay in memory and disappear on reload.
  • Production: the Vite plugin never applies to builds, and tree-shaking removes the widget from production bundles that only import the React boundary. Guard manual initBugCat() calls with your environment check or enabled: false.

Troubleshooting

The cat doesn't appear. Check that initBugCat() runs in the browser (not only on the server) and that enabled isn't false. With the auto entry, make sure your bundler doesn't set NODE_ENV=production in development.

The cat is flat (2D). WebGL is unavailable or blocked (some VMs, remote desktops, or render3D: false). Everything else works the same.

I only see "Script error." The script is served from another origin without CORS. Add crossorigin="anonymous" to the <script> tag and serve it with Access-Control-Allow-Origin.

Locations point at bundled files. No source map was found for that script. Enable source maps in your bundler for development builds.

I see the error twice — in Vite's overlay and BugCat. Use bugCat({ disableViteOverlay: true }).

The hotkey clashes with my app. Set hotkey: "ctrl+alt+k" or disable it with hotkey: "".

Browser support

Current versions of Chrome, Edge, Firefox and Safari (desktop and mobile) — anything with ES2020, Shadow DOM and ResizeObserver. The 3D cat needs WebGL; without it, the 2D cat is used. Stack parsing covers Chromium/V8, Firefox (SpiderMonkey) and Safari (JavaScriptCore) formats.

Examples

git clone https://github.com/your-org/bugcat-devtools.git
cd bugcat-devtools
npm install
npm run example:react     # React + Vite playground with the Vite plugin and error boundary
npm run example:vanilla   # framework-free playground using initBugCat()

Both playgrounds have buttons for every error type: runtime errors, rejections with different reasons, grouped repeats, React render crashes, Vite compile errors, hostile messages, and destroy/re-initialise.

Contributing

Contributions are welcome — see CONTRIBUTING.md.

License

MIT