UNPKG

@osjs/common

Version:
45 lines 27.9 kB
!function(t,e){for(var n in e)t[n]=e[n]}(exports,function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=16)}([function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(e)}t.exports=n},function(t,e,n){global,t.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e,n){t.exports=n(3)},function(t,e,n){"use strict";n.r(e),n.d(e,"EventEmitter",(function(){return c}));var r=n(0),o=n.n(r),i=n(1),u=n.n(i),a=function(t){return t instanceof Array?t:String(t).replace(/\s+/g,"").split(",")},c=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined";o()(this,t),this.name=e,this.events={}}return u()(t,[{key:"destroy",value:function(){this.events={}}},{key:"on",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r=r||{},"function"!=typeof e)throw new TypeError("Invalid callback");return a(t).forEach((function(t){n.events[t]||(n.events[t]=[]),n.events[t].push({callback:e,options:r})})),this}},{key:"once",value:function(t,e){return this.on(t,e,{once:!0})}},{key:"off",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return a(t).filter((function(t){return!!e.events[t]})).forEach((function(t){if(n)for(var o=e.events[t].length;o--;){var i=e.events[t][o];(!i.options.persist||r)&&i.callback===n&&e.events[t].splice(o,1)}else e.events[t]=r?[]:e.events[t].filter((function(t){return!0===t.options.persist}))})),this}},{key:"emit",value:function(t){for(var e=this,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return a(t).forEach((function(t){if(e.events[t])for(var n=e.events[t].length;n--;){var o=e.events[t][n],i=o.options,u=o.callback;try{u.apply(void 0,r)}catch(t){console.warn(t)}i&&i.once&&e.events[t].splice(n,1)}})),this}}]),t}()}])},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e,n){"use strict";var r=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===o}(t)}(t)};var o="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(t,e){return!1!==e.clone&&e.isMergeableObject(t)?f((n=t,Array.isArray(n)?[]:{}),t,e):t;var n}function u(t,e,n){return t.concat(e).map((function(t){return i(t,n)}))}function a(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter((function(e){return t.propertyIsEnumerable(e)})):[]}(t))}function c(t,e){try{return e in t}catch(t){return!1}}function s(t,e,n){var r={};return n.isMergeableObject(t)&&a(t).forEach((function(e){r[e]=i(t[e],n)})),a(e).forEach((function(o){(function(t,e){return c(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,o)||(c(t,o)&&n.isMergeableObject(e[o])?r[o]=function(t,e){if(!e.customMerge)return f;var n=e.customMerge(t);return"function"==typeof n?n:f}(o,n)(t[o],e[o],n):r[o]=i(e[o],n))})),r}function f(t,e,n){(n=n||{}).arrayMerge=n.arrayMerge||u,n.isMergeableObject=n.isMergeableObject||r,n.cloneUnlessOtherwiseSpecified=i;var o=Array.isArray(e);return o===Array.isArray(t)?o?n.arrayMerge(t,e,n):s(t,e,n):i(e,n)}f.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce((function(t,n){return f(t,n,e)}),{})};var l=f;t.exports=l},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e,n){var r=n(20),o=n(21),i=n(22),u=n(23);t.exports=function(t){return r(t)||o(t)||i(t)||u()}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(24))},function(t,e,n){t.exports=n(33)},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}},function(t,e,n){"use strict"; /*! * isobject <https://github.com/jonschlinkert/isobject> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},function(t,e,n){var r=n(17);function o(e,n,i){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=o=Reflect.get:t.exports=o=function(t,e,n){var o=r(t,e);if(o){var i=Object.getOwnPropertyDescriptor(o,e);return i.get?i.get.call(n):i.value}},o(e,n,i||e)}t.exports=o},function(t,e,n){var r=n(18);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}},function(t,e,n){var r=n(19),o=n(5);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?o(t):e}},function(t,e,n){"use strict";var r=n(26),o=n(27);t.exports=function t(e,n){if(void 0===e)return{};if(Array.isArray(e)){for(var i=0;i<e.length;i++)e[i]=t(e[i],n);return e}if(!r(e))return e;if("string"==typeof n&&(n=[n]),!Array.isArray(n))return e;for(var u=0;u<n.length;u++)o(e,n[u]);for(var a in e)e.hasOwnProperty(a)&&(e[a]=t(e[a],n));return e}},function(t,e){function n(t,e,n,r,o,i,u){try{var a=t[i](u),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,o)}t.exports=function(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var u=t.apply(e,r);function a(t){n(u,o,i,a,c,"next",t)}function c(t){n(u,o,i,a,c,"throw",t)}a(void 0)}))}}},function(t,e,n){t.exports=n(34)},function(t,e,n){var r=n(0);t.exports=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,r)}t.exports=n},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e,n){var r=n(9);t.exports=function(t){if(Array.isArray(t))return r(t)}},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}},function(t,e,n){var r=n(9);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),o=function(){function t(){this.nodes={},this.outgoingEdges={},this.incomingEdges={}}return t.prototype.addNode=function(t){if(this.hasNode(t.name))throw new Error('A node with the name of "'+t.name+'" already exists in the graph!');this.nodes[t.name]=t,this.outgoingEdges[t.name]=[],this.incomingEdges[t.name]=[]},t.prototype.removeNode=function(t){if(!this.hasNode(t))throw new Error('A node with the name of "'+t+'" does not exist in the graph!');for(var e in delete this.nodes[t],delete this.outgoingEdges[t],delete this.incomingEdges[t],this.incomingEdges)this.incomingEdges[e].includes(t)&&this.incomingEdges[e].splice(e.indexOf(t),1);for(var n in this.outgoingEdges)this.outgoingEdges[n].includes(t)&&this.outgoingEdges[n].splice(n.indexOf(t),1)},t.prototype.hasNode=function(t){return this.nodes.hasOwnProperty(t)},Object.defineProperty(t.prototype,"size",{get:function(){return Object.keys(this.nodes).length},enumerable:!0,configurable:!0}),t.prototype.getNode=function(t){if(this.hasNode(t))return this.nodes[t];throw new Error('Node "'+t+'" not found!')},t.prototype.addDependency=function(t,e){if(!this.hasNode(t))throw new Error("Node does not exist: "+t);if(!this.hasNode(e))throw new Error("Node does not exist: "+e);if(t===e)throw new Error("Cannot add self dependency: "+e);this.outgoingEdges[t].includes(e)||this.outgoingEdges[t].push(e),this.incomingEdges[e].includes(t)||this.incomingEdges[e].push(t)},t.prototype.removeDependency=function(t,e){if(console.warn("removeDependency() has not been tested."),!this.hasNode(t))throw new Error("Node does not exist: "+t);if(!this.hasNode(e))throw new Error("Node does not exist: "+e);if(t===e)throw new Error("Cannot remove self dependency: "+e);this.outgoingEdges[t].includes(e)||this.outgoingEdges[t].splice(this.outgoingEdges[t].indexOf(e),1),this.incomingEdges[e].includes(t)||this.incomingEdges[e].splice(this.incomingEdges[e].indexOf(e),1)},t.prototype.dependenciesOf=function(t){return this.outgoingEdges[t]},t.prototype.dependentsOf=function(t){return this.incomingEdges[t]},t.prototype.traverse=function(){var t=this;Object.keys(this.nodes).map((function(e){return t.getNode(e).clearMutex()}));var e=function(n){return Promise.all(t.dependenciesOf(n.name).map((function(e){return t.nodes[e].awaitData()}))).then((function(){return n.signalDependenciesReady(),t.dependentsOf(n.name).length>0?Promise.all(t.dependentsOf(n.name).map((function(n){return e(t.getNode(n))}))):n.awaitData()}))},n=Object.keys(this.nodes).filter((function(e){return 0===t.dependenciesOf(e).length}));return 0===n.length&&Object.keys(this.nodes).length>0?Promise.reject(new Error("The graph is circular. Cannot traverse graph due to no root node.")):Promise.all(n.map((function(n){return e(t.nodes[n])})))},t.prototype.clearNodeAndDependents=function(t){var e=this,n=this.getNode(t),r=function(t){return t.hasData()?(t.clearData(),Promise.all(e.dependentsOf(t.name).map((function(t){return r(e.getNode(t))})))):Promise.resolve()};return r(n)},t.prototype.reset=function(){for(var t in this.nodes)this.nodes[t].reset()},t.prototype.ls=function(){for(var t in this.nodes)console.log(t),console.log(this.dependentsOf(t))},t}();e.Graph=o;var i=function(){function t(t,e){this.locked=!1,this._name=t,this._promise=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.awaitData=function(){var t=this;return this.mutex||(this.mutex=new r.Mutex((function(){return void 0!==t._data}))),new Promise((function(e,n){t.mutex.await((function(r){if(r)return n(r);e(t._data)}))}))},t.prototype.signalDependenciesReady=function(){var t=this;if(this.mutex||(this.mutex=new r.Mutex((function(){return void 0!==t._data}))),void 0===this._data){if(!0===this.locked)return;this.locked=!0;var e=this._promise();if(void 0===e)throw new Error('Node "'+this._name+'" has undefined promise.');e.then((function(e){t._data=e,t.locked=!1,t.mutex.ready()})).catch((function(e){t._data=null,t.locked=!1,t.mutex.ready(e)}))}else this.mutex.ready()},t.prototype.setData=function(t){this._data=t,this.signalDependenciesReady()},t.prototype.reset=function(){this.clearData(),this.clearMutex()},t.prototype.clearMutex=function(){this.hasData()&&(this.mutex=void 0)},t.prototype.hasData=function(){return void 0!==this._data},t.prototype.clearData=function(){this._data=void 0},t}();e.Node=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){this.readyTest=t}return t.prototype.await=function(t){!0===this.readyTest()?t():(this.waiting=this.waiting||[],this.waiting.push(t))},t.prototype.ready=function(t){this.waiting&&this.waiting.forEach((function(e){return e(t)})),delete this.waiting},t}();e.Mutex=r},function(t,e,n){"use strict"; /*! * is-plain-object <https://github.com/jonschlinkert/is-plain-object> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */var r=n(10);function o(t){return!0===r(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,n;return!1!==o(t)&&("function"==typeof(e=t.constructor)&&(!1!==o(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")))}},function(t,e,n){"use strict"; /*! * unset-value <https://github.com/jonschlinkert/unset-value> * * Copyright (c) 2015, 2017, Jon Schlinkert. * Released under the MIT License. */var r=n(10),o=n(28);t.exports=function(t,e){if(!r(t))throw new TypeError("expected an object.");if(t.hasOwnProperty(e))return delete t[e],!0;if(o(t,e)){for(var n=e.split("."),i=n.pop();n.length&&"\\"===n[n.length-1].slice(-1);)i=n.pop().slice(0,-1)+"."+i;for(;n.length;)t=t[e=n.shift()];return delete t[i]}return!0}},function(t,e,n){"use strict"; /*! * has-value <https://github.com/jonschlinkert/has-value> * * Copyright (c) 2014-2016, Jon Schlinkert. * Licensed under the MIT License. */var r=n(29),o=n(31),i=n(32);t.exports=function(t,e,n){return r(t)?o(i(t,e),n):o(t,e)}},function(t,e,n){"use strict"; /*! * isobject <https://github.com/jonschlinkert/isobject> * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */var r=n(30);t.exports=function(t){return null!=t&&"object"==typeof t&&!1===r(t)}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict"; /*! * has-values <https://github.com/jonschlinkert/has-values> * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */t.exports=function(t,e){if(null==t)return!1;if("boolean"==typeof t)return!0;if("number"==typeof t)return 0!==t||!0!==e;if(void 0!==t.length)return 0!==t.length;for(var n in t)if(t.hasOwnProperty(n))return!0;return!1}},function(t,e){function n(t){return t?Array.isArray(t)?t.join("."):t:""} /*! * get-value <https://github.com/jonschlinkert/get-value> * * Copyright (c) 2014-2015, Jon Schlinkert. * Licensed under the MIT License. */ t.exports=function(t,e,r,o,i){if(null===(u=t)||"object"!=typeof u&&"function"!=typeof u||!e)return t;var u;if(e=n(e),r&&(e+="."+n(r)),o&&(e+="."+n(o)),i&&(e+="."+n(i)),e in t)return t[e];for(var a=e.split("."),c=a.length,s=-1;t&&++s<c;){for(var f=a[s];"\\"===f[f.length-1];)f=f.slice(0,-1)+"."+a[++s];t=t[f]}return t}},function(t,e,n){var r=function(t){"use strict";var e=Object.prototype,n=e.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";function a(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var o=e&&e.prototype instanceof l?e:l,i=Object.create(o.prototype),u=new E(r||[]);return i._invoke=function(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return P()}for(n.method=o,n.arg=i;;){var u=n.delegate;if(u){var a=w(u,n);if(a){if(a===f)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=s(t,e,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(t,n,u),i}function s(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function l(){}function p(){}function d(){}var h={};h[o]=function(){return this};var y=Object.getPrototypeOf,v=y&&y(y(j([])));v&&v!==e&&n.call(v,o)&&(h=v);var g=d.prototype=l.prototype=Object.create(h);function m(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var r;this._invoke=function(o,i){function u(){return new e((function(r,u){!function r(o,i,u,a){var c=s(t[o],t,i);if("throw"!==c.type){var f=c.arg,l=f.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,u,a)}),(function(t){r("throw",t,u,a)})):e.resolve(l).then((function(t){f.value=t,u(f)}),(function(t){return r("throw",t,u,a)}))}a(c.arg)}(o,i,r,u)}))}return r=r?r.then(u,u):u()}}function w(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var r=s(n,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,f;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function j(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:P}}function P(){return{value:void 0,done:!0}}return p.prototype=g.constructor=d,d.constructor=p,p.displayName=a(d,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,a(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(b.prototype),b.prototype[i]=function(){return this},t.AsyncIterator=b,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var u=new b(c(e,n,r,o),i);return t.isGeneratorFunction(n)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},m(g),a(g,u,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=j,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return u.type="throw",u.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},function(t,e,n){"use strict";n.r(e),n.d(e,"CoreBase",(function(){return k})),n.d(e,"ServiceProvider",(function(){return M})),n.d(e,"EventEmitter",(function(){return x.EventHandler}));var r=n(2),o=n.n(r),i=n(3),u=n.n(i),a=n(5),c=n.n(a),s=n(11),f=n.n(s),l=n(12),p=n.n(l),d=n(13),h=n.n(d),y=n(0),v=n.n(y),g=n(6),m=n.n(g),b=n(7),w=function(t){var e={},n=[],r=[],o=function(t,e){var n=new b.Graph,r=t.map((function(t){return"function"==typeof t.provider.provides?t.provider.provides():[]}));return t.forEach((function(t,r){n.addNode(new b.Node(String(r),(function(){try{return Promise.resolve(t.provider[e]())}catch(t){return Promise.reject(t)}})))})),t.forEach((function(t,e){var o,i=t.options.depends instanceof Array?t.options.depends:[],u="function"==typeof t.provider.depends?t.provider.depends():[],a=[].concat(m()(i),m()(u));if(a.length>0){var c=(o=a,r.findIndex((function(t){return t.some((function(t){return-1!==o.indexOf(t)}))})));-1!==c&&n.addDependency(String(e),String(c))}})),n.traverse().catch((function(t){return console.warn(t)}))};return{register:function(e,r){try{n.push({provider:new e(t,r.args),options:r})}catch(t){console.error("Provider register error",t)}},init:function(t){return e=t?n.filter((function(t){return t.options.before})):n.filter((function(t){return!t.options.before})),o(e,"init").then((function(){return o(e,"start")}));var e},bind:function(e,n,o){t.logger.info("Provider binding",e),r.push({singleton:n,name:e,make:function(){return o.apply(void 0,arguments)}})},has:function(t){return-1!==r.findIndex((function(e){return e.name===t}))},make:function(t){var n=r.find((function(e){return e.name===t}));if(!n)throw new Error("Provider '".concat(t,"' not found"));for(var o=arguments.length,i=new Array(o>1?o-1:0),u=1;u<o;u++)i[u-1]=arguments[u];return n.singleton?(e[t]||n&&(e[t]=n.make.apply(n,i)),e[t]):n.make.apply(n,i)},destroy:function(){var t,o,i=(t=n,o="destroy",Promise.all(t.map((function(t){try{return t.provider[o]()}catch(t){return Promise.reject(t)}}))).catch((function(t){return console.warn(t)})));return e={},r=[],i}}},x=n(1),O=n(4),E=n.n(O),j=n(14),P=n.n(j);function _(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=v()(t);if(e){var o=v()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return h()(this,n)}}var k=function(t){p()(n,t);var e=_(n);function n(t,r,i){var u;o()(this,n),u=e.call(this,"Core");var a=E.a.default?E.a.default:E.a,s=P()(t,i.omit||[]);return u.logger=console,u.configuration=a(s,r),u.options=i,u.booted=!1,u.started=!1,u.destroyed=!1,u.providers=w(c()(u)),u}return u()(n,[{key:"destroy",value:function(){if(this.destroyed)return!1;this.booted=!1,this.destroyed=!0,this.started=!1;var t=this.providers.destroy();return f()(v()(n.prototype),"destroy",this).call(this),t}},{key:"boot",value:function(){return this.booted?Promise.resolve(!0):(this.started=!1,this.destroyed=!1,this.booted=!0,this.providers.init(!0).then((function(){return!0})))}},{key:"start",value:function(){return this.started?Promise.resolve(!0):(this.started=!0,this.providers.init(!1).then((function(){return!0})))}},{key:"config",value:function(t,e){return t?function(t,e,n){var r;try{r=e.split(/\./g).reduce((function(t,e){return t[e]}),Object.assign({},t))}catch(t){}return void 0===r?n:r}(this.configuration,t,e):Object.assign({},this.configuration)}},{key:"register",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.providers.register(t,e)}},{key:"instance",value:function(t,e){this.providers.bind(t,!1,e)}},{key:"singleton",value:function(t,e){this.providers.bind(t,!0,e)}},{key:"make",value:function(t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return(e=this.providers).make.apply(e,[t].concat(r))}},{key:"has",value:function(t){return this.providers.has(t)}}]),n}(x.EventEmitter),S=n(8),A=n.n(S),N=n(15),L=n.n(N),M=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o()(this,t),this.core=e,this.options=n}var e;return u()(t,[{key:"provides",value:function(){return[]}},{key:"depends",value:function(){return[]}},{key:"init",value:(e=L()(A.a.mark((function t(){return A.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(){return e.apply(this,arguments)})},{key:"start",value:function(){}},{key:"destroy",value:function(){}}]),t}()}])); //# sourceMappingURL=main.js.map