@eva/eva.js 1.2.2-mini.2 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/EVA.js CHANGED
@@ -1533,12 +1533,14 @@ var _EVA_IIFE_EVA = function (exports) {
1533
1533
  }
1534
1534
 
1535
1535
  function addObserver(_a) {
1536
+ var _b, _c;
1537
+
1536
1538
  var systemName = _a.systemName,
1537
1539
  componentName = _a.componentName,
1538
1540
  component = _a.component,
1539
1541
  prop = _a.prop,
1540
1542
  type = _a.type;
1541
- systemInstance[systemName].componentObserver.add({
1543
+ (_c = (_b = systemInstance[systemName]) === null || _b === void 0 ? void 0 : _b.componentObserver) === null || _c === void 0 ? void 0 : _c.add({
1542
1544
  component: component,
1543
1545
  prop: prop,
1544
1546
  type: type,
@@ -1751,6 +1753,8 @@ var _EVA_IIFE_EVA = function (exports) {
1751
1753
  }
1752
1754
 
1753
1755
  function observerAdded(component, componentName) {
1756
+ var _a, _b;
1757
+
1754
1758
  if (componentName === void 0) {
1755
1759
  componentName = component.name;
1756
1760
  }
@@ -1760,7 +1764,7 @@ var _EVA_IIFE_EVA = function (exports) {
1760
1764
  var info = observerInfo[componentName];
1761
1765
 
1762
1766
  if (info) {
1763
- systemInstance[systemName].componentObserver.add({
1767
+ (_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
1764
1768
  component: component,
1765
1769
  type: exports.OBSERVER_TYPE.ADD,
1766
1770
  componentName: componentName
@@ -1770,6 +1774,8 @@ var _EVA_IIFE_EVA = function (exports) {
1770
1774
  }
1771
1775
 
1772
1776
  function observerRemoved(component, componentName) {
1777
+ var _a, _b;
1778
+
1773
1779
  if (componentName === void 0) {
1774
1780
  componentName = component.name;
1775
1781
  }
@@ -1779,7 +1785,7 @@ var _EVA_IIFE_EVA = function (exports) {
1779
1785
  var info = observerInfo[componentName];
1780
1786
 
1781
1787
  if (info) {
1782
- systemInstance[systemName].componentObserver.add({
1788
+ (_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
1783
1789
  component: component,
1784
1790
  type: exports.OBSERVER_TYPE.REMOVE,
1785
1791
  componentName: componentName
@@ -2139,6 +2145,11 @@ var _EVA_IIFE_EVA = function (exports) {
2139
2145
  };
2140
2146
 
2141
2147
  GameObject.prototype.destroy = function () {
2148
+ if (!this.transform) {
2149
+ console.error('Cannot destroy gameObject that have already been destroyed.');
2150
+ return;
2151
+ }
2152
+
2142
2153
  Array.from(this.transform.children).forEach(function (_a) {
2143
2154
  var gameObject = _a.gameObject;
2144
2155
  gameObject.destroy();
@@ -4788,7 +4799,7 @@ var _EVA_IIFE_EVA = function (exports) {
4788
4799
  for (var key in this.resourcesMap) {
4789
4800
  var resource_1 = this.resourcesMap[key];
4790
4801
 
4791
- if (resource_1.preload && !resource_1.complete) {
4802
+ if (resource_1.preload && !resource_1.complete && !this.promiseMap[key]) {
4792
4803
  names.push(resource_1.name);
4793
4804
  }
4794
4805
  }
@@ -5144,7 +5155,7 @@ var _EVA_IIFE_EVA = function (exports) {
5144
5155
  IDEProp: IDEProp,
5145
5156
  componentObserver: componentObserver
5146
5157
  };
5147
- var version = '1.2.2-alpha.2';
5158
+ var version = '1.2.2';
5148
5159
  console.log("Eva.js version: " + version);
5149
5160
  exports.Component = Component$1;
5150
5161
  exports.Game = Game$1;
package/dist/EVA.min.js CHANGED
@@ -1 +1 @@
1
- function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var _EVA_IIFE_EVA=function(t){"use strict";var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,r)};function r(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function n(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function c(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t}var u=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||t,s),c=r?r+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,i,s){var a=r?r+t:t;if(!this._events[a])return!1;var c,u,l=this._events[a],p=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),p){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,s),!0}for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(t,l[u].fn,void 0,!0),p){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,e);break;case 3:l[u].fn.call(l[u].context,e,n);break;case 4:l[u].fn.call(l[u].context,e,n,o);break;default:if(!c)for(h=1,c=new Array(p-1);h<p;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==e||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a}));var l=function(t){function e(e){var r=t.call(this)||this;return r.started=!1,r.name=r.constructor.componentName,r.__componentDefaultParams=e,r}return r(e,t),e}(u),p=l,h="object"==typeof global&&global&&global.Object===Object&&global,f="object"==typeof self&&self&&self.Object===Object&&self,d=h||f||Function("return this")(),y=d.Symbol,m=Object.prototype,_=m.hasOwnProperty,v=m.toString,b=y?y.toStringTag:void 0;var g=Object.prototype.toString;var E=y?y.toStringTag:void 0;function O(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":E&&E in Object(t)?function(t){var e=_.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=v.call(t);return n&&(e?t[b]=r:delete t[b]),o}(t):function(t){return g.call(t)}(t)}function w(t){return null!=t&&"object"==typeof t}var x=Array.isArray;function T(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function j(t){if(!T(t))return!1;var e=O(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var k,A=d["__core-js_shared__"],R=(k=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"";var P=Function.prototype.toString;function S(t){if(null!=t){try{return P.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var C=/^\[object .+?Constructor\]$/,L=Function.prototype,M=Object.prototype,D=L.toString,I=M.hasOwnProperty,N=RegExp("^"+D.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function B(t){return!(!T(t)||(e=t,R&&R in e))&&(j(t)?N:C).test(S(t));var e}function U(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return B(r)?r:void 0}var V=U(d,"WeakMap"),q=/^(?:0|[1-9]\d*)$/;function z(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&q.test(t))&&t>-1&&t%1==0&&t<e}function F(t,e){return t===e||t!=t&&e!=e}function G(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var X=Object.prototype;function Y(t){return w(t)&&"[object Arguments]"==O(t)}var H=Object.prototype,J=H.hasOwnProperty,$=H.propertyIsEnumerable,Q=Y(function(){return arguments}())?Y:function(t){return w(t)&&J.call(t,"callee")&&!$.call(t,"callee")};var W="object"==typeof t&&t&&!t.nodeType&&t,K=W&&"object"==typeof module&&module&&!module.nodeType&&module,Z=K&&K.exports===W?d.Buffer:void 0,tt=(Z?Z.isBuffer:void 0)||function(){return!1},et={};et["[object Float32Array]"]=et["[object Float64Array]"]=et["[object Int8Array]"]=et["[object Int16Array]"]=et["[object Int32Array]"]=et["[object Uint8Array]"]=et["[object Uint8ClampedArray]"]=et["[object Uint16Array]"]=et["[object Uint32Array]"]=!0,et["[object Arguments]"]=et["[object Array]"]=et["[object ArrayBuffer]"]=et["[object Boolean]"]=et["[object DataView]"]=et["[object Date]"]=et["[object Error]"]=et["[object Function]"]=et["[object Map]"]=et["[object Number]"]=et["[object Object]"]=et["[object RegExp]"]=et["[object Set]"]=et["[object String]"]=et["[object WeakMap]"]=!1;var rt,nt="object"==typeof t&&t&&!t.nodeType&&t,ot=nt&&"object"==typeof module&&module&&!module.nodeType&&module,it=ot&&ot.exports===nt&&h.process,st=function(){try{var t=ot&&ot.require&&ot.require("util").types;return t||it&&it.binding&&it.binding("util")}catch(t){}}(),at=st&&st.isTypedArray,ct=at?(rt=at,function(t){return rt(t)}):function(t){return w(t)&&G(t.length)&&!!et[O(t)]},ut=Object.prototype.hasOwnProperty;function lt(t,e){var r=x(t),n=!r&&Q(t),o=!r&&!n&&tt(t),i=!r&&!n&&!o&&ct(t),s=r||n||o||i,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var u in t)!e&&!ut.call(t,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||z(u,c))||a.push(u);return a}var pt=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),ht=Object.prototype.hasOwnProperty;function ft(t){if(r=(e=t)&&e.constructor,e!==("function"==typeof r&&r.prototype||X))return pt(t);var e,r,n=[];for(var o in Object(t))ht.call(t,o)&&"constructor"!=o&&n.push(o);return n}function dt(t){return null!=(e=t)&&G(e.length)&&!j(e)?lt(t):ft(t);var e}var yt=U(Object,"create");var mt=Object.prototype.hasOwnProperty;var _t=Object.prototype.hasOwnProperty;function vt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function bt(t,e){for(var r=t.length;r--;)if(F(t[r][0],e))return r;return-1}vt.prototype.clear=function(){this.__data__=yt?yt(null):{},this.size=0},vt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},vt.prototype.get=function(t){var e=this.__data__;if(yt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return mt.call(e,t)?e[t]:void 0},vt.prototype.has=function(t){var e=this.__data__;return yt?void 0!==e[t]:_t.call(e,t)},vt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=yt&&void 0===e?"__lodash_hash_undefined__":e,this};var gt=Array.prototype.splice;function Et(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Et.prototype.clear=function(){this.__data__=[],this.size=0},Et.prototype.delete=function(t){var e=this.__data__,r=bt(e,t);return!(r<0)&&(r==e.length-1?e.pop():gt.call(e,r,1),--this.size,!0)},Et.prototype.get=function(t){var e=this.__data__,r=bt(e,t);return r<0?void 0:e[r][1]},Et.prototype.has=function(t){return bt(this.__data__,t)>-1},Et.prototype.set=function(t,e){var r=this.__data__,n=bt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ot=U(d,"Map");function wt(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function xt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}xt.prototype.clear=function(){this.size=0,this.__data__={hash:new vt,map:new(Ot||Et),string:new vt}},xt.prototype.delete=function(t){var e=wt(this,t).delete(t);return this.size-=e?1:0,e},xt.prototype.get=function(t){return wt(this,t).get(t)},xt.prototype.has=function(t){return wt(this,t).has(t)},xt.prototype.set=function(t,e){var r=wt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Tt(t){var e=this.__data__=new Et(t);this.size=e.size}Tt.prototype.clear=function(){this.__data__=new Et,this.size=0},Tt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Tt.prototype.get=function(t){return this.__data__.get(t)},Tt.prototype.has=function(t){return this.__data__.has(t)},Tt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Et){var n=r.__data__;if(!Ot||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new xt(n)}return r.set(t,e),this.size=r.size,this};var jt=Object.prototype.propertyIsEnumerable,kt=Object.getOwnPropertySymbols,At=kt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i}(kt(t),(function(e){return jt.call(t,e)})))}:function(){return[]};function Rt(t){return function(t,e,r){var n=e(t);return x(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,dt,At)}var Pt=U(d,"DataView"),St=U(d,"Promise"),Ct=U(d,"Set"),Lt="[object Map]",Mt="[object Promise]",Dt="[object Set]",It="[object WeakMap]",Nt="[object DataView]",Bt=S(Pt),Ut=S(Ot),Vt=S(St),qt=S(Ct),zt=S(V),Ft=O;(Pt&&Ft(new Pt(new ArrayBuffer(1)))!=Nt||Ot&&Ft(new Ot)!=Lt||St&&Ft(St.resolve())!=Mt||Ct&&Ft(new Ct)!=Dt||V&&Ft(new V)!=It)&&(Ft=function(t){var e=O(t),r="[object Object]"==e?t.constructor:void 0,n=r?S(r):"";if(n)switch(n){case Bt:return Nt;case Ut:return Lt;case Vt:return Mt;case qt:return Dt;case zt:return It}return e});var Gt=Ft,Xt=d.Uint8Array;function Yt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new xt;++e<r;)this.add(t[e])}function Ht(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}Yt.prototype.add=Yt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Yt.prototype.has=function(t){return this.__data__.has(t)};function Jt(t,e,r,n,o,i){var s=1&r,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=i.get(t),l=i.get(e);if(u&&l)return u==e&&l==t;var p=-1,h=!0,f=2&r?new Yt:void 0;for(i.set(t,e),i.set(e,t);++p<a;){var d=t[p],y=e[p];if(n)var m=s?n(y,d,p,e,t,i):n(d,y,p,t,e,i);if(void 0!==m){if(m)continue;h=!1;break}if(f){if(!Ht(e,(function(t,e){if(s=e,!f.has(s)&&(d===t||o(d,t,r,n,i)))return f.push(e);var s}))){h=!1;break}}else if(d!==y&&!o(d,y,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h}function $t(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function Qt(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var Wt=y?y.prototype:void 0,Kt=Wt?Wt.valueOf:void 0;var Zt=Object.prototype.hasOwnProperty;var te,ee="[object Arguments]",re="[object Array]",ne="[object Object]",oe=Object.prototype.hasOwnProperty;function ie(t,e,r,n,o,i){var s=x(t),a=x(e),c=s?re:Gt(t),u=a?re:Gt(e),l=(c=c==ee?ne:c)==ne,p=(u=u==ee?ne:u)==ne,h=c==u;if(h&&tt(t)){if(!tt(e))return!1;s=!0,l=!1}if(h&&!l)return i||(i=new Tt),s||ct(t)?Jt(t,e,r,n,o,i):function(t,e,r,n,o,i,s){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!i(new Xt(t),new Xt(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return F(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=$t;case"[object Set]":var c=1&n;if(a||(a=Qt),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;n|=2,s.set(t,e);var l=Jt(a(t),a(e),n,o,i,s);return s.delete(t),l;case"[object Symbol]":if(Kt)return Kt.call(t)==Kt.call(e)}return!1}(t,e,c,r,n,o,i);if(!(1&r)){var f=l&&oe.call(t,"__wrapped__"),d=p&&oe.call(e,"__wrapped__");if(f||d){var y=f?t.value():t,m=d?e.value():e;return i||(i=new Tt),o(y,m,r,n,i)}}return!!h&&(i||(i=new Tt),function(t,e,r,n,o,i){var s=1&r,a=Rt(t),c=a.length;if(c!=Rt(e).length&&!s)return!1;for(var u=c;u--;){var l=a[u];if(!(s?l in e:Zt.call(e,l)))return!1}var p=i.get(t),h=i.get(e);if(p&&h)return p==e&&h==t;var f=!0;i.set(t,e),i.set(e,t);for(var d=s;++u<c;){var y=t[l=a[u]],m=e[l];if(n)var _=s?n(m,y,l,e,t,i):n(y,m,l,t,e,i);if(!(void 0===_?y===m||o(y,m,r,n,i):_)){f=!1;break}d||(d="constructor"==l)}if(f&&!d){var v=t.constructor,b=e.constructor;v==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b||(f=!1)}return i.delete(t),i.delete(e),f}(t,e,r,n,o,i))}function se(t,e,r,n,o){return t===e||(null==t||null==e||!w(t)&&!w(e)?t!=t&&e!=e:ie(t,e,r,n,se,o))}function ae(t,e){return se(t,e)}t.OBSERVER_TYPE=void 0,(te=t.OBSERVER_TYPE||(t.OBSERVER_TYPE={})).ADD="ADD",te.REMOVE="REMOVE",te.CHANGE="CHANGE";var ce={},ue={},le={},pe={};function he(t,e){ce[t.gameObject.id]||(ce[t.gameObject.id]={});var r=ce[t.gameObject.id],n=t.name+"_"+e.join(",");if(r[n])return r[n];for(var o=e.length-1,i=t,s=0;s<o;s++)i=i[e[s]];return r[n]={property:i,key:e[o]},r[n]}function fe(t){var e=t.systemName,r=t.componentName,n=t.component,o=t.prop,i=t.type;ue[e].componentObserver.add({component:n,prop:o,type:i,componentName:r})}function de(e){var r,n,o=e.obj,i=e.key,a=e.prop,c=e.component,u=e.componentName;if(void 0!==o)if(i in o){if(Object.defineProperty(o,"_"+i,{enumerable:!1,writable:!0,value:o[i]}),a.deep&&T(o[i]))try{for(var l=s(Object.keys(o[i])),p=l.next();!p.done;p=l.next()){var h=p.value;de({obj:o[i],key:h,prop:a,component:c,componentName:u})}}catch(t){r={error:t}}finally{try{p&&!p.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}Object.defineProperty(o,i,{enumerable:!0,set:function(e){o["_"+i]!==e&&(o["_"+i]=e,function(e){var r=e.prop,n=e.component,o=e.componentName;for(var i in le){var s=(le[i]||{})[o];s&&s.findIndex((function(t){return ae(t,r)}))>-1&&fe({systemName:i,componentName:o,component:n,prop:r,type:t.OBSERVER_TYPE.CHANGE})}}({prop:a,component:c,componentName:u}))},get:function(){return o["_"+i]}})}else console.error("prop "+i+" not in component: "+u+", Can not observer")}function ye(e,r){for(var n in void 0===r&&(r=e.name),le){(le[n]||{})[r]&&ue[n].componentObserver.add({component:e,type:t.OBSERVER_TYPE.REMOVE,componentName:r})}!function(t){t.gameObject&&delete ce[t.gameObject.id]}(e)}function me(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function _e(t){return function(e,r){var n=me(e,r);n.key=r,n.type=t}}function ve(t){return function(e,r){me(e,r).step=t}}var be=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Transform",e._parent=null,e.inScene=!1,e.children=[],e.position={x:0,y:0},e.size={width:0,height:0},e.origin={x:0,y:0},e.anchor={x:0,y:0},e.scale={x:1,y:1},e.skew={x:0,y:0},e.rotation=0,e}return r(e,t),e.prototype.init=function(t){var e,r;void 0===t&&(t={});try{for(var n=s(["position","size","origin","anchor","scale","skew"]),o=n.next();!o.done;o=n.next()){var i=o.value;_extends(this[i],t[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}this.rotation=t.rotation||this.rotation},Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(t){t?t.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t.parent===this){var e=this.children.findIndex((function(e){return e===t}));this.children.splice(e,1)}else t.parent&&t.parent.removeChild(t);t._parent=this,this.children.push(t)},e.prototype.removeChild=function(t){var e=this.children.findIndex((function(e){return e===t}));e>-1&&(this.children.splice(e,1),t._parent=null)},e.prototype.clearChildren=function(){this.children.length=0},e.componentName="Transform",n([_e("vector2"),ve(1)],e.prototype,"position",void 0),n([_e("size"),ve(1)],e.prototype,"size",void 0),n([_e("vector2"),ve(.1)],e.prototype,"origin",void 0),n([_e("vector2"),ve(.1)],e.prototype,"anchor",void 0),n([_e("vector2"),ve(.1)],e.prototype,"scale",void 0),n([_e("vector2"),ve(.1)],e.prototype,"skew",void 0),n([_e("number"),ve(.1)],e.prototype,"rotation",void 0),e}(p),ge=0;var Ee=function(){function e(t,e){this._componentCache={},this.components=[],this._name=t,this.id=++ge,this.addComponent(be,e)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(be)},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(t){var e,r;if(this._scene!==t){var n=this._scene;if(this._scene=t,this.transform&&this.transform.children)try{for(var o=s(this.transform.children),i=o.next();!i.done;i=o.next()){i.value.gameObject.scene=t}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}t?t.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,r){var n=function(t){return t instanceof l?t.name:t instanceof Function?t.componentName:void 0}(e);if(!this._componentCache[n]){var o;if(e instanceof Function)o=new e(r);else{if(!(e instanceof p))throw new Error("addComponent recieve Component and Component Constructor");o=e}if(o.gameObject)throw new Error("component has been added on gameObject "+o.gameObject.name);return o.gameObject=this,o.init&&o.init(o.__componentDefaultParams),function(e,r){for(var n in void 0===r&&(r=e.name),le)(le[n]||{})[r]&&ue[n].componentObserver.add({component:e,type:t.OBSERVER_TYPE.ADD,componentName:r})}(o,o.name),function(t,e){var r,n;if(void 0===e&&(e=t.name),e&&pe[e]){if(!(t&&(o=t,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!t.gameObject||!t.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var i=s(pe[e]),a=i.next();!a.done;a=i.next()){var c=a.value,u=he(t,c.prop);de({obj:u.property,key:u.key,prop:c,component:t,componentName:e})}}catch(t){r={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}}(o,o.name),this.components.push(o),this._componentCache[n]=o,o.awake&&o.awake(),o}},e.prototype.removeComponent=function(t){var e;if("string"==typeof t?e=t:t instanceof p?e=t.name:t.componentName&&(e=t.componentName),"Transform"===e)throw new Error("Transform can't be removed");return this._removeComponent(e)},e.prototype._removeComponent=function(t){var e=this.components.findIndex((function(e){return e.name===t}));if(-1!==e){var r=this.components.splice(e,1)[0];return delete this._componentCache[t],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),ye(r,t),r.gameObject=void 0,r}},e.prototype.getComponent=function(t){var e;return"string"==typeof t?e=t:t instanceof p?e=t.name:t.componentName&&(e=t.componentName),void 0!==this._componentCache[e]?this._componentCache[e]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var t in Array.from(this.transform.children).forEach((function(t){t.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(t);this.components.length=0},e}(),Oe=function(){function e(){this.events=[]}return e.prototype.add=function(e){var r=e.component,n=e.prop,o=e.type,i=e.componentName;if(o===t.OBSERVER_TYPE.REMOVE){if(this.events.find((function(e){return e.component===r&&e.type===t.OBSERVER_TYPE.ADD})))return;this.events=this.events.filter((function(t){return t.component!==r}))}var s=this.events.findIndex((function(t){return t.component===r&&ae(t.prop,n)&&t.type===o}));s>-1&&this.events.splice(s,1),this.events.push({gameObject:r.gameObject,component:r,prop:n,type:o,componentName:i})},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 t=this.events;return this.events=[],t},e}(),we=function(){function t(t){this.started=!1,this.componentObserver=new Oe,this.__systemDefaultParams=t,this.name=this.constructor.systemName}return t.prototype.destroy=function(){var t;this.componentObserver=null,this.__systemDefaultParams=null,null===(t=this.onDestroy)||void 0===t||t.call(this)},t}();var xe,Te=Date.now?Date.now:function(){return(new Date).getTime()},je={originTime:0,playbackRate:1},ke=function(){function t(e,r){e instanceof t&&(r=e,e={}),e=_extends({},je,e),r&&(this._parent=r),this._createTime=Te(),this._timeMark=[{globalTime:this.globalTime,localTime:-e.originTime,entropy:-e.originTime,playbackRate:e.playbackRate,globalEntropy:0}],this._parent&&(this._timeMark[0].globalEntropy=this._parent.entropy),this._playbackRate=e.playbackRate}return Object.defineProperty(t.prototype,"globalTime",{get:function(){return this.parent?this.parent.currentTime:Te()-this._createTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastTimeMark",{get:function(){return this._timeMark[this._timeMark.length-1]},enumerable:!1,configurable:!0}),t.prototype.markTime=function(t){var e=void 0===t?{}:t,r=e.time,n=void 0===r?this.currentTime:r,o=e.entropy,i=void 0===o?this.entropy:o,s=e.playbackRate,a=void 0===s?this.playbackRate:s,c={globalTime:this.globalTime,localTime:n,entropy:i,playbackRate:a,globalEntropy:this.globalEntropy};this._timeMark.push(c)},Object.defineProperty(t.prototype,"currentTime",{get:function(){var t=this.lastTimeMark,e=t.localTime,r=t.globalTime;return e+(this.globalTime-r)*this.playbackRate},set:function(t){this.markTime({time:t})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"globalEntropy",{get:function(){return this._parent?this._parent.entropy:this.globalTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"entropy",{get:function(){var t=this.lastTimeMark,e=t.entropy,r=t.globalEntropy;return e+Math.abs((this.globalEntropy-r)*this.playbackRate)},set:function(t){if(this.entropy>t){var e=this.seekTimeMark(t);this._timeMark.length=e+1}this.markTime({entropy:t})},enumerable:!1,configurable:!0}),t.prototype.fork=function(e){return new t(e,this)},t.prototype.seekGlobalTime=function(t){var e=this.seekTimeMark(t),r=this._timeMark[e],n=r.entropy,o=r.playbackRate;return r.globalTime+(t-n)/Math.abs(o)},t.prototype.seekLocalTime=function(t){var e=this.seekTimeMark(t),r=this._timeMark[e],n=r.localTime,o=r.entropy;return r.playbackRate>0?n+(t-o):n-(t-o)},t.prototype.seekTimeMark=function(t){var e=this._timeMark,r=0,n=e.length-1;if(t<=e[r].entropy)return r;if(t>=e[n].entropy)return n;for(var o=Math.floor((r+n)/2);o>r&&o<n;){if(t===e[o].entropy)return o;t<e[o].entropy?n=o:t>e[o].entropy&&(r=o),o=Math.floor((r+n)/2)}return r},Object.defineProperty(t.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){t!==this.playbackRate&&(this.markTime({playbackRate:t}),this._playbackRate=t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paused",{get:function(){if(0===this.playbackRate)return!0;for(var t=this.parent;t;){if(0===t.playbackRate)return!0;t=t.parent}return!1},enumerable:!1,configurable:!0}),t}(),Ae={autoStart:!0,frameRate:60},Re=function(){function t(t){var e=this;t=_extends({},Ae,t),this._frameCount=0,this._frameDuration=1e3/t.frameRate,this.autoStart=t.autoStart,this.frameRate=t.frameRate,this.timeline=new ke({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=function(){e._started&&(e._requestId=requestAnimationFrame(e._ticker),e.update())},this.autoStart&&this.start()}return t.prototype.update=function(){var t,e,r=this.timeline.currentTime,n=r-this._lastFrameTime;if(n>=this._frameDuration){var o=r-n%this._frameDuration,i=o-this._lastFrameTime;this._lastFrameTime=o;var a={deltaTime:i,time:o,currentTime:o,frameCount:++this._frameCount,fps:Math.round(1e3/i)};try{for(var c=s(this._tickers),u=c.next();!u.done;u=c.next()){var l=u.value;"function"==typeof l&&l(a)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}}},t.prototype.add=function(t){this._tickers.add(t)},t.prototype.remove=function(t){this._tickers.delete(t)},t.prototype.start=function(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))},t.prototype.pause=function(){this._started=!1,this.timeline.playbackRate=0},t.prototype.setPlaybackRate=function(t){this.timeline.playbackRate=t},t}(),Pe=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.gameObjects=[],n.scene=n,n}return r(e,t),e.prototype.addGameObject=function(t){this.gameObjects.push(t),t.transform&&(t.transform.inScene=!0)},e.prototype.removeGameObject=function(t){var e=this.gameObjects.indexOf(t);-1!==e&&(t.transform&&(t.transform.inScene=!1),this.gameObjects.splice(e,1))},e.prototype.destroy=function(){this.scene=null,t.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},e}(Ee);t.LOAD_SCENE_MODE=void 0,(xe=t.LOAD_SCENE_MODE||(t.LOAD_SCENE_MODE={})).SINGLE="SINGLE",xe.MULTI_CANVAS="MULTI_CANVAS";var Se=function(t){if((t instanceof we||t instanceof p)&&!t.started){t.started=!0;try{t.start&&t.start()}catch(e){t instanceof p?console.error(t.constructor.componentName+" start error",e):console.error(t.constructor.systemName+" start error",e)}}},Ce=function(e){function n(t){var r,n,o=void 0===t?{}:t,i=o.systems,a=o.frameRate,c=void 0===a?60:a,u=o.autoStart,l=void 0===u||u,p=o.needScene,h=void 0===p||p,f=e.call(this)||this;if(f.playing=!1,f.started=!1,f.multiScenes=[],f.systems=[],window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=f),f.ticker=new Re({autoStart:!1,frameRate:c}),f.initTicker(),i&&i.length)try{for(var d=s(i),y=d.next();!y.done;y=d.next()){var m=y.value;f.addSystem(m)}}catch(t){r={error:t}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}return h&&f.loadScene(new Pe("scene")),l&&f.start(),f}return r(n,e),Object.defineProperty(n.prototype,"scene",{get:function(){return this._scene},set:function(t){this._scene=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"gameObjects",{get:function(){return function(t){var e,r,n,o=(null===(n=null==t?void 0:t.scene)||void 0===n?void 0:n.gameObjects)||[],i=null==t?void 0:t.multiScenes.map((function(t){return t.gameObjects})),a=[];try{for(var u=s(i),l=u.next();!l.done;l=u.next())a=c(a,l.value)}catch(t){e={error:t}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return c(o,a)}(this)},enumerable:!1,configurable:!0}),n.prototype.addSystem=function(t,e){var r;if(t instanceof Function)r=new t(e);else{if(!(t instanceof we))return void console.warn("can only add System");r=t}if(!this.systems.find((function(t){return t.constructor===r.constructor}))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(t,e){le[e.systemName]=e.observerInfo,ue[e.systemName]=t}(r,r.constructor),function(t){var e,r,n,o,i=[];t instanceof Array?i.push.apply(i,c(t)):i.push(t);try{for(var a=s(i),u=a.next();!u.done;u=a.next()){var l=u.value;for(var p in l.observerInfo){pe[p]=pe[p]||[];var h=pe[p],f=function(t){-1===h.findIndex((function(e){return ae(e,t)}))&&pe[p].push(t)};try{for(var d=(n=void 0,s(l.observerInfo[p])),y=d.next();!y.done;y=d.next())f(y.value)}catch(t){n={error:t}}finally{try{y&&!y.done&&(o=d.return)&&o.call(d)}finally{if(n)throw n.error}}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}}(r.constructor);try{r.awake&&r.awake()}catch(t){console.error(r.constructor.systemName+" awake error",t)}return this.systems.push(r),r}console.warn(r.constructor.systemName+" System has been added")},n.prototype.removeSystem=function(t){if(t){var e=-1;"string"==typeof t?e=this.systems.findIndex((function(e){return e.name===t})):t instanceof Function?e=this.systems.findIndex((function(e){return e.constructor===t})):t instanceof we&&(e=this.systems.findIndex((function(e){return e===t}))),e>-1&&(this.systems[e].destroy&&this.systems[e].destroy(),this.systems.splice(e,1))}},n.prototype.getSystem=function(t){return this.systems.find((function(e){return"string"==typeof t?e.name===t:e instanceof t}))},n.prototype.pause=function(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},n.prototype.start=function(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())},n.prototype.resume=function(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())},n.prototype.initTicker=function(){var t=this;this.ticker.add((function(e){var r,n,o,i;t.scene&&function(t,e){var r,n,o,i,a,c,u,l;void 0===e&&(e=[]);try{for(var p=s(e),h=p.next();!h.done;h=p.next()){var f=h.value;try{for(var d=(o=void 0,s(f.components)),y=d.next();!y.done;y=d.next()){var m=y.value;try{Se(m),m.update&&m.update(t)}catch(t){console.error("gameObject: "+f.name+" "+m.name+" update error",t)}}}catch(t){o={error:t}}finally{try{y&&!y.done&&(i=d.return)&&i.call(d)}finally{if(o)throw o.error}}}}catch(t){r={error:t}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var _=s(e),v=_.next();!v.done;v=_.next()){f=v.value;try{for(var b=(u=void 0,s(f.components)),g=b.next();!g.done;g=b.next()){m=g.value;try{m.lateUpdate&&m.lateUpdate(t)}catch(t){console.error("gameObject: "+f.name+" "+m.name+" lateUpdate error",t)}}}catch(t){u={error:t}}finally{try{g&&!g.done&&(l=b.return)&&l.call(b)}finally{if(u)throw u.error}}}}catch(t){a={error:t}}finally{try{v&&!v.done&&(c=_.return)&&c.call(_)}finally{if(a)throw a.error}}}(e,t.gameObjects);try{for(var a=s(t.systems),c=a.next();!c.done;c=a.next()){var u=c.value;try{Se(u),u.update&&u.update(e)}catch(e){console.error(u.constructor.systemName+" update error",e)}}}catch(t){r={error:t}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}try{for(var l=s(t.systems),p=l.next();!p.done;p=l.next()){u=p.value;try{u.lateUpdate&&u.lateUpdate(e)}catch(e){console.error(u.constructor.systemName+" lateUpdate error",e)}}}catch(t){o={error:t}}finally{try{p&&!p.done&&(i=l.return)&&i.call(l)}finally{if(o)throw o.error}}}))},n.prototype.triggerResume=function(){var t,e;!function(t){var e,r,n,o;try{for(var i=s(t),a=i.next();!a.done;a=i.next()){var c=a.value;try{for(var u=(n=void 0,s(c.components)),l=u.next();!l.done;l=u.next()){var p=l.value;try{p.onResume&&p.onResume()}catch(t){console.error("gameObject: "+c.name+", "+p.name+", onResume error",t)}}}catch(t){n={error:t}}finally{try{l&&!l.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}(this.gameObjects);try{for(var r=s(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onResume&&o.onResume()}catch(t){console.error(o.constructor.systemName+", onResume error",t)}}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}},n.prototype.triggerPause=function(){var t,e;!function(t){var e,r,n,o;try{for(var i=s(t),a=i.next();!a.done;a=i.next()){var c=a.value;try{for(var u=(n=void 0,s(c.components)),l=u.next();!l.done;l=u.next()){var p=l.value;try{p.onPause&&p.onPause()}catch(t){console.error("gameObject: "+c.name+", "+p.name+", onResume error",t)}}}catch(t){n={error:t}}finally{try{l&&!l.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}(this.gameObjects);try{for(var r=s(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onPause&&o.onPause()}catch(t){console.error(o.constructor.systemName+", onPause error",t)}}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}},n.prototype.destroySystems=function(){var t,e;try{for(var r=s(c(this.systems)),n=r.next();!n.done;n=r.next()){var o=n.value;this.removeSystem(o)}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}this.systems.length=0},n.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},n.prototype.loadScene=function(e){var r=e.scene,n=e.mode,o=void 0===n?t.LOAD_SCENE_MODE.SINGLE:n,i=e.params,s=void 0===i?{}:i;if(r){switch(o){case t.LOAD_SCENE_MODE.SINGLE:this.scene=r;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(r)}this.emit("sceneChanged",{scene:r,mode:o,params:s})}},n}(u);function Le(t,e){t.constructor.IDEProps||(t.constructor.IDEProps=[]),t.constructor.IDEProps.push(e)}function Me(t){return void 0===t&&(t={}),function(e){if(!e.observerInfo){for(var r in t)for(var n in t[r]){"string"==typeof t[r][n]&&(t[r][n]=[t[r][n]]);var o=void 0;Array.isArray(t[r][n])&&(o={prop:t[r][n],deep:!1},t[r][n]=o),"string"==typeof(o=t[r][n]).prop&&(o.prop=[o.prop])}e.observerInfo=t}}}var De=function(){function t(t,e,r){void 0===e&&(e=!1),this.next=null,this.prev=null,this.owner=null,this.fn=t,this.once=e,this.thisArg=r}return t.prototype.detach=function(){return null!==this.owner&&(this.owner.detach(this),!0)},t.prototype.dispose=function(){this.detach()},t}(),Ie=function(){function t(){this._head=null,this._tail=null,this._filter=null}return t.prototype.handlers=function(){for(var t=this._head,e=[];t;)e.push(t),t=t.next;return e},t.prototype.hasAny=function(){return!!this._head},t.prototype.has=function(t){return t.owner===this},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this._head;if(!r)return!1;if(this._filter&&!this._filter.apply(this,t))return!1;for(;r;)r.once&&this.detach(r),r.fn.apply(r.thisArg,t),r=r.next;return!0},t.prototype.add=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new De(t,!1,e))},t.prototype.once=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new De(t,!0,e))},t.prototype.detach=function(t){var e=t;return e.owner!==this||(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e===this._head?(this._head=e.next,null===e.next&&(this._tail=null)):e===this._tail&&(this._tail=e.prev,this._tail&&(this._tail.next=null)),e.owner=null),this},t.prototype.detachAll=function(){var t=this._head;if(!t)return this;for(this._head=null,this._tail=null;t;)t.owner=null,t=t.next;return this},t.prototype.filter=function(t){this._filter=t},t.prototype.proxy=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.dispatch.apply(t,e)},o=0;o<e.length;++o)e[o].add(n);return this},t.prototype._addSignalBinding=function(t){var e=t;return this._head?(this._tail&&(this._tail.next=e),e.prev=this._tail,this._tail=e):(this._head=e,this._tail=e),e.owner=this,e},t}();var Ne,Be,Ue=function(t,e){if(t){e=e||{};for(var r={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},n=r.parser[e.strictMode?"strict":"loose"].exec(t),o={},i=14;i--;)o[r.key[i]]=n[i]||"";return o[r.q.name]={},o[r.key[12]].replace(r.q.parser,(function(t,e,n){e&&(o[r.q.name][e]=n)})),o}},Ve=function(t){this.config=t,this.onError=new Ie,this.onComplete=new Ie,this.onProgress=new Ie},qe=function(t,e){return(qe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function ze(t,e){function r(){this.constructor=t}qe(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function Fe(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}function Ge(t){var e="";if(0===t.indexOf("data:")){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var n=t.indexOf("?"),o=t.indexOf("#"),i=Math.min(n>-1?n:t.length,o>-1?o:t.length);e=(t=t.substring(0,i)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()}function Xe(t){throw new Error("Unexpected value. Should have been never.")}!function(t){t[t.Unknown=0]="Unknown",t[t.Buffer=1]="Buffer",t[t.Blob=2]="Blob",t[t.Json=3]="Json",t[t.Xml=4]="Xml",t[t.Image=5]="Image",t[t.Audio=6]="Audio",t[t.Video=7]="Video",t[t.Text=8]="Text"}(Ne||(Ne={})),function(t){t[t.NotStarted=0]="NotStarted",t[t.Loading=1]="Loading",t[t.Complete=2]="Complete"}(Be||(Be={}));var Ye,He=function(t){function e(e,r){var n=t.call(this,e)||this;return n.elementType=r,n._boundOnLoad=n._onLoad.bind(n),n._boundOnError=n._onError.bind(n),n._boundOnTimeout=n._onTimeout.bind(n),n._element=n._createElement(),n._elementTimer=0,n}return ze(e,t),e.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin);var e=t.sourceSet||[t.url];if(navigator.isCocoonJS)this._element.src=e[0];else for(var r=0;r<e.length;++r){var n=e[r],o=t.mimeTypes?t.mimeTypes[r]:void 0;o||(o=this.elementType+"/"+Ge(n));var i=document.createElement("source");i.src=n,i.type=o,this._element.appendChild(i)}this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("canplaythrough",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),this._element.load(),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},e.prototype.abort=function(){for(this._clearEvents();this._element.firstChild;)this._element.removeChild(this._element.firstChild);this._error(this.elementType+" load aborted by the user.")},e.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement(this.elementType)},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("canplaythrough",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(){this._clearEvents();var t=Ne.Unknown;switch(this.elementType){case"audio":t=Ne.Audio;break;case"video":t=Ne.Video;break;default:Xe(this.elementType)}this.onComplete.dispatch(t,this._element)},e.prototype._onLoad=function(){this._complete()},e.prototype._onError=function(){this._error(this.elementType+" failed to load.")},e.prototype._onTimeout=function(){this._error(this.elementType+" load timed out.")},e}(Ve),Je=function(t){function e(e){return t.call(this,e,"audio")||this}return ze(e,t),e}(He),$e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._boundOnLoad=e._onLoad.bind(e),e._boundOnError=e._onError.bind(e),e._boundOnTimeout=e._onTimeout.bind(e),e._element=e._createElement(),e._elementTimer=0,e}return ze(e,t),e.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin),this._element.src=t.url,this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},e.prototype.abort=function(){this._clearEvents(),this._element.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",this._error("Image load aborted by the user.")},e.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement("img")},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(){this._clearEvents(),this.onComplete.dispatch(Ne.Image,this._element)},e.prototype._onLoad=function(){this._complete()},e.prototype._onError=function(){this._error("Image failed to load.")},e.prototype._onTimeout=function(){this._error("Image load timed out.")},e}(Ve),Qe=function(t){function e(e){return t.call(this,e,"video")||this}return ze(e,t),e}(He),We=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest);function Ke(t){return t.toString().replace("object ","")}!function(t){t.Default="text",t.Buffer="arraybuffer",t.Blob="blob",t.Document="document",t.Json="json",t.Text="text"}(Ye||(Ye={}));var Ze=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._boundOnLoad=e._onLoad.bind(e),e._boundOnAbort=e._onAbort.bind(e),e._boundOnError=e._onError.bind(e),e._boundOnTimeout=e._onTimeout.bind(e),e._boundOnProgress=e._onProgress.bind(e),e._xhr=e._createRequest(),e._xhrType=Ye.Default,e}return ze(e,t),e.prototype.load=function(){var t=this.config,e=Ge(t.url);"string"!=typeof t.xhrType&&(t.xhrType=this._determineXhrType(e));var r=this._xhr;this._xhrType=t.xhrType||Ye.Default,We?(r.timeout=t.timeout||5e3,r.onload=this._boundOnLoad,r.onerror=this._boundOnError,r.ontimeout=this._boundOnTimeout,r.onprogress=this._boundOnProgress,r.open("GET",t.url,!0),setTimeout((function(){r.send()}),0)):(r.open("GET",t.url,!0),t.timeout&&(r.timeout=t.timeout),t.xhrType===Ye.Json||t.xhrType===Ye.Document?r.responseType=Ye.Text:r.responseType=t.xhrType,r.addEventListener("load",this._boundOnLoad,!1),r.addEventListener("abort",this._boundOnAbort,!1),r.addEventListener("error",this._boundOnError,!1),r.addEventListener("timeout",this._boundOnTimeout,!1),r.addEventListener("progress",this._boundOnProgress,!1),r.send())},e.prototype.abort=function(){We?(this._clearEvents(),this._xhr.abort(),this._onAbort()):this._xhr.abort()},e.prototype._createRequest=function(){return We?new window.XDomainRequest:new XMLHttpRequest},e.prototype._determineXhrType=function(t){return e._xhrTypeMap[t]||Ye.Default},e.prototype._clearEvents=function(){We?(this._xhr.onload=null,this._xhr.onerror=null,this._xhr.ontimeout=null,this._xhr.onprogress=null):(this._xhr.removeEventListener("load",this._boundOnLoad,!1),this._xhr.removeEventListener("abort",this._boundOnAbort,!1),this._xhr.removeEventListener("error",this._boundOnError,!1),this._xhr.removeEventListener("timeout",this._boundOnTimeout,!1),this._xhr.removeEventListener("progress",this._boundOnProgress,!1))},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(t,e){this._clearEvents(),this.onComplete.dispatch(t,e)},e.prototype._onLoad=function(){var t=this._xhr,e="",r=void 0===t.status?200:t.status;if(void 0!==t.responseType&&""!==t.responseType&&"text"!==t.responseType||(e=t.responseText),0===r&&(e.length>0||t.responseType===Ye.Buffer)?r=200:1223===r&&(r=204),200===100*Math.floor(r/100))switch(this._xhrType){case Ye.Buffer:this._complete(Ne.Buffer,t.response);break;case Ye.Blob:this._complete(Ne.Blob,t.response);break;case Ye.Document:this._parseDocument(e);break;case Ye.Json:this._parseJson(e);break;case Ye.Default:case Ye.Text:this._complete(Ne.Text,e);break;default:Xe(this._xhrType)}else this._error("["+t.status+"] "+t.statusText+": "+t.responseURL)},e.prototype._parseDocument=function(t){try{if(window.DOMParser){var e=(new DOMParser).parseFromString(t,"text/xml");this._complete(Ne.Xml,e)}else{var r=document.createElement("div");r.innerHTML=t,this._complete(Ne.Xml,r)}}catch(t){this._error("Error trying to parse loaded xml: "+t)}},e.prototype._parseJson=function(t){try{var e=JSON.parse(t);this._complete(Ne.Json,e)}catch(t){this._error("Error trying to parse loaded json: "+t)}},e.prototype._onAbort=function(){var t=this._xhr;this._error(Ke(t)+" Request was aborted by the user.")},e.prototype._onError=function(){var t=this._xhr;this._error(Ke(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},e.prototype._onTimeout=function(){var t=this._xhr;this._error(Ke(t)+" Request timed out.")},e.prototype._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(t.loaded/t.total)},e.setExtensionXhrType=function(t,r){t&&0===t.indexOf(".")&&(t=t.substring(1)),t&&(e._xhrTypeMap[t]=r)},e.ResponseType=Ye,e._xhrTypeMap={xhtml:Ye.Document,html:Ye.Document,htm:Ye.Document,xml:Ye.Document,tmx:Ye.Document,svg:Ye.Document,tsx:Ye.Document,gif:Ye.Blob,png:Ye.Blob,bmp:Ye.Blob,jpg:Ye.Blob,jpeg:Ye.Blob,tif:Ye.Blob,tiff:Ye.Blob,webp:Ye.Blob,tga:Ye.Blob,json:Ye.Json,text:Ye.Text,txt:Ye.Text,ttf:Ye.Buffer,otf:Ye.Buffer},e}(Ve);function tr(t){var e=t;return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(null===e)throw new Error("Callback was already called.");var n=e;return e=null,n.apply(this,t)}}var er=function(){function t(t,e){if(void 0===e&&(e=1),this.worker=t,this.concurrency=e,this.workers=0,this.buffer=0,this.paused=!1,this._started=!1,this._tasks=[],this.onSaturated=new Ie,this.onUnsaturated=new Ie,this.onEmpty=new Ie,this.onDrain=new Ie,this.onError=new Ie,0===e)throw new Error("Concurrency must not be zero");this.buffer=e/4}return Object.defineProperty(t.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.onDrain.detachAll(),this.workers=0,this._started=!1,this._tasks=[]},t.prototype.push=function(t,e){this._insert(t,!1,e)},t.prototype.unshift=function(t,e){this._insert(t,!0,e)},t.prototype.process=function(){for(;!this.paused&&this.workers<this.concurrency&&this._tasks.length;){var t=this._tasks.shift();0===this._tasks.length&&this.onEmpty.dispatch(),this.workers+=1,this.workers===this.concurrency&&this.onSaturated.dispatch(),this.worker(t.data,tr(this._next(t)))}},t.prototype.length=function(){return this._tasks.length},t.prototype.running=function(){return this.workers},t.prototype.idle=function(){return this._tasks.length+this.workers===0},t.prototype.pause=function(){!0!==this.paused&&(this.paused=!0)},t.prototype.resume=function(){if(!1!==this.paused){this.paused=!1;for(var t=1;t<=this.concurrency;t++)this.process()}},t.prototype.getTask=function(t){return this._tasks[t]},t.prototype._insert=function(t,e,r){var n=this;if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(this._started=!0,null==t&&this.idle())setTimeout((function(){return n.onDrain.dispatch()}),1);else{var o={data:t,callback:r};e?this._tasks.unshift(o):this._tasks.push(o),setTimeout((function(){return n.process()}),1)}},t.prototype._next=function(t){var e=this;return function(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];e.workers-=1,t.callback&&t.callback.apply(t,Fe([r],n)),r&&e.onError.dispatch(r,t.data),e.workers<=e.concurrency-e.buffer&&e.onUnsaturated.dispatch(),e.idle()&&e.onDrain.dispatch(),e.process()}},t}(),rr=function(){function t(e,r){if(this.children=[],this.onStart=new Ie,this.onProgress=new Ie,this.onComplete=new Ie,this.onAfterMiddleware=new Ie,this.data=null,this.type=Ne.Unknown,this.error="",this.progressChunk=0,this._dequeue=function(){},this._onCompleteBinding=null,this._state=Be.NotStarted,this.name=e,this.metadata=r.metadata,"string"!=typeof r.crossOrigin&&(r.crossOrigin=this._determineCrossOrigin(r.url)),r.strategy&&"function"!=typeof r.strategy)this._strategy=r.strategy,this._strategy.config=r;else{var n=r.strategy;n||(n=t._loadStrategyMap[Ge(r.url)]),n||(n=t._defaultLoadStrategy),this._strategy=new n(r)}this._strategy.onError.add(this._error,this),this._strategy.onComplete.add(this._complete,this),this._strategy.onProgress.add(this._progress,this)}return t.setDefaultLoadStrategy=function(e){t._defaultLoadStrategy=e},t.setLoadStrategy=function(e,r){e&&0===e.indexOf(".")&&(e=e.substring(1)),e&&(t._loadStrategyMap[e]=r)},Object.defineProperty(t.prototype,"strategy",{get:function(){return this._strategy},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._strategy.config.url},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLoading",{get:function(){return this._state===Be.Loading},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isComplete",{get:function(){return this._state===Be.Complete},enumerable:!0,configurable:!0}),t.prototype.abort=function(){this._strategy.abort()},t.prototype.load=function(){this._state=Be.Loading,this.onStart.dispatch(this),this._strategy.load()},t.prototype._error=function(t){this._state=Be.Complete,this.error=t,this.onComplete.dispatch(this)},t.prototype._complete=function(t,e){this._state=Be.Complete,this.type=t,this.data=e,this.onComplete.dispatch(this)},t.prototype._progress=function(t){this.onProgress.dispatch(this,t)},t.prototype._determineCrossOrigin=function(e,r){if(void 0===r&&(r=window.location),0===e.indexOf("data:")||0===e.indexOf("javascript:"))return"";if(window.origin!==window.location.origin)return"anonymous";t._tempAnchor||(t._tempAnchor=document.createElement("a")),t._tempAnchor.href=e;var n=Ue(t._tempAnchor.href,{strictMode:!0}),o=!n.port&&""===r.port||n.port===r.port,i=n.protocol?n.protocol+":":"";return n.host===r.hostname&&o&&i===r.protocol?"":"anonymous"},t._tempAnchor=null,t._defaultLoadStrategy=Ze,t._loadStrategyMap={gif:$e,png:$e,bmp:$e,jpg:$e,jpeg:$e,tif:$e,tiff:$e,webp:$e,tga:$e,svg:$e,"svg+xml":$e,mp3:Je,ogg:Je,wav:Je,mp4:Qe,webm:Qe,mov:Qe},t}();var nr,or,ir=/(#[\w-]+)?$/,sr=function(){function t(e,r){void 0===e&&(e=""),void 0===r&&(r=10),this.progress=0,this.loading=!1,this.defaultQueryString="",this.resources={},this.onError=new Ie,this.onLoad=new Ie,this.onStart=new Ie,this.onComplete=new Ie,this.onProgress=new Ie,this._baseUrl="",this._urlResolvers=[],this._middleware=[],this._resourcesParsing=[],this._boundLoadResource=this._loadResource.bind(this),this.baseUrl=e,this._queue=new er(this._boundLoadResource,r),this._queue.pause(),this._middleware=t._defaultMiddleware.slice()}return Object.defineProperty(t.prototype,"baseUrl",{get:function(){return this._baseUrl},set:function(t){for(;t.length&&"/"===t.charAt(t.length-1);)t=t.slice(0,-1);this._baseUrl=t},enumerable:!0,configurable:!0}),t.prototype.add=function(t,e){if(Array.isArray(t)){for(var r=0;r<t.length;++r)this.add(t[r]);return this}var n="",o="",i=this._baseUrl,s={url:""};if("object"==typeof t?(n=t.url,o=t.name||t.url,i=t.baseUrl||i,s=t):(o=t,n="string"==typeof e?e:o),!n)throw new Error("You must specify the `url` property.");if(this.loading&&!s.parentResource)throw new Error("Cannot add root resources while the loader is running.");if(this.resources[o])throw new Error('Resource named "'+o+'" already exists.');n=this._prepareUrl(n,i),s.url=n;var a=new rr(o,s);if(this.resources[o]=a,"function"==typeof s.onComplete&&a.onAfterMiddleware.once(s.onComplete),this.loading){var c=s.parentResource,u=[];for(r=0;r<c.children.length;++r)c.children[r].isComplete||u.push(c.children[r]);var l=c.progressChunk*(u.length+1)/(u.length+2);c.children.push(a),c.progressChunk=l;for(r=0;r<u.length;++r)u[r].progressChunk=l;a.progressChunk=l}return this._queue.push(a),this},t.prototype.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),this._middleware.push({fn:e,priority:r}),this._middleware.sort((function(t,e){return t.priority-e.priority})),this},t.prototype.reset=function(){for(var t in this.progress=0,this.loading=!1,this._queue.reset(),this._queue.pause(),this.resources){var e=this.resources[t];e&&(e._onCompleteBinding&&e._onCompleteBinding.detach(),e.isLoading&&e.abort())}return this.resources={},this},t.prototype.load=function(t){if("function"==typeof t&&this.onComplete.once(t),this.loading)return this;if(this._queue.idle())this._onStart(),this._onComplete();else{for(var e=100/this._queue.length(),r=0;r<this._queue.length();++r)this._queue.getTask(r).data.progressChunk=e;this._onStart(),this._queue.resume()}return this},Object.defineProperty(t.prototype,"concurrency",{get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t},enumerable:!0,configurable:!0}),t.prototype.addUrlResolver=function(t){return this._urlResolvers.push(t),this},t.prototype._prepareUrl=function(t,e){var r=Ue(t,{strictMode:!0});if(this._urlResolvers.forEach((function(e){t=e(t,r),r=Ue(t,{strictMode:!0})})),r.protocol||0===t.indexOf("//")||(t=e.length&&"/"!==t.charAt(0)?e+"/"+t:e+t),this.defaultQueryString){var n=ir.exec(t);if(n){var o=n[0];-1!==(t=t.substr(0,t.length-o.length)).indexOf("?")?t+="&"+this.defaultQueryString:t+="?"+this.defaultQueryString,t+=o}}return t},t.prototype._loadResource=function(t,e){t._dequeue=e,t._onCompleteBinding=t.onComplete.once(this._onLoad,this),t.load()},t.prototype._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},t.prototype._onComplete=function(){this.progress=100,this.loading=!1,this.onComplete.dispatch(this,this.resources)},t.prototype._onLoad=function(t){var e=this;t._onCompleteBinding=null,this._resourcesParsing.push(t),t._dequeue(),function(t,e,r,n){void 0===n&&(n=!1);var o=0,i=t.length;!function s(a){a||o===i?r&&r(a):n?setTimeout((function(){return e(t[o++],s)}),1):e(t[o++],s)}()}(this._middleware,(function(r,n){r.fn.call(e,t,n)}),(function(){t.onAfterMiddleware.dispatch(t),e.progress=Math.min(100,e.progress+t.progressChunk),e.onProgress.dispatch(e,t),t.error?e.onError.dispatch(t.error,e,t):e.onLoad.dispatch(e,t),e._resourcesParsing.splice(e._resourcesParsing.indexOf(t),1),e._queue.idle()&&0===e._resourcesParsing.length&&e._onComplete()}),!0)},t.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),t._defaultMiddleware.push({fn:e,priority:r}),t._defaultMiddleware.sort((function(t,e){return t.priority-e.priority})),t},t.DefaultMiddlewarePriority=50,t._defaultMiddleware=[],t}(),ar=function(e){function n(r){var n=r.resource,o=r.resourceTotal,i=e.call(this)||this;return i.progress=0,i.resourceTotal=0,i.resourceLoadedCount=0,i.resource=n,i.resourceTotal=o,0===o&&i.resource.emit(t.LOAD_EVENT.COMPLETE,i),i}return r(n,e),n.prototype.onStart=function(){this.resource.emit(t.LOAD_EVENT.START,this)},n.prototype.onProgress=function(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(t.LOAD_EVENT.LOADED,this,e):this.resource.emit(t.LOAD_EVENT.ERROR,this,e),this.resource.emit(t.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(t.LOAD_EVENT.COMPLETE,this)},n}(u),cr={AbstractLoadStrategy:Ve,AudioLoadStrategy:Je,ImageLoadStrategy:$e,XhrResponseType:Ye,MediaElementLoadStrategy:He,VideoLoadStrategy:Qe,XhrLoadStrategy:Ze,Loader:sr,Resource:rr,ResourceType:Ne,ResourceState:Be};t.LOAD_EVENT=void 0,(nr=t.LOAD_EVENT||(t.LOAD_EVENT={})).START="start",nr.PROGRESS="progress",nr.LOADED="loaded",nr.COMPLETE="complete",nr.ERROR="error",t.RESOURCE_TYPE=void 0,(or=t.RESOURCE_TYPE||(t.RESOURCE_TYPE={})).IMAGE="IMAGE",or.SPRITE="SPRITE",or.SPRITE_ANIMATION="SPRITE_ANIMATION",or.AUDIO="AUDIO",or.VIDEO="VIDEO",Ze.setExtensionXhrType("json",Ye.Json),Ze.setExtensionXhrType("tex",Ye.Json),Ze.setExtensionXhrType("ske",Ye.Json),Ze.setExtensionXhrType("mp3",Ye.Buffer),Ze.setExtensionXhrType("wav",Ye.Buffer),Ze.setExtensionXhrType("aac",Ye.Buffer),Ze.setExtensionXhrType("ogg",Ye.Buffer);var ur={png:$e,jpg:$e,jpeg:$e,webp:$e,json:Ze,tex:Ze,ske:Ze,audio:Ze,video:Qe},lr=new(function(e){function n(t){var r=e.call(this)||this;return r.timeout=6e3,r.preProcessResourceHandlers=[],r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return r(n,e),n.prototype.loadConfig=function(t){this.addResource(t),this.preload()},n.prototype.loadSingle=function(t){return this.addResource([t]),this.getResource(t.name)},n.prototype.addResource=function(t){var e,r;if(!t||t.length<1)console.warn("no resources");else try{for(var n=s(t),o=n.next();!o.done;o=n.next()){var i=o.value;this.resourcesMap[i.name]?console.warn(i.name+" was already added"):(this.resourcesMap[i.name]=i,this.resourcesMap[i.name].data={})}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},n.prototype.addPreProcessResourceHandler=function(t){this.preProcessResourceHandlers.push(t)},n.prototype.removePreProcessResourceHandler=function(t){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(t),1)},n.prototype.preload=function(){var t=[];for(var e in this.resourcesMap){var r=this.resourcesMap[e];r.preload&&!r.complete&&t.push(r.name)}this.progress=new ar({resource:this,resourceTotal:t.length}),this.loadResource({names:t,preload:!0})},n.prototype.getResource=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this.loadResource({names:[t]}),[2,this.promiseMap[t]||Promise.resolve({})]}))}))},n.prototype.instance=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return e=this.resourcesMap[t],(r=this.makeInstanceFunctions[e.type])?[4,this.makeInstanceFunctions[e.type](e)]:[3,2];case 1:r=n.sent(),n.label=2;case 2:return[2,r]}}))}))},n.prototype.destroy=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._destroy(t)];case 1:return e.sent(),[2]}}))}))},n.prototype._destroy=function(t,e){return void 0===e&&(e=!1),o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:if(!(r=this.resourcesMap[t]))return[2];if(e)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[t],r.data={},r.complete=!1,r.instance=void 0,[2]}}))}))},n.prototype.registerResourceType=function(e,r){if(void 0===r&&(r=e),t.RESOURCE_TYPE[e])throw new Error("The type "+e+" already exists in RESOURCE_TYPE");t.RESOURCE_TYPE[e]=r},n.prototype.registerInstance=function(t,e){this.makeInstanceFunctions[t]=e},n.prototype.registerDestroy=function(t,e){this.destroyInstanceFunctions[t]=e},n.prototype.loadResource=function(t){var e=this,r=t.names,n=void 0===r?[]:r,o=t.preload,i=void 0!==o&&o,a=n.filter((function(t){return!e.promiseMap[t]&&e.resourcesMap[t]}));if(a.length){var c={},u=this.getLoader(i);a.forEach((function(t){var r,n;e.promiseMap[t]=new Promise((function(e){return c[t]=e}));var o=e.resourcesMap[t];try{for(var a=s(e.preProcessResourceHandlers),l=a.next();!l.done;l=a.next()){(0,l.value)(o)}}catch(t){r={error:t}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}for(var p in o.src){var h=o.src[p].type;"data"===h?(o.data[p]=o.src[p].data,e.doComplete(t,c[t],i)):u.add({url:o.src[p].url,name:o.name+"_"+p,strategy:ur[h],metadata:{key:p,name:o.name,resolves:c}})}})),u.load()}},n.prototype.doComplete=function(t,e,r){return void 0===r&&(r=!1),o(this,void 0,void 0,(function(){var n,o,s,a;return i(this,(function(i){switch(i.label){case 0:if(n=this.resourcesMap[t],o={name:t,resource:this.resourcesMap[t],success:!0},!this.checkAllLoaded(t))return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),s=n,[4,this.instance(t)];case 2:return s.instance=i.sent(),n.complete=!0,r&&this.progress.onProgress(o),e(n),[3,4];case 3:return a=i.sent(),console.error(a),n.complete=!1,r&&(o.errMsg=a.message,o.success=!1,this.progress.onProgress(o)),e({}),[3,4];case 4:return[2]}}))}))},n.prototype.checkAllLoaded=function(t){var e=this.resourcesMap[t];return Array.from(Object.keys(e.src)).every((function(t){return e.data[t]}))},n.prototype.getLoader=function(t){var e=this;void 0===t&&(t=!1);var r=this.loaders.find((function(t){return!t.loading}));return r||(r=new sr,this.loaders.push(r)),t&&r.onStart.once((function(){e.progress.onStart()})),r.onLoad.add((function(r,n){e.onLoad({preload:t,resource:n})})),r.onError.add((function(r,n,o){e.onError({errMsg:r,resource:o,preload:t})})),r.onComplete.once((function(){r.onLoad.detachAll(),r.onError.detachAll(),r.reset()})),r},n.prototype.onLoad=function(t){var e=t.preload,r=void 0!==e&&e,n=t.resource;return o(this,void 0,void 0,(function(){var t,e,o,s,a;return i(this,(function(i){return t=n.metadata,e=t.key,o=t.name,s=t.resolves,a=n.data,this.resourcesMap[o].data[e]=a,this.doComplete(o,s[o],r),[2]}))}))},n.prototype.onError=function(t){var e=t.errMsg,r=t.preload,n=void 0!==r&&r,s=t.resource;return o(this,void 0,void 0,(function(){var t,r,o,a;return i(this,(function(i){return t=s.metadata,r=t.name,o=t.resolves,this._destroy(r,!0),o[r]({}),n&&(a={name:r,resource:this.resourcesMap[r],success:!1,errMsg:e},this.progress.onProgress(a)),[2]}))}))},n}(u)),pr={IDEProp:Le,componentObserver:Me},hr="1.2.2-alpha.2";return console.log("Eva.js version: "+hr),t.Component=p,t.Game=Ce,t.GameObject=Ee,t.IDEProp=Le,t.RESOURCE_TYPE_STRATEGY=ur,t.Scene=Pe,t.System=we,t.Transform=be,t.componentObserver=Me,t.decorators=pr,t.resource=lr,t.resourceLoader=cr,t.version=hr,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
1
+ function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var _EVA_IIFE_EVA=function(t){"use strict";var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,r)};function r(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function n(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function c(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t}var u=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||t,s),c=r?r+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,i,s){var a=r?r+t:t;if(!this._events[a])return!1;var c,u,l=this._events[a],p=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),p){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,s),!0}for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(t,l[u].fn,void 0,!0),p){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,e);break;case 3:l[u].fn.call(l[u].context,e,n);break;case 4:l[u].fn.call(l[u].context,e,n,o);break;default:if(!c)for(h=1,c=new Array(p-1);h<p;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==e||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[i]=1===u.length?u[0]:u:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a}));var l=function(t){function e(e){var r=t.call(this)||this;return r.started=!1,r.name=r.constructor.componentName,r.__componentDefaultParams=e,r}return r(e,t),e}(u),p=l,h="object"==typeof global&&global&&global.Object===Object&&global,f="object"==typeof self&&self&&self.Object===Object&&self,d=h||f||Function("return this")(),y=d.Symbol,m=Object.prototype,v=m.hasOwnProperty,_=m.toString,b=y?y.toStringTag:void 0;var g=Object.prototype.toString;var E=y?y.toStringTag:void 0;function O(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":E&&E in Object(t)?function(t){var e=v.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=_.call(t);return n&&(e?t[b]=r:delete t[b]),o}(t):function(t){return g.call(t)}(t)}function w(t){return null!=t&&"object"==typeof t}var x=Array.isArray;function T(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function j(t){if(!T(t))return!1;var e=O(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var k,A=d["__core-js_shared__"],R=(k=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"";var P=Function.prototype.toString;function S(t){if(null!=t){try{return P.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var C=/^\[object .+?Constructor\]$/,L=Function.prototype,M=Object.prototype,D=L.toString,I=M.hasOwnProperty,N=RegExp("^"+D.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function B(t){return!(!T(t)||(e=t,R&&R in e))&&(j(t)?N:C).test(S(t));var e}function U(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return B(r)?r:void 0}var V=U(d,"WeakMap"),q=/^(?:0|[1-9]\d*)$/;function z(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&q.test(t))&&t>-1&&t%1==0&&t<e}function F(t,e){return t===e||t!=t&&e!=e}function G(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var X=Object.prototype;function Y(t){return w(t)&&"[object Arguments]"==O(t)}var H=Object.prototype,J=H.hasOwnProperty,$=H.propertyIsEnumerable,Q=Y(function(){return arguments}())?Y:function(t){return w(t)&&J.call(t,"callee")&&!$.call(t,"callee")};var W="object"==typeof t&&t&&!t.nodeType&&t,K=W&&"object"==typeof module&&module&&!module.nodeType&&module,Z=K&&K.exports===W?d.Buffer:void 0,tt=(Z?Z.isBuffer:void 0)||function(){return!1},et={};et["[object Float32Array]"]=et["[object Float64Array]"]=et["[object Int8Array]"]=et["[object Int16Array]"]=et["[object Int32Array]"]=et["[object Uint8Array]"]=et["[object Uint8ClampedArray]"]=et["[object Uint16Array]"]=et["[object Uint32Array]"]=!0,et["[object Arguments]"]=et["[object Array]"]=et["[object ArrayBuffer]"]=et["[object Boolean]"]=et["[object DataView]"]=et["[object Date]"]=et["[object Error]"]=et["[object Function]"]=et["[object Map]"]=et["[object Number]"]=et["[object Object]"]=et["[object RegExp]"]=et["[object Set]"]=et["[object String]"]=et["[object WeakMap]"]=!1;var rt,nt="object"==typeof t&&t&&!t.nodeType&&t,ot=nt&&"object"==typeof module&&module&&!module.nodeType&&module,it=ot&&ot.exports===nt&&h.process,st=function(){try{var t=ot&&ot.require&&ot.require("util").types;return t||it&&it.binding&&it.binding("util")}catch(t){}}(),at=st&&st.isTypedArray,ct=at?(rt=at,function(t){return rt(t)}):function(t){return w(t)&&G(t.length)&&!!et[O(t)]},ut=Object.prototype.hasOwnProperty;function lt(t,e){var r=x(t),n=!r&&Q(t),o=!r&&!n&&tt(t),i=!r&&!n&&!o&&ct(t),s=r||n||o||i,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var u in t)!e&&!ut.call(t,u)||s&&("length"==u||o&&("offset"==u||"parent"==u)||i&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||z(u,c))||a.push(u);return a}var pt=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),ht=Object.prototype.hasOwnProperty;function ft(t){if(r=(e=t)&&e.constructor,e!==("function"==typeof r&&r.prototype||X))return pt(t);var e,r,n=[];for(var o in Object(t))ht.call(t,o)&&"constructor"!=o&&n.push(o);return n}function dt(t){return null!=(e=t)&&G(e.length)&&!j(e)?lt(t):ft(t);var e}var yt=U(Object,"create");var mt=Object.prototype.hasOwnProperty;var vt=Object.prototype.hasOwnProperty;function _t(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function bt(t,e){for(var r=t.length;r--;)if(F(t[r][0],e))return r;return-1}_t.prototype.clear=function(){this.__data__=yt?yt(null):{},this.size=0},_t.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},_t.prototype.get=function(t){var e=this.__data__;if(yt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return mt.call(e,t)?e[t]:void 0},_t.prototype.has=function(t){var e=this.__data__;return yt?void 0!==e[t]:vt.call(e,t)},_t.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=yt&&void 0===e?"__lodash_hash_undefined__":e,this};var gt=Array.prototype.splice;function Et(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Et.prototype.clear=function(){this.__data__=[],this.size=0},Et.prototype.delete=function(t){var e=this.__data__,r=bt(e,t);return!(r<0)&&(r==e.length-1?e.pop():gt.call(e,r,1),--this.size,!0)},Et.prototype.get=function(t){var e=this.__data__,r=bt(e,t);return r<0?void 0:e[r][1]},Et.prototype.has=function(t){return bt(this.__data__,t)>-1},Et.prototype.set=function(t,e){var r=this.__data__,n=bt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ot=U(d,"Map");function wt(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function xt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}xt.prototype.clear=function(){this.size=0,this.__data__={hash:new _t,map:new(Ot||Et),string:new _t}},xt.prototype.delete=function(t){var e=wt(this,t).delete(t);return this.size-=e?1:0,e},xt.prototype.get=function(t){return wt(this,t).get(t)},xt.prototype.has=function(t){return wt(this,t).has(t)},xt.prototype.set=function(t,e){var r=wt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Tt(t){var e=this.__data__=new Et(t);this.size=e.size}Tt.prototype.clear=function(){this.__data__=new Et,this.size=0},Tt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Tt.prototype.get=function(t){return this.__data__.get(t)},Tt.prototype.has=function(t){return this.__data__.has(t)},Tt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Et){var n=r.__data__;if(!Ot||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new xt(n)}return r.set(t,e),this.size=r.size,this};var jt=Object.prototype.propertyIsEnumerable,kt=Object.getOwnPropertySymbols,At=kt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i}(kt(t),(function(e){return jt.call(t,e)})))}:function(){return[]};function Rt(t){return function(t,e,r){var n=e(t);return x(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,dt,At)}var Pt=U(d,"DataView"),St=U(d,"Promise"),Ct=U(d,"Set"),Lt="[object Map]",Mt="[object Promise]",Dt="[object Set]",It="[object WeakMap]",Nt="[object DataView]",Bt=S(Pt),Ut=S(Ot),Vt=S(St),qt=S(Ct),zt=S(V),Ft=O;(Pt&&Ft(new Pt(new ArrayBuffer(1)))!=Nt||Ot&&Ft(new Ot)!=Lt||St&&Ft(St.resolve())!=Mt||Ct&&Ft(new Ct)!=Dt||V&&Ft(new V)!=It)&&(Ft=function(t){var e=O(t),r="[object Object]"==e?t.constructor:void 0,n=r?S(r):"";if(n)switch(n){case Bt:return Nt;case Ut:return Lt;case Vt:return Mt;case qt:return Dt;case zt:return It}return e});var Gt=Ft,Xt=d.Uint8Array;function Yt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new xt;++e<r;)this.add(t[e])}function Ht(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}Yt.prototype.add=Yt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Yt.prototype.has=function(t){return this.__data__.has(t)};function Jt(t,e,r,n,o,i){var s=1&r,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=i.get(t),l=i.get(e);if(u&&l)return u==e&&l==t;var p=-1,h=!0,f=2&r?new Yt:void 0;for(i.set(t,e),i.set(e,t);++p<a;){var d=t[p],y=e[p];if(n)var m=s?n(y,d,p,e,t,i):n(d,y,p,t,e,i);if(void 0!==m){if(m)continue;h=!1;break}if(f){if(!Ht(e,(function(t,e){if(s=e,!f.has(s)&&(d===t||o(d,t,r,n,i)))return f.push(e);var s}))){h=!1;break}}else if(d!==y&&!o(d,y,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h}function $t(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function Qt(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var Wt=y?y.prototype:void 0,Kt=Wt?Wt.valueOf:void 0;var Zt=Object.prototype.hasOwnProperty;var te,ee="[object Arguments]",re="[object Array]",ne="[object Object]",oe=Object.prototype.hasOwnProperty;function ie(t,e,r,n,o,i){var s=x(t),a=x(e),c=s?re:Gt(t),u=a?re:Gt(e),l=(c=c==ee?ne:c)==ne,p=(u=u==ee?ne:u)==ne,h=c==u;if(h&&tt(t)){if(!tt(e))return!1;s=!0,l=!1}if(h&&!l)return i||(i=new Tt),s||ct(t)?Jt(t,e,r,n,o,i):function(t,e,r,n,o,i,s){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!i(new Xt(t),new Xt(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return F(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=$t;case"[object Set]":var c=1&n;if(a||(a=Qt),t.size!=e.size&&!c)return!1;var u=s.get(t);if(u)return u==e;n|=2,s.set(t,e);var l=Jt(a(t),a(e),n,o,i,s);return s.delete(t),l;case"[object Symbol]":if(Kt)return Kt.call(t)==Kt.call(e)}return!1}(t,e,c,r,n,o,i);if(!(1&r)){var f=l&&oe.call(t,"__wrapped__"),d=p&&oe.call(e,"__wrapped__");if(f||d){var y=f?t.value():t,m=d?e.value():e;return i||(i=new Tt),o(y,m,r,n,i)}}return!!h&&(i||(i=new Tt),function(t,e,r,n,o,i){var s=1&r,a=Rt(t),c=a.length;if(c!=Rt(e).length&&!s)return!1;for(var u=c;u--;){var l=a[u];if(!(s?l in e:Zt.call(e,l)))return!1}var p=i.get(t),h=i.get(e);if(p&&h)return p==e&&h==t;var f=!0;i.set(t,e),i.set(e,t);for(var d=s;++u<c;){var y=t[l=a[u]],m=e[l];if(n)var v=s?n(m,y,l,e,t,i):n(y,m,l,t,e,i);if(!(void 0===v?y===m||o(y,m,r,n,i):v)){f=!1;break}d||(d="constructor"==l)}if(f&&!d){var _=t.constructor,b=e.constructor;_==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof _&&_ instanceof _&&"function"==typeof b&&b instanceof b||(f=!1)}return i.delete(t),i.delete(e),f}(t,e,r,n,o,i))}function se(t,e,r,n,o){return t===e||(null==t||null==e||!w(t)&&!w(e)?t!=t&&e!=e:ie(t,e,r,n,se,o))}function ae(t,e){return se(t,e)}t.OBSERVER_TYPE=void 0,(te=t.OBSERVER_TYPE||(t.OBSERVER_TYPE={})).ADD="ADD",te.REMOVE="REMOVE",te.CHANGE="CHANGE";var ce={},ue={},le={},pe={};function he(t,e){ce[t.gameObject.id]||(ce[t.gameObject.id]={});var r=ce[t.gameObject.id],n=t.name+"_"+e.join(",");if(r[n])return r[n];for(var o=e.length-1,i=t,s=0;s<o;s++)i=i[e[s]];return r[n]={property:i,key:e[o]},r[n]}function fe(t){var e,r,n=t.systemName,o=t.componentName,i=t.component,s=t.prop,a=t.type;null===(r=null===(e=ue[n])||void 0===e?void 0:e.componentObserver)||void 0===r||r.add({component:i,prop:s,type:a,componentName:o})}function de(e){var r,n,o=e.obj,i=e.key,a=e.prop,c=e.component,u=e.componentName;if(void 0!==o)if(i in o){if(Object.defineProperty(o,"_"+i,{enumerable:!1,writable:!0,value:o[i]}),a.deep&&T(o[i]))try{for(var l=s(Object.keys(o[i])),p=l.next();!p.done;p=l.next()){var h=p.value;de({obj:o[i],key:h,prop:a,component:c,componentName:u})}}catch(t){r={error:t}}finally{try{p&&!p.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}Object.defineProperty(o,i,{enumerable:!0,set:function(e){o["_"+i]!==e&&(o["_"+i]=e,function(e){var r=e.prop,n=e.component,o=e.componentName;for(var i in le){var s=(le[i]||{})[o];s&&s.findIndex((function(t){return ae(t,r)}))>-1&&fe({systemName:i,componentName:o,component:n,prop:r,type:t.OBSERVER_TYPE.CHANGE})}}({prop:a,component:c,componentName:u}))},get:function(){return o["_"+i]}})}else console.error("prop "+i+" not in component: "+u+", Can not observer")}function ye(e,r){var n,o;for(var i in void 0===r&&(r=e.name),le){(le[i]||{})[r]&&(null===(o=null===(n=ue[i])||void 0===n?void 0:n.componentObserver)||void 0===o||o.add({component:e,type:t.OBSERVER_TYPE.REMOVE,componentName:r}))}!function(t){t.gameObject&&delete ce[t.gameObject.id]}(e)}function me(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function ve(t){return function(e,r){var n=me(e,r);n.key=r,n.type=t}}function _e(t){return function(e,r){me(e,r).step=t}}var be=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="Transform",e._parent=null,e.inScene=!1,e.children=[],e.position={x:0,y:0},e.size={width:0,height:0},e.origin={x:0,y:0},e.anchor={x:0,y:0},e.scale={x:1,y:1},e.skew={x:0,y:0},e.rotation=0,e}return r(e,t),e.prototype.init=function(t){var e,r;void 0===t&&(t={});try{for(var n=s(["position","size","origin","anchor","scale","skew"]),o=n.next();!o.done;o=n.next()){var i=o.value;_extends(this[i],t[i])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}this.rotation=t.rotation||this.rotation},Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},set:function(t){t?t.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t.parent===this){var e=this.children.findIndex((function(e){return e===t}));this.children.splice(e,1)}else t.parent&&t.parent.removeChild(t);t._parent=this,this.children.push(t)},e.prototype.removeChild=function(t){var e=this.children.findIndex((function(e){return e===t}));e>-1&&(this.children.splice(e,1),t._parent=null)},e.prototype.clearChildren=function(){this.children.length=0},e.componentName="Transform",n([ve("vector2"),_e(1)],e.prototype,"position",void 0),n([ve("size"),_e(1)],e.prototype,"size",void 0),n([ve("vector2"),_e(.1)],e.prototype,"origin",void 0),n([ve("vector2"),_e(.1)],e.prototype,"anchor",void 0),n([ve("vector2"),_e(.1)],e.prototype,"scale",void 0),n([ve("vector2"),_e(.1)],e.prototype,"skew",void 0),n([ve("number"),_e(.1)],e.prototype,"rotation",void 0),e}(p),ge=0;var Ee=function(){function e(t,e){this._componentCache={},this.components=[],this._name=t,this.id=++ge,this.addComponent(be,e)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(be)},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(t){var e,r;if(this._scene!==t){var n=this._scene;if(this._scene=t,this.transform&&this.transform.children)try{for(var o=s(this.transform.children),i=o.next();!i.done;i=o.next()){i.value.gameObject.scene=t}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}t?t.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,r){var n=function(t){return t instanceof l?t.name:t instanceof Function?t.componentName:void 0}(e);if(!this._componentCache[n]){var o;if(e instanceof Function)o=new e(r);else{if(!(e instanceof p))throw new Error("addComponent recieve Component and Component Constructor");o=e}if(o.gameObject)throw new Error("component has been added on gameObject "+o.gameObject.name);return o.gameObject=this,o.init&&o.init(o.__componentDefaultParams),function(e,r){var n,o;for(var i in void 0===r&&(r=e.name),le)(le[i]||{})[r]&&(null===(o=null===(n=ue[i])||void 0===n?void 0:n.componentObserver)||void 0===o||o.add({component:e,type:t.OBSERVER_TYPE.ADD,componentName:r}))}(o,o.name),function(t,e){var r,n;if(void 0===e&&(e=t.name),e&&pe[e]){if(!(t&&(o=t,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!t.gameObject||!t.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var i=s(pe[e]),a=i.next();!a.done;a=i.next()){var c=a.value,u=he(t,c.prop);de({obj:u.property,key:u.key,prop:c,component:t,componentName:e})}}catch(t){r={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}}(o,o.name),this.components.push(o),this._componentCache[n]=o,o.awake&&o.awake(),o}},e.prototype.removeComponent=function(t){var e;if("string"==typeof t?e=t:t instanceof p?e=t.name:t.componentName&&(e=t.componentName),"Transform"===e)throw new Error("Transform can't be removed");return this._removeComponent(e)},e.prototype._removeComponent=function(t){var e=this.components.findIndex((function(e){return e.name===t}));if(-1!==e){var r=this.components.splice(e,1)[0];return delete this._componentCache[t],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),ye(r,t),r.gameObject=void 0,r}},e.prototype.getComponent=function(t){var e;return"string"==typeof t?e=t:t instanceof p?e=t.name:t.componentName&&(e=t.componentName),void 0!==this._componentCache[e]?this._componentCache[e]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){if(this.transform){for(var t in Array.from(this.transform.children).forEach((function(t){t.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(t);this.components.length=0}else console.error("Cannot destroy gameObject that have already been destroyed.")},e}(),Oe=function(){function e(){this.events=[]}return e.prototype.add=function(e){var r=e.component,n=e.prop,o=e.type,i=e.componentName;if(o===t.OBSERVER_TYPE.REMOVE){if(this.events.find((function(e){return e.component===r&&e.type===t.OBSERVER_TYPE.ADD})))return;this.events=this.events.filter((function(t){return t.component!==r}))}var s=this.events.findIndex((function(t){return t.component===r&&ae(t.prop,n)&&t.type===o}));s>-1&&this.events.splice(s,1),this.events.push({gameObject:r.gameObject,component:r,prop:n,type:o,componentName:i})},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 t=this.events;return this.events=[],t},e}(),we=function(){function t(t){this.started=!1,this.componentObserver=new Oe,this.__systemDefaultParams=t,this.name=this.constructor.systemName}return t.prototype.destroy=function(){var t;this.componentObserver=null,this.__systemDefaultParams=null,null===(t=this.onDestroy)||void 0===t||t.call(this)},t}();var xe,Te=Date.now?Date.now:function(){return(new Date).getTime()},je={originTime:0,playbackRate:1},ke=function(){function t(e,r){e instanceof t&&(r=e,e={}),e=_extends({},je,e),r&&(this._parent=r),this._createTime=Te(),this._timeMark=[{globalTime:this.globalTime,localTime:-e.originTime,entropy:-e.originTime,playbackRate:e.playbackRate,globalEntropy:0}],this._parent&&(this._timeMark[0].globalEntropy=this._parent.entropy),this._playbackRate=e.playbackRate}return Object.defineProperty(t.prototype,"globalTime",{get:function(){return this.parent?this.parent.currentTime:Te()-this._createTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastTimeMark",{get:function(){return this._timeMark[this._timeMark.length-1]},enumerable:!1,configurable:!0}),t.prototype.markTime=function(t){var e=void 0===t?{}:t,r=e.time,n=void 0===r?this.currentTime:r,o=e.entropy,i=void 0===o?this.entropy:o,s=e.playbackRate,a=void 0===s?this.playbackRate:s,c={globalTime:this.globalTime,localTime:n,entropy:i,playbackRate:a,globalEntropy:this.globalEntropy};this._timeMark.push(c)},Object.defineProperty(t.prototype,"currentTime",{get:function(){var t=this.lastTimeMark,e=t.localTime,r=t.globalTime;return e+(this.globalTime-r)*this.playbackRate},set:function(t){this.markTime({time:t})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"globalEntropy",{get:function(){return this._parent?this._parent.entropy:this.globalTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"entropy",{get:function(){var t=this.lastTimeMark,e=t.entropy,r=t.globalEntropy;return e+Math.abs((this.globalEntropy-r)*this.playbackRate)},set:function(t){if(this.entropy>t){var e=this.seekTimeMark(t);this._timeMark.length=e+1}this.markTime({entropy:t})},enumerable:!1,configurable:!0}),t.prototype.fork=function(e){return new t(e,this)},t.prototype.seekGlobalTime=function(t){var e=this.seekTimeMark(t),r=this._timeMark[e],n=r.entropy,o=r.playbackRate;return r.globalTime+(t-n)/Math.abs(o)},t.prototype.seekLocalTime=function(t){var e=this.seekTimeMark(t),r=this._timeMark[e],n=r.localTime,o=r.entropy;return r.playbackRate>0?n+(t-o):n-(t-o)},t.prototype.seekTimeMark=function(t){var e=this._timeMark,r=0,n=e.length-1;if(t<=e[r].entropy)return r;if(t>=e[n].entropy)return n;for(var o=Math.floor((r+n)/2);o>r&&o<n;){if(t===e[o].entropy)return o;t<e[o].entropy?n=o:t>e[o].entropy&&(r=o),o=Math.floor((r+n)/2)}return r},Object.defineProperty(t.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){t!==this.playbackRate&&(this.markTime({playbackRate:t}),this._playbackRate=t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paused",{get:function(){if(0===this.playbackRate)return!0;for(var t=this.parent;t;){if(0===t.playbackRate)return!0;t=t.parent}return!1},enumerable:!1,configurable:!0}),t}(),Ae={autoStart:!0,frameRate:60},Re=function(){function t(t){var e=this;t=_extends({},Ae,t),this._frameCount=0,this._frameDuration=1e3/t.frameRate,this.autoStart=t.autoStart,this.frameRate=t.frameRate,this.timeline=new ke({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=function(){e._started&&(e._requestId=requestAnimationFrame(e._ticker),e.update())},this.autoStart&&this.start()}return t.prototype.update=function(){var t,e,r=this.timeline.currentTime,n=r-this._lastFrameTime;if(n>=this._frameDuration){var o=r-n%this._frameDuration,i=o-this._lastFrameTime;this._lastFrameTime=o;var a={deltaTime:i,time:o,currentTime:o,frameCount:++this._frameCount,fps:Math.round(1e3/i)};try{for(var c=s(this._tickers),u=c.next();!u.done;u=c.next()){var l=u.value;"function"==typeof l&&l(a)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}}},t.prototype.add=function(t){this._tickers.add(t)},t.prototype.remove=function(t){this._tickers.delete(t)},t.prototype.start=function(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))},t.prototype.pause=function(){this._started=!1,this.timeline.playbackRate=0},t.prototype.setPlaybackRate=function(t){this.timeline.playbackRate=t},t}(),Pe=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.gameObjects=[],n.scene=n,n}return r(e,t),e.prototype.addGameObject=function(t){this.gameObjects.push(t),t.transform&&(t.transform.inScene=!0)},e.prototype.removeGameObject=function(t){var e=this.gameObjects.indexOf(t);-1!==e&&(t.transform&&(t.transform.inScene=!1),this.gameObjects.splice(e,1))},e.prototype.destroy=function(){this.scene=null,t.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},e}(Ee);t.LOAD_SCENE_MODE=void 0,(xe=t.LOAD_SCENE_MODE||(t.LOAD_SCENE_MODE={})).SINGLE="SINGLE",xe.MULTI_CANVAS="MULTI_CANVAS";var Se=function(t){if((t instanceof we||t instanceof p)&&!t.started){t.started=!0;try{t.start&&t.start()}catch(e){t instanceof p?console.error(t.constructor.componentName+" start error",e):console.error(t.constructor.systemName+" start error",e)}}},Ce=function(e){function n(t){var r,n,o=void 0===t?{}:t,i=o.systems,a=o.frameRate,c=void 0===a?60:a,u=o.autoStart,l=void 0===u||u,p=o.needScene,h=void 0===p||p,f=e.call(this)||this;if(f.playing=!1,f.started=!1,f.multiScenes=[],f.systems=[],window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=f),f.ticker=new Re({autoStart:!1,frameRate:c}),f.initTicker(),i&&i.length)try{for(var d=s(i),y=d.next();!y.done;y=d.next()){var m=y.value;f.addSystem(m)}}catch(t){r={error:t}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}return h&&f.loadScene(new Pe("scene")),l&&f.start(),f}return r(n,e),Object.defineProperty(n.prototype,"scene",{get:function(){return this._scene},set:function(t){this._scene=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"gameObjects",{get:function(){return function(t){var e,r,n,o=(null===(n=null==t?void 0:t.scene)||void 0===n?void 0:n.gameObjects)||[],i=null==t?void 0:t.multiScenes.map((function(t){return t.gameObjects})),a=[];try{for(var u=s(i),l=u.next();!l.done;l=u.next())a=c(a,l.value)}catch(t){e={error:t}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return c(o,a)}(this)},enumerable:!1,configurable:!0}),n.prototype.addSystem=function(t,e){var r;if(t instanceof Function)r=new t(e);else{if(!(t instanceof we))return void console.warn("can only add System");r=t}if(!this.systems.find((function(t){return t.constructor===r.constructor}))){r.game=this,r.init&&r.init(r.__systemDefaultParams),function(t,e){le[e.systemName]=e.observerInfo,ue[e.systemName]=t}(r,r.constructor),function(t){var e,r,n,o,i=[];t instanceof Array?i.push.apply(i,c(t)):i.push(t);try{for(var a=s(i),u=a.next();!u.done;u=a.next()){var l=u.value;for(var p in l.observerInfo){pe[p]=pe[p]||[];var h=pe[p],f=function(t){-1===h.findIndex((function(e){return ae(e,t)}))&&pe[p].push(t)};try{for(var d=(n=void 0,s(l.observerInfo[p])),y=d.next();!y.done;y=d.next())f(y.value)}catch(t){n={error:t}}finally{try{y&&!y.done&&(o=d.return)&&o.call(d)}finally{if(n)throw n.error}}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}}(r.constructor);try{r.awake&&r.awake()}catch(t){console.error(r.constructor.systemName+" awake error",t)}return this.systems.push(r),r}console.warn(r.constructor.systemName+" System has been added")},n.prototype.removeSystem=function(t){if(t){var e=-1;"string"==typeof t?e=this.systems.findIndex((function(e){return e.name===t})):t instanceof Function?e=this.systems.findIndex((function(e){return e.constructor===t})):t instanceof we&&(e=this.systems.findIndex((function(e){return e===t}))),e>-1&&(this.systems[e].destroy&&this.systems[e].destroy(),this.systems.splice(e,1))}},n.prototype.getSystem=function(t){return this.systems.find((function(e){return"string"==typeof t?e.name===t:e instanceof t}))},n.prototype.pause=function(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},n.prototype.start=function(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())},n.prototype.resume=function(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())},n.prototype.initTicker=function(){var t=this;this.ticker.add((function(e){var r,n,o,i;t.scene&&function(t,e){var r,n,o,i,a,c,u,l;void 0===e&&(e=[]);try{for(var p=s(e),h=p.next();!h.done;h=p.next()){var f=h.value;try{for(var d=(o=void 0,s(f.components)),y=d.next();!y.done;y=d.next()){var m=y.value;try{Se(m),m.update&&m.update(t)}catch(t){console.error("gameObject: "+f.name+" "+m.name+" update error",t)}}}catch(t){o={error:t}}finally{try{y&&!y.done&&(i=d.return)&&i.call(d)}finally{if(o)throw o.error}}}}catch(t){r={error:t}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var v=s(e),_=v.next();!_.done;_=v.next()){f=_.value;try{for(var b=(u=void 0,s(f.components)),g=b.next();!g.done;g=b.next()){m=g.value;try{m.lateUpdate&&m.lateUpdate(t)}catch(t){console.error("gameObject: "+f.name+" "+m.name+" lateUpdate error",t)}}}catch(t){u={error:t}}finally{try{g&&!g.done&&(l=b.return)&&l.call(b)}finally{if(u)throw u.error}}}}catch(t){a={error:t}}finally{try{_&&!_.done&&(c=v.return)&&c.call(v)}finally{if(a)throw a.error}}}(e,t.gameObjects);try{for(var a=s(t.systems),c=a.next();!c.done;c=a.next()){var u=c.value;try{Se(u),u.update&&u.update(e)}catch(e){console.error(u.constructor.systemName+" update error",e)}}}catch(t){r={error:t}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}try{for(var l=s(t.systems),p=l.next();!p.done;p=l.next()){u=p.value;try{u.lateUpdate&&u.lateUpdate(e)}catch(e){console.error(u.constructor.systemName+" lateUpdate error",e)}}}catch(t){o={error:t}}finally{try{p&&!p.done&&(i=l.return)&&i.call(l)}finally{if(o)throw o.error}}}))},n.prototype.triggerResume=function(){var t,e;!function(t){var e,r,n,o;try{for(var i=s(t),a=i.next();!a.done;a=i.next()){var c=a.value;try{for(var u=(n=void 0,s(c.components)),l=u.next();!l.done;l=u.next()){var p=l.value;try{p.onResume&&p.onResume()}catch(t){console.error("gameObject: "+c.name+", "+p.name+", onResume error",t)}}}catch(t){n={error:t}}finally{try{l&&!l.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}(this.gameObjects);try{for(var r=s(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onResume&&o.onResume()}catch(t){console.error(o.constructor.systemName+", onResume error",t)}}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}},n.prototype.triggerPause=function(){var t,e;!function(t){var e,r,n,o;try{for(var i=s(t),a=i.next();!a.done;a=i.next()){var c=a.value;try{for(var u=(n=void 0,s(c.components)),l=u.next();!l.done;l=u.next()){var p=l.value;try{p.onPause&&p.onPause()}catch(t){console.error("gameObject: "+c.name+", "+p.name+", onResume error",t)}}}catch(t){n={error:t}}finally{try{l&&!l.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}}(this.gameObjects);try{for(var r=s(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onPause&&o.onPause()}catch(t){console.error(o.constructor.systemName+", onPause error",t)}}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}},n.prototype.destroySystems=function(){var t,e;try{for(var r=s(c(this.systems)),n=r.next();!n.done;n=r.next()){var o=n.value;this.removeSystem(o)}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}this.systems.length=0},n.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},n.prototype.loadScene=function(e){var r=e.scene,n=e.mode,o=void 0===n?t.LOAD_SCENE_MODE.SINGLE:n,i=e.params,s=void 0===i?{}:i;if(r){switch(o){case t.LOAD_SCENE_MODE.SINGLE:this.scene=r;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(r)}this.emit("sceneChanged",{scene:r,mode:o,params:s})}},n}(u);function Le(t,e){t.constructor.IDEProps||(t.constructor.IDEProps=[]),t.constructor.IDEProps.push(e)}function Me(t){return void 0===t&&(t={}),function(e){if(!e.observerInfo){for(var r in t)for(var n in t[r]){"string"==typeof t[r][n]&&(t[r][n]=[t[r][n]]);var o=void 0;Array.isArray(t[r][n])&&(o={prop:t[r][n],deep:!1},t[r][n]=o),"string"==typeof(o=t[r][n]).prop&&(o.prop=[o.prop])}e.observerInfo=t}}}var De=function(){function t(t,e,r){void 0===e&&(e=!1),this.next=null,this.prev=null,this.owner=null,this.fn=t,this.once=e,this.thisArg=r}return t.prototype.detach=function(){return null!==this.owner&&(this.owner.detach(this),!0)},t.prototype.dispose=function(){this.detach()},t}(),Ie=function(){function t(){this._head=null,this._tail=null,this._filter=null}return t.prototype.handlers=function(){for(var t=this._head,e=[];t;)e.push(t),t=t.next;return e},t.prototype.hasAny=function(){return!!this._head},t.prototype.has=function(t){return t.owner===this},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=this._head;if(!r)return!1;if(this._filter&&!this._filter.apply(this,t))return!1;for(;r;)r.once&&this.detach(r),r.fn.apply(r.thisArg,t),r=r.next;return!0},t.prototype.add=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new De(t,!1,e))},t.prototype.once=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new De(t,!0,e))},t.prototype.detach=function(t){var e=t;return e.owner!==this||(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e===this._head?(this._head=e.next,null===e.next&&(this._tail=null)):e===this._tail&&(this._tail=e.prev,this._tail&&(this._tail.next=null)),e.owner=null),this},t.prototype.detachAll=function(){var t=this._head;if(!t)return this;for(this._head=null,this._tail=null;t;)t.owner=null,t=t.next;return this},t.prototype.filter=function(t){this._filter=t},t.prototype.proxy=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.dispatch.apply(t,e)},o=0;o<e.length;++o)e[o].add(n);return this},t.prototype._addSignalBinding=function(t){var e=t;return this._head?(this._tail&&(this._tail.next=e),e.prev=this._tail,this._tail=e):(this._head=e,this._tail=e),e.owner=this,e},t}();var Ne,Be,Ue=function(t,e){if(t){e=e||{};for(var r={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},n=r.parser[e.strictMode?"strict":"loose"].exec(t),o={},i=14;i--;)o[r.key[i]]=n[i]||"";return o[r.q.name]={},o[r.key[12]].replace(r.q.parser,(function(t,e,n){e&&(o[r.q.name][e]=n)})),o}},Ve=function(t){this.config=t,this.onError=new Ie,this.onComplete=new Ie,this.onProgress=new Ie},qe=function(t,e){return(qe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function ze(t,e){function r(){this.constructor=t}qe(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function Fe(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}function Ge(t){var e="";if(0===t.indexOf("data:")){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var n=t.indexOf("?"),o=t.indexOf("#"),i=Math.min(n>-1?n:t.length,o>-1?o:t.length);e=(t=t.substring(0,i)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()}function Xe(t){throw new Error("Unexpected value. Should have been never.")}!function(t){t[t.Unknown=0]="Unknown",t[t.Buffer=1]="Buffer",t[t.Blob=2]="Blob",t[t.Json=3]="Json",t[t.Xml=4]="Xml",t[t.Image=5]="Image",t[t.Audio=6]="Audio",t[t.Video=7]="Video",t[t.Text=8]="Text"}(Ne||(Ne={})),function(t){t[t.NotStarted=0]="NotStarted",t[t.Loading=1]="Loading",t[t.Complete=2]="Complete"}(Be||(Be={}));var Ye,He=function(t){function e(e,r){var n=t.call(this,e)||this;return n.elementType=r,n._boundOnLoad=n._onLoad.bind(n),n._boundOnError=n._onError.bind(n),n._boundOnTimeout=n._onTimeout.bind(n),n._element=n._createElement(),n._elementTimer=0,n}return ze(e,t),e.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin);var e=t.sourceSet||[t.url];if(navigator.isCocoonJS)this._element.src=e[0];else for(var r=0;r<e.length;++r){var n=e[r],o=t.mimeTypes?t.mimeTypes[r]:void 0;o||(o=this.elementType+"/"+Ge(n));var i=document.createElement("source");i.src=n,i.type=o,this._element.appendChild(i)}this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("canplaythrough",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),this._element.load(),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},e.prototype.abort=function(){for(this._clearEvents();this._element.firstChild;)this._element.removeChild(this._element.firstChild);this._error(this.elementType+" load aborted by the user.")},e.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement(this.elementType)},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("canplaythrough",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(){this._clearEvents();var t=Ne.Unknown;switch(this.elementType){case"audio":t=Ne.Audio;break;case"video":t=Ne.Video;break;default:Xe(this.elementType)}this.onComplete.dispatch(t,this._element)},e.prototype._onLoad=function(){this._complete()},e.prototype._onError=function(){this._error(this.elementType+" failed to load.")},e.prototype._onTimeout=function(){this._error(this.elementType+" load timed out.")},e}(Ve),Je=function(t){function e(e){return t.call(this,e,"audio")||this}return ze(e,t),e}(He),$e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._boundOnLoad=e._onLoad.bind(e),e._boundOnError=e._onError.bind(e),e._boundOnTimeout=e._onTimeout.bind(e),e._element=e._createElement(),e._elementTimer=0,e}return ze(e,t),e.prototype.load=function(){var t=this.config;t.crossOrigin&&(this._element.crossOrigin=t.crossOrigin),this._element.src=t.url,this._element.addEventListener("load",this._boundOnLoad,!1),this._element.addEventListener("error",this._boundOnError,!1),t.timeout&&(this._elementTimer=window.setTimeout(this._boundOnTimeout,t.timeout))},e.prototype.abort=function(){this._clearEvents(),this._element.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",this._error("Image load aborted by the user.")},e.prototype._createElement=function(){return this.config.loadElement?this.config.loadElement:document.createElement("img")},e.prototype._clearEvents=function(){clearTimeout(this._elementTimer),this._element.removeEventListener("load",this._boundOnLoad,!1),this._element.removeEventListener("error",this._boundOnError,!1)},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(){this._clearEvents(),this.onComplete.dispatch(Ne.Image,this._element)},e.prototype._onLoad=function(){this._complete()},e.prototype._onError=function(){this._error("Image failed to load.")},e.prototype._onTimeout=function(){this._error("Image load timed out.")},e}(Ve),Qe=function(t){function e(e){return t.call(this,e,"video")||this}return ze(e,t),e}(He),We=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest);function Ke(t){return t.toString().replace("object ","")}!function(t){t.Default="text",t.Buffer="arraybuffer",t.Blob="blob",t.Document="document",t.Json="json",t.Text="text"}(Ye||(Ye={}));var Ze=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._boundOnLoad=e._onLoad.bind(e),e._boundOnAbort=e._onAbort.bind(e),e._boundOnError=e._onError.bind(e),e._boundOnTimeout=e._onTimeout.bind(e),e._boundOnProgress=e._onProgress.bind(e),e._xhr=e._createRequest(),e._xhrType=Ye.Default,e}return ze(e,t),e.prototype.load=function(){var t=this.config,e=Ge(t.url);"string"!=typeof t.xhrType&&(t.xhrType=this._determineXhrType(e));var r=this._xhr;this._xhrType=t.xhrType||Ye.Default,We?(r.timeout=t.timeout||5e3,r.onload=this._boundOnLoad,r.onerror=this._boundOnError,r.ontimeout=this._boundOnTimeout,r.onprogress=this._boundOnProgress,r.open("GET",t.url,!0),setTimeout((function(){r.send()}),0)):(r.open("GET",t.url,!0),t.timeout&&(r.timeout=t.timeout),t.xhrType===Ye.Json||t.xhrType===Ye.Document?r.responseType=Ye.Text:r.responseType=t.xhrType,r.addEventListener("load",this._boundOnLoad,!1),r.addEventListener("abort",this._boundOnAbort,!1),r.addEventListener("error",this._boundOnError,!1),r.addEventListener("timeout",this._boundOnTimeout,!1),r.addEventListener("progress",this._boundOnProgress,!1),r.send())},e.prototype.abort=function(){We?(this._clearEvents(),this._xhr.abort(),this._onAbort()):this._xhr.abort()},e.prototype._createRequest=function(){return We?new window.XDomainRequest:new XMLHttpRequest},e.prototype._determineXhrType=function(t){return e._xhrTypeMap[t]||Ye.Default},e.prototype._clearEvents=function(){We?(this._xhr.onload=null,this._xhr.onerror=null,this._xhr.ontimeout=null,this._xhr.onprogress=null):(this._xhr.removeEventListener("load",this._boundOnLoad,!1),this._xhr.removeEventListener("abort",this._boundOnAbort,!1),this._xhr.removeEventListener("error",this._boundOnError,!1),this._xhr.removeEventListener("timeout",this._boundOnTimeout,!1),this._xhr.removeEventListener("progress",this._boundOnProgress,!1))},e.prototype._error=function(t){this._clearEvents(),this.onError.dispatch(t)},e.prototype._complete=function(t,e){this._clearEvents(),this.onComplete.dispatch(t,e)},e.prototype._onLoad=function(){var t=this._xhr,e="",r=void 0===t.status?200:t.status;if(void 0!==t.responseType&&""!==t.responseType&&"text"!==t.responseType||(e=t.responseText),0===r&&(e.length>0||t.responseType===Ye.Buffer)?r=200:1223===r&&(r=204),200===100*Math.floor(r/100))switch(this._xhrType){case Ye.Buffer:this._complete(Ne.Buffer,t.response);break;case Ye.Blob:this._complete(Ne.Blob,t.response);break;case Ye.Document:this._parseDocument(e);break;case Ye.Json:this._parseJson(e);break;case Ye.Default:case Ye.Text:this._complete(Ne.Text,e);break;default:Xe(this._xhrType)}else this._error("["+t.status+"] "+t.statusText+": "+t.responseURL)},e.prototype._parseDocument=function(t){try{if(window.DOMParser){var e=(new DOMParser).parseFromString(t,"text/xml");this._complete(Ne.Xml,e)}else{var r=document.createElement("div");r.innerHTML=t,this._complete(Ne.Xml,r)}}catch(t){this._error("Error trying to parse loaded xml: "+t)}},e.prototype._parseJson=function(t){try{var e=JSON.parse(t);this._complete(Ne.Json,e)}catch(t){this._error("Error trying to parse loaded json: "+t)}},e.prototype._onAbort=function(){var t=this._xhr;this._error(Ke(t)+" Request was aborted by the user.")},e.prototype._onError=function(){var t=this._xhr;this._error(Ke(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},e.prototype._onTimeout=function(){var t=this._xhr;this._error(Ke(t)+" Request timed out.")},e.prototype._onProgress=function(t){t&&t.lengthComputable&&this.onProgress.dispatch(t.loaded/t.total)},e.setExtensionXhrType=function(t,r){t&&0===t.indexOf(".")&&(t=t.substring(1)),t&&(e._xhrTypeMap[t]=r)},e.ResponseType=Ye,e._xhrTypeMap={xhtml:Ye.Document,html:Ye.Document,htm:Ye.Document,xml:Ye.Document,tmx:Ye.Document,svg:Ye.Document,tsx:Ye.Document,gif:Ye.Blob,png:Ye.Blob,bmp:Ye.Blob,jpg:Ye.Blob,jpeg:Ye.Blob,tif:Ye.Blob,tiff:Ye.Blob,webp:Ye.Blob,tga:Ye.Blob,json:Ye.Json,text:Ye.Text,txt:Ye.Text,ttf:Ye.Buffer,otf:Ye.Buffer},e}(Ve);function tr(t){var e=t;return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(null===e)throw new Error("Callback was already called.");var n=e;return e=null,n.apply(this,t)}}var er=function(){function t(t,e){if(void 0===e&&(e=1),this.worker=t,this.concurrency=e,this.workers=0,this.buffer=0,this.paused=!1,this._started=!1,this._tasks=[],this.onSaturated=new Ie,this.onUnsaturated=new Ie,this.onEmpty=new Ie,this.onDrain=new Ie,this.onError=new Ie,0===e)throw new Error("Concurrency must not be zero");this.buffer=e/4}return Object.defineProperty(t.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.onDrain.detachAll(),this.workers=0,this._started=!1,this._tasks=[]},t.prototype.push=function(t,e){this._insert(t,!1,e)},t.prototype.unshift=function(t,e){this._insert(t,!0,e)},t.prototype.process=function(){for(;!this.paused&&this.workers<this.concurrency&&this._tasks.length;){var t=this._tasks.shift();0===this._tasks.length&&this.onEmpty.dispatch(),this.workers+=1,this.workers===this.concurrency&&this.onSaturated.dispatch(),this.worker(t.data,tr(this._next(t)))}},t.prototype.length=function(){return this._tasks.length},t.prototype.running=function(){return this.workers},t.prototype.idle=function(){return this._tasks.length+this.workers===0},t.prototype.pause=function(){!0!==this.paused&&(this.paused=!0)},t.prototype.resume=function(){if(!1!==this.paused){this.paused=!1;for(var t=1;t<=this.concurrency;t++)this.process()}},t.prototype.getTask=function(t){return this._tasks[t]},t.prototype._insert=function(t,e,r){var n=this;if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(this._started=!0,null==t&&this.idle())setTimeout((function(){return n.onDrain.dispatch()}),1);else{var o={data:t,callback:r};e?this._tasks.unshift(o):this._tasks.push(o),setTimeout((function(){return n.process()}),1)}},t.prototype._next=function(t){var e=this;return function(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];e.workers-=1,t.callback&&t.callback.apply(t,Fe([r],n)),r&&e.onError.dispatch(r,t.data),e.workers<=e.concurrency-e.buffer&&e.onUnsaturated.dispatch(),e.idle()&&e.onDrain.dispatch(),e.process()}},t}(),rr=function(){function t(e,r){if(this.children=[],this.onStart=new Ie,this.onProgress=new Ie,this.onComplete=new Ie,this.onAfterMiddleware=new Ie,this.data=null,this.type=Ne.Unknown,this.error="",this.progressChunk=0,this._dequeue=function(){},this._onCompleteBinding=null,this._state=Be.NotStarted,this.name=e,this.metadata=r.metadata,"string"!=typeof r.crossOrigin&&(r.crossOrigin=this._determineCrossOrigin(r.url)),r.strategy&&"function"!=typeof r.strategy)this._strategy=r.strategy,this._strategy.config=r;else{var n=r.strategy;n||(n=t._loadStrategyMap[Ge(r.url)]),n||(n=t._defaultLoadStrategy),this._strategy=new n(r)}this._strategy.onError.add(this._error,this),this._strategy.onComplete.add(this._complete,this),this._strategy.onProgress.add(this._progress,this)}return t.setDefaultLoadStrategy=function(e){t._defaultLoadStrategy=e},t.setLoadStrategy=function(e,r){e&&0===e.indexOf(".")&&(e=e.substring(1)),e&&(t._loadStrategyMap[e]=r)},Object.defineProperty(t.prototype,"strategy",{get:function(){return this._strategy},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"url",{get:function(){return this._strategy.config.url},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLoading",{get:function(){return this._state===Be.Loading},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isComplete",{get:function(){return this._state===Be.Complete},enumerable:!0,configurable:!0}),t.prototype.abort=function(){this._strategy.abort()},t.prototype.load=function(){this._state=Be.Loading,this.onStart.dispatch(this),this._strategy.load()},t.prototype._error=function(t){this._state=Be.Complete,this.error=t,this.onComplete.dispatch(this)},t.prototype._complete=function(t,e){this._state=Be.Complete,this.type=t,this.data=e,this.onComplete.dispatch(this)},t.prototype._progress=function(t){this.onProgress.dispatch(this,t)},t.prototype._determineCrossOrigin=function(e,r){if(void 0===r&&(r=window.location),0===e.indexOf("data:")||0===e.indexOf("javascript:"))return"";if(window.origin!==window.location.origin)return"anonymous";t._tempAnchor||(t._tempAnchor=document.createElement("a")),t._tempAnchor.href=e;var n=Ue(t._tempAnchor.href,{strictMode:!0}),o=!n.port&&""===r.port||n.port===r.port,i=n.protocol?n.protocol+":":"";return n.host===r.hostname&&o&&i===r.protocol?"":"anonymous"},t._tempAnchor=null,t._defaultLoadStrategy=Ze,t._loadStrategyMap={gif:$e,png:$e,bmp:$e,jpg:$e,jpeg:$e,tif:$e,tiff:$e,webp:$e,tga:$e,svg:$e,"svg+xml":$e,mp3:Je,ogg:Je,wav:Je,mp4:Qe,webm:Qe,mov:Qe},t}();var nr,or,ir=/(#[\w-]+)?$/,sr=function(){function t(e,r){void 0===e&&(e=""),void 0===r&&(r=10),this.progress=0,this.loading=!1,this.defaultQueryString="",this.resources={},this.onError=new Ie,this.onLoad=new Ie,this.onStart=new Ie,this.onComplete=new Ie,this.onProgress=new Ie,this._baseUrl="",this._urlResolvers=[],this._middleware=[],this._resourcesParsing=[],this._boundLoadResource=this._loadResource.bind(this),this.baseUrl=e,this._queue=new er(this._boundLoadResource,r),this._queue.pause(),this._middleware=t._defaultMiddleware.slice()}return Object.defineProperty(t.prototype,"baseUrl",{get:function(){return this._baseUrl},set:function(t){for(;t.length&&"/"===t.charAt(t.length-1);)t=t.slice(0,-1);this._baseUrl=t},enumerable:!0,configurable:!0}),t.prototype.add=function(t,e){if(Array.isArray(t)){for(var r=0;r<t.length;++r)this.add(t[r]);return this}var n="",o="",i=this._baseUrl,s={url:""};if("object"==typeof t?(n=t.url,o=t.name||t.url,i=t.baseUrl||i,s=t):(o=t,n="string"==typeof e?e:o),!n)throw new Error("You must specify the `url` property.");if(this.loading&&!s.parentResource)throw new Error("Cannot add root resources while the loader is running.");if(this.resources[o])throw new Error('Resource named "'+o+'" already exists.');n=this._prepareUrl(n,i),s.url=n;var a=new rr(o,s);if(this.resources[o]=a,"function"==typeof s.onComplete&&a.onAfterMiddleware.once(s.onComplete),this.loading){var c=s.parentResource,u=[];for(r=0;r<c.children.length;++r)c.children[r].isComplete||u.push(c.children[r]);var l=c.progressChunk*(u.length+1)/(u.length+2);c.children.push(a),c.progressChunk=l;for(r=0;r<u.length;++r)u[r].progressChunk=l;a.progressChunk=l}return this._queue.push(a),this},t.prototype.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),this._middleware.push({fn:e,priority:r}),this._middleware.sort((function(t,e){return t.priority-e.priority})),this},t.prototype.reset=function(){for(var t in this.progress=0,this.loading=!1,this._queue.reset(),this._queue.pause(),this.resources){var e=this.resources[t];e&&(e._onCompleteBinding&&e._onCompleteBinding.detach(),e.isLoading&&e.abort())}return this.resources={},this},t.prototype.load=function(t){if("function"==typeof t&&this.onComplete.once(t),this.loading)return this;if(this._queue.idle())this._onStart(),this._onComplete();else{for(var e=100/this._queue.length(),r=0;r<this._queue.length();++r)this._queue.getTask(r).data.progressChunk=e;this._onStart(),this._queue.resume()}return this},Object.defineProperty(t.prototype,"concurrency",{get:function(){return this._queue.concurrency},set:function(t){this._queue.concurrency=t},enumerable:!0,configurable:!0}),t.prototype.addUrlResolver=function(t){return this._urlResolvers.push(t),this},t.prototype._prepareUrl=function(t,e){var r=Ue(t,{strictMode:!0});if(this._urlResolvers.forEach((function(e){t=e(t,r),r=Ue(t,{strictMode:!0})})),r.protocol||0===t.indexOf("//")||(t=e.length&&"/"!==t.charAt(0)?e+"/"+t:e+t),this.defaultQueryString){var n=ir.exec(t);if(n){var o=n[0];-1!==(t=t.substr(0,t.length-o.length)).indexOf("?")?t+="&"+this.defaultQueryString:t+="?"+this.defaultQueryString,t+=o}}return t},t.prototype._loadResource=function(t,e){t._dequeue=e,t._onCompleteBinding=t.onComplete.once(this._onLoad,this),t.load()},t.prototype._onStart=function(){this.progress=0,this.loading=!0,this.onStart.dispatch(this)},t.prototype._onComplete=function(){this.progress=100,this.loading=!1,this.onComplete.dispatch(this,this.resources)},t.prototype._onLoad=function(t){var e=this;t._onCompleteBinding=null,this._resourcesParsing.push(t),t._dequeue(),function(t,e,r,n){void 0===n&&(n=!1);var o=0,i=t.length;!function s(a){a||o===i?r&&r(a):n?setTimeout((function(){return e(t[o++],s)}),1):e(t[o++],s)}()}(this._middleware,(function(r,n){r.fn.call(e,t,n)}),(function(){t.onAfterMiddleware.dispatch(t),e.progress=Math.min(100,e.progress+t.progressChunk),e.onProgress.dispatch(e,t),t.error?e.onError.dispatch(t.error,e,t):e.onLoad.dispatch(e,t),e._resourcesParsing.splice(e._resourcesParsing.indexOf(t),1),e._queue.idle()&&0===e._resourcesParsing.length&&e._onComplete()}),!0)},t.use=function(e,r){return void 0===r&&(r=t.DefaultMiddlewarePriority),t._defaultMiddleware.push({fn:e,priority:r}),t._defaultMiddleware.sort((function(t,e){return t.priority-e.priority})),t},t.DefaultMiddlewarePriority=50,t._defaultMiddleware=[],t}(),ar=function(e){function n(r){var n=r.resource,o=r.resourceTotal,i=e.call(this)||this;return i.progress=0,i.resourceTotal=0,i.resourceLoadedCount=0,i.resource=n,i.resourceTotal=o,0===o&&i.resource.emit(t.LOAD_EVENT.COMPLETE,i),i}return r(n,e),n.prototype.onStart=function(){this.resource.emit(t.LOAD_EVENT.START,this)},n.prototype.onProgress=function(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(t.LOAD_EVENT.LOADED,this,e):this.resource.emit(t.LOAD_EVENT.ERROR,this,e),this.resource.emit(t.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(t.LOAD_EVENT.COMPLETE,this)},n}(u),cr={AbstractLoadStrategy:Ve,AudioLoadStrategy:Je,ImageLoadStrategy:$e,XhrResponseType:Ye,MediaElementLoadStrategy:He,VideoLoadStrategy:Qe,XhrLoadStrategy:Ze,Loader:sr,Resource:rr,ResourceType:Ne,ResourceState:Be};t.LOAD_EVENT=void 0,(nr=t.LOAD_EVENT||(t.LOAD_EVENT={})).START="start",nr.PROGRESS="progress",nr.LOADED="loaded",nr.COMPLETE="complete",nr.ERROR="error",t.RESOURCE_TYPE=void 0,(or=t.RESOURCE_TYPE||(t.RESOURCE_TYPE={})).IMAGE="IMAGE",or.SPRITE="SPRITE",or.SPRITE_ANIMATION="SPRITE_ANIMATION",or.AUDIO="AUDIO",or.VIDEO="VIDEO",Ze.setExtensionXhrType("json",Ye.Json),Ze.setExtensionXhrType("tex",Ye.Json),Ze.setExtensionXhrType("ske",Ye.Json),Ze.setExtensionXhrType("mp3",Ye.Buffer),Ze.setExtensionXhrType("wav",Ye.Buffer),Ze.setExtensionXhrType("aac",Ye.Buffer),Ze.setExtensionXhrType("ogg",Ye.Buffer);var ur={png:$e,jpg:$e,jpeg:$e,webp:$e,json:Ze,tex:Ze,ske:Ze,audio:Ze,video:Qe},lr=new(function(e){function n(t){var r=e.call(this)||this;return r.timeout=6e3,r.preProcessResourceHandlers=[],r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return r(n,e),n.prototype.loadConfig=function(t){this.addResource(t),this.preload()},n.prototype.loadSingle=function(t){return this.addResource([t]),this.getResource(t.name)},n.prototype.addResource=function(t){var e,r;if(!t||t.length<1)console.warn("no resources");else try{for(var n=s(t),o=n.next();!o.done;o=n.next()){var i=o.value;this.resourcesMap[i.name]?console.warn(i.name+" was already added"):(this.resourcesMap[i.name]=i,this.resourcesMap[i.name].data={})}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},n.prototype.addPreProcessResourceHandler=function(t){this.preProcessResourceHandlers.push(t)},n.prototype.removePreProcessResourceHandler=function(t){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(t),1)},n.prototype.preload=function(){var t=[];for(var e in this.resourcesMap){var r=this.resourcesMap[e];!r.preload||r.complete||this.promiseMap[e]||t.push(r.name)}this.progress=new ar({resource:this,resourceTotal:t.length}),this.loadResource({names:t,preload:!0})},n.prototype.getResource=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this.loadResource({names:[t]}),[2,this.promiseMap[t]||Promise.resolve({})]}))}))},n.prototype.instance=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return e=this.resourcesMap[t],(r=this.makeInstanceFunctions[e.type])?[4,this.makeInstanceFunctions[e.type](e)]:[3,2];case 1:r=n.sent(),n.label=2;case 2:return[2,r]}}))}))},n.prototype.destroy=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._destroy(t)];case 1:return e.sent(),[2]}}))}))},n.prototype._destroy=function(t,e){return void 0===e&&(e=!1),o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:if(!(r=this.resourcesMap[t]))return[2];if(e)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[t],r.data={},r.complete=!1,r.instance=void 0,[2]}}))}))},n.prototype.registerResourceType=function(e,r){if(void 0===r&&(r=e),t.RESOURCE_TYPE[e])throw new Error("The type "+e+" already exists in RESOURCE_TYPE");t.RESOURCE_TYPE[e]=r},n.prototype.registerInstance=function(t,e){this.makeInstanceFunctions[t]=e},n.prototype.registerDestroy=function(t,e){this.destroyInstanceFunctions[t]=e},n.prototype.loadResource=function(t){var e=this,r=t.names,n=void 0===r?[]:r,o=t.preload,i=void 0!==o&&o,a=n.filter((function(t){return!e.promiseMap[t]&&e.resourcesMap[t]}));if(a.length){var c={},u=this.getLoader(i);a.forEach((function(t){var r,n;e.promiseMap[t]=new Promise((function(e){return c[t]=e}));var o=e.resourcesMap[t];try{for(var a=s(e.preProcessResourceHandlers),l=a.next();!l.done;l=a.next()){(0,l.value)(o)}}catch(t){r={error:t}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}for(var p in o.src){var h=o.src[p].type;"data"===h?(o.data[p]=o.src[p].data,e.doComplete(t,c[t],i)):u.add({url:o.src[p].url,name:o.name+"_"+p,strategy:ur[h],metadata:{key:p,name:o.name,resolves:c}})}})),u.load()}},n.prototype.doComplete=function(t,e,r){return void 0===r&&(r=!1),o(this,void 0,void 0,(function(){var n,o,s,a;return i(this,(function(i){switch(i.label){case 0:if(n=this.resourcesMap[t],o={name:t,resource:this.resourcesMap[t],success:!0},!this.checkAllLoaded(t))return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),s=n,[4,this.instance(t)];case 2:return s.instance=i.sent(),n.complete=!0,r&&this.progress.onProgress(o),e(n),[3,4];case 3:return a=i.sent(),console.error(a),n.complete=!1,r&&(o.errMsg=a.message,o.success=!1,this.progress.onProgress(o)),e({}),[3,4];case 4:return[2]}}))}))},n.prototype.checkAllLoaded=function(t){var e=this.resourcesMap[t];return Array.from(Object.keys(e.src)).every((function(t){return e.data[t]}))},n.prototype.getLoader=function(t){var e=this;void 0===t&&(t=!1);var r=this.loaders.find((function(t){return!t.loading}));return r||(r=new sr,this.loaders.push(r)),t&&r.onStart.once((function(){e.progress.onStart()})),r.onLoad.add((function(r,n){e.onLoad({preload:t,resource:n})})),r.onError.add((function(r,n,o){e.onError({errMsg:r,resource:o,preload:t})})),r.onComplete.once((function(){r.onLoad.detachAll(),r.onError.detachAll(),r.reset()})),r},n.prototype.onLoad=function(t){var e=t.preload,r=void 0!==e&&e,n=t.resource;return o(this,void 0,void 0,(function(){var t,e,o,s,a;return i(this,(function(i){return t=n.metadata,e=t.key,o=t.name,s=t.resolves,a=n.data,this.resourcesMap[o].data[e]=a,this.doComplete(o,s[o],r),[2]}))}))},n.prototype.onError=function(t){var e=t.errMsg,r=t.preload,n=void 0!==r&&r,s=t.resource;return o(this,void 0,void 0,(function(){var t,r,o,a;return i(this,(function(i){return t=s.metadata,r=t.name,o=t.resolves,this._destroy(r,!0),o[r]({}),n&&(a={name:r,resource:this.resourcesMap[r],success:!1,errMsg:e},this.progress.onProgress(a)),[2]}))}))},n}(u)),pr={IDEProp:Le,componentObserver:Me},hr="1.2.2";return console.log("Eva.js version: 1.2.2"),t.Component=p,t.Game=Ce,t.GameObject=Ee,t.IDEProp=Le,t.RESOURCE_TYPE_STRATEGY=ur,t.Scene=Pe,t.System=we,t.Transform=be,t.componentObserver=Me,t.decorators=pr,t.resource=lr,t.resourceLoader=cr,t.version=hr,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
@@ -1,16 +1,16 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var EventEmitter = require('eventemitter3');
6
- var lodashEs = require('lodash-es');
7
- var inspectorDecorator = require('@eva/inspector-decorator');
8
- var resourceLoader$1 = require('resource-loader');
9
-
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
11
-
12
- var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
13
-
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var EventEmitter = require('eventemitter3');
6
+ var lodashEs = require('lodash-es');
7
+ var inspectorDecorator = require('@eva/inspector-decorator');
8
+ var resourceLoader$1 = require('resource-loader');
9
+
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
11
+
12
+ var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
13
+
14
14
  /*! *****************************************************************************
15
15
  Copyright (c) Microsoft Corporation. All rights reserved.
16
16
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -116,8 +116,8 @@ function __spread() {
116
116
  for (var ar = [], i = 0; i < arguments.length; i++)
117
117
  ar = ar.concat(__read(arguments[i]));
118
118
  return ar;
119
- }
120
-
119
+ }
120
+
121
121
  function getComponentName(component) {
122
122
  if (component instanceof Component) {
123
123
  return component.name;
@@ -137,8 +137,8 @@ var Component = (function (_super) {
137
137
  }
138
138
  return Component;
139
139
  }(EventEmitter__default));
140
- var Component$1 = Component;
141
-
140
+ var Component$1 = Component;
141
+
142
142
  exports.OBSERVER_TYPE = void 0;
143
143
  (function (ObserverType) {
144
144
  ObserverType["ADD"] = "ADD";
@@ -172,8 +172,9 @@ function removeObjectCache(component) {
172
172
  }
173
173
  }
174
174
  function addObserver(_a) {
175
+ var _b, _c;
175
176
  var systemName = _a.systemName, componentName = _a.componentName, component = _a.component, prop = _a.prop, type = _a.type;
176
- systemInstance[systemName].componentObserver.add({
177
+ (_c = (_b = systemInstance[systemName]) === null || _b === void 0 ? void 0 : _b.componentObserver) === null || _c === void 0 ? void 0 : _c.add({
177
178
  component: component,
178
179
  prop: prop,
179
180
  type: type,
@@ -334,12 +335,13 @@ function observer(component, componentName) {
334
335
  }
335
336
  }
336
337
  function observerAdded(component, componentName) {
338
+ var _a, _b;
337
339
  if (componentName === void 0) { componentName = component.name; }
338
340
  for (var systemName in observerInfos) {
339
341
  var observerInfo = observerInfos[systemName] || {};
340
342
  var info = observerInfo[componentName];
341
343
  if (info) {
342
- systemInstance[systemName].componentObserver.add({
344
+ (_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
343
345
  component: component,
344
346
  type: exports.OBSERVER_TYPE.ADD,
345
347
  componentName: componentName,
@@ -348,12 +350,13 @@ function observerAdded(component, componentName) {
348
350
  }
349
351
  }
350
352
  function observerRemoved(component, componentName) {
353
+ var _a, _b;
351
354
  if (componentName === void 0) { componentName = component.name; }
352
355
  for (var systemName in observerInfos) {
353
356
  var observerInfo = observerInfos[systemName] || {};
354
357
  var info = observerInfo[componentName];
355
358
  if (info) {
356
- systemInstance[systemName].componentObserver.add({
359
+ (_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
357
360
  component: component,
358
361
  type: exports.OBSERVER_TYPE.REMOVE,
359
362
  componentName: componentName,
@@ -365,8 +368,8 @@ function observerRemoved(component, componentName) {
365
368
  function setSystemObserver(system, S) {
366
369
  observerInfos[S.systemName] = S.observerInfo;
367
370
  systemInstance[S.systemName] = system;
368
- }
369
-
371
+ }
372
+
370
373
  var Transform = (function (_super) {
371
374
  __extends(Transform, _super);
372
375
  function Transform() {
@@ -470,8 +473,8 @@ var Transform = (function (_super) {
470
473
  ], Transform.prototype, "rotation", void 0);
471
474
  return Transform;
472
475
  }(Component$1));
473
- var Transform$1 = Transform;
474
-
476
+ var Transform$1 = Transform;
477
+
475
478
  var _id = 0;
476
479
  function getId() {
477
480
  return ++_id;
@@ -640,6 +643,10 @@ var GameObject = (function () {
640
643
  return this.parent.removeChild(this);
641
644
  };
642
645
  GameObject.prototype.destroy = function () {
646
+ if (!this.transform) {
647
+ console.error('Cannot destroy gameObject that have already been destroyed.');
648
+ return;
649
+ }
643
650
  Array.from(this.transform.children).forEach(function (_a) {
644
651
  var gameObject = _a.gameObject;
645
652
  gameObject.destroy();
@@ -653,8 +660,8 @@ var GameObject = (function () {
653
660
  };
654
661
  return GameObject;
655
662
  }());
656
- var GameObject$1 = GameObject;
657
-
663
+ var GameObject$1 = GameObject;
664
+
658
665
  var ComponentObserver = (function () {
659
666
  function ComponentObserver() {
660
667
  this.events = [];
@@ -696,8 +703,8 @@ var ComponentObserver = (function () {
696
703
  };
697
704
  return ComponentObserver;
698
705
  }());
699
- var ComponentObserver$1 = ComponentObserver;
700
-
706
+ var ComponentObserver$1 = ComponentObserver;
707
+
701
708
  var System = (function () {
702
709
  function System(params) {
703
710
  this.started = false;
@@ -713,8 +720,8 @@ var System = (function () {
713
720
  };
714
721
  return System;
715
722
  }());
716
- var System$1 = System;
717
-
723
+ var System$1 = System;
724
+
718
725
  function createNowTime() {
719
726
  var nowtime = null;
720
727
  if (Date.now) {
@@ -724,8 +731,8 @@ function createNowTime() {
724
731
  nowtime = function () { return new Date().getTime(); };
725
732
  }
726
733
  return nowtime;
727
- }
728
-
734
+ }
735
+
729
736
  var _nowtime = createNowTime();
730
737
  var defaultOptions$1 = {
731
738
  originTime: 0,
@@ -891,8 +898,8 @@ var Timeline = (function () {
891
898
  });
892
899
  return Timeline;
893
900
  }());
894
- var Timeline$1 = Timeline;
895
-
901
+ var Timeline$1 = Timeline;
902
+
896
903
  var defaultOptions = {
897
904
  autoStart: true,
898
905
  frameRate: 60,
@@ -973,8 +980,8 @@ var Ticker = (function () {
973
980
  };
974
981
  return Ticker;
975
982
  }());
976
- var Ticker$1 = Ticker;
977
-
983
+ var Ticker$1 = Ticker;
984
+
978
985
  var Scene = (function (_super) {
979
986
  __extends(Scene, _super);
980
987
  function Scene(name, obj) {
@@ -1006,8 +1013,8 @@ var Scene = (function (_super) {
1006
1013
  };
1007
1014
  return Scene;
1008
1015
  }(GameObject$1));
1009
- var Scene$1 = Scene;
1010
-
1016
+ var Scene$1 = Scene;
1017
+
1011
1018
  exports.LOAD_SCENE_MODE = void 0;
1012
1019
  (function (LOAD_SCENE_MODE) {
1013
1020
  LOAD_SCENE_MODE["SINGLE"] = "SINGLE";
@@ -1454,15 +1461,15 @@ var Game = (function (_super) {
1454
1461
  };
1455
1462
  return Game;
1456
1463
  }(EventEmitter__default));
1457
- var Game$1 = Game;
1458
-
1464
+ var Game$1 = Game;
1465
+
1459
1466
  function IDEProp(target, propertyKey) {
1460
1467
  if (!target.constructor.IDEProps) {
1461
1468
  target.constructor.IDEProps = [];
1462
1469
  }
1463
1470
  target.constructor.IDEProps.push(propertyKey);
1464
- }
1465
-
1471
+ }
1472
+
1466
1473
  function componentObserver(observerInfo) {
1467
1474
  if (observerInfo === void 0) { observerInfo = {}; }
1468
1475
  return function (constructor) {
@@ -1489,8 +1496,8 @@ function componentObserver(observerInfo) {
1489
1496
  constructor.observerInfo = observerInfo;
1490
1497
  }
1491
1498
  };
1492
- }
1493
-
1499
+ }
1500
+
1494
1501
  var Progress = (function (_super) {
1495
1502
  __extends(Progress, _super);
1496
1503
  function Progress(_a) {
@@ -1525,8 +1532,8 @@ var Progress = (function (_super) {
1525
1532
  };
1526
1533
  return Progress;
1527
1534
  }(EventEmitter__default));
1528
- var Progress$1 = Progress;
1529
-
1535
+ var Progress$1 = Progress;
1536
+
1530
1537
  var resourceLoader = {
1531
1538
  AbstractLoadStrategy: resourceLoader$1.AbstractLoadStrategy,
1532
1539
  AudioLoadStrategy: resourceLoader$1.AudioLoadStrategy,
@@ -1539,8 +1546,8 @@ var resourceLoader = {
1539
1546
  Resource: resourceLoader$1.Resource,
1540
1547
  ResourceType: resourceLoader$1.ResourceType,
1541
1548
  ResourceState: resourceLoader$1.ResourceState
1542
- };
1543
-
1549
+ };
1550
+
1544
1551
  exports.LOAD_EVENT = void 0;
1545
1552
  (function (LOAD_EVENT) {
1546
1553
  LOAD_EVENT["START"] = "start";
@@ -1634,7 +1641,7 @@ var Resource = (function (_super) {
1634
1641
  var names = [];
1635
1642
  for (var key in this.resourcesMap) {
1636
1643
  var resource_1 = this.resourcesMap[key];
1637
- if (resource_1.preload && !resource_1.complete) {
1644
+ if (resource_1.preload && !resource_1.complete && !this.promiseMap[key]) {
1638
1645
  names.push(resource_1.name);
1639
1646
  }
1640
1647
  }
@@ -1888,25 +1895,25 @@ var Resource = (function (_super) {
1888
1895
  };
1889
1896
  return Resource;
1890
1897
  }(EventEmitter__default));
1891
- var resource = new Resource();
1892
-
1898
+ var resource = new Resource();
1899
+
1893
1900
  var decorators = {
1894
1901
  IDEProp: IDEProp,
1895
1902
  componentObserver: componentObserver,
1896
1903
  };
1897
- var version = '1.2.2-alpha.2';
1898
- console.log("Eva.js version: " + version);
1899
-
1900
- exports.Component = Component$1;
1901
- exports.Game = Game$1;
1902
- exports.GameObject = GameObject$1;
1903
- exports.IDEProp = IDEProp;
1904
- exports.RESOURCE_TYPE_STRATEGY = RESOURCE_TYPE_STRATEGY;
1905
- exports.Scene = Scene$1;
1906
- exports.System = System$1;
1907
- exports.Transform = Transform$1;
1908
- exports.componentObserver = componentObserver;
1909
- exports.decorators = decorators;
1910
- exports.resource = resource;
1911
- exports.resourceLoader = resourceLoader;
1912
- exports.version = version;
1904
+ var version = '1.2.2';
1905
+ console.log("Eva.js version: " + version);
1906
+
1907
+ exports.Component = Component$1;
1908
+ exports.Game = Game$1;
1909
+ exports.GameObject = GameObject$1;
1910
+ exports.IDEProp = IDEProp;
1911
+ exports.RESOURCE_TYPE_STRATEGY = RESOURCE_TYPE_STRATEGY;
1912
+ exports.Scene = Scene$1;
1913
+ exports.System = System$1;
1914
+ exports.Transform = Transform$1;
1915
+ exports.componentObserver = componentObserver;
1916
+ exports.decorators = decorators;
1917
+ exports.resource = resource;
1918
+ exports.resourceLoader = resourceLoader;
1919
+ exports.version = version;
@@ -12,4 +12,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
12
12
 
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
- ***************************************************************************** */function i(e,t){function r(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function c(e,t,r,o){var n,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(s=(a<3?n(s):a>3?n(t,r,s):n(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}function u(e,t,r,o){return new(r||(r=Promise))((function(n,a){function s(e){try{c(o.next(e))}catch(e){a(e)}}function i(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):new r((function(t){t(e.value)})).then(s,i)}c((o=o.apply(e,t||[])).next())}))}function p(e,t){var r,o,n,a,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[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,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function l(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 f(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,a=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=a.next()).done;)s.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return s}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}var y,m=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 i(t,e),t}(a),d=m;exports.OBSERVER_TYPE=void 0,(y=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",y.REMOVE="REMOVE",y.CHANGE="CHANGE";var v={},g={},b={},E={};function _(e,t){v[e.gameObject.id]||(v[e.gameObject.id]={});var r=v[e.gameObject.id],o=e.name+"_"+t.join(",");if(r[o])return r[o];for(var n=t.length-1,a=e,s=0;s<n;s++)a=a[t[s]];return r[o]={property:a,key:t[n]},r[o]}function O(e){var t=e.systemName,r=e.componentName,o=e.component,n=e.prop,a=e.type;g[t].componentObserver.add({component:o,prop:n,type:a,componentName:r})}function R(e){var r,o,n=e.obj,a=e.key,s=e.prop,i=e.component,c=e.componentName;if(void 0!==n)if(a in n){if(Object.defineProperty(n,"_"+a,{enumerable:!1,writable:!0,value:n[a]}),s.deep&&t.isObject(n[a]))try{for(var u=l(Object.keys(n[a])),p=u.next();!p.done;p=u.next()){var f=p.value;R({obj:n[a],key:f,prop:s,component:i,componentName:c})}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}Object.defineProperty(n,a,{enumerable:!0,set:function(e){n["_"+a]!==e&&(n["_"+a]=e,function(e){var r=e.prop,o=e.component,n=e.componentName;for(var a in b){var s=(b[a]||{})[n];s&&s.findIndex((function(e){return t.isEqual(e,r)}))>-1&&O({systemName:a,componentName:n,component:o,prop:r,type:exports.OBSERVER_TYPE.CHANGE})}}({prop:s,component:i,componentName:c}))},get:function(){return n["_"+a]}})}else console.error("prop "+a+" not in component: "+c+", Can not observer")}function x(e,t){for(var r in void 0===t&&(t=e.name),b){(b[r]||{})[t]&&g[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t})}!function(e){e.gameObject&&delete v[e.gameObject.id]}(e)}var T=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 i(t,e),t.prototype.init=function(e){var t,r;void 0===e&&(e={});try{for(var o=l(["position","size","origin","anchor","scale","skew"]),n=o.next();!n.done;n=o.next()){var a=n.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}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",c([r.type("vector2"),r.step(1)],t.prototype,"position",void 0),c([r.type("size"),r.step(1)],t.prototype,"size",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"origin",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"anchor",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"scale",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"skew",void 0),c([r.type("number"),r.step(.1)],t.prototype,"rotation",void 0),t}(d),S=0;var w=function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++S,this.addComponent(T,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(T)},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 o=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var n=l(this.transform.children),a=n.next();!a.done;a=n.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e?e.addGameObject(this):o&&o.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 m?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[r]){var o;if(e instanceof Function)o=new e(t);else{if(!(e instanceof d))throw new Error("addComponent recieve Component and Component Constructor");o=e}if(o.gameObject)throw new Error("component has been added on gameObject "+o.gameObject.name);return o.gameObject=this,o.init&&o.init(o.__componentDefaultParams),function(e,t){for(var r in void 0===t&&(t=e.name),b)(b[r]||{})[t]&&g[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t})}(o,o.name),function(e,t){var r,o;if(void 0===t&&(t=e.name),t&&E[t]){if(!(e&&(n=e,n&&n.constructor&&"componentName"in n.constructor)))throw new Error("component param must be an instance of Component");var n;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=l(E[t]),s=a.next();!s.done;s=a.next()){var i=s.value,c=_(e,i.prop);R({obj:c.property,key:c.key,prop:i,component:e,componentName:t})}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}(o,o.name),this.components.push(o),this._componentCache[r]=o,o.awake&&o.awake(),o}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof d?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],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),x(r,e),r.gameObject=void 0,r}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof d?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}(),k=function(){function e(){this.events=[]}return e.prototype.add=function(e){var r=e.component,o=e.prop,n=e.type,a=e.componentName;if(n===exports.OBSERVER_TYPE.REMOVE){if(this.events.find((function(e){return e.component===r&&e.type===exports.OBSERVER_TYPE.ADD})))return;this.events=this.events.filter((function(e){return e.component!==r}))}var s=this.events.findIndex((function(e){return e.component===r&&t.isEqual(e.prop,o)&&e.type===n}));s>-1&&this.events.splice(s,1),this.events.push({gameObject:r.gameObject,component:r,prop:o,type:n,componentName:a})},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}(),P=function(){function e(e){this.started=!1,this.componentObserver=new k,this.__systemDefaultParams=e,this.name=this.constructor.systemName}return e.prototype.destroy=function(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)},e}();var j,L=Date.now?Date.now:function(){return(new Date).getTime()},C={originTime:0,playbackRate:1},M=function(){function e(t,r){t instanceof e&&(r=t,t={}),t=Object.assign({},C,t),r&&(this._parent=r),this._createTime=L(),this._timeMark=[{globalTime:this.globalTime,localTime:-t.originTime,entropy:-t.originTime,playbackRate:t.playbackRate,globalEntropy:0}],this._parent&&(this._timeMark[0].globalEntropy=this._parent.entropy),this._playbackRate=t.playbackRate}return Object.defineProperty(e.prototype,"globalTime",{get:function(){return this.parent?this.parent.currentTime:L()-this._createTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastTimeMark",{get:function(){return this._timeMark[this._timeMark.length-1]},enumerable:!1,configurable:!0}),e.prototype.markTime=function(e){var t=void 0===e?{}:e,r=t.time,o=void 0===r?this.currentTime:r,n=t.entropy,a=void 0===n?this.entropy:n,s=t.playbackRate,i=void 0===s?this.playbackRate:s,c={globalTime:this.globalTime,localTime:o,entropy:a,playbackRate:i,globalEntropy:this.globalEntropy};this._timeMark.push(c)},Object.defineProperty(e.prototype,"currentTime",{get:function(){var e=this.lastTimeMark,t=e.localTime,r=e.globalTime;return t+(this.globalTime-r)*this.playbackRate},set:function(e){this.markTime({time:e})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalEntropy",{get:function(){return this._parent?this._parent.entropy:this.globalTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"entropy",{get:function(){var e=this.lastTimeMark,t=e.entropy,r=e.globalEntropy;return t+Math.abs((this.globalEntropy-r)*this.playbackRate)},set:function(e){if(this.entropy>e){var t=this.seekTimeMark(e);this._timeMark.length=t+1}this.markTime({entropy:e})},enumerable:!1,configurable:!0}),e.prototype.fork=function(t){return new e(t,this)},e.prototype.seekGlobalTime=function(e){var t=this.seekTimeMark(e),r=this._timeMark[t],o=r.entropy,n=r.playbackRate;return r.globalTime+(e-o)/Math.abs(n)},e.prototype.seekLocalTime=function(e){var t=this.seekTimeMark(e),r=this._timeMark[t],o=r.localTime,n=r.entropy;return r.playbackRate>0?o+(e-n):o-(e-n)},e.prototype.seekTimeMark=function(e){var t=this._timeMark,r=0,o=t.length-1;if(e<=t[r].entropy)return r;if(e>=t[o].entropy)return o;for(var n=Math.floor((r+o)/2);n>r&&n<o;){if(e===t[n].entropy)return n;e<t[n].entropy?o=n:e>t[n].entropy&&(r=n),n=Math.floor((r+o)/2)}return r},Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this._playbackRate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){if(0===this.playbackRate)return!0;for(var e=this.parent;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1},enumerable:!1,configurable:!0}),e}(),N={autoStart:!0,frameRate:60},A=function(){function e(e){var t=this;e=Object.assign({},N,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new M({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start()}return e.prototype.update=function(){var e,t,r=this.timeline.currentTime,o=r-this._lastFrameTime;if(o>=this._frameDuration){var n=r-o%this._frameDuration,a=n-this._lastFrameTime;this._lastFrameTime=n;var s={deltaTime:a,time:n,currentTime:n,frameCount:++this._frameCount,fps:Math.round(1e3/a)};try{for(var i=l(this._tickers),c=i.next();!c.done;c=i.next()){var u=c.value;"function"==typeof u&&u(s)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}}},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._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this.timeline.playbackRate=0},e.prototype.setPlaybackRate=function(e){this.timeline.playbackRate=e},e}(),I=function(e){function t(t,r){var o=e.call(this,t,r)||this;return o.gameObjects=[],o.scene=o,o}return i(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}(w);exports.LOAD_SCENE_MODE=void 0,(j=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",j.MULTI_CANVAS="MULTI_CANVAS";var D=function(e){if((e instanceof P||e instanceof d)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof d?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}}},V=function(e){function r(t){var r,o,n=void 0===t?{}:t,a=n.systems,s=n.frameRate,i=void 0===s?60:s,c=n.autoStart,u=void 0===c||c,p=n.needScene,f=void 0===p||p,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=h),h.ticker=new A({autoStart:!1,frameRate:i}),h.initTicker(),a&&a.length)try{for(var y=l(a),m=y.next();!m.done;m=y.next()){var d=m.value;h.addSystem(d)}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}return f&&h.loadScene(new I("scene")),u&&h.start(),h}return i(r,e),Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"gameObjects",{get:function(){return function(e){var t,r,o,n=(null===(o=null==e?void 0:e.scene)||void 0===o?void 0:o.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),s=[];try{for(var i=l(a),c=i.next();!c.done;c=i.next())s=h(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 h(n,s)}(this)},enumerable:!1,configurable:!0}),r.prototype.addSystem=function(e,r){var o;if(e instanceof Function)o=new e(r);else{if(!(e instanceof P))return void console.warn("can only add System");o=e}if(!this.systems.find((function(e){return e.constructor===o.constructor}))){o.game=this,o.init&&o.init(o.__systemDefaultParams),function(e,t){b[t.systemName]=t.observerInfo,g[t.systemName]=e}(o,o.constructor),function(e){var r,o,n,a,s=[];e instanceof Array?s.push.apply(s,h(e)):s.push(e);try{for(var i=l(s),c=i.next();!c.done;c=i.next()){var u=c.value;for(var p in u.observerInfo){E[p]=E[p]||[];var f=E[p],y=function(e){-1===f.findIndex((function(r){return t.isEqual(r,e)}))&&E[p].push(e)};try{for(var m=(n=void 0,l(u.observerInfo[p])),d=m.next();!d.done;d=m.next())y(d.value)}catch(e){n={error:e}}finally{try{d&&!d.done&&(a=m.return)&&a.call(m)}finally{if(n)throw n.error}}}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}(o.constructor);try{o.awake&&o.awake()}catch(e){console.error(o.constructor.systemName+" awake error",e)}return this.systems.push(o),o}console.warn(o.constructor.systemName+" System has been added")},r.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 P&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},r.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},r.prototype.pause=function(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},r.prototype.start=function(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())},r.prototype.resume=function(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())},r.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var r,o,n,a;e.scene&&function(e,t){var r,o,n,a,s,i,c,u;void 0===t&&(t=[]);try{for(var p=l(t),f=p.next();!f.done;f=p.next()){var h=f.value;try{for(var y=(n=void 0,l(h.components)),m=y.next();!m.done;m=y.next()){var d=m.value;try{D(d),d.update&&d.update(e)}catch(e){console.error("gameObject: "+h.name+" "+d.name+" update error",e)}}}catch(e){n={error:e}}finally{try{m&&!m.done&&(a=y.return)&&a.call(y)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}try{for(var v=l(t),g=v.next();!g.done;g=v.next()){h=g.value;try{for(var b=(c=void 0,l(h.components)),E=b.next();!E.done;E=b.next()){d=E.value;try{d.lateUpdate&&d.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+d.name+" lateUpdate error",e)}}}catch(e){c={error:e}}finally{try{E&&!E.done&&(u=b.return)&&u.call(b)}finally{if(c)throw c.error}}}}catch(e){s={error:e}}finally{try{g&&!g.done&&(i=v.return)&&i.call(v)}finally{if(s)throw s.error}}}(t,e.gameObjects);try{for(var s=l(e.systems),i=s.next();!i.done;i=s.next()){var c=i.value;try{D(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&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}try{for(var u=l(e.systems),p=u.next();!p.done;p=u.next()){c=p.value;try{c.lateUpdate&&c.lateUpdate(t)}catch(t){console.error(c.constructor.systemName+" lateUpdate error",t)}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}}))},r.prototype.triggerResume=function(){var e,t;!function(e){var t,r,o,n;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(o=void 0,l(i.components)),u=c.next();!u.done;u=c.next()){var p=u.value;try{p.onResume&&p.onResume()}catch(e){console.error("gameObject: "+i.name+", "+p.name+", onResume error",e)}}}catch(e){o={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(o)throw o.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=l(this.systems),o=r.next();!o.done;o=r.next()){var n=o.value;try{n.onResume&&n.onResume()}catch(e){console.error(n.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},r.prototype.triggerPause=function(){var e,t;!function(e){var t,r,o,n;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(o=void 0,l(i.components)),u=c.next();!u.done;u=c.next()){var p=u.value;try{p.onPause&&p.onPause()}catch(e){console.error("gameObject: "+i.name+", "+p.name+", onResume error",e)}}}catch(e){o={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(o)throw o.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=l(this.systems),o=r.next();!o.done;o=r.next()){var n=o.value;try{n.onPause&&n.onPause()}catch(e){console.error(n.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},r.prototype.destroySystems=function(){var e,t;try{for(var r=l(h(this.systems)),o=r.next();!o.done;o=r.next()){var n=o.value;this.removeSystem(n)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}this.systems.length=0},r.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},r.prototype.loadScene=function(e){var t=e.scene,r=e.mode,o=void 0===r?exports.LOAD_SCENE_MODE.SINGLE:r,n=e.params,a=void 0===n?{}:n;if(t){switch(o){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:o,params:a})}},r}(a);function X(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function G(e){return void 0===e&&(e={}),function(t){if(!t.observerInfo){for(var r in e)for(var o in e[r]){"string"==typeof e[r][o]&&(e[r][o]=[e[r][o]]);var n=void 0;Array.isArray(e[r][o])&&(n={prop:e[r][o],deep:!1},e[r][o]=n),"string"==typeof(n=e[r][o]).prop&&(n.prop=[n.prop])}t.observerInfo=e}}}var F,U,Y=function(e){function t(t){var r=t.resource,o=t.resourceTotal,n=e.call(this)||this;return n.progress=0,n.resourceTotal=0,n.resourceLoadedCount=0,n.resource=r,n.resourceTotal=o,0===o&&n.resource.emit(exports.LOAD_EVENT.COMPLETE,n),n}return i(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}(a),q={AbstractLoadStrategy:o.AbstractLoadStrategy,AudioLoadStrategy:o.AudioLoadStrategy,ImageLoadStrategy:o.ImageLoadStrategy,XhrResponseType:o.XhrResponseType,MediaElementLoadStrategy:o.MediaElementLoadStrategy,VideoLoadStrategy:o.VideoLoadStrategy,XhrLoadStrategy:o.XhrLoadStrategy,Loader:o.Loader,Resource:o.Resource,ResourceType:o.ResourceType,ResourceState:o.ResourceState};exports.LOAD_EVENT=void 0,(F=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",F.PROGRESS="progress",F.LOADED="loaded",F.COMPLETE="complete",F.ERROR="error",exports.RESOURCE_TYPE=void 0,(U=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",U.SPRITE="SPRITE",U.SPRITE_ANIMATION="SPRITE_ANIMATION",U.AUDIO="AUDIO",U.VIDEO="VIDEO",o.XhrLoadStrategy.setExtensionXhrType("json",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("tex",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("ske",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("mp3",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("wav",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("aac",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("ogg",o.XhrResponseType.Buffer);var B={png:o.ImageLoadStrategy,jpg:o.ImageLoadStrategy,jpeg:o.ImageLoadStrategy,webp:o.ImageLoadStrategy,json:o.XhrLoadStrategy,tex:o.XhrLoadStrategy,ske:o.XhrLoadStrategy,audio:o.XhrLoadStrategy,video:o.VideoLoadStrategy},H=new(function(e){function t(t){var r=e.call(this)||this;return r.timeout=6e3,r.preProcessResourceHandlers=[],r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return i(t,e),t.prototype.loadConfig=function(e){this.addResource(e),this.preload()},t.prototype.loadSingle=function(e){return this.addResource([e]),this.getResource(e.name)},t.prototype.addResource=function(e){var t,r;if(!e||e.length<1)console.warn("no resources");else try{for(var o=l(e),n=o.next();!n.done;n=o.next()){var a=n.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{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},t.prototype.addPreProcessResourceHandler=function(e){this.preProcessResourceHandlers.push(e)},t.prototype.removePreProcessResourceHandler=function(e){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(e),1)},t.prototype.preload=function(){var e=[];for(var t in this.resourcesMap){var r=this.resourcesMap[t];r.preload&&!r.complete&&e.push(r.name)}this.progress=new Y({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})},t.prototype.getResource=function(e){return u(this,void 0,void 0,(function(){return p(this,(function(t){return this.loadResource({names:[e]}),[2,this.promiseMap[e]||Promise.resolve({})]}))}))},t.prototype.instance=function(e){return u(this,void 0,void 0,(function(){var t,r;return p(this,(function(o){switch(o.label){case 0:return t=this.resourcesMap[e],(r=this.makeInstanceFunctions[t.type])?[4,this.makeInstanceFunctions[t.type](t)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return[2,r]}}))}))},t.prototype.destroy=function(e){return u(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._destroy(e)];case 1:return t.sent(),[2]}}))}))},t.prototype._destroy=function(e,t){return void 0===t&&(t=!1),u(this,void 0,void 0,(function(){var r,o;return p(this,(function(n){switch(n.label){case 0:if(!(r=this.resourcesMap[e]))return[2];if(t)return[3,5];n.label=1;case 1:return n.trys.push([1,4,,5]),this.destroyInstanceFunctions[r.type]?[4,this.destroyInstanceFunctions[r.type](r)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:return o=n.sent(),console.warn("destroy resource "+r.name+" error with '"+o.message+"'"),[3,5];case 5:return delete this.promiseMap[e],r.data={},r.complete=!1,r.instance=void 0,[2]}}))}))},t.prototype.registerResourceType=function(e,t){if(void 0===t&&(t=e),exports.RESOURCE_TYPE[e])throw new Error("The type "+e+" already exists in RESOURCE_TYPE");exports.RESOURCE_TYPE[e]=t},t.prototype.registerInstance=function(e,t){this.makeInstanceFunctions[e]=t},t.prototype.registerDestroy=function(e,t){this.destroyInstanceFunctions[e]=t},t.prototype.loadResource=function(e){var t=this,r=e.names,o=void 0===r?[]:r,n=e.preload,a=void 0!==n&&n,s=o.filter((function(e){return!t.promiseMap[e]&&t.resourcesMap[e]}));if(s.length){var i={},c=this.getLoader(a);s.forEach((function(e){var r,o;t.promiseMap[e]=new Promise((function(t){return i[e]=t}));var n=t.resourcesMap[e];try{for(var s=l(t.preProcessResourceHandlers),u=s.next();!u.done;u=s.next()){(0,u.value)(n)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}for(var p in n.src){var f=n.src[p].type;"data"===f?(n.data[p]=n.src[p].data,t.doComplete(e,i[e],a)):c.add({url:n.src[p].url,name:n.name+"_"+p,strategy:B[f],metadata:{key:p,name:n.name,resolves:i}})}})),c.load()}},t.prototype.doComplete=function(e,t,r){return void 0===r&&(r=!1),u(this,void 0,void 0,(function(){var o,n,a,s;return p(this,(function(i){switch(i.label){case 0:if(o=this.resourcesMap[e],n={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=o,[4,this.instance(e)];case 2:return a.instance=i.sent(),o.complete=!0,r&&this.progress.onProgress(n),t(o),[3,4];case 3:return s=i.sent(),console.error(s),o.complete=!1,r&&(n.errMsg=s.message,n.success=!1,this.progress.onProgress(n)),t({}),[3,4];case 4:return[2]}}))}))},t.prototype.checkAllLoaded=function(e){var t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((function(e){return t.data[e]}))},t.prototype.getLoader=function(e){var t=this;void 0===e&&(e=!1);var r=this.loaders.find((function(e){return!e.loading}));return r||(r=new o.Loader,this.loaders.push(r)),e&&r.onStart.once((function(){t.progress.onStart()})),r.onLoad.add((function(r,o){t.onLoad({preload:e,resource:o})})),r.onError.add((function(r,o,n){t.onError({errMsg:r,resource:n,preload:e})})),r.onComplete.once((function(){r.onLoad.detachAll(),r.onError.detachAll(),r.reset()})),r},t.prototype.onLoad=function(e){var t=e.preload,r=void 0!==t&&t,o=e.resource;return u(this,void 0,void 0,(function(){var e,t,n,a,s;return p(this,(function(i){return e=o.metadata,t=e.key,n=e.name,a=e.resolves,s=o.data,this.resourcesMap[n].data[t]=s,this.doComplete(n,a[n],r),[2]}))}))},t.prototype.onError=function(e){var t=e.errMsg,r=e.preload,o=void 0!==r&&r,n=e.resource;return u(this,void 0,void 0,(function(){var e,r,a,s;return p(this,(function(i){return e=n.metadata,r=e.name,a=e.resolves,this._destroy(r,!0),a[r]({}),o&&(s={name:r,resource:this.resourcesMap[r],success:!1,errMsg:t},this.progress.onProgress(s)),[2]}))}))},t}(a)),z={IDEProp:X,componentObserver:G};console.log("Eva.js version: 1.2.2-alpha.2"),exports.Component=d,exports.Game=V,exports.GameObject=w,exports.IDEProp=X,exports.RESOURCE_TYPE_STRATEGY=B,exports.Scene=I,exports.System=P,exports.Transform=T,exports.componentObserver=G,exports.decorators=z,exports.resource=H,exports.resourceLoader=q,exports.version="1.2.2-alpha.2";
15
+ ***************************************************************************** */function i(e,t){function r(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function c(e,t,r,o){var n,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(s=(a<3?n(s):a>3?n(t,r,s):n(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}function u(e,t,r,o){return new(r||(r=Promise))((function(n,a){function s(e){try{c(o.next(e))}catch(e){a(e)}}function i(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):new r((function(t){t(e.value)})).then(s,i)}c((o=o.apply(e,t||[])).next())}))}function p(e,t){var r,o,n,a,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[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,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function l(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 f(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,a=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=a.next()).done;)s.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return s}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}var y,m=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 i(t,e),t}(a),d=m;exports.OBSERVER_TYPE=void 0,(y=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",y.REMOVE="REMOVE",y.CHANGE="CHANGE";var v={},g={},b={},E={};function _(e,t){v[e.gameObject.id]||(v[e.gameObject.id]={});var r=v[e.gameObject.id],o=e.name+"_"+t.join(",");if(r[o])return r[o];for(var n=t.length-1,a=e,s=0;s<n;s++)a=a[t[s]];return r[o]={property:a,key:t[n]},r[o]}function O(e){var t,r,o=e.systemName,n=e.componentName,a=e.component,s=e.prop,i=e.type;null===(r=null===(t=g[o])||void 0===t?void 0:t.componentObserver)||void 0===r||r.add({component:a,prop:s,type:i,componentName:n})}function R(e){var r,o,n=e.obj,a=e.key,s=e.prop,i=e.component,c=e.componentName;if(void 0!==n)if(a in n){if(Object.defineProperty(n,"_"+a,{enumerable:!1,writable:!0,value:n[a]}),s.deep&&t.isObject(n[a]))try{for(var u=l(Object.keys(n[a])),p=u.next();!p.done;p=u.next()){var f=p.value;R({obj:n[a],key:f,prop:s,component:i,componentName:c})}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}Object.defineProperty(n,a,{enumerable:!0,set:function(e){n["_"+a]!==e&&(n["_"+a]=e,function(e){var r=e.prop,o=e.component,n=e.componentName;for(var a in b){var s=(b[a]||{})[n];s&&s.findIndex((function(e){return t.isEqual(e,r)}))>-1&&O({systemName:a,componentName:n,component:o,prop:r,type:exports.OBSERVER_TYPE.CHANGE})}}({prop:s,component:i,componentName:c}))},get:function(){return n["_"+a]}})}else console.error("prop "+a+" not in component: "+c+", Can not observer")}function x(e,t){var r,o;for(var n in void 0===t&&(t=e.name),b){(b[n]||{})[t]&&(null===(o=null===(r=g[n])||void 0===r?void 0:r.componentObserver)||void 0===o||o.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t}))}!function(e){e.gameObject&&delete v[e.gameObject.id]}(e)}var T=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 i(t,e),t.prototype.init=function(e){var t,r;void 0===e&&(e={});try{for(var o=l(["position","size","origin","anchor","scale","skew"]),n=o.next();!n.done;n=o.next()){var a=n.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}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",c([r.type("vector2"),r.step(1)],t.prototype,"position",void 0),c([r.type("size"),r.step(1)],t.prototype,"size",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"origin",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"anchor",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"scale",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"skew",void 0),c([r.type("number"),r.step(.1)],t.prototype,"rotation",void 0),t}(d),S=0;var w=function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++S,this.addComponent(T,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(T)},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 o=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var n=l(this.transform.children),a=n.next();!a.done;a=n.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e?e.addGameObject(this):o&&o.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 m?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[r]){var o;if(e instanceof Function)o=new e(t);else{if(!(e instanceof d))throw new Error("addComponent recieve Component and Component Constructor");o=e}if(o.gameObject)throw new Error("component has been added on gameObject "+o.gameObject.name);return o.gameObject=this,o.init&&o.init(o.__componentDefaultParams),function(e,t){var r,o;for(var n in void 0===t&&(t=e.name),b)(b[n]||{})[t]&&(null===(o=null===(r=g[n])||void 0===r?void 0:r.componentObserver)||void 0===o||o.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t}))}(o,o.name),function(e,t){var r,o;if(void 0===t&&(t=e.name),t&&E[t]){if(!(e&&(n=e,n&&n.constructor&&"componentName"in n.constructor)))throw new Error("component param must be an instance of Component");var n;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=l(E[t]),s=a.next();!s.done;s=a.next()){var i=s.value,c=_(e,i.prop);R({obj:c.property,key:c.key,prop:i,component:e,componentName:t})}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}(o,o.name),this.components.push(o),this._componentCache[r]=o,o.awake&&o.awake(),o}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof d?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],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),x(r,e),r.gameObject=void 0,r}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof d?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(){if(this.transform){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}else console.error("Cannot destroy gameObject that have already been destroyed.")},e}(),k=function(){function e(){this.events=[]}return e.prototype.add=function(e){var r=e.component,o=e.prop,n=e.type,a=e.componentName;if(n===exports.OBSERVER_TYPE.REMOVE){if(this.events.find((function(e){return e.component===r&&e.type===exports.OBSERVER_TYPE.ADD})))return;this.events=this.events.filter((function(e){return e.component!==r}))}var s=this.events.findIndex((function(e){return e.component===r&&t.isEqual(e.prop,o)&&e.type===n}));s>-1&&this.events.splice(s,1),this.events.push({gameObject:r.gameObject,component:r,prop:o,type:n,componentName:a})},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}(),P=function(){function e(e){this.started=!1,this.componentObserver=new k,this.__systemDefaultParams=e,this.name=this.constructor.systemName}return e.prototype.destroy=function(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)},e}();var j,L=Date.now?Date.now:function(){return(new Date).getTime()},C={originTime:0,playbackRate:1},M=function(){function e(t,r){t instanceof e&&(r=t,t={}),t=Object.assign({},C,t),r&&(this._parent=r),this._createTime=L(),this._timeMark=[{globalTime:this.globalTime,localTime:-t.originTime,entropy:-t.originTime,playbackRate:t.playbackRate,globalEntropy:0}],this._parent&&(this._timeMark[0].globalEntropy=this._parent.entropy),this._playbackRate=t.playbackRate}return Object.defineProperty(e.prototype,"globalTime",{get:function(){return this.parent?this.parent.currentTime:L()-this._createTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastTimeMark",{get:function(){return this._timeMark[this._timeMark.length-1]},enumerable:!1,configurable:!0}),e.prototype.markTime=function(e){var t=void 0===e?{}:e,r=t.time,o=void 0===r?this.currentTime:r,n=t.entropy,a=void 0===n?this.entropy:n,s=t.playbackRate,i=void 0===s?this.playbackRate:s,c={globalTime:this.globalTime,localTime:o,entropy:a,playbackRate:i,globalEntropy:this.globalEntropy};this._timeMark.push(c)},Object.defineProperty(e.prototype,"currentTime",{get:function(){var e=this.lastTimeMark,t=e.localTime,r=e.globalTime;return t+(this.globalTime-r)*this.playbackRate},set:function(e){this.markTime({time:e})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalEntropy",{get:function(){return this._parent?this._parent.entropy:this.globalTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"entropy",{get:function(){var e=this.lastTimeMark,t=e.entropy,r=e.globalEntropy;return t+Math.abs((this.globalEntropy-r)*this.playbackRate)},set:function(e){if(this.entropy>e){var t=this.seekTimeMark(e);this._timeMark.length=t+1}this.markTime({entropy:e})},enumerable:!1,configurable:!0}),e.prototype.fork=function(t){return new e(t,this)},e.prototype.seekGlobalTime=function(e){var t=this.seekTimeMark(e),r=this._timeMark[t],o=r.entropy,n=r.playbackRate;return r.globalTime+(e-o)/Math.abs(n)},e.prototype.seekLocalTime=function(e){var t=this.seekTimeMark(e),r=this._timeMark[t],o=r.localTime,n=r.entropy;return r.playbackRate>0?o+(e-n):o-(e-n)},e.prototype.seekTimeMark=function(e){var t=this._timeMark,r=0,o=t.length-1;if(e<=t[r].entropy)return r;if(e>=t[o].entropy)return o;for(var n=Math.floor((r+o)/2);n>r&&n<o;){if(e===t[n].entropy)return n;e<t[n].entropy?o=n:e>t[n].entropy&&(r=n),n=Math.floor((r+o)/2)}return r},Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this._playbackRate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){if(0===this.playbackRate)return!0;for(var e=this.parent;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1},enumerable:!1,configurable:!0}),e}(),N={autoStart:!0,frameRate:60},A=function(){function e(e){var t=this;e=Object.assign({},N,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new M({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start()}return e.prototype.update=function(){var e,t,r=this.timeline.currentTime,o=r-this._lastFrameTime;if(o>=this._frameDuration){var n=r-o%this._frameDuration,a=n-this._lastFrameTime;this._lastFrameTime=n;var s={deltaTime:a,time:n,currentTime:n,frameCount:++this._frameCount,fps:Math.round(1e3/a)};try{for(var i=l(this._tickers),c=i.next();!c.done;c=i.next()){var u=c.value;"function"==typeof u&&u(s)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}}},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._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this.timeline.playbackRate=0},e.prototype.setPlaybackRate=function(e){this.timeline.playbackRate=e},e}(),I=function(e){function t(t,r){var o=e.call(this,t,r)||this;return o.gameObjects=[],o.scene=o,o}return i(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}(w);exports.LOAD_SCENE_MODE=void 0,(j=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",j.MULTI_CANVAS="MULTI_CANVAS";var D=function(e){if((e instanceof P||e instanceof d)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof d?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}}},V=function(e){function r(t){var r,o,n=void 0===t?{}:t,a=n.systems,s=n.frameRate,i=void 0===s?60:s,c=n.autoStart,u=void 0===c||c,p=n.needScene,f=void 0===p||p,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=h),h.ticker=new A({autoStart:!1,frameRate:i}),h.initTicker(),a&&a.length)try{for(var y=l(a),m=y.next();!m.done;m=y.next()){var d=m.value;h.addSystem(d)}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}return f&&h.loadScene(new I("scene")),u&&h.start(),h}return i(r,e),Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"gameObjects",{get:function(){return function(e){var t,r,o,n=(null===(o=null==e?void 0:e.scene)||void 0===o?void 0:o.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),s=[];try{for(var i=l(a),c=i.next();!c.done;c=i.next())s=h(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 h(n,s)}(this)},enumerable:!1,configurable:!0}),r.prototype.addSystem=function(e,r){var o;if(e instanceof Function)o=new e(r);else{if(!(e instanceof P))return void console.warn("can only add System");o=e}if(!this.systems.find((function(e){return e.constructor===o.constructor}))){o.game=this,o.init&&o.init(o.__systemDefaultParams),function(e,t){b[t.systemName]=t.observerInfo,g[t.systemName]=e}(o,o.constructor),function(e){var r,o,n,a,s=[];e instanceof Array?s.push.apply(s,h(e)):s.push(e);try{for(var i=l(s),c=i.next();!c.done;c=i.next()){var u=c.value;for(var p in u.observerInfo){E[p]=E[p]||[];var f=E[p],y=function(e){-1===f.findIndex((function(r){return t.isEqual(r,e)}))&&E[p].push(e)};try{for(var m=(n=void 0,l(u.observerInfo[p])),d=m.next();!d.done;d=m.next())y(d.value)}catch(e){n={error:e}}finally{try{d&&!d.done&&(a=m.return)&&a.call(m)}finally{if(n)throw n.error}}}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}(o.constructor);try{o.awake&&o.awake()}catch(e){console.error(o.constructor.systemName+" awake error",e)}return this.systems.push(o),o}console.warn(o.constructor.systemName+" System has been added")},r.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 P&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},r.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},r.prototype.pause=function(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},r.prototype.start=function(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())},r.prototype.resume=function(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())},r.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var r,o,n,a;e.scene&&function(e,t){var r,o,n,a,s,i,c,u;void 0===t&&(t=[]);try{for(var p=l(t),f=p.next();!f.done;f=p.next()){var h=f.value;try{for(var y=(n=void 0,l(h.components)),m=y.next();!m.done;m=y.next()){var d=m.value;try{D(d),d.update&&d.update(e)}catch(e){console.error("gameObject: "+h.name+" "+d.name+" update error",e)}}}catch(e){n={error:e}}finally{try{m&&!m.done&&(a=y.return)&&a.call(y)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}try{for(var v=l(t),g=v.next();!g.done;g=v.next()){h=g.value;try{for(var b=(c=void 0,l(h.components)),E=b.next();!E.done;E=b.next()){d=E.value;try{d.lateUpdate&&d.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+d.name+" lateUpdate error",e)}}}catch(e){c={error:e}}finally{try{E&&!E.done&&(u=b.return)&&u.call(b)}finally{if(c)throw c.error}}}}catch(e){s={error:e}}finally{try{g&&!g.done&&(i=v.return)&&i.call(v)}finally{if(s)throw s.error}}}(t,e.gameObjects);try{for(var s=l(e.systems),i=s.next();!i.done;i=s.next()){var c=i.value;try{D(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&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}try{for(var u=l(e.systems),p=u.next();!p.done;p=u.next()){c=p.value;try{c.lateUpdate&&c.lateUpdate(t)}catch(t){console.error(c.constructor.systemName+" lateUpdate error",t)}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}}))},r.prototype.triggerResume=function(){var e,t;!function(e){var t,r,o,n;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(o=void 0,l(i.components)),u=c.next();!u.done;u=c.next()){var p=u.value;try{p.onResume&&p.onResume()}catch(e){console.error("gameObject: "+i.name+", "+p.name+", onResume error",e)}}}catch(e){o={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(o)throw o.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=l(this.systems),o=r.next();!o.done;o=r.next()){var n=o.value;try{n.onResume&&n.onResume()}catch(e){console.error(n.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},r.prototype.triggerPause=function(){var e,t;!function(e){var t,r,o,n;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(o=void 0,l(i.components)),u=c.next();!u.done;u=c.next()){var p=u.value;try{p.onPause&&p.onPause()}catch(e){console.error("gameObject: "+i.name+", "+p.name+", onResume error",e)}}}catch(e){o={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(o)throw o.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=l(this.systems),o=r.next();!o.done;o=r.next()){var n=o.value;try{n.onPause&&n.onPause()}catch(e){console.error(n.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},r.prototype.destroySystems=function(){var e,t;try{for(var r=l(h(this.systems)),o=r.next();!o.done;o=r.next()){var n=o.value;this.removeSystem(n)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}this.systems.length=0},r.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},r.prototype.loadScene=function(e){var t=e.scene,r=e.mode,o=void 0===r?exports.LOAD_SCENE_MODE.SINGLE:r,n=e.params,a=void 0===n?{}:n;if(t){switch(o){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:o,params:a})}},r}(a);function X(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function G(e){return void 0===e&&(e={}),function(t){if(!t.observerInfo){for(var r in e)for(var o in e[r]){"string"==typeof e[r][o]&&(e[r][o]=[e[r][o]]);var n=void 0;Array.isArray(e[r][o])&&(n={prop:e[r][o],deep:!1},e[r][o]=n),"string"==typeof(n=e[r][o]).prop&&(n.prop=[n.prop])}t.observerInfo=e}}}var F,U,Y=function(e){function t(t){var r=t.resource,o=t.resourceTotal,n=e.call(this)||this;return n.progress=0,n.resourceTotal=0,n.resourceLoadedCount=0,n.resource=r,n.resourceTotal=o,0===o&&n.resource.emit(exports.LOAD_EVENT.COMPLETE,n),n}return i(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}(a),q={AbstractLoadStrategy:o.AbstractLoadStrategy,AudioLoadStrategy:o.AudioLoadStrategy,ImageLoadStrategy:o.ImageLoadStrategy,XhrResponseType:o.XhrResponseType,MediaElementLoadStrategy:o.MediaElementLoadStrategy,VideoLoadStrategy:o.VideoLoadStrategy,XhrLoadStrategy:o.XhrLoadStrategy,Loader:o.Loader,Resource:o.Resource,ResourceType:o.ResourceType,ResourceState:o.ResourceState};exports.LOAD_EVENT=void 0,(F=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",F.PROGRESS="progress",F.LOADED="loaded",F.COMPLETE="complete",F.ERROR="error",exports.RESOURCE_TYPE=void 0,(U=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",U.SPRITE="SPRITE",U.SPRITE_ANIMATION="SPRITE_ANIMATION",U.AUDIO="AUDIO",U.VIDEO="VIDEO",o.XhrLoadStrategy.setExtensionXhrType("json",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("tex",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("ske",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("mp3",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("wav",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("aac",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("ogg",o.XhrResponseType.Buffer);var B={png:o.ImageLoadStrategy,jpg:o.ImageLoadStrategy,jpeg:o.ImageLoadStrategy,webp:o.ImageLoadStrategy,json:o.XhrLoadStrategy,tex:o.XhrLoadStrategy,ske:o.XhrLoadStrategy,audio:o.XhrLoadStrategy,video:o.VideoLoadStrategy},H=new(function(e){function t(t){var r=e.call(this)||this;return r.timeout=6e3,r.preProcessResourceHandlers=[],r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return i(t,e),t.prototype.loadConfig=function(e){this.addResource(e),this.preload()},t.prototype.loadSingle=function(e){return this.addResource([e]),this.getResource(e.name)},t.prototype.addResource=function(e){var t,r;if(!e||e.length<1)console.warn("no resources");else try{for(var o=l(e),n=o.next();!n.done;n=o.next()){var a=n.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{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},t.prototype.addPreProcessResourceHandler=function(e){this.preProcessResourceHandlers.push(e)},t.prototype.removePreProcessResourceHandler=function(e){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(e),1)},t.prototype.preload=function(){var e=[];for(var t in this.resourcesMap){var r=this.resourcesMap[t];!r.preload||r.complete||this.promiseMap[t]||e.push(r.name)}this.progress=new Y({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})},t.prototype.getResource=function(e){return u(this,void 0,void 0,(function(){return p(this,(function(t){return this.loadResource({names:[e]}),[2,this.promiseMap[e]||Promise.resolve({})]}))}))},t.prototype.instance=function(e){return u(this,void 0,void 0,(function(){var t,r;return p(this,(function(o){switch(o.label){case 0:return t=this.resourcesMap[e],(r=this.makeInstanceFunctions[t.type])?[4,this.makeInstanceFunctions[t.type](t)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return[2,r]}}))}))},t.prototype.destroy=function(e){return u(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._destroy(e)];case 1:return t.sent(),[2]}}))}))},t.prototype._destroy=function(e,t){return void 0===t&&(t=!1),u(this,void 0,void 0,(function(){var r,o;return p(this,(function(n){switch(n.label){case 0:if(!(r=this.resourcesMap[e]))return[2];if(t)return[3,5];n.label=1;case 1:return n.trys.push([1,4,,5]),this.destroyInstanceFunctions[r.type]?[4,this.destroyInstanceFunctions[r.type](r)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:return o=n.sent(),console.warn("destroy resource "+r.name+" error with '"+o.message+"'"),[3,5];case 5:return delete this.promiseMap[e],r.data={},r.complete=!1,r.instance=void 0,[2]}}))}))},t.prototype.registerResourceType=function(e,t){if(void 0===t&&(t=e),exports.RESOURCE_TYPE[e])throw new Error("The type "+e+" already exists in RESOURCE_TYPE");exports.RESOURCE_TYPE[e]=t},t.prototype.registerInstance=function(e,t){this.makeInstanceFunctions[e]=t},t.prototype.registerDestroy=function(e,t){this.destroyInstanceFunctions[e]=t},t.prototype.loadResource=function(e){var t=this,r=e.names,o=void 0===r?[]:r,n=e.preload,a=void 0!==n&&n,s=o.filter((function(e){return!t.promiseMap[e]&&t.resourcesMap[e]}));if(s.length){var i={},c=this.getLoader(a);s.forEach((function(e){var r,o;t.promiseMap[e]=new Promise((function(t){return i[e]=t}));var n=t.resourcesMap[e];try{for(var s=l(t.preProcessResourceHandlers),u=s.next();!u.done;u=s.next()){(0,u.value)(n)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}for(var p in n.src){var f=n.src[p].type;"data"===f?(n.data[p]=n.src[p].data,t.doComplete(e,i[e],a)):c.add({url:n.src[p].url,name:n.name+"_"+p,strategy:B[f],metadata:{key:p,name:n.name,resolves:i}})}})),c.load()}},t.prototype.doComplete=function(e,t,r){return void 0===r&&(r=!1),u(this,void 0,void 0,(function(){var o,n,a,s;return p(this,(function(i){switch(i.label){case 0:if(o=this.resourcesMap[e],n={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=o,[4,this.instance(e)];case 2:return a.instance=i.sent(),o.complete=!0,r&&this.progress.onProgress(n),t(o),[3,4];case 3:return s=i.sent(),console.error(s),o.complete=!1,r&&(n.errMsg=s.message,n.success=!1,this.progress.onProgress(n)),t({}),[3,4];case 4:return[2]}}))}))},t.prototype.checkAllLoaded=function(e){var t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((function(e){return t.data[e]}))},t.prototype.getLoader=function(e){var t=this;void 0===e&&(e=!1);var r=this.loaders.find((function(e){return!e.loading}));return r||(r=new o.Loader,this.loaders.push(r)),e&&r.onStart.once((function(){t.progress.onStart()})),r.onLoad.add((function(r,o){t.onLoad({preload:e,resource:o})})),r.onError.add((function(r,o,n){t.onError({errMsg:r,resource:n,preload:e})})),r.onComplete.once((function(){r.onLoad.detachAll(),r.onError.detachAll(),r.reset()})),r},t.prototype.onLoad=function(e){var t=e.preload,r=void 0!==t&&t,o=e.resource;return u(this,void 0,void 0,(function(){var e,t,n,a,s;return p(this,(function(i){return e=o.metadata,t=e.key,n=e.name,a=e.resolves,s=o.data,this.resourcesMap[n].data[t]=s,this.doComplete(n,a[n],r),[2]}))}))},t.prototype.onError=function(e){var t=e.errMsg,r=e.preload,o=void 0!==r&&r,n=e.resource;return u(this,void 0,void 0,(function(){var e,r,a,s;return p(this,(function(i){return e=n.metadata,r=e.name,a=e.resolves,this._destroy(r,!0),a[r]({}),o&&(s={name:r,resource:this.resourcesMap[r],success:!1,errMsg:t},this.progress.onProgress(s)),[2]}))}))},t}(a)),z={IDEProp:X,componentObserver:G};console.log("Eva.js version: 1.2.2"),exports.Component=d,exports.Game=V,exports.GameObject=w,exports.IDEProp=X,exports.RESOURCE_TYPE_STRATEGY=B,exports.Scene=I,exports.System=P,exports.Transform=T,exports.componentObserver=G,exports.decorators=z,exports.resource=H,exports.resourceLoader=q,exports.version="1.2.2";
package/dist/eva.js.d.ts CHANGED
@@ -450,6 +450,6 @@ declare interface Vector2 {
450
450
  y: number;
451
451
  }
452
452
 
453
- export declare const version = "1.2.2-mini.2";
453
+ export declare const version = "1.2.2";
454
454
 
455
455
  export { }
@@ -1,8 +1,8 @@
1
- import EventEmitter from 'eventemitter3';
2
- import { isEqual, isObject } from 'lodash-es';
3
- import { type, step } from '@eva/inspector-decorator';
4
- import { AbstractLoadStrategy, AudioLoadStrategy, ImageLoadStrategy, XhrResponseType, MediaElementLoadStrategy, VideoLoadStrategy, XhrLoadStrategy, Loader, Resource as Resource$1, ResourceType, ResourceState } from 'resource-loader';
5
-
1
+ import EventEmitter from 'eventemitter3';
2
+ import { isEqual, isObject } from 'lodash-es';
3
+ import { type, step } from '@eva/inspector-decorator';
4
+ import { AbstractLoadStrategy, AudioLoadStrategy, ImageLoadStrategy, XhrResponseType, MediaElementLoadStrategy, VideoLoadStrategy, XhrLoadStrategy, Loader, Resource as Resource$1, ResourceType, ResourceState } from 'resource-loader';
5
+
6
6
  /*! *****************************************************************************
7
7
  Copyright (c) Microsoft Corporation. All rights reserved.
8
8
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -108,8 +108,8 @@ function __spread() {
108
108
  for (var ar = [], i = 0; i < arguments.length; i++)
109
109
  ar = ar.concat(__read(arguments[i]));
110
110
  return ar;
111
- }
112
-
111
+ }
112
+
113
113
  function getComponentName(component) {
114
114
  if (component instanceof Component) {
115
115
  return component.name;
@@ -129,8 +129,8 @@ var Component = (function (_super) {
129
129
  }
130
130
  return Component;
131
131
  }(EventEmitter));
132
- var Component$1 = Component;
133
-
132
+ var Component$1 = Component;
133
+
134
134
  var ObserverType;
135
135
  (function (ObserverType) {
136
136
  ObserverType["ADD"] = "ADD";
@@ -164,8 +164,9 @@ function removeObjectCache(component) {
164
164
  }
165
165
  }
166
166
  function addObserver(_a) {
167
+ var _b, _c;
167
168
  var systemName = _a.systemName, componentName = _a.componentName, component = _a.component, prop = _a.prop, type = _a.type;
168
- systemInstance[systemName].componentObserver.add({
169
+ (_c = (_b = systemInstance[systemName]) === null || _b === void 0 ? void 0 : _b.componentObserver) === null || _c === void 0 ? void 0 : _c.add({
169
170
  component: component,
170
171
  prop: prop,
171
172
  type: type,
@@ -326,12 +327,13 @@ function observer(component, componentName) {
326
327
  }
327
328
  }
328
329
  function observerAdded(component, componentName) {
330
+ var _a, _b;
329
331
  if (componentName === void 0) { componentName = component.name; }
330
332
  for (var systemName in observerInfos) {
331
333
  var observerInfo = observerInfos[systemName] || {};
332
334
  var info = observerInfo[componentName];
333
335
  if (info) {
334
- systemInstance[systemName].componentObserver.add({
336
+ (_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
335
337
  component: component,
336
338
  type: ObserverType.ADD,
337
339
  componentName: componentName,
@@ -340,12 +342,13 @@ function observerAdded(component, componentName) {
340
342
  }
341
343
  }
342
344
  function observerRemoved(component, componentName) {
345
+ var _a, _b;
343
346
  if (componentName === void 0) { componentName = component.name; }
344
347
  for (var systemName in observerInfos) {
345
348
  var observerInfo = observerInfos[systemName] || {};
346
349
  var info = observerInfo[componentName];
347
350
  if (info) {
348
- systemInstance[systemName].componentObserver.add({
351
+ (_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
349
352
  component: component,
350
353
  type: ObserverType.REMOVE,
351
354
  componentName: componentName,
@@ -357,8 +360,8 @@ function observerRemoved(component, componentName) {
357
360
  function setSystemObserver(system, S) {
358
361
  observerInfos[S.systemName] = S.observerInfo;
359
362
  systemInstance[S.systemName] = system;
360
- }
361
-
363
+ }
364
+
362
365
  var Transform = (function (_super) {
363
366
  __extends(Transform, _super);
364
367
  function Transform() {
@@ -462,8 +465,8 @@ var Transform = (function (_super) {
462
465
  ], Transform.prototype, "rotation", void 0);
463
466
  return Transform;
464
467
  }(Component$1));
465
- var Transform$1 = Transform;
466
-
468
+ var Transform$1 = Transform;
469
+
467
470
  var _id = 0;
468
471
  function getId() {
469
472
  return ++_id;
@@ -632,6 +635,10 @@ var GameObject = (function () {
632
635
  return this.parent.removeChild(this);
633
636
  };
634
637
  GameObject.prototype.destroy = function () {
638
+ if (!this.transform) {
639
+ console.error('Cannot destroy gameObject that have already been destroyed.');
640
+ return;
641
+ }
635
642
  Array.from(this.transform.children).forEach(function (_a) {
636
643
  var gameObject = _a.gameObject;
637
644
  gameObject.destroy();
@@ -645,8 +652,8 @@ var GameObject = (function () {
645
652
  };
646
653
  return GameObject;
647
654
  }());
648
- var GameObject$1 = GameObject;
649
-
655
+ var GameObject$1 = GameObject;
656
+
650
657
  var ComponentObserver = (function () {
651
658
  function ComponentObserver() {
652
659
  this.events = [];
@@ -688,8 +695,8 @@ var ComponentObserver = (function () {
688
695
  };
689
696
  return ComponentObserver;
690
697
  }());
691
- var ComponentObserver$1 = ComponentObserver;
692
-
698
+ var ComponentObserver$1 = ComponentObserver;
699
+
693
700
  var System = (function () {
694
701
  function System(params) {
695
702
  this.started = false;
@@ -705,8 +712,8 @@ var System = (function () {
705
712
  };
706
713
  return System;
707
714
  }());
708
- var System$1 = System;
709
-
715
+ var System$1 = System;
716
+
710
717
  function createNowTime() {
711
718
  var nowtime = null;
712
719
  if (Date.now) {
@@ -716,8 +723,8 @@ function createNowTime() {
716
723
  nowtime = function () { return new Date().getTime(); };
717
724
  }
718
725
  return nowtime;
719
- }
720
-
726
+ }
727
+
721
728
  var _nowtime = createNowTime();
722
729
  var defaultOptions$1 = {
723
730
  originTime: 0,
@@ -883,8 +890,8 @@ var Timeline = (function () {
883
890
  });
884
891
  return Timeline;
885
892
  }());
886
- var Timeline$1 = Timeline;
887
-
893
+ var Timeline$1 = Timeline;
894
+
888
895
  var defaultOptions = {
889
896
  autoStart: true,
890
897
  frameRate: 60,
@@ -965,8 +972,8 @@ var Ticker = (function () {
965
972
  };
966
973
  return Ticker;
967
974
  }());
968
- var Ticker$1 = Ticker;
969
-
975
+ var Ticker$1 = Ticker;
976
+
970
977
  var Scene = (function (_super) {
971
978
  __extends(Scene, _super);
972
979
  function Scene(name, obj) {
@@ -998,8 +1005,8 @@ var Scene = (function (_super) {
998
1005
  };
999
1006
  return Scene;
1000
1007
  }(GameObject$1));
1001
- var Scene$1 = Scene;
1002
-
1008
+ var Scene$1 = Scene;
1009
+
1003
1010
  var LOAD_SCENE_MODE;
1004
1011
  (function (LOAD_SCENE_MODE) {
1005
1012
  LOAD_SCENE_MODE["SINGLE"] = "SINGLE";
@@ -1446,15 +1453,15 @@ var Game = (function (_super) {
1446
1453
  };
1447
1454
  return Game;
1448
1455
  }(EventEmitter));
1449
- var Game$1 = Game;
1450
-
1456
+ var Game$1 = Game;
1457
+
1451
1458
  function IDEProp(target, propertyKey) {
1452
1459
  if (!target.constructor.IDEProps) {
1453
1460
  target.constructor.IDEProps = [];
1454
1461
  }
1455
1462
  target.constructor.IDEProps.push(propertyKey);
1456
- }
1457
-
1463
+ }
1464
+
1458
1465
  function componentObserver(observerInfo) {
1459
1466
  if (observerInfo === void 0) { observerInfo = {}; }
1460
1467
  return function (constructor) {
@@ -1481,8 +1488,8 @@ function componentObserver(observerInfo) {
1481
1488
  constructor.observerInfo = observerInfo;
1482
1489
  }
1483
1490
  };
1484
- }
1485
-
1491
+ }
1492
+
1486
1493
  var Progress = (function (_super) {
1487
1494
  __extends(Progress, _super);
1488
1495
  function Progress(_a) {
@@ -1517,8 +1524,8 @@ var Progress = (function (_super) {
1517
1524
  };
1518
1525
  return Progress;
1519
1526
  }(EventEmitter));
1520
- var Progress$1 = Progress;
1521
-
1527
+ var Progress$1 = Progress;
1528
+
1522
1529
  var resourceLoader = {
1523
1530
  AbstractLoadStrategy: AbstractLoadStrategy,
1524
1531
  AudioLoadStrategy: AudioLoadStrategy,
@@ -1531,8 +1538,8 @@ var resourceLoader = {
1531
1538
  Resource: Resource$1,
1532
1539
  ResourceType: ResourceType,
1533
1540
  ResourceState: ResourceState
1534
- };
1535
-
1541
+ };
1542
+
1536
1543
  var LOAD_EVENT;
1537
1544
  (function (LOAD_EVENT) {
1538
1545
  LOAD_EVENT["START"] = "start";
@@ -1626,7 +1633,7 @@ var Resource = (function (_super) {
1626
1633
  var names = [];
1627
1634
  for (var key in this.resourcesMap) {
1628
1635
  var resource_1 = this.resourcesMap[key];
1629
- if (resource_1.preload && !resource_1.complete) {
1636
+ if (resource_1.preload && !resource_1.complete && !this.promiseMap[key]) {
1630
1637
  names.push(resource_1.name);
1631
1638
  }
1632
1639
  }
@@ -1880,13 +1887,13 @@ var Resource = (function (_super) {
1880
1887
  };
1881
1888
  return Resource;
1882
1889
  }(EventEmitter));
1883
- var resource = new Resource();
1884
-
1890
+ var resource = new Resource();
1891
+
1885
1892
  var decorators = {
1886
1893
  IDEProp: IDEProp,
1887
1894
  componentObserver: componentObserver,
1888
1895
  };
1889
- var version = '1.2.2-alpha.2';
1890
- console.log("Eva.js version: " + version);
1891
-
1892
- export { Component$1 as Component, Game$1 as Game, GameObject$1 as GameObject, IDEProp, LOAD_EVENT, LOAD_SCENE_MODE, ObserverType as OBSERVER_TYPE, RESOURCE_TYPE, RESOURCE_TYPE_STRATEGY, Scene$1 as Scene, System$1 as System, Transform$1 as Transform, componentObserver, decorators, resource, resourceLoader, version };
1896
+ var version = '1.2.2';
1897
+ console.log("Eva.js version: " + version);
1898
+
1899
+ export { Component$1 as Component, Game$1 as Game, GameObject$1 as GameObject, IDEProp, LOAD_EVENT, LOAD_SCENE_MODE, ObserverType as OBSERVER_TYPE, RESOURCE_TYPE, RESOURCE_TYPE_STRATEGY, Scene$1 as Scene, System$1 as System, Transform$1 as Transform, componentObserver, decorators, resource, resourceLoader, version };
@@ -76,12 +76,14 @@ function removeObjectCache(component) {
76
76
  }
77
77
 
78
78
  function addObserver(_a) {
79
+ var _b, _c;
80
+
79
81
  var systemName = _a.systemName,
80
82
  componentName = _a.componentName,
81
83
  component = _a.component,
82
84
  prop = _a.prop,
83
85
  type = _a.type;
84
- systemInstance[systemName].componentObserver.add({
86
+ (_c = (_b = systemInstance[systemName]) === null || _b === void 0 ? void 0 : _b.componentObserver) === null || _c === void 0 ? void 0 : _c.add({
85
87
  component: component,
86
88
  prop: prop,
87
89
  type: type,
@@ -294,6 +296,8 @@ function observer(component, componentName) {
294
296
  }
295
297
 
296
298
  function observerAdded(component, componentName) {
299
+ var _a, _b;
300
+
297
301
  if (componentName === void 0) {
298
302
  componentName = component.name;
299
303
  }
@@ -303,7 +307,7 @@ function observerAdded(component, componentName) {
303
307
  var info = observerInfo[componentName];
304
308
 
305
309
  if (info) {
306
- systemInstance[systemName].componentObserver.add({
310
+ (_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
307
311
  component: component,
308
312
  type: ObserverType.ADD,
309
313
  componentName: componentName
@@ -313,6 +317,8 @@ function observerAdded(component, componentName) {
313
317
  }
314
318
 
315
319
  function observerRemoved(component, componentName) {
320
+ var _a, _b;
321
+
316
322
  if (componentName === void 0) {
317
323
  componentName = component.name;
318
324
  }
@@ -322,7 +328,7 @@ function observerRemoved(component, componentName) {
322
328
  var info = observerInfo[componentName];
323
329
 
324
330
  if (info) {
325
- systemInstance[systemName].componentObserver.add({
331
+ (_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
326
332
  component: component,
327
333
  type: ObserverType.REMOVE,
328
334
  componentName: componentName
@@ -654,6 +660,11 @@ var GameObject = function () {
654
660
  };
655
661
 
656
662
  GameObject.prototype.destroy = function () {
663
+ if (!this.transform) {
664
+ console.error('Cannot destroy gameObject that have already been destroyed.');
665
+ return;
666
+ }
667
+
657
668
  Array.from(this.transform.children).forEach(function (_a) {
658
669
  var gameObject = _a.gameObject;
659
670
  gameObject.destroy();
@@ -3303,7 +3314,7 @@ var Resource = function (_super) {
3303
3314
  for (var key in this.resourcesMap) {
3304
3315
  var resource_1 = this.resourcesMap[key];
3305
3316
 
3306
- if (resource_1.preload && !resource_1.complete) {
3317
+ if (resource_1.preload && !resource_1.complete && !this.promiseMap[key]) {
3307
3318
  names.push(resource_1.name);
3308
3319
  }
3309
3320
  }
@@ -3659,6 +3670,6 @@ var decorators = {
3659
3670
  IDEProp: IDEProp,
3660
3671
  componentObserver: componentObserver
3661
3672
  };
3662
- var version = '1.2.2-mini.2';
3673
+ var version = '1.2.2';
3663
3674
  console.log("Eva.js version: " + version);
3664
3675
  export { Component$1 as Component, Game$1 as Game, GameObject$1 as GameObject, IDEProp, LOAD_EVENT, LOAD_SCENE_MODE, ObserverType as OBSERVER_TYPE, RESOURCE_TYPE, RESOURCE_TYPE_STRATEGY, Scene$1 as Scene, System$1 as System, Transform$1 as Transform, componentObserver, decorators, resource, resourceLoader, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/eva.js",
3
- "version": "1.2.2-mini.2",
3
+ "version": "1.2.2",
4
4
  "description": "@eva/eva.js",
5
5
  "main": "index.js",
6
6
  "module": "dist/eva.js.esm.js",