webzlp
Version:
A small library using WebUSB to print labels on label printers.
200 lines • 8.58 kB
TypeScript
import * as Util from '../Util/index.js';
/** Utility type to create an 'update' object, making all properties optional and not readonly. */
export type UpdateFor<Type> = {
-readonly [Property in keyof Type]?: Type[Property];
};
/** The darkness of the printer setting, higher being printing darker. */
export type DarknessPercent = Util.Percent;
/** Coordinates on a 2D plane. */
export interface Coordinate {
/** Offset from the left side of the plane, incrementing to the right. --> */
left: number;
/** Offset from the top side of the plane, incrementing down. */
top: number;
}
/** The orientation of a media as it comes out of the printer. */
export declare enum PrintOrientation {
/** Right-side up when the printer faces the user. */
normal = 0,
/** Upside-down when the printer faces the user. */
inverted = 1
}
/** Printer speed values in inches per second (IPS). */
export declare enum PrintSpeed {
unknown = -1,
/** Mobile printers can't be configured otherwise. */
ipsAuto = 0,
/** The lowest speed a given printer supports. */
ipsPrinterMin = 1,
ips1 = 2,
/** EPL-only. Not often supported */
ips1_5 = 3,
ips2 = 4,
/** EPL-only. Not often supported */
ips2_5 = 5,
ips3 = 6,
/** EPL-only. Not often supported */
ips3_5 = 7,
ips4 = 8,
ips5 = 9,
ips6 = 10,
ips7 = 11,
ips8 = 12,
ips9 = 13,
ips10 = 14,
ips11 = 15,
ips12 = 16,
/** Not often supported */
ips13 = 17,
/** Not often supported */
ips14 = 18,
/** The highest speed a given printer supports. */
ipsPrinterMax = 1000
}
/** The thermal media print mode */
export declare enum ThermalPrintMode {
/** Direct thermal with no ribbon. Printer must support this mode. */
direct = 0,
/** Thermal transfer, using a ribbon. Printer must support this mode. */
transfer = 1
}
/** Behavior of pressing the feed button on the printer. */
export type FeedButtonMode = 'disabled' | 'feedBlank' | 'tapToPrint' | 'tapToReprint';
/** Describes the way the medias are marked for the printer to detect separate medias. */
export declare enum MediaMediaGapDetectionMode {
/** Media is one continuous media with no gaps. Used with cutters usually. */
continuous = 0,
/** Media is opaque with gaps between medias that can be sensed by the printer. */
webSensing = 1,
/** Media has black marks indicating media spacing. */
markSensing = 2,
/** Autodetect during calibration. G-series printers only. */
autoDuringCalibration = 3,
/** KR403 printer only. */
continuousVariableLength = 4
}
/** Printing behavior */
export declare enum MediaPrintMode {
/** Media advances so web is over tear bar, to be torn manually. */
tearOff = 0,
/** Media advances over Media Taken sensor. Printing pauses until media is removed. */
peel = 1,
/** Peel mode, but each media is fed to pre-peel a small portion. Helps some media types. ZPL only.*/
peelWithPrePeel = 2,
/** Peel mode, but printer waits for button tap between media. */
peelWithButtonTap = 3,
/** Media advances until web is over cutter. */
cutter = 4,
/** Cutter, but cut operation waits for separate command. ZPL only. */
cutterWaitForCommand = 5,
/** Media and liner are rewound on an external device. No backfeed motion. ZPL only. */
rewind = 6,
/** Media advances far enough for applicator device to grab. Printers with applicator ports only. */
applicator = 7,
/** Removes backfeed between RFID media, improving throughput. RFID printers only. */
rfid = 8,
/** Media is moved into a presentation position. ZPL only.*/
kiosk = 9
}
/** Percentage to backfeed after taking/cutting label, vs before printing the next. */
export type BackfeedAfterTaken = 'disabled' | '0' | '10' | '20' | '30' | '40' | '50' | '60' | '70' | '80' | '90' | '100';
/** Class for representing a printer's relationship between speeds and raw values */
export declare class SpeedTable {
private readonly speedTable;
get table(): ReadonlyMap<PrintSpeed, number>;
constructor(speedTable?: Map<PrintSpeed, number>);
/** Look up a speed enum value from a given whole number */
static getSpeedFromWholeNumber(speed: number): PrintSpeed;
/** Determine if a given speed will work with this model. */
isValid(speed: PrintSpeed): boolean;
/** Get a raw value to send to the printer for a speed. */
toRawSpeed(speed: PrintSpeed): number;
/** Get a speed value from the raw value sent by the printer. Defaults to minimum if parse fails. */
fromRawSpeed(rawSpeed?: number): PrintSpeed;
}
/** Configured print speeds for a printer. */
export declare class PrintSpeedSettings {
constructor(printSpeed: PrintSpeed, slewSpeed?: PrintSpeed);
/** Speed during printing media. */
printSpeed: PrintSpeed;
/** Speed during feeding a blank media. ZPL only, same as media speed for EPL. */
slewSpeed: PrintSpeed;
}
/** Hardware information about the printer that can't be modified. */
export interface IPrinterHardware {
/** The DPI of the printer. */
readonly dpi: number;
/** The firmware version information for the printer. */
readonly firmware: string;
/** The manufacturer of the printer. */
readonly manufacturer: string;
/** The model name of the printer. */
readonly model: string;
/** The maximum print width, in dots. */
readonly maxMediaWidthDots: number;
/** The maximum print length, in dots. */
readonly maxMediaLengthDots: number;
/** The maximum value for the darkness setting. */
readonly maxMediaDarkness: number;
/** The raw serial number of the printer. */
readonly serialNumber: string;
/** The speed table of supported speeds. */
readonly speedTable: SpeedTable;
}
/** Settings for printer behavior */
export interface IPrinterSettings {
/** What percentage of backfeed happens after cutting/taking label, vs before printing. */
readonly backfeedAfterTaken: BackfeedAfterTaken;
/** The behavior when pressing the feed button on the printer. */
readonly feedButtonMode: FeedButtonMode;
}
/** Printer options related to the media media being printed */
export interface IPrinterMedia {
/** How dark to print. 0 is blank, 99 is max darkness */
darknessPercent: DarknessPercent;
/** Mode the printer uses to detect separate medias when printing. */
mediaGapDetectMode: MediaMediaGapDetectionMode;
/**
* The gap / mark length between medias. Mandatory for markSensing black line mode.
* Media with webSensing gaps can use AutoSense to get this value.
*/
get mediaGapInches(): number;
/** Media web gap in dots */
mediaGapDots: number;
/** The offset in inches from the normal location of the media gap or black line. Can be negative. */
get mediaLineOffsetInches(): number;
/** The offset in dots from the normal location of the media gap or black line. Can be negative. */
mediaLineOffsetDots: number;
/** The length of the media media, in inches. */
get mediaLengthInches(): number;
/** The length of the media media, in dots. */
mediaLengthDots: number;
/** The width of the media media, in inches. */
get mediaWidthInches(): number;
/** The width of the media media, in dots. */
mediaWidthDots: number;
/** The offset of the printable area, from the top-left corner. */
mediaPrintOriginOffsetDots: Coordinate;
/**
* Value to use for rounding read-from-config media sizes.
*
* When reading the config from a printer the media width and length may be
* variable. When you set the media width to 4 inches it's translated into
* dots, and then the printer adds a calculated offset to that. This offset
* is unique per printer (so far as I have observed) and introduces noise.
* This value rounds the returned value to the nearest fraction of an inch.
*
* For example, with a rounding step of 0.25 (the default) if the printer
* returns a width 4.113 it will be rounded to 4.0
*/
mediaDimensionRoundingStep: number;
/** Media print speed settings */
speed: PrintSpeedSettings;
/** The media thermal print mode. */
thermalPrintMode: ThermalPrintMode;
/** The behavior of media after form printing. */
mediaPrintMode: MediaPrintMode;
/** Whether the media prints right-side-up or upside-down. */
printOrientation: PrintOrientation;
}
//# sourceMappingURL=ConfigurationTypes.d.ts.map