webstack-screenshot
Version:
📸网站截图 API | Website Screenshot API
33 lines (29 loc) • 1.07 kB
text/typescript
import { Viewport, ScreenshotOptions, ScreenshotClip, PuppeteerLifeCycleEvent, LaunchOptions, Page } from 'puppeteer-core';
interface IOptions {
url: string;
type?: 'png' | 'jpeg' | 'webp';
cache?: number | boolean;
quality?: number;
size?: string;
viewport?: Viewport;
fullPage?: boolean;
isMobile?: boolean;
await?: number;
timeout?: number;
encoding?: ScreenshotOptions['encoding'];
clip?: string | ScreenshotClip;
waitUntil?: PuppeteerLifeCycleEvent;
}
type TLaunchOptions = LaunchOptions;
declare class Screenshot {
private static instance;
private constructor();
static getInstance(): Screenshot;
getScreenshot(page: Page, options: IOptions): Promise<Uint8Array | string>;
setViewport(page: Page, options: IOptions): Promise<void>;
parse(options: IOptions): ScreenshotOptions;
parseViewport(viewportString: string): Viewport | undefined;
parseClip(clip: string): ScreenshotClip | undefined;
}
export { Screenshot as S };
export type { IOptions as I, TLaunchOptions as T };