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 🙏

© 2024 – Pkg Stats / Ryan Hefner

stdout-ext

v0.0.2

Published

A simple Chrome extension for console-logging *other* Chrome extensions

Downloads

9

Readme

icon

stdout-ext

A simple Chrome extension for console-logging other Chrome extensions

Why?

Seeing console log output can be crucial for debugging Chrome extensions, especially when they use a manifest V3 service worker to respond to user-generated events, like a tab opening, the focus changing, etc. Sure, you can inspect the service worker console, but leaving that devtools window open keeps the service worker active. So you'll never see your extension go through the transition from active to inactive and back again — which is often where bugs sneak in.

stdout-ext provides an easy way to send console output from your service worker or other extension pages without keeping your background scripts active.

Installation

npm install --save-dev stdout-ext

After installing the package, you'll need to add the unpacked stdout extension to Chrome. To do so, drag the extension folder from node_modules/stdout-ext/ into the Extensions window in Chrome (chrome://extensions).

Once stdout is running, click its service worker link to open the devtools window. This is where any console output from your extension will be displayed.

Usage

To send logs from your extension, import stdout() from the package and call it with the stdout extension ID, which you can get from the Chrome Extensions window. (The exact ID will be unique to your local installation.)

// service-worker.js
import stdout from "stdout-ext";

stdout("<ID for the unpacked stdout extension>");
console.log("my important message", { hello: "world" });

By default, the global console object will be wrapped with methods that forward all calls to the stdout extension, so anything passed to console.log(), console.error(), etc. in your extension will also be displayed in the stdout service worker's console.

Call stdout() once from each "page" in your extension from which you want to send console output: the service worker, the popup, content scripts, etc. If you pass an empty string or null for the ID, stdout() will silently do nothing, so you can use an environment variable or something similar to enable log forwarding in development mode but disable it in production.

Options

Instead of passing a plain string ID to stdout(), you can also pass an object that contains the id and other options.

wrapConsole

If you don't want to wrap the global console object, set wrapConsole to false. In that case, stdout() will return an object with the standard console methods that you can call when you want to send console output to the stdout extension:

const { log, error } = stdout({ id: "...", wrapConsole: false });

console.log("this message will not be sent to stdout");
log("this message will be logged locally *and* sent to stdout", { hello: "world" });
error("so will this error", new Error("something went wrong"));

filename

In the stdout devtools window, the filename of your extension page is prefixed to each line of output, since different parts of your extension can all send messages to that console. By default, this filename is extracted from location.pathname, but you can specify a custom name by passing a filename field in the options object:

// service-worker.js
stdout({ id: "...", filename: "background" });

// popup.html
stdout({ id: "...", filename: "toolbar" });

License

MIT © John Dunning