import { Align, Align as Align$1, BarcodeOptions, BarcodeOptions as BarcodeOptions$1, BarcodeType, BarcodeType as BarcodeType$1, CashDrawerPin, CashDrawerPin as CashDrawerPin$1, CharacterSet, DeserializedCommand, DeserializedCommandName, Printer, PrinterOptions, PrinterType, QRCodeOptions, QRCodeOptions as QRCodeOptions$1, TextFont, TextFont as TextFont$1, TextSize, TextSize as TextSize$1, TextUnderline, TextUnderline as TextUnderline$1, TextWordBreak, decode, deserialize, encode } from "@react-thermal-printer/printer"; import * as react_jsx_runtime0 from "react/jsx-runtime"; import { ComponentProps, JSX, ReactElement, ReactNode } from "react"; import { Image, ImageToRasterOptions, ImageTransform } from "@react-thermal-printer/image"; //#region src/types/PrinterContext.d.ts interface PrinterContext { printer: Printer; width: number; reset(): void; } //#endregion //#region src/types/Printable.d.ts interface Printable { (props: Props): JSX.Element | null; print: (elem: ReactElement, context: PrinterContext) => void | Promise; } //#endregion //#region src/components/Barcode.d.ts interface BarcodeProps extends BarcodeOptions$1 { type: BarcodeType$1; align?: Align$1; content: string; } /** * @public * @name Barcode * @category components * @signature * ```tsx * function Barcode(props: BarcodeProps): JSX.Element; * ``` * * @description * Print barcode. * * ```tsx * * * * ``` */ declare const Barcode: Printable; //#endregion //#region src/types/HTMLProps.d.ts type JSXElement = keyof JSX.IntrinsicElements; type JSXElementProps = JSX.IntrinsicElements[E]; type ExtendHTMLProps = Props & Omit, keyof Props>; //#endregion //#region src/components/Br.d.ts type BrProps = ExtendHTMLProps<'br'>; /** * @public * @name Br * @category components * @signature * ```tsx * function Br(props: BrProps): JSX.Element; * ``` * * @description * Feed line. * * ```tsx *
* ``` */ declare const Br: Printable; //#endregion //#region src/components/Cashdraw.d.ts interface CashdrawProps { /** pin to generate pulse */ pin: CashDrawerPin$1; } /** * @public * @name Cashdraw * @category components * @signature * ```tsx * function Cashdraw(props: CashdrawProps): JSX.Element; * ``` * * @description * Open cash drawer. * * ```tsx * * * ``` */ declare const Cashdraw: Printable; //#endregion //#region src/components/Cut.d.ts interface CutProps { /** * cut after line feeds * @default 6 */ lineFeeds?: number; /** * partial cut * @default false */ partial?: boolean; } /** * @public * @name Cut * @category components * @signature * ```tsx * function Cut(props: CutProps): JSX.Element; * ``` * * @description * Cut the paper. * * Perform full/partial cutting, and feeds lines after cutting. * * ```tsx * * * // partial cut * * ``` */ declare const Cut: Printable; //#endregion //#region src/components/Image.d.ts type ImageProps = ExtendHTMLProps<'img', { align?: Align$1; src: string; /** * Image transformer. * @example * // Greyscale dithering with floyd-steinberg algorithm. * import { transforms } from '@react-thermal-printer/image'; * * */ transforms?: ImageTransform[]; rgbToBlack?: ImageToRasterOptions['rgbToBlack']; /** * Image data reader * @default read data from and */ reader?: (elem: ReactElement) => Promise; }>; /** * @public * @name Image * @category components * @signature * ```tsx * function Image(props: ImageProps): JSX.Element; * ``` * * @description * Print image bitmap. * * ```tsx * * * * * // A custom reader for reading image binary data. * function myCustomImageReader( * elem: ReactElement> * ): Promise; * ``` * * By passing transform functions, image can be converted. * * The example below applies the [Floyd-Steinberg dithering](https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering) algorithm: * ```tsx * import { transforms } from '@react-thermal-printer/image'; * * * ``` */ declare const ImageComp: Printable; //#endregion //#region src/components/Line.d.ts type LineProps = ExtendHTMLProps<'hr', { /** * Character to draw line * @default '-' */ character?: string; }>; /** * @public * @name Line * @category components * @signature * ```tsx * function Line(props: LineProps): JSX.Element; * ``` * * @description * Draw line. Prints the character as much as the `width` which from ``. * * ```tsx * * * ``` */ declare const Line: Printable; //#endregion //#region src/components/Printer.d.ts interface PrinterProps$1 extends PrinterOptions { /** * number of characters in one line * @default 48 */ width?: number; /** * whether to put initialize command to last * @default true */ initialize?: boolean; /** log esc/pos commands before render. */ debug?: boolean; children: ReactNode; } /** * @public * @name Printer * @category components * @signature * ```tsx * function Printer(props: PrinterProps): JSX.Element; * ``` * * @description * Interface of thermal printer. * * Requires `type` to determine a printer type. * * Currently, supports `epson` and `start` printers. * * ```tsx * ... * ... * ... * ``` * * ### With custom encoder * Pass `encoder` prop to use custom encoder. * * ```tsx * // utf8 encoding * const encoder = text => new TextEncoder().encode(text); * const receipt = ( * * ... * * ); * ``` */ declare function PrinterComp({ type, width, characterSet, initialize, debug, children, className, ...props }: ExtendHTMLProps<'div', PrinterProps$1>): react_jsx_runtime0.JSX.Element; //#endregion //#region src/components/QRCode.d.ts interface QRCodeProps extends QRCodeOptions$1 { align?: Align$1; content: string; } /** * @public * @name QRCode * @category components * @signature * ```tsx * function QRCode(props: QRCodeProps): JSX.Element; * ``` * * @description * Print qr code (2d barcode). * * ```tsx * * * ``` */ declare const QRCode: Printable; //#endregion //#region src/components/Raw.d.ts interface RawProps { data: Uint8Array | number[]; } /** * @public * @name Raw * @category components * @signature * ```tsx * function Raw(props: RawProps): JSX.Element; * ``` * * @description * Print raw data. * * ```tsx * * ``` */ declare const Raw: Printable; //#endregion //#region src/components/Text.d.ts type TextProps = ExtendHTMLProps<'div', { align?: Align$1; bold?: boolean; font?: TextFont$1; underline?: TextUnderline$1; invert?: boolean; size?: { width: TextSize$1; height: TextSize$1; }; wordBreak?: 'break-all' | 'break-word'; /** if true, don't feed line after print text */ inline?: boolean; children?: ReactNode; }>; /** * @public * @name Text * @category components * @signature * ```tsx * function Text(props: TextProps): JSX.Element; * ``` * * @description * Display text, and change text size or style to make it bold, underline, etc. * * `` component also allows `
` element props. * * **Note**: `` allows only string nodes. * * ```tsx * text * fragment is {'allowed'} * center text * right text * bold text * underline text * invert text * big size text * ``` */ declare const Text: Printable; //#endregion //#region src/components/Row.d.ts type RowProps = ExtendHTMLProps<'div', { left: string | ReactElement>; center?: string | ReactElement>; right: string | ReactElement>; /** * gap between left and right * @default 0 */ gap?: number; children?: never; }>; /** * @public * @name Row * @category components * @signature * ```tsx * function Row(props: RowProps): JSX.Element; * ``` * * @description * Display `` on the left, center and right sides. * * ```tsx * * * * left} * right="right" * /> * left} * right="very very long text will be multi line placed." * /> * ``` */ declare const Row: Printable; //#endregion //#region src/render.d.ts type PrinterProps = ComponentProps; interface RenderOptions { resetPrinter?: (printer: Printer) => void; } /** * @public * @name render * @category functions * @signature * ```typescript * function render(elem: ReactElement, options?: RenderOptions): Promise; * ``` * * @description * Render the React element as printable binary data. * * @param {ReactElement} elem - The React element to render. * @param {RenderOptions} [options] - Optional rendering options. * @returns {Promise} The printable binary data. * * @example * ```tsx * import { Printer, Text, render } from 'react-thermal-printer'; * * const receipt = ( * * $5.00 * * ); * const data = await render(receipt); * * // Prints receipt data via serial port. * const port = await navigator.serial.requestPort(); * await port.open({ baudRate: 9600 }); * const writer = port.writable.getWriter(); * await writer.write(data); * writer.releaseLock(); * ``` */ declare function render(elem: ReactElement, options?: RenderOptions): Promise; //#endregion //#region src/utils/textLength.d.ts declare function textLength(text: string, { size }?: { size?: TextSize$1; }): number; //#endregion //#region src/utils/wrapText.d.ts /** wrap text to multiple lines */ declare function wrapText(text: string, options: { size?: TextSize$1; width: number; wordBreak?: TextWordBreak; }): string[]; //#endregion export { type Align, Barcode, type BarcodeOptions, BarcodeProps, type BarcodeType, Br, BrProps, type CashDrawerPin, Cashdraw, CashdrawProps, type CharacterSet, Cut, CutProps, type DeserializedCommand, type DeserializedCommandName, ImageComp as Image, Line, LineProps, PrinterComp as Printer, type PrinterType, QRCode, type QRCodeOptions, QRCodeProps, Raw, RawProps, RenderOptions, Row, RowProps, Text, type TextFont, TextProps, type TextSize, type TextUnderline, decode, deserialize, encode, render, textLength, wrapText };