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

webshot-factory

v0.5.5

Published

screenshots at scale based on headless chrome

Downloads

111

Readme

webshot-factory

Build Status npm version

screenshots at scale based on headless chrome.

Basic Concept

  • Webshot-factory creates a number of headless-chrome worker instances which take screenshots in round robin. Thus, can be horizontally scaled to provide good throughput.
  • Includes a debug status page to monitor the worker instances.
  • Can be used for batch report generation.
  • Or to take a number of screenshots in general.
  • Written in Typescript (types bundled).

Installation

npm i webshot-factory

Usage

import * as shotFactory from 'webshot-factory';

await shotFactory.init({
    // Number of worker threads (chrome instances) to run.
    // A shot is assigned to a worker in round robin.
    concurrency: 10,

    // The callback method to be exposed on the window, 
    // which would be called by the application
    // Shot will be taken when callback is called.
    // This was 'callPhantom' in PhantomJS.
    callbackName: '',

    // A cache warmer url, 
    // so that workers can cache the webpage scripts.
    warmerUrl: 'http://google.com',
    width: 1000, // shot width
    height: 600, // shot height
    timeout: 60000, // timeout (millis) to wait for shot.
    webshotDebugPort: 3030 // Port where the status page is served.
    // To use Puppeteer with a different version of Chrome or Chromium,
    chromeExecutablePath: '/path/to/Chrome'
});

// Once initialized, just call getShot and
// a shot will be scheduled on a worker
// chrome instance.
shotFactory.getShot('http://yahoo.com').then(buffer => {
    // Do whatever with the buffer, can be used to email to recipients.
    console.log(buffer);
    // Or can be saved to a file.
    // Using the `fs` module.
    fs.createWriteStream('shot.png')
        .write(buffer)
        .end();
});

Status Page

Webshot-factory includes a status page to check the status of the running chrome instance workers.

Visit: http://<host>:<webshotDebugPort>/status

Note: The default port is 3030.

To check the status and debug any problems. The page looks like this: