@eva/eva.js
Advanced tools
Comparing version 1.0.1 to 1.0.2-alpha
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("resource-loader");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function a(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function i(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function s(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(i,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function u(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function p(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function l(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(p(arguments[t]));return e}var f=function(e){function t(t){var r=e.call(this)||this;return r.started=!1,r.name=r.constructor.componentName,r.__componentDefaultParams=t,r}return a(t,e),t}(n.default);function h(e,t){return e===t||e!=e&&t!=t}function y(e,t){for(var r=e.length;r--;)if(h(e[r][0],t))return r;return-1}var d=Array.prototype.splice;function m(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}m.prototype.clear=function(){this.__data__=[],this.size=0},m.prototype.delete=function(e){var t=this.__data__,r=y(t,e);return!(r<0)&&(r==t.length-1?t.pop():d.call(t,r,1),--this.size,!0)},m.prototype.get=function(e){var t=this.__data__,r=y(t,e);return r<0?void 0:t[r][1]},m.prototype.has=function(e){return y(this.__data__,e)>-1},m.prototype.set=function(e,t){var r=this.__data__,n=y(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b="object"==typeof v&&v&&v.Object===Object&&v,_="object"==typeof self&&self&&self.Object===Object&&self,g=b||_||Function("return this")(),O=g.Symbol,j=Object.prototype,E=j.hasOwnProperty,w=j.toString,x=O?O.toStringTag:void 0;var T=Object.prototype.toString;var S=O?O.toStringTag:void 0;function R(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":S&&S in Object(e)?function(e){var t=E.call(e,x),r=e[x];try{e[x]=void 0;var n=!0}catch(e){}var o=w.call(e);return n&&(t?e[x]=r:delete e[x]),o}(e):function(e){return T.call(e)}(e)}function A(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function P(e){if(!A(e))return!1;var t=R(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var N,C=g["__core-js_shared__"],D=(N=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"";var I=Function.prototype.toString;function k(e){if(null!=e){try{return I.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var M=/^\[object .+?Constructor\]$/,L=Function.prototype,V=Object.prototype,z=L.toString,F=V.hasOwnProperty,G=RegExp("^"+z.call(F).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function U(e){return!(!A(e)||(t=e,D&&D in t))&&(P(e)?G:M).test(k(e));var t}function B(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return U(r)?r:void 0}var Y=B(g,"Map"),q=B(Object,"create");var W=Object.prototype.hasOwnProperty;var J=Object.prototype.hasOwnProperty;function $(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function X(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function H(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}$.prototype.clear=function(){this.__data__=q?q(null):{},this.size=0},$.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},$.prototype.get=function(e){var t=this.__data__;if(q){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return W.call(t,e)?t[e]:void 0},$.prototype.has=function(e){var t=this.__data__;return q?void 0!==t[e]:J.call(t,e)},$.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=q&&void 0===t?"__lodash_hash_undefined__":t,this},H.prototype.clear=function(){this.size=0,this.__data__={hash:new $,map:new(Y||m),string:new $}},H.prototype.delete=function(e){var t=X(this,e).delete(e);return this.size-=t?1:0,t},H.prototype.get=function(e){return X(this,e).get(e)},H.prototype.has=function(e){return X(this,e).has(e)},H.prototype.set=function(e,t){var r=X(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function K(e){var t=this.__data__=new m(e);this.size=t.size}K.prototype.clear=function(){this.__data__=new m,this.size=0},K.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},K.prototype.get=function(e){return this.__data__.get(e)},K.prototype.has=function(e){return this.__data__.has(e)},K.prototype.set=function(e,t){var r=this.__data__;if(r instanceof m){var n=r.__data__;if(!Y||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new H(n)}return r.set(e,t),this.size=r.size,this};function Q(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new H;++t<r;)this.add(e[t])}function Z(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}Q.prototype.add=Q.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Q.prototype.has=function(e){return this.__data__.has(e)};function ee(e,t,r,n,o,a){var i=1&r,s=e.length,c=t.length;if(s!=c&&!(i&&c>s))return!1;var u=a.get(e),p=a.get(t);if(u&&p)return u==t&&p==e;var l=-1,f=!0,h=2&r?new Q:void 0;for(a.set(e,t),a.set(t,e);++l<s;){var y=e[l],d=t[l];if(n)var m=i?n(d,y,l,t,e,a):n(y,d,l,e,t,a);if(void 0!==m){if(m)continue;f=!1;break}if(h){if(!Z(t,(function(e,t){if(i=t,!h.has(i)&&(y===e||o(y,e,r,n,a)))return h.push(t);var i}))){f=!1;break}}else if(y!==d&&!o(y,d,r,n,a)){f=!1;break}}return a.delete(e),a.delete(t),f}var te=g.Uint8Array;function re(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function ne(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var oe=O?O.prototype:void 0,ae=oe?oe.valueOf:void 0;var ie=Array.isArray;var se=Object.prototype.propertyIsEnumerable,ce=Object.getOwnPropertySymbols,ue=ce?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,o=0,a=[];++r<n;){var i=e[r];t(i,r,e)&&(a[o++]=i)}return a}(ce(e),(function(t){return se.call(e,t)})))}:function(){return[]};function pe(e){return null!=e&&"object"==typeof e}function le(e){return pe(e)&&"[object Arguments]"==R(e)}var fe=Object.prototype,he=fe.hasOwnProperty,ye=fe.propertyIsEnumerable,de=le(function(){return arguments}())?le:function(e){return pe(e)&&he.call(e,"callee")&&!ye.call(e,"callee")};var me="object"==typeof exports&&exports&&!exports.nodeType&&exports,ve=me&&"object"==typeof module&&module&&!module.nodeType&&module,be=ve&&ve.exports===me?g.Buffer:void 0,_e=(be?be.isBuffer:void 0)||function(){return!1},ge=/^(?:0|[1-9]\d*)$/;function Oe(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&ge.test(e))&&e>-1&&e%1==0&&e<t}function je(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var Ee={};Ee["[object Float32Array]"]=Ee["[object Float64Array]"]=Ee["[object Int8Array]"]=Ee["[object Int16Array]"]=Ee["[object Int32Array]"]=Ee["[object Uint8Array]"]=Ee["[object Uint8ClampedArray]"]=Ee["[object Uint16Array]"]=Ee["[object Uint32Array]"]=!0,Ee["[object Arguments]"]=Ee["[object Array]"]=Ee["[object ArrayBuffer]"]=Ee["[object Boolean]"]=Ee["[object DataView]"]=Ee["[object Date]"]=Ee["[object Error]"]=Ee["[object Function]"]=Ee["[object Map]"]=Ee["[object Number]"]=Ee["[object Object]"]=Ee["[object RegExp]"]=Ee["[object Set]"]=Ee["[object String]"]=Ee["[object WeakMap]"]=!1;var we,xe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Te=xe&&"object"==typeof module&&module&&!module.nodeType&&module,Se=Te&&Te.exports===xe&&b.process,Re=function(){try{var e=Te&&Te.require&&Te.require("util").types;return e||Se&&Se.binding&&Se.binding("util")}catch(e){}}(),Ae=Re&&Re.isTypedArray,Pe=Ae?(we=Ae,function(e){return we(e)}):function(e){return pe(e)&&je(e.length)&&!!Ee[R(e)]},Ne=Object.prototype.hasOwnProperty;function Ce(e,t){var r=ie(e),n=!r&&de(e),o=!r&&!n&&_e(e),a=!r&&!n&&!o&&Pe(e),i=r||n||o||a,s=i?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!Ne.call(e,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Oe(u,c))||s.push(u);return s}var De=Object.prototype;var Ie=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),ke=Object.prototype.hasOwnProperty;function Me(e){if(r=(t=e)&&t.constructor,t!==("function"==typeof r&&r.prototype||De))return Ie(e);var t,r,n=[];for(var o in Object(e))ke.call(e,o)&&"constructor"!=o&&n.push(o);return n}function Le(e){return null!=(t=e)&&je(t.length)&&!P(t)?Ce(e):Me(e);var t}function Ve(e){return function(e,t,r){var n=t(e);return ie(e)?n:function(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}(n,r(e))}(e,Le,ue)}var ze=Object.prototype.hasOwnProperty;var Fe=B(g,"DataView"),Ge=B(g,"Promise"),Ue=B(g,"Set"),Be=B(g,"WeakMap"),Ye=k(Fe),qe=k(Y),We=k(Ge),Je=k(Ue),$e=k(Be),Xe=R;(Fe&&"[object DataView]"!=Xe(new Fe(new ArrayBuffer(1)))||Y&&"[object Map]"!=Xe(new Y)||Ge&&"[object Promise]"!=Xe(Ge.resolve())||Ue&&"[object Set]"!=Xe(new Ue)||Be&&"[object WeakMap]"!=Xe(new Be))&&(Xe=function(e){var t=R(e),r="[object Object]"==t?e.constructor:void 0,n=r?k(r):"";if(n)switch(n){case Ye:return"[object DataView]";case qe:return"[object Map]";case We:return"[object Promise]";case Je:return"[object Set]";case $e:return"[object WeakMap]"}return t});var He,Ke=Xe,Qe="[object Object]",Ze=Object.prototype.hasOwnProperty;function et(e,t,r,n,o,a){var i=ie(e),s=ie(t),c=i?"[object Array]":Ke(e),u=s?"[object Array]":Ke(t),p=(c="[object Arguments]"==c?Qe:c)==Qe,l=(u="[object Arguments]"==u?Qe:u)==Qe,f=c==u;if(f&&_e(e)){if(!_e(t))return!1;i=!0,p=!1}if(f&&!p)return a||(a=new K),i||Pe(e)?ee(e,t,r,n,o,a):function(e,t,r,n,o,a,i){switch(r){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!a(new te(e),new te(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return h(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=re;case"[object Set]":var c=1&n;if(s||(s=ne),e.size!=t.size&&!c)return!1;var u=i.get(e);if(u)return u==t;n|=2,i.set(e,t);var p=ee(s(e),s(t),n,o,a,i);return i.delete(e),p;case"[object Symbol]":if(ae)return ae.call(e)==ae.call(t)}return!1}(e,t,c,r,n,o,a);if(!(1&r)){var y=p&&Ze.call(e,"__wrapped__"),d=l&&Ze.call(t,"__wrapped__");if(y||d){var m=y?e.value():e,v=d?t.value():t;return a||(a=new K),o(m,v,r,n,a)}}return!!f&&(a||(a=new K),function(e,t,r,n,o,a){var i=1&r,s=Ve(e),c=s.length;if(c!=Ve(t).length&&!i)return!1;for(var u=c;u--;){var p=s[u];if(!(i?p in t:ze.call(t,p)))return!1}var l=a.get(e),f=a.get(t);if(l&&f)return l==t&&f==e;var h=!0;a.set(e,t),a.set(t,e);for(var y=i;++u<c;){var d=e[p=s[u]],m=t[p];if(n)var v=i?n(m,d,p,t,e,a):n(d,m,p,e,t,a);if(!(void 0===v?d===m||o(d,m,r,n,a):v)){h=!1;break}y||(y="constructor"==p)}if(h&&!y){var b=e.constructor,_=t.constructor;b==_||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof _&&_ instanceof _||(h=!1)}return a.delete(e),a.delete(t),h}(e,t,r,n,o,a))}function tt(e,t,r,n,o){return e===t||(null==e||null==t||!pe(e)&&!pe(t)?e!=e&&t!=t:et(e,t,r,n,tt,o))}function rt(e,t){return tt(e,t)}exports.OBSERVER_TYPE=void 0,(He=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",He.REMOVE="REMOVE",He.CHANGE="CHANGE";var nt={},ot={},at={},it={};function st(e,t){nt[e.gameObject.id]||(nt[e.gameObject.id]={});var r=nt[e.gameObject.id],n=e.name+"_"+t.join(",");if(r[n])return r[n];for(var o=t.length-1,a=e,i=0;i<o;i++)a=a[t[i]];return r[n]={property:a,key:t[o]},r[n]}function ct(e){var t=e.systemName,r=e.componentName,n=e.component,o=e.prop,a=e.type;ot[t].componentObserver.add({component:n,prop:o,type:a,componentName:r})}function ut(e){var t,r,n=e.obj,o=e.key,a=e.prop,i=e.component,s=e.componentName;if(void 0!==n)if(o in n){if(Object.defineProperty(n,"_"+o,{enumerable:!1,writable:!0,value:n[o]}),a.deep&&A(n[o]))try{for(var c=u(Object.keys(n[o])),p=c.next();!p.done;p=c.next()){var l=p.value;ut({obj:n[o],key:l,prop:a,component:i,componentName:s})}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}Object.defineProperty(n,o,{enumerable:!0,set:function(e){n["_"+o]!==e&&(n["_"+o]=e,function(e){var t=e.prop,r=e.component,n=e.componentName;for(var o in at){var a=(at[o]||{})[n];a&&a.findIndex((function(e){return rt(e,t)}))>-1&&ct({systemName:o,componentName:n,component:r,prop:t,type:exports.OBSERVER_TYPE.CHANGE})}}({prop:a,component:i,componentName:s}))},get:function(){return n["_"+o]}})}else console.error("prop "+o+" not in component: "+s+", Can not observer")}function pt(e,t){for(var r in void 0===t&&(t=e.name),at){(at[r]||{})[t]&&ot[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t})}!function(e){e.gameObject&&delete nt[e.gameObject.id]}(e)}function lt(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}var ft=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Transform",t._parent=null,t.inScene=!1,t.children=[],t.position={x:0,y:0},t.size={width:0,height:0},t.origin={x:0,y:0},t.anchor={x:0,y:0},t.scale={x:1,y:1},t.skew={x:0,y:0},t.rotation=0,t}return a(t,e),t.prototype.init=function(e){var t,r;void 0===e&&(e={});try{for(var n=u(["position","size","origin","anchor","scale","skew"]),o=n.next();!o.done;o=n.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",i([lt],t.prototype,"position",void 0),i([lt],t.prototype,"size",void 0),i([lt],t.prototype,"origin",void 0),i([lt],t.prototype,"anchor",void 0),i([lt],t.prototype,"scale",void 0),i([lt],t.prototype,"skew",void 0),i([lt],t.prototype,"rotation",void 0),t}(f),ht=0;var yt,dt=function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++ht,this.addComponent(ft,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(ft.componentName)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t,r;if(this._scene!==e){var n=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var o=u(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):n&&n.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error("gameObject '"+this.name+"' has been destroy");t.transform.parent=this.transform,t.scene=this.scene}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var r=function(e){return e instanceof f?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[r]){var n;if(e instanceof Function)n=new e(t);else{if(!(e instanceof f))throw new Error("addComponent recieve Component and Component Constructor");n=e}if(n.gameObject)throw new Error("component has been added on gameObject "+n.gameObject.name);return n.gameObject=this,n.init&&n.init(n.__componentDefaultParams),function(e,t){for(var r in void 0===t&&(t=e.name),at)(at[r]||{})[t]&&ot[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t})}(n,n.name),function(e,t){var r,n;if(void 0===t&&(t=e.name),t&&it[t]){if(!(e&&(o=e,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=u(it[t]),i=a.next();!i.done;i=a.next()){var s=i.value,c=st(e,s.prop);ut({obj:c.property,key:c.key,prop:s,component:e,componentName:t})}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}}(n,n.name),this.components.push(n),this._componentCache[r]=n,n.awake&&n.awake(),n}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof f?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var r=this.components.splice(t,1)[0];return delete this._componentCache[e],r.onDestroy&&r.onDestroy(),pt(r,e),r.gameObject=void 0,r}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof f?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}(),mt=function(){function e(){this.events=[]}return e.prototype.add=function(e){var t=e.component,r=e.prop,n=e.type,o=e.componentName;n===exports.OBSERVER_TYPE.REMOVE&&(this.events=this.events.filter((function(e){return e.component!==t})));var a=this.events.findIndex((function(e){return e.component===t&&rt(e.prop,r)&&e.type===n}));a>-1&&this.events.splice(a,1),this.events.push({gameObject:t.gameObject,component:t,prop:r,type:n,componentName:o})},e.prototype.getChanged=function(){return this.events},Object.defineProperty(e.prototype,"changed",{get:function(){return this.events},enumerable:!1,configurable:!0}),e.prototype.clear=function(){var e=this.events;return this.events=[],e},e}(),vt=function(){function e(e){this.started=!1,this.componentObserver=new mt,this.__systemDefaultParams=e,this.name=this.constructor.systemName}return e.prototype.destroy=function(){this.componentObserver=null,this.__systemDefaultParams=null,this.onDestroy()},e}(),bt={autoStart:!0,frameRate:60},_t=function(){function e(e){var t=this;e=Object.assign({},bt,e),this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this._tickers=new Set,this._requestId=null,this._blockTime=0,this._lastTime=Date.now(),this._frameCount=0,this._activeWithPause=!1,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start(),this.bindEvent()}return e.prototype.update=function(){var e,t,r=Date.now();if(r-this._lastTime>=this._frameDuration){var n=r-this._lastTime,o={deltaTime:n,frameCount:++this._frameCount,time:r-this._blockTime,fps:Math.round(1e3/n)};try{for(var a=u(this._tickers),i=a.next();!i.done;i=a.next()){var s=i.value;"function"==typeof s&&s(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}this._lastTime=r}},e.prototype.add=function(e){this._tickers.add(e)},e.prototype.remove=function(e){this._tickers.delete(e)},e.prototype.start=function(){this._started||(this._lastStopTime>0&&(this._blockTime=this._blockTime+Date.now()-this._lastStopTime,this._lastStopTime=0),this._started=!0,this._lastTime=Date.now(),this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this._lastStopTime=Date.now()},e.prototype.active=function(){this._activeWithPause||this.start(),this._activeWithPause=!1},e.prototype.background=function(){this._started?this.pause():this._activeWithPause=!0},e.prototype.bindEvent=function(){},e}(),gt=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.gameObjects=[],n.scene=n,n}return a(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(dt);exports.LOAD_SCENE_MODE=void 0,(yt=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",yt.MULTI_CANVAS="MULTI_CANVAS";var Ot=function(e){if((e instanceof vt||e instanceof f)&&!e.started){try{e.start&&e.start()}catch(t){e instanceof f?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}e.started=!0}},jt=function(e){function t(t){var r,n,o=void 0===t?{}:t,a=o.autoStart,i=void 0===a||a,s=o.frameRate,c=void 0===s?120:s,p=o.systems,l=o.needScene,f=void 0===l||l,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],h.ticker=new _t({autoStart:!1,frameRate:c}),h.initTicker(),p&&p.length)try{for(var y=u(p),d=y.next();!d.done;d=y.next()){var m=d.value;h.addSystem(m)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(n=y.return)&&n.call(y)}finally{if(r)throw r.error}}return f&&h.loadScene(new gt("scene")),i&&h.start(),h}return a(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gameObjects",{get:function(){return function(e){var t,r,n,o=(null===(n=null==e?void 0:e.scene)||void 0===n?void 0:n.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),i=[];try{for(var s=u(a),c=s.next();!c.done;c=s.next())i=l(i,c.value)}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return l(o,i)}(this)},enumerable:!1,configurable:!0}),t.prototype.addSystem=function(e,t){var r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof vt))return void console.warn("can only add System");r=e}if(!this.systems.find((function(e){return e.constructor===r.constructor}))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(e,t){at[t.systemName]=t.observerInfo,ot[t.systemName]=e}(r,r.constructor),function(e){var t,r,n,o,a=[];e instanceof Array?a.push.apply(a,l(e)):a.push(e);try{for(var i=u(a),s=i.next();!s.done;s=i.next()){var c=s.value;for(var p in c.observerInfo){it[p]=it[p]||[];var f=it[p],h=function(e){-1===f.findIndex((function(t){return rt(t,e)}))&&it[p].push(e)};try{for(var y=(n=void 0,u(c.observerInfo[p])),d=y.next();!d.done;d=y.next())h(d.value)}catch(e){n={error:e}}finally{try{d&&!d.done&&(o=y.return)&&o.call(y)}finally{if(n)throw n.error}}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}(r.constructor);try{r.awake&&r.awake()}catch(e){console.error(r.constructor.systemName+" awake error",e)}return this.systems.push(r),r}console.warn(r.constructor.systemName+" System has been added")},t.prototype.removeSystem=function(e){if(e){var t=-1;"string"==typeof e?t=this.systems.findIndex((function(t){return t.name===e})):e instanceof Function?t=this.systems.findIndex((function(t){return t.constructor===e})):e instanceof vt&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},t.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},t.prototype.pause=function(){!1!==this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},t.prototype.start=function(){!0!==this.playing&&(this.ticker.start(),this.playing=!0,this.started=!0)},t.prototype.resume=function(){!0!==this.playing&&(this.ticker.start(),this.triggerResume(),this.playing=!0)},t.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var r,n,o,a;e.scene&&function(e,t){var r,n,o,a,i,s,c,p;void 0===t&&(t=[]);try{for(var l=u(t),f=l.next();!f.done;f=l.next()){var h=f.value;try{for(var y=(o=void 0,u(h.components)),d=y.next();!d.done;d=y.next()){var m=d.value;try{Ot(m),m.update&&m.update(e)}catch(e){console.error("gameObject: "+h.name+" "+m.name+" update error",e)}}}catch(e){o={error:e}}finally{try{d&&!d.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}try{for(var v=u(t),b=v.next();!b.done;b=v.next()){h=b.value;try{for(var _=(c=void 0,u(h.components)),g=_.next();!g.done;g=_.next()){m=g.value;try{m.lateUpdate&&m.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+m.name+" lateUpdate error",e)}}}catch(e){c={error:e}}finally{try{g&&!g.done&&(p=_.return)&&p.call(_)}finally{if(c)throw c.error}}}}catch(e){i={error:e}}finally{try{b&&!b.done&&(s=v.return)&&s.call(v)}finally{if(i)throw i.error}}}(t,e.gameObjects);try{for(var i=u(e.systems),s=i.next();!s.done;s=i.next()){var c=s.value;try{Ot(c),c.update&&c.update(t)}catch(t){console.error(c.constructor.systemName+" update error",t)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}try{for(var p=u(e.systems),l=p.next();!l.done;l=p.next()){c=l.value;try{c.lateUpdate&&c.lateUpdate(t)}catch(t){console.error(c.constructor.systemName+" lateUpdate error",t)}}}catch(e){o={error:e}}finally{try{l&&!l.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}}))},t.prototype.triggerResume=function(){var e,t;!function(e){var t,r,n,o;try{for(var a=u(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(n=void 0,u(s.components)),p=c.next();!p.done;p=c.next()){var l=p.value;try{l.onResume&&l.onResume()}catch(e){console.error("gameObject: "+s.name+", "+l.name+", onResume error",e)}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=u(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onResume&&o.onResume()}catch(e){console.error(o.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t.prototype.triggerPause=function(){var e,t;!function(e){var t,r,n,o;try{for(var a=u(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(n=void 0,u(s.components)),p=c.next();!p.done;p=c.next()){var l=p.value;try{l.onPause&&l.onPause()}catch(e){console.error("gameObject: "+s.name+", "+l.name+", onResume error",e)}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=u(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onPause&&o.onPause()}catch(e){console.error(o.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t.prototype.destroySystems=function(){var e,t;try{for(var r=u(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;this.removeSystem(o)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},t.prototype.loadScene=function(e){var t=e.scene,r=e.mode,n=void 0===r?exports.LOAD_SCENE_MODE.SINGLE:r,o=e.params,a=void 0===o?{}:o;if(t){switch(n){case exports.LOAD_SCENE_MODE.SINGLE:this.scene=t;break;case exports.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:n,params:a})}},t}(n.default);function Et(e){return void 0===e&&(e={}),function(t){if(!t.observerInfo){for(var r in e)for(var n in e[r]){"string"==typeof e[r][n]&&(e[r][n]=[e[r][n]]);var o=void 0;Array.isArray(e[r][n])&&(o={prop:e[r][n],deep:!1},e[r][n]=o),"string"==typeof(o=e[r][n]).prop&&(o.prop=[o.prop])}t.observerInfo=e}}}var wt,xt,Tt=function(e){function t(t){var r=t.resource,n=t.resourceTotal,o=e.call(this)||this;return o.progress=0,o.resourceTotal=0,o.resourceLoadedCount=0,o.resource=r,o.resourceTotal=n,0===n&&o.resource.emit(exports.LOAD_EVENT.COMPLETE,o),o}return a(t,e),t.prototype.onStart=function(){this.resource.emit(exports.LOAD_EVENT.START,this)},t.prototype.onProgress=function(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(exports.LOAD_EVENT.LOADED,this,e):this.resource.emit(exports.LOAD_EVENT.ERROR,this,e),this.resource.emit(exports.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)},t}(n.default);exports.LOAD_EVENT=void 0,(wt=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",wt.PROGRESS="progress",wt.LOADED="loaded",wt.COMPLETE="complete",wt.ERROR="error",exports.RESOURCE_TYPE=void 0,(xt=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",xt.SPRITE="SPRITE",xt.SPRITE_ANIMATION="SPRITE_ANIMATION",xt.DRAGONBONE="DRAGONBONE",xt.SPINE="SPINE",xt.AUDIO="AUDIO",xt.VIDEO="VIDEO";var St={png:{loadType:t.ResourceType.Image},jpg:{loadType:t.ResourceType.Image},jpeg:{loadType:t.ResourceType.Image},webp:{loadType:t.ResourceType.Image},json:{loadType:t.ResourceType.Json,responseType:t.XhrResponseType.Json},tex:{loadType:t.ResourceType.Json,responseType:t.XhrResponseType.Json},ske:{loadType:t.ResourceType.Json,responseType:t.XhrResponseType.Json}},Rt=new(function(e){function r(t){var r=e.call(this)||this;return r.timeout=6e3,r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return a(r,e),r.prototype.loadConfig=function(e){this.addResource(e),this.preload()},r.prototype.loadSingle=function(e){return this.addResource([e]),this.getResource(e.name)},r.prototype.addResource=function(e){var t,r;if(!e||e.length<1)console.warn("no resources");else try{for(var n=u(e),o=n.next();!o.done;o=n.next()){var a=o.value;this.resourcesMap[a.name]?console.warn(a.name+" was already added"):(this.resourcesMap[a.name]=a,this.resourcesMap[a.name].data={})}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},r.prototype.preload=function(){var e=Object.values(this.resourcesMap).filter((function(e){return e.preload})).map((function(e){return e.name}));this.progress=new Tt({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})},r.prototype.getResource=function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return this.loadResource({names:[e]}),[2,this.promiseMap[e]||Promise.resolve({})]}))}))},r.prototype.instance=function(e){return s(this,void 0,void 0,(function(){var t,r;return c(this,(function(n){switch(n.label){case 0:return t=this.resourcesMap[e],(r=this.makeInstanceFunctions[t.type])?[4,this.makeInstanceFunctions[t.type](t)]:[3,2];case 1:r=n.sent(),n.label=2;case 2:return[2,r]}}))}))},r.prototype.destroy=function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this._destroy(e)];case 1:return t.sent(),[2]}}))}))},r.prototype._destroy=function(e,t){return void 0===t&&(t=!1),s(this,void 0,void 0,(function(){var r,n;return c(this,(function(o){switch(o.label){case 0:if(!(r=this.resourcesMap[e]))return[2];if(t)return[3,5];o.label=1;case 1:return o.trys.push([1,4,,5]),this.destroyInstanceFunctions[r.type]?[4,this.destroyInstanceFunctions[r.type](r)]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return n=o.sent(),console.warn("destroy resource "+r.name+" error with '"+n.message+"'"),[3,5];case 5:return delete this.promiseMap[e],r.complete=!1,r.instance=void 0,[2]}}))}))},r.prototype.registerInstance=function(e,t){this.makeInstanceFunctions[e]=t},r.prototype.registerDestroy=function(e,t){this.destroyInstanceFunctions[e]=t},r.prototype.loadResource=function(e){var t=this,r=e.names,n=void 0===r?[]:r,o=e.preload,a=void 0!==o&&o,i=n.filter((function(e){return!t.promiseMap[e]&&t.resourcesMap[e]}));if(i.length){var s={},c=this.getLoader(a);i.forEach((function(e){t.promiseMap[e]=new Promise((function(t){return s[e]=t}));var r=t.resourcesMap[e];for(var n in r.src){var o=r.src[n].type;"data"===o?(r.data[n]=r.src[n].data,t.doComplete(e,s[e],a)):c.add({url:r.src[n].url,name:r.name+"_"+n,metadata:{key:n,name:r.name,resolves:s},type:St[o]&&St[o].loadType,xhrType:t.getXhrType(o)})}})),c.load()}},r.prototype.doComplete=function(e,t,r){return void 0===r&&(r=!1),s(this,void 0,void 0,(function(){var n,o,a,i;return c(this,(function(s){switch(s.label){case 0:if(n=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0},!this.checkAllLoaded(e))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),a=n,[4,this.instance(e)];case 2:return a.instance=s.sent(),n.complete=!0,r&&this.progress.onProgress(o),t(n),[3,4];case 3:return i=s.sent(),n.complete=!1,r&&(o.errMsg=i.message,o.success=!1,this.progress.onProgress(o)),t({}),[3,4];case 4:return[2]}}))}))},r.prototype.checkAllLoaded=function(e){var t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((function(e){return t.data[e]}))},r.prototype.getLoader=function(e){var r=this;void 0===e&&(e=!1);var n=this.loaders.find((function(e){return!e.loading}));return n||(n=new t.Loader,this.loaders.push(n)),e&&n.onStart.once((function(){r.progress.onStart()})),n.onLoad.add((function(t,n){r.onLoad({preload:e,loader:t,resource:n})})),n.onError.add((function(t,n,o){r.onError({errMsg:t,loader:n,resource:o,preload:e})})),n.onComplete.once((function(){n.onLoad.detachAll(),n.onError.detachAll(),n.reset()})),n},r.prototype.onLoad=function(e){var t=e.preload,r=void 0!==t&&t;e.loader;var n=e.resource;return s(this,void 0,void 0,(function(){var e,t,o,a,i;return c(this,(function(s){return e=n.metadata,t=e.key,o=e.name,a=e.resolves,i=n.data,this.resourcesMap[o].data[t]=i,this.doComplete(o,a[o],r),[2]}))}))},r.prototype.onError=function(e){var t=e.errMsg,r=e.preload,n=void 0!==r&&r;e.loader;var o=e.resource;return s(this,void 0,void 0,(function(){var e,r,a,i;return c(this,(function(s){return e=o.metadata,r=e.name,a=e.resolves,this._destroy(r,!0),a[r]({}),n&&(i={name:r,resource:this.resourcesMap[r],success:!1,errMsg:t},this.progress.onProgress(i)),[2]}))}))},r.prototype.getXhrType=function(e){if(St[e]&&St[e].loadType===t.ResourceType.Json)return St[e].responseType},r}(n.default)),At={IDEProp:lt,componentObserver:Et};exports.Component=f,exports.Game=jt,exports.GameObject=dt,exports.IDEProp=lt,exports.Scene=gt,exports.System=vt,exports.Transform=ft,exports.componentObserver=Et,exports.decorators=At,exports.resource=Rt; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("resource-loader");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function a(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var o,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(s=(a<3?o(s):a>3?o(t,r,s):o(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}function i(e,t,r,n){return new(r||(r=Promise))((function(o,a){function s(e){try{c(n.next(e))}catch(e){a(e)}}function i(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(s,i)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var r,n,o,a,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function u(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function p(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return s}function l(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(p(arguments[t]));return e}var f=function(e){function t(t){var r=e.call(this)||this;return r.started=!1,r.name=r.constructor.componentName,r.__componentDefaultParams=t,r}return a(t,e),t}(n.default);function h(e,t){return e===t||e!=e&&t!=t}function y(e,t){for(var r=e.length;r--;)if(h(e[r][0],t))return r;return-1}var d=Array.prototype.splice;function m(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}m.prototype.clear=function(){this.__data__=[],this.size=0},m.prototype.delete=function(e){var t=this.__data__,r=y(t,e);return!(r<0)&&(r==t.length-1?t.pop():d.call(t,r,1),--this.size,!0)},m.prototype.get=function(e){var t=this.__data__,r=y(t,e);return r<0?void 0:t[r][1]},m.prototype.has=function(e){return y(this.__data__,e)>-1},m.prototype.set=function(e,t){var r=this.__data__,n=y(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var v="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b="object"==typeof v&&v&&v.Object===Object&&v,_="object"==typeof self&&self&&self.Object===Object&&self,g=b||_||Function("return this")(),O=g.Symbol,j=Object.prototype,E=j.hasOwnProperty,w=j.toString,x=O?O.toStringTag:void 0;var S=Object.prototype.toString;var T=O?O.toStringTag:void 0;function R(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":T&&T in Object(e)?function(e){var t=E.call(e,x),r=e[x];try{e[x]=void 0;var n=!0}catch(e){}var o=w.call(e);return n&&(t?e[x]=r:delete e[x]),o}(e):function(e){return S.call(e)}(e)}function A(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function P(e){if(!A(e))return!1;var t=R(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var N,I=g["__core-js_shared__"],C=(N=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"";var D=Function.prototype.toString;function k(e){if(null!=e){try{return D.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var M=/^\[object .+?Constructor\]$/,L=Function.prototype,V=Object.prototype,z=L.toString,F=V.hasOwnProperty,G=RegExp("^"+z.call(F).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function U(e){return!(!A(e)||(t=e,C&&C in t))&&(P(e)?G:M).test(k(e));var t}function B(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return U(r)?r:void 0}var Y=B(g,"Map"),q=B(Object,"create");var W=Object.prototype.hasOwnProperty;var X=Object.prototype.hasOwnProperty;function J(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function $(e,t){var r,n,o=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof t?"string":"hash"]:o.map}function H(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}J.prototype.clear=function(){this.__data__=q?q(null):{},this.size=0},J.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},J.prototype.get=function(e){var t=this.__data__;if(q){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return W.call(t,e)?t[e]:void 0},J.prototype.has=function(e){var t=this.__data__;return q?void 0!==t[e]:X.call(t,e)},J.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=q&&void 0===t?"__lodash_hash_undefined__":t,this},H.prototype.clear=function(){this.size=0,this.__data__={hash:new J,map:new(Y||m),string:new J}},H.prototype.delete=function(e){var t=$(this,e).delete(e);return this.size-=t?1:0,t},H.prototype.get=function(e){return $(this,e).get(e)},H.prototype.has=function(e){return $(this,e).has(e)},H.prototype.set=function(e,t){var r=$(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function K(e){var t=this.__data__=new m(e);this.size=t.size}K.prototype.clear=function(){this.__data__=new m,this.size=0},K.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},K.prototype.get=function(e){return this.__data__.get(e)},K.prototype.has=function(e){return this.__data__.has(e)},K.prototype.set=function(e,t){var r=this.__data__;if(r instanceof m){var n=r.__data__;if(!Y||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new H(n)}return r.set(e,t),this.size=r.size,this};function Q(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new H;++t<r;)this.add(e[t])}function Z(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}Q.prototype.add=Q.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Q.prototype.has=function(e){return this.__data__.has(e)};function ee(e,t,r,n,o,a){var s=1&r,i=e.length,c=t.length;if(i!=c&&!(s&&c>i))return!1;var u=a.get(e),p=a.get(t);if(u&&p)return u==t&&p==e;var l=-1,f=!0,h=2&r?new Q:void 0;for(a.set(e,t),a.set(t,e);++l<i;){var y=e[l],d=t[l];if(n)var m=s?n(d,y,l,t,e,a):n(y,d,l,e,t,a);if(void 0!==m){if(m)continue;f=!1;break}if(h){if(!Z(t,(function(e,t){if(s=t,!h.has(s)&&(y===e||o(y,e,r,n,a)))return h.push(t);var s}))){f=!1;break}}else if(y!==d&&!o(y,d,r,n,a)){f=!1;break}}return a.delete(e),a.delete(t),f}var te=g.Uint8Array;function re(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function ne(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var oe=O?O.prototype:void 0,ae=oe?oe.valueOf:void 0;var se=Array.isArray;var ie=Object.prototype.propertyIsEnumerable,ce=Object.getOwnPropertySymbols,ue=ce?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,o=0,a=[];++r<n;){var s=e[r];t(s,r,e)&&(a[o++]=s)}return a}(ce(e),(function(t){return ie.call(e,t)})))}:function(){return[]};function pe(e){return null!=e&&"object"==typeof e}function le(e){return pe(e)&&"[object Arguments]"==R(e)}var fe=Object.prototype,he=fe.hasOwnProperty,ye=fe.propertyIsEnumerable,de=le(function(){return arguments}())?le:function(e){return pe(e)&&he.call(e,"callee")&&!ye.call(e,"callee")};var me="object"==typeof exports&&exports&&!exports.nodeType&&exports,ve=me&&"object"==typeof module&&module&&!module.nodeType&&module,be=ve&&ve.exports===me?g.Buffer:void 0,_e=(be?be.isBuffer:void 0)||function(){return!1},ge=/^(?:0|[1-9]\d*)$/;function Oe(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&ge.test(e))&&e>-1&&e%1==0&&e<t}function je(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var Ee={};Ee["[object Float32Array]"]=Ee["[object Float64Array]"]=Ee["[object Int8Array]"]=Ee["[object Int16Array]"]=Ee["[object Int32Array]"]=Ee["[object Uint8Array]"]=Ee["[object Uint8ClampedArray]"]=Ee["[object Uint16Array]"]=Ee["[object Uint32Array]"]=!0,Ee["[object Arguments]"]=Ee["[object Array]"]=Ee["[object ArrayBuffer]"]=Ee["[object Boolean]"]=Ee["[object DataView]"]=Ee["[object Date]"]=Ee["[object Error]"]=Ee["[object Function]"]=Ee["[object Map]"]=Ee["[object Number]"]=Ee["[object Object]"]=Ee["[object RegExp]"]=Ee["[object Set]"]=Ee["[object String]"]=Ee["[object WeakMap]"]=!1;var we,xe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Se=xe&&"object"==typeof module&&module&&!module.nodeType&&module,Te=Se&&Se.exports===xe&&b.process,Re=function(){try{var e=Se&&Se.require&&Se.require("util").types;return e||Te&&Te.binding&&Te.binding("util")}catch(e){}}(),Ae=Re&&Re.isTypedArray,Pe=Ae?(we=Ae,function(e){return we(e)}):function(e){return pe(e)&&je(e.length)&&!!Ee[R(e)]},Ne=Object.prototype.hasOwnProperty;function Ie(e,t){var r=se(e),n=!r&&de(e),o=!r&&!n&&_e(e),a=!r&&!n&&!o&&Pe(e),s=r||n||o||a,i=s?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=i.length;for(var u in e)!t&&!Ne.call(e,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||a&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||Oe(u,c))||i.push(u);return i}var Ce=Object.prototype;var De=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),ke=Object.prototype.hasOwnProperty;function Me(e){if(r=(t=e)&&t.constructor,t!==("function"==typeof r&&r.prototype||Ce))return De(e);var t,r,n=[];for(var o in Object(e))ke.call(e,o)&&"constructor"!=o&&n.push(o);return n}function Le(e){return null!=(t=e)&&je(t.length)&&!P(t)?Ie(e):Me(e);var t}function Ve(e){return function(e,t,r){var n=t(e);return se(e)?n:function(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}(n,r(e))}(e,Le,ue)}var ze=Object.prototype.hasOwnProperty;var Fe=B(g,"DataView"),Ge=B(g,"Promise"),Ue=B(g,"Set"),Be=B(g,"WeakMap"),Ye=k(Fe),qe=k(Y),We=k(Ge),Xe=k(Ue),Je=k(Be),$e=R;(Fe&&"[object DataView]"!=$e(new Fe(new ArrayBuffer(1)))||Y&&"[object Map]"!=$e(new Y)||Ge&&"[object Promise]"!=$e(Ge.resolve())||Ue&&"[object Set]"!=$e(new Ue)||Be&&"[object WeakMap]"!=$e(new Be))&&($e=function(e){var t=R(e),r="[object Object]"==t?e.constructor:void 0,n=r?k(r):"";if(n)switch(n){case Ye:return"[object DataView]";case qe:return"[object Map]";case We:return"[object Promise]";case Xe:return"[object Set]";case Je:return"[object WeakMap]"}return t});var He,Ke=$e,Qe="[object Object]",Ze=Object.prototype.hasOwnProperty;function et(e,t,r,n,o,a){var s=se(e),i=se(t),c=s?"[object Array]":Ke(e),u=i?"[object Array]":Ke(t),p=(c="[object Arguments]"==c?Qe:c)==Qe,l=(u="[object Arguments]"==u?Qe:u)==Qe,f=c==u;if(f&&_e(e)){if(!_e(t))return!1;s=!0,p=!1}if(f&&!p)return a||(a=new K),s||Pe(e)?ee(e,t,r,n,o,a):function(e,t,r,n,o,a,s){switch(r){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!a(new te(e),new te(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return h(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var i=re;case"[object Set]":var c=1&n;if(i||(i=ne),e.size!=t.size&&!c)return!1;var u=s.get(e);if(u)return u==t;n|=2,s.set(e,t);var p=ee(i(e),i(t),n,o,a,s);return s.delete(e),p;case"[object Symbol]":if(ae)return ae.call(e)==ae.call(t)}return!1}(e,t,c,r,n,o,a);if(!(1&r)){var y=p&&Ze.call(e,"__wrapped__"),d=l&&Ze.call(t,"__wrapped__");if(y||d){var m=y?e.value():e,v=d?t.value():t;return a||(a=new K),o(m,v,r,n,a)}}return!!f&&(a||(a=new K),function(e,t,r,n,o,a){var s=1&r,i=Ve(e),c=i.length;if(c!=Ve(t).length&&!s)return!1;for(var u=c;u--;){var p=i[u];if(!(s?p in t:ze.call(t,p)))return!1}var l=a.get(e),f=a.get(t);if(l&&f)return l==t&&f==e;var h=!0;a.set(e,t),a.set(t,e);for(var y=s;++u<c;){var d=e[p=i[u]],m=t[p];if(n)var v=s?n(m,d,p,t,e,a):n(d,m,p,e,t,a);if(!(void 0===v?d===m||o(d,m,r,n,a):v)){h=!1;break}y||(y="constructor"==p)}if(h&&!y){var b=e.constructor,_=t.constructor;b==_||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof _&&_ instanceof _||(h=!1)}return a.delete(e),a.delete(t),h}(e,t,r,n,o,a))}function tt(e,t,r,n,o){return e===t||(null==e||null==t||!pe(e)&&!pe(t)?e!=e&&t!=t:et(e,t,r,n,tt,o))}function rt(e,t){return tt(e,t)}exports.OBSERVER_TYPE=void 0,(He=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",He.REMOVE="REMOVE",He.CHANGE="CHANGE";var nt={},ot={},at={},st={};function it(e,t){nt[e.gameObject.id]||(nt[e.gameObject.id]={});var r=nt[e.gameObject.id],n=e.name+"_"+t.join(",");if(r[n])return r[n];for(var o=t.length-1,a=e,s=0;s<o;s++)a=a[t[s]];return r[n]={property:a,key:t[o]},r[n]}function ct(e){var t=e.systemName,r=e.componentName,n=e.component,o=e.prop,a=e.type;ot[t].componentObserver.add({component:n,prop:o,type:a,componentName:r})}function ut(e){var t,r,n=e.obj,o=e.key,a=e.prop,s=e.component,i=e.componentName;if(void 0!==n)if(o in n){if(Object.defineProperty(n,"_"+o,{enumerable:!1,writable:!0,value:n[o]}),a.deep&&A(n[o]))try{for(var c=u(Object.keys(n[o])),p=c.next();!p.done;p=c.next()){var l=p.value;ut({obj:n[o],key:l,prop:a,component:s,componentName:i})}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}Object.defineProperty(n,o,{enumerable:!0,set:function(e){n["_"+o]!==e&&(n["_"+o]=e,function(e){var t=e.prop,r=e.component,n=e.componentName;for(var o in at){var a=(at[o]||{})[n];a&&a.findIndex((function(e){return rt(e,t)}))>-1&&ct({systemName:o,componentName:n,component:r,prop:t,type:exports.OBSERVER_TYPE.CHANGE})}}({prop:a,component:s,componentName:i}))},get:function(){return n["_"+o]}})}else console.error("prop "+o+" not in component: "+i+", Can not observer")}function pt(e,t){for(var r in void 0===t&&(t=e.name),at){(at[r]||{})[t]&&ot[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t})}!function(e){e.gameObject&&delete nt[e.gameObject.id]}(e)}function lt(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}var ft=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Transform",t._parent=null,t.inScene=!1,t.children=[],t.position={x:0,y:0},t.size={width:0,height:0},t.origin={x:0,y:0},t.anchor={x:0,y:0},t.scale={x:1,y:1},t.skew={x:0,y:0},t.rotation=0,t}return a(t,e),t.prototype.init=function(e){var t,r;void 0===e&&(e={});try{for(var n=u(["position","size","origin","anchor","scale","skew"]),o=n.next();!o.done;o=n.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",s([lt],t.prototype,"position",void 0),s([lt],t.prototype,"size",void 0),s([lt],t.prototype,"origin",void 0),s([lt],t.prototype,"anchor",void 0),s([lt],t.prototype,"scale",void 0),s([lt],t.prototype,"skew",void 0),s([lt],t.prototype,"rotation",void 0),t}(f),ht=0;var yt,dt=function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++ht,this.addComponent(ft,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(ft.componentName)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t,r;if(this._scene!==e){var n=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var o=u(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):n&&n.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error("gameObject '"+this.name+"' has been destroy");t.transform.parent=this.transform,t.scene=this.scene}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var r=function(e){return e instanceof f?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[r]){var n;if(e instanceof Function)n=new e(t);else{if(!(e instanceof f))throw new Error("addComponent recieve Component and Component Constructor");n=e}if(n.gameObject)throw new Error("component has been added on gameObject "+n.gameObject.name);return n.gameObject=this,n.init&&n.init(n.__componentDefaultParams),function(e,t){for(var r in void 0===t&&(t=e.name),at)(at[r]||{})[t]&&ot[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t})}(n,n.name),function(e,t){var r,n;if(void 0===t&&(t=e.name),t&&st[t]){if(!(e&&(o=e,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=u(st[t]),s=a.next();!s.done;s=a.next()){var i=s.value,c=it(e,i.prop);ut({obj:c.property,key:c.key,prop:i,component:e,componentName:t})}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}}(n,n.name),this.components.push(n),this._componentCache[r]=n,n.awake&&n.awake(),n}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof f?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var r=this.components.splice(t,1)[0];return delete this._componentCache[e],r.onDestroy&&r.onDestroy(),pt(r,e),r.gameObject=void 0,r}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof f?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}(),mt=function(){function e(){this.events=[]}return e.prototype.add=function(e){var t=e.component,r=e.prop,n=e.type,o=e.componentName;n===exports.OBSERVER_TYPE.REMOVE&&(this.events=this.events.filter((function(e){return e.component!==t})));var a=this.events.findIndex((function(e){return e.component===t&&rt(e.prop,r)&&e.type===n}));a>-1&&this.events.splice(a,1),this.events.push({gameObject:t.gameObject,component:t,prop:r,type:n,componentName:o})},e.prototype.getChanged=function(){return this.events},Object.defineProperty(e.prototype,"changed",{get:function(){return this.events},enumerable:!1,configurable:!0}),e.prototype.clear=function(){var e=this.events;return this.events=[],e},e}(),vt=function(){function e(e){this.started=!1,this.componentObserver=new mt,this.__systemDefaultParams=e,this.name=this.constructor.systemName}return e.prototype.destroy=function(){this.componentObserver=null,this.__systemDefaultParams=null,this.onDestroy()},e}(),bt={autoStart:!0,frameRate:60},_t=function(){function e(e){var t=this;e=Object.assign({},bt,e),this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this._tickers=new Set,this._requestId=null,this._blockTime=0,this._lastTime=Date.now(),this._frameCount=0,this._activeWithPause=!1,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start(),this.bindEvent()}return e.prototype.update=function(){var e,t,r=Date.now();if(r-this._lastTime>=this._frameDuration){var n=r-this._lastTime,o={deltaTime:n,frameCount:++this._frameCount,time:r-this._blockTime,fps:Math.round(1e3/n)};try{for(var a=u(this._tickers),s=a.next();!s.done;s=a.next()){var i=s.value;"function"==typeof i&&i(o)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}this._lastTime=r}},e.prototype.add=function(e){this._tickers.add(e)},e.prototype.remove=function(e){this._tickers.delete(e)},e.prototype.start=function(){this._started||(this._lastStopTime>0&&(this._blockTime=this._blockTime+Date.now()-this._lastStopTime,this._lastStopTime=0),this._started=!0,this._lastTime=Date.now(),this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this._lastStopTime=Date.now()},e.prototype.active=function(){this._activeWithPause||this.start(),this._activeWithPause=!1},e.prototype.background=function(){this._started?this.pause():this._activeWithPause=!0},e.prototype.bindEvent=function(){},e}(),gt=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.gameObjects=[],n.scene=n,n}return a(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(dt);exports.LOAD_SCENE_MODE=void 0,(yt=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",yt.MULTI_CANVAS="MULTI_CANVAS";var Ot=function(e){if((e instanceof vt||e instanceof f)&&!e.started){try{e.start&&e.start()}catch(t){e instanceof f?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}e.started=!0}},jt=function(e){function t(t){var r,n,o=void 0===t?{}:t,a=o.autoStart,s=void 0===a||a,i=o.frameRate,c=void 0===i?120:i,p=o.systems,l=o.needScene,f=void 0===l||l,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],h.ticker=new _t({autoStart:!1,frameRate:c}),h.initTicker(),p&&p.length)try{for(var y=u(p),d=y.next();!d.done;d=y.next()){var m=d.value;h.addSystem(m)}}catch(e){r={error:e}}finally{try{d&&!d.done&&(n=y.return)&&n.call(y)}finally{if(r)throw r.error}}return f&&h.loadScene(new gt("scene")),s&&h.start(),h}return a(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gameObjects",{get:function(){return function(e){var t,r,n,o=(null===(n=null==e?void 0:e.scene)||void 0===n?void 0:n.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),s=[];try{for(var i=u(a),c=i.next();!c.done;c=i.next())s=l(s,c.value)}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return l(o,s)}(this)},enumerable:!1,configurable:!0}),t.prototype.addSystem=function(e,t){var r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof vt))return void console.warn("can only add System");r=e}if(!this.systems.find((function(e){return e.constructor===r.constructor}))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(e,t){at[t.systemName]=t.observerInfo,ot[t.systemName]=e}(r,r.constructor),function(e){var t,r,n,o,a=[];e instanceof Array?a.push.apply(a,l(e)):a.push(e);try{for(var s=u(a),i=s.next();!i.done;i=s.next()){var c=i.value;for(var p in c.observerInfo){st[p]=st[p]||[];var f=st[p],h=function(e){-1===f.findIndex((function(t){return rt(t,e)}))&&st[p].push(e)};try{for(var y=(n=void 0,u(c.observerInfo[p])),d=y.next();!d.done;d=y.next())h(d.value)}catch(e){n={error:e}}finally{try{d&&!d.done&&(o=y.return)&&o.call(y)}finally{if(n)throw n.error}}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}(r.constructor);try{r.awake&&r.awake()}catch(e){console.error(r.constructor.systemName+" awake error",e)}return this.systems.push(r),r}console.warn(r.constructor.systemName+" System has been added")},t.prototype.removeSystem=function(e){if(e){var t=-1;"string"==typeof e?t=this.systems.findIndex((function(t){return t.name===e})):e instanceof Function?t=this.systems.findIndex((function(t){return t.constructor===e})):e instanceof vt&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},t.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},t.prototype.pause=function(){!1!==this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},t.prototype.start=function(){!0!==this.playing&&(this.ticker.start(),this.playing=!0,this.started=!0)},t.prototype.resume=function(){!0!==this.playing&&(this.ticker.start(),this.triggerResume(),this.playing=!0)},t.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var r,n,o,a;e.scene&&function(e,t){var r,n,o,a,s,i,c,p;void 0===t&&(t=[]);try{for(var l=u(t),f=l.next();!f.done;f=l.next()){var h=f.value;try{for(var y=(o=void 0,u(h.components)),d=y.next();!d.done;d=y.next()){var m=d.value;try{Ot(m),m.update&&m.update(e)}catch(e){console.error("gameObject: "+h.name+" "+m.name+" update error",e)}}}catch(e){o={error:e}}finally{try{d&&!d.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}try{for(var v=u(t),b=v.next();!b.done;b=v.next()){h=b.value;try{for(var _=(c=void 0,u(h.components)),g=_.next();!g.done;g=_.next()){m=g.value;try{m.lateUpdate&&m.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+m.name+" lateUpdate error",e)}}}catch(e){c={error:e}}finally{try{g&&!g.done&&(p=_.return)&&p.call(_)}finally{if(c)throw c.error}}}}catch(e){s={error:e}}finally{try{b&&!b.done&&(i=v.return)&&i.call(v)}finally{if(s)throw s.error}}}(t,e.gameObjects);try{for(var s=u(e.systems),i=s.next();!i.done;i=s.next()){var c=i.value;try{Ot(c),c.update&&c.update(t)}catch(t){console.error(c.constructor.systemName+" update error",t)}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}try{for(var p=u(e.systems),l=p.next();!l.done;l=p.next()){c=l.value;try{c.lateUpdate&&c.lateUpdate(t)}catch(t){console.error(c.constructor.systemName+" lateUpdate error",t)}}}catch(e){o={error:e}}finally{try{l&&!l.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}}))},t.prototype.triggerResume=function(){var e,t;!function(e){var t,r,n,o;try{for(var a=u(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(n=void 0,u(i.components)),p=c.next();!p.done;p=c.next()){var l=p.value;try{l.onResume&&l.onResume()}catch(e){console.error("gameObject: "+i.name+", "+l.name+", onResume error",e)}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=u(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onResume&&o.onResume()}catch(e){console.error(o.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t.prototype.triggerPause=function(){var e,t;!function(e){var t,r,n,o;try{for(var a=u(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(n=void 0,u(i.components)),p=c.next();!p.done;p=c.next()){var l=p.value;try{l.onPause&&l.onPause()}catch(e){console.error("gameObject: "+i.name+", "+l.name+", onResume error",e)}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=u(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onPause&&o.onPause()}catch(e){console.error(o.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t.prototype.destroySystems=function(){var e,t;try{for(var r=u(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;this.removeSystem(o)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},t.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},t.prototype.loadScene=function(e){var t=e.scene,r=e.mode,n=void 0===r?exports.LOAD_SCENE_MODE.SINGLE:r,o=e.params,a=void 0===o?{}:o;if(t){switch(n){case exports.LOAD_SCENE_MODE.SINGLE:this.scene=t;break;case exports.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:n,params:a})}},t}(n.default);function Et(e){return void 0===e&&(e={}),function(t){if(!t.observerInfo){for(var r in e)for(var n in e[r]){"string"==typeof e[r][n]&&(e[r][n]=[e[r][n]]);var o=void 0;Array.isArray(e[r][n])&&(o={prop:e[r][n],deep:!1},e[r][n]=o),"string"==typeof(o=e[r][n]).prop&&(o.prop=[o.prop])}t.observerInfo=e}}}var wt,xt,St=function(e){function t(t){var r=t.resource,n=t.resourceTotal,o=e.call(this)||this;return o.progress=0,o.resourceTotal=0,o.resourceLoadedCount=0,o.resource=r,o.resourceTotal=n,0===n&&o.resource.emit(exports.LOAD_EVENT.COMPLETE,o),o}return a(t,e),t.prototype.onStart=function(){this.resource.emit(exports.LOAD_EVENT.START,this)},t.prototype.onProgress=function(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(exports.LOAD_EVENT.LOADED,this,e):this.resource.emit(exports.LOAD_EVENT.ERROR,this,e),this.resource.emit(exports.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)},t}(n.default);exports.LOAD_EVENT=void 0,(wt=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",wt.PROGRESS="progress",wt.LOADED="loaded",wt.COMPLETE="complete",wt.ERROR="error",exports.RESOURCE_TYPE=void 0,(xt=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",xt.SPRITE="SPRITE",xt.SPRITE_ANIMATION="SPRITE_ANIMATION",xt.DRAGONBONE="DRAGONBONE",xt.SPINE="SPINE",xt.AUDIO="AUDIO",xt.VIDEO="VIDEO";var Tt={png:{loadType:t.ResourceType.Image,strategy:t.ImageLoadStrategy},jpg:{strategy:t.ImageLoadStrategy,loadType:t.ResourceType.Image},jpeg:{strategy:t.ImageLoadStrategy,loadType:t.ResourceType.Image},webp:{strategy:t.ImageLoadStrategy,loadType:t.ResourceType.Image},json:{strategy:t.XhrLoadStrategy,loadType:t.ResourceType.Json,responseType:t.XhrResponseType.Json},tex:{loadType:t.ResourceType.Json,responseType:t.XhrResponseType.Json,strategy:t.XhrLoadStrategy},ske:{loadType:t.ResourceType.Json,responseType:t.XhrResponseType.Json,strategy:t.XhrLoadStrategy}},Rt=new(function(e){function r(t){var r=e.call(this)||this;return r.timeout=6e3,r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return a(r,e),r.prototype.loadConfig=function(e){this.addResource(e),this.preload()},r.prototype.loadSingle=function(e){return this.addResource([e]),this.getResource(e.name)},r.prototype.addResource=function(e){var t,r;if(!e||e.length<1)console.warn("no resources");else try{for(var n=u(e),o=n.next();!o.done;o=n.next()){var a=o.value;this.resourcesMap[a.name]?console.warn(a.name+" was already added"):(this.resourcesMap[a.name]=a,this.resourcesMap[a.name].data={})}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},r.prototype.preload=function(){var e=Object.values(this.resourcesMap).filter((function(e){return e.preload})).map((function(e){return e.name}));this.progress=new St({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})},r.prototype.getResource=function(e){return i(this,void 0,void 0,(function(){return c(this,(function(t){return this.loadResource({names:[e]}),[2,this.promiseMap[e]||Promise.resolve({})]}))}))},r.prototype.instance=function(e){return i(this,void 0,void 0,(function(){var t,r;return c(this,(function(n){switch(n.label){case 0:return t=this.resourcesMap[e],(r=this.makeInstanceFunctions[t.type])?[4,this.makeInstanceFunctions[t.type](t)]:[3,2];case 1:r=n.sent(),n.label=2;case 2:return[2,r]}}))}))},r.prototype.destroy=function(e){return i(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this._destroy(e)];case 1:return t.sent(),[2]}}))}))},r.prototype._destroy=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var r,n;return c(this,(function(o){switch(o.label){case 0:if(!(r=this.resourcesMap[e]))return[2];if(t)return[3,5];o.label=1;case 1:return o.trys.push([1,4,,5]),this.destroyInstanceFunctions[r.type]?[4,this.destroyInstanceFunctions[r.type](r)]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return n=o.sent(),console.warn("destroy resource "+r.name+" error with '"+n.message+"'"),[3,5];case 5:return delete this.promiseMap[e],r.complete=!1,r.instance=void 0,[2]}}))}))},r.prototype.registerInstance=function(e,t){this.makeInstanceFunctions[e]=t},r.prototype.registerDestroy=function(e,t){this.destroyInstanceFunctions[e]=t},r.prototype.loadResource=function(e){var t=this,r=e.names,n=void 0===r?[]:r,o=e.preload,a=void 0!==o&&o,s=n.filter((function(e){return!t.promiseMap[e]&&t.resourcesMap[e]}));if(s.length){var i={},c=this.getLoader(a);s.forEach((function(e){t.promiseMap[e]=new Promise((function(t){return i[e]=t}));var r=t.resourcesMap[e];for(var n in r.src){var o=r.src[n].type;"data"===o?(r.data[n]=r.src[n].data,t.doComplete(e,i[e],a)):c.add({url:r.src[n].url,name:r.name+"_"+n,metadata:{key:n,name:r.name,resolves:i},strategy:Tt[o]&&Tt[o].strategy,xhrType:t.getXhrType(o)})}})),c.load()}},r.prototype.doComplete=function(e,t,r){return void 0===r&&(r=!1),i(this,void 0,void 0,(function(){var n,o,a,s;return c(this,(function(i){switch(i.label){case 0:if(n=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0},!this.checkAllLoaded(e))return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),a=n,[4,this.instance(e)];case 2:return a.instance=i.sent(),n.complete=!0,r&&this.progress.onProgress(o),t(n),[3,4];case 3:return s=i.sent(),n.complete=!1,r&&(o.errMsg=s.message,o.success=!1,this.progress.onProgress(o)),t({}),[3,4];case 4:return[2]}}))}))},r.prototype.checkAllLoaded=function(e){var t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((function(e){return t.data[e]}))},r.prototype.getLoader=function(e){var r=this;void 0===e&&(e=!1);var n=this.loaders.find((function(e){return!e.loading}));return n||(n=new t.Loader,this.loaders.push(n)),e&&n.onStart.once((function(){r.progress.onStart()})),n.onLoad.add((function(t,n){r.onLoad({preload:e,loader:t,resource:n})})),n.onError.add((function(t,n,o){r.onError({errMsg:t,loader:n,resource:o,preload:e})})),n.onComplete.once((function(){n.onLoad.detachAll(),n.onError.detachAll(),n.reset()})),n},r.prototype.onLoad=function(e){var t=e.preload,r=void 0!==t&&t;e.loader;var n=e.resource;return i(this,void 0,void 0,(function(){var e,t,o,a,s;return c(this,(function(i){return e=n.metadata,t=e.key,o=e.name,a=e.resolves,s=n.data,this.resourcesMap[o].data[t]=s,this.doComplete(o,a[o],r),[2]}))}))},r.prototype.onError=function(e){var t=e.errMsg,r=e.preload,n=void 0!==r&&r;e.loader;var o=e.resource;return i(this,void 0,void 0,(function(){var e,r,a,s;return c(this,(function(i){return e=o.metadata,r=e.name,a=e.resolves,this._destroy(r,!0),a[r]({}),n&&(s={name:r,resource:this.resourcesMap[r],success:!1,errMsg:t},this.progress.onProgress(s)),[2]}))}))},r.prototype.getXhrType=function(e){if(Tt[e]&&Tt[e].loadType===t.ResourceType.Json)return Tt[e].responseType},r}(n.default)),At={IDEProp:lt,componentObserver:Et};exports.Component=f,exports.Game=jt,exports.GameObject=dt,exports.IDEProp=lt,exports.Scene=gt,exports.System=vt,exports.Transform=ft,exports.componentObserver=Et,exports.decorators=At,exports.resource=Rt; |
{ | ||
"name": "@eva/eva.js", | ||
"version": "1.0.1", | ||
"version": "1.0.2-alpha", | ||
"description": "@eva/eva.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
317028
8463
2