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

@pen.dev/sdk

v0.1.0

Published

pen.dev SDK

Readme

@pen.dev/sdk

Captures a web page, or an element the user picks in it, from an Electron WebContents as a pen.dev browser import. It is the Electron counterpart of the pen.dev Chrome extension: the same in-page crawler, picker, and payload format, with asset downloads and image work done through the host process and the live page instead of an extension service worker.

The root entry exports the browser-import types. @pen.dev/sdk/electron is the published, narrow surface over the internal @ha/electron-browser-import: everything it and its dependencies need is bundled in, and Electron (>= 30) is an optional peer dependency that only the electron entry needs.

Use

import { PenCapturer } from "@pen.dev/sdk/electron";

const capturer = new PenCapturer(view.webContents);

capturer.on("picker", (state) => {
  // undefined: no session; { pick: undefined }: crosshair is up;
  // { pick }: an element is selected (pick.element, on pick.path) and stays live.
});
capturer.on("action", (action) => {
  // "import" on Enter, "screenshot" on Cmd/Ctrl+Enter, while a selection is live.
  if (action === "import") {
    void run();
  }
});

capturer.startPicking(); // Escape in the page, or endPicking(), clears it.

async function run() {
  // The picked element when there is one, the full page otherwise;
  // `payload` is the string pen.dev accepts as a browser import.
  const payload = await capturer.capture({
    onProgress: (fraction) => progressBar.value = fraction,
  });
}

capturer.dispose();

capture() resolves to the self-contained payload. Failed downloads keep their original URLs and produce an import warning on the pen.dev side.

select(selector) selects an element without the crosshair phase; the selection is live afterwards exactly as after a pick. hover(selector) shows the picker's hover highlight on an element, as the mouse does. selectPathEntry(index) retargets a live selection along the picked element's ancestor path.

Requirements

  • The WebContents must be attached to a visible view. Captures on hidden or detached contents never resolve, because the renderer does not paint.
  • Asset downloads go through webContents.session.fetch, so they carry the page's cookies and are not subject to the page's CORS or CSP.
  • The page API is injected into the page's main world with executeJavaScript. It installs window.__pencil; nothing else is added to the page.
  • screenshots: true also captures canvases, videos, and cross-origin media the crawl cannot read. It attaches the Chrome DevTools Protocol debugger to the WebContents for the duration of the capture. It is off by default; without it those nodes import as placeholders.
  • Pass onWarning to route warnings into the host's log; the default writes to the console.

Example

The pen-embed-demo repository next to this checkout embeds the pen.dev web editor in Electron and uses this package for its browser window: element picking, selector hover, breadcrumb navigation, and import onto the canvas through the embed bridge.

Build

Built with tsdown like the CLI: @ha/electron-browser-import and everything under it are inlined into dist, which is all the package ships.

./build-shared.sh
npm --prefix lib/browser-inject run build
npm --prefix lib/electron-browser-import run build
npm --prefix lib/sdk ci
npm --prefix lib/sdk run build

Release

The SDK release workflow bumps the version, builds, creates an sdk-v<version> GitHub release, and, when publish_npm is checked, publishes to npm with npm publish --access public.