TelegramPWA/dist/8967.99acf133851b2f244fc6.js
Alexander Zinchuk 6fd1d0c598 [Build]
2025-09-19 14:39:00 +02:00

2 lines
2.3 KiB
JavaScript

"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[8967],{11348:(e,t,s)=>{s.r(t),s.d(t,{Child:()=>r,Command:()=>o,EventEmitter:()=>i,open:()=>a});var n=s(55962);class i{constructor(){this.eventListeners=Object.create(null)}addListener(e,t){return this.on(e,t)}removeListener(e,t){return this.off(e,t)}on(e,t){return e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t],this}once(e,t){const s=n=>{this.removeListener(e,s),t(n)};return this.addListener(e,s)}off(e,t){return e in this.eventListeners&&(this.eventListeners[e]=this.eventListeners[e].filter(e=>e!==t)),this}removeAllListeners(e){return e?delete this.eventListeners[e]:this.eventListeners=Object.create(null),this}emit(e,t){if(e in this.eventListeners){const s=this.eventListeners[e];for(const e of s)e(t);return!0}return!1}listenerCount(e){return e in this.eventListeners?this.eventListeners[e].length:0}prependListener(e,t){return e in this.eventListeners?this.eventListeners[e].unshift(t):this.eventListeners[e]=[t],this}prependOnceListener(e,t){const s=n=>{this.removeListener(e,s),t(n)};return this.prependListener(e,s)}}class r{constructor(e){this.pid=e}async write(e){await(0,n.invoke)("plugin:shell|stdin_write",{pid:this.pid,buffer:e})}async kill(){await(0,n.invoke)("plugin:shell|kill",{cmd:"killChild",pid:this.pid})}}class o extends i{constructor(e,t=[],s){super(),this.stdout=new i,this.stderr=new i,this.program=e,this.args="string"==typeof t?[t]:t,this.options=s??{}}static create(e,t=[],s){return new o(e,t,s)}static sidecar(e,t=[],s){const n=new o(e,t,s);return n.options.sidecar=!0,n}async spawn(){const e=this.program,t=this.args,s=this.options;"object"==typeof t&&Object.freeze(t);const i=new n.Channel;return i.onmessage=e=>{switch(e.event){case"Error":this.emit("error",e.payload);break;case"Terminated":this.emit("close",e.payload);break;case"Stdout":this.stdout.emit("data",e.payload);break;case"Stderr":this.stderr.emit("data",e.payload)}},await(0,n.invoke)("plugin:shell|spawn",{program:e,args:t,options:s,onEvent:i}).then(e=>new r(e))}async execute(){const e=this.program,t=this.args,s=this.options;return"object"==typeof t&&Object.freeze(t),await(0,n.invoke)("plugin:shell|execute",{program:e,args:t,options:s})}}async function a(e,t){await(0,n.invoke)("plugin:shell|open",{path:e,with:t})}}}]);
//# sourceMappingURL=8967.99acf133851b2f244fc6.js.map