lego-core
Version:
web组件化前端框架, virtual-dom + ES6 + webpack + sass
6 lines • 23 kB
JavaScript
/**
* lego.min.js v1.15.8
* (c) 2017 Ronghui Yu
* @license MIT
*/
;function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function __async(e){return new Promise(function(t,r){function n(i,a){try{var s=e[a?"throw":"next"](i)}catch(e){return void r(e)}s.done?t(s.value):Promise.resolve(s.value).then(n,o)}function o(e){n(e,1)}n()})}var html5HistoryApi=require("html5-history-api"),page=_interopDefault(require("page")),object_observe=require("object.observe"),hyperx=_interopDefault(require("hyperx")),vdom=_interopDefault(require("virtual-dom"));window.page=page;var Core=function(){return this.config={alias:"Lego",version:"1.0.0",isDebug:!0,fetchMode:"same-origin",isAnimate:!1,isMultiWindow:!1,permit:function(){},pageEl:"",defaultApp:"",rootUri:"",screenWidth:window.innerWidth},this._debugger(),this.prevApp="",this.currentApp="",this.idCounter=0,this.viewsMap=new WeakMap,this.views={},this.oldViews={},this.datas={},this.timer=new Map,this.UI={},this.routers=new Map,this};Core.prototype.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(window.$)return $.extend.apply($,[!0].concat(e));if(e.length>0){var r=e[0];"object"!=typeof r&&"function"!=typeof r&&(r={});for(var n=1;n<e.length;n++){var o=e[n];if(null!=o&&"object"==typeof o){var i=Object.keys(o);if(r===o)continue;for(var a=0;a<i.length;a++){var s=i[a];Object.prototype.hasOwnProperty.call(o,s)&&("object"!=typeof o[s]?r[s]=o[s]:r[s]=Lego.extend(r[s],o[s]))}}}return r}return{}},Core.prototype.create=function(e,t){function r(e){var t=n.getView(e);n.oldViews[t.options.vid]=t.options.id}void 0===t&&(t={});var n=this;if(t.vid=this.uniqueId("v"),e&&(!this.config.permit||"function"!=typeof this.config.permit||!t.permis||this.config.permit(t.permis))){var o=new e(t);if("html"==t.insert){this.removeOldViews();var i=o.$("[view-id]");if(i.length)if(window.$)i.each(function(e,t){r(t)});else for(var a=0;a<i.length;a++)r(i[a]);this.oldViews[t.vid]=o.options.id}return this.viewsMap.set(o.el,t.vid),this.views[t.vid]=o,o}},Core.prototype.removeOldViews=function(){var e=this;for(var t in this.oldViews){var r=e.getView(t);r?(e.Eventer.off(null,null,r),e.viewsMap.delete(r.el),r.remove()):(delete e.oldViews[t],delete e.views[t])}},Core.prototype.setting=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return e.length>1?"string"==typeof e[0]&&(this.config[e[0]]=e[1]):"object"==typeof e[0]&&Object.assign(this.config,e[0]),page.base(this.config.routeRoot),this._debugger(),this},Core.prototype.components=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r=!1),"string"==typeof e&&(this.UI[e]=t),"object"==typeof e&&(this.isEmptyObject(e)?this.UI=e:Object.assign(this.UI,e))},Core.prototype.param=function(e){void 0===e&&(e={});var t=[];for(var r in e)"object"==typeof e[r]&&(e[r]=JSON.stringify(e[r])),t.push(r+"="+e[r]);return t.join("&")},Core.prototype.randomKey=function(e){e=e||32;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n},Core.prototype.uniqueId=function(e){var t=++this.idCounter+"";return e?e+t:t},Core.prototype.isEmptyObject=function(e){if(void 0===e&&(e={}),window.$)return $.isEmptyObject(e);if(null!=e&&"object"==typeof e)for(var t in e)return!1;return!0},Core.prototype._debugger=function(){if(window.debug={},!window.console)return function(){};if(this.config.isDebug)for(var e in console)"function"==typeof console[e]&&(debug[e]=console[e].bind(window.console));else for(var t in console)"function"==typeof console[t]&&(debug[t]=function(){})},Core.prototype._clearObj=function(e){var t=this;e!==this.currentApp&&this.timer.forEach(function(e,r){clearTimeout(e),clearInterval(e),t.timer.delete(r)})},Core.prototype.ns=function ns(nameSpaceStr,obj){function getNameSpace(nameSpaceObj,num){if(num<nameSpaceArr.length){var itemStr=nameSpaceArr[num];tempArr.push(itemStr);var allStr=tempArr.join("."),subObj=eval(allStr);return num==nameSpaceArr.length-1?that.isEmptyObject(nameSpaceObj[itemStr])&&(nameSpaceObj[itemStr]=obj):nameSpaceObj[itemStr]="object"!=typeof subObj||Array.isArray(subObj)?{}:subObj,getNameSpace(nameSpaceObj[itemStr],num+1)}return nameSpaceObj}if(void 0===obj&&(obj={}),"string"!=typeof nameSpaceStr&&Array.isArray(obj)||"object"!=typeof obj)return void debug.error("namespace error",obj);"Lego."!==nameSpaceStr.substring(0,5)&&(nameSpaceStr="Lego."+nameSpaceStr);var nameSpaceArr=nameSpaceStr.split("."),tempArr=["Lego"],that=this;return getNameSpace(this,1)},Core.prototype.addEvent=function(e,t,r){e.addEventListener?e.addEventListener(t,r,!1):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r},Core.prototype.removeEvent=function(e,t,r){e.removeEventListener?e.removeEventListener(t,r,!1):e.detachEvent?e.detachEvent("on"+t,r):delete e["on"+t]},Core.prototype.loadScript=function(e,t,r){void 0===r&&(r="");var n=document.createElement("script"),o="Lego-js-"+r,i=(e.indexOf("?")<0?"?":"&")+(this.config.version||0);n.setAttribute("id",o),n.type="text/javascript",n.readyState?n.onreadystatechange=function(){"loaded"!=n.readyState&&"complete"!=n.readyState||(n.onreadystatechange=null,t())}:n.onload=function(){t()},n.src=e+i,document.getElementById(o)&&document.getElementsByTagName("head")[0].removeChild(document.getElementById(o)),document.getElementsByTagName("head")[0].appendChild(n)},Core.prototype.loadCss=function(e,t){var r=document.createElement("link"),n="Lego-css-"+t,o=(e.indexOf("?")<0?"?":"&")+(this.config.version||0);if(e){var i=e+o;document.getElementById(n)||(r.setAttribute("id",n),r.rel="stylesheet",r.href=i,document.getElementsByTagName("head")[0].appendChild(r))}},Core.prototype.removeCss=function(e){var t="Lego-css-"+e;document.getElementById(t)&&document.getElementsByTagName("head")[0].removeChild(document.getElementById(t))},Core.prototype.startApp=function(e,t,r){void 0===t&&(t="app"),void 0===r&&(r={});var n,o={removeCss:!0,startBefore:function(){},startAfter:function(){}},i=this;Object.assign(o,r);var a=window.location.hash.replace(/#/,""),s=0==a.indexOf("/")?a.replace(/\//,""):"";s="index"!==s?s:"",e=e||s||this.config.defaultApp,n=this.currentApp?e.indexOf("/")>0?e.split("/")[0]:e:"index",this.prevApp=this.currentApp,this.currentApp=this.currentApp?n:"index","function"==typeof o.startBefore&&o.startBefore(),this.config.isMultiWindow||(page.stop(),this.routers.delete(this.prevApp)),this.loadCss(this.config.rootUri+n+"/"+t+".css",n),this.theTimer&&clearTimeout(this.theTimer),this.theTimer=setTimeout(function(){i.loadScript(i.config.rootUri+n+"/"+t+".js",function(){if(e&&"index"!==n&&(page(0!==e.indexOf("/")?"/"+e:e),!i.config.isMultiWindow)){var t="Lego-js-"+i.prevApp;document.getElementById(t)&&document.getElementsByTagName("head")[0].removeChild(document.getElementById(t)),"index"!==i.prevApp&&o.removeCss&&i.removeCss(i.prevApp),i._clearObj(i.prevApp)}"function"==typeof o.startAfter&&o.startAfter()},n)},200)},Core.prototype.getUrlParam=function(e){if(window.pageParams={},window.pageParams[e])return window.pageParams[e];var t=decodeURI(document.location.search);if(t.indexOf("?")>=0){for(var r=t.substr(1).split("&"),n=[],o=0;o<r.length;o++)n=r[o].split("="),window.pageParams[n[0]]=n[1];return window.pageParams[e]||""}return""},Core.prototype.getAppName=function(){var e=window.location.hash.replace(/#/,"");return e=0==e.indexOf("/")?e.replace(/\//,""):"",e.split("/")[0]||this.config.defaultApp},Core.prototype.getView=function(e){if("string"==typeof e){var t=this.views[e];if(t)return t}var r="string"==typeof e?document.querySelector(e):e;if(window.$&&"object"==typeof e&&(r=e instanceof window.$?e[0]:r),this.viewsMap.has(r)){var n=this.viewsMap.get(r);return this.views[n]}return null},Core.prototype.setTimer=function(e,t){if(e&&t){var r=this.timer,n=r.get(e);n&&(clearTimeout(n),clearInterval(n),r.clear()),r.set(e,t)}},Core.prototype.router=function e(e){if(void 0===e&&(e={}),!this.isEmptyObject(e)){var t=this.getAppName();if(!this.routers.get(t)){var r=e.pages||{},n={};e.pages?n=e:"function"==typeof e&&(n=new e,r=n.pages);var o=function(e){var t=r[e],o=[e];t=Array.isArray(t)?t:[t],t.forEach(function(e){"function"==typeof e?(e=e.bind(n),o.push(e)):"string"==typeof e&&o.push(n[e].bind(n))}),n[t[t.length-1]+"_out"]&&page.exit(e,n[t[t.length-1]+"_out"].bind(n)),page.apply(void 0,o)};for(var i in r)o(i);this.routers.set(t,e)}}},window.Lego=window.Lego||new Core;var LegoCore$1=window.Lego;window.hx=hyperx(vdom.h);var View=function(e){var t=this;if(void 0===e&&(e={}),this.eventNameSpace=new Map,this.dataMap=new Map,e.context=e.context||document,e.data=e.data||null,e.components=e.components||[],this.options=e,this.options.listener&&Lego.Eventer)for(var r in this.options.listener)Lego.Eventer.on(r,t.options.listener[r],t);"function"==typeof this.options.renderBefore&&(this.options.renderBefore=this.options.renderBefore.bind(this)),"function"==typeof this.options.renderAfter&&(this.options.renderAfter=this.options.renderAfter.bind(this)),this._renderRootNode(),this.setElement(this.options.el),this._observe(),this.options.stopFetch||this.fetch()};View.prototype.makeDatamap=function(e,t,r){var n=this;return void 0===t&&(t="id"),void 0===r&&(r={}),Array.isArray(e)&&(this.dataMap.clear(),e.forEach(function(e,o){if("object"==typeof e&&!Array.isArray(e)){(e[t]||0==e[t])&&(e[t]=e[t].toString(),n.dataMap.set(e[t],e));for(var i in e)e[i]="undefined"==typeof e[i]||"null"==e[i]?r[i]:e[i]}})),e},View.prototype.fetch=function(e){var t=this;if(void 0===e&&(e={}),this.options.dataSource){this.options.loading&&this._showLoading();var r=this.options.dataSource,n="";if(r.api=Array.isArray(r.api)?r.api:[r.api],1==r.api.length&&(n=r.api[0]),r.api.forEach(function(t){r[t]=Lego.extend({},r.server.options[t],r[t]||{},e)}),r.server){var o=null;o="function"==typeof r.server?new r.server:r.server,o.fetch(r.api,r.isAjax&&window.$?r:{},function(e){if(n&&Array.isArray(e)){var r="id",i={};o.options[n]&&(r=o.options[n].modelkey,i=o.options[n].defaultModel),t.options.data=t.makeDatamap(e,r,i)}else t.options.data=e;t.options.loading&&t._hideLoading(),t.dataReady(),t.refresh()},this)}}else this._renderComponents()},View.prototype._showLoading=function(){},View.prototype._hideLoading=function(){},View.prototype._renderRootNode=function(){var e=this,t=this.options;t.renderBefore&&t.renderBefore(),this.renderBefore(),t.data="function"==typeof t.data?t.data():t.data,t.data=this.makeDatamap(t.data);var r=this.render();if(r?(this.oldNode=r,this.rootNode=vdom.create(r),this.el=this.rootNode):this.el=document.createElement("<div></div>"),t.id||t.el)if(t.id)this.el.setAttribute("id",t.id);else if(new RegExp(/#/).test(t.el)){var n=t.el.replace(/#/,"");this.el.setAttribute("id",n),t.id=n}else this.el.setAttribute("id",t.vid),t.id=t.vid;if(this.el.setAttribute("view-id",t.vid),t.style)for(var o in t.style)"number"==typeof t.style[o]&&(t.style[o]+="px"),e.el.style[o]=t.style[o];if(t.attr)for(var i in t.attr)e.el.setAttribute(i,t.attr[i]);t.className&&(this.el.className+=" "+t.className),window.$&&(this.$el=window.$(this.el))},View.prototype._renderComponents=function(){var e=this,t=this.options;this.components();var r=this.options.components;r=Array.isArray(r)?r:[r],r.length&&r.forEach(function(t,r){if(e.$(t.el).length){var n=t.el?e.$(t.el)[0].tagName.toLowerCase():"";n&&(t.context=e,Lego.UI[n]&&Lego.create(Lego.UI[n],t))}}),t.renderAfter&&t.renderAfter(),this.renderAfter()},View.prototype.addCom=function(e){var t=this;return e=Array.isArray(e)?e:[e],e.length&&e.forEach(function(e){if(e.el){var r=t.options.components.find(function(t){return t.el==e.el});r?Object.assign(r,e):t.options.components.push(e)}}),t.options.components},View.prototype._observe=function(){var e=this;this.options&&"object"==typeof this.options&&Object.observe(this.options,function(t){"function"==typeof e.options.data&&(e.options.data=e.options.data());var r=e.render(),n=vdom.diff(e.oldNode,r);e.rootNode=vdom.patch(e.rootNode,n),e.el=e.rootNode,e.oldNode=r,e._renderComponents()})},View.prototype.setElement=function(e){if(e){var t=this.options.context.el||document,r="string"==typeof e?t.querySelector(e):e;if(r||(r=document.querySelector(e)),"body"==e&&(this.options.insert="html"),r)switch(this.options.insert){case"html":for(var n=r.childNodes,o=n.length-1;o>=0;o--)r.removeChild(n.item(o));r.appendChild(this.el);break;case"append":r.appendChild(this.el);break;case"prepend":r.insertBefore(this.el,r.childNodes[0]);break;default:r.parentNode.replaceChild(this.el,r)}}},View.prototype.$=function(e){return this.$el?this.$el.find(e):this.el.querySelectorAll(e)},View.prototype.components=function(){return this},View.prototype.dataReady=function(){return this},View.prototype.render=function(){return""},View.prototype.renderBefore=function(){return this},View.prototype.renderAfter=function(){return this},View.prototype.refresh=function(){this.options.__v=Lego.randomKey()},View.prototype.remove=function(){Lego.Eventer.off(null,null,this),Lego.viewsMap.delete(this.el),delete Lego.views[this.options.vid],this.$el?(this.$el.off(),this.$el.remove()):this.el.remove()};var Data=function(e){var t=this;void 0===e&&(e={}),this.datas=new Map;for(var r in e)t.datas.set(r,{});this.options=e};Data.prototype.fetch=function(e,t,r,n){function o(e,t){$.ajax(Lego.extend(e,{success:function(e){e&&(i.datas.set(t,e),"function"==typeof r&&r(i.parse(e,t,n)))},error:function(e){debug.warn("login error: ",e)}}))}var i=this,a=Array.isArray(e)?e:[e];if(t.isAjax){var s=Array.isArray(e)?e[0]:e,c=Lego.extend({reset:!0},i.options[s]||{},n?n.options.dataSource[s]||{}:{},t||{});(window.$||window.jQuery)&&(c.url.indexOf("http")<0&&(c.url=Lego.config.serviceUri+c.url),Lego.isEmptyObject(this.datas.get(s))?o(c,s):c.reset?o(c,s):"function"==typeof r&&r(this.parse(this.datas.get(s),s,n)))}else this.__fetch(e,t,n).then(function(e){a.forEach(function(t,r){i.datas.set(t,e[r])}),"function"==typeof r&&r(i.parse(1==e.length?e[0]:e,a.join("_"),n))})},Data.prototype.__fetch=function(e,t,r){return __async(regeneratorRuntime.mark(function n(){var o,i,a,s,c,p,f,u;return regeneratorRuntime.wrap(function(n){for(var l=this;;)switch(n.prev=n.next){case 0:o=l,i=[],a=Array.isArray(e)?e:[e],n.prev=1,s=a.map(function(e){return __async(regeneratorRuntime.mark(function n(){var i,a,s,c,p,f,u,l,h;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(i=o.datas.get(e)||{},a=Lego.extend({reset:!0},o.options[e]||{},r?r.options.dataSource[e]||{}:{},t||{}),Lego.isEmptyObject(i)||a.reset){n.next=7;break}return n.next=4,i;case 4:return n.abrupt("return",n.sent);case 7:if(!o.datas.has(e)||!a.url||!Lego.isEmptyObject(i)&&!a.reset){n.next=18;break}return s=/http/.test(a.url)?a.url:Lego.config.serviceUri+a.url,c=a.headers||{Accept:"application/json","Content-type":"application/json; charset=UTF-8"},p=a.body,f=a.method||"POST","GET"==f&&p&&(u=Lego.param(p),s+=s.indexOf("?")>0?"&"+u:"?"+u),l={method:f,headers:c,mode:Lego.config.fetchMode||"same-origin",credentials:"include",body:"POST"==f?JSON.stringify(p):void 0},n.next=16,fetch(s,l);case 16:return h=n.sent,n.abrupt("return",h.json());case 18:case"end":return n.stop()}},n,this)})())}),p=regeneratorRuntime.values(s);case 4:if((f=p.next()).done){n.next=12;break}return c=f.value,n.next=8,c;case 8:u=n.sent,i.push(u);case 10:n.next=4;break;case 12:n.next=17;break;case 14:n.prev=14,n.t0=n.catch(1),debug.log("data has error:",n.t0);case 17:return n.abrupt("return",i);case 18:case"end":return n.stop()}},n,this,[[1,14]])}).call(this))},Data.prototype.parse=function(e,t,r){return"function"==typeof this[t]?this[t](e,r):e},Data.prototype.getData=function(e){return e?this.datas.get(e)?this.datas.get(e):{}:this.datas};var Event=function(e){void 0===e&&(e={}),this.listener=new Map};Event.prototype.on=function(e,t,r){if(e){if("function"!=typeof t)return;r&&(t=t.bind(r));var n=r||Symbol(),o={callback:t};if(this.listener.has(e)){var i=this.listener.get(e);if(i.has(n)){var a=i.get(n);a.push(o)}else i.set(n,[o])}else{var s=new Map;s.set(n,[o]),this.listener.set(e,s)}}},Event.prototype.off=function(e,t,r){if(e||t||r)if(e||t||!r)if(e||!t||r)if(!e&&t&&r)this.listener.forEach(function(e,n){var o=e.get(r);o&&(o=o.filter(function(e){return e.callback!==t}))});else if(!e||t||r){if(e&&!t&&r){var n=this.listener.get(e);n&&n.delete(r)}else if(e&&t&&!r){var o=this.listener.get(e);o&&o.forEach(function(e,r){e=e.filter(function(e){return e.callback!==t})})}else if(e&&t&&r){var i=this.listener.get(e);if(i){var a=i.get(r);a&&(a=a.filter(function(e){return e.callback!==t}))}}}else this.listener.has(e)&&this.listener.delete(e);else this.listener.forEach(function(e,r){e.forEach(function(e,r){e=e.filter(function(e){return e.callback!==t})})});else this.listener.forEach(function(e,t){e.delete(r)});else this.listener.clear()},Event.prototype.trigger=function(){for(var e=this,t=[],r=arguments.length;r--;)t[r]=arguments[r];if(t.length){var n=t.shift();if(this.listener.has(n)){var o=this.listener.get(n);o.forEach(function(r,n){r.forEach(function(r){"function"==typeof r.callback&&r.callback.apply(e,t)})})}}},!function(e){function t(e,t,r,o){var i=t&&t.prototype instanceof n?t:n,a=Object.create(i.prototype),s=new l(o||[]);return a._invoke=p(e,r,s),a}function r(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}function n(){}function o(){}function i(){}function a(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function s(e){this.arg=e}function c(e){function t(n,o,i,a){var c=r(e[n],e,o);if("throw"!==c.type){var p=c.arg,f=p.value;return f instanceof s?Promise.resolve(f.arg).then(function(e){t("next",e,i,a)},function(e){t("throw",e,i,a)}):Promise.resolve(f).then(function(e){p.value=e,i(p)},a)}a(c.arg)}function n(e,r){function n(){return new Promise(function(n,o){t(e,r,n,o)})}return o=o?o.then(n,n):n()}"object"==typeof process&&process.domain&&(t=process.domain.bind(t));var o;this._invoke=n}function p(e,t,n){var o=L;return function(i,a){if(o===A)throw new Error("Generator is already running");if(o===j){if("throw"===i)throw a;return d()}for(;;){var s=n.delegate;if(s){if("return"===i||"throw"===i&&s.iterator[i]===v){n.delegate=null;var c=s.iterator.return;if(c){var p=r(c,s.iterator,a);if("throw"===p.type){i="throw",a=p.arg;continue}}if("return"===i)continue}var p=r(s.iterator[i],s.iterator,a);if("throw"===p.type){n.delegate=null,i="throw",a=p.arg;continue}i="next",a=v;var f=p.arg;if(!f.done)return o=x,f;n[s.resultName]=f.value,n.next=s.nextLoc,n.delegate=null}if("next"===i)n.sent=n._sent=a;else if("throw"===i){if(o===L)throw o=j,a;n.dispatchException(a)&&(i="next",a=v)}else"return"===i&&n.abrupt("return",a);o=A;var p=r(e,t,n);if("normal"===p.type){o=n.done?j:x;var f={value:p.arg,done:n.done};if(p.arg!==S)return f;n.delegate&&"next"===i&&(a=v)}else"throw"===p.type&&(o=j,i="throw",a=p.arg)}}}function f(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function u(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function l(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(f,this),this.reset(!0)}function h(e){if(e){var t=e[m];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(y.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=v,t.done=!0,t};return n.next=n}}return{next:d}}function d(){return{value:v,done:!0}}var v,y=Object.prototype.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},m=g.iterator||"@@iterator",w=g.toStringTag||"@@toStringTag",b="object"==typeof module,E=e.regeneratorRuntime;if(E)return void(b&&(module.exports=E));E=e.regeneratorRuntime=b?module.exports:{},E.wrap=t;var L="suspendedStart",x="suspendedYield",A="executing",j="completed",S={},C=i.prototype=n.prototype;o.prototype=C.constructor=i,i.constructor=o,i[w]=o.displayName="GeneratorFunction",E.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===o||"GeneratorFunction"===(t.displayName||t.name))},E.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,i):(e.__proto__=i,w in e||(e[w]="GeneratorFunction")),e.prototype=Object.create(C),e},E.awrap=function(e){return new s(e)},a(c.prototype),E.async=function(e,r,n,o){var i=new c(t(e,r,n,o));return E.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},a(C),C[m]=function(){return this},C[w]="Generator",C.toString=function(){return"[object Generator]"},E.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},E.values=h,l.prototype={constructor:l,reset:function(e){var t=this;if(this.prev=0,this.next=0,this.sent=this._sent=v,this.done=!1,this.delegate=null,this.tryEntries.forEach(u),!e)for(var r in this)"t"===r.charAt(0)&&y.call(t,r)&&!isNaN(+r.slice(1))&&(t[r]=v)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){function t(t,r){return a.type="throw",a.arg=e,n.next=t,!!r}var r=this;if(this.done)throw e;for(var n=this,o=this.tryEntries.length-1;o>=0;--o){var i=r.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return t("end");if(i.tryLoc<=r.prev){var s=y.call(i,"catchLoc"),c=y.call(i,"finallyLoc");if(s&&c){if(r.prev<i.catchLoc)return t(i.catchLoc,!0);if(r.prev<i.finallyLoc)return t(i.finallyLoc)}else if(s){if(r.prev<i.catchLoc)return t(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(r.prev<i.finallyLoc)return t(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this,n=this.tryEntries.length-1;n>=0;--n){var o=r.tryEntries[n];if(o.tryLoc<=r.prev&&y.call(o,"finallyLoc")&&r.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?this.next=i.finallyLoc:this.complete(a),S},complete:function(e,t){if("throw"===e.type)throw e.arg;"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=e.arg,this.next="end"):"normal"===e.type&&t&&(this.next=t)},finish:function(e){for(var t=this,r=this.tryEntries.length-1;r>=0;--r){var n=t.tryEntries[r];if(n.finallyLoc===e)return t.complete(n.completion,n.afterLoc),u(n),S}},catch:function(e){for(var t=this,r=this.tryEntries.length-1;r>=0;--r){var n=t.tryEntries[r];if(n.tryLoc===e){var o=n.completion;if("throw"===o.type){var i=o.arg;u(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:h(e),resultName:t,nextLoc:r},S}}}("object"==typeof global?global:"object"==typeof window?window:"object"==typeof self?self:void 0),LegoCore$1.View=View,LegoCore$1.Data=Data,LegoCore$1.Event=Event,LegoCore$1.Ux={},LegoCore$1.Eventer=new Event,module.exports=LegoCore$1;