///
import { ViewStyle, TextStyle, ImageStyle } from 'react-native';
import { Buffer } from 'buffer';
import type { BarCodeSymbology, Codepage, EscPosOptions, EscPosState } from './Encoder';
export default class PreviewEncoder {
protected _paperColor: string;
protected _textColor: string;
protected _options: EscPosOptions;
protected _state: EscPosState;
protected _styles: {
text: TextStyle;
image: ImageStyle;
view: ViewStyle;
};
protected _embedded: boolean;
protected _buffer: JSX.Element[];
protected _queued: JSX.Element[];
protected _cursor: number;
protected _codepage: Codepage | 'auto' | 'ascii';
protected _maxLineLength: number;
/**
* Create a new object
*
* @param {object} options Object containing configuration options
*/
constructor(options?: Partial);
/**
* Reset the state of the object
*
* @param {object} options Object containing configuration options
*/
protected _reset(options?: Partial): void;
/**
* Add commands to the queue
*
* @param {array} value Add array of numbers, arrays, buffers or Uint8Arrays to add to the buffer
*
*/
protected _queue(value: JSX.Element[]): void;
/**
* Flush current queue to buffer
*/
protected _flush(): void;
/**
* Restore styles and codepages after drawing boxes or lines
*/
protected _restoreState(): void;
/**
* Initialize the printer
*
* @return Return self, for easy chaining commands
*/
initialize(): this;
/**
* Change the code page
*
* @param _ The codepage that we set the printer to
* @return Return self, for easy chaining commands
*/
codepage(_: Codepage | 'auto' | 'ascii'): this;
/**
* Print text
*
* @param value Text that needs to be printed
* @param wrap Wrap text after this many positions
* @return Return self, for easy chaining commands
*/
text(value: string, wrap?: number): this;
/**
* Print a newline
*
* @param size Size 0 - 255
* @return Return self, for easy chaining commands
*/
newline(size?: number): this;
/**
* Print text, followed by a newline
*
* @param value Text that needs to be printed
* @param wrap Wrap text after this many positions
* @return Return self, for easy chaining commands
*/
line(value: string, wrap?: number): this;
/**
* Print an array of lines
*
* @param value Text that needs to be printed
* @return Return self, for easy chaining commands
*/
lines(value: string[]): this;
/**
* Print a key and a value with spaces or dots filling in between
*
* @param key Left item
* @param value Right item
* @param style Style of the spaces in between
* @returns Return self, for easy chaining commands
*/
keyvalue(key: string, value: string, style?: 'dots' | 'spaces'): this;
/**
* Underline text
*
* @param value `true` to turn on underline, `false` to turn off, or 2 for double underline
* @returnReturn self, for easy chaining commands
*/
underline(value?: boolean | number): this;
/**
* Italic text
*
* @param value `true` to turn on italic, `false` to turn off
* @return Return self, for easy chaining commands
*/
italic(value?: boolean): this;
/**
* Bold text
*
* @param value `true` to turn on bold, `false` to turn off
* @return Return self, for easy chaining commands
*/
bold(value?: boolean): this;
/**
* Change width of text
*
* @param width The width of the text, 1 - 3
* @return Return self, for easy chaining commands
*/
width(width?: number): this;
/**
* Change height of text
*
* @param height The height of the text, 1 - 3
* @return Return self, for easy chaining commands
*/
height(height?: number): this;
/**
* Invert text
*
* @param value `true` to turn on white text on black, `false` to turn off
* @return Return self, for easy chaining commands
*/
invert(value?: boolean): this;
/**
* Change text size
*
* @param value `'small'` or `'normal'`
* @return Return self, for easy chaining commands
*/
size(value?: 'small' | 'normal'): this;
/**
* Change text alignment
*
* @param value `'left'`, `'center'` or `'right'`, defaults to 'left'
* @return Return self, for easy chaining commands
*/
align(value?: 'left' | 'center' | 'right'): this;
/**
* Insert a horizontal rule
*
* @param width Defaults to max line length
* @return Return self, for easy chaining commands
*/
rule(width?: number): this;
/**
* Barcode
*
* @param value Barcode contents
* @param symbology Barcode type
* @param height Barcode height, defaults to `10`
* @return Return self, for easy chaining commands
*/
barcode(value: string, symbology: BarCodeSymbology, height?: number): this;
/**
* QR Code
*
* @param value QR Code contents
* @param _ Model of the qrcode, either `1` or `2`
* @param size Size of the qrcode, a value between `1` and `8`, defaults to `6`
* @param size The amount of error correction used, either `'l'`, `'m'`, `'q'` or `'h'`
* @return Return self, for easy chaining commands
*/
qrcode(value: string, _model?: 1 | 2, size?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8, errorLevel?: 'L' | 'M' | 'Q' | 'H'): this;
/**
* Prints image, supports PNG and JPEG
*
* @param base64 png base64
* @param algorithm The dithering algorithm for making the image black and white
* @param threshold Threshold for the dithering algorithm
* @return Return self, for easy chaining commands
*/
image(base64: string, algorithm?: 'threshold' | 'bayer' | 'floydsteinberg' | 'atkinson', threshold?: number): this;
/**
* Cut paper
*
* Polyfill
* @return Return self, for easy chaining commands
*/
cut(..._args: any[]): this;
/**
* Pulse
*
* Polyfill
* @return Return self, for easy chaining commands
*/
pulse(..._args: any[]): this;
/**
* Add raw printer commands
*
* !TODO: Finish this
* @param {array} data raw bytes to be included
* @return {object} Return self, for easy chaining commands
*/
raw(data: (number | any[] | Uint8Array | Buffer)[]): this;
/**
* Encode all previous commands
*
* @return Return the encoded bytes
*/
encode(): JSX.Element[];
}