@gitcode6/munbyn-pos-sdk 1.0.0
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/README.md +225 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2252 -0
- package/dist/index.d.ts +2252 -0
- package/dist/index.js +1 -0
- package/package.json +63 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ir=Object.defineProperty;var Ft=(i,e)=>()=>(i&&(e=i(i=0)),e);var jt=(i,e)=>{for(var t in e)ir(i,t,{get:e[t],enumerable:!0})};var Qt={};jt(Qt,{CutMode:()=>H});var H,F=Ft(()=>{"use strict";H=(r=>(r[r.Full=0]="Full",r[r.Partial=1]="Partial",r[r.PartialAfterFeed=66]="PartialAfterFeed",r))(H||{})});var Yt={};jt(Yt,{DrawerPin:()=>st});var st,at=Ft(()=>{"use strict";st=(t=>(t[t.Pin2=0]="Pin2",t[t.Pin5=1]="Pin5",t))(st||{})});var Ot=0,kt=9,It=10,rt=12,$t=13,E=16,qt=20,Tt=24,a=27,x=28,c=29,zt=4,Nt=5,Wt=32;var sr=new Map([[8364,128],[8218,130],[402,131],[8222,132],[8230,133],[8224,134],[8225,135],[710,136],[8240,137],[352,138],[8249,139],[338,140],[381,142],[8216,145],[8217,146],[8220,147],[8221,148],[8226,149],[8211,150],[8212,151],[732,152],[8482,153],[353,154],[8250,155],[339,156],[382,158],[376,159]]),h=class{chunks=[];totalLength=0;push(...e){for(let t of e){let r;typeof t=="number"?r=new Uint8Array([t&255]):t instanceof Uint8Array?r=t:r=new Uint8Array(t.map(n=>n&255)),this.chunks.push(r),this.totalLength+=r.length}return this}text(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);t[r]=sr.get(n)??n&255}return this.chunks.push(t),this.totalLength+=t.length,this}build(){let e=new Uint8Array(this.totalLength),t=0;for(let r of this.chunks)e.set(r,t),t+=r.length;return e}get length(){return this.totalLength}reset(){return this.chunks.length=0,this.totalLength=0,this}};function g(i){if(i<0||i>65535)throw new RangeError(`toUint16LE: Wert ${i} ist au\xDFerhalb von [0, 65535]`);return[i&255,i>>8&255]}function M(i){if(i<1||i>32767)throw new RangeError(`toComplement16: Wert ${i} muss im Bereich [1, 32767] liegen`);return 65536-i}function ar(i,e){return(i&255)+(e&255)*256}var nt=(r=>(r[r.Left=0]="Left",r[r.Center=1]="Center",r[r.Right=2]="Right",r))(nt||{});var ot=(t=>(t[t.A=0]="A",t[t.B=1]="B",t))(ot||{});var it=(r=>(r[r.Off=0]="Off",r[r.OneTick=1]="OneTick",r[r.TwoTicks=2]="TwoTicks",r))(it||{});var v=(l=>(l[l.UPC_A=65]="UPC_A",l[l.UPC_E=66]="UPC_E",l[l.EAN13=67]="EAN13",l[l.EAN8=68]="EAN8",l[l.CODE39=69]="CODE39",l[l.ITF=70]="ITF",l[l.CODABAR=71]="CODABAR",l[l.CODE93=72]="CODE93",l[l.CODE128=73]="CODE128",l))(v||{});var _t=(s=>(s[s.Narrow=2]="Narrow",s[s.Medium=3]="Medium",s[s.Wide=4]="Wide",s[s.Wider=5]="Wider",s[s.Widest=6]="Widest",s))(_t||{});var Gt=(n=>(n[n.None=0]="None",n[n.Above=1]="Above",n[n.Below=2]="Below",n[n.Both=3]="Both",n))(Gt||{});var Kt=(t=>(t[t.A=0]="A",t[t.B=1]="B",t))(Kt||{});F();var At=(u=>(u[u.PC437=0]="PC437",u[u.Katakana=1]="Katakana",u[u.PC850=2]="PC850",u[u.PC860=3]="PC860",u[u.PC863=4]="PC863",u[u.PC865=5]="PC865",u[u.WestEurope=6]="WestEurope",u[u.Greek=7]="Greek",u[u.Hebrew=8]="Hebrew",u[u.PC755=9]="PC755",u[u.Iran=10]="Iran",u[u.WPC1252=16]="WPC1252",u[u.PC866=17]="PC866",u[u.PC852=18]="PC852",u[u.PC858=19]="PC858",u[u.IranII=20]="IranII",u[u.Latvian=21]="Latvian",u))(At||{});var Zt=(p=>(p[p.USA=0]="USA",p[p.France=1]="France",p[p.Germany=2]="Germany",p[p.UK=3]="UK",p[p.Denmark=4]="Denmark",p[p.Sweden=5]="Sweden",p[p.Italy=6]="Italy",p[p.Spain=7]="Spain",p[p.Japan=8]="Japan",p[p.Norway=9]="Norway",p[p.Denmark2=10]="Denmark2",p[p.Spain2=11]="Spain2",p[p.Latin=12]="Latin",p[p.Korea=13]="Korea",p[p.SloveniaCroatia=14]="SloveniaCroatia",p[p.Chinese=15]="Chinese",p))(Zt||{});var Vt=(n=>(n[n.LeftToRight=0]="LeftToRight",n[n.BottomToTop=1]="BottomToTop",n[n.RightToLeft=2]="RightToLeft",n[n.TopToBottom=3]="TopToBottom",n))(Vt||{});var Jt=(n=>(n[n.SingleDensity8=0]="SingleDensity8",n[n.DoubleDensity8=1]="DoubleDensity8",n[n.SingleDensity24=32]="SingleDensity24",n[n.DoubleDensity24=33]="DoubleDensity24",n))(Jt||{});var Xt=(n=>(n[n.Normal=0]="Normal",n[n.DoubleWidth=1]="DoubleWidth",n[n.DoubleHeight=2]="DoubleHeight",n[n.Quadruple=3]="Quadruple",n))(Xt||{});at();var vt=(n=>(n[n.L=48]="L",n[n.M=49]="M",n[n.Q=50]="Q",n[n.H=51]="H",n))(vt||{});var o=class{encode(){return this.validate(),this.encodeBody()}validate(){}assertRange(e,t,r,n="n"){if(e<t||e>r||!Number.isInteger(e))throw new RangeError(`[${this.name}] Parameter "${n}" muss eine ganze Zahl in [${t}, ${r}] sein, erhalten: ${e}`)}};var j=class{name="CommandSequence";commands=[];constructor(...e){this.commands.push(...e)}add(...e){return this.commands.push(...e),this}get size(){return this.commands.length}[Symbol.iterator](){let e=0,t=this.commands;return{next(){if(e<t.length){let r=t[e++];return r===void 0?{value:void 0,done:!0}:{value:r,done:!1}}return{value:void 0,done:!0}}}}encode(){let e=new h;for(let t of this)e.push(t.encode());return e.build()}};var O=class{name;bytes;constructor(e,t="RawCommand"){this.bytes=e instanceof Uint8Array?e:new Uint8Array(e),this.name=t}encode(){return this.bytes.slice()}};var k=class i{static instance;registrations=new Map;constructor(){}static getInstance(){return i.instance||(i.instance=new i),i.instance}register(e){this.registrations.set(e.name,e)}getAll(){return this.registrations}get(e){return this.registrations.get(e)}has(e){return this.registrations.has(e)}static _reset(){i.instance=void 0}};var I=class extends o{name="HorizontalTab";encodeBody(){return new Uint8Array([9])}};var $=class extends o{name="LineFeed";encodeBody(){return new Uint8Array([10])}};var q=class extends o{name="FormFeed";encodeBody(){return new Uint8Array([12])}};var T=class extends o{name="CarriageReturn";encodeBody(){return new Uint8Array([13])}};var z=class extends o{name="CancelPageData";encodeBody(){return new Uint8Array([24])}};var N=class extends o{constructor(t){super();this.n=t}n;name="TransmitRealtimeStatus";validate(){this.assertRange(this.n,1,4)}encodeBody(){return new Uint8Array([16,4,this.n])}};var W=class extends o{constructor(t){super();this.n=t}n;name="RealtimeRequest";validate(){this.assertRange(this.n,1,2)}encodeBody(){return new Uint8Array([16,5,this.n])}};var _=class extends o{constructor(t,r){super();this.pin=t;this.t=r}pin;t;name="GeneratePulseRealtime";validate(){this.assertRange(this.pin,0,1,"pin"),this.assertRange(this.t,1,8,"t")}encodeBody(){return new Uint8Array([16,20,1,this.pin,this.t])}};var mt=class extends o{name="PrintPageMode";encodeBody(){return new Uint8Array([27,12])}};var dt=class extends o{constructor(t){super();this.n=t}n;name="SetRightCharacterSpacing";validate(){this.assertRange(this.n,0,255)}encodeBody(){return new Uint8Array([27,32,this.n])}};var G=class extends o{name="SelectPrintModes";n;constructor(e={}){super();let t=0;e.fontB&&(t|=1),e.emphasized&&(t|=8),e.doubleHeight&&(t|=16),e.doubleWidth&&(t|=32),e.underline&&(t|=128),this.n=t}encodeBody(){return new Uint8Array([27,33,this.n])}};var K=class extends o{constructor(t){super();this.n=t}n;name="SetAbsolutePosition";validate(){this.assertRange(this.n,0,65535)}encodeBody(){let[t,r]=g(this.n);return new Uint8Array([27,36,t,r])}};var ct=class extends o{constructor(t){super();this.enable=t}enable;name="SelectUserCharSet";encodeBody(){return new Uint8Array([27,37,this.enable?1:0])}};var pt=class extends o{constructor(t,r,n,s){super();this.y=t;this.c1=r;this.c2=n;this.data=s}y;c1;c2;data;name="DefineUserChars";validate(){if(this.y!==3)throw new RangeError(`[${this.name}] y muss 3 sein, erhalten: ${this.y}`);if(this.assertRange(this.c1,32,127,"c1"),this.assertRange(this.c2,32,127,"c2"),this.c1>this.c2)throw new RangeError(`[${this.name}] c1 (${this.c1}) darf nicht gr\xF6\xDFer als c2 (${this.c2}) sein`)}encodeBody(){let t=new h;return t.push(27,38,this.y,this.c1,this.c2),t.push(this.data),t.build()}};var ut=class extends o{constructor(t,r,n,s){super();this.mode=t;this.nL=r;this.nH=n;this.data=s}mode;nL;nH;data;name="SelectBitImageMode";validate(){if(![0,1,32,33].includes(this.mode))throw new RangeError(`[${this.name}] Ung\xFCltiger Modus: ${this.mode}`);this.assertRange(this.nL,0,255,"nL"),this.assertRange(this.nH,0,3,"nH")}encodeBody(){let t=new h;return t.push(27,42,this.mode,this.nL,this.nH),t.push(this.data),t.build()}};var Q=class extends o{constructor(t){super();this.mode=t}mode;name="SetUnderline";validate(){this.assertRange(this.mode,0,2)}encodeBody(){return new Uint8Array([27,45,this.mode])}};var Z=class extends o{name="SetDefaultLineSpacing";encodeBody(){return new Uint8Array([27,50])}};var V=class extends o{constructor(t){super();this.n=t}n;name="SetLineSpacing";validate(){this.assertRange(this.n,0,255)}encodeBody(){return new Uint8Array([27,51,this.n])}};var lt=class extends o{constructor(t){super();this.n=t}n;name="SetPeripheralDevice";validate(){this.assertRange(this.n,1,255)}encodeBody(){return new Uint8Array([27,61,this.n])}};var ht=class extends o{constructor(t){super();this.n=t}n;name="CancelUserChar";validate(){this.assertRange(this.n,32,126)}encodeBody(){return new Uint8Array([27,63,this.n])}};var J=class extends o{name="Initialize";encodeBody(){return new Uint8Array([27,64])}};var X=class extends o{constructor(t){super();this.positions=t}positions;name="SetHorizontalTabPositions";validate(){if(this.positions.length>32)throw new RangeError(`[${this.name}] Maximal 32 Tabpositionen erlaubt, erhalten: ${this.positions.length}`);for(let t of this.positions)this.assertRange(t,1,255,"Tabposition")}encodeBody(){let t=new h;t.push(27,68);for(let r of this.positions)t.push(r);return t.push(0),t.build()}};var Y=class extends o{constructor(t){super();this.on=t}on;name="SetEmphasized";encodeBody(){return new Uint8Array([27,69,this.on?1:0])}};var ft=class extends o{constructor(t){super();this.on=t}on;name="SetDoubleStrike";encodeBody(){return new Uint8Array([27,71,this.on?1:0])}};var ee=class extends o{constructor(t){super();this.n=t}n;name="PrintAndFeedPaper";validate(){this.assertRange(this.n,0,255)}encodeBody(){return new Uint8Array([27,74,this.n])}};var te=class extends o{name="SelectPageMode";encodeBody(){return new Uint8Array([27,76])}};var re=class extends o{constructor(t){super();this.font=t}font;name="SelectCharacterFont";validate(){this.assertRange(this.font,0,1)}encodeBody(){return new Uint8Array([27,77,this.font])}};var ne=class extends o{constructor(t){super();this.charSet=t}charSet;name="SelectInternationalCharSet";validate(){this.assertRange(this.charSet,0,15)}encodeBody(){return new Uint8Array([27,82,this.charSet])}};var oe=class extends o{name="SelectStandardMode";encodeBody(){return new Uint8Array([27,83])}};var ie=class extends o{constructor(t){super();this.direction=t}direction;name="SelectPrintDirection";validate(){this.assertRange(this.direction,0,3)}encodeBody(){return new Uint8Array([27,84,this.direction])}};var se=class extends o{constructor(t){super();this.on=t}on;name="SetRotation";encodeBody(){return new Uint8Array([27,86,this.on?1:0])}};var ae=class extends o{constructor(t,r,n,s,m,f,y,l){super();this.xL=t;this.xH=r;this.yL=n;this.yH=s;this.dxL=m;this.dxH=f;this.dyL=y;this.dyH=l}xL;xH;yL;yH;dxL;dxH;dyL;dyH;name="SetPrintingAreaPageMode";validate(){for(let[t,r]of[[this.xL,"xL"],[this.xH,"xH"],[this.yL,"yL"],[this.yH,"yH"],[this.dxL,"dxL"],[this.dxH,"dxH"],[this.dyL,"dyL"],[this.dyH,"dyH"]])this.assertRange(t,0,255,r)}encodeBody(){return new Uint8Array([27,87,this.xL,this.xH,this.yL,this.yH,this.dxL,this.dxH,this.dyL,this.dyH])}};var me=class extends o{constructor(t){super();this.n=t}n;name="SetRelativePosition";validate(){if(!Number.isInteger(this.n)||this.n<-32767||this.n>32767)throw new RangeError(`[${this.name}] n muss eine ganze Zahl in [-32767, 32767] sein`)}encodeBody(){let t=this.n<0?M(-this.n):this.n,[r,n]=g(t);return new Uint8Array([27,92,r,n])}};var de=class extends o{constructor(t){super();this.alignment=t}alignment;name="SetJustification";validate(){this.assertRange(this.alignment,0,2)}encodeBody(){return new Uint8Array([27,97,this.alignment])}};var yt=class extends o{constructor(t){super();this.n=t}n;name="SelectPaperEndSensors";validate(){this.assertRange(this.n,0,255)}encodeBody(){return new Uint8Array([27,99,51,this.n])}};var xt=class extends o{constructor(t){super();this.n=t}n;name="SelectPaperStopSensors";validate(){this.assertRange(this.n,0,255)}encodeBody(){return new Uint8Array([27,99,52,this.n])}};var gt=class extends o{constructor(t){super();this.enable=t}enable;name="EnablePanelButtons";encodeBody(){return new Uint8Array([27,99,53,this.enable?0:1])}};var ce=class extends o{constructor(t){super();this.n=t}n;name="PrintAndFeedLines";validate(){this.assertRange(this.n,0,255)}encodeBody(){return new Uint8Array([27,100,this.n])}};var pe=class extends o{constructor(t,r,n){super();this.pin=t;this.t1=r;this.t2=n}pin;t1;t2;name="GeneratePulse";validate(){this.assertRange(this.pin,0,1,"pin"),this.assertRange(this.t1,0,255,"t1"),this.assertRange(this.t2,0,255,"t2")}encodeBody(){return new Uint8Array([27,112,this.pin,this.t1,this.t2])}};var ue=class extends o{constructor(t){super();this.table=t}table;name="SelectCharacterCodeTable";validate(){if(![0,1,2,3,4,5,6,7,8,9,10,16,17,18,19,20,21].includes(this.table))throw new RangeError(`[${this.name}] Ung\xFCltige Codetabelle: ${this.table}`)}encodeBody(){return new Uint8Array([27,116,this.table])}};var le=class extends o{constructor(t){super();this.on=t}on;name="SetUpsideDown";encodeBody(){return new Uint8Array([27,123,this.on?1:0])}};var he=class extends o{constructor(t,r){super();this.count=t;this.duration=r}count;duration;name="Beep";validate(){this.assertRange(this.count,1,9,"count"),this.assertRange(this.duration,1,9,"duration")}encodeBody(){return new Uint8Array([27,66,this.count,this.duration])}};var fe=class extends o{constructor(t,r,n){super();this.count=t;this.interval=r;this.mode=n}count;interval;mode;name="BeepAndFlash";validate(){this.assertRange(this.count,1,20,"count"),this.assertRange(this.interval,1,20,"interval"),this.assertRange(this.mode,0,3,"mode")}encodeBody(){return new Uint8Array([27,67,this.count,this.interval,this.mode])}};var ye=class extends o{constructor(t,r){super();this.n=t;this.mode=r}n;mode;name="PrintNvBitImage";validate(){this.assertRange(this.n,0,255),this.assertRange(this.mode,0,3,"mode")}encodeBody(){return new Uint8Array([28,112,this.n,this.mode])}};var xe=class extends o{constructor(t,r){super();this.n=t;this.images=r}n;images;name="DefineNvBitImage";validate(){if(this.assertRange(this.n,0,255),this.images.length!==this.n)throw new RangeError(`[${this.name}] n=${this.n} aber ${this.images.length} Bilder \xFCbergeben`)}encodeBody(){let t=new h;t.push(28,113,this.n);for(let r of this.images)t.push(r.xL,r.xH,r.yL,r.yH),t.push(r.data);return t.build()}};var ge=class extends o{constructor(t){super();this.n=t}n;name="SetKanjiPrintMode";validate(){this.assertRange(this.n,0,255)}encodeBody(){return new Uint8Array([28,33,this.n])}};var be=class extends o{name="SelectKanjiMode";encodeBody(){return new Uint8Array([28,38])}};var we=class extends o{constructor(t){super();this.mode=t}mode;name="SetKanjiUnderline";validate(){this.assertRange(this.mode,0,2)}encodeBody(){return new Uint8Array([28,45,this.mode])}};var Ce=class extends o{name="CancelKanjiMode";encodeBody(){return new Uint8Array([28,46])}};var Se=class extends o{constructor(t,r,n){super();this.c1=t;this.c2=r;this.data=n}c1;c2;data;name="DefineKanji";validate(){if(this.c1!==254)throw new RangeError(`[${this.name}] c1 muss 0xFE sein, erhalten: ${this.c1}`);if(this.assertRange(this.c2,161,254,"c2"),this.data.length!==72)throw new RangeError(`[${this.name}] Datenl\xE4nge muss 72 Bytes sein, erhalten: ${this.data.length}`)}encodeBody(){let t=new h;return t.push(28,50,this.c1,this.c2),t.push(this.data),t.build()}};var Ae=class extends o{constructor(t,r){super();this.n1=t;this.n2=r}n1;n2;name="SetKanjiSpacing";validate(){this.assertRange(this.n1,0,255,"n1"),this.assertRange(this.n2,0,255,"n2")}encodeBody(){return new Uint8Array([28,83,this.n1,this.n2])}};var ve=class extends o{constructor(t){super();this.on=t}on;name="SetKanjiQuadruple";encodeBody(){return new Uint8Array([28,87,this.on?1:0])}};var Ue=class extends o{constructor(t,r){super();this.heightTimes=t;this.widthTimes=r}heightTimes;widthTimes;name="SelectCharacterSize";validate(){this.assertRange(this.heightTimes,1,8,"heightTimes"),this.assertRange(this.widthTimes,1,8,"widthTimes")}encodeBody(){let t=this.widthTimes-1<<4|this.heightTimes-1;return new Uint8Array([29,33,t])}};var bt=class extends o{constructor(t){super();this.n=t}n;name="SetAbsoluteVerticalPosition";validate(){this.assertRange(this.n,0,65535)}encodeBody(){let[t,r]=g(this.n);return new Uint8Array([29,36,t,r])}};var Pe=class extends o{constructor(t,r,n){super();this.x=t;this.y=r;this.data=n}x;y;data;name="DefineDownloadedBitImage";validate(){if(this.assertRange(this.x,1,255,"x"),this.assertRange(this.y,1,48,"y"),this.x*this.y>912)throw new RangeError(`[${this.name}] x\xD7y (${this.x*this.y}) darf 912 nicht \xFCberschreiten`);let t=this.x*this.y*8;if(this.data.length!==t)throw new RangeError(`[${this.name}] Datenl\xE4nge muss ${t} Bytes sein, erhalten: ${this.data.length}`)}encodeBody(){let t=new h;return t.push(29,42,this.x,this.y),t.push(this.data),t.build()}};var Be=class extends o{constructor(t){super();this.mode=t}mode;name="PrintDownloadedBitImage";validate(){this.assertRange(this.mode,0,3,"mode")}encodeBody(){return new Uint8Array([29,47,this.mode])}};var Ee=class extends o{name="MacroStartEnd";encodeBody(){return new Uint8Array([29,58])}};var Re=class extends o{constructor(t){super();this.on=t}on;name="SetReverse";encodeBody(){return new Uint8Array([29,66,this.on?1:0])}};var De=class extends o{constructor(t){super();this.position=t}position;name="SetHriPosition";validate(){this.assertRange(this.position,0,3)}encodeBody(){return new Uint8Array([29,72,this.position])}};var Le=class extends o{constructor(t){super();this.n=t}n;name="SetLeftMargin";validate(){this.assertRange(this.n,0,65535)}encodeBody(){let[t,r]=g(this.n);return new Uint8Array([29,76,t,r])}};var wt=class extends o{constructor(t,r){super();this.x=t;this.y=r}x;y;name="SetMotionUnits";validate(){this.assertRange(this.x,0,255,"x"),this.assertRange(this.y,0,255,"y")}encodeBody(){return new Uint8Array([29,80,this.x,this.y])}};F();var Me=class extends o{constructor(t,r){super();this.mode=t;this.feedDots=r}mode;feedDots;name="Cut";validate(){if(this.mode===66){if(this.feedDots===void 0)throw new RangeError(`[${this.name}] PartialAfterFeed ben\xF6tigt feedDots`);this.assertRange(this.feedDots,0,255,"feedDots")}}encodeBody(){return this.mode===66?new Uint8Array([29,86,66,this.feedDots]):new Uint8Array([29,86,this.mode])}};var He=class extends o{constructor(t){super();this.n=t}n;name="SetPrintingAreaWidth";validate(){this.assertRange(this.n,0,65535)}encodeBody(){let[t,r]=g(this.n);return new Uint8Array([29,87,t,r])}};var Ct=class extends o{constructor(t){super();this.n=t}n;name="SetRelativeVerticalPosition";validate(){if(!Number.isInteger(this.n)||this.n<-32767||this.n>32767)throw new RangeError(`[${this.name}] n muss eine ganze Zahl in [-32767, 32767] sein`)}encodeBody(){let t=this.n<0?M(-this.n):this.n,[r,n]=g(t);return new Uint8Array([29,92,r,n])}};var Fe=class extends o{constructor(t,r,n){super();this.r=t;this.t=r;this.m=n}r;t;m;name="ExecuteMacro";validate(){this.assertRange(this.r,0,255,"r"),this.assertRange(this.t,0,255,"t"),this.assertRange(this.m,0,1,"m")}encodeBody(){return new Uint8Array([29,94,this.r,this.t,this.m])}};var je=class extends o{constructor(t){super();this.n=t}n;name="EnableAsb";validate(){this.assertRange(this.n,0,255)}encodeBody(){return new Uint8Array([29,97,this.n])}};var Oe=class extends o{constructor(t){super();this.font=t}font;name="SetHriFont";validate(){this.assertRange(this.font,0,1)}encodeBody(){return new Uint8Array([29,102,this.font])}};var ke=class extends o{constructor(t){super();this.n=t}n;name="SetBarcodeHeight";validate(){this.assertRange(this.n,1,255)}encodeBody(){return new Uint8Array([29,104,this.n])}};import{TextDecoder as mr}from"util";var C=class{constructor(e,t,r){this.system=e;this.minLen=t;this.maxLen=r}system;minLen;maxLen;encode(e){let t=typeof e=="string"?e:new mr().decode(e);if(t.length<this.minLen||t.length>this.maxLen)throw new RangeError(`Barcode-Daten f\xFCr System ${this.system}: L\xE4nge ${t.length} au\xDFerhalb [${this.minLen}, ${this.maxLen}]`);for(let s of t){let m=s.charCodeAt(0);if(m<48||m>57)throw new Error(`Ung\xFCltiges Zeichen "${s}" \u2014 nur Ziffern 0\u20139 erlaubt`)}let r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);let n=new Uint8Array(1+r.length);return n[0]=r.length,n.set(r,1),n}};import{TextDecoder as dr}from"util";var cr=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%+-./*"),Ie=class{system=69;encode(e){let t=typeof e=="string"?e:new dr().decode(e);if(t.length<1)throw new RangeError("CODE39: Mindestens 1 Zeichen erforderlich");for(let s of t)if(!cr.has(s))throw new Error(`CODE39: Ung\xFCltiges Zeichen "${s}"`);let r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);let n=new Uint8Array(1+r.length);return n[0]=r.length,n.set(r,1),n}};import{TextDecoder as pr}from"util";var $e=class{system=70;encode(e){let t=typeof e=="string"?e:new pr().decode(e);if(t.length<1)throw new RangeError("ITF: Mindestens 1 Zeichen erforderlich");if(t.length%2!==0)throw new RangeError(`ITF: Datenl\xE4nge muss gerade sein, erhalten: ${t.length}`);for(let s of t)if(s<"0"||s>"9")throw new Error(`ITF: Ung\xFCltiges Zeichen "${s}" \u2014 nur Ziffern 0\u20139 erlaubt`);let r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);let n=new Uint8Array(1+r.length);return n[0]=r.length,n.set(r,1),n}};import{TextDecoder as ur}from"util";var lr=new Set("0123456789ABCDabcd$+-./:".split("")),qe=class{system=71;encode(e){let t=(typeof e=="string"?e:new ur().decode(e)).toUpperCase();if(t.length<1)throw new RangeError("CODABAR: Mindestens 1 Zeichen erforderlich");for(let s of t)if(!lr.has(s))throw new Error(`CODABAR: Ung\xFCltiges Zeichen "${s}"`);let r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);let n=new Uint8Array(1+r.length);return n[0]=r.length,n.set(r,1),n}};import{TextDecoder as hr}from"util";var Te=class{system=73;encode(e){let t=typeof e=="string"?e:new hr().decode(e);if(t.length<2)throw new RangeError("CODE128: Mindestens 2 Zeichen erforderlich (Subset-Selektor + Daten)");if(!["{A","{B","{C"].some(m=>t.startsWith(m)))throw new Error(`CODE128: Daten m\xFCssen mit einem Subset-Selektor beginnen ({A, {B oder {C), erhalten: "${t.substring(0,2)}"`);let n=new Uint8Array(t.length);for(let m=0;m<t.length;m++)n[m]=t.charCodeAt(m)&255;let s=new Uint8Array(1+n.length);return s[0]=n.length,s.set(n,1),s}};var fr=new Map([[65,new C(65,11,12)],[66,new C(66,11,12)],[67,new C(67,12,13)],[68,new C(68,7,8)],[69,new Ie],[70,new $e],[71,new qe],[73,new Te]]);function er(i){let e=fr.get(i);if(!e)throw new Error(`Keine Standard-Strategie f\xFCr Barcode-System ${i}`);return e}var ze=class extends o{constructor(t,r,n){super();this.system=t;this.data=r;this.strategy=n??er(t)}system;data;name="PrintBarcode";strategy;encodeBody(){let t=this.strategy.encode(this.data),r=new h;return r.push(29,107,this.system),r.push(t),r.build()}};var Ne=class extends o{constructor(t){super();this.n=t}n;name="TransmitStatus";validate(){if(![1,2,49,50].includes(this.n))throw new RangeError(`[${this.name}] n muss 1, 2, 49 oder 50 sein, erhalten: ${this.n}`)}encodeBody(){return new Uint8Array([29,114,this.n])}};var We=class extends o{constructor(t,r,n,s,m,f){super();this.mode=t;this.xL=r;this.xH=n;this.yL=s;this.yH=m;this.data=f}mode;xL;xH;yL;yH;data;name="PrintRasterBitImage";validate(){this.assertRange(this.mode,0,3,"mode"),this.assertRange(this.xL,0,255,"xL"),this.assertRange(this.xH,0,255,"xH"),this.assertRange(this.yL,0,255,"yL"),this.assertRange(this.yH,0,255,"yH");let t=(this.xL+this.xH*256)*(this.yL+this.yH*256);if(t===0)throw new RangeError(`[${this.name}] Bildgr\xF6\xDFe darf nicht 0 sein`);if(this.data.length!==t)throw new RangeError(`[${this.name}] Datenl\xE4nge muss ${t} Bytes sein, erhalten: ${this.data.length}`)}encodeBody(){let t=new h;return t.push(29,118,48,this.mode,this.xL,this.xH,this.yL,this.yH),t.push(this.data),t.build()}};var _e=class extends o{constructor(t){super();this.width=t}width;name="SetBarcodeWidth";validate(){this.assertRange(this.width,2,6)}encodeBody(){return new Uint8Array([29,119,this.width])}};var St=class extends o{name="HexDump";encodeBody(){return new Uint8Array([29,40,65,2,0,0,1])}};var Ge=class extends o{name="PrintQrCode";data;moduleSize;errorCorrection;model;constructor(e,t={}){if(super(),this.data=typeof e=="string"?new TextEncoder().encode(e):e,this.moduleSize=t.moduleSize??3,this.errorCorrection=t.errorCorrection??49,this.model=t.model??2,this.moduleSize<1||this.moduleSize>16)throw new RangeError(`QR-Modulgr\xF6\xDFe muss 1\u201316 sein, war: ${this.moduleSize}`);if(this.data.length<1)throw new RangeError("QR-Code-Daten d\xFCrfen nicht leer sein")}encodeBody(){let e=new h,t=49;e.push(29,40,107,4,0,t,65,this.model,0),e.push(29,40,107,3,0,t,67,this.moduleSize),e.push(29,40,107,3,0,t,69,this.errorCorrection);let n=this.data.length+3,s=n&255,m=n>>8&255;return e.push(29,40,107,s,m,t,80,48),e.push(this.data),e.push(29,40,107,3,0,t,81,48),e.build()}};var d=class i{static customFactories=new Map;static register(e,t){i.customFactories.set(e,t),k.getInstance().register({name:e,description:"Custom Command",escPosCommand:"custom"})}static createCustom(e,t){let r=i.customFactories.get(e);if(!r)throw new Error(`Kein Custom-Command mit dem Namen "${e}" registriert`);return r(t)}static horizontalTab(){return new I}static lineFeed(){return new $}static formFeed(){return new q}static carriageReturn(){return new T}static cancelPageData(){return new z}static transmitRealtimeStatus(e){return new N(e)}static realtimeRequest(e){return new W(e)}static generatePulseRealtime(e,t){return new _(e,t)}static printPageMode(){return new mt}static setRightCharacterSpacing(e){return new dt(e)}static selectPrintModes(e){return new G(e)}static setAbsolutePosition(e){return new K(e)}static selectUserCharSet(e){return new ct(e)}static defineUserChars(e,t,r,n){return new pt(e,t,r,n)}static selectBitImageMode(e,t,r,n){return new ut(e,t,r,n)}static setUnderline(e){return new Q(e)}static setDefaultLineSpacing(){return new Z}static setLineSpacing(e){return new V(e)}static setPeripheralDevice(e){return new lt(e)}static cancelUserChar(e){return new ht(e)}static initialize(){return new J}static setHorizontalTabPositions(e){return new X(e)}static setEmphasized(e){return new Y(e)}static setDoubleStrike(e){return new ft(e)}static printAndFeedPaper(e){return new ee(e)}static selectPageMode(){return new te}static selectCharacterFont(e){return new re(e)}static selectInternationalCharSet(e){return new ne(e)}static selectStandardMode(){return new oe}static selectPrintDirection(e){return new ie(e)}static setRotation(e){return new se(e)}static setPrintingAreaPageMode(e,t,r,n,s,m,f,y){return new ae(e,t,r,n,s,m,f,y)}static setRelativePosition(e){return new me(e)}static setJustification(e){return new de(e)}static selectPaperEndSensors(e){return new yt(e)}static selectPaperStopSensors(e){return new xt(e)}static enablePanelButtons(e){return new gt(e)}static printAndFeedLines(e){return new ce(e)}static generatePulse(e,t,r){return new pe(e,t,r)}static selectCharacterCodeTable(e){return new ue(e)}static setUpsideDown(e){return new le(e)}static beep(e,t){return new he(e,t)}static beepAndFlash(e,t,r){return new fe(e,t,r)}static printNvBitImage(e,t){return new ye(e,t)}static defineNvBitImage(e,t){return new xe(e,t)}static setKanjiPrintMode(e){return new ge(e)}static selectKanjiMode(){return new be}static setKanjiUnderline(e){return new we(e)}static cancelKanjiMode(){return new Ce}static defineKanji(e,t,r){return new Se(e,t,r)}static setKanjiSpacing(e,t){return new Ae(e,t)}static setKanjiQuadruple(e){return new ve(e)}static selectCharacterSize(e,t){return new Ue(e,t)}static setAbsoluteVerticalPosition(e){return new bt(e)}static defineDownloadedBitImage(e,t,r){return new Pe(e,t,r)}static printDownloadedBitImage(e){return new Be(e)}static macroStartEnd(){return new Ee}static setReverse(e){return new Re(e)}static setHriPosition(e){return new De(e)}static setLeftMargin(e){return new Le(e)}static setMotionUnits(e,t){return new wt(e,t)}static cut(e,t){return new Me(e,t)}static setPrintingAreaWidth(e){return new He(e)}static setRelativeVerticalPosition(e){return new Ct(e)}static executeMacro(e,t,r){return new Fe(e,t,r)}static enableAsb(e){return new je(e)}static setHriFont(e){return new Oe(e)}static setBarcodeHeight(e){return new ke(e)}static printBarcode(e,t,r){return new ze(e,t,r)}static transmitStatus(e){return new Ne(e)}static printRasterBitImage(e,t,r,n,s,m){return new We(e,t,r,n,s,m)}static setBarcodeWidth(e){return new _e(e)}static hexDump(){return new St}static printQrCode(e,t){return new Ge(e,t)}static raw(e,t){return new O(e,t)}};var R=class i{constructor(e=0,t=0,r=!1,n=!1,s=!1,m=!1,f=0,y=!1,l=!1,P=!1,A=0,Mt=0,Ht=null){this.alignment=e;this.font=t;this.emphasized=r;this.doubleStrike=n;this.doubleHeight=s;this.doubleWidth=m;this.underline=f;this.rotation=y;this.upsideDown=l;this.reverse=P;this.codeTable=A;this.rightSpacing=Mt;this.lineSpacing=Ht}alignment;font;emphasized;doubleStrike;doubleHeight;doubleWidth;underline;rotation;upsideDown;reverse;codeTable;rightSpacing;lineSpacing;clone(){return new i(this.alignment,this.font,this.emphasized,this.doubleStrike,this.doubleHeight,this.doubleWidth,this.underline,this.rotation,this.upsideDown,this.reverse,this.codeTable,this.rightSpacing,this.lineSpacing)}};var Ke=class{snapshot;constructor(e){this.snapshot=e.clone()}getSnapshot(){return this.snapshot.clone()}};F();at();var S=class{sequence=new j;state=new R;mementoStack=[];save(){return this.mementoStack.push(new Ke(this.state)),this}restore(){let e=this.mementoStack.pop();if(!e)throw new Error("ReceiptBuilder.restore(): kein gespeicherter Zustand vorhanden");let t=this.state;return this.state=e.getSnapshot(),this._syncState(t),this}_syncState(e){let t=this.state;t.alignment!==e.alignment&&this.sequence.add(d.setJustification(t.alignment)),t.font!==e.font&&this.sequence.add(d.selectCharacterFont(t.font)),t.underline!==e.underline&&this.sequence.add(d.setUnderline(t.underline)),t.rotation!==e.rotation&&this.sequence.add(d.setRotation(t.rotation)),t.upsideDown!==e.upsideDown&&this.sequence.add(d.setUpsideDown(t.upsideDown)),t.reverse!==e.reverse&&this.sequence.add(d.setReverse(t.reverse)),t.codeTable!==e.codeTable&&this.sequence.add(d.selectCharacterCodeTable(t.codeTable)),t.rightSpacing!==e.rightSpacing&&this.sequence.add(d.setRightCharacterSpacing(t.rightSpacing)),(t.emphasized!==e.emphasized||t.doubleStrike!==e.doubleStrike||t.doubleHeight!==e.doubleHeight||t.doubleWidth!==e.doubleWidth||t.font!==e.font)&&this.sequence.add(d.selectPrintModes({fontB:t.font===1,emphasized:t.emphasized,doubleHeight:t.doubleHeight,doubleWidth:t.doubleWidth,underline:t.underline!==0})),t.lineSpacing!==e.lineSpacing&&(t.lineSpacing===null?this.sequence.add(d.setDefaultLineSpacing()):this.sequence.add(d.setLineSpacing(t.lineSpacing)))}add(e){return this.sequence.add(e),this}use(e){return e(this),this}initialize(){return this.sequence.add(d.initialize()),this.state=new R,this}align(e){return this.state.alignment!==e&&(this.state.alignment=e,this.sequence.add(d.setJustification(e))),this}left(){return this.align(0)}center(){return this.align(1)}right(){return this.align(2)}font(e){return this.state.font!==e&&(this.state.font=e,this.sequence.add(d.selectCharacterFont(e))),this}bold(e=!0){return this.state.emphasized!==e&&(this.state.emphasized=e,this.sequence.add(d.setEmphasized(e))),this}doubleStrike(e=!0){return this.state.doubleStrike!==e&&(this.state.doubleStrike=e,this.sequence.add(d.setDoubleStrike(e))),this}underline(e=1){return this.state.underline!==e&&(this.state.underline=e,this.sequence.add(d.setUnderline(e))),this}doubleHeight(e=!0){return this.state.doubleHeight=e,this.sequence.add(d.selectPrintModes({fontB:this.state.font===1,emphasized:this.state.emphasized,doubleHeight:e,doubleWidth:this.state.doubleWidth})),this}doubleWidth(e=!0){return this.state.doubleWidth=e,this.sequence.add(d.selectPrintModes({fontB:this.state.font===1,emphasized:this.state.emphasized,doubleHeight:this.state.doubleHeight,doubleWidth:e})),this}rotate(e=!0){return this.state.rotation!==e&&(this.state.rotation=e,this.sequence.add(d.setRotation(e))),this}upsideDown(e=!0){return this.state.upsideDown!==e&&(this.state.upsideDown=e,this.sequence.add(d.setUpsideDown(e))),this}reverse(e=!0){return this.state.reverse!==e&&(this.state.reverse=e,this.sequence.add(d.setReverse(e))),this}codeTable(e){return this.state.codeTable!==e&&(this.state.codeTable=e,this.sequence.add(d.selectCharacterCodeTable(e))),this}rightSpacing(e){return this.state.rightSpacing=e,this.sequence.add(d.setRightCharacterSpacing(e)),this}lineSpacing(e){return this.state.lineSpacing=e,this.sequence.add(d.setLineSpacing(e)),this}defaultLineSpacing(){return this.state.lineSpacing=null,this.sequence.add(d.setDefaultLineSpacing()),this}text(e){let t=new h;return t.text(e),this.sequence.add(d.raw(t.build(),"Text")),this}textLine(e){return this.text(e).feed()}feed(){return this.sequence.add(d.lineFeed()),this}feedLines(e){return this.sequence.add(d.printAndFeedLines(e)),this}feedDots(e){return this.sequence.add(d.printAndFeedPaper(e)),this}divider(e="-",t=48){return this.textLine(e.repeat(t))}absolutePosition(e){return this.sequence.add(d.setAbsolutePosition(e)),this}relativePosition(e){return this.sequence.add(d.setRelativePosition(e)),this}leftMargin(e){return this.sequence.add(d.setLeftMargin(e)),this}hriPosition(e){return this.sequence.add(d.setHriPosition(e)),this}hriFont(e){return this.sequence.add(d.setHriFont(e)),this}barcodeHeight(e){return this.sequence.add(d.setBarcodeHeight(e)),this}barcode(e,t,r){return this.sequence.add(d.printBarcode(e,t,r)),this}qrCode(e,t){return this.sequence.add(d.printQrCode(e,t)),this}cut(e=1,t){return this.sequence.add(d.cut(e,t)),this}openDrawer(e=0,t=50,r=50){return this.sequence.add(d.generatePulse(e,t,r)),this}rasterImage(e,t,r,n,s,m){return this.sequence.add(d.printRasterBitImage(e,t,r,n,s,m)),this}beep(e=1,t=1){return this.sequence.add(d.beep(e,t)),this}build(){return this.sequence}encode(){return this.sequence.encode()}};import{Jimp as tr}from"jimp";var Qe=class{name="FloydSteinberg";dither(e,t,r){let n=new Float32Array(e.length);for(let m=0;m<e.length;m++)n[m]=e[m]??255;let s=new Uint8Array(e.length);for(let m=0;m<r;m++)for(let f=0;f<t;f++){let y=m*t+f,l=n[y]??255,P=l<128?0:255;s[y]=P===0?1:0;let A=l-P;f+1<t&&(n[y+1]=(n[y+1]??255)+A*7/16),m+1<r&&f>0&&(n[y+t-1]=(n[y+t-1]??255)+A*3/16),m+1<r&&(n[y+t]=(n[y+t]??255)+A*5/16),m+1<r&&f+1<t&&(n[y+t+1]=(n[y+t+1]??255)+A*1/16)}return s}};var Ze=class{dither;printWidthDots;constructor(e={}){this.printWidthDots=e.printWidthDots??576,this.dither=e.dither??new Qe}async encodeFile(e){let t=await tr.read(e);return this._processImage(t)}async encodeBuffer(e){let t=await tr.fromBuffer(Buffer.from(e));return this._processImage(t)}async _processImage(e){let t=this.printWidthDots,r=e.height/e.width,n=Math.round(t*r);e.resize({w:t,h:n});let s=e.width,m=e.height,f=new Uint8Array(s*m);for(let w=0;w<m;w++)for(let p=0;p<s;p++){let u=e.getPixelColor(p,w),B=u>>>24&255,tt=u>>>16&255,or=u>>>8&255;(u&255)<128?f[w*s+p]=255:f[w*s+p]=Math.round(.299*B+.587*tt+.114*or)}let y=this.dither.dither(f,s,m),l=Math.ceil(s/8),P=new Uint8Array(l*m);for(let w=0;w<m;w++)for(let p=0;p<l;p++){let u=0;for(let B=0;B<8;B++){let tt=p*8+B;tt<s&&(y[w*s+tt]??0)&&(u|=128>>B)}P[w*l+p]=u}let A=l&255,Mt=l>>8&255,Ht=m&255,nr=m>>8&255;return{data:P,widthBytes:l,heightDots:m,xL:A,xH:Mt,yL:Ht,yH:nr}}};var Ut=class extends S{cols;printWidthDots;defaultQtyDisplay;subIndent=" ";constructor(e={}){super(),this.printWidthDots=e.printWidthDots??576,this.cols=e.charsPerLine??48,this.defaultQtyDisplay=e.quantityDisplay??"inline"}async logo(e,t){let n=await new Ze({printWidthDots:this.printWidthDots,...t!==void 0?{dither:t}:{}}).encodeFile(e);return this.center().rasterImage(0,n.xL,n.xH,n.yL,n.yH,n.data).feed(),this}address(e){return this.center().bold(!0).textLine(e.company).bold(!1).textLine(e.street),e.postalCity&&this.textLine(e.postalCity),e.extra&&this.textLine(e.extra),this.left()}separator(e="-"){return this.divider(e,this.cols)}itemsHeader(){return this.textLine(this._mainRow("Nr","Artikel","Preis"))}item(e,t,r,n={}){let s=n.qty??1,m=n.qtyDisplay??this.defaultQtyDisplay,f=s>1,y=f&&m==="inline"?`${s}x ${t}`:t;if(this.textLine(this._mainRow(String(e),y,r)),f&&m==="separate"){let l=n.unitPrice?`${s}x \xE0 ${n.unitPrice}`:`${s}x`;this.textLine(this.subIndent+l)}for(let l of n.subLines??[])this.textLine(this._subRow(l));return this}total(e,t){return this.bold(!0).textLine(this._twoCol(e,t)).bold(!1)}taxLine(e,t){return this.textLine(this._twoCol(e,t))}footer(e,{withSeparator:t=!0}={}){t&&this.separator(),this.center();for(let r of e)this.textLine(r);return this.left()}_mainRow(e,t,r){return`${e.padStart(2)} ${t}`.padEnd(this.cols-r.length)+r}_subRow(e){let t=this.subIndent+e.label;return e.value?t.padEnd(this.cols-e.value.length)+e.value:t}_twoCol(e,t){return e.padEnd(this.cols-t.length)+t}};var U=class{observers=new Set;subscribe(e){return this.observers.add(e),()=>this.observers.delete(e)}unsubscribe(e){this.observers.delete(e)}notify(e){for(let t of this.observers)try{t.onEvent(e)}catch{}}makeEvent(e,t){return{type:e,timestamp:new Date,data:t}}};var Pt=class extends U{constructor(t){super();this.connection=t}connection;createBuilder(){return new S}async write(t){try{await this.connection.write(t),this.notify(this.makeEvent("written",{bytes:t,byteCount:t.length}))}catch(r){let n=r instanceof Error?r:new Error(String(r));throw this.notify(this.makeEvent("error",{error:n})),n}}async send(t){return this.write(t.encode())}async print(t){let r=(t instanceof S,t.encode());return this.write(r)}async open(){await this.connection.open(),this.notify(this.makeEvent("opened"))}async close(){await this.connection.close(),this.notify(this.makeEvent("closed"))}async initialize(){return this.send(d.initialize())}async cut(t=5){let{CutMode:r}=await Promise.resolve().then(()=>(F(),Qt));return this.send(d.cut(r.Partial,t))}async openDrawer(t=0,r=50,n=50){let{DrawerPin:s}=await Promise.resolve().then(()=>(at(),Yt));return this.send(d.generatePulse(t,r,n))}};var Ve=class{constructor(e){this.byte=e}byte;get rawByte(){return this.byte}get isCashDrawerClosed(){return(this.byte&4)!==0}get isOffline(){return(this.byte&8)!==0}get isOnline(){return!this.isOffline}};var Je=class{constructor(e){this.byte=e}byte;get rawByte(){return this.byte}get isCoverOpen(){return(this.byte&4)!==0}get isPaperBeingFed(){return(this.byte&8)!==0}get isPaperEndStop(){return(this.byte&32)!==0}get hasError(){return(this.byte&64)!==0}};var Xe=class{constructor(e){this.byte=e}byte;get rawByte(){return this.byte}get hasAutoCutterError(){return(this.byte&8)!==0}get hasUnrecoverableError(){return(this.byte&32)!==0}get hasAutoRecoverableError(){return(this.byte&64)!==0}get hasAnyError(){return this.hasAutoCutterError||this.hasUnrecoverableError||this.hasAutoRecoverableError}};var Ye=class{constructor(e){this.byte=e}byte;get rawByte(){return this.byte}get isPaperNearEnd(){return(this.byte&12)!==0}get isPaperEnd(){return(this.byte&96)!==0}get isNearEndGsr(){return(this.byte&3)!==0}get isPaperEndGsr(){return(this.byte&12)!==0}get isPaperPresent(){return!this.isPaperEnd}};var et=class{constructor(e){this.byte=e}byte;get rawByte(){return this.byte}get isDrawerClosed(){return(this.byte&1)!==0}get isDrawerOpen(){return!this.isDrawerClosed}};var Bt=class i{static decodePrinterStatus(e){return new Ve(e)}static decodeOfflineStatus(e){return new Je(e)}static decodeErrorStatus(e){return new Xe(e)}static decodePaperSensorStatus(e){return new Ye(e)}static decodeDrawerStatus(e){return new et(e)}static decode(e,t){switch(e){case"printer":return i.decodePrinterStatus(t);case"offline":return i.decodeOfflineStatus(t);case"error":return i.decodeErrorStatus(t);case"paper":return i.decodePaperSensorStatus(t);case"drawer":return i.decodeDrawerStatus(t)}}static typeFromN(e){return{1:"printer",2:"offline",3:"error",4:"paper"}[e]}};var b=class extends U{_isOpen=!1;get isOpen(){return this._isOpen}async open(){this._isOpen||(await this._open(),this._isOpen=!0,this.notify(this.makeEvent("opened")))}async write(e){if(!this._isOpen)throw new Error(`[${this.constructor.name}] Verbindung ist nicht ge\xF6ffnet`);await this._write(e),this.notify(this.makeEvent("written",{bytes:e,byteCount:e.length}))}async close(){this._isOpen&&(await this._close(),this._isOpen=!1,this.notify(this.makeEvent("closed")))}};var D=class extends b{buffers=[];async _open(){}async _write(e){this.buffers.push(e.slice())}async _close(){}getBuffer(){let e=0;for(let n of this.buffers)e+=n.length;let t=new Uint8Array(e),r=0;for(let n of this.buffers)t.set(n,r),r+=n.length;return t}getWrites(){return this.buffers}clear(){this.buffers.length=0}async read(e){return this.buffers[this.buffers.length-1]??new Uint8Array(0)}};import*as rr from"net";var L=class extends b{constructor(t,r=9100,n=5e3){super();this.host=t;this.port=r;this.connectTimeout=n}host;port;connectTimeout;socket=null;async _open(){return new Promise((t,r)=>{let n=new rr.Socket,s=setTimeout(()=>{n.destroy(),r(new Error(`Verbindungs-Timeout zu ${this.host}:${this.port}`))},this.connectTimeout);n.connect(this.port,this.host,()=>{clearTimeout(s),this.socket=n,t()}),n.once("error",m=>{clearTimeout(s),r(m)})})}async _write(t){if(!this.socket)throw new Error("Kein aktiver Socket");return new Promise((r,n)=>{this.socket.write(t,s=>{s?n(s):r()})})}async _close(){return new Promise(t=>{if(!this.socket){t();return}this.socket.end(()=>{this.socket=null,t()})})}async read(t=2e3){if(!this.socket)throw new Error("Kein aktiver Socket");return new Promise((r,n)=>{let s=setTimeout(()=>{n(new Error("Lese-Timeout"))},t);this.socket.once("data",m=>{clearTimeout(s),r(new Uint8Array(m))})})}};var Et=class extends b{constructor(t,r){super();this.vendorId=t;this.productId=r}vendorId;productId;device=null;async _open(){let t;try{t=await import("usb")}catch{throw new Error('Das "usb"-Package ist nicht installiert. Bitte mit npm install usb nachinstallieren.')}let r=t.findByIds(this.vendorId,this.productId);if(!r)throw new Error(`USB-Ger\xE4t mit VID=${this.vendorId} PID=${this.productId} nicht gefunden`);r.open(),this.device=r}async _write(t){throw new Error("UsbConnection._write: Bitte die Bulk-Transfer-Logik f\xFCr dein Ger\xE4t implementieren")}async _close(){this.device&&(this.device.close(),this.device=null)}};var Rt=class extends b{constructor(t,r=9600){super();this.path=t;this.baudRate=r}path;baudRate;port=null;async _open(){let t;try{t=await import("serialport")}catch{throw new Error('Das "serialport"-Package ist nicht installiert. Bitte mit npm install serialport nachinstallieren.')}let{SerialPort:r}=t,n=new r({path:this.path,baudRate:this.baudRate,autoOpen:!1});await new Promise((s,m)=>{n.open(f=>{f?m(f):s()})}),this.port=n}async _write(t){if(!this.port)throw new Error("Serial-Port nicht ge\xF6ffnet");let r=this.port;return new Promise((n,s)=>{r.write(t,m=>{m?s(m):n()})})}async _close(){if(!this.port)return;let t=this.port;await new Promise((r,n)=>{t.close(s=>{s?n(s):r()})}),this.port=null}};var Dt=class i{static creators=new Map([["buffer",e=>new D],["network",e=>new L(e.host,e.port??9100,e.timeout??5e3)]]);static register(e,t){i.creators.set(e,t)}static create(e,t={}){let r=i.creators.get(e);if(!r)throw new Error(`Unbekannter Connection-Typ "${e}". Registriert: ${[...i.creators.keys()].join(", ")}`);return r(t)}static createBuffer(){return new D}static createNetwork(e,t=9100){return new L(e,t)}};var Lt=class{constructor(e=128){this.threshold=e}threshold;name="Threshold";dither(e,t,r){let n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=(e[s]??255)<this.threshold?1:0;return n}};export{o as AbstractCommand,b as AbstractConnection,nt as Alignment,v as BarcodeSystem,_t as BarcodeWidth,fe as BeepAndFlashCommand,he as BeepCommand,Jt as BitImageMode,D as BufferConnection,h as ByteBuilder,Tt as CAN,$t as CR,Ce as CancelKanjiModeCommand,z as CancelPageDataCommand,T as CarriageReturnCommand,At as CharacterCodeTable,qe as CodabarStrategy,Te as Code128Strategy,Ie as Code39Strategy,d as CommandFactory,k as CommandRegistry,j as CommandSequence,Dt as ConnectionFactory,Me as CutCommand,H as CutMode,qt as DC4,E as DLE,Pe as DefineDownloadedBitImageCommand,Se as DefineKanjiCommand,xe as DefineNvBitImageCommand,st as DrawerPin,et as DrawerStatus,Nt as ENQ,zt as EOT,a as ESC,je as EnableAsbCommand,Xe as ErrorStatus,Fe as ExecuteMacroCommand,rt as FF,x as FS,Qe as FloydSteinbergDither,ot as Font,q as FormFeedCommand,c as GS,pe as GeneratePulseCommand,_ as GeneratePulseRealtimeCommand,kt as HT,I as HorizontalTabCommand,Kt as HriFont,Gt as HriPosition,Ze as ImageEncoder,J as InitializeCommand,Zt as InternationalCharacterSet,Ut as InvoiceBuilder,$e as ItfStrategy,It as LF,$ as LineFeedCommand,Ee as MacroStartEndCommand,Ot as NUL,L as NetworkConnection,Je as OfflineStatus,Ye as PaperSensorStatus,ce as PrintAndFeedLinesCommand,ee as PrintAndFeedPaperCommand,ze as PrintBarcodeCommand,Vt as PrintDirection,Be as PrintDownloadedBitImageCommand,ye as PrintNvBitImageCommand,Ge as PrintQrCodeCommand,We as PrintRasterBitImageCommand,R as PrintState,Pt as Printer,Ve as PrinterStatus,vt as QrCodeErrorCorrection,Xt as RasterMode,O as RawCommand,W as RealtimeRequestCommand,S as ReceiptBuilder,Wt as SP,ue as SelectCharacterCodeTableCommand,re as SelectCharacterFontCommand,Ue as SelectCharacterSizeCommand,ne as SelectInternationalCharSetCommand,be as SelectKanjiModeCommand,te as SelectPageModeCommand,ie as SelectPrintDirectionCommand,G as SelectPrintModesCommand,oe as SelectStandardModeCommand,Rt as SerialConnection,K as SetAbsolutePositionCommand,ke as SetBarcodeHeightCommand,_e as SetBarcodeWidthCommand,Z as SetDefaultLineSpacingCommand,Y as SetEmphasizedCommand,X as SetHorizontalTabPositionsCommand,Oe as SetHriFontCommand,De as SetHriPositionCommand,de as SetJustificationCommand,ge as SetKanjiPrintModeCommand,ve as SetKanjiQuadrupleCommand,Ae as SetKanjiSpacingCommand,we as SetKanjiUnderlineCommand,Le as SetLeftMarginCommand,V as SetLineSpacingCommand,ae as SetPrintingAreaPageModeCommand,He as SetPrintingAreaWidthCommand,me as SetRelativePositionCommand,Re as SetReverseCommand,se as SetRotationCommand,Q as SetUnderlineCommand,le as SetUpsideDownCommand,C as SimpleNumericBarcodeStrategy,Ke as StateMemento,Bt as StatusDecoder,U as Subject,Lt as ThresholdDither,N as TransmitRealtimeStatusCommand,Ne as TransmitStatusCommand,it as UnderlineMode,Et as UsbConnection,ar as fromUint16LE,M as toComplement16,g as toUint16LE};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gitcode6/munbyn-pos-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Vollständiges, hochgradig objektorientiertes TypeScript SDK für MUNBYN POS-80XX 80mm Thermodrucker (ESC/POS)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"test:coverage": "vitest run --coverage",
|
|
30
|
+
"test:hardware": "vitest run --config vitest.hardware.config.ts",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"docs": "typedoc",
|
|
33
|
+
"docs:watch": "typedoc --watch"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"pos",
|
|
37
|
+
"escpos",
|
|
38
|
+
"receipt",
|
|
39
|
+
"printer",
|
|
40
|
+
"thermal",
|
|
41
|
+
"munbyn",
|
|
42
|
+
"typescript"
|
|
43
|
+
],
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"jimp": "^1.6.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^26.0.1",
|
|
50
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
51
|
+
"tsup": "^8.5.0",
|
|
52
|
+
"typedoc": "^0.28.19",
|
|
53
|
+
"typescript": "^5.8.3",
|
|
54
|
+
"vitest": "^3.2.4"
|
|
55
|
+
},
|
|
56
|
+
"optionalDependencies": {
|
|
57
|
+
"serialport": "^12.0.0",
|
|
58
|
+
"usb": "^2.14.0"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18.0.0"
|
|
62
|
+
}
|
|
63
|
+
}
|