UNPKG

54.2 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.pluginEngine=t():e.pluginEngine=t()}(global,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=15)}([function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),s=function(){function e(e){this.profile=e,this.activateService={},this.requestQueue=[]}return Object.defineProperty(e.prototype,"name",{get:function(){return this.profile.name},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"methods",{get:function(){return this.profile.methods},set:function(e){this.profile.methods=e},enumerable:!0,configurable:!0}),e.prototype.activate=function(){this.onActivation&&this.onActivation()},e.prototype.deactivate=function(){this.onDeactivation&&this.onDeactivation()},e.prototype.callPluginMethod=function(e,t){var n=this.currentRequest&&this.currentRequest.path,r=o.getMethodPath(e,n);if(!(r in this))throw new Error("Method "+r+" is not implemented by "+this.profile.name);return this[r].apply(this,t)},e.prototype.addRequest=function(e,t,n){var o=this;return new Promise(function(s,a){o.requestQueue.push(function(){return r(o,void 0,void 0,function(){var r,o,u,c,l,f=this;return i(this,function(i){switch(i.label){case 0:this.currentRequest=e,r=!1,o=function(){r&&a("call to plugin has timed out "+f.profile.name+" - "+t+" - "+JSON.stringify(f.currentRequest)),delete f.currentRequest,f.requestQueue.shift(),0!==f.requestQueue.length&&f.requestQueue[0]()},u=setTimeout(function(){r=!0,o()},1e4),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.callPluginMethod(t,n)];case 2:return c=i.sent(),r?[2]:(delete this.currentRequest,s(c),[3,4]);case 3:return l=i.sent(),a(l),[3,4];case 4:return clearTimeout(u),o(),[2]}})})}),1===o.requestQueue.length&&o.requestQueue[0]()})},e.prototype.askUserPermission=function(e,t){if(!this.currentRequest)return Promise.resolve(!0);if(this.methods.includes(e)){var n=this.currentRequest.from,r=this.name;return this.call("manager","canCall",n,r,e,t)}return Promise.resolve(!1)},e.prototype.createService=function(e,t){return r(this,void 0,void 0,function(){var n;return i(this,function(r){switch(r.label){case 0:if(this.methods&&this.methods.includes(e))throw new Error("A service cannot have the same name as an exposed method");return n=o.createService(e,t),[4,o.activateService(this,n)];case 1:return r.sent(),[2,n]}})})},e.prototype.prepareService=function(e,t){var n=this;return this.activateService[e]=function(){return r(n,void 0,void 0,function(){var n,r;return i(this,function(i){switch(i.label){case 0:if(this.methods&&this.methods.includes(e))throw new Error("A service cannot have the same name as an exposed method");return[4,t()];case 1:return n=i.sent(),r=o.createService(e,n),[4,o.activateService(this,r)];case 2:return i.sent(),delete this.activateService[e],[2,r]}})})}},e.prototype.on=function(e,t,n){throw new Error('Cannot use method "on" from plugin "'+this.name+'". It is not registered in the engine yet.')},e.prototype.once=function(e,t,n){throw new Error('Cannot use method "once" from plugin "'+this.name+'". It is not registered in the engine yet.')},e.prototype.off=function(e,t){throw new Error('Cannot use method "off" from plugin "'+this.name+'". It is not registered in the engine yet.')},e.prototype.call=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return r(this,void 0,void 0,function(){return i(this,function(e){throw new Error('Cannot use method "call" from plugin "'+this.name+'". It is not registered in the engine yet.')})})},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];throw new Error('Cannot use method "emit" from plugin "'+this.name+'". It is not registered in the engine yet.')},e}();t.Plugin=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(19))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(22))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(23))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(24))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(25))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(26))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(31))},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},u=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r};Object.defineProperty(t,"__esModule",{value:!0});var c=n(0);t.defaultGateways={"ipfs://":function(e,t){return"https://"+t+".dyn.plugin.remixproject.org/ipfs/"+e.replace("ipfs://","")},"swarm://":function(e,t){return"https://swarm-gateways.net/bzz-raw://"+e.replace("swarm://","")}},t.transformUrl=function(e,n){var r=Object.keys(t.defaultGateways).find(function(t){return e.startsWith(t)});return r?t.defaultGateways[r](e,n):e};var l=function(e){function t(t){var n=e.call(this,t)||this;return n.id=0,n.pendingRequest={},n}return i(t,e),t.prototype.deactivate=function(){this.loaded=!1,e.prototype.deactivate.call(this)},t.prototype.callPluginMethod=function(e,t){var n=this;void 0===t&&(t=[]);var r=this.id++,i=this.currentRequest,o=this.name,s=new Promise(function(e,t){n.pendingRequest[r]=function(n,r){return r?t(r):e(n)}});return this.postMessage({id:r,action:"request",key:e,payload:t,requestInfo:i,name:o}),s},t.prototype.handshake=function(){return s(this,void 0,void 0,function(){var e;return a(this,function(t){switch(t.label){case 0:return console.log("trying to handshake",this.loaded,this.profile.name),this.loaded?[3,2]:(this.loaded=!0,[4,this.callPluginMethod("handshake",[this.profile.name])]);case 1:e=t.sent(),this.call("manager","updateProfile",this.profile),e&&(this.profile.methods=e),t.label=2;case 2:return[2]}})})},t.prototype.getMessage=function(e){return s(this,void 0,void 0,function(){var t,n,r,i,s,c,l,f,h,p,d,v=this;return a(this,function(a){switch(a.label){case 0:if("request"===e.action&&"handshake"===e.key)return[2,this.handshake()];switch(e.action){case"on":case"listen":return[3,1];case"off":return[3,2];case"once":return[3,3];case"emit":case"notification":return[3,4];case"call":case"request":return[3,5];case"response":return[3,10]}return[3,11];case 1:return t=e.name,n=e.key,"notification",this.on(t,n,function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return v.postMessage({action:"notification",name:t,key:n,payload:e})}),[3,12];case 2:return r=e.name,i=e.key,this.off(r,i),[3,12];case 3:return s=e.name,c=e.key,"notification",this.once(s,c,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.postMessage({action:"notification",name:s,key:c,payload:e})}),[3,12];case 4:return e.payload?(this.emit.apply(this,u([e.key],e.payload)),[3,12]):[3,12];case 5:l="response",a.label=6;case 6:return a.trys.push([6,8,,9]),[4,this.call.apply(this,u([e.name,e.key],e.payload))];case 7:return p=a.sent(),d=void 0,this.postMessage(o(o({},e),{action:l,payload:p,error:d})),[3,9];case 8:return f=a.sent(),p=void 0,d=f.message,this.postMessage(o(o({},e),{action:l,payload:p,error:d})),[3,9];case 9:return[3,12];case 10:return h=e.id,p=e.payload,d=e.error,this.pendingRequest[h](p,d),delete this.pendingRequest[h],[3,12];case 11:throw new Error("Message should be a notification, request or response");case 12:return[2]}})})},t}(c.Plugin);t.ExternalPlugin=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(27))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(28))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(29))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(30))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMethodPath=function(e,t){if(!t)return e;var n=t.split(".");return n.shift(),n.push(e),n.join(".")},t.getRootPath=function(e){return e.split(".").shift()}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},s=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r};Object.defineProperty(t,"__esModule",{value:!0});var a=n(13),u=function(){function e(){}return e.prototype.emit=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(t=this.plugin).emit.apply(t,s([e],n))},e.prototype.createService=function(e,t){return i(this,void 0,void 0,function(){var n,r;return o(this,function(i){switch(i.label){case 0:if(this.methods.includes(e))throw new Error("A service cannot have the same name as an exposed method");return n=this.path+"."+e,r=l(n,t),[4,f(this.plugin,r)];case 1:return i.sent(),[2,r]}})})},e.prototype.prepareService=function(e,t){var n=this;if(this.methods.includes(e))throw new Error("A service cannot have the same name as an exposed method");var r=this.path+"."+e;this.plugin.activateService[r]=function(){return i(n,void 0,void 0,function(){var e,n;return o(this,function(i){switch(i.label){case 0:return e=t(),n=l(r,e),[4,f(this.plugin,n)];case 1:return i.sent(),delete this.plugin.activateService[r],[2,n]}})})}},e}();function c(e){if(e.methods){for(var n=0,r=e.methods;n<r.length;n++){var i=r[n];if(!(i in e))throw new Error("Method "+i+" is not part of serivce")}return e.methods}if(t.isPluginService(e)){var o=Object.getPrototypeOf(e);return Object.getOwnPropertyNames(o).filter(function(e){return"constructor"!==e&&!e.startsWith("_")})}return Object.getOwnPropertyNames(e).filter(function(t){return"function"==typeof e[t]&&!t.startsWith("_")})}function l(e,n){if(n.path&&a.getRootPath(n.path)!==e)throw new Error("Service path "+n.path+" is different from the one provided: "+e);for(var i=c(n),o=0,s=i;o<s.length;o++){var u=s[o];if(!(u in n))throw new Error("Method "+u+" is not part of service "+e)}return t.isPluginService(n)?(n.methods||(n.methods=i),n):r(r({},n),{methods:i,path:e})}function f(e,t){e.methods=s(e.methods||[],t.methods);for(var n=0,r=c(t);n<r.length;n++){var i=r[n];e[t.path+"."+i]=t[i].bind(t)}return e.call("manager","updateProfile",{methods:e.methods})}t.PluginService=u,t.isPluginService=function(e){return e instanceof u},t.getMethods=c,t.createService=l,t.activateService=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(16))},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(17)),r(n(39)),r(n(14))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(18))},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r};Object.defineProperty(t,"__esModule",{value:!0});var s=n(1),a=function(){function e(e){var t=this;this.manager=e,this.plugins={},this.events={},this.listeners={},this.isLoaded=!1,this.plugins.manager=e,this.manager.engineActivatePlugin=function(e){return t.activatePlugin(e)},this.manager.engineDeactivatePlugin=function(e){return t.deactivatePlugin(e)},e.activatePlugin("manager").then(function(){t.isLoaded=!0,t.managerLoaded&&t.managerLoaded()})}return e.prototype.onload=function(e){return r(this,void 0,void 0,function(){var t=this;return i(this,function(n){return[2,new Promise(function(n,r){t.isLoaded?(n(),e&&e()):t.managerLoaded=function(){n(),e&&e(),delete t.managerLoaded}})]})})},e.prototype.broadcast=function(e,t){for(var n=this,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var o=s.listenEvent(e,t);this.listeners[o]&&(this.listeners[o]||[]).forEach(function(i){var s;if(!n.events[i][o])throw new Error("Plugin "+i+" should be listening on event "+t+" from "+e+". But no callback have been found");(s=n.events[i])[o].apply(s,r)})},e.prototype.addListener=function(e,t,n,r){var i=s.listenEvent(t,n);this.events[e][i]||(this.events[e][i]=r),this.listeners[i]||(this.listeners[i]=[]),this.listeners[i].includes(e)||this.listeners[i].push(e)},e.prototype.removeListener=function(e,t,n){var r=s.listenEvent(t,n);this.listeners[r]=this.listeners[r].filter(function(t){return t!==e}),delete this.events[e][r]},e.prototype.listenOnce=function(e,t,n,r){var i=this;this.addListener(e,t,n,function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];r.apply(void 0,o),i.removeListener(e,t,n)})},e.prototype.callMethod=function(e,t,n){for(var o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return r(this,void 0,void 0,function(){var r,s,a,u,c,l,f;return i(this,function(i){switch(i.label){case 0:if(r=t.split(".").shift(),!this.plugins[r])throw new Error("Cannot call "+r+" from "+e+", because "+r+" is not registered");return[4,Promise.all([this.manager.getProfile(r),this.manager.getProfile(e)])];case 1:return s=i.sent(),a=s[0],u=s[1],[4,this.manager.isActive(r)];case 2:return i.sent()?[3,6]:[4,this.manager.canActivate(u,a)];case 3:return i.sent()?[4,this.manager.toggleActive(r)]:[3,5];case 4:return i.sent(),[3,6];case 5:throw new Error(u.name+" cannot call "+n+" of "+r+", because "+r+" is not activated yet");case 6:if(!a.methods.includes(n))throw c='Cannot call method "'+n+'" of "'+r+'" from "'+e+'", because "'+n+'" is not exposed.',l="Here is the list of exposed methods: "+a.methods.map(function(e){return'"'+e+'"'}).join(","),new Error(c+" "+l);return f={from:e,path:t},[2,this.plugins[r].addRequest(f,n,o)]}})})},e.prototype.createApp=function(e){return r(this,void 0,void 0,function(){var t,n=this;return i(this,function(r){switch(r.label){case 0:return t=Object.keys(this.plugins).map(function(e){return n.manager.getProfile(e)}),[4,Promise.all(t)];case 1:return[2,r.sent().reduce(function(t,r){return t[r.name]=(r.methods||[]).reduce(function(t,i){return t[i]=function(){for(var t=[],s=0;s<arguments.length;s++)t[s]=arguments[s];return n.callMethod.apply(n,o([e,r.name,i],t))},t},{on:function(t,i){return n.addListener(e,r.name,t,i)},once:function(t,i){return n.listenOnce(e,r.name,t,i)},off:function(t){return n.removeListener(e,r.name,t)},profile:r}),t},{})]}})})},e.prototype.activatePlugin=function(e){return r(this,void 0,void 0,function(){var t,n,r,s=this;return i(this,function(i){switch(i.label){case 0:if(!this.plugins[e])throw new Error("Cannot active plugin "+e+" because it's not registered yet");return[4,this.manager.isActive(e)];case 1:return i.sent()?[2]:(t=this.plugins[e],this.events[e]={},t.on=function(t,n,r){s.addListener(e,t,n,r)},t.once=function(t,n,r){s.listenOnce(e,t,n,r)},t.off=function(t,n){s.removeListener(e,t,n)},t.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];s.broadcast.apply(s,o([e,t],n))},t.call=function(t,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return s.callMethod.apply(s,o([e,t,n],r))},n=t,r="app",[4,this.createApp(e)]);case 2:return n[r]=i.sent(),t.createApp=function(){return s.createApp(e)},[4,t.activate()];case 3:return i.sent(),[2]}})})},e.prototype.deactivatePlugin=function(e){return r(this,void 0,void 0,function(){var t,n=this;return i(this,function(r){switch(r.label){case 0:if(!this.plugins[e])throw new Error("Cannot deactive plugin "+e+" because it's not registered yet");return[4,this.manager.isActive(e)];case 1:return r.sent()?[4,(t=this.plugins[e]).deactivate()]:[2];case 2:return r.sent(),this.updateErrorHandler(t),delete t.app,delete t.createApp,delete this.events[e],Object.keys(this.listeners).forEach(function(t){n.listeners[t].forEach(function(r,i){r===e&&n.listeners[t].splice(i,1)})}),[2]}})})},e.prototype.updateErrorHandler=function(e){var t=function(e){return"Plugin "+name+" is currently deactivated. "+e+". Activate "+name+" first."};e.call=function(e,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];throw new Error(t("It cannot call method "+n+" of plugin "+e+"."))},e.on=function(e,n){throw new Error(t("It cannot listen on event "+n+" of plugin "+e+"."))},e.once=function(e,n){throw new Error(t("It cannot listen on event "+n+" of plugin "+e+"."))},e.off=function(e,n){throw new Error(t("All event listeners are already removed."))},e.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];throw new Error(t("It cannot emit the event "+e))}},e.prototype.register=function(e){var t=this,n=function(e){if(t.plugins[e.name])throw new Error("Plugin "+e.name+" is already register.");return t.plugins[e.name]=e,t.manager.addProfile(e.profile),t.updateErrorHandler(e),e.onRegistration&&e.onRegistration(),t.onRegistration&&t.onRegistration(e),e.name};return Array.isArray(e)?e.map(function(e){return n(e)}):n(e)},e.prototype.isRegistered=function(e){return!!this.plugins[e]},e}();t.Engine=a},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(20)),r(n(21)),r(n(36)),r(n(13)),r(n(14))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.callEvent=function(e,t,n){return"["+e+"] "+t+"-"+n},t.listenEvent=function(e,t){return"["+e+"] "+t}},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(2)),r(n(3)),r(n(4)),r(n(5)),r(n(6)),r(n(9)),r(n(10)),r(n(11)),r(n(12)),r(n(7)),r(n(32)),r(n(35))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.compilerProfile={name:"compiler",methods:["compile","getCompilationResult"],events:["compilationFinished"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.editorProfile={name:"editor",methods:["discardHighlight","highlight"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filSystemProfile={name:"fs",methods:["getCurrentFile","getFile","getFolder","setFile","switchFile"],events:["currentFileChanged"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.networkProfile={name:"network",methods:["addNetwork","detectNetwork","getEndpoint","getNetworkProvider","removeNetwork"],events:["providerChanged"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.udappProfile={name:"udapp",methods:["createVMAccount","getAccounts","sendTransaction"],events:["newTransaction"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.themeProfile={name:"theme",methods:[],events:["themeChanged"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unitTestProfile={name:"unitTest",methods:["testFromPath","testFromSource"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.contentImportProfile={name:"contentImport",methods:["resolve"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsProfile={name:"settings",methods:["getGithubAccessToken"]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluginManagerProfile={name:"manager",methods:["getProfile","updateProfile","activatePlugin","deactivatePlugin","canCall"]}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o=n(4),s=n(3),a=n(5),u=n(6),c=n(9),l=n(10),f=n(11),h=n(12),p=n(33),d=n(7);t.remixApi=Object.freeze({manager:d.pluginManagerProfile,solidity:r(r({},i.compilerProfile),{name:"solidity"}),fileManager:r(r({},o.filSystemProfile),{name:"fileManager"}),solidityUnitTesting:r(r({},l.unitTestProfile),{name:"solidityUnitTesting"}),editor:s.editorProfile,network:a.networkProfile,udapp:u.udappProfile,contentImport:f.contentImportProfile,settings:h.settingsProfile,theme:c.themeProfile}),t.remixProfiles=Object.freeze({manager:d.pluginManagerProfile,solidity:r(r({},i.compilerProfile),{name:"solidity"}),fileManager:r(r({},o.filSystemProfile),{name:"fileManager"}),git:r(r({},p.gitProfile),{name:"git"}),solidityUnitTesting:r(r({},l.unitTestProfile),{name:"solidityUnitTesting"}),editor:s.editorProfile,network:a.networkProfile,udapp:u.udappProfile,contentImport:f.contentImportProfile,settings:h.settingsProfile,theme:c.themeProfile})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(34))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitProfile={name:"remixd.git",methods:["clone","checkout","init","add","commit","fetch","pull","push","reset","status","remote","log"]}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),o=n(4),s=n(3),a=n(5),u=n(6),c=n(7);t.standardProfiles=Object.freeze({manager:c.pluginManagerProfile,solidity:r(r({},i.compilerProfile),{name:"solidity"}),fileManager:r(r({},o.filSystemProfile),{name:"fileManager"}),editor:s.editorProfile,network:a.networkProfile,udapp:u.udappProfile})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(37))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(38))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.boxProfile={name:"box",methods:["login","isEnabled","getUserAddress","openSpace","closeSpace","isSpaceOpened","getSpacePrivateValue","setSpacePrivateValue","getSpacePublicValue","setSpacePublicValue","getSpacePublicData","getSpaceName"],events:["enabled","loggedIn","loggedOut","spaceClosed","spaceOpened"]}},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(0)),r(n(40)),r(n(41)),r(n(42)),r(n(43)),r(n(44)),r(n(45)),r(n(46))},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},s=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r};Object.defineProperty(t,"__esModule",{value:!0});var a=function(e){function t(t){var n=Array.from(new Set(s(t.methods||[],["currentFocus","focus","addView","removeView"])));return e.call(this,o(o({},t),{methods:n}))||this}return i(t,e),t}(n(0).Plugin);t.HostPlugin=a},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(8),u=function(e){function t(t){var n=e.call(this,t)||this;return n.profile=t,n.listener=["message",function(e){return n.getEvent(e)},!1],n.iframe=document.createElement("iframe"),n}return i(t,e),t.prototype.activate=function(){return o(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.call(this.profile.location,"addView",this.profile,this.render())];case 1:return t.sent(),e.prototype.activate.call(this),[2]}})})},t.prototype.deactivate=function(){this.iframe.remove(),window.removeEventListener.apply(window,this.listener),this.call(this.profile.location,"removeView",this.profile),e.prototype.deactivate.call(this)},t.prototype.getEvent=function(e){return o(this,void 0,void 0,function(){var t;return s(this,function(n){return e.source!==this.source?[2]:e.origin!==this.origin?[2]:(t=e.data,this.getMessage(t),[2])})})},t.prototype.postMessage=function(e){if(!this.source)throw new Error("No window attached to Iframe yet");this.source.postMessage(e,this.origin)},t.prototype.render=function(){var e=this;if(this.iframe.contentWindow)throw new Error(this.name+" plugin is already rendered");return this.iframe.setAttribute("sandbox","allow-popups allow-scripts allow-same-origin allow-forms allow-top-navigation"),this.iframe.setAttribute("seamless","true"),this.iframe.setAttribute("id","plugin-"+this.name),this.iframe.src=a.transformUrl(this.profile.url,this.name),this.iframe.onload=function(){return o(e,void 0,void 0,function(){return s(this,function(e){if(!this.iframe.contentWindow)throw new Error(this.name+" plugin is cannot find url "+this.profile.url);return this.origin=new URL(this.iframe.src).origin,this.source=this.iframe.contentWindow,window.addEventListener.apply(window,this.listener),this.handshake(),[2]})})},this.iframe},t}(a.ExternalPlugin);t.IframePlugin=u},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},a=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,i++)r[i]=o[s];return r};Object.defineProperty(t,"__esModule",{value:!0});var u=n(0);function c(e){return!!e.location}t.isViewLibrary=c;var l=function(e){function t(t,n){var r=e.call(this,n)||this;if(r.library=t,r.profile=n,n.methods.forEach(function(e){if(!t[e])throw new Error("Method "+e+" is exposed by LibraryPlugin "+n.name+". But library doesn't expose this method")}),r.isView=c(n),r.isView&&!r.render)throw new Error("Profile "+n.name+" define the location "+n.location+', but method "render" is not implemented');return r}return i(t,e),t.prototype.activate=function(){return o(this,void 0,void 0,function(){var t=this;return s(this,function(n){switch(n.label){case 0:return this.isView?[4,this.call(this.profile.location,"addView",this.profile,this.render())]:[3,2];case 1:n.sent(),n.label=2;case 2:if(e.prototype.activate.call(this),this.profile.notifications){if(!this.library.events||!this.library.events.emit)throw new Error('"events" object from Library of plugin '+this.name+' should implement "emit"');Object.keys(this.profile.notifications).forEach(function(e){t.profile.notifications[e].forEach(function(n){t.on(e,n,function(r){var i;return(i=t.library.events).emit.apply(i,a(["["+e+"] "+n],r))})})})}if(this.profile.events){if(!this.library.events||!this.library.events.emit)throw new Error('"events" object from Library of plugin '+this.name+' should implement "emit"');this.profile.events.forEach(function(e){t.library.events.on(e,function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t.emit.apply(t,a([e],n))})})}return[2]}})})},t.prototype.deactivate=function(){var t=this;this.isView&&this.call(this.profile.location,"removeView",this.profile),this.profile.notifications&&Object.keys(this.profile.notifications).forEach(function(e){t.profile.notifications[e].forEach(function(n){return t.off(e,n)})}),this.profile.events&&this.library.events.off&&this.profile.events.forEach(function(e){return t.library.events.off(e)}),e.prototype.deactivate.call(this)},t.prototype.callPluginMethod=function(e,t){var n;if(!this.library[e])throw new Error("LibraryPlugin "+this.name+" doesn't expose method "+e);return(n=this.library)[e].apply(n,t)},t}(u.Plugin);t.LibraryPlugin=l},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(0);t.isView=function(e){return!!e.location};var u=function(e){function t(t){var n=e.call(this,t)||this;return n.profile=t,n}return i(t,e),t.prototype.activate=function(){return o(this,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,this.call(this.profile.location,"addView",this.profile,this.render())];case 1:return t.sent(),e.prototype.activate.call(this),[2]}})})},t.prototype.deactivate=function(){this.call(this.profile.location,"removeView",this.profile),e.prototype.deactivate.call(this)},t}(a.Plugin);t.ViewPlugin=u},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(8),c=function(e){function t(t,n){void 0===n&&(n={});var r=e.call(this,t)||this;return r.profile=t,r.listener=["message",function(e){return r.getEvent(e)},!1],r.reconnectOnclose=["close",function(){return r.reconnect()},!1],r.options={reconnectDelay:1e3},r.options=o(o({},r.options),n),r}return i(t,e),t.prototype.activate=function(){return s(this,void 0,void 0,function(){var t;return a(this,function(n){return this.connect(),(t=this.socket).addEventListener.apply(t,this.reconnectOnclose),e.prototype.activate.call(this),[2]})})},t.prototype.deactivate=function(){var t,n;(t=this.socket).removeEventListener.apply(t,this.reconnectOnclose),(n=this.socket).removeEventListener.apply(n,this.listener),this.socket.close(),e.prototype.deactivate.call(this)},t.prototype.reconnect=function(){var e=this;this.loaded=!1,setTimeout(function(){return e.connect()},this.options.reconnectDelay)},t.prototype.connect=function(){var e=this,t=u.transformUrl(this.profile.url,this.profile.name);this.socket=new WebSocket(t),this.socket.addEventListener("open",function(){return s(e,void 0,void 0,function(){var e;return a(this,function(t){return(e=this.socket).addEventListener.apply(e,this.listener),this.handshake(),[2]})})})},t.prototype.getEvent=function(e){return s(this,void 0,void 0,function(){var t;return a(this,function(n){return t=JSON.parse(e.data),this.getMessage(t),[2]})})},t.prototype.postMessage=function(e){if(this.socket.readyState!==this.socket.OPEN)throw new Error("Websocket connection is not open yet");this.socket.send(JSON.stringify(e))},t}(u.ExternalPlugin);t.WebsocketPlugin=c},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var u=n(1),c=n(0);t.managerMethods=["getProfile","updateProfile","activatePlugin","deactivatePlugin","canCall"];var l=function(e){function n(n){void 0===n&&(n=u.pluginManagerProfile);var r=e.call(this,n)||this;return r.profiles={},r.actives=[],r.methods=t.managerMethods,r.profiles[n.name]=n,r}return i(n,e),Object.defineProperty(n.prototype,"requestFrom",{get:function(){return this.currentRequest?this.currentRequest.from:"manager"},enumerable:!0,configurable:!0}),n.prototype.getProfile=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,this.profiles[e]]})})},n.prototype.updateProfile=function(e){if(e){if(e.name&&e.name!==this.requestFrom)throw new Error("A plugin cannot change its name.");var t=this.requestFrom;if(!this.profiles[t])throw new Error("Plugin "+t+" is not register, you cannot update it's profile.");if(e.url&&e.url!==this.profiles[t].url)throw new Error("Url from Profile cannot be updated.");this.profiles[t]=o(o({},this.profiles[t]),e),this.emit("profileUpdated",this.profiles[t])}},n.prototype.addProfile=function(e){if(this.profiles[e.name])throw new Error("Plugin "+e.name+" already exist");this.profiles[e.name]=e,this.emit("profileAdded",e),this.onProfileAdded&&this.onProfileAdded(e)},n.prototype.isActive=function(e){return s(this,void 0,void 0,function(){return a(this,function(t){return[2,this.actives.includes(e)]})})},n.prototype.activatePlugin=function(e){return s(this,void 0,void 0,function(){var t,n=this;return a(this,function(r){return t=function(e){return s(n,void 0,void 0,function(){var t,n,r;return a(this,function(i){switch(i.label){case 0:return[4,this.isActive(e)];case 1:return i.sent()?[2]:[4,Promise.all([this.getProfile(e),this.getProfile(this.requestFrom)])];case 2:return t=i.sent(),n=t[0],r=t[1],[4,this.canActivate(r,n)];case 3:return i.sent()?[4,this.toggleActive(e)]:[3,5];case 4:return i.sent(),[3,6];case 5:throw new Error("Plugin "+this.requestFrom+" has no right to activate plugin "+e);case 6:return[2]}})})},[2,Array.isArray(e)?Promise.all(e.map(t)):t(e)]})})},n.prototype.deactivatePlugin=function(e){return s(this,void 0,void 0,function(){var t,n=this;return a(this,function(r){return t=function(e){return s(n,void 0,void 0,function(){var t,n,r;return a(this,function(i){switch(i.label){case 0:return[4,this.isActive(e)];case 1:return i.sent()?[4,Promise.all([this.getProfile(e),this.getProfile(this.requestFrom)])]:[2];case 2:return t=i.sent(),n=t[0],r=t[1],[4,this.canDeactivate(r,n)];case 3:return i.sent()?[4,this.toggleActive(e)]:[3,5];case 4:return i.sent(),[3,6];case 5:throw new Error("Plugin "+this.requestFrom+" has no right to deactivate plugin "+e);case 6:return[2]}})})},[2,Array.isArray(e)?Promise.all(e.map(t)):t(e)]})})},n.prototype.toggleActive=function(e){return s(this,void 0,void 0,function(){var t,n=this;return a(this,function(r){return t=function(e){return s(n,void 0,void 0,function(){var t,n,r;return a(this,function(i){switch(i.label){case 0:return[4,Promise.all([this.isActive(e),this.getProfile(e)])];case 1:return t=i.sent(),n=t[0],r=t[1],n?[4,this.engineDeactivatePlugin(e)]:[3,3];case 2:return i.sent(),this.actives=this.actives.filter(function(t){return t!==e}),this.emit("pluginDeactivated",r),this.onPluginDeactivated&&this.onPluginDeactivated(r),[3,5];case 3:return[4,this.engineActivatePlugin(e)];case 4:i.sent(),this.actives.push(e),this.emit("pluginActivated",r),this.onPluginActivated&&this.onPluginActivated(r),i.label=5;case 5:return[2]}})})},[2,Array.isArray(e)?Promise.all(e.map(t)):t(e)]})})},n.prototype.canActivate=function(e,t){return s(this,void 0,void 0,function(){return a(this,function(e){return[2,!0]})})},n.prototype.canDeactivate=function(e,t){return s(this,void 0,void 0,function(){return a(this,function(t){return"manager"===e.name?[2,!0]:[2,!1]})})},n.prototype.canCall=function(e,t,n,r){return s(this,void 0,void 0,function(){return a(this,function(e){return[2,!0]})})},n}(c.Plugin);t.PluginManager=l},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(8),u=n(47),c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.listener=["message",function(e){return t.getMessage(e)}],t}return i(t,e),t.prototype.activate=function(){return o(this,void 0,void 0,function(){var t;return s(this,function(n){return this.process=u.fork(this.profile.url),(t=this.process).on.apply(t,this.listener),e.prototype.activate.call(this),[2]})})},t.prototype.deactivate=function(){var t;(t=this.process).off.apply(t,this.listener),this.process.disconnect(),this.process.kill(),e.prototype.deactivate.call(this)},t.prototype.postMessage=function(e){var t;if(!(null===(t=this.process)||void 0===t?void 0:t.connected))throw new Error('Child process from plugin "'+this.name+'" is not yet connected');this.process.send(e)},t}(a.ExternalPlugin);t.ChildProcessPlugin=c},function(e,t){e.exports=require("child_process")}])});
\No newline at end of file