import { IPrinterDriver, IQrOptions } from '../types'; /** * Alignment options for text positioning */ export type Alignment = 'left' | 'center' | 'right'; /** * Barcode types supported by STAR printers */ export type BarcodeType = 'CODE39' | 'CODE128' | 'EAN13'; /** * STAR printer driver options */ export interface StarPrinterOptions { /** Use the EncodingService for GBK/UTF-8 encoding (default: true) */ useEncodingService?: boolean; /** Show warnings for unsupported characters (default: true) */ showEncodingWarnings?: boolean; /** Fallback character for unsupported characters (default: '?') */ fallbackChar?: string; /** Enable international character mode (default: true) */ internationalCharset?: boolean; } /** * Barcode options for STAR printers */ export interface StarBarcodeOptions { /** Barcode height in dots (default: 40) */ height?: number; /** Barcode width (default: 2) */ width?: number; /** HRI text position: 'none' | 'above' | 'below' | 'both' (default: 'below') */ hri?: 'none' | 'above' | 'below' | 'both'; /** Barcode type: CODE39, CODE128, EAN13 */ type?: BarcodeType; } /** * QR code options for STAR printers */ export interface StarQrOptions { /** QR code model (default: 2) */ model?: 1 | 2; /** QR code cell size in dots (default: 4) */ cellSize?: number; /** Error correction level: 'L' | 'M' | 'Q' | 'H' (default: 'M') */ errorCorrection?: 'L' | 'M' | 'Q' | 'H'; } /** * Image print options */ export interface StarImageOptions { /** Enable dithering (default: true) */ dithering?: boolean; /** Threshold for binarization 0-255 (default: 128) */ threshold?: number; /** Print in greyscale mode (default: false) */ greyscale?: boolean; } /** * STAR TSP/TSP700 series thermal printer driver * * Implements the STAR command set for thermal receipt printers. * Supports text, images, QR codes, barcodes, and paper control. * * @example * ```typescript * const driver = new StarPrinter(); * const commands = [ * ...driver.init(), * ...driver.text('Hello World!'), * ...driver.feed(3), * ...driver.cut() * ]; * ``` */ export declare class StarPrinter implements IPrinterDriver { private readonly logger; private readonly encodingService; private readonly useEncodingService; private readonly internationalCharset; private _boldEnabled; private _alignment; /** * Creates a new StarPrinter driver instance * @param options - Driver options */ constructor(options?: StarPrinterOptions); /** * Initialize the printer to default state * Sends ESC @ to reset printer to power-on defaults * * @returns Array of command buffers * * @example * ```typescript * const commands = driver.init(); * ``` */ init(): Uint8Array[]; /** * Print text content with specified encoding * * Supports GBK, UTF-8, EUC-KR, Shift-JIS, ISO-2022-JP through EncodingService. * When using ESC/POS compatible mode, text is output as-is with line feed. * * @param content - Text content to print * @param encoding - Text encoding (default: 'GBK') * @returns Array of command buffers * * @example * ```typescript * driver.text('Hello World', 'UTF-8'); * driver.text('你好世界', 'GBK'); * ``` */ text(content: string, encoding?: string): Uint8Array[]; /** * Feed paper by specified number of lines * * @param lines - Number of lines to feed (default: 1, max: 255) * @returns Array of command buffers * * @example * ```typescript * driver.feed(3); // Feed 3 lines * ``` */ feed(lines?: number): Uint8Array[]; /** * Cut the paper using the built-in cutter * * Note: Not all STAR printers have a cutter. For printers without cutter, * this will attempt a full paper cut which may result in no action. * * @returns Array of command buffers * * @example * ```typescript * driver.cut(); * ``` */ cut(): Uint8Array[]; /** * Print a QR code * * Uses STAR's built-in QR code command when available (GS W 01 pattern), * otherwise falls back to printing QR code as a raster image. * * @param content - Content to encode in the QR code * @param options - QR code options (model, cellSize, errorCorrection) * @returns Array of command buffers * * @example * ```typescript * driver.qr('https://example.com', { model: 2, cellSize: 6, errorCorrection: 'M' }); * ``` */ qr(content: string, options?: IQrOptions | StarQrOptions): Uint8Array[]; /** * Print a barcode * * Supports CODE39, CODE128, and EAN13 barcode types. * HRI (Human Readable Interpretation) text can be positioned above, * below, or both sides of the barcode. * * @param data - Barcode data content * @param options - Barcode options (type, height, width, hri) * @returns Array of command buffers * * @example * ```typescript * driver.barcode('123456789012', { type: 'EAN13', height: 60 }); * driver.barcode('ABC-1234', { type: 'CODE39', width: 3 }); * ``` */ barcode(data: string, options?: StarBarcodeOptions): Uint8Array[]; /** * Print a raster image * * Converts RGBA image data to 1-bit bitmap using dithering and sends * to the printer using STAR's raster image command. * * @param data - RGBA pixel data (Uint8Array, 4 bytes per pixel) * @param width - Image width in pixels * @param height - Image height in pixels * @param options - Image print options (dithering, threshold, greyscale) * @returns Array of command buffers * * @example * ```typescript * const imageData = new Uint8Array(width * height * 4); // RGBA * driver.image(imageData, 200, 100, { dithering: true }); * ``` */ image(data: Uint8Array, width: number, height: number, options?: StarImageOptions): Uint8Array[]; /** * Sound a beep/buzzer on supported printers * * Sends a command to activate the printer's built-in buzzer. * Useful for alerting operators to print completion or errors. * * @returns Array of command buffers * * @example * ```typescript * driver.beep(); * ``` */ beep(): Uint8Array[]; /** * Enable or disable bold text * * When bold is enabled, subsequent text will be printed in bold. * This state persists until explicitly disabled. * * @param on - true to enable bold, false to disable * @returns Array of command buffers * * @example * ```typescript * driver.bold(true); * driver.text('Bold Text'); * driver.bold(false); * ``` */ bold(on: boolean): Uint8Array[]; /** * Set text alignment * * Controls horizontal text alignment for subsequent text. * Alignment persists until explicitly changed. * * @param align - Alignment: 'left' | 'center' | 'right' * @returns Array of command buffers * * @example * ```typescript * driver.align('center'); * driver.text('Centered Title'); * driver.align('left'); * ``` */ align(align: Alignment): Uint8Array[]; }