-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[0.5.0] Docs updated + Ability to not specify callbackName
- Loading branch information
Showing
5 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dist: trusty | ||
addons: | ||
chrome: stable | ||
language: node_js | ||
node_js: | ||
- "8.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,55 @@ | ||
# webshot-factory | ||
[![Build Status](https://travis-ci.org/ashubham/webshot-factory.svg?branch=master)](https://travis-ci.org/ashubham/webshot-factory) | ||
[![npm version](https://badge.fury.io/js/webshot-factory.svg)](https://badge.fury.io/js/webshot-factory) | ||
|
||
<img src="https://github.com/ashubham/webshot-factory/raw/master/assets/webshot-factory.png" align="right" alt="Webshot Factory" /> | ||
|
||
screenshots at scale based on headless chrome | ||
|
||
## Installation | ||
|
||
``` | ||
npm i webshot-factory | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
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. | ||
callbackName: 'callPhantom', | ||
|
||
// 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. | ||
}); | ||
|
||
// Once initialized just call getShot and | ||
// a shot will be scheduled on a worker | ||
// chrome instance. | ||
shotFactory.getShot('http://yahoo.com').then(buffer => { | ||
console.log(buffer); | ||
}); | ||
``` | ||
|
||
## Status Page | ||
|
||
`Webshot-factory` includes a status page to check the status of the running chrome instance workers. | ||
|
||
Visit: `http://<host>:<webshotDebugPort>/status` | ||
|
||
To check the status and debug any problems. The page looks like this: | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
{ | ||
"name": "webshot-factory", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "screenshots at scale based on headless chrome", | ||
"main": "dist/index.js", | ||
"types": "dist/declarations/index.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"test": "npm run build", | ||
"build": "tsc -p .", | ||
"prepublish": "npm run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ashubham/webshot-factory.git" | ||
}, | ||
"keywords": [ | ||
"webshot", | ||
"headless", | ||
"chrome", | ||
"screenshot" | ||
], | ||
"author": "[email protected]", | ||
"license": "ISC", | ||
"bugs": { | ||
|
@@ -27,7 +33,7 @@ | |
"internal-ip": "^3.0.0", | ||
"lodash": "^4.17.4", | ||
"log4js": "^1.1.1", | ||
"puppeteer": "^0.11.0" | ||
"puppeteer": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/bluebird": "^3.5.11", | ||
|