import { Alignment, Barcode, FontStyle, ImageEncoding, ImageSourceEncoding } from './utils'; export type baseChunk = { /** How to align the text */ align?: Alignment; }; /** * Common options for all chunks */ export type chunkOptions = baseChunk & { /** Font style */ style?: FontStyle; /** The amount of margin from the left side of the paper */ paddingLeft?: number; /** Instructs the printer how to handle hex values */ supportHexValues?: boolean; /** Instructs the printer how to handle fixed or variable width font */ isFixedWidthFont?: boolean; /** * Instructs the printer how to handle arabic characters * @deprecated * @use {@link language} instead */ containsArabicChars?: boolean; /** Instructs the printer how to handle the specified language */ language?: string; /** The height of the font in pixels */ fontHeight?: number; /** The width of the font in pixels */ fontWidth?: number; /** The amount of space between lines in pixels */ lineSpacing?: number; }; /** Used to specify additional options when printing images */ export type imageOptions = chunkOptions & { /** Used to select the image output encoding. */ imageEncoding?: ImageEncoding; /** Used to select the image source encoding */ sourceEncoding?: ImageSourceEncoding; /** * The font to use when printing text as an image * @remarks Used only in ESC/P2 image printing for now */ font?: string; /** the amount of space between two images when using imgColumns */ offset?: number; }; export type barcodeOptions = baseChunk & { barcodeType?: Barcode; height?: number; width?: number; offset?: number; /** Module width for ^BY command (1-10, default: 2) */ moduleWidth?: number; /** Wide bar to narrow bar width ratio for ^BY command (2.0-3.0, default: 3.0) */ wideBarRatio?: number; /** Field height for ^BY command in dots */ fieldHeight?: number; }; export type lineOptions = chunkOptions & { maxTextLength?: number; enableSplit?: boolean; fontSize?: number; lineHeight?: number; offset?: number; strikethroughOptions?: strikethroughOptions; }; export type textOptions = chunkOptions & { maxTextLength?: number; enableSplit?: boolean; fontSize?: number; lineHeight?: number; offset?: number; strikethroughOptions?: strikethroughOptions; }; export type strikethroughOptions = { length?: number; thickness?: number; offsetY?: number; offsetX?: number; }; /** * Used to print empty row */ export type empty = { type: "empty"; index?: number; }; /** * Used to print ruler */ export type ruler = { type: "ruler"; index?: number; }; /** * Used to print a text line */ export type text = { type: "text"; value: string; options?: chunkOptions & { maxTextLength?: number; enableSplit?: boolean; isCustomCommand?: boolean; }; index?: number; }; /** * Used to print a text line with advanced formatting. * Used mainly when printing arabic */ export type line = { type: "line"; value: Array; options?: chunkOptions & { maxTextLength?: number; enableSplit?: boolean; fontSize?: number; lineHeight?: number; offset?: number; }; index?: number; maxTextLength?: number; enableSplit?: boolean; }; export type barcode = { type: "barcode"; value: string; options?: barcodeOptions; index?: number; }; export type columns = { type: "columns"; columns: Array>; options?: chunkOptions & { columnWidth?: Array; }; index?: number; }; export type imageRow = { type: "imageRow"; width: number; height: number; images: Array; options?: baseChunk & imageOptions; index?: number; }; /** * Used to print a grid */ export type grid = { type: "grid"; fields: Record; width?: number; headerOptions?: chunkOptions; fieldOptions?: chunkOptions; }>; lines: Array; options?: chunkOptions & { lineRulerChar?: string; columnSeparatorChar?: string; borderSeparatorChar?: string; }; index?: number; }; /** * Used to print a list of properties */ export type properties = { type: "properties"; value: Array<{ name: string; value: string; options?: chunkOptions; }>; options?: chunkOptions; index?: number; }; /** * Used to print an image */ export type image = { type: "image"; data: Uint8Array; fileName?: string; width: number; height: number; options?: imageOptions; index?: number; fileMime?: string; }; export type ConfigurationSegment = { /** The space from the leftmost edge of the paper in pixels */ leftMargin?: number; /** The number of characters to print on a page. * @remarks 40 -> 3-inch receipt width | * 70 -> 4-inch receipt width (default value) | * 110 -> A4 paper size | */ pageWidth?: number; /** The height of the font in pixels. * @remakrs Used by ZPL devices for some fonts, as well * as during calculation of spacing after printing images with ZPL devices. */ fontHeight?: number; /** the width of the font in pixels * @remakrs Used by ZPL devices for some fonts, as well */ fontWidth?: number; lineSpacing?: number; font?: string; }; export type ConfigurationChunk = ConfigurationSegment & { printers: Record; }; export type template = { type: "template"; value: string; templateParams?: Record; };