@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.
91 lines (77 loc) • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
const {
TectoySunmiSdk
} = _reactNative.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
};
var _default = NativeModuleTectToySunmiPrinterSDK;
exports.default = _default;
//# sourceMappingURL=tectoysunmi-printer.js.map