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

embedded-mock-tools

v1.0.3

Published

An embedded network request interception and mock panel prototype with Service Worker support.

Readme

Embedded DevTools Mock Panel

An embedded network request interception and mock panel prototype, supporting:

  • Interception of fetch and XMLHttpRequest.
  • A floating button to collapse/expand the debug panel.
  • A left-side request list with search filtering and newest/oldest sorting.
  • A center request detail view with collapsible code blocks.
  • A right-side mock rule editor.
  • Real-time modification of response body, status code, delay, and headers.
  • Persistent mock rule storage prioritizing IndexedDB, with localStorage as a fallback and migration path.

Quick Start

Open index.html directly in your browser to experience the demo.

If you want the browser's native DevTools Network tab to also capture the mocked requests, you must serve the files via a local HTTP server since Service Workers do not support the file:// protocol:

python3 -m http.server 5173

Then visit:

http://localhost:5173/

To integrate into your own project:

<script src="./devtools-panel.js"></script>
<script>
  window.MockTools.init({
    seedMocks: [
      {
        enabled: true,
        method: "GET",
        pattern: "/api/users",
        status: 200,
        delay: 200,
        headers: { "content-type": "application/json" },
        body: JSON.stringify({ users: [] }, null, 2)
      }
    ]
  });
</script>

URL Matching

The pattern property supports two matching behaviors:

  • String literal: e.g., /api/users, matches any request URL containing this substring.
  • Simple Regex: e.g., /\/api\/users\/\d+/, matches as a RegExp when wrapped with / at both ends.

API

window.MockTools.addMock(mock);
window.MockTools.clearRequests();
window.MockTools.getRequests();
window.MockTools.getMocks();

Persistence

Mock configurations are stored in IndexedDB:

  • Database: embedded-devtools
  • Object Store: settings
  • Record Key: mocks

If IndexedDB is not supported by the browser, it falls back to localStorage. Existing mock configurations from older versions saved in localStorage will be automatically migrated to IndexedDB during initialization.

Note that when clearing site data, both IndexedDB and localStorage might be deleted. The panel provides Export and Import features to backup configurations to a JSON file and restore them later.

Native DevTools Network Integration

Under http://localhost or https environments, the panel automatically registers mocktools-sw.js. Any matched requests will be intercepted and resolved by the Service Worker, which enables the browser's native DevTools Network tab to show these mocked requests.

Under a file:// protocol environment, the tool falls back to JS-only interception: requests will still appear inside the embedded panel, but they won't appear inside the browser's native Network tab due to bypassing the browser network stack.

This prototype is built with zero external dependencies, making it ideal as an SDK seed. Future updates could split this into an npm package, custom React/Vue components, or add features like HAR exports, request replay, filter searches, environment variables, and shared team configurations.