@linvix-sistemas/react-native-tectoysunmisdk
Version:
Pacote de comunicação com o hardware de Sunmi/Tectoy Automação, para efetuar impressão, comunicação com LCD entre outros.
82 lines (71 loc) • 1.6 kB
JavaScript
import { NativeModules } from 'react-native';
const {
TectoySunmiSdk
} = NativeModules;
/**
* Obtém o status da impressora
*/
const ObterStatus = async () => {
try {
const status = await TectoySunmiSdk.getStatus();
return JSON.parse(status);
} catch (error) {
throw error;
}
};
const ImprimirTexto = function () {
let texto = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
try {
TectoySunmiSdk.printText(texto);
} catch (error) {
throw error;
}
};
const ImprimirRAW = function (bytes) {
let feed_lines = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
try {
TectoySunmiSdk.printRaw(bytes, feed_lines);
} catch (error) {
throw error;
}
};
const AvancarLinha = function () {
let linhas = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
try {
TectoySunmiSdk.feedAdvancesLines(linhas);
} catch (error) {
throw error;
}
};
const Avancar3Linhas = () => {
try {
TectoySunmiSdk.feed3lines();
} catch (error) {
throw error;
}
};
const CortarPapel = () => {
try {
TectoySunmiSdk.cutpaper();
} catch (error) {
throw error;
}
};
const ImprimirQRCode = data => {
try {
TectoySunmiSdk.printQr(data.data, data.size, data.error);
} catch (error) {
throw error;
}
};
const NativeModuleTectToySunmiPrinterSDK = {
ObterStatus,
ImprimirTexto,
ImprimirQRCode,
ImprimirRAW,
CortarPapel,
AvancarLinha,
Avancar3Linhas
};
export default NativeModuleTectToySunmiPrinterSDK;
//# sourceMappingURL=tectoysunmi-printer.js.map