diff --git a/jsstp.min.js b/jsstp.min.js index fe25182..35e150c 100644 --- a/jsstp.min.js +++ b/jsstp.min.js @@ -1 +1 @@ -class sstp_info_t{#head;#unknown_lines;constructor(t,s,e){if(this.set_head(t),this.#unknown_lines=e,s)if(s.keys)for(var n of s.keys())this[n]=s.get(n);else if("object"==typeof s)for(var i in s)this[i]=s[i];else console.error("sstp_info_t: info_body is not a Map or object: "+typeof s)}static from_string(t){var s=t.split("\r\n")[0],e=new Map,n=t.split("\r\n"),i=(n.shift(),[]),_=[": ",String.fromCharCode(1)];for(let t=0;t{fetch(this.#host,n).then(function(t){200!=t.status?e(t.status):t.text().then(function(t){s(sstp_info_t.from_string(t))})})};if(s&&t(s,function(){}),null==s)return new Promise(t)}costom_send(t,s,e){if("object"==typeof s){var n,i,_=new sstp_info_t;for(n in _.set_head(t),this.#default_info)_[n]=this.#default_info[n];for(i in s)_[i]=s[i];return this.#base_post(_.to_string(),e)}console.error("jsstp.send: wrong type of info: "+typeof s)}SEND(t,s){return this.costom_send("SEND SSTP/1.4",t,s)}NOTIFY(t,s){return this.costom_send("NOTIFY SSTP/1.1",t,s)}COMMUNICATE(t,s){return this.costom_send("COMMUNICATE SSTP/1.1",t,s)}EXECUTE(t,s){return this.costom_send("EXECUTE SSTP/1.2",t,s)}GIVE(t,s){return this.costom_send("GIVE SSTP/1.1",t,s)}by_type(type){return eval("this."+type).bind(this)}async has_event(t,s="external"){t=(await this.SEND({Event:"Has_Event",Reference0:t,Reference1:s})).get_passthrough("Result");return!!t&&"0"!=t}async get_supported_events(){var t=await this.SEND({Event:"Get_Supported_Events"}),s=t.get_passthrough("local"),t=t.get_passthrough("external");return{local:s?s.split(","):[],external:t?t.split(","):[]}}async get_fmo_infos(){let t={};try{t=await this.EXECUTE({Command:"GetFMO"})}catch(t){}return new sstp_fmo_info_t(t)}async available(){return(await this.get_fmo_infos()).available()}async new_event_queryer(){var t=new ghost_events_queryer_t(this);return await t.init(),t}}var jsstp=new jsstp_t,jsttp=jsstp,jsttp_t=jsstp_t,sttp_info_t=sstp_info_t,sttp_fmo_info_t=sstp_fmo_info_t; \ No newline at end of file +class sstp_info_t{#t;#e;constructor(t,e,s){if(this.set_head(t),this.#e=s,e)if(e.keys)for(let t of e.keys())this[t]=e.get(t);else if("object"==typeof e)for(let t in e)this[t]=e[t];else console.error("sstp_info_t: info_body is not a Map or object: "+typeof e)}static from_string(t){let e=t.split("\r\n")[0],s=new Map,n=t.split("\r\n");n.shift();let i=[],_=[": ",String.fromCharCode(1)];for(let t=0;t{fetch(this.#a,s).then((function(s){200!=s.status?e(s.status):s.text().then((function(e){t(sstp_info_t.from_string(e))}))}))};if(e&&n(e,(function(){})),null==e)return new Promise(n)}costom_send(t,e,s){if("object"==typeof e){let n=new sstp_info_t;n.set_head(t);for(let t in this.#r)n[t]=this.#r[t];for(let t in e)n[t]=e[t];return this.#l(n.to_string(),s)}console.error("jsstp.send: wrong type of info: "+typeof e)}SEND(t,e){return this.costom_send("SEND SSTP/1.4",t,e)}NOTIFY(t,e){return this.costom_send("NOTIFY SSTP/1.1",t,e)}COMMUNICATE(t,e){return this.costom_send("COMMUNICATE SSTP/1.1",t,e)}EXECUTE(t,e){return this.costom_send("EXECUTE SSTP/1.2",t,e)}GIVE(t,e){return this.costom_send("GIVE SSTP/1.1",t,e)}by_type(type){return eval("this."+type).bind(this)}async has_event(t,e="external"){const s=(await this.SEND({Event:"Has_Event",Reference0:t,Reference1:e})).get_passthrough("Result");return!!s&&"0"!=s}async get_supported_events(){const t=await this.SEND({Event:"Get_Supported_Events"}),e=t.get_passthrough("local"),s=t.get_passthrough("external");return{local:e?e.split(","):[],external:s?s.split(","):[]}}async get_fmo_infos(){let t={};try{t=await this.EXECUTE({Command:"GetFMO"})}catch(t){}return new sstp_fmo_info_t(t)}async available(){return(await this.get_fmo_infos()).available()}async new_event_queryer(){let t=new ghost_events_queryer_t(this);return await t.init(),t}}var jsstp=new jsstp_t,jsttp=jsstp,jsttp_t=jsstp_t,sttp_info_t=sstp_info_t,sttp_fmo_info_t=sstp_fmo_info_t; \ No newline at end of file