webzlp
Version:
A small library using WebUSB to print labels on label printers.
73 lines • 3.94 kB
TypeScript
import * as Conf from '../Configs/index.js';
export type PrinterCommandEffectTypes = "unknown"
/** Changes the printer config, necessitating an update of the cached config. */
| "altersConfig"
/** Causes the printer motor to engage, even if nothing is printed. */
| "feedsPaper"
/** Causes the printer to print labels, regardless of peel settings. */
| "feedsPaperIgnoringPeeler"
/** Causes the printer to disconnect or otherwise need reconnecting. */
| "lossOfConnection"
/** Causes something sharp to move. */
| "actuatesCutter"
/** Expects a response from the printer. */
| "waitsForResponse";
/** Flags to indicate special operations a command might cause. */
export declare class CommandEffectFlags extends Set<PrinterCommandEffectTypes> {
}
export declare const NoEffect: CommandEffectFlags;
export declare const AwaitsEffect: CommandEffectFlags;
/** A command that can be sent to a printer. */
export type IPrinterCommand = IPrinterCommandBase & (IPrinterBasicCommand | IPrinterExtendedCommand);
interface IPrinterCommandBase {
/** Get the display name of this command. */
readonly name: string;
/** Any effects this command may cause the printer to undergo. */
readonly effectFlags: CommandEffectFlags;
/** Get the human-readable output of this command. */
toDisplay(): string;
}
export type CommandTypeBasic = Exclude<CommandType, 'CustomCommand'>;
/** A basic printer command, common to all printer languages. */
export interface IPrinterBasicCommand extends IPrinterCommandBase {
/** Get the command type of this command. */
readonly type: CommandTypeBasic;
}
/** A custom command beyond the standard command set, with language-specific behavior. */
export interface IPrinterExtendedCommand extends IPrinterCommandBase {
/** Get the command type of this command. */
readonly type: Extract<CommandType, 'CustomCommand'>;
/** The unique identifier for this command. */
readonly typeExtended: symbol;
/** Gets the command languages this extended command can apply to. */
readonly commandLanguageApplicability: Conf.PrinterCommandLanguage;
}
/** Behavior to take for commands that belong inside or outside of a form. */
export declare enum CommandReorderBehavior {
/** Perform no reordering, non-form commands will be interpreted as form closing. */
closeForm = 0,
/** Reorder non-form commands to the end, retaining order. */
afterAllForms = 1,
/** Reorder non-form commands before all forms, retaining order. */
beforeAllForms = 2,
/**
* Throw an exception if a non-form command is within a form.
* You will need to explicitly close and open forms to use this option.
*/
throwError = 3
}
export declare const basicCommandTypes: readonly ["CustomCommand", "Identify", "RebootPrinter", "Raw", "NoOp", "GetStatus", "PrintConfiguration", "QueryConfiguration", "SaveCurrentConfiguration", "AutosenseMediaDimensions", "SetDarkness", "SetLabelDimensions", "SetLabelHome", "SetLabelPrintOriginOffset", "SetMediaToContinuousMedia", "SetMediaToWebGapMedia", "SetMediaToMarkMedia", "SetPrintDirection", "SetPrintSpeed", "SetBackfeedAfterTaken", "NewLabel", "StartLabel", "EndLabel", "CutNow", "Print", "ClearImageBuffer", "AddBox", "AddImage", "AddLine", "Offset"];
/** Union type of all possible commands that must be handled by command sets. */
export type CommandType = typeof basicCommandTypes[number];
/**A regular command or an extended command type. */
export type CommandAnyType = CommandType | symbol;
export declare function getCommandAnyType(cmd: IPrinterCommand | IPrinterExtendedCommand): CommandAnyType;
export declare abstract class BasicCommand implements IPrinterBasicCommand {
abstract name: string;
abstract type: CommandTypeBasic;
effectFlags: CommandEffectFlags;
toDisplay(): string;
constructor(effects?: PrinterCommandEffectTypes[]);
}
export {};
//# sourceMappingURL=Commands.d.ts.map