react-native-epson-escposprinter
Version:
A Turbo Module wrapper for the Epson ePOS Printer SDK.
90 lines (86 loc) • 3.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LogPeriod = exports.LogOutput = exports.LogLevel = exports.Log = void 0;
var _index = require("./errors/index.js");
var _NativeInterface = require("./NativeInterface.js");
let LogPeriod = exports.LogPeriod = /*#__PURE__*/function (LogPeriod) {
LogPeriod[LogPeriod["PERIOD_TEMPORARY"] = 0] = "PERIOD_TEMPORARY";
LogPeriod[LogPeriod["PERIOD_PERMANENT"] = 1] = "PERIOD_PERMANENT";
return LogPeriod;
}({});
let LogOutput = exports.LogOutput = /*#__PURE__*/function (LogOutput) {
LogOutput[LogOutput["OUTPUT_DISABLE"] = 0] = "OUTPUT_DISABLE";
LogOutput[LogOutput["OUTPUT_STORAGE"] = 1] = "OUTPUT_STORAGE";
LogOutput[LogOutput["OUTPUT_TCP"] = 2] = "OUTPUT_TCP";
return LogOutput;
}({});
let LogLevel = exports.LogLevel = /*#__PURE__*/function (LogLevel) {
LogLevel[LogLevel["LOGLEVEL_LOW"] = 0] = "LOGLEVEL_LOW";
return LogLevel;
}({});
class Log {
/**
* Disable logs.
*/
static async disable() {
try {
return await _NativeInterface.NativeInterface.setLogSettings(LogPeriod.PERIOD_TEMPORARY, LogOutput.OUTPUT_DISABLE, "", 1024, 1, LogLevel.LOGLEVEL_LOW);
} catch (error) {
throw (0, _index.getEpsonError)(error);
}
}
/**
* Enable logs and send the output to the device storage.
*/
static async enableLocal(
/**
* Specifies whether the log output function setting is temporary or
* permanent. The configuration file is not created for temporary setting
* but is created for permanent setting.
*
* @default LogPeriod.PERIOD_TEMPORARY
*/
period = LogPeriod.PERIOD_TEMPORARY,
/**
* Specifies the maximum capacity of the log stored in the storage.
*
* @default 10
*/
size = 10, level = LogLevel.LOGLEVEL_LOW) {
if (size <= 0 || size > 1000) {
throw new _index.PrinterParamError("Log size must be between 1 and 1000 MB.");
}
try {
return await _NativeInterface.NativeInterface.setLogSettings(period, LogOutput.OUTPUT_STORAGE, "", 1, size, level);
} catch (error) {
throw (0, _index.getEpsonError)(error);
}
}
/**
* Enable logs and stream output to the specified TCP endpoint.
*/
static async enableNetwork(/** Specifies the IP address in the IPv4 format for TCP communication. */
ip, /** Specifies the port number for TCP communication. */
port, level = LogLevel.LOGLEVEL_LOW) {
if (port < 1 || port > 65535) {
throw new _index.PrinterParamError("Port number must be between 1 and 65535.");
}
try {
return await _NativeInterface.NativeInterface.setLogSettings(LogPeriod.PERIOD_TEMPORARY, LogOutput.OUTPUT_TCP, ip, port, 1, level);
} catch (error) {
throw (0, _index.getEpsonError)(error);
}
}
/** Acquires the Epson ePOS SDK version. */
static async getSdkVersion() {
try {
return await _NativeInterface.NativeInterface.getSdkVersion();
} catch (error) {
throw (0, _index.getEpsonError)(error);
}
}
}
exports.Log = Log;
//# sourceMappingURL=Log.js.map