UNPKG

@ltcode/crosshot

Version:

Cross-platform desktop screenshot utility

125 lines (110 loc) 3.12 kB
// Type definitions for @ltcode/crosshot // Project: https://github.com/ltcodedev/crosshot // Definitions by: Lucas Tiago <dev@lucastiago.com.br> export interface ScreenshotSize { bytes: number; kb: number; mb: number; } export interface ScreenshotMetadata { created: Date; modified: Date; permissions: number; } export interface ScreenshotResult { success: true; filename: string; filepath: string; absolutePath: string; directory: string; size: ScreenshotSize; tool: string; platform: string; timestamp: string; format: string; metadata: ScreenshotMetadata; base64?: string; // Data URL format (data:image/png;base64,...) base64Raw?: string; // Raw base64 string } export interface ScreenshotError { success: false; error: string; platform: string; availableTools: string[]; timestamp: string; suggestions: string[]; } export interface ScreenshotOptions { silent?: boolean; verbose?: boolean; format?: 'png' | 'jpg' | 'jpeg' | 'bmp' | 'webp'; quality?: number; returnBase64?: boolean; // Return base64 string instead of just file path } export interface CaptureScreenOptions { outputDir?: string; filename?: string; silent?: boolean; verbose?: boolean; createDir?: boolean; format?: 'png' | 'jpg' | 'jpeg' | 'bmp' | 'webp'; quality?: number; returnBase64?: boolean; // Return base64 string in addition to file } /** * Information about available screenshot tools on the system */ export interface AvailableTools { platform: string; detectedTools: string[]; recommendedTool?: string; } /** * Library version and information */ export interface LibraryVersion { name: string; version: string; platform: string; architecture: string; nodeVersion: string; } export interface LibraryVersion { version: string; platform: string; name: string; description: string; } /** * Take a screenshot with full control over options * @param destinationDir Directory to save the screenshot * @param customName Custom filename without extension (optional) * @param options Screenshot options * @returns Promise that resolves to ScreenshotResult or rejects with ScreenshotError */ export function takeScreenshot( destinationDir?: string, customName?: string | null, options?: ScreenshotOptions ): Promise<ScreenshotResult>; /** * Convenience function for taking screenshots with simplified options * @param options Capture options * @returns Promise that resolves to ScreenshotResult or rejects with ScreenshotError */ export function captureScreen(options?: CaptureScreenOptions): Promise<ScreenshotResult>; /** * Check what screenshot tools are available on the current system * @returns Promise that resolves to AvailableTools information */ export function getAvailableTools(): Promise<AvailableTools>; /** * Get library version and information * @returns LibraryVersion object with version and platform info */ export function getLibraryVersion(): LibraryVersion; /** * Default export - same as takeScreenshot */ declare const _default: typeof takeScreenshot; export default _default;