/** * The "base" XML stuff with minimal abstraction. * * @module */ import { XMLRootElement, XMLElement, XMLBinaryText, XMLDocumentRoot } from 'rsstrogen/xml'; import { EposImageData, EposImageHalftone } from './epos-image-helpers.js'; /** A printer font. */ export declare enum EposFont { FontA = "font_a", FontB = "font_b", FontC = "font_c", /** * @version printer-v3.2 */ FontD = "font_d", /** * @version printer-v3.2 */ FontE = "font_e", SpecialA = "special_a", SpecialB = "special_b" } /** The alignment on the horizontal axis */ export declare enum EposAlign { Center = "center", Left = "left", Right = "right" } /** How the printer should cut the feed */ export declare enum EposCutType { /** * Feed before cutting. */ Feed = "feed", /** * Cut exactly where the printer is right now. */ NoFeed = "no_feed", /** * TODO: Figure out behaviour */ Reserve = "reserve", /** * Didn't work on my printer * @experimental */ NoFeedFullCut = "no_feed_full_cut", /** * Didn't work on my printer * @experimental */ FeedFullCut = "feed_full_cut", /** * Didn't work on my printer * @experimental */ ReserveFullCut = "reserve_full_cut" } /** * The root `` element of the document. Everything of yours should be a child hereof. */ export declare class EposPrint extends XMLRootElement { constructor(); /** Wraps this {@link EposPrint} in a {@link SoapEnvelopeDocumentRoot}, {@link SoapEnvelope} and {@link SoapBody} */ toSoapDocument(): SoapEnvelopeDocumentRoot; } /** * A `` element. Formatting carries through to the next text elements. */ export declare class EposText extends XMLElement { private xmlTextChild?; private xmlTextChildIsBinary; constructor(content?: string); rawOptions: { width: number | undefined; height: number | undefined; smooth: boolean | undefined; align: EposAlign | undefined; font: EposFont | undefined; }; /** * Due to ePOS Formatting carrying through to future elements in the * sequence, this provides every option that {@link EposText} has as a * sensible default, trying to stay close to the printer's defaults. */ hardReset(): this; /** Creates a blank new {@link EposText.prototype.hardReset hardReset}-formatted {@link EposText} */ static hardReset(): EposText; /** * Whether to use "raw" mode when encoding text. * * Ensures, at the cost of size, that every character is pedantically * escaped. Useful for guaranteeing a parser will always get the * expected value back out. */ get raw(): boolean; set raw(value: boolean); get text(): string | undefined; set text(text: string | undefined); /** Wrapper around setting {@link EposText.prototype.text this.text} */ setText(text: string): this; /** * Similar to the `println` equivalent of `printf`, this simply wraps {@link EposText.prototype.setText this.setText} and adds a trailing newline. */ setTextLn(text: string): this; /** Clears {@link EposText.prototype.text this.text}, but preserves formatting options. */ clearText(): this; /** Sets the {@link EposAlign alignment} of this text. */ setAlignment(alignment: EposAlign | undefined): this; /** Alias of {@link EposText.prototype.setAlignment} */ align: (alignment: EposAlign | undefined) => this; set alignment(alignment: EposAlign | undefined); get alignment(): EposAlign | undefined; /** Sets the {@link EposFont font} of this text. */ setFont(font: EposFont | undefined): this; set font(font: EposFont | undefined); get font(): EposFont | undefined; /** Sets whether the printer should smooth the edges of this text. */ setSmooth(value?: boolean): this; get smooth(): boolean | undefined; set smooth(smoothing: boolean | undefined); /** Sets the size, as integer multiples, of each character. Printer defaults to (1,1). */ setSize(w?: number, h?: number): this; set size(size: { width?: number; height?: number; }); get size(): { width?: number; height?: number; }; toString(): string; } /** Epson Point of Sale system image modes. */ export declare enum EposImageMode { /** * Default. * * Uses {@link toMonoImage}. */ Monochrome = "mono", /** * Epson UI Tooltip: Only for supported models. * * Uses {@link toGrayImage}. * * @experimental Untested, due to the model I have not supporting this. TODO: Remove the experimental flag once it has been checked. */ Grayscale = "gray16" } /** The colour mode to use. Only {@link EposImageColour.Colour1 Colour1} is tested. */ export declare enum EposImageColour { /** * Only for supported models * * @experimental Untested, due to the model I have not supporting this. TODO: Remove the experimental flag once it has been checked. */ None = "none", /** Default */ Colour1 = "color_1", /** * Only for supported models * * @experimental Untested, due to the model I have not supporting this. TODO: Remove the experimental flag once it has been checked. */ Colour2 = "color_2", /** * Only for supported models * * @experimental Untested, due to the model I have not supporting this. TODO: Remove the experimental flag once it has been checked. */ Colour3 = "color_3", /** * Only for supported models * * @experimental Untested, due to the model I have not supporting this. TODO: Remove the experimental flag once it has been checked. */ Colour4 = "color_4" } export { EposImageHalftone } from './epos-image-helpers.js'; /** * Converts a Bit Matrix to an ImageData. * @param scale How much to multiply each dimension by. Non-ints are untested. <=0 untested. * * @experimental API may change at any time. Function may be moved elsewhere. Matrix being passed may change if zxing is replaced entirely. */ export declare const bitMatrixToImageData: (matrix: { getWidth(): number; getHeight(): number; get(x: number, y: number): boolean; }, scale?: number) => { data: Uint8Array; width: number; height: number; }; /** * An ePOS `` element. Embeds an image into the output. * * A bit of a work-in-progress. */ export declare class EposImage extends XMLElement { image: EposImageData; constructor(image: EposImageData); /** * The raw child used for the pure image data. It's contents are replaced in the {@link EposImage.toString toString()} function. */ protected readonly imageDataChild: XMLBinaryText; /** * The image's mode= and encoding function. See {@link EposImageMode}. * * Only {@link EposImageMode.Monochrome monochrome} is tested, due to the model I have not supporting any other value. * @experimental TODO: Remove the experimental flag once it has been checked. */ mode: EposImageMode; /** * The image's color=. See {@link EposImageColour}. * * Only {@link EposImageColour.Colour1 colour1} is tested, due to the model I have not supporting any other value. * @experimental TODO: Remove the experimental flag once it has been checked. */ colour: EposImageColour; /** * No-op when {@link EposImage.prototype.mode} === {@link EposImageMode.Grayscale} */ halftone: EposImageHalftone; /** * The gamma correction to use. */ brightness: number; /** * Chainable helper for setting {@link EposImage.halftone this.halftone}. * * No-op when {@link EposImage.prototype.mode} === {@link EposImageMode.Grayscale} */ setHalftone(halftone: EposImageHalftone): this; /** * Chainable helper for setting {@link EposImage.brightness this.brightness}. */ setBrightness(brightness: number): this; /** * Returns a Uint8Array of the image data. * * In {@link EposImageMode.Monochrome Monochrome} {@link EposImage.mode mode}, this uses {@link toMonoImage}. * In {@link EposImageMode.Grayscale} {@link EposImage.mode mode}, this uses {@link toGrayImage}. */ toEposImageData(): Uint8Array; /** * Sets the mode=, width=, height= and color= XML attributes. */ protected updateAttributes(): void; /** * Converts this `` to an XML String. * * Calls {@link EposImage.updateAttributes}. */ toString(): string; } /** * A `` element. * * Feeds forward the roll without printing anything on it. * * @example Separate 2 text elements by 20 units of feed * ```ts * new EposPrint() * .append( * new EposText('Hello,'), * new EposFeed().units(20), * new EposText('World!'), * ) * ``` * * @example Separate 2 text elements by a line feed (lf) * ```ts * new EposPrint() * .append( * new EposText('Hello,'), * EposFeed.lf(), // Shorthand for `new EposFeed().lf()` * new EposText('World!'), * ) * ``` * * @example Separate 2 text elements by 3 blank lines * ```ts * new EposPrint() * .append( * new EposText('Hello,'), * EposFeed.lines(3), // Shorthand for `new EposFeed().lines(3)` * new EposText('World!'), * ) * ``` */ export declare class EposFeed extends XMLElement { constructor(); /** * Makes this feed into a blank , removing any unit= or lines=. * * This, in practice, makes it into a simple line feed * * @see {@link EposFeed.units} * @see {@link EposFeed.lines} */ lf(): this; /** * Makes this feed forward {@link units} units. * * @param {number} units How many units to feed forward. * * @see {@link EposFeed.lf} * @see {@link EposFeed.lines} */ units(units: number): this; /** * Makes this feed forward {@link lines} lines. * * @param {number} lines How many lines to feed forward. * * @see {@link EposFeed.units} * @see {@link EposFeed.lf} */ lines(lines: number): this; /** * Creates a new EposFeed, before calling {@link EposFeed.units} on it. */ static unit(units: number): EposFeed; /** * Creates a new EposFeed, before calling {@link EposFeed.lf} on it. */ static lf(): EposFeed; /** * Creates a new EposFeed, before calling {@link EposFeed.lines} on it. */ static lines(lines: number): EposFeed; } /** * A `` element. * * Tells the printer to cut the document. * * @example Cut the feed after printing a hello world! * ```ts * new EposPrint().append( * new EposText('Hello, World!\n') * new EposCut(), * ) * ``` * @example Cut the feed after printing a customer receipt and a ticket * ```ts * new EposPrint().append( * new EposText(` * ...some text here... * ----------------------- * * Customer Receipt * * Payment Method: * Catgirlcard contactless * ************1234 * ----------------------- * ...some text here... * `) * .align(EposAlign.Center()), * new EposCut(), * new EposText(` * ...some text here... * Your Product: * `) * .align(EposAlign.Center()), * new EposFeed().units(30), * new EposAztec( * new Uint8Array(ticketData) * ), * new EposCut(), * ) * ``` */ export declare class EposCut extends XMLElement { type: EposCutType; constructor(type?: EposCutType); toString(): string; } /** * The document root, with the declaration element, for a Soap Envelope. * @see EposPrint.prototype.toSoapDocument * @see SoapEnvelope * @see SoapBody */ export declare class SoapEnvelopeDocumentRoot extends XMLDocumentRoot { constructor(); envelope(envelope: SoapEnvelope): this; } /** * The `` Root XML element for an XMLSoap document. * @see EposPrint.prototype.toSoapDocument * @see SoapEnvelopeDocumentRoot * @see SoapBody */ export declare class SoapEnvelope extends XMLRootElement { constructor(); body(body: SoapBody): this; } /** * The `` XML element for an XMLSoap document. * @see EposPrint.prototype.toSoapDocument * @see SoapEnvelopeDocumentRoot * @see SoapEnvelope */ export declare class SoapBody extends XMLElement { constructor(); } //# sourceMappingURL=epos-xml.d.ts.map