UNPKG

snipify

Version:

A production-ready tool for capturing and processing web screenshots with Puppeteer and Sharp.

164 lines (160 loc) 4.64 kB
declare const DEVICE_PRESETS: { readonly desktop: { readonly viewport: { readonly width: 1920; readonly height: 1080; }; readonly userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64)...Chrome/121.0.0.0 Safari/537.36"; }; readonly laptop: { readonly viewport: { readonly width: 1366; readonly height: 768; }; readonly userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64)...Chrome/121.0.0.0 Safari/537.36"; }; readonly tablet: { readonly viewport: { readonly width: 768; readonly height: 1024; }; readonly userAgent: "Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X)...Safari/604.1"; }; readonly mobile: { readonly viewport: { readonly width: 375; readonly height: 667; }; readonly userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)...Safari/604.1"; }; readonly "mobile-large": { readonly viewport: { readonly width: 414; readonly height: 896; }; readonly userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)...Safari/604.1"; }; }; declare const PRODUCTION_SIZES: { readonly thumbnail: { readonly width: 300; readonly height: 200; }; readonly card: { readonly width: 400; readonly height: 300; }; readonly "social-media": { readonly width: 1200; readonly height: 630; }; readonly "instagram-post": { readonly width: 1080; readonly height: 1080; }; readonly "instagram-story": { readonly width: 1080; readonly height: 1920; }; readonly "youtube-thumbnail": { readonly width: 1280; readonly height: 720; }; readonly "blog-header": { readonly width: 800; readonly height: 400; }; readonly "email-banner": { readonly width: 600; readonly height: 200; }; readonly "preview-small": { readonly width: 200; readonly height: 150; }; readonly "preview-medium": { readonly width: 400; readonly height: 300; }; readonly "preview-large": { readonly width: 800; readonly height: 600; }; }; type DevicePresetKey = keyof typeof DEVICE_PRESETS; interface ScreenshotOptions { outputPath?: string; outputDir?: string; format?: "png" | "jpeg"; quality?: number; fullPage?: boolean; waitForSelector?: string; delay?: number; headless?: boolean; blockResources?: boolean; clip?: { x: number; y: number; width: number; height: number; }; fixedSize?: { width: number; height: number; }; } declare function captureScreenshot({ url, device, options, }: { url: string; device?: DevicePresetKey; options?: ScreenshotOptions; }): Promise<Uint8Array<ArrayBufferLike>>; declare function captureProductionScreenshots({ url, device, sizes, options, }: { url: string; device?: DevicePresetKey; sizes?: (keyof typeof PRODUCTION_SIZES)[]; options?: ScreenshotOptions; }): Promise<{ size: "thumbnail" | "card" | "social-media" | "instagram-post" | "instagram-story" | "youtube-thumbnail" | "blog-header" | "email-banner" | "preview-small" | "preview-medium" | "preview-large"; dimensions: { readonly width: 300; readonly height: 200; } | { readonly width: 400; readonly height: 300; } | { readonly width: 1200; readonly height: 630; } | { readonly width: 1080; readonly height: 1080; } | { readonly width: 1080; readonly height: 1920; } | { readonly width: 1280; readonly height: 720; } | { readonly width: 800; readonly height: 400; } | { readonly width: 600; readonly height: 200; } | { readonly width: 200; readonly height: 150; } | { readonly width: 400; readonly height: 300; } | { readonly width: 800; readonly height: 600; }; buffer: Buffer<ArrayBufferLike>; path: string; fileSize: string; }[]>; declare function generateFilename(url: string, device: DevicePresetKey, format?: "png" | "jpeg", size?: { width: number; height: number; } | string): Promise<string>; export { DEVICE_PRESETS, type DevicePresetKey, PRODUCTION_SIZES, type ScreenshotOptions, captureProductionScreenshots, captureScreenshot, generateFilename };