@sebbo2002/node-pyatv 7.1.1-develop.2 → 8.0.0-develop.2
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/dist/bin/check.cjs +4 -4
- package/dist/bin/check.cjs.map +1 -1
- package/dist/bin/check.js +1 -1
- package/dist/{chunk-HPNBSME2.js → chunk-D57T7NS2.js} +5 -5
- package/dist/chunk-D57T7NS2.js.map +1 -0
- package/dist/lib/index.cjs +4 -4
- package/dist/lib/index.cjs.map +1 -1
- package/dist/lib/index.d.cts +10 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-HPNBSME2.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var o=(s,e,t)=>new Promise((i,n)=>{var a=c=>{try{p(t.next(c))}catch(u){n(u)}},r=c=>{try{p(t.throw(c))}catch(u){n(u)}},p=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,r);p((t=t.apply(s,e)).next())});var N=(t=>(t.atvremote="atvremote",t.atvscript="atvscript",t))(N||{}),
|
|
1
|
+
var o=(s,e,t)=>new Promise((i,n)=>{var a=c=>{try{p(t.next(c))}catch(u){n(u)}},r=c=>{try{p(t.throw(c))}catch(u){n(u)}},p=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,r);p((t=t.apply(s,e)).next())});var N=(t=>(t.atvremote="atvremote",t.atvscript="atvscript",t))(N||{}),R=(n=>(n.dmap="dmap",n.mrp="mrp",n.airplay="airplay",n.mdns="mdns",n))(R||{}),k=(n=>(n.music="music",n.tv="tv",n.video="video",n.unknown="unknown",n))(k||{}),x=(r=>(r.idle="idle",r.loading="loading",r.paused="paused",r.playing="playing",r.seeking="seeking",r.stopped="stopped",r))(x||{}),E=(i=>(i.all="all",i.track="track",i.off="off",i))(E||{}),_=(i=>(i.albums="albums",i.songs="songs",i.off="off",i))(_||{}),D=(t=>(t.on="on",t.off="off",t))(D||{}),L=(t=>(t.focued="focused",t.unfocused="unfocused",t))(L||{}),U=(d=>(d.down="down",d.home="home",d.homeHold="homeHold",d.left="left",d.menu="menu",d.next="next",d.pause="pause",d.play="play",d.playPause="playPause",d.previous="previous",d.right="right",d.select="select",d.skipBackward="skipBackward",d.skipForward="skipForward",d.stop="stop",d.suspend="suspend",d.topMenu="topMenu",d.up="up",d.volumeDown="volumeDown",d.volumeUp="volumeUp",d.wakeup="wakeup",d.turnOff="turnOff",d.turnOn="turnOn",d))(U||{}),j=(d=>(d.down="down",d.home="home",d.homeHold="home_hold",d.left="left",d.menu="menu",d.next="next",d.pause="pause",d.play="play",d.playPause="play_pause",d.previous="previous",d.right="right",d.select="select",d.skipBackward="skip_backward",d.skipForward="skip_forward",d.stop="stop",d.suspend="suspend",d.topMenu="top_menu",d.up="up",d.volumeDown="volume_down",d.volumeUp="volume_up",d.wakeup="wakeup",d.turnOff="turn_off",d.turnOn="turn_on",d))(j||{}),F=(n=>(n[n.stopped=0]="stopped",n[n.starting=1]="starting",n[n.started=2]="started",n[n.stopping=3]="stopping",n))(F||{});var A=class{constructor(e){this.values=Object.assign({},e,{key:e.key})}get key(){return this.values.key}get oldValue(){return this.values.old}get newValue(){return this.values.new}get value(){return this.values.new}get device(){return this.values.device}};import{EventEmitter as B}from"events";import{spawn as J}from"child_process";var $=[];function y(){let s="?";for(let e=0;e<1e3;e+=1)if(s=Math.round(Math.random()*(e+6)*36).toString(36).toUpperCase(),!$.includes(s)){$.push(s);break}return s}function h(s){s&&$.includes(s)&&$.splice($.indexOf(s),1)}function l(s,e,t){if(t.debug){let i=typeof t.debug=="function"?t.debug:console.log,n=!process.env.NO_COLOR&&!t.noColors,a=[n?"\x1B[0m":"",n?"\x1B[90m":"","[node-pyatv][",n?"\x1B[37m":"",s,n?"\x1B[90m":"","] ",n?"\x1B[0m":"",e];i.apply(null,[a.join("")])}}function M(s,e){return s==="atvremote"&&typeof e.atvremotePath=="string"?e.atvremotePath:s==="atvscript"&&typeof e.atvscriptPath=="string"?e.atvscriptPath:s}function I(s,e,t,i){let n=M(e,i),a=typeof i.spawn=="function"?i.spawn:J;l(s,`${n} ${t.join(" ")}`,i);let r=a(n,t,{env:process.env}),p=v=>l(s,`stdout: ${String(v).trim()}`,i),c=v=>l(s,`stderr: ${String(v).trim()}`,i),u=v=>l(s,`error: ${String(v).trim()}`,i),m=v=>{l(s,`${n} exited with code: ${v}`,i),r.stdout&&r.stdout.off("data",p),r.stderr&&r.stderr.off("data",c),r.off("error",u),r.off("close",m)};return r.stdout&&r.stdout.on("data",p),r.stderr&&r.stderr.on("data",c),r.on("error",u),r.on("close",m),r}function T(s,e,t,i){return o(this,null,function*(){let n={stdout:"",stderr:"",code:0};if(yield new Promise((a,r)=>{let p=I(s,e,t,i),c=f=>n.stdout+=String(f).trim(),u=f=>n.stderr+=String(f).trim(),m=f=>r(f instanceof Error?f:new Error(String(f))),v=f=>{n.code=f,p.stdout&&p.stdout.off("data",c),p.stderr&&p.stderr.off("data",u),p.off("error",m),p.off("close",v),a(void 0)};p.stdout&&p.stdout.on("data",c),p.stderr&&p.stderr.on("data",u),p.on("error",m),p.on("close",v)}),n.stderr.length>0){let a=`Unable to execute request ${s}: ${n.stderr}`;throw l(s,a,i),new Error(a)}if(e==="atvscript")try{return JSON.parse(n.stdout)}catch(a){let r=`Unable to parse result ${s} json: ${a}`;throw l(s,r,i),new Error(r)}return n.stdout})}function g(s={}){let e=[];return s.hosts?e.push("-s",s.hosts.join(",")):s.host&&e.push("-s",s.host),s.id&&e.push("-i",s.id),s.protocol&&e.push("--protocol",s.protocol),s.dmapCredentials&&e.push("--dmap-credentials",s.dmapCredentials),s.mrpCredentials&&e.push("--mrp-credentials",s.mrpCredentials),s.airplayCredentials&&e.push("--airplay-credentials",s.airplayCredentials),s.companionCredentials&&e.push("--companion-credentials",s.companionCredentials),s.raopCredentials&&e.push("--raop-credentials",s.raopCredentials),e}function P(s,e,t,i,n){if(typeof s[t]=="string"){e[i]=s[t];return}n(`No ${i} value found in input (${JSON.stringify(s)})`)}function V(s,e,t){let i=a=>l(e,a,t),n={dateTime:null,hash:null,mediaType:null,deviceState:null,title:null,artist:null,album:null,genre:null,totalTime:null,position:null,shuffle:null,repeat:null,app:null,appId:null,powerState:null,volume:null,focusState:null};if(!s||typeof s!="object")return n;if(s.exception){let a="Got pyatv Error: "+s.exception;throw s.stacktrace&&(a+=`
|
|
2
2
|
|
|
3
3
|
pyatv Stacktrace:
|
|
4
|
-
`+s.stacktrace),new Error(a)}if(typeof s.datetime=="string"){let a=new Date(s.datetime);isNaN(a.getTime())?i(`Invalid datetime value ${s.datetime}, ignore attribute`):n.dateTime=a}else i(`No datetime value found in input (${JSON.stringify(s)})`);return P(s,n,"hash","hash",i),typeof s.media_type=="string"?Object.keys(k).map(r=>String(r)).includes(s.media_type)?n.mediaType=k[s.media_type]:i(`Unsupported mediaType value ${s.media_type}, ignore attribute`):i(`No mediaType value found in input (${JSON.stringify(s)})`),typeof s.device_state=="string"?Object.keys(x).map(r=>String(r)).includes(s.device_state)?n.deviceState=x[s.device_state]:i(`Unsupported deviceState value ${s.device_state}, ignore attribute`):i(`No deviceState value found in input (${JSON.stringify(s)})`),P(s,n,"title","title",i),P(s,n,"artist","artist",i),P(s,n,"album","album",i),P(s,n,"genre","genre",i),typeof s.total_time=="number"?n.totalTime=s.total_time:i(`No totalTime value found in input (${JSON.stringify(s)})`),typeof s.position=="number"?n.position=s.position:i(`No position value found in input (${JSON.stringify(s)})`),typeof s.shuffle=="string"?Object.keys(_).map(r=>String(r)).includes(s.shuffle)?n.shuffle=_[s.shuffle]:i(`Unsupported shuffle value ${s.shuffle}, ignore attribute`):i(`No shuffle value found in input (${JSON.stringify(s)})`),typeof s.repeat=="string"?Object.keys(E).map(r=>String(r)).includes(s.repeat)?n.repeat=E[s.repeat]:i(`Unsupported repeat value ${s.repeat}, ignore attribute`):i(`No repeat value found in input (${JSON.stringify(s)})`),P(s,n,"app","app",i),P(s,n,"app_id","appId",i),typeof s.power_state=="string"?Object.keys(D).map(r=>String(r)).includes(s.power_state)?n.powerState=D[s.power_state]:i(`Unsupported powerState value ${s.power_state}, ignore attribute`):i(`No powerState value found in input (${JSON.stringify(s)})`),typeof s.volume=="number"&&(n.volume=s.volume),typeof s.focus_state=="string"?Object.keys(L).map(r=>String(r)).includes(s.focus_state)?n.focusState=L[s.power_state]:i(`Unsupported focusState value ${s.focus_state}, ignore attribute`):i(`No focusState value found in input (${JSON.stringify(s)})`),n}var b=class extends B{constructor(t,i,n){super();this.state=t,this.device=i,this.options=Object.assign({},n),this.listenerState=0}applyStateAndEmitEvents(t){Object.keys(this.state).forEach(i=>{let n=this.state[i],a=t[i];if(n===void 0||a===void 0||n===a)return;let r=new A({key:i,old:n,new:a,device:this.device});this.state[i]=t[i];try{this.emit("update:"+i,r),this.emit("update",r)}catch(p){this.emit("error",p)}})}parsePushUpdate(t,i){let n;try{n=JSON.parse(i)}catch(a){let r=`Unable to parse stdout json: ${a}`;l(t,r,this.options),this.emit("error",new Error(r));return}this.applyPushUpdate(n,t),this.listenerState===1&&(this.listenerState=2,this.checkListener())}applyPushUpdate(t,i){try{let n=V(t,i,this.options);this.applyStateAndEmitEvents(n)}catch(n){this.emit("error",n)}}checkListener(){if(this.listenerState===0&&this.listenerCount()===0&&this.timeout)clearTimeout(this.timeout),this.timeout=void 0;else if(this.listenerState===0&&this.listenerCount()>0){let t=y();l(t,`Start listeing to events from device ${this.options.name}`,this.options),this.startListening(t),
|
|
5
|
-
`).map(m=>m.trim()).filter(Boolean).forEach(m=>{l(t,`> ${m}`,this.options),this.parsePushUpdate(t,m)})},c=u=>{this.pyatv!==void 0&&(this.listenerState=0,l(t,`Listening with atvscript exited with code ${u}`,this.options),this.timeout!==void 0&&(clearTimeout(this.timeout),this.timeout=void 0),this.pyatv.stdout&&this.pyatv.stdout.off("data",p),this.pyatv.stderr&&this.pyatv.stderr.off("data",r),this.pyatv.off("error",a),this.pyatv.off("close",c),this.listenerCount()>0&&new Date().getTime()-i<3e4?(l(t,`Wait 15s and restart listeing to events from device ${this.options.name}`,this.options),this.timeout=setTimeout(()=>{this.checkListener()},15e3)):this.listenerCount()>0&&(l(t,`Restart listeing to events from device ${this.options.name}`,this.options),this.checkListener()),
|
|
6
|
-
`),yield new Promise(i=>this.timeout=setTimeout(i,250))),this.listenerState===3&&this.pyatv&&this.pyatv.kill(),this.listenerState=0}})}addListener(t,i){return super.addListener(t,i),this.checkListener(),this}on(t,i){return super.on(t,i),this.checkListener(),this}once(t,i){return super.once(t,n=>{i(n),setTimeout(()=>this.checkListener(),0)}),this.checkListener(),this}prependListener(t,i){return super.prependListener(t,i),this.checkListener(),this}off(t,i){return super.off(t,i),this.checkListener(),this}removeAllListeners(t){return super.removeAllListeners(t),this.checkListener(),this}removeListener(t,i){return super.removeListener(t,i),this.checkListener(),this}listenerCount(t){return t!==void 0?super.listenerCount(t):this.eventNames().map(i=>this.listenerCount(i)).reduce((i,n)=>i+n,0)}};var O=class{constructor(e){this.options=Object.assign({},e),this.state=V({},"",{}),this.events=new b(this.state,this,this.options)}get name(){return this.options.name}get host(){return this.options.host}get id(){return this.options.id}get protocol(){return this.options.protocol}get model(){return this.options.model}get modelName(){return this.options.modelName}get os(){return this.options.os}get version(){return this.options.version}get services(){return this.options.services}get debug(){return this.options.debug}set debug(e){typeof e=="function"?this.options.debug=e:this.options.debug=!!e||void 0}toJSON(){return{name:this.name,host:this.host,id:this.id,protocol:this.protocol}}toString(){return`NodePyATVDevice(${this.name}, ${this.host})`}getState(){return o(this,arguments,function*(e={}){var i;if((i=this.state)!=null&&i.dateTime&&new Date().getTime()-this.state.dateTime.getTime()<(e.maxAge||5e3)){let n=null;return this.state.position&&this.state.dateTime&&(n=Math.round(this.state.position+(new Date().getTime()-this.state.dateTime.getTime())/1e3)),Object.assign({},this.state,{position:n})}let t=y();try{let n=g(this.options),a=yield T(t,"atvscript",[...n,"playing"],this.options),r=V(a,t,this.options);return this.applyState(r),r}finally{
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
`+s.stacktrace),new Error(a)}if(typeof s.datetime=="string"){let a=new Date(s.datetime);isNaN(a.getTime())?i(`Invalid datetime value ${s.datetime}, ignore attribute`):n.dateTime=a}else i(`No datetime value found in input (${JSON.stringify(s)})`);return P(s,n,"hash","hash",i),typeof s.media_type=="string"?Object.keys(k).map(r=>String(r)).includes(s.media_type)?n.mediaType=k[s.media_type]:i(`Unsupported mediaType value ${s.media_type}, ignore attribute`):i(`No mediaType value found in input (${JSON.stringify(s)})`),typeof s.device_state=="string"?Object.keys(x).map(r=>String(r)).includes(s.device_state)?n.deviceState=x[s.device_state]:i(`Unsupported deviceState value ${s.device_state}, ignore attribute`):i(`No deviceState value found in input (${JSON.stringify(s)})`),P(s,n,"title","title",i),P(s,n,"artist","artist",i),P(s,n,"album","album",i),P(s,n,"genre","genre",i),typeof s.total_time=="number"?n.totalTime=s.total_time:i(`No totalTime value found in input (${JSON.stringify(s)})`),typeof s.position=="number"?n.position=s.position:i(`No position value found in input (${JSON.stringify(s)})`),typeof s.shuffle=="string"?Object.keys(_).map(r=>String(r)).includes(s.shuffle)?n.shuffle=_[s.shuffle]:i(`Unsupported shuffle value ${s.shuffle}, ignore attribute`):i(`No shuffle value found in input (${JSON.stringify(s)})`),typeof s.repeat=="string"?Object.keys(E).map(r=>String(r)).includes(s.repeat)?n.repeat=E[s.repeat]:i(`Unsupported repeat value ${s.repeat}, ignore attribute`):i(`No repeat value found in input (${JSON.stringify(s)})`),P(s,n,"app","app",i),P(s,n,"app_id","appId",i),typeof s.power_state=="string"?Object.keys(D).map(r=>String(r)).includes(s.power_state)?n.powerState=D[s.power_state]:i(`Unsupported powerState value ${s.power_state}, ignore attribute`):i(`No powerState value found in input (${JSON.stringify(s)})`),typeof s.volume=="number"&&(n.volume=s.volume),typeof s.focus_state=="string"?Object.keys(L).map(r=>String(r)).includes(s.focus_state)?n.focusState=L[s.power_state]:i(`Unsupported focusState value ${s.focus_state}, ignore attribute`):i(`No focusState value found in input (${JSON.stringify(s)})`),n}var b=class extends B{constructor(t,i,n){super();this.state=t,this.device=i,this.options=Object.assign({},n),this.listenerState=0}applyStateAndEmitEvents(t){Object.keys(this.state).forEach(i=>{let n=this.state[i],a=t[i];if(n===void 0||a===void 0||n===a)return;let r=new A({key:i,old:n,new:a,device:this.device});this.state[i]=t[i];try{this.emit("update:"+i,r),this.emit("update",r)}catch(p){this.emit("error",p)}})}parsePushUpdate(t,i){let n;try{n=JSON.parse(i)}catch(a){let r=`Unable to parse stdout json: ${a}`;l(t,r,this.options),this.emit("error",new Error(r));return}this.applyPushUpdate(n,t),this.listenerState===1&&(this.listenerState=2,this.checkListener())}applyPushUpdate(t,i){try{let n=V(t,i,this.options);this.applyStateAndEmitEvents(n)}catch(n){this.emit("error",n)}}checkListener(){if(this.listenerState===0&&this.listenerCount()===0&&this.timeout)clearTimeout(this.timeout),this.timeout=void 0;else if(this.listenerState===0&&this.listenerCount()>0){let t=y();l(t,`Start listeing to events from device ${this.options.name}`,this.options),this.startListening(t),h(t)}else if([1,2].includes(this.listenerState)&&this.listenerCount()===0){let t=y();l(t,`Stop listening to events from device ${this.options.name}`,this.options),this.stopListening(t).catch(i=>l(t,`Unable to stop listeing: ${i}`,this.options)).finally(()=>h(t))}}startListening(t){if(this.listenerState!==0)return;this.listenerState=1;let i=new Date().getTime(),n=g(this.options);if(this.pyatv=I(t,"atvscript",[...n,"push_updates"],this.options),!this.pyatv)throw new Error("Unable to start listener: Unable to start atvscript");let a=u=>{l(t,`Got error from child process: ${u}`,this.options),this.emit("error",u)},r=u=>{let m=new Error(`Got stderr output from pyatv: ${u}`);l(t,u.toString(),this.options),this.emit("error",m)},p=u=>{String(u).split(`
|
|
5
|
+
`).map(m=>m.trim()).filter(Boolean).forEach(m=>{l(t,`> ${m}`,this.options),this.parsePushUpdate(t,m)})},c=u=>{this.pyatv!==void 0&&(this.listenerState=0,l(t,`Listening with atvscript exited with code ${u}`,this.options),this.timeout!==void 0&&(clearTimeout(this.timeout),this.timeout=void 0),this.pyatv.stdout&&this.pyatv.stdout.off("data",p),this.pyatv.stderr&&this.pyatv.stderr.off("data",r),this.pyatv.off("error",a),this.pyatv.off("close",c),this.listenerCount()>0&&new Date().getTime()-i<3e4?(l(t,`Wait 15s and restart listeing to events from device ${this.options.name}`,this.options),this.timeout=setTimeout(()=>{this.checkListener()},15e3)):this.listenerCount()>0&&(l(t,`Restart listeing to events from device ${this.options.name}`,this.options),this.checkListener()),h(t))};this.pyatv.on("error",a),this.pyatv.on("close",c),this.pyatv.stdout&&this.pyatv.stdout.on("data",p),this.pyatv.stderr&&this.pyatv.stderr.on("data",r)}stopListening(t){return o(this,null,function*(){if(!(this.listenerState!==1&&this.listenerState!==2)){if(this.listenerState=3,this.pyatv===void 0)throw new Error("Unable to stop listening due to internal error: state is stopping, but there's no child process. This should never happen, please report this.");this.pyatv.stdin&&(l(t,"Pressing enter to close atvscript\u2026",this.options),this.pyatv.stdin.write(`
|
|
6
|
+
`),yield new Promise(i=>this.timeout=setTimeout(i,250))),this.listenerState===3&&this.pyatv&&this.pyatv.kill(),this.listenerState=0}})}addListener(t,i){return super.addListener(t,i),this.checkListener(),this}on(t,i){return super.on(t,i),this.checkListener(),this}once(t,i){return super.once(t,n=>{i(n),setTimeout(()=>this.checkListener(),0)}),this.checkListener(),this}prependListener(t,i){return super.prependListener(t,i),this.checkListener(),this}off(t,i){return super.off(t,i),this.checkListener(),this}removeAllListeners(t){return super.removeAllListeners(t),this.checkListener(),this}removeListener(t,i){return super.removeListener(t,i),this.checkListener(),this}listenerCount(t){return t!==void 0?super.listenerCount(t):this.eventNames().map(i=>this.listenerCount(i)).reduce((i,n)=>i+n,0)}};var O=class{constructor(e){this.options=Object.assign({},e),this.state=V({},"",{}),this.events=new b(this.state,this,this.options)}get name(){return this.options.name}get host(){return this.options.host}get id(){return this.options.id}get allIDs(){return this.options.allIDs}get protocol(){return this.options.protocol}get mac(){return this.options.mac}get model(){return this.options.model}get modelName(){return this.options.modelName}get os(){return this.options.os}get version(){return this.options.version}get services(){return this.options.services}get debug(){return this.options.debug}set debug(e){typeof e=="function"?this.options.debug=e:this.options.debug=!!e||void 0}toJSON(){return{name:this.name,host:this.host,id:this.id,protocol:this.protocol}}toString(){return`NodePyATVDevice(${this.name}, ${this.host})`}getState(){return o(this,arguments,function*(e={}){var i;if((i=this.state)!=null&&i.dateTime&&new Date().getTime()-this.state.dateTime.getTime()<(e.maxAge||5e3)){let n=null;return this.state.position&&this.state.dateTime&&(n=Math.round(this.state.position+(new Date().getTime()-this.state.dateTime.getTime())/1e3)),Object.assign({},this.state,{position:n})}let t=y();try{let n=g(this.options),a=yield T(t,"atvscript",[...n,"playing"],this.options),r=V(a,t,this.options);return this.applyState(r),r}finally{h(t)}})}clearState(){this.applyState(V({},"",{}))}applyState(e){this.events.applyStateAndEmitEvents(e)}getDateTime(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).dateTime})}getHash(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).hash})}getMediaType(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).mediaType})}getDeviceState(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).deviceState})}getTitle(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).title})}getArtist(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).artist})}getAlbum(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).album})}getGenre(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).genre})}getTotalTime(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).totalTime})}getPosition(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).position})}getShuffle(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).shuffle})}getRepeat(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).repeat})}getApp(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).app})}getAppId(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).appId})}listApps(){return o(this,null,function*(){let e=y(),t=g(this.options),i=yield T(e,"atvremote",[...t,"app_list"],this.options);if(typeof i!="string"||!i.startsWith("App: "))throw new Error("Unexpected atvremote response: "+i);h(e);let n=/(.+) \(([^\)]+)\)$/i;return i.substring(5).split(", App: ").map(r=>{let p=r.match(n);if(p!==null)return{id:p[2],name:p[1],launch:()=>this.launchApp(p[2])}}).filter(Boolean)})}_pressKey(e,t){return o(this,null,function*(){let i=y(),n=g(this.options),a=yield T(i,t,[...n,e],this.options);if(t==="atvscript"&&(typeof a!="object"||a.result!=="success"))throw new Error(`Unable to parse pyatv response: ${JSON.stringify(a,null," ")}`);h(i)})}pressKey(e){return o(this,null,function*(){let t=Object.entries(j).find(([a])=>e===a);if(!t)throw new Error(`Unsupported key value ${e}!`);let i=t[1],n=["turnOn","turnOff"].includes(e)?"atvremote":"atvscript";yield this._pressKey(i,n)})}down(){return o(this,null,function*(){yield this._pressKey("down","atvscript")})}home(){return o(this,null,function*(){yield this._pressKey("home","atvscript")})}homeHold(){return o(this,null,function*(){yield this._pressKey("home_hold","atvscript")})}left(){return o(this,null,function*(){yield this._pressKey("left","atvscript")})}menu(){return o(this,null,function*(){yield this._pressKey("menu","atvscript")})}next(){return o(this,null,function*(){yield this._pressKey("next","atvscript")})}pause(){return o(this,null,function*(){yield this._pressKey("pause","atvscript")})}play(){return o(this,null,function*(){yield this._pressKey("play","atvscript")})}playPause(){return o(this,null,function*(){yield this._pressKey("play_pause","atvscript")})}previous(){return o(this,null,function*(){yield this._pressKey("previous","atvscript")})}right(){return o(this,null,function*(){yield this._pressKey("right","atvscript")})}select(){return o(this,null,function*(){yield this._pressKey("select","atvscript")})}skipBackward(){return o(this,null,function*(){yield this._pressKey("skip_backward","atvscript")})}skipForward(){return o(this,null,function*(){yield this._pressKey("skip_forward","atvscript")})}stop(){return o(this,null,function*(){yield this._pressKey("stop","atvscript")})}suspend(){return o(this,null,function*(){yield this._pressKey("suspend","atvscript")})}topMenu(){return o(this,null,function*(){yield this._pressKey("top_menu","atvscript")})}up(){return o(this,null,function*(){yield this._pressKey("up","atvscript")})}volumeDown(){return o(this,null,function*(){yield this._pressKey("volume_down","atvscript")})}volumeUp(){return o(this,null,function*(){yield this._pressKey("volume_up","atvscript")})}wakeup(){return o(this,null,function*(){yield this._pressKey("wakeup","atvscript")})}turnOff(){return o(this,null,function*(){yield this._pressKey("turn_off","atvremote")})}turnOn(){return o(this,null,function*(){yield this._pressKey("turn_on","atvremote")})}launchApp(e){return o(this,null,function*(){yield this._pressKey("launch_app="+e,"atvremote")})}addListener(e,t){return this.events.addListener(e,t),this}emit(e,t){return this.events.emit(e,t)}eventNames(){return this.events.eventNames()}getMaxListeners(){return this.events.getMaxListeners()}listenerCount(e){return this.events.listenerCount(e)}listeners(e){return this.events.listeners(e)}off(e,t){return this.events.off(e,t),this}on(e,t){return this.events.on(e,t),this}once(e,t){return this.events.once(e,t),this}prependListener(e,t){return this.events.prependListener(e,t),this}prependOnceListener(e,t){return this.events.prependOnceListener(e,t),this}rawListeners(e){return this.events.rawListeners(e)}removeAllListeners(e){return this.events.removeAllListeners(e),this}removeListener(e,t){return this.events.removeListener(e,t),this}setMaxListeners(e){return this.events.setMaxListeners(e),this}};import G from"semver";import{join as H,dirname as W}from"path";import{fileURLToPath as z}from"url";import{promises as Q}from"fs";var X={};var C=class s{constructor(e={}){this.options={};this.options=Object.assign({},e)}static check(){return o(this,arguments,function*(e={}){let t=yield this.version(e);if(!t.pyatv)throw new Error("Unable to find pyatv. Is it installed?");if(G.lt(t.pyatv,"0.6.0"))throw new Error("Found pyatv, but unforunately it's too old. Please update pyatv.");try{yield this.find(e)}catch(i){throw new Error(`Unable to scan for devices: ${String(i).replace("Error: ","")}`)}})}static version(){return o(this,arguments,function*(e={}){let t=y(),i=null,n=null;try{i=yield T(t,"atvremote",["--version"],e)}catch(a){l(t,`Unable to get pyatv version due to ${a}`,e)}i&&i.substr(0,10)==="atvremote "&&(i=i.substr(10)),G.valid(i)||(l(t,`String "${i}" is not a valid pyatv version, set it to null`,e),i=null);try{let a=H(W(z(X.url)),"..","..","package.json"),r=JSON.parse(yield Q.readFile(a,"utf8"));n=(r==null?void 0:r.version)||null}catch(a){l(t,`Unable to get module version due to ${a}`,e)}return n&&!G.valid(n)&&(l(t,`String "${n}" is not a valid module version, set it to null`,e),n=null),h(t),{pyatv:i,module:n}})}static find(){return o(this,arguments,function*(e={}){let t=y(),i=g(e),n=yield T(t,"atvscript",[...i,"scan"],e);if(typeof n!="object"||n.result!=="success"||!Array.isArray(n.devices))throw new Error(`Unable to parse pyatv response: ${JSON.stringify(n,null," ")}`);let a=n.devices.map(r=>{var p,c,u,m,v;return this.device(Object.assign({},e,{host:r.address,id:r.identifier,allIDs:r.all_identifiers,name:r.name,mac:(p=r.device_info)==null?void 0:p.mac,model:(c=r.device_info)==null?void 0:c.model,modelName:(u=r.device_info)==null?void 0:u.model_str,os:(m=r.device_info)==null?void 0:m.operating_system,version:(v=r.device_info)==null?void 0:v.version,services:r.services}))});return h(t),a})}static device(e){return new O(e)}check(){return o(this,arguments,function*(e={}){return s.check(Object.assign({},this.options,e))})}version(){return o(this,arguments,function*(e={}){return s.version(Object.assign({},this.options,e))})}find(){return o(this,arguments,function*(e={}){return s.find(Object.assign({},this.options,e))})}device(e){return s.device(Object.assign({},this.options,e))}};export{o as a,N as b,R as c,k as d,x as e,E as f,_ as g,D as h,U as i,F as j,A as k,b as l,O as m,C as n};
|
|
7
|
+
//# sourceMappingURL=chunk-D57T7NS2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/types.ts","../src/lib/device-event.ts","../src/lib/device-events.ts","../src/lib/tools.ts","../src/lib/device.ts","../src/lib/instance.ts"],"sourcesContent":["import {ChildProcess, SpawnOptions} from 'child_process';\nimport {FakeChildProcess} from './fake-spawn.js';\n\nexport enum NodePyATVExecutableType {\n atvremote = 'atvremote',\n atvscript = 'atvscript',\n}\n\nexport enum NodePyATVProtocol {\n dmap = 'dmap',\n mrp = 'mrp',\n airplay = 'airplay',\n mdns = 'mdns',\n}\n\nexport enum NodePyATVMediaType {\n music = 'music',\n tv = 'tv',\n video = 'video',\n unknown = 'unknown'\n}\n\nexport enum NodePyATVDeviceState {\n idle = 'idle',\n loading = 'loading',\n paused = 'paused',\n playing = 'playing',\n seeking = 'seeking',\n stopped = 'stopped'\n}\n\nexport enum NodePyATVRepeatState {\n all = 'all',\n track = 'track',\n off = 'off'\n}\n\nexport enum NodePyATVShuffleState {\n albums = 'albums',\n songs = 'songs',\n off = 'off'\n}\n\nexport enum NodePyATVPowerState {\n on = 'on',\n off = 'off'\n}\n\nexport enum NodePyATVFocusState {\n focued = 'focused',\n unfocused = 'unfocused'\n}\n\nexport enum NodePyATVKeys {\n down = 'down',\n home = 'home',\n homeHold = 'homeHold',\n left = 'left',\n menu = 'menu',\n next = 'next',\n pause = 'pause',\n play = 'play',\n playPause = 'playPause',\n previous = 'previous',\n right = 'right',\n select = 'select',\n skipBackward = 'skipBackward',\n skipForward = 'skipForward',\n stop = 'stop',\n suspend = 'suspend',\n topMenu = 'topMenu',\n up = 'up',\n volumeDown = 'volumeDown',\n volumeUp = 'volumeUp',\n wakeup = 'wakeup',\n turnOff = 'turnOff',\n turnOn = 'turnOn'\n}\n\n/**\n * @internal\n */\nexport enum NodePyATVInternalKeys {\n down = 'down',\n home = 'home',\n homeHold = 'home_hold',\n left = 'left',\n menu = 'menu',\n next = 'next',\n pause = 'pause',\n play = 'play',\n playPause = 'play_pause',\n previous = 'previous',\n right = 'right',\n select = 'select',\n skipBackward = 'skip_backward',\n skipForward = 'skip_forward',\n stop = 'stop',\n suspend = 'suspend',\n topMenu = 'top_menu',\n up = 'up',\n volumeDown = 'volume_down',\n volumeUp = 'volume_up',\n wakeup = 'wakeup',\n turnOff = 'turn_off',\n turnOn = 'turn_on'\n}\n\nexport enum NodePyATVListenerState {\n stopped,\n starting,\n started,\n stopping\n}\n\n\nexport type NodePyATVStateIndex = keyof NodePyATVState;\n\nexport type NodePyATVEventValueType = (string | number | NodePyATVMediaType | NodePyATVDeviceState |\n NodePyATVShuffleState | NodePyATVRepeatState);\n\n\nexport interface NodePyATVInstanceOptions {\n atvremotePath?: string;\n atvscriptPath?: string;\n debug?: true | ((msg: string) => void);\n noColors?: true;\n spawn?: (command: string, args: Array<string>, options: SpawnOptions) => (ChildProcess | FakeChildProcess);\n}\n\nexport interface NodePyATVVersionResponse {\n pyatv: string | null;\n module: string | null;\n}\n\nexport interface NodePyATVFindOptions {\n host?: string;\n hosts?: string[];\n id?: string;\n protocol?: NodePyATVProtocol;\n dmapCredentials?: string;\n mrpCredentials?: string;\n airplayCredentials?: string;\n companionCredentials?: string;\n raopCredentials?: string;\n}\n\nexport interface NodePyATVFindAndInstanceOptions extends NodePyATVInstanceOptions, NodePyATVFindOptions {\n\n}\n\nexport interface NodePyATVDeviceOptions extends NodePyATVFindAndInstanceOptions {\n host: string;\n name: string;\n mac?: string;\n model?: string;\n modelName?: string;\n os?: string;\n version?: string;\n services?: NodePyATVService[];\n allIDs?: string[];\n}\n\nexport interface NodePyATVGetStateOptions {\n maxAge?: number;\n}\n\nexport interface NodePyATVService {\n protocol: NodePyATVProtocol;\n port: number;\n}\n\n/**\n * @internal\n */\nexport interface NodePyATVInternalScanDevice {\n name: string;\n address: string;\n identifier: string;\n all_identifiers: string[];\n device_info?: {\n mac: string | null;\n model: string;\n model_str: string;\n operating_system: string;\n version: string;\n };\n services?: NodePyATVService[];\n}\n\n/**\n * @internal\n */\nexport interface NodePyATVInternalState {\n result?: string | unknown;\n datetime?: string | unknown;\n hash?: string | unknown;\n media_type?: string | unknown;\n device_state?: string | unknown;\n title?: string | unknown;\n artist?: string | unknown;\n album?: string | unknown;\n genre?: string | unknown;\n total_time?: number | unknown;\n position?: 1 | unknown;\n shuffle?: string | unknown;\n repeat?: string | unknown;\n app?: string | unknown;\n app_id?: string | unknown;\n power_state?: string | unknown;\n push_updates?: string | unknown;\n exception?: string | unknown;\n stacktrace?: string | unknown;\n connection?: string | unknown;\n volume?: number | unknown;\n focus_state?: string | unknown;\n}\n\nexport interface NodePyATVState {\n dateTime: Date | null;\n hash: string | null;\n mediaType: NodePyATVMediaType | null;\n deviceState: NodePyATVDeviceState | null;\n title: string | null;\n artist: string | null;\n album: string | null;\n genre: string | null;\n totalTime: number | null;\n position: number | null;\n shuffle: NodePyATVShuffleState | null;\n repeat: NodePyATVRepeatState | null;\n app: string | null;\n appId: string | null;\n powerState: NodePyATVPowerState | null;\n volume: number | null;\n focusState: NodePyATVFocusState | null;\n}\n\nexport interface NodePyATVApp {\n id: string;\n name: string;\n launch: () => Promise<void>;\n}\n","'use strict';\n\nimport {NodePyATVDevice} from '../lib/index.js';\nimport type {NodePyATVEventValueType, NodePyATVStateIndex} from './types.js';\n\nexport default class NodePyATVDeviceEvent {\n protected readonly values: {key: NodePyATVStateIndex, old: NodePyATVEventValueType, new: NodePyATVEventValueType, device: NodePyATVDevice};\n\n /**\n *\n * @param values\n * @internal\n */\n constructor(values: {key: NodePyATVStateIndex, old: NodePyATVEventValueType, new: NodePyATVEventValueType, device: NodePyATVDevice}) {\n this.values = Object.assign({}, values, {\n key: values.key as NodePyATVStateIndex\n });\n }\n\n /**\n * References the attribute name which was changed. So if the\n * title has been updated, this would be `title`.\n */\n get key(): NodePyATVStateIndex {\n return this.values.key;\n }\n\n /**\n * Holds the old value which was there\n * before the value was changed.\n */\n get oldValue(): NodePyATVEventValueType {\n return this.values.old;\n }\n\n /**\n * @alias value\n */\n get newValue(): NodePyATVEventValueType {\n return this.values.new;\n }\n\n /**\n * New, current value for `key`\n */\n get value(): NodePyATVEventValueType {\n return this.values.new;\n }\n\n /**\n * References the device instance this\n * event originates from\n */\n get device(): NodePyATVDevice {\n return this.values.device;\n }\n}\n","'use strict';\n\nimport {\n NodePyATVDeviceOptions,\n NodePyATVExecutableType,\n NodePyATVInternalState,\n NodePyATVListenerState,\n NodePyATVState,\n NodePyATVStateIndex\n} from './types.js';\nimport {ChildProcess} from 'child_process';\n\nimport {EventEmitter} from 'events';\nimport {NodePyATVDevice, NodePyATVDeviceEvent} from '../lib/index.js';\nimport {addRequestId, debug, execute, getParamters, parseState, removeRequestId} from './tools.js';\nimport {FakeChildProcess} from './fake-spawn.js';\n\n/**\n * @internal\n */\nexport default class NodePyATVDeviceEvents extends EventEmitter {\n private readonly options: NodePyATVDeviceOptions;\n private readonly state: NodePyATVState;\n private readonly device: NodePyATVDevice;\n private pyatv: ChildProcess | FakeChildProcess | undefined;\n private timeout: NodeJS.Timeout | undefined;\n private listenerState: NodePyATVListenerState;\n\n constructor(state: NodePyATVState, device: NodePyATVDevice, options: NodePyATVDeviceOptions) {\n super();\n\n this.state = state;\n this.device = device;\n this.options = Object.assign({}, options);\n this.listenerState = NodePyATVListenerState.stopped;\n }\n\n applyStateAndEmitEvents(newState: NodePyATVState): void {\n Object.keys(this.state).forEach((key: string) => {\n\n // @ts-ignore\n const oldValue = this.state[key];\n\n // @ts-ignore\n const newValue = newState[key];\n\n if(oldValue === undefined || newValue === undefined || oldValue === newValue) {\n return;\n }\n\n const event = new NodePyATVDeviceEvent({\n key: key as NodePyATVStateIndex,\n old: oldValue,\n new: newValue,\n device: this.device\n });\n\n // @ts-ignore\n this.state[key] = newState[key];\n\n try {\n this.emit('update:' + key, event);\n this.emit('update', event);\n }\n catch(error) {\n this.emit('error', error);\n }\n });\n }\n\n private parsePushUpdate(reqId: string, data: string): void {\n let json: NodePyATVInternalState;\n\n try {\n json = JSON.parse(data);\n }\n catch(error) {\n const msg = `Unable to parse stdout json: ${error}`;\n debug(reqId, msg, this.options);\n this.emit('error', new Error(msg));\n return;\n }\n\n this.applyPushUpdate(json, reqId);\n\n if(this.listenerState === NodePyATVListenerState.starting) {\n this.listenerState = NodePyATVListenerState.started;\n this.checkListener();\n }\n }\n\n private applyPushUpdate(update: NodePyATVInternalState, reqId: string): void {\n try {\n const newState = parseState(update, reqId, this.options);\n this.applyStateAndEmitEvents(newState);\n }\n catch(error) {\n this.emit('error', error);\n }\n }\n\n private checkListener(): void {\n if(this.listenerState === NodePyATVListenerState.stopped && this.listenerCount() === 0 && this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = undefined;\n }\n else if(this.listenerState === NodePyATVListenerState.stopped && this.listenerCount() > 0) {\n const id = addRequestId();\n debug(id, `Start listeing to events from device ${this.options.name}`, this.options);\n\n this.startListening(id);\n removeRequestId(id);\n }\n else if(\n [NodePyATVListenerState.starting, NodePyATVListenerState.started].includes(this.listenerState) &&\n this.listenerCount() === 0\n ) {\n const id = addRequestId();\n debug(id, `Stop listening to events from device ${this.options.name}`, this.options);\n\n this.stopListening(id)\n .catch(error => debug(id, `Unable to stop listeing: ${error}`, this.options))\n .finally(() => removeRequestId(id));\n }\n }\n\n private startListening(reqId: string): void {\n if(this.listenerState !== NodePyATVListenerState.stopped) {\n return;\n }\n\n this.listenerState = NodePyATVListenerState.starting;\n\n const listenStart = new Date().getTime();\n const parameters = getParamters(this.options);\n this.pyatv = execute(reqId, NodePyATVExecutableType.atvscript, [...parameters, 'push_updates'], this.options);\n if(!this.pyatv) {\n throw new Error('Unable to start listener: Unable to start atvscript');\n }\n\n const onError = (error: Error) => {\n debug(reqId, `Got error from child process: ${error}`, this.options);\n this.emit('error', error);\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const onStdErr = (data: any) => {\n const error = new Error(`Got stderr output from pyatv: ${data}`);\n debug(reqId, data.toString(), this.options);\n this.emit('error', error);\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const onStdOut = (data: any) => {\n String(data)\n .split('\\n')\n .map(s => s.trim())\n .filter(Boolean)\n .forEach(s => {\n debug(reqId, `> ${s}`, this.options);\n this.parsePushUpdate(reqId, s);\n });\n };\n const onClose = (code: number) => {\n if(this.pyatv === undefined) {\n // this should never happen… :/\n return;\n }\n\n this.listenerState = NodePyATVListenerState.stopped;\n debug(reqId, `Listening with atvscript exited with code ${code}`, this.options);\n if(this.timeout !== undefined) {\n clearTimeout(this.timeout);\n this.timeout = undefined;\n }\n\n if (this.pyatv.stdout) {\n this.pyatv.stdout.off('data', onStdOut);\n }\n if (this.pyatv.stderr) {\n this.pyatv.stderr.off('data', onStdErr);\n }\n this.pyatv.off('error', onError);\n this.pyatv.off('close', onClose);\n\n\n if(this.listenerCount() > 0 && new Date().getTime() - listenStart < 30000) {\n debug(reqId, `Wait 15s and restart listeing to events from device ${this.options.name}`, this.options);\n\n this.timeout = setTimeout(() => {\n this.checkListener();\n }, 15000);\n }\n else if(this.listenerCount() > 0) {\n debug(reqId, `Restart listeing to events from device ${this.options.name}`, this.options);\n this.checkListener();\n }\n\n removeRequestId(reqId);\n };\n\n this.pyatv.on('error', onError);\n this.pyatv.on('close', onClose);\n\n if (this.pyatv.stdout) {\n this.pyatv.stdout.on('data', onStdOut);\n }\n if (this.pyatv.stderr) {\n this.pyatv.stderr.on('data', onStdErr);\n }\n }\n\n protected async stopListening(reqId: string): Promise<void> {\n if(\n this.listenerState !== NodePyATVListenerState.starting &&\n this.listenerState !== NodePyATVListenerState.started\n ) {\n return;\n }\n\n this.listenerState = NodePyATVListenerState.stopping;\n if(this.pyatv === undefined) {\n throw new Error(\n 'Unable to stop listening due to internal error: state is stopping, but there\\'s no child process. ' +\n 'This should never happen, please report this.'\n );\n }\n\n if(this.pyatv.stdin) {\n debug(reqId, 'Pressing enter to close atvscript…', this.options);\n this.pyatv.stdin.write('\\n');\n\n await new Promise(cb => this.timeout = setTimeout(cb, 250));\n }\n\n if(this.listenerState === NodePyATVListenerState.stopping && this.pyatv) {\n this.pyatv.kill();\n }\n\n this.listenerState = NodePyATVListenerState.stopped;\n return;\n }\n\n addListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this {\n super.addListener(event, listener);\n this.checkListener();\n return this;\n }\n\n on(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this {\n super.on(event, listener);\n this.checkListener();\n return this;\n }\n\n once(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this {\n super.once(event, (event: NodePyATVDeviceEvent) => {\n listener(event);\n setTimeout(() => this.checkListener(), 0);\n });\n this.checkListener();\n return this;\n }\n\n prependListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this {\n super.prependListener(event, listener);\n this.checkListener();\n return this;\n }\n\n off(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this {\n super.off(event, listener);\n this.checkListener();\n return this;\n }\n\n removeAllListeners(event?: string | symbol): this {\n super.removeAllListeners(event);\n this.checkListener();\n return this;\n }\n\n removeListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this {\n super.removeListener(event, listener);\n this.checkListener();\n return this;\n }\n\n listenerCount(event?: string | symbol): number {\n if(event !== undefined) {\n return super.listenerCount(event);\n }\n\n return this.eventNames()\n .map(event => this.listenerCount(event))\n .reduce((a, b) => a + b, 0);\n }\n}\n","'use strict';\n\nimport {\n NodePyATVDeviceState,\n NodePyATVExecutableType,\n NodePyATVFindAndInstanceOptions,\n NodePyATVFocusState,\n NodePyATVInstanceOptions,\n NodePyATVInternalState,\n NodePyATVMediaType,\n NodePyATVPowerState,\n NodePyATVRepeatState,\n NodePyATVShuffleState,\n NodePyATVState\n} from './types.js';\n\nimport {ChildProcess, spawn, SpawnOptions} from 'child_process';\nimport {FakeChildProcess} from './fake-spawn.js';\n\nconst requestIds: string[] = [];\n\nexport function addRequestId(): string {\n let id = '?';\n\n for (let i = 0; i < 1000; i += 1) {\n id = Math.round(Math.random() * (i + 6) * 36).toString(36).toUpperCase();\n if (!requestIds.includes(id)) {\n requestIds.push(id);\n break;\n }\n }\n\n return id;\n}\n\nexport function removeRequestId(id: string | undefined): void {\n if (id && requestIds.includes(id)) {\n requestIds.splice(requestIds.indexOf(id), 1);\n }\n}\n\nexport function debug(id: string, message: string, options: NodePyATVInstanceOptions): void {\n if (options.debug) {\n const log = typeof options.debug === 'function' ? options.debug : console.log;\n const enableColors = !process.env.NO_COLOR && !options.noColors;\n\n const parts = [\n enableColors ? '\\x1b[0m' : '', // Color Reset\n enableColors ? '\\x1b[90m' : '', // Grey\n '[node-pyatv][',\n enableColors ? '\\x1b[37m' : '', // Light Grey\n id,\n enableColors ? '\\x1b[90m' : '', // Grey\n '] ',\n enableColors ? '\\x1b[0m' : '', // Color Reset\n message\n ];\n\n log.apply(null, [parts.join('')]);\n }\n}\n\nexport function getExecutable(executable: NodePyATVExecutableType, options: NodePyATVInstanceOptions): string {\n if (executable === NodePyATVExecutableType.atvremote && typeof options.atvremotePath === 'string') {\n return options.atvremotePath;\n }\n else if (executable === NodePyATVExecutableType.atvscript && typeof options.atvscriptPath === 'string') {\n return options.atvscriptPath;\n }\n else {\n return executable;\n }\n}\n\nexport function execute(\n requestId: string,\n executableType: NodePyATVExecutableType,\n parameters: string[],\n options: NodePyATVInstanceOptions\n): ChildProcess | FakeChildProcess {\n const executable = getExecutable(executableType, options);\n const mySpawn: ((command: string, args: Array<string>, options: SpawnOptions) => (ChildProcess | FakeChildProcess)) = typeof options.spawn === 'function' ? options.spawn : spawn;\n\n debug(requestId, `${executable} ${parameters.join(' ')}`, options);\n const child = mySpawn(executable, parameters, {\n env: process.env\n });\n\n /* eslint-disable @typescript-eslint/no-explicit-any*/\n const onStdOut = (data: any) => debug(requestId, `stdout: ${String(data).trim()}`, options);\n const onStdErr = (data: any) => debug(requestId, `stderr: ${String(data).trim()}`, options);\n const onError = (data: any) => debug(requestId, `error: ${String(data).trim()}`, options);\n /* eslint-enable @typescript-eslint/no-explicit-any*/\n\n const onClose = (code: number) => {\n debug(requestId, `${executable} exited with code: ${code}`, options);\n\n if (child.stdout) {\n child.stdout.off('data', onStdOut);\n }\n if (child.stderr) {\n child.stderr.off('data', onStdErr);\n }\n\n child.off('error', onError);\n child.off('close', onClose);\n };\n\n if (child.stdout) {\n child.stdout.on('data', onStdOut);\n }\n if (child.stderr) {\n child.stderr.on('data', onStdErr);\n }\n\n child.on('error', onError);\n child.on('close', onClose);\n\n return child;\n}\n\nexport async function request(\n requestId: string,\n executableType: NodePyATVExecutableType,\n parameters: string[],\n options: NodePyATVInstanceOptions\n): Promise<string|Record<string,unknown>> {\n const result = {\n stdout: '',\n stderr: '',\n code: 0\n };\n\n await new Promise((resolve, reject) => {\n const pyatv = execute(requestId, executableType, parameters, options);\n\n /* eslint-disable @typescript-eslint/no-explicit-any*/\n const onStdOut = (data: any) => result.stdout += String(data).trim();\n const onStdErr = (data: any) => result.stderr += String(data).trim();\n const onError = (data: any) => reject(data instanceof Error ? data : new Error(String(data)));\n /* eslint-enable @typescript-eslint/no-explicit-any*/\n\n const onClose: (code: number) => void = (code: number) => {\n result.code = code;\n\n if (pyatv.stdout) {\n pyatv.stdout.off('data', onStdOut);\n }\n if (pyatv.stderr) {\n pyatv.stderr.off('data', onStdErr);\n }\n\n pyatv.off('error', onError);\n pyatv.off('close', onClose);\n resolve(undefined);\n };\n\n if (pyatv.stdout) {\n pyatv.stdout.on('data', onStdOut);\n }\n if (pyatv.stderr) {\n pyatv.stderr.on('data', onStdErr);\n }\n\n pyatv.on('error', onError);\n pyatv.on('close', onClose);\n });\n\n if (result.stderr.length > 0) {\n const msg = `Unable to execute request ${requestId}: ${result.stderr}`;\n debug(requestId, msg, options);\n throw new Error(msg);\n }\n if (executableType === NodePyATVExecutableType.atvscript) {\n try {\n return JSON.parse(result.stdout);\n }\n catch (error) {\n const msg = `Unable to parse result ${requestId} json: ${error}`;\n debug(requestId, msg, options);\n throw new Error(msg);\n }\n }\n\n return result.stdout;\n}\n\nexport function getParamters(options: NodePyATVFindAndInstanceOptions = {}): string[] {\n const parameters: string[] = [];\n\n if (options.hosts) {\n parameters.push('-s', options.hosts.join(','));\n }\n else if (options.host) {\n parameters.push('-s', options.host);\n }\n if (options.id) {\n parameters.push('-i', options.id);\n }\n if (options.protocol) {\n parameters.push('--protocol', options.protocol);\n }\n if (options.dmapCredentials) {\n parameters.push('--dmap-credentials', options.dmapCredentials);\n }\n if (options.mrpCredentials) {\n parameters.push('--mrp-credentials', options.mrpCredentials);\n }\n if (options.airplayCredentials) {\n parameters.push('--airplay-credentials', options.airplayCredentials);\n }\n if (options.companionCredentials) {\n parameters.push('--companion-credentials', options.companionCredentials);\n }\n if (options.raopCredentials) {\n parameters.push('--raop-credentials', options.raopCredentials);\n }\n\n return parameters;\n}\n\nfunction parseStateStringAttr(\n input: NodePyATVInternalState,\n output: NodePyATVState,\n inputAttr: ('hash' | 'title' | 'album' | 'artist' | 'genre' | 'app' | 'app_id'),\n outputAttr: ('hash' | 'title' | 'album' | 'artist' | 'genre' | 'app' | 'appId'),\n d: (msg: string) => void\n): void {\n if (typeof input[inputAttr] === 'string') {\n output[outputAttr] = input[inputAttr] as string;\n return;\n }\n\n d(`No ${outputAttr} value found in input (${JSON.stringify(input)})`);\n}\n\nexport function parseState(input: NodePyATVInternalState, id: string, options: NodePyATVInstanceOptions): NodePyATVState {\n const d = (msg: string) => debug(id, msg, options);\n const result: NodePyATVState = {\n dateTime: null,\n hash: null,\n mediaType: null,\n deviceState: null,\n title: null,\n artist: null,\n album: null,\n genre: null,\n totalTime: null,\n position: null,\n shuffle: null,\n repeat: null,\n app: null,\n appId: null,\n powerState: null,\n volume: null,\n focusState: null\n };\n if (!input || typeof input !== 'object') {\n return result;\n }\n if(input.exception) {\n let errorStr = 'Got pyatv Error: ' + input.exception;\n if(input.stacktrace) {\n errorStr += '\\n\\npyatv Stacktrace:\\n' + input.stacktrace;\n }\n\n throw new Error(errorStr);\n }\n\n // datetime\n if (typeof input.datetime === 'string') {\n const date = new Date(input.datetime);\n if (!isNaN(date.getTime())) {\n result.dateTime = date;\n }\n else {\n d(`Invalid datetime value ${input.datetime}, ignore attribute`);\n }\n }\n else {\n d(`No datetime value found in input (${JSON.stringify(input)})`);\n }\n\n // hash\n parseStateStringAttr(input, result, 'hash', 'hash', d);\n\n // mediaType\n if(typeof input.media_type === 'string') {\n const validValues = Object.keys(NodePyATVMediaType).map(o => String(o));\n if (validValues.includes(input.media_type)) {\n result.mediaType = NodePyATVMediaType[input.media_type as NodePyATVMediaType];\n }\n else {\n d(`Unsupported mediaType value ${input.media_type}, ignore attribute`);\n }\n } else {\n d(`No mediaType value found in input (${JSON.stringify(input)})`);\n }\n\n // deviceState\n if(typeof input.device_state === 'string') {\n const validValues = Object.keys(NodePyATVDeviceState).map(o => String(o));\n if (validValues.includes(input.device_state)) {\n result.deviceState = NodePyATVDeviceState[input.device_state as NodePyATVDeviceState];\n }\n else {\n d(`Unsupported deviceState value ${input.device_state}, ignore attribute`);\n }\n } else {\n d(`No deviceState value found in input (${JSON.stringify(input)})`);\n }\n\n // title\n parseStateStringAttr(input, result, 'title', 'title', d);\n\n // artist\n parseStateStringAttr(input, result, 'artist', 'artist', d);\n\n // album\n parseStateStringAttr(input, result, 'album', 'album', d);\n\n // genre\n parseStateStringAttr(input, result, 'genre', 'genre', d);\n\n // totalTime\n if (typeof input.total_time === 'number') {\n result.totalTime = input.total_time;\n }\n else {\n d(`No totalTime value found in input (${JSON.stringify(input)})`);\n }\n\n // position\n if (typeof input.position === 'number') {\n result.position = input.position;\n }\n else {\n d(`No position value found in input (${JSON.stringify(input)})`);\n }\n\n // shuffle\n if(typeof input.shuffle === 'string') {\n const validValues = Object.keys(NodePyATVShuffleState).map(o => String(o));\n if (validValues.includes(input.shuffle)) {\n result.shuffle = NodePyATVShuffleState[input.shuffle as NodePyATVShuffleState];\n }\n else {\n d(`Unsupported shuffle value ${input.shuffle}, ignore attribute`);\n }\n } else {\n d(`No shuffle value found in input (${JSON.stringify(input)})`);\n }\n\n // repeat\n if(typeof input.repeat === 'string') {\n const validValues = Object.keys(NodePyATVRepeatState).map(o => String(o));\n if (validValues.includes(input.repeat)) {\n result.repeat = NodePyATVRepeatState[input.repeat as NodePyATVRepeatState];\n }\n else {\n d(`Unsupported repeat value ${input.repeat}, ignore attribute`);\n }\n } else {\n d(`No repeat value found in input (${JSON.stringify(input)})`);\n }\n\n // app\n parseStateStringAttr(input, result, 'app', 'app', d);\n parseStateStringAttr(input, result, 'app_id', 'appId', d);\n\n // powerState\n if(typeof input.power_state === 'string') {\n const validValues = Object.keys(NodePyATVPowerState).map(o => String(o));\n if (validValues.includes(input.power_state)) {\n result.powerState = NodePyATVPowerState[input.power_state as NodePyATVPowerState];\n }\n else {\n d(`Unsupported powerState value ${input.power_state}, ignore attribute`);\n }\n } else {\n d(`No powerState value found in input (${JSON.stringify(input)})`);\n }\n\n // volume\n if (typeof input.volume === 'number') {\n result.volume = input.volume;\n }\n\n // focusState\n if(typeof input.focus_state === 'string') {\n const validValues = Object.keys(NodePyATVFocusState).map(o => String(o));\n if (validValues.includes(input.focus_state)) {\n result.focusState = NodePyATVFocusState[input.power_state as NodePyATVFocusState];\n }\n else {\n d(`Unsupported focusState value ${input.focus_state}, ignore attribute`);\n }\n } else {\n d(`No focusState value found in input (${JSON.stringify(input)})`);\n }\n\n return result;\n}\n","'use strict';\n\nimport {\n NodePyATVApp,\n NodePyATVDeviceOptions,\n NodePyATVDeviceState,\n NodePyATVExecutableType,\n NodePyATVGetStateOptions,\n NodePyATVInternalKeys,\n NodePyATVKeys,\n NodePyATVMediaType,\n NodePyATVProtocol,\n NodePyATVRepeatState,\n NodePyATVService,\n NodePyATVShuffleState,\n NodePyATVState\n} from './types.js';\n\nimport { addRequestId, getParamters, parseState, removeRequestId, request } from './tools.js';\nimport { NodePyATVDeviceEvent, NodePyATVDeviceEvents } from '../lib/index.js';\nimport { EventEmitter } from 'events';\n\n/**\n * Represents an Apple TV. Use [[getState]] to query the current state (e.g. media\n * type and title). You can also use the attribute methods (e.g. [[getTitle]] to get\n * the state. If you want realtime updates, subscribe to it's events with an\n * `EventEmitter` like API, so for example by using [[on]], [[once]] or [[addListener]].\n * It's also possible to send key commands by using [[pressKey]] or methods like [[pause]].\n */\nexport default class NodePyATVDevice implements EventEmitter{\n private readonly options: NodePyATVDeviceOptions;\n private readonly state: NodePyATVState;\n private readonly events: NodePyATVDeviceEvents;\n\n constructor(options: NodePyATVDeviceOptions) {\n this.options = Object.assign({}, options);\n this.state = parseState({}, '', {});\n this.events = new NodePyATVDeviceEvents(this.state, this, this.options);\n\n // @todo basic validation\n }\n\n /**\n * Get the name of the Apple TV.\n *\n * ```typescript\n * import pyatv from '@sebbo2002/node-pyatv';\n * const devices = await pyatv.find();\n * devices.forEach(device =>\n * console.log(device.name)\n * );\n * ```\n */\n get name(): string {\n return this.options.name;\n }\n\n /**\n * Get the IP address of the Apple TV.\n */\n get host(): string {\n return this.options.host;\n }\n\n /**\n * Get the ID of the Apple TV.\n */\n get id(): string | undefined {\n return this.options.id;\n }\n\n /**\n * Get all IDs of the Apple TV.\n */\n get allIDs(): string[] | undefined {\n return this.options.allIDs;\n }\n\n /**\n * Get the used protocol to connect to the Apple TV.\n */\n get protocol(): NodePyATVProtocol | undefined {\n return this.options.protocol;\n }\n\n /**\n * Get the MAC address of the Apple TV.\n */\n get mac(): string | undefined {\n return this.options.mac;\n }\n\n /**\n * Get the model identifier of the device. Only set, if the\n * device was found using [[find()]]. Requires pyatv ≧ 0.10.3.\n *\n * @example device.model → \"Gen4K\"\n */\n get model(): string | undefined {\n return this.options.model;\n }\n\n /**\n * Get the model name of the device. Only set, if the device\n * was found with [[find()]]. Requires pyatv ≧ 0.10.3.\n *\n * @example device.modelName → \"Apple TV 4K\"\n */\n get modelName(): string | undefined {\n return this.options.modelName;\n }\n\n /**\n * Get the operating system of the device. Only set, if the\n * device was found with [[find()]]. Requires pyatv ≧ 0.10.3.\n *\n * @example device.os → \"TvOS\"\n */\n get os(): string | undefined {\n return this.options.os;\n }\n\n /**\n * Get the device version. Only set, if the device was found\n * during a scan using [[find()]]. Requires pyatv ≧ 0.10.3.\n *\n * @example device.version → \"15.5.1\"\n */\n get version(): string | undefined {\n return this.options.version;\n }\n\n /**\n * Returns a list of services supported by the device. Ony set, if\n * the device was found during a scan using [[find()]]. Requires\n * pyatv ≧ 0.10.3.\n *\n * @example device.services → [\n * {\n * \"protocol\": \"airplay\",\n * \"port\": 7000\n * },\n * {\n * \"protocol\": \"dmap\",\n * \"port\": 3689\n * }\n * ]\n */\n get services(): NodePyATVService[] | undefined {\n return this.options.services;\n }\n\n\n /**\n * Returns true, if debugging is enabled. Returns the custom\n * logging method, if one was specified. Otherwise, if debug\n * log is disabled, returns undefined.\n */\n get debug(): true | ((msg: string) => void) | undefined {\n return this.options.debug;\n }\n\n /**\n * Enable or disable debugging or set a custom\n * debugging method to use.\n *\n * @param debug\n */\n set debug(debug: true | ((msg: string) => void) | undefined) {\n if (typeof debug === 'function') {\n this.options.debug = debug;\n }\n else {\n this.options.debug = Boolean(debug) || undefined;\n }\n }\n\n /**\n * Returns an object with `name`, `host`, `id` and `protocol`.\n * Can be used to initiate a new device instance.\n *\n * @category Basic\n */\n toJSON(): { name: string; host: string; id: string | undefined; protocol: NodePyATVProtocol | undefined } {\n return {\n name: this.name,\n host: this.host,\n id: this.id,\n protocol: this.protocol\n };\n }\n\n /**\n * Returns a string. Just for debugging, etc.\n *\n * @category Basic\n */\n toString(): string {\n return `NodePyATVDevice(${this.name}, ${this.host})`;\n }\n\n /**\n * Returns an [[NodePyATVState]] object representing the current state\n * of the device. Has an internal cache, which has a default TTL of 5s.\n * You can change this default value by passing the `maxAge` option.\n *\n * ```typescript\n * await device.getState({maxAge: 10000}); // cache TTL: 10s\n * ```\n *\n * @param options\n * @category State\n */\n async getState(options: NodePyATVGetStateOptions = {}): Promise<NodePyATVState> {\n if (this.state?.dateTime && new Date().getTime() - this.state.dateTime.getTime() < (options.maxAge || 5000)) {\n let position = null;\n if (this.state.position && this.state.dateTime) {\n position = Math.round(\n this.state.position +\n ((new Date().getTime() - this.state.dateTime.getTime()) / 1000)\n );\n }\n\n return Object.assign({}, this.state, {position});\n }\n\n const id = addRequestId();\n\n try {\n const parameters = getParamters(this.options);\n\n const result = await request(id, NodePyATVExecutableType.atvscript, [...parameters, 'playing'], this.options);\n const newState = parseState(result, id, this.options);\n\n this.applyState(newState);\n return newState;\n }\n finally {\n removeRequestId(id);\n }\n }\n\n /**\n * Removes the state node-pyatv cached for this device.\n *\n * @category State\n */\n clearState(): void {\n this.applyState(parseState({}, '', {}));\n }\n\n private applyState(newState: NodePyATVState): void {\n this.events.applyStateAndEmitEvents(newState);\n }\n\n /**\n * Get the date and time when the state was last updated.\n * @param options\n * @category State\n */\n async getDateTime(options: NodePyATVGetStateOptions = {}): Promise<Date | null> {\n const state = await this.getState(options);\n return state.dateTime;\n }\n\n /**\n * Get the hash of the current media\n * @param options\n * @category State\n */\n async getHash(options: NodePyATVGetStateOptions = {}): Promise<string | null> {\n const state = await this.getState(options);\n return state.hash;\n }\n\n /**\n * Get the media type of the current media\n * @param options\n * @category State\n */\n async getMediaType(options: NodePyATVGetStateOptions = {}): Promise<NodePyATVMediaType | null> {\n const state = await this.getState(options);\n return state.mediaType;\n }\n\n /**\n * Get the state of this device (e.g. playing, etc.)\n * @param options\n * @category State\n */\n async getDeviceState(options: NodePyATVGetStateOptions = {}): Promise<NodePyATVDeviceState | null> {\n const state = await this.getState(options);\n return state.deviceState;\n }\n\n /**\n * Returns the title of the current playing media\n * @param options\n * @category State\n */\n async getTitle(options: NodePyATVGetStateOptions = {}): Promise<string | null> {\n const state = await this.getState(options);\n return state.title;\n }\n\n /**\n * Returns the artist of the current playing media\n * @param options\n * @category State\n */\n async getArtist(options: NodePyATVGetStateOptions = {}): Promise<string | null> {\n const state = await this.getState(options);\n return state.artist;\n }\n\n /**\n * Returns the album of the current playing media\n * @param options\n * @category State\n */\n async getAlbum(options: NodePyATVGetStateOptions = {}): Promise<string | null> {\n const state = await this.getState(options);\n return state.album;\n }\n\n /**\n * Returns the genre of the current playing media\n * @param options\n * @category State\n */\n async getGenre(options: NodePyATVGetStateOptions = {}): Promise<string | null> {\n const state = await this.getState(options);\n return state.genre;\n }\n\n /**\n * Returns the media length of the current playing media\n * @param options\n * @category State\n */\n async getTotalTime(options: NodePyATVGetStateOptions = {}): Promise<number | null> {\n const state = await this.getState(options);\n return state.totalTime;\n }\n\n /**\n * Returns the title of the current playing media\n * @param options\n * @category State\n */\n async getPosition(options: NodePyATVGetStateOptions = {}): Promise<number | null> {\n const state = await this.getState(options);\n return state.position;\n }\n\n /**\n * Returns the shuffle state\n * @param options\n * @category State\n */\n async getShuffle(options: NodePyATVGetStateOptions = {}): Promise<NodePyATVShuffleState | null> {\n const state = await this.getState(options);\n return state.shuffle;\n }\n\n /**\n * Returns the repeat state\n * @param options\n * @category State\n */\n async getRepeat(options: NodePyATVGetStateOptions = {}): Promise<NodePyATVRepeatState | null> {\n const state = await this.getState(options);\n return state.repeat;\n }\n\n /**\n * Returns the currently used app\n * @param options\n * @category State\n */\n async getApp(options: NodePyATVGetStateOptions = {}): Promise<string | null> {\n const state = await this.getState(options);\n return state.app;\n }\n\n /**\n * Returns the id of the currently used app\n * @param options\n * @category State\n */\n async getAppId(options: NodePyATVGetStateOptions = {}): Promise<string | null> {\n const state = await this.getState(options);\n return state.appId;\n }\n\n /**\n * Returns the list of installed apps on the Apple TV. Probably requires `companionCredentials`,\n * see https://pyatv.dev/documentation/atvremote/#apps for more details.\n */\n async listApps(): Promise<NodePyATVApp[]> {\n const id = addRequestId();\n const parameters = getParamters(this.options);\n\n const result = await request(id, NodePyATVExecutableType.atvremote, [...parameters, 'app_list'], this.options);\n if(typeof result !== 'string' || !result.startsWith('App: ')) {\n throw new Error('Unexpected atvremote response: ' + result);\n }\n\n removeRequestId(id);\n const regex = /(.+) \\(([^\\)]+)\\)$/i;\n const items = result.substring(5, ).split(', App: ').map(i => {\n const m = i.match(regex);\n if (m !== null) {\n return {\n id: m[2],\n name: m[1],\n launch: () => this.launchApp(m[2])\n };\n }\n }) as Array<NodePyATVApp | undefined>;\n\n return items.filter(Boolean) as NodePyATVApp[];\n }\n\n private async _pressKey(key: NodePyATVInternalKeys | string, executableType: NodePyATVExecutableType) {\n const id = addRequestId();\n const parameters = getParamters(this.options);\n\n const result = await request(id, executableType, [...parameters, key], this.options);\n if (\n executableType === NodePyATVExecutableType.atvscript &&\n (typeof result !== 'object' || result.result !== 'success')\n ) {\n throw new Error(`Unable to parse pyatv response: ${JSON.stringify(result, null, ' ')}`);\n }\n\n removeRequestId(id);\n }\n\n /**\n * Send a key press to the Apple TV\n *\n * ```typescript\n * await device.pressKey(NodePyATVKeys.home);\n * ```\n *\n * <br />\n *\n * ```javascript\n * await device.pressKey('home');\n * ```\n *\n * @param key\n * @category Control\n */\n async pressKey(key: NodePyATVKeys): Promise<void> {\n const internalKeyEntry = Object.entries(NodePyATVInternalKeys)\n .find(([k]) => key === k);\n\n if(!internalKeyEntry) {\n throw new Error(`Unsupported key value ${key}!`);\n }\n\n const internalKey = internalKeyEntry[1];\n const executableType = [NodePyATVKeys.turnOn, NodePyATVKeys.turnOff].includes(key) ?\n NodePyATVExecutableType.atvremote :\n NodePyATVExecutableType.atvscript;\n\n await this._pressKey(internalKey, executableType);\n }\n\n /**\n * Send the \"down\" command\n * @category Control\n */\n async down(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.down, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"home\" command\n * @category Control\n */\n async home(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.home, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"homeHold\" command\n * @category Control\n */\n async homeHold(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.homeHold, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"left\" command\n * @category Control\n */\n async left(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.left, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"menu\" command\n * @category Control\n */\n async menu(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.menu, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"next\" command\n * @category Control\n */\n async next(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.next, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"pause\" command\n * @category Control\n */\n async pause(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.pause, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"play\" command\n * @category Control\n */\n async play(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.play, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"playPause\" command\n * @category Control\n */\n async playPause(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.playPause, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"previous\" command\n * @category Control\n */\n async previous(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.previous, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"right\" command\n * @category Control\n */\n async right(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.right, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"select\" command\n * @category Control\n */\n async select(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.select, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"skipBackward\" command\n * @category Control\n */\n async skipBackward(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.skipBackward, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"skipForward\" command\n * @category Control\n */\n async skipForward(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.skipForward, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"stop\" command\n * @category Control\n */\n async stop(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.stop, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"suspend\" command\n * @category Control\n * @deprecated\n */\n async suspend(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.suspend, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"topMenu\" command\n * @category Control\n */\n async topMenu(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.topMenu, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"up\" command\n * @category Control\n */\n async up(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.up, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"volumeDown\" command\n * @category Control\n */\n async volumeDown(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.volumeDown, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"volumeUp\" command\n * @category Control\n */\n async volumeUp(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.volumeUp, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"wakeup\" command\n * @category Control\n * @deprecated\n */\n async wakeup(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.wakeup, NodePyATVExecutableType.atvscript);\n }\n\n /**\n * Send the \"turn_off\" command\n * @category Control\n */\n async turnOff(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.turnOff, NodePyATVExecutableType.atvremote);\n }\n\n /**\n * Send the \"turn_on\" command\n * @category Control\n */\n async turnOn(): Promise<void> {\n await this._pressKey(NodePyATVInternalKeys.turnOn, NodePyATVExecutableType.atvremote);\n }\n\n /**\n * Launch an application. Probably requires `companionCredentials`, see\n * https://pyatv.dev/documentation/atvremote/#apps for more details.\n * @param id App identifier, e.g. `com.netflix.Netflix`\n */\n async launchApp(id: string): Promise<void> {\n await this._pressKey('launch_app=' + id, NodePyATVExecutableType.atvremote);\n }\n\n /**\n * Add an event listener. Will start the event subscription with the\n * Apple TV as long as there are listeners for any event registered.\n * @param event\n * @param listener\n * @category Event\n */\n addListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this {\n this.events.addListener(event, listener);\n return this;\n }\n\n /**\n * Emit an event.\n * @param event\n * @param payload\n * @category Event\n */\n emit(event: string | symbol, payload: NodePyATVDeviceEvent): boolean {\n return this.events.emit(event, payload);\n }\n\n /**\n * Get all event names which are currently known.\n * @category Event\n */\n eventNames(): Array<string | symbol> {\n return this.events.eventNames();\n }\n\n /**\n * Get max number of listeners allowed\n * @category Event\n */\n getMaxListeners(): number {\n return this.events.getMaxListeners();\n }\n\n /**\n * Get number of listeners for event\n * @param event\n * @category Event\n */\n listenerCount(event: string | symbol): number {\n return this.events.listenerCount(event);\n }\n\n /**\n * Get listeners for event. Will also return\n * node-pyatv wrappers (e.g. once)\n *\n * @param event\n * @category Event\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n listeners(event: string | symbol): Function[] {\n return this.events.listeners(event);\n }\n\n /**\n * Remove an event listener. Will stop the event subscription with the\n * Apple TV if this was the last event listener.\n * @param event\n * @param listener\n * @category Event\n */\n off(event: string | symbol, listener: (event: NodePyATVDeviceEvent | Error) => void): this {\n this.events.off(event, listener);\n return this;\n }\n\n /**\n * Add an event listener. Will start the event subscription with the\n * Apple TV as long as there are listeners for any event registered.\n * @param event\n * @param listener\n * @category Event\n */\n on(event: string | symbol, listener: (event: NodePyATVDeviceEvent | Error) => void): this {\n this.events.on(event, listener);\n return this;\n }\n\n /**\n * Add an event listener. Will start the event subscription with the\n * Apple TV as long as there are listeners for any event registered.\n * Removes the listener automatically after the first occurrence.\n * @param event\n * @param listener\n * @category Event\n */\n once(event: string | symbol, listener: (event: NodePyATVDeviceEvent | Error) => void): this {\n this.events.once(event, listener);\n return this;\n }\n\n /**\n * @param event\n * @param listener\n * @category Event\n */\n prependListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent | Error) => void): this {\n this.events.prependListener(event, listener);\n return this;\n }\n\n /**\n * @param event\n * @param listener\n * @category Event\n */\n prependOnceListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent | Error) => void): this {\n this.events.prependOnceListener(event, listener);\n return this;\n }\n\n /**\n * @param event\n * @category Event\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n rawListeners(event: string | symbol): Function[] {\n return this.events.rawListeners(event);\n }\n\n /**\n * Removes all listeners, either for the given event or\n * for every event. Will stop the event subscription with\n * the Apple TV if this was the last event listener.\n *\n * @param event\n * @category Event\n */\n removeAllListeners(event?: string | symbol): this {\n this.events.removeAllListeners(event);\n return this;\n }\n\n /**\n * Remove an event listener. Will stop the event subscription with the\n * Apple TV if this was the last event listener.\n * @param event\n * @param listener\n * @category Event\n */\n removeListener(event: string | symbol, listener: (event: NodePyATVDeviceEvent) => void): this {\n this.events.removeListener(event, listener);\n return this;\n }\n\n /**\n * @param n\n * @category Event\n */\n setMaxListeners(n: number): this {\n this.events.setMaxListeners(n);\n return this;\n }\n}\n","'use strict';\n\nimport semver from 'semver';\nimport { join, dirname } from 'path';\nimport { fileURLToPath } from 'url';\nimport { promises as fsPromises } from 'fs';\n\nimport {\n NodePyATVDeviceOptions,\n NodePyATVExecutableType,\n NodePyATVFindAndInstanceOptions,\n NodePyATVInstanceOptions,\n NodePyATVInternalScanDevice,\n NodePyATVVersionResponse\n} from './types.js';\n\nimport { addRequestId, debug, getParamters, removeRequestId, request } from './tools.js';\nimport { NodePyATVDevice } from '../lib/index.js';\n\n/**\n * Default class exported by `@sebbo2002/node-pyatv`. Use [[find]] to scan for devices in your local network. Use\n * [[device]] to connect to a known device by passing (at least) it's name and IP.\n *\n * ```typescript\n * import pyatv from '@sebbo2002/node-pyatv';\n * ```\n */\nexport default class NodePyATVInstance {\n private readonly options: NodePyATVInstanceOptions = {};\n\n /**\n * Checks if pyatv is installed and ready to be used.\n * Will throw an error if not.\n *\n * @param options\n */\n public static async check (options: NodePyATVInstanceOptions = {}): Promise<void> {\n const versions = await this.version(options);\n if (!versions.pyatv) {\n throw new Error('Unable to find pyatv. Is it installed?');\n }\n if (semver.lt(versions.pyatv, '0.6.0')) {\n throw new Error('Found pyatv, but unforunately it\\'s too old. Please update pyatv.');\n }\n\n try {\n await this.find(options);\n } catch (error) {\n throw new Error(`Unable to scan for devices: ${String(error).replace('Error: ', '')}`);\n }\n }\n\n /**\n * Resolves with the version of pyatv and of the module itself.\n * If a value can't be found, null is returned instead.\n *\n * @param options\n */\n public static async version (options: NodePyATVInstanceOptions = {}): Promise<NodePyATVVersionResponse> {\n const id = addRequestId();\n let pyatv = null;\n let module = null;\n\n try {\n pyatv = await request(id, NodePyATVExecutableType.atvremote, ['--version'], options) as string;\n } catch (error) {\n debug(id, `Unable to get pyatv version due to ${error}`, options);\n }\n\n if (pyatv && pyatv.substr(0, 10) === 'atvremote ') {\n pyatv = pyatv.substr(10);\n }\n if (!semver.valid(pyatv)) {\n debug(id, `String \"${pyatv}\" is not a valid pyatv version, set it to null`, options);\n pyatv = null;\n }\n\n try {\n const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json');\n const json = JSON.parse(await fsPromises.readFile(packageJsonPath, 'utf8'));\n module = json?.version || null;\n } catch (error) {\n debug(id, `Unable to get module version due to ${error}`, options);\n }\n if (module && !semver.valid(module)) {\n debug(id, `String \"${module}\" is not a valid module version, set it to null`, options);\n module = null;\n }\n\n removeRequestId(id);\n return {\n pyatv,\n module\n };\n }\n\n /**\n * Scan the network for Apple TVs by using pyatv's atvscript. See [[NodePyATVFindAndInstanceOptions]]\n * for the options allowed. Use the `host` / `hosts` attribute to filter by IP addresses. Resolves with\n * an array of [[NodePyATVDevice]].\n *\n * ```typescript\n * import pyatv from '@sebbo2002/node-pyatv';\n * const devices = await pyatv.find();\n * console.log(devices);\n * ```\n *\n * @param options\n */\n public static async find (options: NodePyATVFindAndInstanceOptions = {}): Promise<NodePyATVDevice[]> {\n const id = addRequestId();\n const parameters = getParamters(options);\n\n const result = await request(id, NodePyATVExecutableType.atvscript, [...parameters, 'scan'], options);\n if (typeof result !== 'object' || result.result !== 'success' || !Array.isArray(result.devices)) {\n throw new Error(`Unable to parse pyatv response: ${JSON.stringify(result, null, ' ')}`);\n }\n\n const objects = result.devices.map((device: NodePyATVInternalScanDevice) =>\n this.device(Object.assign({}, options, {\n host: device.address,\n id: device.identifier,\n allIDs: device.all_identifiers,\n name: device.name,\n mac: device.device_info?.mac,\n model: device.device_info?.model,\n modelName: device.device_info?.model_str,\n os: device.device_info?.operating_system,\n version: device.device_info?.version,\n services: device.services\n }))\n );\n\n removeRequestId(id);\n return objects;\n }\n\n /**\n * Create a [[NodePyATVDevice]] to query the state and control it.\n * At least `host` and `name` are required.\n *\n * @param options\n */\n public static device (options: NodePyATVDeviceOptions): NodePyATVDevice {\n return new NodePyATVDevice(options);\n }\n\n /**\n * Use this to apply [[NodePyATVInstanceOptions]]\n * (e.g. debug log method) to all further requests\n *\n * ```typescript\n * import pyatv from '@sebbo2002/node-pyatv';\n * const myPyatv = new pyatv({debug: true});\n * const devices = myPyatv.find();\n * console.log(devices);\n * ```\n * @param options\n */\n public constructor (options: NodePyATVInstanceOptions = {}) {\n this.options = Object.assign({}, options);\n }\n\n /**\n * Checks if pyatv is installed and ready to be used.\n * Will throw an error if not.\n *\n * @param options\n */\n public async check (options: NodePyATVInstanceOptions = {}): Promise<void> {\n return NodePyATVInstance.check(Object.assign({}, this.options, options));\n }\n\n /**\n * Resolves with the version of pyatv and of the module itself.\n * If a value can't be found, null is returned instead.\n *\n * @param options\n */\n public async version (options: NodePyATVInstanceOptions = {}): Promise<NodePyATVVersionResponse> {\n return NodePyATVInstance.version(Object.assign({}, this.options, options));\n }\n\n /**\n * Scan the network for Apple TVs by using pyatv's atvscript. See [[NodePyATVFindAndInstanceOptions]]\n * for the options allowed. Use the `host` / `hosts` attribute to filter by IP addresses. Resolves with\n * an array of [[NodePyATVDevice]].\n *\n * ```typescript\n * import pyatv from '@sebbo2002/node-pyatv';\n * const myPyATV = new pyatv({debug: true});\n * const devices = await myPyATV.find();\n * console.log(devices);\n * ```\n *\n * @param options\n */\n public async find (options: NodePyATVFindAndInstanceOptions = {}): Promise<NodePyATVDevice[]> {\n return NodePyATVInstance.find(Object.assign({}, this.options, options));\n }\n\n /**\n * Create a [[NodePyATVDevice]] to query the state and control it.\n * At least `host` and `name` are required.\n *\n * @param options\n */\n public device (options: NodePyATVDeviceOptions): NodePyATVDevice {\n return NodePyATVInstance.device(Object.assign({}, this.options, options));\n }\n}\n"],"mappings":"6MAGO,IAAKA,OACRA,EAAA,UAAY,YACZA,EAAA,UAAY,YAFJA,OAAA,IAKAC,OACRA,EAAA,KAAO,OACPA,EAAA,IAAM,MACNA,EAAA,QAAU,UACVA,EAAA,KAAO,OAJCA,OA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AMA,EAAO,KACb,KAAKC,EAAAD,EAAO,cAAP,YAAAC,EAAoB,IACzB,OAAOC,EAAAF,EAAO,cAAP,YAAAE,EAAoB,MAC3B,WAAWC,EAAAH,EAAO,cAAP,YAAAG,EAAoB,UAC/B,IAAIC,EAAAJ,EAAO,cAAP,YAAAI,EAAoB,iBACxB,SAASC,EAAAL,EAAO,cAAP,YAAAK,EAAoB,QAC7B,SAAUL,EAAO,QACrB,CAAC,CAAC,EACN,EAEA,OAAAL,EAAgBb,CAAE,EACXiB,CACX,GAQA,OAAc,OAAQtB,EAAkD,CACpE,OAAO,IAAI6B,EAAgB7B,CAAO,CACtC,CAwBa,OAA8D,QAAAC,EAAA,yBAAvDD,EAAoC,CAAC,EAAkB,CACvE,OAAOD,EAAkB,MAAM,OAAO,OAAO,CAAC,EAAG,KAAK,QAASC,CAAO,CAAC,CAC3E,GAQa,SAAoF,QAAAC,EAAA,yBAA3ED,EAAoC,CAAC,EAAsC,CAC7F,OAAOD,EAAkB,QAAQ,OAAO,OAAO,CAAC,EAAG,KAAK,QAASC,CAAO,CAAC,CAC7E,GAgBa,MAAiF,QAAAC,EAAA,yBAA3ED,EAA2C,CAAC,EAA+B,CAC1F,OAAOD,EAAkB,KAAK,OAAO,OAAO,CAAC,EAAG,KAAK,QAASC,CAAO,CAAC,CAC1E,GAQO,OAAQA,EAAkD,CAC7D,OAAOD,EAAkB,OAAO,OAAO,OAAO,CAAC,EAAG,KAAK,QAASC,CAAO,CAAC,CAC5E,CACJ","names":["NodePyATVExecutableType","NodePyATVProtocol","NodePyATVMediaType","NodePyATVDeviceState","NodePyATVRepeatState","NodePyATVShuffleState","NodePyATVPowerState","NodePyATVFocusState","NodePyATVKeys","NodePyATVInternalKeys","NodePyATVListenerState","NodePyATVDeviceEvent","values","EventEmitter","spawn","requestIds","addRequestId","id","i","removeRequestId","debug","message","options","log","enableColors","parts","getExecutable","executable","execute","requestId","executableType","parameters","mySpawn","spawn","child","onStdOut","data","onStdErr","onError","onClose","code","request","__async","result","resolve","reject","pyatv","msg","error","getParamters","parseStateStringAttr","input","output","inputAttr","outputAttr","d","parseState","errorStr","date","NodePyATVMediaType","o","NodePyATVDeviceState","NodePyATVShuffleState","NodePyATVRepeatState","NodePyATVPowerState","NodePyATVFocusState","NodePyATVDeviceEvents","EventEmitter","state","device","options","newState","key","oldValue","newValue","event","NodePyATVDeviceEvent","error","reqId","data","json","msg","debug","update","parseState","id","addRequestId","removeRequestId","listenStart","parameters","getParamters","execute","onError","onStdErr","onStdOut","s","onClose","code","__async","cb","listener","a","b","NodePyATVDevice","options","parseState","NodePyATVDeviceEvents","debug","__async","_a","position","id","addRequestId","parameters","getParamters","result","request","newState","removeRequestId","regex","i","m","key","executableType","internalKeyEntry","NodePyATVInternalKeys","k","internalKey","event","listener","payload","n","semver","join","dirname","fileURLToPath","fsPromises","import_meta","NodePyATVInstance","_NodePyATVInstance","options","__async","versions","semver","error","id","addRequestId","pyatv","module","request","debug","packageJsonPath","join","dirname","fileURLToPath","import_meta","json","fsPromises","removeRequestId","parameters","getParamters","result","objects","device","_a","_b","_c","_d","_e","NodePyATVDevice"]}
|
package/dist/lib/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var Q=Object.create;var C=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var K=(s,e)=>{for(var t in e)C(s,t,{get:e[t],enumerable:!0})},M=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Y(e))!q.call(s,n)&&n!==t&&C(s,n,{get:()=>e[n],enumerable:!(i=X(e,n))||i.enumerable});return s};var ee=(s,e,t)=>(t=s!=null?Q(Z(s)):{},M(e||!s||!s.__esModule?C(t,"default",{value:s,enumerable:!0}):t,s)),te=s=>M(C({},"__esModule",{value:!0}),s);var o=(s,e,t)=>new Promise((i,n)=>{var a=c=>{try{p(t.next(c))}catch(u){n(u)}},r=c=>{try{p(t.throw(c))}catch(u){n(u)}},p=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,r);p((t=t.apply(s,e)).next())});var ne={};K(ne,{NodePyATVDevice:()=>V,NodePyATVDeviceEvent:()=>T,NodePyATVDeviceEvents:()=>A,NodePyATVDeviceState:()=>O,NodePyATVExecutableType:()=>S,NodePyATVInstance:()=>D,NodePyATVKeys:()=>U,NodePyATVListenerState:()=>j,NodePyATVMediaType:()=>b,NodePyATVPowerState:()=>E,NodePyATVProtocol:()=>
|
|
1
|
+
"use strict";var Q=Object.create;var C=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var K=(s,e)=>{for(var t in e)C(s,t,{get:e[t],enumerable:!0})},M=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Y(e))!q.call(s,n)&&n!==t&&C(s,n,{get:()=>e[n],enumerable:!(i=X(e,n))||i.enumerable});return s};var ee=(s,e,t)=>(t=s!=null?Q(Z(s)):{},M(e||!s||!s.__esModule?C(t,"default",{value:s,enumerable:!0}):t,s)),te=s=>M(C({},"__esModule",{value:!0}),s);var o=(s,e,t)=>new Promise((i,n)=>{var a=c=>{try{p(t.next(c))}catch(u){n(u)}},r=c=>{try{p(t.throw(c))}catch(u){n(u)}},p=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,r);p((t=t.apply(s,e)).next())});var ne={};K(ne,{NodePyATVDevice:()=>V,NodePyATVDeviceEvent:()=>T,NodePyATVDeviceEvents:()=>A,NodePyATVDeviceState:()=>O,NodePyATVExecutableType:()=>S,NodePyATVInstance:()=>D,NodePyATVKeys:()=>U,NodePyATVListenerState:()=>j,NodePyATVMediaType:()=>b,NodePyATVPowerState:()=>E,NodePyATVProtocol:()=>R,NodePyATVRepeatState:()=>k,NodePyATVShuffleState:()=>x,default:()=>D});module.exports=te(ne);var se=()=>typeof document=="undefined"?new URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,g=se();var S=(t=>(t.atvremote="atvremote",t.atvscript="atvscript",t))(S||{}),R=(n=>(n.dmap="dmap",n.mrp="mrp",n.airplay="airplay",n.mdns="mdns",n))(R||{}),b=(n=>(n.music="music",n.tv="tv",n.video="video",n.unknown="unknown",n))(b||{}),O=(r=>(r.idle="idle",r.loading="loading",r.paused="paused",r.playing="playing",r.seeking="seeking",r.stopped="stopped",r))(O||{}),k=(i=>(i.all="all",i.track="track",i.off="off",i))(k||{}),x=(i=>(i.albums="albums",i.songs="songs",i.off="off",i))(x||{}),E=(t=>(t.on="on",t.off="off",t))(E||{}),L=(t=>(t.focued="focused",t.unfocused="unfocused",t))(L||{}),U=(d=>(d.down="down",d.home="home",d.homeHold="homeHold",d.left="left",d.menu="menu",d.next="next",d.pause="pause",d.play="play",d.playPause="playPause",d.previous="previous",d.right="right",d.select="select",d.skipBackward="skipBackward",d.skipForward="skipForward",d.stop="stop",d.suspend="suspend",d.topMenu="topMenu",d.up="up",d.volumeDown="volumeDown",d.volumeUp="volumeUp",d.wakeup="wakeup",d.turnOff="turnOff",d.turnOn="turnOn",d))(U||{}),G=(d=>(d.down="down",d.home="home",d.homeHold="home_hold",d.left="left",d.menu="menu",d.next="next",d.pause="pause",d.play="play",d.playPause="play_pause",d.previous="previous",d.right="right",d.select="select",d.skipBackward="skip_backward",d.skipForward="skip_forward",d.stop="stop",d.suspend="suspend",d.topMenu="top_menu",d.up="up",d.volumeDown="volume_down",d.volumeUp="volume_up",d.wakeup="wakeup",d.turnOff="turn_off",d.turnOn="turn_on",d))(G||{}),j=(n=>(n[n.stopped=0]="stopped",n[n.starting=1]="starting",n[n.started=2]="started",n[n.stopping=3]="stopping",n))(j||{});var T=class{constructor(e){this.values=Object.assign({},e,{key:e.key})}get key(){return this.values.key}get oldValue(){return this.values.old}get newValue(){return this.values.new}get value(){return this.values.new}get device(){return this.values.device}};var H=require("events");var B=require("child_process");var $=[];function y(){let s="?";for(let e=0;e<1e3;e+=1)if(s=Math.round(Math.random()*(e+6)*36).toString(36).toUpperCase(),!$.includes(s)){$.push(s);break}return s}function h(s){s&&$.includes(s)&&$.splice($.indexOf(s),1)}function l(s,e,t){if(t.debug){let i=typeof t.debug=="function"?t.debug:console.log,n=!process.env.NO_COLOR&&!t.noColors,a=[n?"\x1B[0m":"",n?"\x1B[90m":"","[node-pyatv][",n?"\x1B[37m":"",s,n?"\x1B[90m":"","] ",n?"\x1B[0m":"",e];i.apply(null,[a.join("")])}}function ie(s,e){return s==="atvremote"&&typeof e.atvremotePath=="string"?e.atvremotePath:s==="atvscript"&&typeof e.atvscriptPath=="string"?e.atvscriptPath:s}function J(s,e,t,i){let n=ie(e,i),a=typeof i.spawn=="function"?i.spawn:B.spawn;l(s,`${n} ${t.join(" ")}`,i);let r=a(n,t,{env:process.env}),p=v=>l(s,`stdout: ${String(v).trim()}`,i),c=v=>l(s,`stderr: ${String(v).trim()}`,i),u=v=>l(s,`error: ${String(v).trim()}`,i),m=v=>{l(s,`${n} exited with code: ${v}`,i),r.stdout&&r.stdout.off("data",p),r.stderr&&r.stderr.off("data",c),r.off("error",u),r.off("close",m)};return r.stdout&&r.stdout.on("data",p),r.stderr&&r.stderr.on("data",c),r.on("error",u),r.on("close",m),r}function N(s,e,t,i){return o(this,null,function*(){let n={stdout:"",stderr:"",code:0};if(yield new Promise((a,r)=>{let p=J(s,e,t,i),c=f=>n.stdout+=String(f).trim(),u=f=>n.stderr+=String(f).trim(),m=f=>r(f instanceof Error?f:new Error(String(f))),v=f=>{n.code=f,p.stdout&&p.stdout.off("data",c),p.stderr&&p.stderr.off("data",u),p.off("error",m),p.off("close",v),a(void 0)};p.stdout&&p.stdout.on("data",c),p.stderr&&p.stderr.on("data",u),p.on("error",m),p.on("close",v)}),n.stderr.length>0){let a=`Unable to execute request ${s}: ${n.stderr}`;throw l(s,a,i),new Error(a)}if(e==="atvscript")try{return JSON.parse(n.stdout)}catch(a){let r=`Unable to parse result ${s} json: ${a}`;throw l(s,r,i),new Error(r)}return n.stdout})}function P(s={}){let e=[];return s.hosts?e.push("-s",s.hosts.join(",")):s.host&&e.push("-s",s.host),s.id&&e.push("-i",s.id),s.protocol&&e.push("--protocol",s.protocol),s.dmapCredentials&&e.push("--dmap-credentials",s.dmapCredentials),s.mrpCredentials&&e.push("--mrp-credentials",s.mrpCredentials),s.airplayCredentials&&e.push("--airplay-credentials",s.airplayCredentials),s.companionCredentials&&e.push("--companion-credentials",s.companionCredentials),s.raopCredentials&&e.push("--raop-credentials",s.raopCredentials),e}function w(s,e,t,i,n){if(typeof s[t]=="string"){e[i]=s[t];return}n(`No ${i} value found in input (${JSON.stringify(s)})`)}function _(s,e,t){let i=a=>l(e,a,t),n={dateTime:null,hash:null,mediaType:null,deviceState:null,title:null,artist:null,album:null,genre:null,totalTime:null,position:null,shuffle:null,repeat:null,app:null,appId:null,powerState:null,volume:null,focusState:null};if(!s||typeof s!="object")return n;if(s.exception){let a="Got pyatv Error: "+s.exception;throw s.stacktrace&&(a+=`
|
|
2
2
|
|
|
3
3
|
pyatv Stacktrace:
|
|
4
|
-
`+s.stacktrace),new Error(a)}if(typeof s.datetime=="string"){let a=new Date(s.datetime);isNaN(a.getTime())?i(`Invalid datetime value ${s.datetime}, ignore attribute`):n.dateTime=a}else i(`No datetime value found in input (${JSON.stringify(s)})`);return w(s,n,"hash","hash",i),typeof s.media_type=="string"?Object.keys(b).map(r=>String(r)).includes(s.media_type)?n.mediaType=b[s.media_type]:i(`Unsupported mediaType value ${s.media_type}, ignore attribute`):i(`No mediaType value found in input (${JSON.stringify(s)})`),typeof s.device_state=="string"?Object.keys(O).map(r=>String(r)).includes(s.device_state)?n.deviceState=O[s.device_state]:i(`Unsupported deviceState value ${s.device_state}, ignore attribute`):i(`No deviceState value found in input (${JSON.stringify(s)})`),w(s,n,"title","title",i),w(s,n,"artist","artist",i),w(s,n,"album","album",i),w(s,n,"genre","genre",i),typeof s.total_time=="number"?n.totalTime=s.total_time:i(`No totalTime value found in input (${JSON.stringify(s)})`),typeof s.position=="number"?n.position=s.position:i(`No position value found in input (${JSON.stringify(s)})`),typeof s.shuffle=="string"?Object.keys(x).map(r=>String(r)).includes(s.shuffle)?n.shuffle=x[s.shuffle]:i(`Unsupported shuffle value ${s.shuffle}, ignore attribute`):i(`No shuffle value found in input (${JSON.stringify(s)})`),typeof s.repeat=="string"?Object.keys(k).map(r=>String(r)).includes(s.repeat)?n.repeat=k[s.repeat]:i(`Unsupported repeat value ${s.repeat}, ignore attribute`):i(`No repeat value found in input (${JSON.stringify(s)})`),w(s,n,"app","app",i),w(s,n,"app_id","appId",i),typeof s.power_state=="string"?Object.keys(E).map(r=>String(r)).includes(s.power_state)?n.powerState=E[s.power_state]:i(`Unsupported powerState value ${s.power_state}, ignore attribute`):i(`No powerState value found in input (${JSON.stringify(s)})`),typeof s.volume=="number"&&(n.volume=s.volume),typeof s.focus_state=="string"?Object.keys(L).map(r=>String(r)).includes(s.focus_state)?n.focusState=L[s.power_state]:i(`Unsupported focusState value ${s.focus_state}, ignore attribute`):i(`No focusState value found in input (${JSON.stringify(s)})`),n}var A=class extends H.EventEmitter{constructor(t,i,n){super();this.state=t,this.device=i,this.options=Object.assign({},n),this.listenerState=0}applyStateAndEmitEvents(t){Object.keys(this.state).forEach(i=>{let n=this.state[i],a=t[i];if(n===void 0||a===void 0||n===a)return;let r=new T({key:i,old:n,new:a,device:this.device});this.state[i]=t[i];try{this.emit("update:"+i,r),this.emit("update",r)}catch(p){this.emit("error",p)}})}parsePushUpdate(t,i){let n;try{n=JSON.parse(i)}catch(a){let r=`Unable to parse stdout json: ${a}`;l(t,r,this.options),this.emit("error",new Error(r));return}this.applyPushUpdate(n,t),this.listenerState===1&&(this.listenerState=2,this.checkListener())}applyPushUpdate(t,i){try{let n=_(t,i,this.options);this.applyStateAndEmitEvents(n)}catch(n){this.emit("error",n)}}checkListener(){if(this.listenerState===0&&this.listenerCount()===0&&this.timeout)clearTimeout(this.timeout),this.timeout=void 0;else if(this.listenerState===0&&this.listenerCount()>0){let t=y();l(t,`Start listeing to events from device ${this.options.name}`,this.options),this.startListening(t),
|
|
5
|
-
`).map(m=>m.trim()).filter(Boolean).forEach(m=>{l(t,`> ${m}`,this.options),this.parsePushUpdate(t,m)})},c=u=>{this.pyatv!==void 0&&(this.listenerState=0,l(t,`Listening with atvscript exited with code ${u}`,this.options),this.timeout!==void 0&&(clearTimeout(this.timeout),this.timeout=void 0),this.pyatv.stdout&&this.pyatv.stdout.off("data",p),this.pyatv.stderr&&this.pyatv.stderr.off("data",r),this.pyatv.off("error",a),this.pyatv.off("close",c),this.listenerCount()>0&&new Date().getTime()-i<3e4?(l(t,`Wait 15s and restart listeing to events from device ${this.options.name}`,this.options),this.timeout=setTimeout(()=>{this.checkListener()},15e3)):this.listenerCount()>0&&(l(t,`Restart listeing to events from device ${this.options.name}`,this.options),this.checkListener()),
|
|
6
|
-
`),yield new Promise(i=>this.timeout=setTimeout(i,250))),this.listenerState===3&&this.pyatv&&this.pyatv.kill(),this.listenerState=0}})}addListener(t,i){return super.addListener(t,i),this.checkListener(),this}on(t,i){return super.on(t,i),this.checkListener(),this}once(t,i){return super.once(t,n=>{i(n),setTimeout(()=>this.checkListener(),0)}),this.checkListener(),this}prependListener(t,i){return super.prependListener(t,i),this.checkListener(),this}off(t,i){return super.off(t,i),this.checkListener(),this}removeAllListeners(t){return super.removeAllListeners(t),this.checkListener(),this}removeListener(t,i){return super.removeListener(t,i),this.checkListener(),this}listenerCount(t){return t!==void 0?super.listenerCount(t):this.eventNames().map(i=>this.listenerCount(i)).reduce((i,n)=>i+n,0)}};var V=class{constructor(e){this.options=Object.assign({},e),this.state=_({},"",{}),this.events=new A(this.state,this,this.options)}get name(){return this.options.name}get host(){return this.options.host}get id(){return this.options.id}get protocol(){return this.options.protocol}get model(){return this.options.model}get modelName(){return this.options.modelName}get os(){return this.options.os}get version(){return this.options.version}get services(){return this.options.services}get debug(){return this.options.debug}set debug(e){typeof e=="function"?this.options.debug=e:this.options.debug=!!e||void 0}toJSON(){return{name:this.name,host:this.host,id:this.id,protocol:this.protocol}}toString(){return`NodePyATVDevice(${this.name}, ${this.host})`}getState(){return o(this,arguments,function*(e={}){var i;if((i=this.state)!=null&&i.dateTime&&new Date().getTime()-this.state.dateTime.getTime()<(e.maxAge||5e3)){let n=null;return this.state.position&&this.state.dateTime&&(n=Math.round(this.state.position+(new Date().getTime()-this.state.dateTime.getTime())/1e3)),Object.assign({},this.state,{position:n})}let t=y();try{let n=P(this.options),a=yield N(t,"atvscript",[...n,"playing"],this.options),r=_(a,t,this.options);return this.applyState(r),r}finally{
|
|
4
|
+
`+s.stacktrace),new Error(a)}if(typeof s.datetime=="string"){let a=new Date(s.datetime);isNaN(a.getTime())?i(`Invalid datetime value ${s.datetime}, ignore attribute`):n.dateTime=a}else i(`No datetime value found in input (${JSON.stringify(s)})`);return w(s,n,"hash","hash",i),typeof s.media_type=="string"?Object.keys(b).map(r=>String(r)).includes(s.media_type)?n.mediaType=b[s.media_type]:i(`Unsupported mediaType value ${s.media_type}, ignore attribute`):i(`No mediaType value found in input (${JSON.stringify(s)})`),typeof s.device_state=="string"?Object.keys(O).map(r=>String(r)).includes(s.device_state)?n.deviceState=O[s.device_state]:i(`Unsupported deviceState value ${s.device_state}, ignore attribute`):i(`No deviceState value found in input (${JSON.stringify(s)})`),w(s,n,"title","title",i),w(s,n,"artist","artist",i),w(s,n,"album","album",i),w(s,n,"genre","genre",i),typeof s.total_time=="number"?n.totalTime=s.total_time:i(`No totalTime value found in input (${JSON.stringify(s)})`),typeof s.position=="number"?n.position=s.position:i(`No position value found in input (${JSON.stringify(s)})`),typeof s.shuffle=="string"?Object.keys(x).map(r=>String(r)).includes(s.shuffle)?n.shuffle=x[s.shuffle]:i(`Unsupported shuffle value ${s.shuffle}, ignore attribute`):i(`No shuffle value found in input (${JSON.stringify(s)})`),typeof s.repeat=="string"?Object.keys(k).map(r=>String(r)).includes(s.repeat)?n.repeat=k[s.repeat]:i(`Unsupported repeat value ${s.repeat}, ignore attribute`):i(`No repeat value found in input (${JSON.stringify(s)})`),w(s,n,"app","app",i),w(s,n,"app_id","appId",i),typeof s.power_state=="string"?Object.keys(E).map(r=>String(r)).includes(s.power_state)?n.powerState=E[s.power_state]:i(`Unsupported powerState value ${s.power_state}, ignore attribute`):i(`No powerState value found in input (${JSON.stringify(s)})`),typeof s.volume=="number"&&(n.volume=s.volume),typeof s.focus_state=="string"?Object.keys(L).map(r=>String(r)).includes(s.focus_state)?n.focusState=L[s.power_state]:i(`Unsupported focusState value ${s.focus_state}, ignore attribute`):i(`No focusState value found in input (${JSON.stringify(s)})`),n}var A=class extends H.EventEmitter{constructor(t,i,n){super();this.state=t,this.device=i,this.options=Object.assign({},n),this.listenerState=0}applyStateAndEmitEvents(t){Object.keys(this.state).forEach(i=>{let n=this.state[i],a=t[i];if(n===void 0||a===void 0||n===a)return;let r=new T({key:i,old:n,new:a,device:this.device});this.state[i]=t[i];try{this.emit("update:"+i,r),this.emit("update",r)}catch(p){this.emit("error",p)}})}parsePushUpdate(t,i){let n;try{n=JSON.parse(i)}catch(a){let r=`Unable to parse stdout json: ${a}`;l(t,r,this.options),this.emit("error",new Error(r));return}this.applyPushUpdate(n,t),this.listenerState===1&&(this.listenerState=2,this.checkListener())}applyPushUpdate(t,i){try{let n=_(t,i,this.options);this.applyStateAndEmitEvents(n)}catch(n){this.emit("error",n)}}checkListener(){if(this.listenerState===0&&this.listenerCount()===0&&this.timeout)clearTimeout(this.timeout),this.timeout=void 0;else if(this.listenerState===0&&this.listenerCount()>0){let t=y();l(t,`Start listeing to events from device ${this.options.name}`,this.options),this.startListening(t),h(t)}else if([1,2].includes(this.listenerState)&&this.listenerCount()===0){let t=y();l(t,`Stop listening to events from device ${this.options.name}`,this.options),this.stopListening(t).catch(i=>l(t,`Unable to stop listeing: ${i}`,this.options)).finally(()=>h(t))}}startListening(t){if(this.listenerState!==0)return;this.listenerState=1;let i=new Date().getTime(),n=P(this.options);if(this.pyatv=J(t,"atvscript",[...n,"push_updates"],this.options),!this.pyatv)throw new Error("Unable to start listener: Unable to start atvscript");let a=u=>{l(t,`Got error from child process: ${u}`,this.options),this.emit("error",u)},r=u=>{let m=new Error(`Got stderr output from pyatv: ${u}`);l(t,u.toString(),this.options),this.emit("error",m)},p=u=>{String(u).split(`
|
|
5
|
+
`).map(m=>m.trim()).filter(Boolean).forEach(m=>{l(t,`> ${m}`,this.options),this.parsePushUpdate(t,m)})},c=u=>{this.pyatv!==void 0&&(this.listenerState=0,l(t,`Listening with atvscript exited with code ${u}`,this.options),this.timeout!==void 0&&(clearTimeout(this.timeout),this.timeout=void 0),this.pyatv.stdout&&this.pyatv.stdout.off("data",p),this.pyatv.stderr&&this.pyatv.stderr.off("data",r),this.pyatv.off("error",a),this.pyatv.off("close",c),this.listenerCount()>0&&new Date().getTime()-i<3e4?(l(t,`Wait 15s and restart listeing to events from device ${this.options.name}`,this.options),this.timeout=setTimeout(()=>{this.checkListener()},15e3)):this.listenerCount()>0&&(l(t,`Restart listeing to events from device ${this.options.name}`,this.options),this.checkListener()),h(t))};this.pyatv.on("error",a),this.pyatv.on("close",c),this.pyatv.stdout&&this.pyatv.stdout.on("data",p),this.pyatv.stderr&&this.pyatv.stderr.on("data",r)}stopListening(t){return o(this,null,function*(){if(!(this.listenerState!==1&&this.listenerState!==2)){if(this.listenerState=3,this.pyatv===void 0)throw new Error("Unable to stop listening due to internal error: state is stopping, but there's no child process. This should never happen, please report this.");this.pyatv.stdin&&(l(t,"Pressing enter to close atvscript\u2026",this.options),this.pyatv.stdin.write(`
|
|
6
|
+
`),yield new Promise(i=>this.timeout=setTimeout(i,250))),this.listenerState===3&&this.pyatv&&this.pyatv.kill(),this.listenerState=0}})}addListener(t,i){return super.addListener(t,i),this.checkListener(),this}on(t,i){return super.on(t,i),this.checkListener(),this}once(t,i){return super.once(t,n=>{i(n),setTimeout(()=>this.checkListener(),0)}),this.checkListener(),this}prependListener(t,i){return super.prependListener(t,i),this.checkListener(),this}off(t,i){return super.off(t,i),this.checkListener(),this}removeAllListeners(t){return super.removeAllListeners(t),this.checkListener(),this}removeListener(t,i){return super.removeListener(t,i),this.checkListener(),this}listenerCount(t){return t!==void 0?super.listenerCount(t):this.eventNames().map(i=>this.listenerCount(i)).reduce((i,n)=>i+n,0)}};var V=class{constructor(e){this.options=Object.assign({},e),this.state=_({},"",{}),this.events=new A(this.state,this,this.options)}get name(){return this.options.name}get host(){return this.options.host}get id(){return this.options.id}get allIDs(){return this.options.allIDs}get protocol(){return this.options.protocol}get mac(){return this.options.mac}get model(){return this.options.model}get modelName(){return this.options.modelName}get os(){return this.options.os}get version(){return this.options.version}get services(){return this.options.services}get debug(){return this.options.debug}set debug(e){typeof e=="function"?this.options.debug=e:this.options.debug=!!e||void 0}toJSON(){return{name:this.name,host:this.host,id:this.id,protocol:this.protocol}}toString(){return`NodePyATVDevice(${this.name}, ${this.host})`}getState(){return o(this,arguments,function*(e={}){var i;if((i=this.state)!=null&&i.dateTime&&new Date().getTime()-this.state.dateTime.getTime()<(e.maxAge||5e3)){let n=null;return this.state.position&&this.state.dateTime&&(n=Math.round(this.state.position+(new Date().getTime()-this.state.dateTime.getTime())/1e3)),Object.assign({},this.state,{position:n})}let t=y();try{let n=P(this.options),a=yield N(t,"atvscript",[...n,"playing"],this.options),r=_(a,t,this.options);return this.applyState(r),r}finally{h(t)}})}clearState(){this.applyState(_({},"",{}))}applyState(e){this.events.applyStateAndEmitEvents(e)}getDateTime(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).dateTime})}getHash(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).hash})}getMediaType(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).mediaType})}getDeviceState(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).deviceState})}getTitle(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).title})}getArtist(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).artist})}getAlbum(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).album})}getGenre(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).genre})}getTotalTime(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).totalTime})}getPosition(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).position})}getShuffle(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).shuffle})}getRepeat(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).repeat})}getApp(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).app})}getAppId(){return o(this,arguments,function*(e={}){return(yield this.getState(e)).appId})}listApps(){return o(this,null,function*(){let e=y(),t=P(this.options),i=yield N(e,"atvremote",[...t,"app_list"],this.options);if(typeof i!="string"||!i.startsWith("App: "))throw new Error("Unexpected atvremote response: "+i);h(e);let n=/(.+) \(([^\)]+)\)$/i;return i.substring(5).split(", App: ").map(r=>{let p=r.match(n);if(p!==null)return{id:p[2],name:p[1],launch:()=>this.launchApp(p[2])}}).filter(Boolean)})}_pressKey(e,t){return o(this,null,function*(){let i=y(),n=P(this.options),a=yield N(i,t,[...n,e],this.options);if(t==="atvscript"&&(typeof a!="object"||a.result!=="success"))throw new Error(`Unable to parse pyatv response: ${JSON.stringify(a,null," ")}`);h(i)})}pressKey(e){return o(this,null,function*(){let t=Object.entries(G).find(([a])=>e===a);if(!t)throw new Error(`Unsupported key value ${e}!`);let i=t[1],n=["turnOn","turnOff"].includes(e)?"atvremote":"atvscript";yield this._pressKey(i,n)})}down(){return o(this,null,function*(){yield this._pressKey("down","atvscript")})}home(){return o(this,null,function*(){yield this._pressKey("home","atvscript")})}homeHold(){return o(this,null,function*(){yield this._pressKey("home_hold","atvscript")})}left(){return o(this,null,function*(){yield this._pressKey("left","atvscript")})}menu(){return o(this,null,function*(){yield this._pressKey("menu","atvscript")})}next(){return o(this,null,function*(){yield this._pressKey("next","atvscript")})}pause(){return o(this,null,function*(){yield this._pressKey("pause","atvscript")})}play(){return o(this,null,function*(){yield this._pressKey("play","atvscript")})}playPause(){return o(this,null,function*(){yield this._pressKey("play_pause","atvscript")})}previous(){return o(this,null,function*(){yield this._pressKey("previous","atvscript")})}right(){return o(this,null,function*(){yield this._pressKey("right","atvscript")})}select(){return o(this,null,function*(){yield this._pressKey("select","atvscript")})}skipBackward(){return o(this,null,function*(){yield this._pressKey("skip_backward","atvscript")})}skipForward(){return o(this,null,function*(){yield this._pressKey("skip_forward","atvscript")})}stop(){return o(this,null,function*(){yield this._pressKey("stop","atvscript")})}suspend(){return o(this,null,function*(){yield this._pressKey("suspend","atvscript")})}topMenu(){return o(this,null,function*(){yield this._pressKey("top_menu","atvscript")})}up(){return o(this,null,function*(){yield this._pressKey("up","atvscript")})}volumeDown(){return o(this,null,function*(){yield this._pressKey("volume_down","atvscript")})}volumeUp(){return o(this,null,function*(){yield this._pressKey("volume_up","atvscript")})}wakeup(){return o(this,null,function*(){yield this._pressKey("wakeup","atvscript")})}turnOff(){return o(this,null,function*(){yield this._pressKey("turn_off","atvremote")})}turnOn(){return o(this,null,function*(){yield this._pressKey("turn_on","atvremote")})}launchApp(e){return o(this,null,function*(){yield this._pressKey("launch_app="+e,"atvremote")})}addListener(e,t){return this.events.addListener(e,t),this}emit(e,t){return this.events.emit(e,t)}eventNames(){return this.events.eventNames()}getMaxListeners(){return this.events.getMaxListeners()}listenerCount(e){return this.events.listenerCount(e)}listeners(e){return this.events.listeners(e)}off(e,t){return this.events.off(e,t),this}on(e,t){return this.events.on(e,t),this}once(e,t){return this.events.once(e,t),this}prependListener(e,t){return this.events.prependListener(e,t),this}prependOnceListener(e,t){return this.events.prependOnceListener(e,t),this}rawListeners(e){return this.events.rawListeners(e)}removeAllListeners(e){return this.events.removeAllListeners(e),this}removeListener(e,t){return this.events.removeListener(e,t),this}setMaxListeners(e){return this.events.setMaxListeners(e),this}};var F=ee(require("semver"),1),I=require("path"),W=require("url"),z=require("fs");var D=class s{constructor(e={}){this.options={};this.options=Object.assign({},e)}static check(){return o(this,arguments,function*(e={}){let t=yield this.version(e);if(!t.pyatv)throw new Error("Unable to find pyatv. Is it installed?");if(F.default.lt(t.pyatv,"0.6.0"))throw new Error("Found pyatv, but unforunately it's too old. Please update pyatv.");try{yield this.find(e)}catch(i){throw new Error(`Unable to scan for devices: ${String(i).replace("Error: ","")}`)}})}static version(){return o(this,arguments,function*(e={}){let t=y(),i=null,n=null;try{i=yield N(t,"atvremote",["--version"],e)}catch(a){l(t,`Unable to get pyatv version due to ${a}`,e)}i&&i.substr(0,10)==="atvremote "&&(i=i.substr(10)),F.default.valid(i)||(l(t,`String "${i}" is not a valid pyatv version, set it to null`,e),i=null);try{let a=(0,I.join)((0,I.dirname)((0,W.fileURLToPath)(g)),"..","..","package.json"),r=JSON.parse(yield z.promises.readFile(a,"utf8"));n=(r==null?void 0:r.version)||null}catch(a){l(t,`Unable to get module version due to ${a}`,e)}return n&&!F.default.valid(n)&&(l(t,`String "${n}" is not a valid module version, set it to null`,e),n=null),h(t),{pyatv:i,module:n}})}static find(){return o(this,arguments,function*(e={}){let t=y(),i=P(e),n=yield N(t,"atvscript",[...i,"scan"],e);if(typeof n!="object"||n.result!=="success"||!Array.isArray(n.devices))throw new Error(`Unable to parse pyatv response: ${JSON.stringify(n,null," ")}`);let a=n.devices.map(r=>{var p,c,u,m,v;return this.device(Object.assign({},e,{host:r.address,id:r.identifier,allIDs:r.all_identifiers,name:r.name,mac:(p=r.device_info)==null?void 0:p.mac,model:(c=r.device_info)==null?void 0:c.model,modelName:(u=r.device_info)==null?void 0:u.model_str,os:(m=r.device_info)==null?void 0:m.operating_system,version:(v=r.device_info)==null?void 0:v.version,services:r.services}))});return h(t),a})}static device(e){return new V(e)}check(){return o(this,arguments,function*(e={}){return s.check(Object.assign({},this.options,e))})}version(){return o(this,arguments,function*(e={}){return s.version(Object.assign({},this.options,e))})}find(){return o(this,arguments,function*(e={}){return s.find(Object.assign({},this.options,e))})}device(e){return s.device(Object.assign({},this.options,e))}};0&&(module.exports={NodePyATVDevice,NodePyATVDeviceEvent,NodePyATVDeviceEvents,NodePyATVDeviceState,NodePyATVExecutableType,NodePyATVInstance,NodePyATVKeys,NodePyATVListenerState,NodePyATVMediaType,NodePyATVPowerState,NodePyATVProtocol,NodePyATVRepeatState,NodePyATVShuffleState});
|
|
7
7
|
//# sourceMappingURL=index.cjs.map
|