import { IAdapterOptions } from '../types'; import { IPrintJobManager, IConnectionManager } from './interfaces'; /** * Print Job Manager implementation */ export declare class PrintJobManager implements IPrintJobManager { /** Instance-level job state storage (per-printer support) */ private instanceJobStateStore; /** Static job state store for backward compatibility */ private static _jobStateStore; /** Auto-cleanup timer for expired job states */ private static _cleanupTimer; private static readonly CLEANUP_INTERVAL_MS; private static readonly DEFAULT_EXPIRY_MS; /** Start the auto-cleanup timer if not already running */ private static ensureCleanupTimer; /** * Get the static job state store (for backward compatibility) * @deprecated Use instance-level store instead for multi-printer support */ private static get jobStateStore(); private adapter; private connectionManager; private jobBuffer; private jobOffset; private _isPaused; private _isInProgress; private adapterOptions; private readonly logger; private onProgress?; private jobId; private onJobStateChange?; /** * Sets the progress callback * * @param callback - Progress callback function */ setProgressCallback(callback?: (sent: number, total: number) => void): void; /** * Sets the job state change callback * * @param callback - Job state change callback function */ setJobStateCallback(callback?: (state: 'in-progress' | 'paused' | 'completed' | 'cancelled') => void): void; /** * Creates a new PrintJobManager instance * * @param connectionManager - Connection manager instance */ constructor(connectionManager: IConnectionManager); /** * Starts a print job * * @param buffer - Print data buffer * @param options - Print job options * @returns Promise */ start(buffer: Uint8Array, options?: { jobId?: string; }): Promise; /** * Resumes a paused print job * * @param jobId - Job ID to resume (optional) * @returns Promise */ resume(jobId?: string): Promise; /** * Cancels the current print job */ cancel(): void; /** * Generates a unique job ID * * @returns string - Unique job ID */ private generateJobId; /** * Saves the current job state for resume later. * * Uses instance-level storage by default. Falls back to static store * for backward compatibility. */ private saveJobState; /** * Loads a saved job state * * @param jobId - Job ID to load */ private loadJobState; /** * Clears the current job state */ private clearJobState; /** * Cleanup resources and clear all job state. * Call this when the printer is no longer needed. */ destroy(): void; /** * Clean up expired job states from static store. * Call this periodically to prevent memory leaks. * * @param maxAge - Maximum age in ms (default: 1 hour) */ static cleanupExpiredJobs(maxAge?: number): number; /** * Stop the auto-cleanup timer. Useful for test teardown. */ static stopCleanupTimer(): void; /** * Get count of pending job states in static store. * Useful for debugging memory usage. */ static getStaticStoreSize(): number; /** * Emits job state change event * * @param state - New job state */ private emitJobState; /** * Handles job completion: logs, resets state, and emits event. * Shared by start() and resume() code paths. */ private completeJob; /** * Pauses the current print job */ pause(): void; /** * Gets the number of bytes remaining to print * * @returns number - Bytes remaining */ remaining(): number; /** * Checks if the print job is paused * * @returns boolean - True if paused, false otherwise */ isPaused(): boolean; /** * Checks if a print job is in progress * * @returns boolean - True if in progress, false otherwise */ isInProgress(): boolean; /** * Sets adapter options for write operations * * @param options - Adapter options */ setOptions(options: IAdapterOptions): void; /** * Processes the print job in chunks * Supports pause/resume functionality * * @returns Promise */ private processJob; /** * Gets the current device ID from the connection manager * * @returns string - Device ID * @throws BluetoothPrintError if no device is connected */ private getDeviceId; }