diff --git a/package.json b/package.json
index 148ceaa..213f921 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
- "build-lib": "ng build ng-thermal-print",
+ "build-lib": "ng build ng-thermal-print --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
@@ -50,4 +50,4 @@
"tslint": "~6.1.0",
"typescript": "3.9.7"
}
-}
+}
\ No newline at end of file
diff --git a/projects/ng-thermal-print/ng-package.prod.json b/projects/ng-thermal-print/ng-package.prod.json
index 4304957..5b41f41 100644
--- a/projects/ng-thermal-print/ng-package.prod.json
+++ b/projects/ng-thermal-print/ng-package.prod.json
@@ -1,7 +1,8 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/ng-thermal-print",
+ "deleteDestPath": false,
"lib": {
"entryFile": "src/public_api.ts"
}
-}
+}
\ No newline at end of file
diff --git a/projects/ng-thermal-print/package.json b/projects/ng-thermal-print/package.json
index 569b163..e511ff4 100644
--- a/projects/ng-thermal-print/package.json
+++ b/projects/ng-thermal-print/package.json
@@ -1,8 +1,13 @@
{
"name": "ng-thermal-print",
- "version": "0.1.6",
+ "version": "1.0.0",
"description": "An angular module to add thermal printing capabilities.",
- "keywords": ["Angular", "Library", "Thermal", "Printer"],
+ "keywords": [
+ "Angular",
+ "Library",
+ "Thermal",
+ "Printer"
+ ],
"repository": {
"type": "git",
"url": "https://github.com/bebo925/ng-thermal-print"
@@ -14,4 +19,4 @@
"dependencies": {
"tslib": "^2.0.0"
}
-}
+}
\ No newline at end of file
diff --git a/projects/ng-thermal-print/src/lib/js/StarWebPrintBuilder.js b/projects/ng-thermal-print/src/lib/js/StarWebPrintBuilder.js
index 7de86fe..28bdaf1 100644
--- a/projects/ng-thermal-print/src/lib/js/StarWebPrintBuilder.js
+++ b/projects/ng-thermal-print/src/lib/js/StarWebPrintBuilder.js
@@ -1,31 +1,341 @@
-//
-// StarWebPrintBuilder API
-//
-// Version 1.1.0
-//
-// Copyright 2012 STAR MICRONICS CO., LTD. All Rights Reserved.
-//
-
-var StarWebPrintBuilder=function(){};StarWebPrintBuilder.prototype.createAlignmentElement=function(b){var a=""};
-StarWebPrintBuilder.prototype.createBarcodeElement=function(b){var a;if(void 0!=b){a=""+this._encodeEscapeSequenceBinary(b.data)}else throw Error("Argument is undefined.");
-return a+=""};
-StarWebPrintBuilder.prototype.createBitImageElement=function(b){var a=""+this._encodeRasterImage(b.context.getImageData(d,
-e,c,f).data,c,f)}else throw Error("Argument is undefined.");return a+=""};StarWebPrintBuilder.prototype.createCutPaperElement=function(b){var a=""};
-StarWebPrintBuilder.prototype.createFeedElement=function(b){var a;if(void 0!=b)if(void 0!=b.line||void 0!=b.unit)a=""};
-StarWebPrintBuilder.prototype.createInitializationElement=function(b){var a=""};
-StarWebPrintBuilder.prototype.createLogoElement=function(b){var a=""};
-StarWebPrintBuilder.prototype.createPdf417Element=function(b){var a;if(void 0!=b){a=""+this._encodeEscapeSequenceBinary(b.data)}else throw Error("Argument is undefined.");
-return a+=""};StarWebPrintBuilder.prototype.createPeripheralElement=function(b){var a=""};
-StarWebPrintBuilder.prototype.createQrCodeElement=function(b){var a;if(void 0!=b){a=""+this._encodeEscapeSequenceBinary(b.data)}else throw Error("Argument is undefined.");return a+=""};
-StarWebPrintBuilder.prototype.createRawDataElement=function(b){if(void 0!=b){if(void 0==b.data)throw Error('Argument "data" is undefined.');b=""+this._encodeBase64Binary(b.data)}else throw Error("Argument is undefined.");return b+""};
-StarWebPrintBuilder.prototype.createRuledLineElement=function(b){var a=""};StarWebPrintBuilder.prototype.createSoundElement=function(b){var a=""};
-StarWebPrintBuilder.prototype.createTextElement=function(b){var a;if(void 0!=b)a="",a=!0==b.binary?a+this._encodeEscapeSequenceBinary(b.data):a+this._encodeEscapeSequence(b.data),a+=""):a+="/>";else throw Error("Argument is undefined.");return a};StarWebPrintBuilder.prototype.createHoldPrintElement=function(b){var a=""};
-StarWebPrintBuilder.prototype._analysisEnumAttribute=function(b,a,d){if(void 0!=a){if(!d.test(a))throw Error('Argument "'+b+'" is invalid.');return" "+b+'="'+a+'"'}return""};StarWebPrintBuilder.prototype._analysisValueAttribute=function(b,a,d,e){if(void 0!=a){if(ae)throw Error('Argument "'+b+'" is invalid.');return" "+b+'="'+a+'"'}return""};
-StarWebPrintBuilder.prototype._encodeEscapeSequence=function(b){var a=/[\\\x00-\x20\x26\x3c\x3e\x7f]/g;a.test(b)&&(b=b.replace(a,function(a){return"\\"==a?"\\\\":"\\x"+("0"+a.charCodeAt(0).toString(16)).slice(-2)}));return b};StarWebPrintBuilder.prototype._encodeEscapeSequenceBinary=function(b){var a=/[\\\x00-\x20\x26\x3c\x3e\x7f-\xff]/g;a.test(b)&&(b=b.replace(a,function(a){return"\\"==a?"\\\\":"\\x"+("0"+a.charCodeAt(0).toString(16)).slice(-2)}));return b};
-StarWebPrintBuilder.prototype._encodeBase64Binary=function(b){var a="",d=b.length;b+="\x00\x00";for(var e=0;e>18&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>12&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>6&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c&
-63));switch(d%3){case 1:return a.slice(0,-2)+"==";case 2:return a.slice(0,-1)+"="}return a};
-StarWebPrintBuilder.prototype._encodeRasterImage=function(b,a,d){for(var e=[[-254,-126,-222,-94,-246,-118,-214,-86],[-62,-190,-30,-158,-54,-182,-22,-150],[-206,-78,-238,-110,-198,-70,-230,-102],[-14,-142,-46,-174,-6,-134,-38,-166],[-242,-114,-210,-82,-250,-122,-218,-90],[-50,-178,-18,-146,-58,-186,-26,-154],[-194,-66,-226,-98,-202,-74,-234,-106],[-2,-130,-34,-162,-10,-138,-42,-170]],c="",f=0,g=0;g>=1))c+=String.fromCharCode(h),h=0,k=128;128!=k&&(c+=String.fromCharCode(h))}b=c;c="";a=b.length;b+="\x00\x00";for(g=0;g>18&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d>>12&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d>>6&63)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d&
-63);switch(a%3){case 1:return c.slice(0,-2)+"==";case 2:return c.slice(0,-1)+"="}return c};
+//
+// StarWebPrintBuilder API
+//
+// Version 1.1.0
+//
+// Copyright 2012 STAR MICRONICS CO., LTD. All Rights Reserved.
+//
+
+var StarWebPrintBuilder = function () {};
+StarWebPrintBuilder.prototype.createAlignmentElement = function (b) {
+ var a = "";
+};
+StarWebPrintBuilder.prototype.createBarcodeElement = function (b) {
+ var a;
+ if (void 0 != b) {
+ a =
+ "" + this._encodeEscapeSequenceBinary(b.data);
+ } else throw Error("Argument is undefined.");
+ return (a += "");
+};
+StarWebPrintBuilder.prototype.createBitImageElement = function (b) {
+ var a = "" +
+ this._encodeRasterImage(b.context.getImageData(d, e, c, f).data, c, f);
+ } else throw Error("Argument is undefined.");
+ return (a += "");
+};
+StarWebPrintBuilder.prototype.createCutPaperElement = function (b) {
+ var a = "";
+};
+StarWebPrintBuilder.prototype.createFeedElement = function (b) {
+ var a;
+ if (void 0 != b)
+ if (void 0 != b.line || void 0 != b.unit)
+ (a = "";
+};
+StarWebPrintBuilder.prototype.createInitializationElement = function (b) {
+ var a = "";
+};
+StarWebPrintBuilder.prototype.createLogoElement = function (b) {
+ var a = "";
+};
+StarWebPrintBuilder.prototype.createPdf417Element = function (b) {
+ var a;
+ if (void 0 != b) {
+ a =
+ "" + this._encodeEscapeSequenceBinary(b.data);
+ } else throw Error("Argument is undefined.");
+ return (a += "");
+};
+StarWebPrintBuilder.prototype.createPeripheralElement = function (b) {
+ var a = "";
+};
+StarWebPrintBuilder.prototype.createQrCodeElement = function (b) {
+ var a;
+ if (void 0 != b) {
+ a =
+ "" + this._encodeEscapeSequenceBinary(b.data);
+ } else throw Error("Argument is undefined.");
+ return (a += "");
+};
+StarWebPrintBuilder.prototype.createRawDataElement = function (b) {
+ if (void 0 != b) {
+ if (void 0 == b.data) throw Error('Argument "data" is undefined.');
+ b = "" + this._encodeBase64Binary(b.data);
+ } else throw Error("Argument is undefined.");
+ return b + "";
+};
+StarWebPrintBuilder.prototype.createRuledLineElement = function (b) {
+ var a = "";
+};
+StarWebPrintBuilder.prototype.createSoundElement = function (b) {
+ var a = "";
+};
+StarWebPrintBuilder.prototype.createTextElement = function (b) {
+ var a;
+ if (void 0 != b)
+ (a =
+ ""),
+ (a =
+ !0 == b.binary
+ ? a + this._encodeEscapeSequenceBinary(b.data)
+ : a + this._encodeEscapeSequence(b.data)),
+ (a += ""))
+ : (a += "/>");
+ else throw Error("Argument is undefined.");
+ return a;
+};
+StarWebPrintBuilder.prototype.createHoldPrintElement = function (b) {
+ var a = "";
+};
+StarWebPrintBuilder.prototype._analysisEnumAttribute = function (b, a, d) {
+ if (void 0 != a) {
+ if (!d.test(a)) throw Error('Argument "' + b + '" is invalid.');
+ return " " + b + '="' + a + '"';
+ }
+ return "";
+};
+StarWebPrintBuilder.prototype._analysisValueAttribute = function (b, a, d, e) {
+ if (void 0 != a) {
+ if (a < d || a > e) throw Error('Argument "' + b + '" is invalid.');
+ return " " + b + '="' + a + '"';
+ }
+ return "";
+};
+StarWebPrintBuilder.prototype._encodeEscapeSequence = function (b) {
+ var a = /[\\\x00-\x20\x26\x3c\x3e\x7f]/g;
+ a.test(b) &&
+ (b = b.replace(a, function (a) {
+ return "\\" == a
+ ? "\\\\"
+ : "\\x" + ("0" + a.charCodeAt(0).toString(16)).slice(-2);
+ }));
+ return b;
+};
+StarWebPrintBuilder.prototype._encodeEscapeSequenceBinary = function (b) {
+ var a = /[\\\x00-\x20\x26\x3c\x3e\x7f-\xff]/g;
+ a.test(b) &&
+ (b = b.replace(a, function (a) {
+ return "\\" == a
+ ? "\\\\"
+ : "\\x" + ("0" + a.charCodeAt(0).toString(16)).slice(-2);
+ }));
+ return b;
+};
+StarWebPrintBuilder.prototype._encodeBase64Binary = function (b) {
+ var a = "",
+ d = b.length;
+ b += "\x00\x00";
+ for (var e = 0; e < d; e += 3)
+ var c =
+ (b.charCodeAt(e) << 16) |
+ (b.charCodeAt(e + 1) << 8) |
+ b.charCodeAt(e + 2),
+ a =
+ a +
+ ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(
+ (c >> 18) & 63
+ ) +
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(
+ (c >> 12) & 63
+ ) +
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(
+ (c >> 6) & 63
+ ) +
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(
+ c & 63
+ ));
+ switch (d % 3) {
+ case 1:
+ return a.slice(0, -2) + "==";
+ case 2:
+ return a.slice(0, -1) + "=";
+ }
+ return a;
+};
+StarWebPrintBuilder.prototype._encodeRasterImage = function (b, a, d) {
+ for (
+ var e = [
+ [-254, -126, -222, -94, -246, -118, -214, -86],
+ [-62, -190, -30, -158, -54, -182, -22, -150],
+ [-206, -78, -238, -110, -198, -70, -230, -102],
+ [-14, -142, -46, -174, -6, -134, -38, -166],
+ [-242, -114, -210, -82, -250, -122, -218, -90],
+ [-50, -178, -18, -146, -58, -186, -26, -154],
+ [-194, -66, -226, -98, -202, -74, -234, -106],
+ [-2, -130, -34, -162, -10, -138, -42, -170],
+ ],
+ c = "",
+ f = 0,
+ g = 0;
+ g < d;
+ g++
+ ) {
+ for (var h = 0, k = 128, l = 0; l < a; l++)
+ if (
+ (((30 * b[f] + 59 * b[f + 1] + 11 * b[f + 2]) * b[f + 3] + 12800) /
+ 25500 -
+ b[f + 3] <
+ e[g & 7][l & 7] && (h |= k),
+ (f += 4),
+ 0 == (k >>= 1))
+ )
+ (c += String.fromCharCode(h)), (h = 0), (k = 128);
+ 128 != k && (c += String.fromCharCode(h));
+ }
+ b = c;
+ c = "";
+ a = b.length;
+ b += "\x00\x00";
+ for (g = 0; g < a; g += 3)
+ (d =
+ (b.charCodeAt(g) << 16) |
+ (b.charCodeAt(g + 1) << 8) |
+ b.charCodeAt(g + 2)),
+ (c +=
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(
+ (d >> 18) & 63
+ ) +
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(
+ (d >> 12) & 63
+ ) +
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(
+ (d >> 6) & 63
+ ) +
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(
+ d & 63
+ ));
+ switch (a % 3) {
+ case 1:
+ return c.slice(0, -2) + "==";
+ case 2:
+ return c.slice(0, -1) + "=";
+ }
+ return c;
+};
+
+export { StarWebPrintBuilder };
diff --git a/projects/ng-thermal-print/src/lib/js/StarWebPrintTrader.js b/projects/ng-thermal-print/src/lib/js/StarWebPrintTrader.js
index 78dda1d..5868973 100644
--- a/projects/ng-thermal-print/src/lib/js/StarWebPrintTrader.js
+++ b/projects/ng-thermal-print/src/lib/js/StarWebPrintTrader.js
@@ -1,22 +1,245 @@
-//
-// StarWebPrintTrader API
-//
-// Version 1.1.0
-//
-// Copyright 2012 STAR MICRONICS CO., LTD. All Rights Reserved.
-//
-
-var StarWebPrintTrader=function(a){this.papertype=this.checkedblock=this.url=null;this.timeout=9E4;this.onTimeout=this.onError=this.onReceive=null;this.holdprint_timeout=void 0;this._json=this._url=null;void 0!=a&&(void 0!=a.url&&(this.url=a.url),void 0!=a.checkedblock&&(this.checkedblock=a.checkedblock),void 0!=a.papertype&&(this.papertype=a.papertype),void 0!=a.timeout&&(this.timeout=a.timeout),void 0!=a.holdprint_timeout&&(this.holdprint_timeout=a.holdprint_timeout))},_handlerCallback={};
-function _onFinish(a){var b=_handlerCallback[a.url],c=a.response;_handlerCallback[a.url]=null;if(200==a.htmlCode)b.onReceive({traderSuccess:c.slice(c.indexOf("<success>")+15,c.indexOf("</success>")),traderCode:c.slice(c.indexOf("<code>")+12,c.indexOf("</code>")),traderStatus:c.slice(c.indexOf("<status>")+14,c.indexOf("</status>")),status:a.htmlCode,responseText:c});else b.onError({status:a.htmlCode,responseText:c})}
-StarWebPrintTrader.prototype._callMessageHandler=function(){var a=this;null==_handlerCallback[a._url]?(_handlerCallback[a._url]=a,webkit.messageHandlers.sendMessageHandler.postMessage(a._json)):setTimeout(function(){a._callMessageHandler()},500)};
-StarWebPrintTrader.prototype.sendMessage=function(a){var b=""+a.request+""),c;c='';c+=this._encodeEscapeSequence(b);c+="";c+="";b="";b=void 0!=
-a.url?a.url:this.url;if(/^https?:\/\/(localhost|127\.0\.0\.1):8001\//.test(b.toLowerCase())&&-1!=navigator.userAgent.indexOf("webPRNTSupportMessageHandler"))this._json=JSON.stringify({url:b,body:c}),this._url=b,this._callMessageHandler();else{var d=null;if(window.XMLHttpRequest)d=new XMLHttpRequest;else if(window.ActiveXObject)d=new ActiveXObject("Microsoft.XMLHTTP");else{if(this.onError)this.onError({status:10001,responseText:"XMLHttpRequest is not supported."});return}if(-1!=navigator.userAgent.indexOf("iPad;")||
--1!=navigator.userAgent.indexOf("iPhone;")||-1!=navigator.userAgent.indexOf("iPod touch;")||-1!=navigator.userAgent.indexOf("Android"))if(-1==navigator.userAgent.indexOf("WebPRNTSupportHTTPS")&&(0==b.toLowerCase().indexOf("https://localhost")||0==b.toLowerCase().indexOf("https://127.0.0.1")))b="http://"+b.substring(8);try{d.open("POST",b,!0)}catch(f){if(this.onError)this.onError({status:10002,responseText:f.message});return}try{void 0!=a.timeout?d.timeout=a.timeout:this.timeout&&(d.timeout=this.timeout)}catch(h){}d.setRequestHeader("Content-Type",
-"text/xml; charset=UTF-8");var e=this;d.onreadystatechange=function(){if(4==d.readyState)try{if(200==d.status){var a=d.responseXML.getElementsByTagName("Response");if(0")+9,b.indexOf("")),traderCode:b.slice(b.indexOf("")+6,b.indexOf("
")),traderStatus:b.slice(b.indexOf("")+8,b.indexOf("")),status:d.status,responseText:d.responseText})}}else if(e.onError)e.onError({status:d.status,
-responseText:d.responseText})}else if(e.onError)e.onError({status:d.status,responseText:d.responseText})}catch(c){if(e.onError)e.onError({status:0,responseText:"Connection timeout occurred."})}};try{d.ontimeout=function(){if(e.onTimeout)e.onTimeout()}}catch(k){}try{d.send(c)}catch(g){if(this.onError)this.onError({status:10003,responseText:g.message})}}};StarWebPrintTrader.prototype._onHandlerSuccess=function(a){if(trader.onReceive)trader.onReceive(a)};
-StarWebPrintTrader.prototype._onHandlerError=function(a){if(trader.onError)trader.onError(a)};StarWebPrintTrader.prototype.isCoverOpen=function(a){return parseInt(a.traderStatus.substr(4,2),16)&32?!0:!1};StarWebPrintTrader.prototype.isOffLine=function(a){return parseInt(a.traderStatus.substr(4,2),16)&8?!0:!1};StarWebPrintTrader.prototype.isCompulsionSwitchClose=function(a){return parseInt(a.traderStatus.substr(4,2),16)&4?!0:!1};
-StarWebPrintTrader.prototype.isEtbCommandExecute=function(a){return parseInt(a.traderStatus.substr(4,2),16)&2?!0:!1};StarWebPrintTrader.prototype.isHighTemperatureStop=function(a){return parseInt(a.traderStatus.substr(6,2),16)&64?!0:!1};StarWebPrintTrader.prototype.isNonRecoverableError=function(a){return parseInt(a.traderStatus.substr(6,2),16)&32?!0:!1};StarWebPrintTrader.prototype.isAutoCutterError=function(a){return parseInt(a.traderStatus.substr(6,2),16)&8?!0:!1};
-StarWebPrintTrader.prototype.isBlackMarkError=function(a){return parseInt(a.traderStatus.substr(8,2),16)&8?!0:!1};StarWebPrintTrader.prototype.isPaperEnd=function(a){return parseInt(a.traderStatus.substr(10,2),16)&8?!0:!1};StarWebPrintTrader.prototype.isPaperNearEnd=function(a){return parseInt(a.traderStatus.substr(10,2),16)&4?!0:!1};StarWebPrintTrader.prototype.isPaperPresent=function(a){return parseInt(a.traderStatus.substr(12,2),16)&2?!0:!1};
-StarWebPrintTrader.prototype.extractionEtbCounter=function(a){var b=0;parseInt(a.traderStatus.substr(14,2),16)&64&&(b|=16);parseInt(a.traderStatus.substr(14,2),16)&32&&(b|=8);parseInt(a.traderStatus.substr(14,2),16)&8&&(b|=4);parseInt(a.traderStatus.substr(14,2),16)&4&&(b|=2);parseInt(a.traderStatus.substr(14,2),16)&2&&(b|=1);return b};
-StarWebPrintTrader.prototype._encodeEscapeSequence=function(a){var b=/[<>&]/g;b.test(a)&&(a=a.replace(b,function(a){switch(a){case "<":return"<";case ">":return">"}return"&"}));return a};
+//
+// StarWebPrintTrader API
+//
+// Version 1.1.0
+//
+// Copyright 2012 STAR MICRONICS CO., LTD. All Rights Reserved.
+//
+
+var StarWebPrintTrader = function (a) {
+ this.papertype = this.checkedblock = this.url = null;
+ this.timeout = 9e4;
+ this.onTimeout = this.onError = this.onReceive = null;
+ this.holdprint_timeout = void 0;
+ this._json = this._url = null;
+ void 0 != a &&
+ (void 0 != a.url && (this.url = a.url),
+ void 0 != a.checkedblock && (this.checkedblock = a.checkedblock),
+ void 0 != a.papertype && (this.papertype = a.papertype),
+ void 0 != a.timeout && (this.timeout = a.timeout),
+ void 0 != a.holdprint_timeout &&
+ (this.holdprint_timeout = a.holdprint_timeout));
+ },
+ _handlerCallback = {};
+function _onFinish(a) {
+ var b = _handlerCallback[a.url],
+ c = a.response;
+ _handlerCallback[a.url] = null;
+ if (200 == a.htmlCode)
+ b.onReceive({
+ traderSuccess: c.slice(
+ c.indexOf("<success>") + 15,
+ c.indexOf("</success>")
+ ),
+ traderCode: c.slice(
+ c.indexOf("<code>") + 12,
+ c.indexOf("</code>")
+ ),
+ traderStatus: c.slice(
+ c.indexOf("<status>") + 14,
+ c.indexOf("</status>")
+ ),
+ status: a.htmlCode,
+ responseText: c,
+ });
+ else b.onError({ status: a.htmlCode, responseText: c });
+}
+StarWebPrintTrader.prototype._callMessageHandler = function () {
+ var a = this;
+ null == _handlerCallback[a._url]
+ ? ((_handlerCallback[a._url] = a),
+ webkit.messageHandlers.sendMessageHandler.postMessage(a._json))
+ : setTimeout(function () {
+ a._callMessageHandler();
+ }, 500);
+};
+StarWebPrintTrader.prototype.sendMessage = function (a) {
+ var b = "" + a.request + ""),
+ c;
+ c =
+ '';
+ c += this._encodeEscapeSequence(b);
+ c += "";
+ c += "";
+ b = "";
+ b = void 0 != a.url ? a.url : this.url;
+ if (
+ /^https?:\/\/(localhost|127\.0\.0\.1):8001\//.test(b.toLowerCase()) &&
+ -1 != navigator.userAgent.indexOf("webPRNTSupportMessageHandler")
+ )
+ (this._json = JSON.stringify({ url: b, body: c })),
+ (this._url = b),
+ this._callMessageHandler();
+ else {
+ var d = null;
+ if (window.XMLHttpRequest) d = new XMLHttpRequest();
+ else if (window.ActiveXObject) d = new ActiveXObject("Microsoft.XMLHTTP");
+ else {
+ if (this.onError)
+ this.onError({
+ status: 10001,
+ responseText: "XMLHttpRequest is not supported.",
+ });
+ return;
+ }
+ if (
+ -1 != navigator.userAgent.indexOf("iPad;") ||
+ -1 != navigator.userAgent.indexOf("iPhone;") ||
+ -1 != navigator.userAgent.indexOf("iPod touch;") ||
+ -1 != navigator.userAgent.indexOf("Android")
+ )
+ if (
+ -1 == navigator.userAgent.indexOf("WebPRNTSupportHTTPS") &&
+ (0 == b.toLowerCase().indexOf("https://localhost") ||
+ 0 == b.toLowerCase().indexOf("https://127.0.0.1"))
+ )
+ b = "http://" + b.substring(8);
+ try {
+ d.open("POST", b, !0);
+ } catch (f) {
+ if (this.onError)
+ this.onError({ status: 10002, responseText: f.message });
+ return;
+ }
+ try {
+ void 0 != a.timeout
+ ? (d.timeout = a.timeout)
+ : this.timeout && (d.timeout = this.timeout);
+ } catch (h) {}
+ d.setRequestHeader("Content-Type", "text/xml; charset=UTF-8");
+ var e = this;
+ d.onreadystatechange = function () {
+ if (4 == d.readyState)
+ try {
+ if (200 == d.status) {
+ var a = d.responseXML.getElementsByTagName("Response");
+ if (0 < a.length) {
+ if (e.onReceive) {
+ var b = a[0].childNodes[0].nodeValue;
+ e.onReceive({
+ traderSuccess: b.slice(
+ b.indexOf("") + 9,
+ b.indexOf("")
+ ),
+ traderCode: b.slice(
+ b.indexOf("") + 6,
+ b.indexOf("
")
+ ),
+ traderStatus: b.slice(
+ b.indexOf("") + 8,
+ b.indexOf("")
+ ),
+ status: d.status,
+ responseText: d.responseText,
+ });
+ }
+ } else if (e.onError)
+ e.onError({ status: d.status, responseText: d.responseText });
+ } else if (e.onError)
+ e.onError({ status: d.status, responseText: d.responseText });
+ } catch (c) {
+ if (e.onError)
+ e.onError({
+ status: 0,
+ responseText: "Connection timeout occurred.",
+ });
+ }
+ };
+ try {
+ d.ontimeout = function () {
+ if (e.onTimeout) e.onTimeout();
+ };
+ } catch (k) {}
+ try {
+ d.send(c);
+ } catch (g) {
+ if (this.onError)
+ this.onError({ status: 10003, responseText: g.message });
+ }
+ }
+};
+StarWebPrintTrader.prototype._onHandlerSuccess = function (a) {
+ if (trader.onReceive) trader.onReceive(a);
+};
+StarWebPrintTrader.prototype._onHandlerError = function (a) {
+ if (trader.onError) trader.onError(a);
+};
+StarWebPrintTrader.prototype.isCoverOpen = function (a) {
+ return parseInt(a.traderStatus.substr(4, 2), 16) & 32 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isOffLine = function (a) {
+ return parseInt(a.traderStatus.substr(4, 2), 16) & 8 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isCompulsionSwitchClose = function (a) {
+ return parseInt(a.traderStatus.substr(4, 2), 16) & 4 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isEtbCommandExecute = function (a) {
+ return parseInt(a.traderStatus.substr(4, 2), 16) & 2 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isHighTemperatureStop = function (a) {
+ return parseInt(a.traderStatus.substr(6, 2), 16) & 64 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isNonRecoverableError = function (a) {
+ return parseInt(a.traderStatus.substr(6, 2), 16) & 32 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isAutoCutterError = function (a) {
+ return parseInt(a.traderStatus.substr(6, 2), 16) & 8 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isBlackMarkError = function (a) {
+ return parseInt(a.traderStatus.substr(8, 2), 16) & 8 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isPaperEnd = function (a) {
+ return parseInt(a.traderStatus.substr(10, 2), 16) & 8 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isPaperNearEnd = function (a) {
+ return parseInt(a.traderStatus.substr(10, 2), 16) & 4 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.isPaperPresent = function (a) {
+ return parseInt(a.traderStatus.substr(12, 2), 16) & 2 ? !0 : !1;
+};
+StarWebPrintTrader.prototype.extractionEtbCounter = function (a) {
+ var b = 0;
+ parseInt(a.traderStatus.substr(14, 2), 16) & 64 && (b |= 16);
+ parseInt(a.traderStatus.substr(14, 2), 16) & 32 && (b |= 8);
+ parseInt(a.traderStatus.substr(14, 2), 16) & 8 && (b |= 4);
+ parseInt(a.traderStatus.substr(14, 2), 16) & 4 && (b |= 2);
+ parseInt(a.traderStatus.substr(14, 2), 16) & 2 && (b |= 1);
+ return b;
+};
+StarWebPrintTrader.prototype._encodeEscapeSequence = function (a) {
+ var b = /[<>&]/g;
+ b.test(a) &&
+ (a = a.replace(b, function (a) {
+ switch (a) {
+ case "<":
+ return "<";
+ case ">":
+ return ">";
+ }
+ return "&";
+ }));
+ return a;
+};
+
+export { StarWebPrintTrader };
diff --git a/projects/ng-thermal-print/tsconfig.lib.json b/projects/ng-thermal-print/tsconfig.lib.json
index b3c96c1..86039bc 100644
--- a/projects/ng-thermal-print/tsconfig.lib.json
+++ b/projects/ng-thermal-print/tsconfig.lib.json
@@ -12,10 +12,7 @@
"experimentalDecorators": true,
"importHelpers": true,
"types": ["w3c-web-usb"],
- "lib": [
- "dom",
- "es2015"
- ]
+ "lib": ["dom", "es2015"]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
@@ -25,8 +22,5 @@
"flatModuleId": "AUTOGENERATED",
"flatModuleOutFile": "AUTOGENERATED"
},
- "exclude": [
- "src/test.ts",
- "**/*.spec.ts"
- ]
+ "exclude": ["src/test.ts", "**/*.spec.ts"]
}