Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#349 - added docs comments #357

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,159 @@ import unusedFilename from 'unused-filename';
const writeFile = promisify(fs.writeFile);

export interface Options {
/**
* Delay capturing the screenshot (seconds).
*
* @default 0
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delay?: number;

/**
* Number of seconds after which the request is aborted.
*
* @default 60
*/
timeout?: number;

/**
* Crop to the set height.
*
* @default false
*/
crop?: boolean;

/**
* Apply custom CSS to the webpage.
*/
css?: string;

/**
* Apply custom JavaScript to the webpage.
*/
script?: string;

/**
* A string with the same format as a browser cookie or an object.
*/
cookies?: (string | {[key: string]: string})[];

/**
* Define a customized filename using Lo-Dash templates.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme contains a lot more info that is missing here.

*/
filename?: string;

/**
* When a file exists, append an incremental number.
*
* @default false
*/
incrementalName?: boolean;

/**
* Capture a specific DOM element matching a CSS selector.
*/
selector?: string;

/**
* Hide an array of DOM elements matching CSS selectors.
*/
hide?: string[];

/**
* Username for authenticating with HTTP auth.
*/
username?: string;

/**
* Password for authenticating with HTTP auth.
*/
password?: string;

/**
* Scale webpage number times.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a valid sentence.

*
* @default 1
*/
scale?: number;

/**
* Image format.
*
* @default png
*/
format?: string;

/**
* Custom user agent.
*/
userAgent?: string;

/**
* Custom HTTP request headers.
*/
headers?: {[key: string]: string};

/**
* Set background color to `transparent` instead of `white` if no background is set.
*
* @default false
*/
transparent?: boolean;
}

export interface Source {
/**
* URL or local path to the website you want to screenshot. You can also use a data URI.
*/
url: string;

/**
* Use a `<width>x<height>` notation or a keyword.
*/
sizes: string[];

/**
* Options set here will take precedence over the ones set in the constructor.
*/
options?: Options;
}

/**
* Set the destination directory.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not correct. The type is the destination directory.

*/
export type Destination = string;

export interface Viewport {
/**
* URL or local path to the website you want to screenshot. You can also use a data URI.
*/
url: string;

/**
* Use a <width>x<height> notation.
*/
sizes: string[];

/**
* A keyword is a version of a device.
*/
keywords: string[];
}

interface Stats {
/**
* Number of URLs.
*/
urls?: number;

/**
* Number of sizes.
*/
sizes?: number;

/**
* Number of screenshots.
*/
screenshots?: number;
}

Expand Down