UNPKG

react-epson-epos-sdk

Version:

React library for managing Epson printers with ePOS SDK support.

29 lines (28 loc) 1.43 kB
import type { Dispatch, RefObject, SetStateAction } from "react"; import type { Printer } from "../../components/Printer"; import type { PrinterConfig } from "../printer.types"; import { ConnectionStatus, PrintResult } from "../PrinterProvider.enum"; import type { UnprintedQueueEntry } from "./internalTypes"; type Args = { instancesRef: RefObject<Map<string, Printer>>; printersRef: RefObject<PrinterConfig[]>; /** Per-id promise chain. Lives in a ref so it survives `useMemo` invalidations of `printForId`. */ lastOpByIdRef: RefObject<Map<string, Promise<void>>>; testMode: boolean; setStatusForId: (id: string, status: ConnectionStatus) => void; setUnprintedById: Dispatch<SetStateAction<Record<string, UnprintedQueueEntry[]>>>; }; export type PrintForIdOptions = { retryOnError?: boolean; /** Used by the heartbeat-flush to send queued data without disturbing the live buffer. */ fromQueue?: string[]; }; /** * Returns a per-id print function. Calls for the same id are serialized via a * promise chain so the buffer is never read across an `await`; different ids * run in parallel. On failure, chunks are requeued from a local snapshot. */ export declare function createPrintForId({ instancesRef, printersRef, lastOpByIdRef, testMode, setStatusForId, setUnprintedById, }: Args): (id: string, opts?: PrintForIdOptions) => Promise<{ printResult: PrintResult; }>; export {};