@websh/web-shell-app
Version:
Client library for WebShell apps
6 lines • 3.13 kB
JavaScript
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"U5b/":[function(require,module,exports) {
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RemoteSlavePort=void 0;class t{constructor(t){this._port=null,this._manifest={},this._commands={},this._handlers={};const s=async({cmd:t,args:s,rsvp:e})=>{try{if(t||this.throw("slave-specify-command"),!this._commands[t])return void(e&&this.throw("slave-command-not-supported",{command:t}));const a=await this._commands[t].call(this,s),[o,n]=[].concat(a);this._port.postMessage({result:o,re:e},n)}catch(r){console.log("app error",r),this._port.postMessage({error:r.error||"command-failed",message:r.message||String(r),data:r.data||{},re:e})}},e=r=>{r.source===window.parent&&r.data&&r.data.port&&"connect"!==!r.data[t]&&(this._port=r.data.port,this._port.postMessage({[t]:"connected",manifest:this._manifest}),window.removeEventListener("message",e),this._port.onmessage=(t=>{s(t.data)}))};window.addEventListener("message",e)}manifest(t){return this._manifest=t,this}on(t,s){return this._handlers[t]=this._handlers[t]||[],this._handlers[t].push(s),this}command(t,s){return this._commands[t]=s,this}commands(t){for(var s in t)this.command(t,t[i])}trigger(t,s={}){return port.postMessage({event:t,data:s}),this}throw(t,s={}){throw{error:t,data:s}}}exports.RemoteSlavePort=t;
},{}],"aESH":[function(require,module,exports) {
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.command=exports.manifest=exports.WebShellApp=void 0;var e=require("@websh/remote-slave-port");const t=new e.RemoteSlavePort("SOUTH-TOOTH");exports.WebShellApp=t;const o=t.manifest.bind(t);exports.manifest=o;const n=t.command.bind(t);exports.command=n,t.command("proc-close",()=>!0),t.command("proc-init",()=>!0),window.addEventListener("load",()=>{document.addEventListener("focus",e=>{t.lastActiveElement=e.target},!0),window.addEventListener("focus",e=>{t.lastActiveElement&&document.activeElement===document.body&&requestIdleCallback(()=>t.lastActiveElement.focus())})});
},{"@websh/remote-slave-port":"U5b/"}]},{},["aESH"], "WebShellApp")
//# sourceMappingURL=/web-shell-app.js.map