taro-bluetooth-print 2.15.2 → 2.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/dist/adapters/index.cjs.js +1 -0
- package/dist/adapters/index.es.js +1 -0
- package/dist/chunks/AdapterFactory-B91w5soC.js +1 -0
- package/dist/chunks/AdapterFactory-sRvkpRnt.js +1 -0
- package/dist/chunks/EscPosDriver-Byd1u4Jk.js +1 -0
- package/dist/chunks/EscPosDriver-DGK4usVf.js +1 -0
- package/dist/chunks/index-CNH0TeFh.js +1 -0
- package/dist/chunks/index-DI6d-y8j.js +1 -0
- package/dist/chunks/shared-C3EQK7YH.js +1 -0
- package/dist/chunks/shared-DuaS72fL.js +1 -0
- package/dist/core/index.cjs.js +1 -0
- package/dist/core/index.es.js +1 -0
- package/dist/drivers/index.cjs.js +1 -0
- package/dist/drivers/index.es.js +1 -0
- package/dist/encoding/index.cjs.js +1 -0
- package/dist/encoding/index.es.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/types/core/BluetoothPrinter.d.ts +37 -0
- package/package.json +7 -3
- package/src/core/BluetoothPrinter.ts +66 -4
- package/dist/hero-illustration.svg +0 -44
- package/dist/index.umd.js +0 -1
- package/dist/logo.svg +0 -17
- package/dist/manifest.webmanifest +0 -17
- package/dist/offline.html +0 -146
- package/dist/service-worker.js +0 -161
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-CNH0TeFh.js");exports.BluetoothPrinter=e.B,exports.EventEmitter=e.E;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as t,E as e}from"../chunks/index-DI6d-y8j.js";export{t as BluetoothPrinter,e as EventEmitter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty,s=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,r=Math.pow,i=(s,e,n)=>e in s?t(s,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[e]=n;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../chunks/EscPosDriver-Byd1u4Jk.js"),a=require("../chunks/shared-C3EQK7YH.js");class o extends h.E{printAndFeed(t){return[new Uint8Array([27,100,t])]}}class u extends h.E{init(){return super.init()}getStatus(){return[new Uint8Array([27,105])]}getDetailedStatus(){const t=[];for(let s=1;4>=s;s++)t.push(new Uint8Array([16,4,s]));return t}feedAndCut(t){return[new Uint8Array([27,100,t]),new Uint8Array([29,86,0])]}}class c extends h.E{sleep(){return[new Uint8Array([27,61,1])]}wakeUp(){return[new Uint8Array([0])]}wakeUpDeep(){const t=[];for(let s=0;5>s;s++)t.push(new Uint8Array([0]));return t.push(new Uint8Array([27,64])),t}setAutoSleep(t){return[new Uint8Array([27,61,t?1:0])]}}function m(t,r,h={}){const a=t;return a.code128=function(s,e=0,n=0,i=50){return r.call(t,s,{x:e,y:n,type:"128",height:i})},a.code39=function(a,o=0,u=0,c=50){return r.call(t,a,((t,r)=>{for(var h in r||(r={}))e.call(r,h)&&i(t,h,r[h]);if(s)for(var h of s(r))n.call(r,h)&&i(t,h,r[h]);return t})({x:o,y:u,type:"39",height:c},h))},a}exports.EscPos=h.E,exports.CpclDriver=class{constructor(t=576,s=0){this.commands=[],this.logger=a.L.scope("CpclDriver"),this.pageWidth=576,this.pageHeight=0,this.pageWidth=t,this.pageHeight=s,m(this,this.barcode.bind(this),{wide:2,narrow:1})}setPageSize(t,s=0){return this.pageWidth=t,this.pageHeight=s,this}usePageSize(t){const[s,e]={"4X6":[576,864],"4X4":[576,576],"4X2":[576,288],"2.25X1.25":[324,180],A4:[992,1406],A5:[701,992],LETTER:[1050,1500],CUSTOM:[576,0]}[t]||[576,0];return this.pageWidth=s,this.pageHeight=e,this}pageStart(){return this.commands.push("! U1 SETLP 5 0 30"),this.commands.push("! U1 PAGE WIDTH "+this.pageWidth),this.pageHeight>0&&this.commands.push("! U1 PAGE HEIGHT "+this.pageHeight),this.commands.push("START"),this}pageEnd(){return this.commands.push("END"),this}formFeed(){return this.commands.push("FORM"),this}setLinePrint(t=5,s=0,e=30){return this.commands.push(`! U1 SETLP ${t} ${s} ${e}`),this}setFont(t=3,s=1,e=1,n=0){const r={0:"N",90:"R",180:"B",270:"I"}[n]||"N";return this.commands.push(`! U1 SETLP ${t} ${s} ${e} ${r}`),this}text(t){return this.commands.push("! U1 TEXT "+this.escapeText(t)),this}textAt(t,s){const{x:e=0,y:n=0,font:r=3,xMulti:i=1,yMulti:h=1,rotation:a=0}=s,o={0:"N",90:"R",180:"B",270:"I"}[a]||"N";return this.commands.push(`! U1 SETLP ${r} ${i} ${h} ${o}`),this.commands.push(`! U1 ${e} ${n} TEXT ${this.escapeText(t)}`),this}legacyText(t,s,e,n=3){return this.commands.push(`TEXT ${s} ${e} ${n} "${this.escapeText(t)}"`),this}barcode(t,s){const{x:e=0,y:n=0,type:r="128",height:i=50,wide:h=2,narrow:a=1,readable:o=!0}=s,u=o?"B":"N";switch(r){case"128":default:this.commands.push(`BARCODE 128 ${e} ${n} ${i} ${u} 0 ${a} ${h} "${t}"`);break;case"39":this.commands.push(`BARCODE 39 ${e} ${n} ${i} ${u} ${h} ${a} "${t}"`);break;case"EAN13":this.commands.push(`BARCODE EAN13 ${e} ${n} ${i} ${u} "${t}"`);break;case"EAN8":this.commands.push(`BARCODE EAN8 ${e} ${n} ${i} ${u} "${t}"`);break;case"UPCA":this.commands.push(`BARCODE UPCA ${e} ${n} ${i} ${u} "${t}"`);break;case"UPCE":this.commands.push(`BARCODE UPCE ${e} ${n} ${i} ${u} "${t}"`);break;case"PDF417":this.commands.push(`BARCODE PDF417 ${e} ${n} 6 200 "${t}"`);break;case"DATAMATRIX":this.commands.push(`BARCODE DATAMATRIX ${e} ${n} 200 "${t}"`);break;case"QR":this.qrcode(t,{x:e,y:n})}return this}qrcode(t,s){const{x:e=0,y:n=0,model:r=2,errorCorrection:i="M",cellSize:h=4}=s||{};return this.commands.push(`BARCODE QR ${e} ${n} ${r} ${h} A ${i} "${t}"`),this}twoDBarcode(t,s,e=0,n=0,r=200){return"PDF417"===s?this.commands.push(`BARCODE PDF417 ${e} ${n} 6 ${r} "${t}"`):this.commands.push(`BARCODE DATAMATRIX ${e} ${n} ${r} "${t}"`),this}line(t){const{x1:s,y1:e,x2:n,y2:r,width:i=1}=t;return this.commands.push(`LINE ${s} ${e} ${n} ${r} ${i}`),this}box(t){const{x:s,y:e,width:n,height:r,thickness:i=1}=t;return this.commands.push(`BOX ${s} ${e} ${n} ${r} ${i}`),this}inverse(t,s,e,n){return this.commands.push(`INVERSE ${e} ${n} ${t} ${s}`),this}setDensity(t){const s=Math.min(50,Math.max(-50,t));return this.commands.push("! U1 SETDENSITY "+s),this}setSpeed(t){const s=Math.min(6,Math.max(2,t));return this.commands.push("! U1 SETSPEED "+s),this}cut(){return this.commands.push("CUT"),this}partialCut(){return this.commands.push("PCUT"),this}feedCut(){return this.commands.push("FEED CUT"),this}beep(t=1,s=5){return this.commands.push(`BEEP ${t} ${s}`),this}logo(t,s,e){return this.commands.push(`LOGO ${t} ${s} "${e}"`),this}downloadLogo(t,s,e){var n,r;const i=null!=(n=null==e?void 0:e.width)?n:100,h=Math.ceil(i/8),o=null!=(r=null==e?void 0:e.height)?r:Math.max(1,Math.floor(s.length/h)),u=h*o;s.length<u&&this.logger.warn(`CPCL logo bitmap size mismatch: expected ${u}, got ${s.length}`);const c=a.Z(s,u);return this.commands.push("! DF "+t),this.commands.push(`CG ${u} ${h} ${o} ${c}`),this.commands.push("! DF"),this.logger.debug(`CPCL logo downloaded: ${t} (${i}x${o})`),this}printLogo(t,s=0,e=0){return this.commands.push(`LOGO ${s} ${e} "${t}"`),this}getCommands(){return this.commands.join("\r\n")+"\r\n"}getBuffer(){const t=this.getCommands();return this.logger.debug("CPCL commands:\n"+t),a.x.encode(t,"ASCII")}getCommandList(){return[...this.commands]}reset(){return this.commands=[],this}getPageWidth(){return this.pageWidth}escapeText(t){return t.replace(/"/g,'""')}},exports.GPrinterDriver=o,exports.SprtDriver=c,exports.StarPrinter=class{constructor(t){var s,e,n,r;this.logger=a.L.scope("StarPrinter"),this._boldEnabled=!1,this._alignment="left",this.useEncodingService=null==(s=null==t?void 0:t.useEncodingService)||s,this.internationalCharset=null==(e=null==t?void 0:t.internationalCharset)||e,this.encodingService=new a.E({showWarnings:null==(n=null==t?void 0:t.showEncodingWarnings)||n,fallbackChar:null!=(r=null==t?void 0:t.fallbackChar)?r:"?"}),this.logger.info("StarPrinter driver initialized")}init(){const t=[];return t.push(new Uint8Array([27,64])),this.internationalCharset&&t.push(new Uint8Array([27,82,0])),this._boldEnabled=!1,this._alignment="left",t}text(t,s="GBK"){if(!t||"string"!=typeof t)return[];const e=[];if("left"!==this._alignment){const t=this.align(this._alignment);t.length>0&&t[0]&&e.push(t[0])}if(this._boldEnabled&&e.push(new Uint8Array([27,69,1])),this.useEncodingService&&this.encodingService.isSupported(s)){const n=this.encodingService.encode(t,s);e.push(n)}else{const s=(new TextEncoder).encode(t);e.push(s)}return e.push(new Uint8Array([10])),this._boldEnabled&&e.push(new Uint8Array([27,69,0])),"left"!==this._alignment&&e.push(new Uint8Array([27,97,0])),e}feed(t=1){return[new Uint8Array([27,100,Math.max(1,Math.min(255,Math.floor(t)))])]}cut(){const t=[];return t.push(new Uint8Array([27,100,3])),t.push(new Uint8Array([29,86,0])),t}qr(t,s){var e,n,r,i,h;if(!t||"string"!=typeof t)return[];const a=null!=(e=null==s?void 0:s.model)?e:2;let o=4;s&&("cellSize"in s?o=null!=(n=s.cellSize)?n:4:"size"in s&&(o=null!=(r=s.size)?r:4));const u=null!=(i=null==s?void 0:s.errorCorrection)?i:"M",c=[];c.push(new Uint8Array([27,29,87,1,1===a?48:49])),c.push(new Uint8Array([27,29,87,2,Math.min(8,Math.max(1,o))]));const m=null!=(h={L:0,M:1,Q:2,H:3}[u])?h:1;c.push(new Uint8Array([27,29,87,3,m]));const d=this.useEncodingService&&this.encodingService.isSupported("UTF-8")?this.encodingService.encode(t,"UTF-8"):(new TextEncoder).encode(t),l=d.length,p=l%256,$=Math.floor(l/256);return c.push(new Uint8Array([27,29,87,0,p,$])),c.push(d),c.push(new Uint8Array([27,29,87,4])),c}barcode(t,s){var e,n,r,i,h;if(!t||"string"!=typeof t)return[];const a=null!=(e=null==s?void 0:s.type)?e:"CODE128",o=Math.max(1,Math.min(255,null!=(n=null==s?void 0:s.height)?n:40)),u=Math.max(1,Math.min(5,null!=(r=null==s?void 0:s.width)?r:2)),c=[],m=null!=(h={none:0,above:1,below:2,both:3}[null!=(i=null==s?void 0:s.hri)?i:"below"])?h:2;switch(c.push(new Uint8Array([29,104,o])),c.push(new Uint8Array([29,119,u])),c.push(new Uint8Array([29,72,m])),a){case"CODE39":{const s=`*${t.toUpperCase()}*`;c.push(new Uint8Array([29,107,4])),c.push((new TextEncoder).encode(s)),c.push(new Uint8Array([0]));break}case"EAN13":{const s=t.replace(/\D/g,"");12>s.length&&this.logger.warn("EAN13 requires 12 digits, got "+s.length),c.push(new Uint8Array([29,107,2]));const e=s.padStart(12,"0").substring(0,12);c.push((new TextEncoder).encode(e)),c.push(new Uint8Array([0]));break}default:c.push(new Uint8Array([29,107,73])),c.push((new TextEncoder).encode(t)),c.push(new Uint8Array([0]))}return c}image(t,s,e,n){if(!(t&&t instanceof Uint8Array&&s>0&&e>0))return this.logger.warn("Invalid image parameters"),[];const r=s*e*4;if(t.length!==r)return this.logger.warn(`Invalid image data length: expected ${r}, got ${t.length}`),[];const i=[],h=a.y.toBitmap(t,s,e),o=Math.ceil(s/8),u=o%256,c=Math.floor(o/256);i.push(new Uint8Array([27,42,u,c]));for(let a=0;e>a;a++){const t=h.slice(a*o,(a+1)*o);i.push(t)}return i}beep(){return[new Uint8Array([27,66,5])]}bold(t){return this._boldEnabled=t,[new Uint8Array([27,69,t?1:0])]}align(t){var s;this._alignment=t;const e=null!=(s={left:0,center:1,right:2}[t])?s:0;return[new Uint8Array([27,97,e])]}},exports.TsplDriver=class{constructor(){this.commands=[],this.logger=a.L.scope("TsplDriver"),this.dpi=203}setDPI(t){return this.dpi=t,this}mmToDots(t){return Math.round(t*this.dpi/25.4)}dotsToMm(t){return 25.4*t/this.dpi}size(t,s){return this.commands.push(`SIZE ${t} mm, ${s} mm`),this}gap(t,s=0){return this.commands.push(`GAP ${t} mm, ${s} mm`),this}speed(t){return this.commands.push("SPEED "+Math.min(10,Math.max(1,t))),this}density(t){return this.commands.push("DENSITY "+Math.min(15,Math.max(0,t))),this}direction(t){return this.commands.push("DIRECTION "+t),this}clear(){return this.commands.push("CLS"),this}text(t,s){const{x:e,y:n,font:r=2,rotation:i=0,xMultiplier:h=1,yMultiplier:a=1}=s;return this.commands.push(`TEXT ${e},${n},"${r}",${i},${h},${a},"${this.escapeString(t)}"`),this}barcode(t,s){const{x:e,y:n,type:r,height:i=100,narrow:h=2,wide:a=4,showText:o=!0,rotation:u=0}=s,c=o?1:0;return"QRCODE"===r?this.qrcode(t,{x:e,y:n,rotation:u}):(this.commands.push(`BARCODE ${e},${n},"${r}",${i},${c},${u},${h},${a},"${t}"`),this)}qrcode(t,s){const{x:e,y:n,eccLevel:r="M",cellWidth:i=6,mode:h="A",rotation:a=0}=s;return this.commands.push(`QRCODE ${e},${n},${r},${i},${h},${a},"${this.escapeString(t)}"`),this}box(t){const{x:s,y:e,width:n,height:r,thickness:i=2}=t;return this.commands.push(`BOX ${s},${e},${s+n},${e+r},${i}`),this}line(t){const{x1:s,y1:e,x2:n,y2:i,thickness:h=2}=t;if(s===n||e===i){const t=Math.abs(n-s)||h,r=Math.abs(i-e)||h;this.commands.push(`BAR ${Math.min(s,n)},${Math.min(e,i)},${t},${r}`)}else this.commands.push(`DIAGONAL ${s},${e},${h},${Math.sqrt(r(n-s,2)+r(i-e,2))},${180*Math.atan2(i-e,n-s)/Math.PI}`);return this}bar(t,s,e,n){return this.commands.push(`BAR ${t},${s},${e},${n}`),this}reverse(t,s,e,n){return this.commands.push(`REVERSE ${t},${s},${e},${n}`),this}print(t=1,s=1){return this.commands.push(`PRINT ${t},${s}`),this}feed(t=1){this.commands.push("FORMFEED");for(let s=1;t>s;s++)this.commands.push("FORMFEED");return this}cut(){return this.commands.push("CUT"),this}beep(){return this.commands.push("BEEP"),this}home(){return this.commands.push("HOME"),this}escapeString(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}getCommands(){return this.commands.join("\r\n")+"\r\n"}getBuffer(){const t=this.getCommands();return this.logger.debug("TSPL commands:\n"+t),a.x.encode(t,"ASCII")}reset(){return this.commands=[],this}},exports.XprinterDriver=u,exports.ZplDriver=class{constructor(){this.commands=[],this.logger=a.L.scope("ZplDriver"),this.startFormat(),m(this,this.barcode.bind(this),{checkDigit:"Y"})}startFormat(){return this.commands.push("^XA"),this}endFormat(){return this.commands.push("^XZ"),this}labelHome(t,s){return this.commands.push(`^FO${t},${s}`),this}fieldData(t){return this.commands.push("^FD"+this.escapeField(t)),this}fieldOrigin(t,s){return this.commands.push(`^FO${t},${s}`),this}printWidth(t){return this.commands.push("^PW"+t),this}labelLength(t){return this.commands.push("^LL"+t),this}labelGap(t){return this.commands.push("^LS"+t),this}quantity(t){return this.commands.push(`^PQ${t},0,1,Y`),this}text(t,s){if(s){const{x:e=0,y:n=0,font:r="0",rotation:i="N",xMultiplier:h=1,yMultiplier:a=1}=s;this.commands.push(`^FO${e},${n}^A${r}${i},${a},${h}^FD${this.escapeField(t)}^FS`)}else this.commands.push(`^FD${this.escapeField(t)}^FS`);return this}textAt(t,s,e,n="0",r="N"){return this.commands.push(`^FO${s},${e}^A${n}${r}^FD${this.escapeField(t)}^FS`),this}font(t,s,e,n=30,r=20){return this.commands.push(`^FO${s},${e}^A${n},${r}^FD${this.escapeField(t)}^FS`),this}scalableText(t,s,e,n="0",r=30,i=20){return this.commands.push(`^FO${s},${e}^A${n}N,${r},${i}^FD${this.escapeField(t)}^FS`),this}barcode(t,s){const{x:e=0,y:n=0,type:r="128",height:i=50,showText:h="Y",checkDigit:a="N",interpretLine:o="Y",interpretLineAbove:u="N"}=s;return this.commands.push(`^FO${e},${n}^B${r}${h},${i},${o},${u},${a}^FD${this.escapeField(t)}^FS`),this}ean13(t,s=0,e=0,n=50){return this.barcode(t,{x:s,y:e,type:"EAN13",height:n})}qrcode(t,s){const{x:e=0,y:n=0,model:r=2,magnification:i=4,errorCorrection:h="M"}=s||{},a=1===r?"1":"2";return this.commands.push(`^FO${e},${n}^BQN,${a},${i}^FD${h},${this.escapeField(t)}^FS`),this}box(t){const{x:s=0,y:e=0,width:n,height:r,borderThickness:i=2,cornerRounding:h=0}=t;return this.commands.push(`^FO${s},${e}^GB${n},${r},${i},${h}^FS`),this}line(t,s,e,n,r=2){const i=Math.abs(e-t)||r,h=Math.abs(n-s)||r,a=Math.min(t,e),o=Math.min(s,n);return this.commands.push(`^FO${a},${o}^GB${i},${h},${r}^FS`),this}circle(t,s,e,n=2){return this.commands.push(`^FO${t},${s}^GC${e},${n}^FS`),this}diagonal(t,s,e,n,r=2){return this.commands.push(`^FO${t},${s}^GD${e},${n},${r}^FS`),this}ellipse(t,s,e,n,r=2){return this.commands.push(`^FO${t},${s}^GE${e},${n},${r}^FS`),this}image(t,s,e,n,r){const i=Math.ceil(e/8),h=i*n;r.length<h&&this.logger.warn(`ZPL image bitmap size mismatch: expected ${h}, got ${r.length}`);const o=a.Z(r,h);return this.commands.push(`^FO${t},${s}`),this.commands.push(`^GFA,${h},${h},${i},${o}`),this.commands.push("^FS"),this.logger.debug(`ZPL image encoded: ${e}x${n} at (${t},${s})`),this}setDarkness(t=15){return this.commands.push("~SD"+Math.min(30,Math.max(0,Math.floor(t)))),this}setSpeed(t){const s=Math.min(14,Math.max(1,Math.floor(t)));return this.commands.push("^PR"+s),this}printConfigLabel(){return this.commands.push("~WC"),this}calibrate(){return this.commands.push("~JC"),this}reset(){return this.commands.push("^JUS"),this}getCommands(){var t,s;return(null==(t=this.commands[0])?void 0:t.startsWith("^XA"))||this.startFormat(),(null==(s=this.commands[this.commands.length-1])?void 0:s.startsWith("^XZ"))||this.endFormat(),this.commands.join("\n")}getBuffer(){const t=this.getCommands();return this.logger.debug("ZPL commands:\n"+t),a.x.encode(t,"UTF-8")}getCommandList(){return[...this.commands]}resetCommands(){return this.commands=[],this.startFormat(),this}print(t=1){return this.quantity(t),this.endFormat(),this}escapeField(t){return t.replace(/\\/g,"\\\\").replace(/\^/g,"\\^").replace(/~/g,"\\~")}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty,s=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,i=Math.pow,r=(s,e,n)=>e in s?t(s,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[e]=n;import{E as h}from"../chunks/EscPosDriver-DGK4usVf.js";import{L as a,x as o,Z as u,E as c,y as m}from"../chunks/shared-DuaS72fL.js";class d extends h{printAndFeed(t){return[new Uint8Array([27,100,t])]}}class l extends h{init(){return super.init()}getStatus(){return[new Uint8Array([27,105])]}getDetailedStatus(){const t=[];for(let s=1;4>=s;s++)t.push(new Uint8Array([16,4,s]));return t}feedAndCut(t){return[new Uint8Array([27,100,t]),new Uint8Array([29,86,0])]}}class $ extends h{sleep(){return[new Uint8Array([27,61,1])]}wakeUp(){return[new Uint8Array([0])]}wakeUpDeep(){const t=[];for(let s=0;5>s;s++)t.push(new Uint8Array([0]));return t.push(new Uint8Array([27,64])),t}setAutoSleep(t){return[new Uint8Array([27,61,t?1:0])]}}class p{constructor(){this.commands=[],this.logger=a.scope("TsplDriver"),this.dpi=203}setDPI(t){return this.dpi=t,this}mmToDots(t){return Math.round(t*this.dpi/25.4)}dotsToMm(t){return 25.4*t/this.dpi}size(t,s){return this.commands.push(`SIZE ${t} mm, ${s} mm`),this}gap(t,s=0){return this.commands.push(`GAP ${t} mm, ${s} mm`),this}speed(t){return this.commands.push("SPEED "+Math.min(10,Math.max(1,t))),this}density(t){return this.commands.push("DENSITY "+Math.min(15,Math.max(0,t))),this}direction(t){return this.commands.push("DIRECTION "+t),this}clear(){return this.commands.push("CLS"),this}text(t,s){const{x:e,y:n,font:i=2,rotation:r=0,xMultiplier:h=1,yMultiplier:a=1}=s;return this.commands.push(`TEXT ${e},${n},"${i}",${r},${h},${a},"${this.escapeString(t)}"`),this}barcode(t,s){const{x:e,y:n,type:i,height:r=100,narrow:h=2,wide:a=4,showText:o=!0,rotation:u=0}=s,c=o?1:0;return"QRCODE"===i?this.qrcode(t,{x:e,y:n,rotation:u}):(this.commands.push(`BARCODE ${e},${n},"${i}",${r},${c},${u},${h},${a},"${t}"`),this)}qrcode(t,s){const{x:e,y:n,eccLevel:i="M",cellWidth:r=6,mode:h="A",rotation:a=0}=s;return this.commands.push(`QRCODE ${e},${n},${i},${r},${h},${a},"${this.escapeString(t)}"`),this}box(t){const{x:s,y:e,width:n,height:i,thickness:r=2}=t;return this.commands.push(`BOX ${s},${e},${s+n},${e+i},${r}`),this}line(t){const{x1:s,y1:e,x2:n,y2:r,thickness:h=2}=t;if(s===n||e===r){const t=Math.abs(n-s)||h,i=Math.abs(r-e)||h;this.commands.push(`BAR ${Math.min(s,n)},${Math.min(e,r)},${t},${i}`)}else this.commands.push(`DIAGONAL ${s},${e},${h},${Math.sqrt(i(n-s,2)+i(r-e,2))},${180*Math.atan2(r-e,n-s)/Math.PI}`);return this}bar(t,s,e,n){return this.commands.push(`BAR ${t},${s},${e},${n}`),this}reverse(t,s,e,n){return this.commands.push(`REVERSE ${t},${s},${e},${n}`),this}print(t=1,s=1){return this.commands.push(`PRINT ${t},${s}`),this}feed(t=1){this.commands.push("FORMFEED");for(let s=1;t>s;s++)this.commands.push("FORMFEED");return this}cut(){return this.commands.push("CUT"),this}beep(){return this.commands.push("BEEP"),this}home(){return this.commands.push("HOME"),this}escapeString(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}getCommands(){return this.commands.join("\r\n")+"\r\n"}getBuffer(){const t=this.getCommands();return this.logger.debug("TSPL commands:\n"+t),o.encode(t,"ASCII")}reset(){return this.commands=[],this}}function g(t,i,h={}){const a=t;return a.code128=function(s,e=0,n=0,r=50){return i.call(t,s,{x:e,y:n,type:"128",height:r})},a.code39=function(a,o=0,u=0,c=50){return i.call(t,a,((t,i)=>{for(var h in i||(i={}))e.call(i,h)&&r(t,h,i[h]);if(s)for(var h of s(i))n.call(i,h)&&r(t,h,i[h]);return t})({x:o,y:u,type:"39",height:c},h))},a}class A{constructor(){this.commands=[],this.logger=a.scope("ZplDriver"),this.startFormat(),g(this,this.barcode.bind(this),{checkDigit:"Y"})}startFormat(){return this.commands.push("^XA"),this}endFormat(){return this.commands.push("^XZ"),this}labelHome(t,s){return this.commands.push(`^FO${t},${s}`),this}fieldData(t){return this.commands.push("^FD"+this.escapeField(t)),this}fieldOrigin(t,s){return this.commands.push(`^FO${t},${s}`),this}printWidth(t){return this.commands.push("^PW"+t),this}labelLength(t){return this.commands.push("^LL"+t),this}labelGap(t){return this.commands.push("^LS"+t),this}quantity(t){return this.commands.push(`^PQ${t},0,1,Y`),this}text(t,s){if(s){const{x:e=0,y:n=0,font:i="0",rotation:r="N",xMultiplier:h=1,yMultiplier:a=1}=s;this.commands.push(`^FO${e},${n}^A${i}${r},${a},${h}^FD${this.escapeField(t)}^FS`)}else this.commands.push(`^FD${this.escapeField(t)}^FS`);return this}textAt(t,s,e,n="0",i="N"){return this.commands.push(`^FO${s},${e}^A${n}${i}^FD${this.escapeField(t)}^FS`),this}font(t,s,e,n=30,i=20){return this.commands.push(`^FO${s},${e}^A${n},${i}^FD${this.escapeField(t)}^FS`),this}scalableText(t,s,e,n="0",i=30,r=20){return this.commands.push(`^FO${s},${e}^A${n}N,${i},${r}^FD${this.escapeField(t)}^FS`),this}barcode(t,s){const{x:e=0,y:n=0,type:i="128",height:r=50,showText:h="Y",checkDigit:a="N",interpretLine:o="Y",interpretLineAbove:u="N"}=s;return this.commands.push(`^FO${e},${n}^B${i}${h},${r},${o},${u},${a}^FD${this.escapeField(t)}^FS`),this}ean13(t,s=0,e=0,n=50){return this.barcode(t,{x:s,y:e,type:"EAN13",height:n})}qrcode(t,s){const{x:e=0,y:n=0,model:i=2,magnification:r=4,errorCorrection:h="M"}=s||{},a=1===i?"1":"2";return this.commands.push(`^FO${e},${n}^BQN,${a},${r}^FD${h},${this.escapeField(t)}^FS`),this}box(t){const{x:s=0,y:e=0,width:n,height:i,borderThickness:r=2,cornerRounding:h=0}=t;return this.commands.push(`^FO${s},${e}^GB${n},${i},${r},${h}^FS`),this}line(t,s,e,n,i=2){const r=Math.abs(e-t)||i,h=Math.abs(n-s)||i,a=Math.min(t,e),o=Math.min(s,n);return this.commands.push(`^FO${a},${o}^GB${r},${h},${i}^FS`),this}circle(t,s,e,n=2){return this.commands.push(`^FO${t},${s}^GC${e},${n}^FS`),this}diagonal(t,s,e,n,i=2){return this.commands.push(`^FO${t},${s}^GD${e},${n},${i}^FS`),this}ellipse(t,s,e,n,i=2){return this.commands.push(`^FO${t},${s}^GE${e},${n},${i}^FS`),this}image(t,s,e,n,i){const r=Math.ceil(e/8),h=r*n;i.length<h&&this.logger.warn(`ZPL image bitmap size mismatch: expected ${h}, got ${i.length}`);const a=u(i,h);return this.commands.push(`^FO${t},${s}`),this.commands.push(`^GFA,${h},${h},${r},${a}`),this.commands.push("^FS"),this.logger.debug(`ZPL image encoded: ${e}x${n} at (${t},${s})`),this}setDarkness(t=15){return this.commands.push("~SD"+Math.min(30,Math.max(0,Math.floor(t)))),this}setSpeed(t){const s=Math.min(14,Math.max(1,Math.floor(t)));return this.commands.push("^PR"+s),this}printConfigLabel(){return this.commands.push("~WC"),this}calibrate(){return this.commands.push("~JC"),this}reset(){return this.commands.push("^JUS"),this}getCommands(){var t,s;return(null==(t=this.commands[0])?void 0:t.startsWith("^XA"))||this.startFormat(),(null==(s=this.commands[this.commands.length-1])?void 0:s.startsWith("^XZ"))||this.endFormat(),this.commands.join("\n")}getBuffer(){const t=this.getCommands();return this.logger.debug("ZPL commands:\n"+t),o.encode(t,"UTF-8")}getCommandList(){return[...this.commands]}resetCommands(){return this.commands=[],this.startFormat(),this}print(t=1){return this.quantity(t),this.endFormat(),this}escapeField(t){return t.replace(/\\/g,"\\\\").replace(/\^/g,"\\^").replace(/~/g,"\\~")}}class E{constructor(t=576,s=0){this.commands=[],this.logger=a.scope("CpclDriver"),this.pageWidth=576,this.pageHeight=0,this.pageWidth=t,this.pageHeight=s,g(this,this.barcode.bind(this),{wide:2,narrow:1})}setPageSize(t,s=0){return this.pageWidth=t,this.pageHeight=s,this}usePageSize(t){const[s,e]={"4X6":[576,864],"4X4":[576,576],"4X2":[576,288],"2.25X1.25":[324,180],A4:[992,1406],A5:[701,992],LETTER:[1050,1500],CUSTOM:[576,0]}[t]||[576,0];return this.pageWidth=s,this.pageHeight=e,this}pageStart(){return this.commands.push("! U1 SETLP 5 0 30"),this.commands.push("! U1 PAGE WIDTH "+this.pageWidth),this.pageHeight>0&&this.commands.push("! U1 PAGE HEIGHT "+this.pageHeight),this.commands.push("START"),this}pageEnd(){return this.commands.push("END"),this}formFeed(){return this.commands.push("FORM"),this}setLinePrint(t=5,s=0,e=30){return this.commands.push(`! U1 SETLP ${t} ${s} ${e}`),this}setFont(t=3,s=1,e=1,n=0){const i={0:"N",90:"R",180:"B",270:"I"}[n]||"N";return this.commands.push(`! U1 SETLP ${t} ${s} ${e} ${i}`),this}text(t){return this.commands.push("! U1 TEXT "+this.escapeText(t)),this}textAt(t,s){const{x:e=0,y:n=0,font:i=3,xMulti:r=1,yMulti:h=1,rotation:a=0}=s,o={0:"N",90:"R",180:"B",270:"I"}[a]||"N";return this.commands.push(`! U1 SETLP ${i} ${r} ${h} ${o}`),this.commands.push(`! U1 ${e} ${n} TEXT ${this.escapeText(t)}`),this}legacyText(t,s,e,n=3){return this.commands.push(`TEXT ${s} ${e} ${n} "${this.escapeText(t)}"`),this}barcode(t,s){const{x:e=0,y:n=0,type:i="128",height:r=50,wide:h=2,narrow:a=1,readable:o=!0}=s,u=o?"B":"N";switch(i){case"128":default:this.commands.push(`BARCODE 128 ${e} ${n} ${r} ${u} 0 ${a} ${h} "${t}"`);break;case"39":this.commands.push(`BARCODE 39 ${e} ${n} ${r} ${u} ${h} ${a} "${t}"`);break;case"EAN13":this.commands.push(`BARCODE EAN13 ${e} ${n} ${r} ${u} "${t}"`);break;case"EAN8":this.commands.push(`BARCODE EAN8 ${e} ${n} ${r} ${u} "${t}"`);break;case"UPCA":this.commands.push(`BARCODE UPCA ${e} ${n} ${r} ${u} "${t}"`);break;case"UPCE":this.commands.push(`BARCODE UPCE ${e} ${n} ${r} ${u} "${t}"`);break;case"PDF417":this.commands.push(`BARCODE PDF417 ${e} ${n} 6 200 "${t}"`);break;case"DATAMATRIX":this.commands.push(`BARCODE DATAMATRIX ${e} ${n} 200 "${t}"`);break;case"QR":this.qrcode(t,{x:e,y:n})}return this}qrcode(t,s){const{x:e=0,y:n=0,model:i=2,errorCorrection:r="M",cellSize:h=4}=s||{};return this.commands.push(`BARCODE QR ${e} ${n} ${i} ${h} A ${r} "${t}"`),this}twoDBarcode(t,s,e=0,n=0,i=200){return"PDF417"===s?this.commands.push(`BARCODE PDF417 ${e} ${n} 6 ${i} "${t}"`):this.commands.push(`BARCODE DATAMATRIX ${e} ${n} ${i} "${t}"`),this}line(t){const{x1:s,y1:e,x2:n,y2:i,width:r=1}=t;return this.commands.push(`LINE ${s} ${e} ${n} ${i} ${r}`),this}box(t){const{x:s,y:e,width:n,height:i,thickness:r=1}=t;return this.commands.push(`BOX ${s} ${e} ${n} ${i} ${r}`),this}inverse(t,s,e,n){return this.commands.push(`INVERSE ${e} ${n} ${t} ${s}`),this}setDensity(t){const s=Math.min(50,Math.max(-50,t));return this.commands.push("! U1 SETDENSITY "+s),this}setSpeed(t){const s=Math.min(6,Math.max(2,t));return this.commands.push("! U1 SETSPEED "+s),this}cut(){return this.commands.push("CUT"),this}partialCut(){return this.commands.push("PCUT"),this}feedCut(){return this.commands.push("FEED CUT"),this}beep(t=1,s=5){return this.commands.push(`BEEP ${t} ${s}`),this}logo(t,s,e){return this.commands.push(`LOGO ${t} ${s} "${e}"`),this}downloadLogo(t,s,e){var n,i;const r=null!=(n=null==e?void 0:e.width)?n:100,h=Math.ceil(r/8),a=null!=(i=null==e?void 0:e.height)?i:Math.max(1,Math.floor(s.length/h)),o=h*a;s.length<o&&this.logger.warn(`CPCL logo bitmap size mismatch: expected ${o}, got ${s.length}`);const c=u(s,o);return this.commands.push("! DF "+t),this.commands.push(`CG ${o} ${h} ${a} ${c}`),this.commands.push("! DF"),this.logger.debug(`CPCL logo downloaded: ${t} (${r}x${a})`),this}printLogo(t,s=0,e=0){return this.commands.push(`LOGO ${s} ${e} "${t}"`),this}getCommands(){return this.commands.join("\r\n")+"\r\n"}getBuffer(){const t=this.getCommands();return this.logger.debug("CPCL commands:\n"+t),o.encode(t,"ASCII")}getCommandList(){return[...this.commands]}reset(){return this.commands=[],this}getPageWidth(){return this.pageWidth}escapeText(t){return t.replace(/"/g,'""')}}class y{constructor(t){var s,e,n,i;this.logger=a.scope("StarPrinter"),this._boldEnabled=!1,this._alignment="left",this.useEncodingService=null==(s=null==t?void 0:t.useEncodingService)||s,this.internationalCharset=null==(e=null==t?void 0:t.internationalCharset)||e,this.encodingService=new c({showWarnings:null==(n=null==t?void 0:t.showEncodingWarnings)||n,fallbackChar:null!=(i=null==t?void 0:t.fallbackChar)?i:"?"}),this.logger.info("StarPrinter driver initialized")}init(){const t=[];return t.push(new Uint8Array([27,64])),this.internationalCharset&&t.push(new Uint8Array([27,82,0])),this._boldEnabled=!1,this._alignment="left",t}text(t,s="GBK"){if(!t||"string"!=typeof t)return[];const e=[];if("left"!==this._alignment){const t=this.align(this._alignment);t.length>0&&t[0]&&e.push(t[0])}if(this._boldEnabled&&e.push(new Uint8Array([27,69,1])),this.useEncodingService&&this.encodingService.isSupported(s)){const n=this.encodingService.encode(t,s);e.push(n)}else{const s=(new TextEncoder).encode(t);e.push(s)}return e.push(new Uint8Array([10])),this._boldEnabled&&e.push(new Uint8Array([27,69,0])),"left"!==this._alignment&&e.push(new Uint8Array([27,97,0])),e}feed(t=1){return[new Uint8Array([27,100,Math.max(1,Math.min(255,Math.floor(t)))])]}cut(){const t=[];return t.push(new Uint8Array([27,100,3])),t.push(new Uint8Array([29,86,0])),t}qr(t,s){var e,n,i,r,h;if(!t||"string"!=typeof t)return[];const a=null!=(e=null==s?void 0:s.model)?e:2;let o=4;s&&("cellSize"in s?o=null!=(n=s.cellSize)?n:4:"size"in s&&(o=null!=(i=s.size)?i:4));const u=null!=(r=null==s?void 0:s.errorCorrection)?r:"M",c=[];c.push(new Uint8Array([27,29,87,1,1===a?48:49])),c.push(new Uint8Array([27,29,87,2,Math.min(8,Math.max(1,o))]));const m=null!=(h={L:0,M:1,Q:2,H:3}[u])?h:1;c.push(new Uint8Array([27,29,87,3,m]));const d=this.useEncodingService&&this.encodingService.isSupported("UTF-8")?this.encodingService.encode(t,"UTF-8"):(new TextEncoder).encode(t),l=d.length,$=l%256,p=Math.floor(l/256);return c.push(new Uint8Array([27,29,87,0,$,p])),c.push(d),c.push(new Uint8Array([27,29,87,4])),c}barcode(t,s){var e,n,i,r,h;if(!t||"string"!=typeof t)return[];const a=null!=(e=null==s?void 0:s.type)?e:"CODE128",o=Math.max(1,Math.min(255,null!=(n=null==s?void 0:s.height)?n:40)),u=Math.max(1,Math.min(5,null!=(i=null==s?void 0:s.width)?i:2)),c=[],m=null!=(h={none:0,above:1,below:2,both:3}[null!=(r=null==s?void 0:s.hri)?r:"below"])?h:2;switch(c.push(new Uint8Array([29,104,o])),c.push(new Uint8Array([29,119,u])),c.push(new Uint8Array([29,72,m])),a){case"CODE39":{const s=`*${t.toUpperCase()}*`;c.push(new Uint8Array([29,107,4])),c.push((new TextEncoder).encode(s)),c.push(new Uint8Array([0]));break}case"EAN13":{const s=t.replace(/\D/g,"");12>s.length&&this.logger.warn("EAN13 requires 12 digits, got "+s.length),c.push(new Uint8Array([29,107,2]));const e=s.padStart(12,"0").substring(0,12);c.push((new TextEncoder).encode(e)),c.push(new Uint8Array([0]));break}default:c.push(new Uint8Array([29,107,73])),c.push((new TextEncoder).encode(t)),c.push(new Uint8Array([0]))}return c}image(t,s,e,n){if(!(t&&t instanceof Uint8Array&&s>0&&e>0))return this.logger.warn("Invalid image parameters"),[];const i=s*e*4;if(t.length!==i)return this.logger.warn(`Invalid image data length: expected ${i}, got ${t.length}`),[];const r=[],h=m.toBitmap(t,s,e),a=Math.ceil(s/8),o=a%256,u=Math.floor(a/256);r.push(new Uint8Array([27,42,o,u]));for(let c=0;e>c;c++){const t=h.slice(c*a,(c+1)*a);r.push(t)}return r}beep(){return[new Uint8Array([27,66,5])]}bold(t){return this._boldEnabled=t,[new Uint8Array([27,69,t?1:0])]}align(t){var s;this._alignment=t;const e=null!=(s={left:0,center:1,right:2}[t])?s:0;return[new Uint8Array([27,97,e])]}}export{E as CpclDriver,h as EscPos,d as GPrinterDriver,$ as SprtDriver,y as StarPrinter,p as TsplDriver,l as XprinterDriver,A as ZplDriver};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/shared-C3EQK7YH.js");exports.EncodingService=e.E,exports.ISO2022JP_ESC_ASCII=e.I,exports.ISO2022JP_ESC_JIS0208=e.a,exports.big5ToUnicode=e.b,exports.encodeHangulSyllable=e.e,exports.encodingService=e.c,exports.gbkToUnicode=e.g,exports.getBig5Bytes=e.d,exports.getGbkBytes=e.f,exports.getUnicodeFromGbk=e.h,exports.isAscii=e.i,exports.isChinesePunctuation=e.j,exports.isCjk=e.k,exports.isJapaneseHiragana=e.l,exports.isJapaneseKanji=e.m,exports.isJapaneseKatakana=e.n,exports.isJisX0201Katakana=e.o,exports.isKoreanHangul=e.p,exports.isKoreanHanja=e.q,exports.isKoreanJamo=e.r,exports.requiresJisX0208Escape=e.s,exports.unicodeToBig5=e.u,exports.unicodeToGbk=e.t,exports.unicodeToShiftJisHiragana=e.v,exports.unicodeToShiftJisKatakana=e.w;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as a,I as s,a as i,b as e,e as n,c as o,g as c,d as r,f as t,h as g,i as d,j as J,k as S,l as u,m as k,n as K,o as b,p,q as T,r as h,s as l,u as C,t as H,v as I,w as j}from"../chunks/shared-DuaS72fL.js";export{a as EncodingService,s as ISO2022JP_ESC_ASCII,i as ISO2022JP_ESC_JIS0208,e as big5ToUnicode,n as encodeHangulSyllable,o as encodingService,c as gbkToUnicode,r as getBig5Bytes,t as getGbkBytes,g as getUnicodeFromGbk,d as isAscii,J as isChinesePunctuation,S as isCjk,u as isJapaneseHiragana,k as isJapaneseKanji,K as isJapaneseKatakana,b as isJisX0201Katakana,p as isKoreanHangul,T as isKoreanHanja,h as isKoreanJamo,l as requiresJisX0208Escape,C as unicodeToBig5,H as unicodeToGbk,I as unicodeToShiftJisHiragana,j as unicodeToShiftJisKatakana};
|