1.1.1 • Published 4 years ago

@selfage/puppeteer_executor_api v1.1.1

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

@selfage/puppeteer_executor_api

Install

npm install @selfage/puppeteer_executor_api

Overview

Written in TypeScript and compiled to ES6 with inline source map & source. See @selfage/tsconfig for full compiler options. Provides Puppeteer executor environment API declarations.

Access argv

Pass-through arguments can be accessed in your executable TS/JS file via a global argv variable which is an array of strings similar to Nodejs's process.argv except no Node path and JS file name.

import '@selfage/puppeteer_executor_api'; // Import for side effect.

// argv = ['-a', '10'] with `$ bundage prun my_file -- -a 10`
// You can use some popular tools to parse arguments.
parseArg(argv);
// or parseArg(globalThis.argv);

All APIs

Below is a file of apis.ts which declares all APIs.

declare var argv: Array<string>;
declare function exit(): void;
declare function screenshot(
  relativePath: string,
  options: { delay?: number; fullPage?: boolean; quality?: number }
): Promise<string>;
declare function fileExists(relativePath: string): Promise<void>;
declare function readFile(relativePath: string): Promise<string>;
declare function deleteFile(relativePath: string): Promise<void>;
declare function setViewport(width: number, height: number): Promise<void>;

They should be self-explanatory and can be used as below.

import '@selfage/puppeteer_executor_api'; // Import for side effect.

// Take a screenshot 500 ms later.
globalThis.screenshot('/rendered.png', {delay: 500});

@selfage/test_runner uses exit() to terminate/exit browser.

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago