@eva/eva.js
Advanced tools
Comparing version 2.0.0-beta.10 to 2.0.0-beta.11
@@ -1390,3 +1390,3 @@ 'use strict'; | ||
}; | ||
const version = '2.0.0-beta.10'; | ||
const version = '2.0.0-beta.11'; | ||
console.log(`Eva.js version: ${version}`); | ||
@@ -1393,0 +1393,0 @@ const RESOURCE_TYPE_STRATEGY = {}; |
@@ -16,2 +16,2 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("lodash-es"),s=require("@eva/inspector-decorator"),r=require("pixi.js"),o=require("resource-loader");function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=n(e);class a extends i{constructor(e){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=e}}var c,m=a;exports.OBSERVER_TYPE=void 0,(c=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",c.REMOVE="REMOVE",c.CHANGE="CHANGE";const h={},p={},l={},u={};function d(e,t){h[e.gameObject.id]||(h[e.gameObject.id]={});const s=h[e.gameObject.id],r=e.name+"_"+t.join(",");if(s[r])return s[r];const o=t.length-1;let n=e;for(let e=0;e<o;e++)n=n[t[e]];return s[r]={property:n,key:t[o]},s[r]}function f({systemName:e,componentName:t,component:s,prop:r,type:o}){var n,i;null===(i=null===(n=p[e])||void 0===n?void 0:n.componentObserver)||void 0===i||i.add({component:s,prop:r,type:o,componentName:t})}function y({obj:e,key:s,prop:r,component:o,componentName:n}){if(void 0!==e)if(s in e){if(Object.defineProperty(e,`_${s}`,{enumerable:!1,writable:!0,value:e[s]}),r.deep&&t.isObject(e[s]))for(const t of Object.keys(e[s]))y({obj:e[s],key:t,prop:r,component:o,componentName:n});Object.defineProperty(e,s,{enumerable:!0,set(i){e[`_${s}`]!==i&&(e[`_${s}`]=i,function({prop:e,component:s,componentName:r}){for(const o in l){const n=(l[o]||{})[r];n&&(n.findIndex((s=>t.isEqual(s,e)))>-1&&f({systemName:o,componentName:r,component:s,prop:e,type:exports.OBSERVER_TYPE.CHANGE}))}}({prop:r,component:o,componentName:n}))},get:()=>e[`_${s}`]})}else console.error(`prop ${s} not in component: ${n}, Can not observer`)}function g(e,t=e.name){var s,r;for(const o in l){(l[o]||{})[t]&&(null===(r=null===(s=p[o])||void 0===s?void 0:s.componentObserver)||void 0===r||r.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t}))}!function(e){e.gameObject&&delete h[e.gameObject.id]}(e)} | ||
***************************************************************************** */ | ||
function E(e,t,s,r){var o,n=arguments.length,i=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,s,i):o(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i}function v(e,t,s,r){return new(s||(s=Promise))((function(o,n){function i(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){e.done?o(e.value):new s((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))}class _ extends m{constructor(){super(...arguments),this.name="Transform",this._parent=null,this.inScene=!1,this.children=[],this.position={x:0,y:0},this.size={width:0,height:0},this.origin={x:0,y:0},this.anchor={x:0,y:0},this.scale={x:1,y:1},this.skew={x:0,y:0},this.rotation=0}init(e={}){const t=["position","size","origin","anchor","scale","skew"];for(const s of t)Object.assign(this[s],e[s]);this.rotation=e.rotation||this.rotation}set parent(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)}get parent(){return this._parent}addChild(e){if(e.parent===this){const t=this.children.findIndex((t=>t===e));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)}removeChild(e){const t=this.children.findIndex((t=>t===e));t>-1&&(this.children.splice(t,1),e._parent=null)}clearChildren(){this.children.length=0}}_.componentName="Transform",E([s.type("vector2"),s.step(1)],_.prototype,"position",void 0),E([s.type("size"),s.step(1)],_.prototype,"size",void 0),E([s.type("vector2"),s.step(.1)],_.prototype,"origin",void 0),E([s.type("vector2"),s.step(.1)],_.prototype,"anchor",void 0),E([s.type("vector2"),s.step(.1)],_.prototype,"scale",void 0),E([s.type("vector2"),s.step(.1)],_.prototype,"skew",void 0),E([s.type("number"),s.step(.1)],_.prototype,"rotation",void 0);var b=_;let R=0;class O{constructor(e,t){this._componentCache={},this.components=[],this.destroyed=!1,this._name=e,this.id=++R,this.addComponent(b,t)}get transform(){return this.getComponent(b)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get name(){return this._name}set scene(e){if(this._scene===e)return;const t=this._scene;if(this._scene=e,this.transform&&this.transform.children)for(const t of this.transform.children)t.gameObject.scene=e;e?e.addGameObject(this):t&&t.removeGameObject(this)}get scene(){return this._scene}addChild(e){if(e&&e.transform&&e!==this){if(!(e instanceof O))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error(`gameObject '${this.name}' has been destroy`);e.transform.parent=this.transform,e.scene=this.scene}}removeChild(e){return e instanceof O&&e.parent&&e.parent===this?(e.transform.parent=null,e.scene=null,e):e}addComponent(e,t){if(this.destroyed)return;const s=function(e){return e instanceof a?e.name:e instanceof Function?e.componentName:void 0}(e);if(this._componentCache[s])return;let r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof m))throw new Error("addComponent recieve Component and Component Constructor");r=e}if(r.gameObject)throw new Error(`component has been added on gameObject ${r.gameObject.name}`);return r.gameObject=this,r.init&&r.init(r.__componentDefaultParams),function(e,t=e.name){var s,r;for(const o in l)(l[o]||{})[t]&&(null===(r=null===(s=p[o])||void 0===s?void 0:s.componentObserver)||void 0===r||r.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t}))}(r,r.name),function(e,t=e.name){if(t&&u[t]){if(!(e&&(s=e,s&&s.constructor&&"componentName"in s.constructor)))throw new Error("component param must be an instance of Component");var s;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");for(const s of u[t]){const{property:r,key:o}=d(e,s.prop);y({obj:r,key:o,prop:s,component:e,componentName:t})}}}(r,r.name),this.components.push(r),this._componentCache[s]=r,r.awake&&r.awake(),r}removeComponent(e){let t;if("string"==typeof e?t=e:e instanceof m?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)}_removeComponent(e){const t=this.components.findIndex((({name:t})=>t===e));if(-1===t)return;const s=this.components.splice(t,1)[0];return delete this._componentCache[e],delete s.__componentDefaultParams,s.onDestroy&&s.onDestroy(),g(s,e),s.gameObject=void 0,s}getComponent(e){let t;return"string"==typeof e?t=e:e instanceof m?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0}remove(){if(this.parent)return this.parent.removeChild(this)}destroy(){if(this.transform){Array.from(this.transform.children).forEach((({gameObject:e})=>{e.destroy()})),this.remove(),this.transform.clearChildren();for(const e in this._componentCache)this._removeComponent(e);this.components.length=0,this.destroyed=!0}else console.error("Cannot destroy gameObject that have already been destroyed.")}}var T=O;var k=class{constructor(){this.events=[]}add({component:e,prop:s,type:r,componentName:o}){if(r===exports.OBSERVER_TYPE.REMOVE){if(this.events.find((t=>t.component===e&&t.type===exports.OBSERVER_TYPE.ADD)))return void(this.events=this.events.filter((t=>t.component!==e)));this.events=this.events.filter((t=>t.component!==e))}const n=this.events.findIndex((o=>o.component===e&&t.isEqual(o.prop,s)&&o.type===r));n>-1&&this.events.splice(n,1),this.events.push({gameObject:e.gameObject,component:e,prop:s,type:r,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const e=this.events;return this.events=[],e}};var S=class{constructor(e){this.started=!1,this.componentObserver=new k,this.__systemDefaultParams=e,this.name=this.constructor.systemName}destroy(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)}};const C=function(){let e=null;return e=Date.now?Date.now:()=>(new Date).getTime(),e}(),M={originTime:0,playbackRate:1};class x{constructor(e,t){e instanceof x&&(t=e,e={}),e=Object.assign({},M,e),t&&(this._parent=t),this._createTime=C(),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}get globalTime(){return this.parent?this.parent.currentTime:C()-this._createTime}get parent(){return this._parent}get lastTimeMark(){return this._timeMark[this._timeMark.length-1]}markTime({time:e=this.currentTime,entropy:t=this.entropy,playbackRate:s=this.playbackRate}={}){const r={globalTime:this.globalTime,localTime:e,entropy:t,playbackRate:s,globalEntropy:this.globalEntropy};this._timeMark.push(r)}get currentTime(){const{localTime:e,globalTime:t}=this.lastTimeMark;return e+(this.globalTime-t)*this.playbackRate}set currentTime(e){this.markTime({time:e})}get globalEntropy(){return this._parent?this._parent.entropy:this.globalTime}get entropy(){const{entropy:e,globalEntropy:t}=this.lastTimeMark;return e+Math.abs((this.globalEntropy-t)*this.playbackRate)}set entropy(e){if(this.entropy>e){const t=this.seekTimeMark(e);this._timeMark.length=t+1}this.markTime({entropy:e})}fork(e){return new x(e,this)}seekGlobalTime(e){const t=this.seekTimeMark(e),s=this._timeMark[t],{entropy:r,playbackRate:o,globalTime:n}=s;return n+(e-r)/Math.abs(o)}seekLocalTime(e){const t=this.seekTimeMark(e),s=this._timeMark[t],{localTime:r,entropy:o,playbackRate:n}=s;return n>0?r+(e-o):r-(e-o)}seekTimeMark(e){const t=this._timeMark;let s=0,r=t.length-1;if(e<=t[s].entropy)return s;if(e>=t[r].entropy)return r;let o=Math.floor((s+r)/2);for(;o>s&&o<r;){if(e===t[o].entropy)return o;e<t[o].entropy?r=o:e>t[o].entropy&&(s=o),o=Math.floor((s+r)/2)}return s}get playbackRate(){return this._playbackRate}set playbackRate(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this._playbackRate=e)}get paused(){if(0===this.playbackRate)return!0;let e=this.parent;for(;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1}}var N=x;const P={autoStart:!0,frameRate:60};var A=class{constructor(e){e=Object.assign({},P,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new N({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=()=>{this._started&&(this._requestId=requestAnimationFrame(this._ticker),this.update())},this.autoStart&&this.start()}update(){const e=this.timeline.currentTime,t=e-this._lastFrameTime;if(t>=this._frameDuration){const s=e-t%this._frameDuration,r=s-this._lastFrameTime;this._lastFrameTime=s;const o={deltaTime:r,time:s,currentTime:s,frameCount:++this._frameCount,fps:Math.round(1e3/r)};for(const e of this._tickers)"function"==typeof e&&e(o)}}add(e){this._tickers.add(e)}remove(e){this._tickers.delete(e)}start(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))}pause(){this._started=!1,this.timeline.playbackRate=0}setPlaybackRate(e){this.timeline.playbackRate=e}};var j,D=class extends T{constructor(e,t){super(e,t),this.gameObjects=[],this.scene=this}addGameObject(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)}removeGameObject(e){const t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null}};exports.LOAD_SCENE_MODE=void 0,(j=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",j.MULTI_CANVAS="MULTI_CANVAS";const w=e=>{if((e instanceof S||e instanceof m)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof m?console.error(`${e.constructor.componentName} start error`,t):console.error(`${e.constructor.systemName} start error`,t)}}};var I=class extends i{constructor(){super(...arguments),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[]}init({systems:e,frameRate:t=60,autoStart:s=!0,needScene:r=!0}={}){return v(this,void 0,void 0,(function*(){if(window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new A({autoStart:!1,frameRate:t}),this.initTicker(),e&&e.length)for(const t of e)yield this.addSystem(t);r&&this.loadScene(new D("scene")),s&&this.start()}))}get scene(){return this._scene}set scene(e){this._scene=e}get gameObjects(){return(e=>{var t;const s=(null===(t=null==e?void 0:e.scene)||void 0===t?void 0:t.gameObjects)||[],r=null==e?void 0:e.multiScenes.map((({gameObjects:e})=>e));let o=[];for(const e of r)o=[...o,...e];return[...s,...o]})(this)}addSystem(e,s){return v(this,void 0,void 0,(function*(){let r;if(e instanceof Function)r=new e(s);else{if(!(e instanceof S))return void console.warn("can only add System");r=e}if(!this.systems.find((e=>e.constructor===r.constructor))){r.game=this,r.init&&(yield r.init(r.__systemDefaultParams)),function(e,t){l[t.systemName]=t.observerInfo,p[t.systemName]=e}(r,r.constructor),function(e){const s=[];e instanceof Array?s.push(...e):s.push(e);for(const e of s)for(const s in e.observerInfo){u[s]=u[s]||[];const r=u[s];for(const o of e.observerInfo[s])-1===r.findIndex((e=>t.isEqual(e,o)))&&u[s].push(o)}}(r.constructor);try{r.awake&&r.awake()}catch(e){console.error(`${r.constructor.systemName} awake error`,e)}return this.systems.push(r),r}console.warn(`${r.constructor.systemName} System has been added`)}))}removeSystem(e){if(!e)return;let t=-1;"string"==typeof e?t=this.systems.findIndex((t=>t.name===e)):e instanceof Function?t=this.systems.findIndex((t=>t.constructor===e)):e instanceof S&&(t=this.systems.findIndex((t=>t===e))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}getSystem(e){return this.systems.find((t=>"string"==typeof e?t.name===e:t instanceof e))}pause(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())}start(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())}resume(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())}initTicker(){this.ticker.add((e=>{this.scene&&((e,t=[])=>{for(const s of t)for(const t of s.components)try{w(t),t.update&&t.update(e)}catch(e){console.error(`gameObject: ${s.name} ${t.name} update error`,e)}for(const s of t)for(const t of s.components)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`gameObject: ${s.name} ${t.name} lateUpdate error`,e)}})(e,this.gameObjects);for(const t of this.systems)try{w(t),t.update&&t.update(e)}catch(e){console.error(`${t.constructor.systemName} update error`,e)}for(const t of this.systems)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`${t.constructor.systemName} lateUpdate error`,e)}}))}triggerResume(){(e=>{for(const t of e)for(const e of t.components)try{e.onResume&&e.onResume()}catch(s){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,s)}})(this.gameObjects);for(const e of this.systems)try{e.onResume&&e.onResume()}catch(t){console.error(`${e.constructor.systemName}, onResume error`,t)}}triggerPause(){(e=>{for(const t of e)for(const e of t.components)try{e.onPause&&e.onPause()}catch(s){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,s)}})(this.gameObjects);for(const e of this.systems)try{e.onPause&&e.onPause()}catch(t){console.error(`${e.constructor.systemName}, onPause error`,t)}}destroySystems(){for(const e of[...this.systems])this.removeSystem(e);this.systems.length=0}destroy(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:e,mode:t=exports.LOAD_SCENE_MODE.SINGLE,params:s={}}){if(e){switch(t){case exports.LOAD_SCENE_MODE.SINGLE:this.scene=e;break;case exports.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(e)}this.emit("sceneChanged",{scene:e,mode:t,params:s})}}};function L(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function V(e={}){return function(t){if(!t.observerInfo){for(const t in e)for(const s in e[t]){let r;"string"==typeof e[t][s]&&(e[t][s]=[e[t][s]]),Array.isArray(e[t][s])&&(r={prop:e[t][s],deep:!1},e[t][s]=r),r=e[t][s],"string"==typeof r.prop&&(r.prop=[r.prop])}t.observerInfo=e}}}class $ extends i{constructor({resource:e,resourceTotal:t}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=e,this.resourceTotal=t,0===t&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(exports.LOAD_EVENT.START,this)}onProgress(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)}}const G={AbstractLoadStrategy:o.AbstractLoadStrategy,AudioLoadStrategy:o.AudioLoadStrategy,ImageLoadStrategy:o.ImageLoadStrategy,XhrResponseType:o.XhrResponseType,MediaElementLoadStrategy:o.MediaElementLoadStrategy,VideoLoadStrategy:o.VideoLoadStrategy,Loader:o.Loader,Resource:o.Resource,ResourceType:o.ResourceType,ResourceState:o.ResourceState};var F,U;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";const Y=new class extends i{constructor(e){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},e&&"number"==typeof e.timeout&&(this.timeout=e.timeout)}loadConfig(e){this.addResource(e),this.preload()}loadSingle(e){return this.addResource([e]),this.getResource(e.name)}addResource(e){if(!e||e.length<1)console.warn("no resources");else for(const t of e)this.resourcesMap[t.name]?console.warn(t.name+" was already added"):(this.resourcesMap[t.name]=t,this.resourcesMap[t.name].data={})}addPreProcessResourceHandler(e){this.preProcessResourceHandlers.push(e)}removePreProcessResourceHandler(e){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(e),1)}preload(){const e=[];for(const t in this.resourcesMap){const s=this.resourcesMap[t];!s.preload||s.complete||this.promiseMap[t]||e.push(s.name)}this.progress=new $({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})}getResource(e){return v(this,void 0,void 0,(function*(){return this.loadResource({names:[e]}),this.promiseMap[e]||Promise.resolve({})}))}instance(e){return v(this,void 0,void 0,(function*(){const t=this.resourcesMap[e];return this.makeInstanceFunctions[t.type]&&(yield this.makeInstanceFunctions[t.type](t))}))}destroy(e){return v(this,void 0,void 0,(function*(){yield this._destroy(e)}))}_destroy(e,t=!1){return v(this,void 0,void 0,(function*(){const s=this.resourcesMap[e];if(s){if(!t)try{this.destroyInstanceFunctions[s.type]&&(yield this.destroyInstanceFunctions[s.type](s))}catch(e){console.warn(`destroy resource ${s.name} error with '${e.message}'`)}delete this.promiseMap[e],s.data={},s.complete=!1,s.instance=void 0}}))}registerResourceType(e,t=e){if(exports.RESOURCE_TYPE[e])throw new Error(`The type ${e} already exists in RESOURCE_TYPE`);exports.RESOURCE_TYPE[e]=t}registerInstance(e,t){this.makeInstanceFunctions[e]=t}registerDestroy(e,t){this.destroyInstanceFunctions[e]=t}loadResource({names:e=[],preload:t=!1}){const s=e.filter((e=>!this.promiseMap[e]&&this.resourcesMap[e]));if(!s.length)return;const o={};s.forEach((e=>{var s;this.promiseMap[e]=new Promise((t=>o[e]=t));const n=this.resourcesMap[e];for(const e of this.preProcessResourceHandlers)e(n);for(const i in n.src){if("data"===n.src[i].type)n.data[i]=n.src[i].data,this.doComplete(e,o[e],t);else{let a=null===(s=n.src[i])||void 0===s?void 0:s.url;"string"==typeof a&&a.startsWith("//")&&(a=`${window.location.protocol}${n.src[i].url}`),"atlas"===i?r.Assets.add({alias:a,src:a,data:{resolve:()=>r.Assets.load(n.src.image.url)}}):r.Assets.add({alias:a,src:a}),r.Assets.load(a).then((s=>{this.onLoad({preload:t,resource:{metadata:{key:i,name:e,resolves:o},data:s}})})).catch((s=>{console.log(">>>E",s),this.onError({preload:t,errMsg:s.message,resource:{metadata:{key:i,name:e,resolves:o}}})}))}}}))}doComplete(e,t,s=!1){return v(this,void 0,void 0,(function*(){const r=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0};if(this.checkAllLoaded(e))try{r.instance=yield this.instance(e),r.complete=!0,s&&this.progress.onProgress(o),t(r)}catch(e){console.error(e),r.complete=!1,s&&(o.errMsg=e.message,o.success=!1,this.progress.onProgress(o)),t({})}}))}checkAllLoaded(e){const t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((e=>t.data[e]))}getLoader(e=!1){}onLoad({preload:e=!1,resource:t}){return v(this,void 0,void 0,(function*(){const{metadata:{key:s,name:r,resolves:o},data:n}=t;this.resourcesMap[r].data[s]=n,this.doComplete(r,o[r],e)}))}onError({errMsg:e,preload:t=!1,resource:s}){return v(this,void 0,void 0,(function*(){const{metadata:{name:r,resolves:o}}=s;if(this._destroy(r,!0),o[r]({}),t){const t={name:r,resource:this.resourcesMap[r],success:!1,errMsg:e};this.progress.onProgress(t)}}))}},q={IDEProp:L,componentObserver:V},H="2.0.0-beta.10";console.log(`Eva.js version: ${H}`);exports.Component=m,exports.Game=I,exports.GameObject=T,exports.IDEProp=L,exports.RESOURCE_TYPE_STRATEGY={},exports.Scene=D,exports.System=S,exports.Transform=b,exports.componentObserver=V,exports.decorators=q,exports.resource=Y,exports.resourceLoader=G,exports.version=H; | ||
function E(e,t,s,r){var o,n=arguments.length,i=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,s,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,s,i):o(t,s))||i);return n>3&&i&&Object.defineProperty(t,s,i),i}function v(e,t,s,r){return new(s||(s=Promise))((function(o,n){function i(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){e.done?o(e.value):new s((function(t){t(e.value)})).then(i,a)}c((r=r.apply(e,t||[])).next())}))}class _ extends m{constructor(){super(...arguments),this.name="Transform",this._parent=null,this.inScene=!1,this.children=[],this.position={x:0,y:0},this.size={width:0,height:0},this.origin={x:0,y:0},this.anchor={x:0,y:0},this.scale={x:1,y:1},this.skew={x:0,y:0},this.rotation=0}init(e={}){const t=["position","size","origin","anchor","scale","skew"];for(const s of t)Object.assign(this[s],e[s]);this.rotation=e.rotation||this.rotation}set parent(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)}get parent(){return this._parent}addChild(e){if(e.parent===this){const t=this.children.findIndex((t=>t===e));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)}removeChild(e){const t=this.children.findIndex((t=>t===e));t>-1&&(this.children.splice(t,1),e._parent=null)}clearChildren(){this.children.length=0}}_.componentName="Transform",E([s.type("vector2"),s.step(1)],_.prototype,"position",void 0),E([s.type("size"),s.step(1)],_.prototype,"size",void 0),E([s.type("vector2"),s.step(.1)],_.prototype,"origin",void 0),E([s.type("vector2"),s.step(.1)],_.prototype,"anchor",void 0),E([s.type("vector2"),s.step(.1)],_.prototype,"scale",void 0),E([s.type("vector2"),s.step(.1)],_.prototype,"skew",void 0),E([s.type("number"),s.step(.1)],_.prototype,"rotation",void 0);var b=_;let R=0;class O{constructor(e,t){this._componentCache={},this.components=[],this.destroyed=!1,this._name=e,this.id=++R,this.addComponent(b,t)}get transform(){return this.getComponent(b)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get name(){return this._name}set scene(e){if(this._scene===e)return;const t=this._scene;if(this._scene=e,this.transform&&this.transform.children)for(const t of this.transform.children)t.gameObject.scene=e;e?e.addGameObject(this):t&&t.removeGameObject(this)}get scene(){return this._scene}addChild(e){if(e&&e.transform&&e!==this){if(!(e instanceof O))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error(`gameObject '${this.name}' has been destroy`);e.transform.parent=this.transform,e.scene=this.scene}}removeChild(e){return e instanceof O&&e.parent&&e.parent===this?(e.transform.parent=null,e.scene=null,e):e}addComponent(e,t){if(this.destroyed)return;const s=function(e){return e instanceof a?e.name:e instanceof Function?e.componentName:void 0}(e);if(this._componentCache[s])return;let r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof m))throw new Error("addComponent recieve Component and Component Constructor");r=e}if(r.gameObject)throw new Error(`component has been added on gameObject ${r.gameObject.name}`);return r.gameObject=this,r.init&&r.init(r.__componentDefaultParams),function(e,t=e.name){var s,r;for(const o in l)(l[o]||{})[t]&&(null===(r=null===(s=p[o])||void 0===s?void 0:s.componentObserver)||void 0===r||r.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t}))}(r,r.name),function(e,t=e.name){if(t&&u[t]){if(!(e&&(s=e,s&&s.constructor&&"componentName"in s.constructor)))throw new Error("component param must be an instance of Component");var s;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");for(const s of u[t]){const{property:r,key:o}=d(e,s.prop);y({obj:r,key:o,prop:s,component:e,componentName:t})}}}(r,r.name),this.components.push(r),this._componentCache[s]=r,r.awake&&r.awake(),r}removeComponent(e){let t;if("string"==typeof e?t=e:e instanceof m?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)}_removeComponent(e){const t=this.components.findIndex((({name:t})=>t===e));if(-1===t)return;const s=this.components.splice(t,1)[0];return delete this._componentCache[e],delete s.__componentDefaultParams,s.onDestroy&&s.onDestroy(),g(s,e),s.gameObject=void 0,s}getComponent(e){let t;return"string"==typeof e?t=e:e instanceof m?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0}remove(){if(this.parent)return this.parent.removeChild(this)}destroy(){if(this.transform){Array.from(this.transform.children).forEach((({gameObject:e})=>{e.destroy()})),this.remove(),this.transform.clearChildren();for(const e in this._componentCache)this._removeComponent(e);this.components.length=0,this.destroyed=!0}else console.error("Cannot destroy gameObject that have already been destroyed.")}}var T=O;var k=class{constructor(){this.events=[]}add({component:e,prop:s,type:r,componentName:o}){if(r===exports.OBSERVER_TYPE.REMOVE){if(this.events.find((t=>t.component===e&&t.type===exports.OBSERVER_TYPE.ADD)))return void(this.events=this.events.filter((t=>t.component!==e)));this.events=this.events.filter((t=>t.component!==e))}const n=this.events.findIndex((o=>o.component===e&&t.isEqual(o.prop,s)&&o.type===r));n>-1&&this.events.splice(n,1),this.events.push({gameObject:e.gameObject,component:e,prop:s,type:r,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const e=this.events;return this.events=[],e}};var S=class{constructor(e){this.started=!1,this.componentObserver=new k,this.__systemDefaultParams=e,this.name=this.constructor.systemName}destroy(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)}};const C=function(){let e=null;return e=Date.now?Date.now:()=>(new Date).getTime(),e}(),M={originTime:0,playbackRate:1};class x{constructor(e,t){e instanceof x&&(t=e,e={}),e=Object.assign({},M,e),t&&(this._parent=t),this._createTime=C(),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}get globalTime(){return this.parent?this.parent.currentTime:C()-this._createTime}get parent(){return this._parent}get lastTimeMark(){return this._timeMark[this._timeMark.length-1]}markTime({time:e=this.currentTime,entropy:t=this.entropy,playbackRate:s=this.playbackRate}={}){const r={globalTime:this.globalTime,localTime:e,entropy:t,playbackRate:s,globalEntropy:this.globalEntropy};this._timeMark.push(r)}get currentTime(){const{localTime:e,globalTime:t}=this.lastTimeMark;return e+(this.globalTime-t)*this.playbackRate}set currentTime(e){this.markTime({time:e})}get globalEntropy(){return this._parent?this._parent.entropy:this.globalTime}get entropy(){const{entropy:e,globalEntropy:t}=this.lastTimeMark;return e+Math.abs((this.globalEntropy-t)*this.playbackRate)}set entropy(e){if(this.entropy>e){const t=this.seekTimeMark(e);this._timeMark.length=t+1}this.markTime({entropy:e})}fork(e){return new x(e,this)}seekGlobalTime(e){const t=this.seekTimeMark(e),s=this._timeMark[t],{entropy:r,playbackRate:o,globalTime:n}=s;return n+(e-r)/Math.abs(o)}seekLocalTime(e){const t=this.seekTimeMark(e),s=this._timeMark[t],{localTime:r,entropy:o,playbackRate:n}=s;return n>0?r+(e-o):r-(e-o)}seekTimeMark(e){const t=this._timeMark;let s=0,r=t.length-1;if(e<=t[s].entropy)return s;if(e>=t[r].entropy)return r;let o=Math.floor((s+r)/2);for(;o>s&&o<r;){if(e===t[o].entropy)return o;e<t[o].entropy?r=o:e>t[o].entropy&&(s=o),o=Math.floor((s+r)/2)}return s}get playbackRate(){return this._playbackRate}set playbackRate(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this._playbackRate=e)}get paused(){if(0===this.playbackRate)return!0;let e=this.parent;for(;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1}}var N=x;const P={autoStart:!0,frameRate:60};var A=class{constructor(e){e=Object.assign({},P,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new N({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=()=>{this._started&&(this._requestId=requestAnimationFrame(this._ticker),this.update())},this.autoStart&&this.start()}update(){const e=this.timeline.currentTime,t=e-this._lastFrameTime;if(t>=this._frameDuration){const s=e-t%this._frameDuration,r=s-this._lastFrameTime;this._lastFrameTime=s;const o={deltaTime:r,time:s,currentTime:s,frameCount:++this._frameCount,fps:Math.round(1e3/r)};for(const e of this._tickers)"function"==typeof e&&e(o)}}add(e){this._tickers.add(e)}remove(e){this._tickers.delete(e)}start(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))}pause(){this._started=!1,this.timeline.playbackRate=0}setPlaybackRate(e){this.timeline.playbackRate=e}};var j,D=class extends T{constructor(e,t){super(e,t),this.gameObjects=[],this.scene=this}addGameObject(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)}removeGameObject(e){const t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null}};exports.LOAD_SCENE_MODE=void 0,(j=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",j.MULTI_CANVAS="MULTI_CANVAS";const w=e=>{if((e instanceof S||e instanceof m)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof m?console.error(`${e.constructor.componentName} start error`,t):console.error(`${e.constructor.systemName} start error`,t)}}};var I=class extends i{constructor(){super(...arguments),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[]}init({systems:e,frameRate:t=60,autoStart:s=!0,needScene:r=!0}={}){return v(this,void 0,void 0,(function*(){if(window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new A({autoStart:!1,frameRate:t}),this.initTicker(),e&&e.length)for(const t of e)yield this.addSystem(t);r&&this.loadScene(new D("scene")),s&&this.start()}))}get scene(){return this._scene}set scene(e){this._scene=e}get gameObjects(){return(e=>{var t;const s=(null===(t=null==e?void 0:e.scene)||void 0===t?void 0:t.gameObjects)||[],r=null==e?void 0:e.multiScenes.map((({gameObjects:e})=>e));let o=[];for(const e of r)o=[...o,...e];return[...s,...o]})(this)}addSystem(e,s){return v(this,void 0,void 0,(function*(){let r;if(e instanceof Function)r=new e(s);else{if(!(e instanceof S))return void console.warn("can only add System");r=e}if(!this.systems.find((e=>e.constructor===r.constructor))){r.game=this,r.init&&(yield r.init(r.__systemDefaultParams)),function(e,t){l[t.systemName]=t.observerInfo,p[t.systemName]=e}(r,r.constructor),function(e){const s=[];e instanceof Array?s.push(...e):s.push(e);for(const e of s)for(const s in e.observerInfo){u[s]=u[s]||[];const r=u[s];for(const o of e.observerInfo[s])-1===r.findIndex((e=>t.isEqual(e,o)))&&u[s].push(o)}}(r.constructor);try{r.awake&&r.awake()}catch(e){console.error(`${r.constructor.systemName} awake error`,e)}return this.systems.push(r),r}console.warn(`${r.constructor.systemName} System has been added`)}))}removeSystem(e){if(!e)return;let t=-1;"string"==typeof e?t=this.systems.findIndex((t=>t.name===e)):e instanceof Function?t=this.systems.findIndex((t=>t.constructor===e)):e instanceof S&&(t=this.systems.findIndex((t=>t===e))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}getSystem(e){return this.systems.find((t=>"string"==typeof e?t.name===e:t instanceof e))}pause(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())}start(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())}resume(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())}initTicker(){this.ticker.add((e=>{this.scene&&((e,t=[])=>{for(const s of t)for(const t of s.components)try{w(t),t.update&&t.update(e)}catch(e){console.error(`gameObject: ${s.name} ${t.name} update error`,e)}for(const s of t)for(const t of s.components)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`gameObject: ${s.name} ${t.name} lateUpdate error`,e)}})(e,this.gameObjects);for(const t of this.systems)try{w(t),t.update&&t.update(e)}catch(e){console.error(`${t.constructor.systemName} update error`,e)}for(const t of this.systems)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`${t.constructor.systemName} lateUpdate error`,e)}}))}triggerResume(){(e=>{for(const t of e)for(const e of t.components)try{e.onResume&&e.onResume()}catch(s){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,s)}})(this.gameObjects);for(const e of this.systems)try{e.onResume&&e.onResume()}catch(t){console.error(`${e.constructor.systemName}, onResume error`,t)}}triggerPause(){(e=>{for(const t of e)for(const e of t.components)try{e.onPause&&e.onPause()}catch(s){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,s)}})(this.gameObjects);for(const e of this.systems)try{e.onPause&&e.onPause()}catch(t){console.error(`${e.constructor.systemName}, onPause error`,t)}}destroySystems(){for(const e of[...this.systems])this.removeSystem(e);this.systems.length=0}destroy(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:e,mode:t=exports.LOAD_SCENE_MODE.SINGLE,params:s={}}){if(e){switch(t){case exports.LOAD_SCENE_MODE.SINGLE:this.scene=e;break;case exports.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(e)}this.emit("sceneChanged",{scene:e,mode:t,params:s})}}};function L(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function V(e={}){return function(t){if(!t.observerInfo){for(const t in e)for(const s in e[t]){let r;"string"==typeof e[t][s]&&(e[t][s]=[e[t][s]]),Array.isArray(e[t][s])&&(r={prop:e[t][s],deep:!1},e[t][s]=r),r=e[t][s],"string"==typeof r.prop&&(r.prop=[r.prop])}t.observerInfo=e}}}class $ extends i{constructor({resource:e,resourceTotal:t}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=e,this.resourceTotal=t,0===t&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(exports.LOAD_EVENT.START,this)}onProgress(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)}}const G={AbstractLoadStrategy:o.AbstractLoadStrategy,AudioLoadStrategy:o.AudioLoadStrategy,ImageLoadStrategy:o.ImageLoadStrategy,XhrResponseType:o.XhrResponseType,MediaElementLoadStrategy:o.MediaElementLoadStrategy,VideoLoadStrategy:o.VideoLoadStrategy,Loader:o.Loader,Resource:o.Resource,ResourceType:o.ResourceType,ResourceState:o.ResourceState};var F,U;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";const Y=new class extends i{constructor(e){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},e&&"number"==typeof e.timeout&&(this.timeout=e.timeout)}loadConfig(e){this.addResource(e),this.preload()}loadSingle(e){return this.addResource([e]),this.getResource(e.name)}addResource(e){if(!e||e.length<1)console.warn("no resources");else for(const t of e)this.resourcesMap[t.name]?console.warn(t.name+" was already added"):(this.resourcesMap[t.name]=t,this.resourcesMap[t.name].data={})}addPreProcessResourceHandler(e){this.preProcessResourceHandlers.push(e)}removePreProcessResourceHandler(e){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(e),1)}preload(){const e=[];for(const t in this.resourcesMap){const s=this.resourcesMap[t];!s.preload||s.complete||this.promiseMap[t]||e.push(s.name)}this.progress=new $({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})}getResource(e){return v(this,void 0,void 0,(function*(){return this.loadResource({names:[e]}),this.promiseMap[e]||Promise.resolve({})}))}instance(e){return v(this,void 0,void 0,(function*(){const t=this.resourcesMap[e];return this.makeInstanceFunctions[t.type]&&(yield this.makeInstanceFunctions[t.type](t))}))}destroy(e){return v(this,void 0,void 0,(function*(){yield this._destroy(e)}))}_destroy(e,t=!1){return v(this,void 0,void 0,(function*(){const s=this.resourcesMap[e];if(s){if(!t)try{this.destroyInstanceFunctions[s.type]&&(yield this.destroyInstanceFunctions[s.type](s))}catch(e){console.warn(`destroy resource ${s.name} error with '${e.message}'`)}delete this.promiseMap[e],s.data={},s.complete=!1,s.instance=void 0}}))}registerResourceType(e,t=e){if(exports.RESOURCE_TYPE[e])throw new Error(`The type ${e} already exists in RESOURCE_TYPE`);exports.RESOURCE_TYPE[e]=t}registerInstance(e,t){this.makeInstanceFunctions[e]=t}registerDestroy(e,t){this.destroyInstanceFunctions[e]=t}loadResource({names:e=[],preload:t=!1}){const s=e.filter((e=>!this.promiseMap[e]&&this.resourcesMap[e]));if(!s.length)return;const o={};s.forEach((e=>{var s;this.promiseMap[e]=new Promise((t=>o[e]=t));const n=this.resourcesMap[e];for(const e of this.preProcessResourceHandlers)e(n);for(const i in n.src){if("data"===n.src[i].type)n.data[i]=n.src[i].data,this.doComplete(e,o[e],t);else{let a=null===(s=n.src[i])||void 0===s?void 0:s.url;"string"==typeof a&&a.startsWith("//")&&(a=`${window.location.protocol}${n.src[i].url}`),"atlas"===i?r.Assets.add({alias:a,src:a,data:{resolve:()=>r.Assets.load(n.src.image.url)}}):r.Assets.add({alias:a,src:a}),r.Assets.load(a).then((s=>{this.onLoad({preload:t,resource:{metadata:{key:i,name:e,resolves:o},data:s}})})).catch((s=>{console.log(">>>E",s),this.onError({preload:t,errMsg:s.message,resource:{metadata:{key:i,name:e,resolves:o}}})}))}}}))}doComplete(e,t,s=!1){return v(this,void 0,void 0,(function*(){const r=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0};if(this.checkAllLoaded(e))try{r.instance=yield this.instance(e),r.complete=!0,s&&this.progress.onProgress(o),t(r)}catch(e){console.error(e),r.complete=!1,s&&(o.errMsg=e.message,o.success=!1,this.progress.onProgress(o)),t({})}}))}checkAllLoaded(e){const t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((e=>t.data[e]))}getLoader(e=!1){}onLoad({preload:e=!1,resource:t}){return v(this,void 0,void 0,(function*(){const{metadata:{key:s,name:r,resolves:o},data:n}=t;this.resourcesMap[r].data[s]=n,this.doComplete(r,o[r],e)}))}onError({errMsg:e,preload:t=!1,resource:s}){return v(this,void 0,void 0,(function*(){const{metadata:{name:r,resolves:o}}=s;if(this._destroy(r,!0),o[r]({}),t){const t={name:r,resource:this.resourcesMap[r],success:!1,errMsg:e};this.progress.onProgress(t)}}))}},q={IDEProp:L,componentObserver:V},H="2.0.0-beta.11";console.log(`Eva.js version: ${H}`);exports.Component=m,exports.Game=I,exports.GameObject=T,exports.IDEProp=L,exports.RESOURCE_TYPE_STRATEGY={},exports.Scene=D,exports.System=S,exports.Transform=b,exports.componentObserver=V,exports.decorators=q,exports.resource=Y,exports.resourceLoader=G,exports.version=H; |
@@ -451,4 +451,4 @@ import { AbstractLoadStrategy } from 'resource-loader'; | ||
export declare const version = "2.0.0-beta.10"; | ||
export declare const version = "2.0.0-beta.11"; | ||
export { } |
@@ -1382,3 +1382,3 @@ import EventEmitter from 'eventemitter3'; | ||
}; | ||
const version = '2.0.0-beta.10'; | ||
const version = '2.0.0-beta.11'; | ||
console.log(`Eva.js version: ${version}`); | ||
@@ -1385,0 +1385,0 @@ const RESOURCE_TYPE_STRATEGY = {}; |
@@ -1,1 +0,1 @@ | ||
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},_extends.apply(null,arguments)}var _EVA_IIFE_EVA=function(t,e){"use strict";var r=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 s(t,e,n,s,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,s||t,i),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 i(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,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i},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,s,i){var a=r?r+t:t;if(!this._events[a])return!1;var c,u,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,o),!0;case 5:return h.fn.call(h.context,e,n,o,s),!0;case 6:return h.fn.call(h.context,e,n,o,s,i),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];h.fn.apply(h.context,c)}else{var p,d=h.length;for(u=0;u<d;u++)switch(h[u].once&&this.removeListener(t,h[u].fn,void 0,!0),l){case 1:h[u].fn.call(h[u].context);break;case 2:h[u].fn.call(h[u].context,e);break;case 3:h[u].fn.call(h[u].context,e,n);break;case 4:h[u].fn.call(h[u].context,e,n,o);break;default:if(!c)for(p=1,c=new Array(l-1);p<l;p++)c[p-1]=arguments[p];h[u].fn.apply(h[u].context,c)}}return!0},a.prototype.on=function(t,e,r){return s(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return s(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var s=r?r+t:t;if(!this._events[s])return this;if(!e)return i(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||i(this,s);else{for(var c=0,u=[],h=a.length;c<h;c++)(a[c].fn!==e||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&i(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})),n=r;class o extends n{constructor(t){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=t}}var s=o,i="object"==typeof global&&global&&global.Object===Object&&global,a="object"==typeof self&&self&&self.Object===Object&&self,c=i||a||Function("return this")(),u=c.Symbol,h=Object.prototype,l=h.hasOwnProperty,p=h.toString,d=u?u.toStringTag:void 0;var f=Object.prototype.toString;var m=u?u.toStringTag:void 0;function _(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":m&&m in Object(t)?function(t){var e=l.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=p.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return f.call(t)}(t)}function y(t){return null!=t&&"object"==typeof t}var v=Array.isArray;function g(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function b(t){if(!g(t))return!1;var e=_(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var E,O=c["__core-js_shared__"],w=(E=/[^.]+$/.exec(O&&O.keys&&O.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"";var T=Function.prototype.toString;function j(t){if(null!=t){try{return T.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var k=/^\[object .+?Constructor\]$/,A=Function.prototype,x=Object.prototype,R=A.toString,C=x.hasOwnProperty,S=RegExp("^"+R.call(C).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function P(t){return!(!g(t)||(e=t,w&&w in e))&&(b(t)?S:k).test(j(t));var e}function L(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return P(r)?r:void 0}var M=L(c,"WeakMap"),D=/^(?:0|[1-9]\d*)$/;function I(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&D.test(t))&&t>-1&&t%1==0&&t<e}function N(t,e){return t===e||t!=t&&e!=e}function B(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var V=Object.prototype;function U(t){return y(t)&&"[object Arguments]"==_(t)}var $=Object.prototype,q=$.hasOwnProperty,F=$.propertyIsEnumerable,z=U(function(){return arguments}())?U:function(t){return y(t)&&q.call(t,"callee")&&!F.call(t,"callee")},G=z;var Y="object"==typeof t&&t&&!t.nodeType&&t,H=Y&&"object"==typeof module&&module&&!module.nodeType&&module,X=H&&H.exports===Y?c.Buffer:void 0,J=(X?X.isBuffer:void 0)||function(){return!1},Q={};Q["[object Float32Array]"]=Q["[object Float64Array]"]=Q["[object Int8Array]"]=Q["[object Int16Array]"]=Q["[object Int32Array]"]=Q["[object Uint8Array]"]=Q["[object Uint8ClampedArray]"]=Q["[object Uint16Array]"]=Q["[object Uint32Array]"]=!0,Q["[object Arguments]"]=Q["[object Array]"]=Q["[object ArrayBuffer]"]=Q["[object Boolean]"]=Q["[object DataView]"]=Q["[object Date]"]=Q["[object Error]"]=Q["[object Function]"]=Q["[object Map]"]=Q["[object Number]"]=Q["[object Object]"]=Q["[object RegExp]"]=Q["[object Set]"]=Q["[object String]"]=Q["[object WeakMap]"]=!1;var W,K="object"==typeof t&&t&&!t.nodeType&&t,Z=K&&"object"==typeof module&&module&&!module.nodeType&&module,tt=Z&&Z.exports===K&&i.process,et=function(){try{var t=Z&&Z.require&&Z.require("util").types;return t||tt&&tt.binding&&tt.binding("util")}catch(t){}}(),rt=et&&et.isTypedArray,nt=rt?(W=rt,function(t){return W(t)}):function(t){return y(t)&&B(t.length)&&!!Q[_(t)]},ot=Object.prototype.hasOwnProperty;function st(t,e){var r=v(t),n=!r&&G(t),o=!r&&!n&&J(t),s=!r&&!n&&!o&&nt(t),i=r||n||o||s,a=i?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&&!ot.call(t,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||I(u,c))||a.push(u);return a}var it=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),at=it,ct=Object.prototype.hasOwnProperty;function ut(t){if(r=(e=t)&&e.constructor,e!==("function"==typeof r&&r.prototype||V))return at(t);var e,r,n=[];for(var o in Object(t))ct.call(t,o)&&"constructor"!=o&&n.push(o);return n}function ht(t){return null!=(e=t)&&B(e.length)&&!b(e)?st(t):ut(t);var e}var lt=L(Object,"create");var pt=Object.prototype.hasOwnProperty;var dt=Object.prototype.hasOwnProperty;function ft(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 mt(t,e){for(var r=t.length;r--;)if(N(t[r][0],e))return r;return-1}ft.prototype.clear=function(){this.__data__=lt?lt(null):{},this.size=0},ft.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ft.prototype.get=function(t){var e=this.__data__;if(lt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return pt.call(e,t)?e[t]:void 0},ft.prototype.has=function(t){var e=this.__data__;return lt?void 0!==e[t]:dt.call(e,t)},ft.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=lt&&void 0===e?"__lodash_hash_undefined__":e,this};var _t=Array.prototype.splice;function yt(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])}}yt.prototype.clear=function(){this.__data__=[],this.size=0},yt.prototype.delete=function(t){var e=this.__data__,r=mt(e,t);return!(r<0)&&(r==e.length-1?e.pop():_t.call(e,r,1),--this.size,!0)},yt.prototype.get=function(t){var e=this.__data__,r=mt(e,t);return r<0?void 0:e[r][1]},yt.prototype.has=function(t){return mt(this.__data__,t)>-1},yt.prototype.set=function(t,e){var r=this.__data__,n=mt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var vt=L(c,"Map");function gt(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 bt(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])}}bt.prototype.clear=function(){this.size=0,this.__data__={hash:new ft,map:new(vt||yt),string:new ft}},bt.prototype.delete=function(t){var e=gt(this,t).delete(t);return this.size-=e?1:0,e},bt.prototype.get=function(t){return gt(this,t).get(t)},bt.prototype.has=function(t){return gt(this,t).has(t)},bt.prototype.set=function(t,e){var r=gt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Et(t){var e=this.__data__=new yt(t);this.size=e.size}Et.prototype.clear=function(){this.__data__=new yt,this.size=0},Et.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Et.prototype.get=function(t){return this.__data__.get(t)},Et.prototype.has=function(t){return this.__data__.has(t)},Et.prototype.set=function(t,e){var r=this.__data__;if(r instanceof yt){var n=r.__data__;if(!vt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new bt(n)}return r.set(t,e),this.size=r.size,this};var Ot=Object.prototype.propertyIsEnumerable,wt=Object.getOwnPropertySymbols,Tt=wt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,s=[];++r<n;){var i=t[r];e(i,r,t)&&(s[o++]=i)}return s}(wt(t),(function(e){return Ot.call(t,e)})))}:function(){return[]};function jt(t){return function(t,e,r){var n=e(t);return v(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,ht,Tt)}var kt=L(c,"DataView"),At=L(c,"Promise"),xt=L(c,"Set"),Rt="[object Map]",Ct="[object Promise]",St="[object Set]",Pt="[object WeakMap]",Lt="[object DataView]",Mt=j(kt),Dt=j(vt),It=j(At),Nt=j(xt),Bt=j(M),Vt=_;(kt&&Vt(new kt(new ArrayBuffer(1)))!=Lt||vt&&Vt(new vt)!=Rt||At&&Vt(At.resolve())!=Ct||xt&&Vt(new xt)!=St||M&&Vt(new M)!=Pt)&&(Vt=function(t){var e=_(t),r="[object Object]"==e?t.constructor:void 0,n=r?j(r):"";if(n)switch(n){case Mt:return Lt;case Dt:return Rt;case It:return Ct;case Nt:return St;case Bt:return Pt}return e});var Ut=Vt,$t=c.Uint8Array;function qt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new bt;++e<r;)this.add(t[e])}function Ft(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}qt.prototype.add=qt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},qt.prototype.has=function(t){return this.__data__.has(t)};function zt(t,e,r,n,o,s){var i=1&r,a=t.length,c=e.length;if(a!=c&&!(i&&c>a))return!1;var u=s.get(t),h=s.get(e);if(u&&h)return u==e&&h==t;var l=-1,p=!0,d=2&r?new qt:void 0;for(s.set(t,e),s.set(e,t);++l<a;){var f=t[l],m=e[l];if(n)var _=i?n(m,f,l,e,t,s):n(f,m,l,t,e,s);if(void 0!==_){if(_)continue;p=!1;break}if(d){if(!Ft(e,(function(t,e){if(i=e,!d.has(i)&&(f===t||o(f,t,r,n,s)))return d.push(e);var i}))){p=!1;break}}else if(f!==m&&!o(f,m,r,n,s)){p=!1;break}}return s.delete(t),s.delete(e),p}function Gt(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function Yt(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var Ht=u?u.prototype:void 0,Xt=Ht?Ht.valueOf:void 0;var Jt=Object.prototype.hasOwnProperty;var Qt,Wt="[object Arguments]",Kt="[object Array]",Zt="[object Object]",te=Object.prototype.hasOwnProperty;function ee(t,e,r,n,o,s){var i=v(t),a=v(e),c=i?Kt:Ut(t),u=a?Kt:Ut(e),h=(c=c==Wt?Zt:c)==Zt,l=(u=u==Wt?Zt:u)==Zt,p=c==u;if(p&&J(t)){if(!J(e))return!1;i=!0,h=!1}if(p&&!h)return s||(s=new Et),i||nt(t)?zt(t,e,r,n,o,s):function(t,e,r,n,o,s,i){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||!s(new $t(t),new $t(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return N(+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=Gt;case"[object Set]":var c=1&n;if(a||(a=Yt),t.size!=e.size&&!c)return!1;var u=i.get(t);if(u)return u==e;n|=2,i.set(t,e);var h=zt(a(t),a(e),n,o,s,i);return i.delete(t),h;case"[object Symbol]":if(Xt)return Xt.call(t)==Xt.call(e)}return!1}(t,e,c,r,n,o,s);if(!(1&r)){var d=h&&te.call(t,"__wrapped__"),f=l&&te.call(e,"__wrapped__");if(d||f){var m=d?t.value():t,_=f?e.value():e;return s||(s=new Et),o(m,_,r,n,s)}}return!!p&&(s||(s=new Et),function(t,e,r,n,o,s){var i=1&r,a=jt(t),c=a.length;if(c!=jt(e).length&&!i)return!1;for(var u=c;u--;){var h=a[u];if(!(i?h in e:Jt.call(e,h)))return!1}var l=s.get(t),p=s.get(e);if(l&&p)return l==e&&p==t;var d=!0;s.set(t,e),s.set(e,t);for(var f=i;++u<c;){var m=t[h=a[u]],_=e[h];if(n)var y=i?n(_,m,h,e,t,s):n(m,_,h,t,e,s);if(!(void 0===y?m===_||o(m,_,r,n,s):y)){d=!1;break}f||(f="constructor"==h)}if(d&&!f){var v=t.constructor,g=e.constructor;v==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof g&&g instanceof g||(d=!1)}return s.delete(t),s.delete(e),d}(t,e,r,n,o,s))}function re(t,e,r,n,o){return t===e||(null==t||null==e||!y(t)&&!y(e)?t!=t&&e!=e:ee(t,e,r,n,re,o))}function ne(t,e){return re(t,e)}t.OBSERVER_TYPE=void 0,(Qt=t.OBSERVER_TYPE||(t.OBSERVER_TYPE={})).ADD="ADD",Qt.REMOVE="REMOVE",Qt.CHANGE="CHANGE";const oe={},se={},ie={},ae={};function ce(t,e){oe[t.gameObject.id]||(oe[t.gameObject.id]={});const r=oe[t.gameObject.id],n=t.name+"_"+e.join(",");if(r[n])return r[n];const o=e.length-1;let s=t;for(let t=0;t<o;t++)s=s[e[t]];return r[n]={property:s,key:e[o]},r[n]}function ue({systemName:t,componentName:e,component:r,prop:n,type:o}){var s,i;null===(i=null===(s=se[t])||void 0===s?void 0:s.componentObserver)||void 0===i||i.add({component:r,prop:n,type:o,componentName:e})}function he({obj:e,key:r,prop:n,component:o,componentName:s}){if(void 0!==e)if(r in e){if(Object.defineProperty(e,`_${r}`,{enumerable:!1,writable:!0,value:e[r]}),n.deep&&g(e[r]))for(const t of Object.keys(e[r]))he({obj:e[r],key:t,prop:n,component:o,componentName:s});Object.defineProperty(e,r,{enumerable:!0,set(i){e[`_${r}`]!==i&&(e[`_${r}`]=i,function({prop:e,component:r,componentName:n}){for(const o in ie){const s=(ie[o]||{})[n];s&&(s.findIndex((t=>ne(t,e)))>-1&&ue({systemName:o,componentName:n,component:r,prop:e,type:t.OBSERVER_TYPE.CHANGE}))}}({prop:n,component:o,componentName:s}))},get:()=>e[`_${r}`]})}else console.error(`prop ${r} not in component: ${s}, Can not observer`)}function le(e,r=e.name){var n,o;for(const s in ie){(ie[s]||{})[r]&&(null===(o=null===(n=se[s])||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 oe[t.gameObject.id]}(e)}function pe(t,e,r,n){var o,s=arguments.length,i=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(i=(s<3?o(i):s>3?o(e,r,i):o(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i}function de(t,e,r,n){return new(r||(r=Promise))((function(o,s){function i(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(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(i,a)}c((n=n.apply(t,e||[])).next())}))}function fe(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function me(t){return function(e,r){var n=fe(e,r);n.key=r,n.type=t}}function _e(t){return function(e,r){fe(e,r).step=t}}class ye extends s{constructor(){super(...arguments),this.name="Transform",this._parent=null,this.inScene=!1,this.children=[],this.position={x:0,y:0},this.size={width:0,height:0},this.origin={x:0,y:0},this.anchor={x:0,y:0},this.scale={x:1,y:1},this.skew={x:0,y:0},this.rotation=0}init(t={}){const e=["position","size","origin","anchor","scale","skew"];for(const r of e)_extends(this[r],t[r]);this.rotation=t.rotation||this.rotation}set parent(t){t?t.addChild(this):this.parent&&this.parent.removeChild(this)}get parent(){return this._parent}addChild(t){if(t.parent===this){const e=this.children.findIndex((e=>e===t));this.children.splice(e,1)}else t.parent&&t.parent.removeChild(t);t._parent=this,this.children.push(t)}removeChild(t){const e=this.children.findIndex((e=>e===t));e>-1&&(this.children.splice(e,1),t._parent=null)}clearChildren(){this.children.length=0}}ye.componentName="Transform",pe([me("vector2"),_e(1)],ye.prototype,"position",void 0),pe([me("size"),_e(1)],ye.prototype,"size",void 0),pe([me("vector2"),_e(.1)],ye.prototype,"origin",void 0),pe([me("vector2"),_e(.1)],ye.prototype,"anchor",void 0),pe([me("vector2"),_e(.1)],ye.prototype,"scale",void 0),pe([me("vector2"),_e(.1)],ye.prototype,"skew",void 0),pe([me("number"),_e(.1)],ye.prototype,"rotation",void 0);var ve=ye;let ge=0;class be{constructor(t,e){this._componentCache={},this.components=[],this.destroyed=!1,this._name=t,this.id=++ge,this.addComponent(ve,e)}get transform(){return this.getComponent(ve)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get name(){return this._name}set scene(t){if(this._scene===t)return;const e=this._scene;if(this._scene=t,this.transform&&this.transform.children)for(const e of this.transform.children)e.gameObject.scene=t;t?t.addGameObject(this):e&&e.removeGameObject(this)}get scene(){return this._scene}addChild(t){if(t&&t.transform&&t!==this){if(!(t instanceof be))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}}removeChild(t){return t instanceof be&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t}addComponent(e,r){if(this.destroyed)return;const n=function(t){return t instanceof o?t.name:t instanceof Function?t.componentName:void 0}(e);if(this._componentCache[n])return;let i;if(e instanceof Function)i=new e(r);else{if(!(e instanceof s))throw new Error("addComponent recieve Component and Component Constructor");i=e}if(i.gameObject)throw new Error(`component has been added on gameObject ${i.gameObject.name}`);return i.gameObject=this,i.init&&i.init(i.__componentDefaultParams),function(e,r=e.name){var n,o;for(const s in ie)(ie[s]||{})[r]&&(null===(o=null===(n=se[s])||void 0===n?void 0:n.componentObserver)||void 0===o||o.add({component:e,type:t.OBSERVER_TYPE.ADD,componentName:r}))}(i,i.name),function(t,e=t.name){if(e&&ae[e]){if(!(t&&(r=t,r&&r.constructor&&"componentName"in r.constructor)))throw new Error("component param must be an instance of Component");var r;if(!t.gameObject||!t.gameObject.id)throw new Error("component should be add to a gameObject");for(const r of ae[e]){const{property:n,key:o}=ce(t,r.prop);he({obj:n,key:o,prop:r,component:t,componentName:e})}}}(i,i.name),this.components.push(i),this._componentCache[n]=i,i.awake&&i.awake(),i}removeComponent(t){let e;if("string"==typeof t?e=t:t instanceof s?e=t.name:t.componentName&&(e=t.componentName),"Transform"===e)throw new Error("Transform can't be removed");return this._removeComponent(e)}_removeComponent(t){const e=this.components.findIndex((({name:e})=>e===t));if(-1===e)return;const r=this.components.splice(e,1)[0];return delete this._componentCache[t],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),le(r,t),r.gameObject=void 0,r}getComponent(t){let e;return"string"==typeof t?e=t:t instanceof s?e=t.name:t.componentName&&(e=t.componentName),void 0!==this._componentCache[e]?this._componentCache[e]:void 0}remove(){if(this.parent)return this.parent.removeChild(this)}destroy(){if(this.transform){Array.from(this.transform.children).forEach((({gameObject:t})=>{t.destroy()})),this.remove(),this.transform.clearChildren();for(const t in this._componentCache)this._removeComponent(t);this.components.length=0,this.destroyed=!0}else console.error("Cannot destroy gameObject that have already been destroyed.")}}var Ee=be;var Oe=class{constructor(){this.events=[]}add({component:e,prop:r,type:n,componentName:o}){if(n===t.OBSERVER_TYPE.REMOVE){if(this.events.find((r=>r.component===e&&r.type===t.OBSERVER_TYPE.ADD)))return void(this.events=this.events.filter((t=>t.component!==e)));this.events=this.events.filter((t=>t.component!==e))}const s=this.events.findIndex((t=>t.component===e&&ne(t.prop,r)&&t.type===n));s>-1&&this.events.splice(s,1),this.events.push({gameObject:e.gameObject,component:e,prop:r,type:n,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const t=this.events;return this.events=[],t}};var we=class{constructor(t){this.started=!1,this.componentObserver=new Oe,this.__systemDefaultParams=t,this.name=this.constructor.systemName}destroy(){var t;this.componentObserver=null,this.__systemDefaultParams=null,null===(t=this.onDestroy)||void 0===t||t.call(this)}};const Te=function(){let t=null;return t=Date.now?Date.now:()=>(new Date).getTime(),t}(),je={originTime:0,playbackRate:1};class ke{constructor(t,e){t instanceof ke&&(e=t,t={}),t=_extends({},je,t),e&&(this._parent=e),this._createTime=Te(),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}get globalTime(){return this.parent?this.parent.currentTime:Te()-this._createTime}get parent(){return this._parent}get lastTimeMark(){return this._timeMark[this._timeMark.length-1]}markTime({time:t=this.currentTime,entropy:e=this.entropy,playbackRate:r=this.playbackRate}={}){const n={globalTime:this.globalTime,localTime:t,entropy:e,playbackRate:r,globalEntropy:this.globalEntropy};this._timeMark.push(n)}get currentTime(){const{localTime:t,globalTime:e}=this.lastTimeMark;return t+(this.globalTime-e)*this.playbackRate}set currentTime(t){this.markTime({time:t})}get globalEntropy(){return this._parent?this._parent.entropy:this.globalTime}get entropy(){const{entropy:t,globalEntropy:e}=this.lastTimeMark;return t+Math.abs((this.globalEntropy-e)*this.playbackRate)}set entropy(t){if(this.entropy>t){const e=this.seekTimeMark(t);this._timeMark.length=e+1}this.markTime({entropy:t})}fork(t){return new ke(t,this)}seekGlobalTime(t){const e=this.seekTimeMark(t),r=this._timeMark[e],{entropy:n,playbackRate:o,globalTime:s}=r;return s+(t-n)/Math.abs(o)}seekLocalTime(t){const e=this.seekTimeMark(t),r=this._timeMark[e],{localTime:n,entropy:o,playbackRate:s}=r;return s>0?n+(t-o):n-(t-o)}seekTimeMark(t){const e=this._timeMark;let r=0,n=e.length-1;if(t<=e[r].entropy)return r;if(t>=e[n].entropy)return n;let o=Math.floor((r+n)/2);for(;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}get playbackRate(){return this._playbackRate}set playbackRate(t){t!==this.playbackRate&&(this.markTime({playbackRate:t}),this._playbackRate=t)}get paused(){if(0===this.playbackRate)return!0;let t=this.parent;for(;t;){if(0===t.playbackRate)return!0;t=t.parent}return!1}}var Ae=ke;const xe={autoStart:!0,frameRate:60};var Re=class{constructor(t){t=_extends({},xe,t),this._frameCount=0,this._frameDuration=1e3/t.frameRate,this.autoStart=t.autoStart,this.frameRate=t.frameRate,this.timeline=new Ae({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=()=>{this._started&&(this._requestId=requestAnimationFrame(this._ticker),this.update())},this.autoStart&&this.start()}update(){const t=this.timeline.currentTime,e=t-this._lastFrameTime;if(e>=this._frameDuration){const r=t-e%this._frameDuration,n=r-this._lastFrameTime;this._lastFrameTime=r;const o={deltaTime:n,time:r,currentTime:r,frameCount:++this._frameCount,fps:Math.round(1e3/n)};for(const t of this._tickers)"function"==typeof t&&t(o)}}add(t){this._tickers.add(t)}remove(t){this._tickers.delete(t)}start(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))}pause(){this._started=!1,this.timeline.playbackRate=0}setPlaybackRate(t){this.timeline.playbackRate=t}};var Ce,Se=class extends Ee{constructor(t,e){super(t,e),this.gameObjects=[],this.scene=this}addGameObject(t){this.gameObjects.push(t),t.transform&&(t.transform.inScene=!0)}removeGameObject(t){const e=this.gameObjects.indexOf(t);-1!==e&&(t.transform&&(t.transform.inScene=!1),this.gameObjects.splice(e,1))}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null}};t.LOAD_SCENE_MODE=void 0,(Ce=t.LOAD_SCENE_MODE||(t.LOAD_SCENE_MODE={})).SINGLE="SINGLE",Ce.MULTI_CANVAS="MULTI_CANVAS";const Pe=t=>{if((t instanceof we||t instanceof s)&&!t.started){t.started=!0;try{t.start&&t.start()}catch(e){t instanceof s?console.error(`${t.constructor.componentName} start error`,e):console.error(`${t.constructor.systemName} start error`,e)}}};var Le=class extends n{constructor(){super(...arguments),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[]}init({systems:t,frameRate:e=60,autoStart:r=!0,needScene:n=!0}={}){return de(this,void 0,void 0,(function*(){if(window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new Re({autoStart:!1,frameRate:e}),this.initTicker(),t&&t.length)for(const e of t)yield this.addSystem(e);n&&this.loadScene(new Se("scene")),r&&this.start()}))}get scene(){return this._scene}set scene(t){this._scene=t}get gameObjects(){return(t=>{var e;const r=(null===(e=null==t?void 0:t.scene)||void 0===e?void 0:e.gameObjects)||[],n=null==t?void 0:t.multiScenes.map((({gameObjects:t})=>t));let o=[];for(const t of n)o=[...o,...t];return[...r,...o]})(this)}addSystem(t,e){return de(this,void 0,void 0,(function*(){let 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((t=>t.constructor===r.constructor))){r.game=this,r.init&&(yield r.init(r.__systemDefaultParams)),function(t,e){ie[e.systemName]=e.observerInfo,se[e.systemName]=t}(r,r.constructor),function(t){const e=[];t instanceof Array?e.push(...t):e.push(t);for(const t of e)for(const e in t.observerInfo){ae[e]=ae[e]||[];const r=ae[e];for(const n of t.observerInfo[e])-1===r.findIndex((t=>ne(t,n)))&&ae[e].push(n)}}(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`)}))}removeSystem(t){if(!t)return;let e=-1;"string"==typeof t?e=this.systems.findIndex((e=>e.name===t)):t instanceof Function?e=this.systems.findIndex((e=>e.constructor===t)):t instanceof we&&(e=this.systems.findIndex((e=>e===t))),e>-1&&(this.systems[e].destroy&&this.systems[e].destroy(),this.systems.splice(e,1))}getSystem(t){return this.systems.find((e=>"string"==typeof t?e.name===t:e instanceof t))}pause(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())}start(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())}resume(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())}initTicker(){this.ticker.add((t=>{this.scene&&((t,e=[])=>{for(const r of e)for(const e of r.components)try{Pe(e),e.update&&e.update(t)}catch(t){console.error(`gameObject: ${r.name} ${e.name} update error`,t)}for(const r of e)for(const e of r.components)try{e.lateUpdate&&e.lateUpdate(t)}catch(t){console.error(`gameObject: ${r.name} ${e.name} lateUpdate error`,t)}})(t,this.gameObjects);for(const e of this.systems)try{Pe(e),e.update&&e.update(t)}catch(t){console.error(`${e.constructor.systemName} update error`,t)}for(const e of this.systems)try{e.lateUpdate&&e.lateUpdate(t)}catch(t){console.error(`${e.constructor.systemName} lateUpdate error`,t)}}))}triggerResume(){(t=>{for(const e of t)for(const t of e.components)try{t.onResume&&t.onResume()}catch(r){console.error(`gameObject: ${e.name}, ${t.name}, onResume error`,r)}})(this.gameObjects);for(const t of this.systems)try{t.onResume&&t.onResume()}catch(e){console.error(`${t.constructor.systemName}, onResume error`,e)}}triggerPause(){(t=>{for(const e of t)for(const t of e.components)try{t.onPause&&t.onPause()}catch(r){console.error(`gameObject: ${e.name}, ${t.name}, onResume error`,r)}})(this.gameObjects);for(const t of this.systems)try{t.onPause&&t.onPause()}catch(e){console.error(`${t.constructor.systemName}, onPause error`,e)}}destroySystems(){for(const t of[...this.systems])this.removeSystem(t);this.systems.length=0}destroy(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:e,mode:r=t.LOAD_SCENE_MODE.SINGLE,params:n={}}){if(e){switch(r){case t.LOAD_SCENE_MODE.SINGLE:this.scene=e;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(e)}this.emit("sceneChanged",{scene:e,mode:r,params:n})}}};function Me(t,e){t.constructor.IDEProps||(t.constructor.IDEProps=[]),t.constructor.IDEProps.push(e)}function De(t={}){return function(e){if(!e.observerInfo){for(const e in t)for(const r in t[e]){let n;"string"==typeof t[e][r]&&(t[e][r]=[t[e][r]]),Array.isArray(t[e][r])&&(n={prop:t[e][r],deep:!1},t[e][r]=n),n=t[e][r],"string"==typeof n.prop&&(n.prop=[n.prop])}e.observerInfo=t}}}class Ie extends n{constructor({resource:e,resourceTotal:r}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=e,this.resourceTotal=r,0===r&&this.resource.emit(t.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(t.LOAD_EVENT.START,this)}onProgress(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)}}var Ne,Be,Ve=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}(),Ue=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 Ve(t,!1,e))},t.prototype.once=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new Ve(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}(),$e=(t,e={})=>{if(!t)return;const 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={};let s=14;for(;s--;)o[r.key[s]]=n[s]||"";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},qe=function(t){this.config=t,this.onError=new Ue,this.onComplete=new Ue,this.onProgress=new Ue},Fe=function(t,e){return Fe=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])},Fe(t,e)};function ze(t,e){function r(){this.constructor=t}Fe(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}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("#"),s=Math.min(n>-1?n:t.length,o>-1?o:t.length);e=(t=t.substring(0,s)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()}function Ye(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 He,Xe=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 s=document.createElement("source");s.src=n,s.type=o,this._element.appendChild(s)}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:Ye(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}(qe),Je=function(t){function e(e){return t.call(this,e,"audio")||this}return ze(e,t),e}(Xe),Qe=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}(qe),We=function(t){function e(e){return t.call(this,e,"video")||this}return ze(e,t),e}(Xe),Ke=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest);function Ze(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"}(He||(He={}));var tr=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=He.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||He.Default,Ke?(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===He.Json||t.xhrType===He.Document?r.responseType=He.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(){Ke?(this._clearEvents(),this._xhr.abort(),this._onAbort()):this._xhr.abort()},e.prototype._createRequest=function(){return Ke?new window.XDomainRequest:new XMLHttpRequest},e.prototype._determineXhrType=function(t){return e._xhrTypeMap[t]||He.Default},e.prototype._clearEvents=function(){Ke?(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===He.Buffer)?r=200:1223===r&&(r=204),200===100*Math.floor(r/100))switch(this._xhrType){case He.Buffer:this._complete(Ne.Buffer,t.response);break;case He.Blob:this._complete(Ne.Blob,t.response);break;case He.Document:this._parseDocument(e);break;case He.Json:this._parseJson(e);break;case He.Default:case He.Text:this._complete(Ne.Text,e);break;default:Ye(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(Ze(t)+" Request was aborted by the user.")},e.prototype._onError=function(){var t=this._xhr;this._error(Ze(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},e.prototype._onTimeout=function(){var t=this._xhr;this._error(Ze(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=He,e._xhrTypeMap={xhtml:He.Document,html:He.Document,htm:He.Document,xml:He.Document,tmx:He.Document,svg:He.Document,tsx:He.Document,gif:He.Blob,png:He.Blob,bmp:He.Blob,jpg:He.Blob,jpeg:He.Blob,tif:He.Blob,tiff:He.Blob,webp:He.Blob,tga:He.Blob,json:He.Json,text:He.Text,txt:He.Text,ttf:He.Buffer,otf:He.Buffer},e}(qe);function er(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 rr=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 Ue,this.onUnsaturated=new Ue,this.onEmpty=new Ue,this.onDrain=new Ue,this.onError=new Ue,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,er(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,function(){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 s=arguments[e],i=0,a=s.length;i<a;i++,o++)n[o]=s[i];return n}([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}(),nr=function(){function t(e,r){if(this.children=[],this.onStart=new Ue,this.onProgress=new Ue,this.onComplete=new Ue,this.onAfterMiddleware=new Ue,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=$e(t._tempAnchor.href,{strictMode:!0}),o=!n.port&&""===r.port||n.port===r.port,s=n.protocol?n.protocol+":":"";return n.host===r.hostname&&o&&s===r.protocol?"":"anonymous"},t._tempAnchor=null,t._defaultLoadStrategy=tr,t._loadStrategyMap={gif:Qe,png:Qe,bmp:Qe,jpg:Qe,jpeg:Qe,tif:Qe,tiff:Qe,webp:Qe,tga:Qe,svg:Qe,"svg+xml":Qe,mp3:Je,ogg:Je,wav:Je,mp4:We,webm:We,mov:We},t}();var or=/(#[\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 Ue,this.onLoad=new Ue,this.onStart=new Ue,this.onComplete=new Ue,this.onProgress=new Ue,this._baseUrl="",this._urlResolvers=[],this._middleware=[],this._resourcesParsing=[],this._boundLoadResource=this._loadResource.bind(this),this.baseUrl=e,this._queue=new rr(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="",s=this._baseUrl,i={url:""};if("object"==typeof t?(n=t.url,o=t.name||t.url,s=t.baseUrl||s,i=t):(o=t,n="string"==typeof e?e:o),!n)throw new Error("You must specify the `url` property.");if(this.loading&&!i.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,s),i.url=n;var a=new nr(o,i);if(this.resources[o]=a,"function"==typeof i.onComplete&&a.onAfterMiddleware.once(i.onComplete),this.loading){var c=i.parentResource,u=[];for(r=0;r<c.children.length;++r)c.children[r].isComplete||u.push(c.children[r]);var h=c.progressChunk*(u.length+1)/(u.length+2);c.children.push(a),c.progressChunk=h;for(r=0;r<u.length;++r)u[r].progressChunk=h;a.progressChunk=h}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=$e(t,{strictMode:!0});if(this._urlResolvers.forEach((function(e){t=e(t,r),r=$e(t,{strictMode:!0})})),r.protocol||0===t.indexOf("//")||(t=e.length&&"/"!==t.charAt(0)?e+"/"+t:e+t),this.defaultQueryString){var n=or.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,s=t.length;!function i(a){a||o===s?r&&r(a):n?setTimeout((function(){return e(t[o++],i)}),1):e(t[o++],i)}()}(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}();const ir={AbstractLoadStrategy:qe,AudioLoadStrategy:Je,ImageLoadStrategy:Qe,XhrResponseType:He,MediaElementLoadStrategy:Xe,VideoLoadStrategy:We,Loader:sr,Resource:nr,ResourceType:Ne,ResourceState:Be};var ar,cr;t.LOAD_EVENT=void 0,(ar=t.LOAD_EVENT||(t.LOAD_EVENT={})).START="start",ar.PROGRESS="progress",ar.LOADED="loaded",ar.COMPLETE="complete",ar.ERROR="error",t.RESOURCE_TYPE=void 0,(cr=t.RESOURCE_TYPE||(t.RESOURCE_TYPE={})).IMAGE="IMAGE",cr.SPRITE="SPRITE",cr.SPRITE_ANIMATION="SPRITE_ANIMATION",cr.AUDIO="AUDIO",cr.VIDEO="VIDEO";const ur=new class extends n{constructor(t){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},t&&"number"==typeof t.timeout&&(this.timeout=t.timeout)}loadConfig(t){this.addResource(t),this.preload()}loadSingle(t){return this.addResource([t]),this.getResource(t.name)}addResource(t){if(!t||t.length<1)console.warn("no resources");else for(const e of t)this.resourcesMap[e.name]?console.warn(e.name+" was already added"):(this.resourcesMap[e.name]=e,this.resourcesMap[e.name].data={})}addPreProcessResourceHandler(t){this.preProcessResourceHandlers.push(t)}removePreProcessResourceHandler(t){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(t),1)}preload(){const t=[];for(const e in this.resourcesMap){const r=this.resourcesMap[e];!r.preload||r.complete||this.promiseMap[e]||t.push(r.name)}this.progress=new Ie({resource:this,resourceTotal:t.length}),this.loadResource({names:t,preload:!0})}getResource(t){return de(this,void 0,void 0,(function*(){return this.loadResource({names:[t]}),this.promiseMap[t]||Promise.resolve({})}))}instance(t){return de(this,void 0,void 0,(function*(){const e=this.resourcesMap[t];return this.makeInstanceFunctions[e.type]&&(yield this.makeInstanceFunctions[e.type](e))}))}destroy(t){return de(this,void 0,void 0,(function*(){yield this._destroy(t)}))}_destroy(t,e=!1){return de(this,void 0,void 0,(function*(){const r=this.resourcesMap[t];if(r){if(!e)try{this.destroyInstanceFunctions[r.type]&&(yield this.destroyInstanceFunctions[r.type](r))}catch(t){console.warn(`destroy resource ${r.name} error with '${t.message}'`)}delete this.promiseMap[t],r.data={},r.complete=!1,r.instance=void 0}}))}registerResourceType(e,r=e){if(t.RESOURCE_TYPE[e])throw new Error(`The type ${e} already exists in RESOURCE_TYPE`);t.RESOURCE_TYPE[e]=r}registerInstance(t,e){this.makeInstanceFunctions[t]=e}registerDestroy(t,e){this.destroyInstanceFunctions[t]=e}loadResource({names:t=[],preload:r=!1}){const n=t.filter((t=>!this.promiseMap[t]&&this.resourcesMap[t]));if(!n.length)return;const o={};n.forEach((t=>{var n;this.promiseMap[t]=new Promise((e=>o[t]=e));const s=this.resourcesMap[t];for(const t of this.preProcessResourceHandlers)t(s);for(const i in s.src){if("data"===s.src[i].type)s.data[i]=s.src[i].data,this.doComplete(t,o[t],r);else{let a=null===(n=s.src[i])||void 0===n?void 0:n.url;"string"==typeof a&&a.startsWith("//")&&(a=`${window.location.protocol}${s.src[i].url}`),"atlas"===i?e.Assets.add({alias:a,src:a,data:{resolve:()=>e.Assets.load(s.src.image.url)}}):e.Assets.add({alias:a,src:a}),e.Assets.load(a).then((e=>{this.onLoad({preload:r,resource:{metadata:{key:i,name:t,resolves:o},data:e}})})).catch((e=>{console.log(">>>E",e),this.onError({preload:r,errMsg:e.message,resource:{metadata:{key:i,name:t,resolves:o}}})}))}}}))}doComplete(t,e,r=!1){return de(this,void 0,void 0,(function*(){const n=this.resourcesMap[t],o={name:t,resource:this.resourcesMap[t],success:!0};if(this.checkAllLoaded(t))try{n.instance=yield this.instance(t),n.complete=!0,r&&this.progress.onProgress(o),e(n)}catch(t){console.error(t),n.complete=!1,r&&(o.errMsg=t.message,o.success=!1,this.progress.onProgress(o)),e({})}}))}checkAllLoaded(t){const e=this.resourcesMap[t];return Array.from(Object.keys(e.src)).every((t=>e.data[t]))}getLoader(t=!1){}onLoad({preload:t=!1,resource:e}){return de(this,void 0,void 0,(function*(){const{metadata:{key:r,name:n,resolves:o},data:s}=e;this.resourcesMap[n].data[r]=s,this.doComplete(n,o[n],t)}))}onError({errMsg:t,preload:e=!1,resource:r}){return de(this,void 0,void 0,(function*(){const{metadata:{name:n,resolves:o}}=r;if(this._destroy(n,!0),o[n]({}),e){const e={name:n,resource:this.resourcesMap[n],success:!1,errMsg:t};this.progress.onProgress(e)}}))}},hr={IDEProp:Me,componentObserver:De},lr="2.0.0-beta.10";console.log(`Eva.js version: ${lr}`);return t.Component=s,t.Game=Le,t.GameObject=Ee,t.IDEProp=Me,t.RESOURCE_TYPE_STRATEGY={},t.Scene=Se,t.System=we,t.Transform=ve,t.componentObserver=De,t.decorators=hr,t.resource=ur,t.resourceLoader=ir,t.version=lr,Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI);window.EVA=window.EVA||_EVA_IIFE_EVA; | ||
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},_extends.apply(null,arguments)}var _EVA_IIFE_EVA=function(t,e){"use strict";var r=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 s(t,e,n,s,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,s||t,i),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 i(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,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i},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,s,i){var a=r?r+t:t;if(!this._events[a])return!1;var c,u,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,o),!0;case 5:return h.fn.call(h.context,e,n,o,s),!0;case 6:return h.fn.call(h.context,e,n,o,s,i),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];h.fn.apply(h.context,c)}else{var p,d=h.length;for(u=0;u<d;u++)switch(h[u].once&&this.removeListener(t,h[u].fn,void 0,!0),l){case 1:h[u].fn.call(h[u].context);break;case 2:h[u].fn.call(h[u].context,e);break;case 3:h[u].fn.call(h[u].context,e,n);break;case 4:h[u].fn.call(h[u].context,e,n,o);break;default:if(!c)for(p=1,c=new Array(l-1);p<l;p++)c[p-1]=arguments[p];h[u].fn.apply(h[u].context,c)}}return!0},a.prototype.on=function(t,e,r){return s(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return s(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var s=r?r+t:t;if(!this._events[s])return this;if(!e)return i(this,s),this;var a=this._events[s];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||i(this,s);else{for(var c=0,u=[],h=a.length;c<h;c++)(a[c].fn!==e||o&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&i(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})),n=r;class o extends n{constructor(t){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=t}}var s=o,i="object"==typeof global&&global&&global.Object===Object&&global,a="object"==typeof self&&self&&self.Object===Object&&self,c=i||a||Function("return this")(),u=c.Symbol,h=Object.prototype,l=h.hasOwnProperty,p=h.toString,d=u?u.toStringTag:void 0;var f=Object.prototype.toString;var m=u?u.toStringTag:void 0;function _(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":m&&m in Object(t)?function(t){var e=l.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=p.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return f.call(t)}(t)}function y(t){return null!=t&&"object"==typeof t}var v=Array.isArray;function g(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function b(t){if(!g(t))return!1;var e=_(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var E,O=c["__core-js_shared__"],w=(E=/[^.]+$/.exec(O&&O.keys&&O.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"";var T=Function.prototype.toString;function j(t){if(null!=t){try{return T.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var k=/^\[object .+?Constructor\]$/,A=Function.prototype,x=Object.prototype,R=A.toString,C=x.hasOwnProperty,S=RegExp("^"+R.call(C).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function P(t){return!(!g(t)||(e=t,w&&w in e))&&(b(t)?S:k).test(j(t));var e}function L(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return P(r)?r:void 0}var M=L(c,"WeakMap"),D=/^(?:0|[1-9]\d*)$/;function I(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&D.test(t))&&t>-1&&t%1==0&&t<e}function N(t,e){return t===e||t!=t&&e!=e}function B(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var V=Object.prototype;function U(t){return y(t)&&"[object Arguments]"==_(t)}var $=Object.prototype,q=$.hasOwnProperty,F=$.propertyIsEnumerable,z=U(function(){return arguments}())?U:function(t){return y(t)&&q.call(t,"callee")&&!F.call(t,"callee")},G=z;var Y="object"==typeof t&&t&&!t.nodeType&&t,H=Y&&"object"==typeof module&&module&&!module.nodeType&&module,X=H&&H.exports===Y?c.Buffer:void 0,J=(X?X.isBuffer:void 0)||function(){return!1},Q={};Q["[object Float32Array]"]=Q["[object Float64Array]"]=Q["[object Int8Array]"]=Q["[object Int16Array]"]=Q["[object Int32Array]"]=Q["[object Uint8Array]"]=Q["[object Uint8ClampedArray]"]=Q["[object Uint16Array]"]=Q["[object Uint32Array]"]=!0,Q["[object Arguments]"]=Q["[object Array]"]=Q["[object ArrayBuffer]"]=Q["[object Boolean]"]=Q["[object DataView]"]=Q["[object Date]"]=Q["[object Error]"]=Q["[object Function]"]=Q["[object Map]"]=Q["[object Number]"]=Q["[object Object]"]=Q["[object RegExp]"]=Q["[object Set]"]=Q["[object String]"]=Q["[object WeakMap]"]=!1;var W,K="object"==typeof t&&t&&!t.nodeType&&t,Z=K&&"object"==typeof module&&module&&!module.nodeType&&module,tt=Z&&Z.exports===K&&i.process,et=function(){try{var t=Z&&Z.require&&Z.require("util").types;return t||tt&&tt.binding&&tt.binding("util")}catch(t){}}(),rt=et&&et.isTypedArray,nt=rt?(W=rt,function(t){return W(t)}):function(t){return y(t)&&B(t.length)&&!!Q[_(t)]},ot=Object.prototype.hasOwnProperty;function st(t,e){var r=v(t),n=!r&&G(t),o=!r&&!n&&J(t),s=!r&&!n&&!o&&nt(t),i=r||n||o||s,a=i?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&&!ot.call(t,u)||i&&("length"==u||o&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||I(u,c))||a.push(u);return a}var it=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),at=it,ct=Object.prototype.hasOwnProperty;function ut(t){if(r=(e=t)&&e.constructor,e!==("function"==typeof r&&r.prototype||V))return at(t);var e,r,n=[];for(var o in Object(t))ct.call(t,o)&&"constructor"!=o&&n.push(o);return n}function ht(t){return null!=(e=t)&&B(e.length)&&!b(e)?st(t):ut(t);var e}var lt=L(Object,"create");var pt=Object.prototype.hasOwnProperty;var dt=Object.prototype.hasOwnProperty;function ft(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 mt(t,e){for(var r=t.length;r--;)if(N(t[r][0],e))return r;return-1}ft.prototype.clear=function(){this.__data__=lt?lt(null):{},this.size=0},ft.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ft.prototype.get=function(t){var e=this.__data__;if(lt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return pt.call(e,t)?e[t]:void 0},ft.prototype.has=function(t){var e=this.__data__;return lt?void 0!==e[t]:dt.call(e,t)},ft.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=lt&&void 0===e?"__lodash_hash_undefined__":e,this};var _t=Array.prototype.splice;function yt(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])}}yt.prototype.clear=function(){this.__data__=[],this.size=0},yt.prototype.delete=function(t){var e=this.__data__,r=mt(e,t);return!(r<0)&&(r==e.length-1?e.pop():_t.call(e,r,1),--this.size,!0)},yt.prototype.get=function(t){var e=this.__data__,r=mt(e,t);return r<0?void 0:e[r][1]},yt.prototype.has=function(t){return mt(this.__data__,t)>-1},yt.prototype.set=function(t,e){var r=this.__data__,n=mt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var vt=L(c,"Map");function gt(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 bt(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])}}bt.prototype.clear=function(){this.size=0,this.__data__={hash:new ft,map:new(vt||yt),string:new ft}},bt.prototype.delete=function(t){var e=gt(this,t).delete(t);return this.size-=e?1:0,e},bt.prototype.get=function(t){return gt(this,t).get(t)},bt.prototype.has=function(t){return gt(this,t).has(t)},bt.prototype.set=function(t,e){var r=gt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Et(t){var e=this.__data__=new yt(t);this.size=e.size}Et.prototype.clear=function(){this.__data__=new yt,this.size=0},Et.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Et.prototype.get=function(t){return this.__data__.get(t)},Et.prototype.has=function(t){return this.__data__.has(t)},Et.prototype.set=function(t,e){var r=this.__data__;if(r instanceof yt){var n=r.__data__;if(!vt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new bt(n)}return r.set(t,e),this.size=r.size,this};var Ot=Object.prototype.propertyIsEnumerable,wt=Object.getOwnPropertySymbols,Tt=wt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,s=[];++r<n;){var i=t[r];e(i,r,t)&&(s[o++]=i)}return s}(wt(t),(function(e){return Ot.call(t,e)})))}:function(){return[]};function jt(t){return function(t,e,r){var n=e(t);return v(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,ht,Tt)}var kt=L(c,"DataView"),At=L(c,"Promise"),xt=L(c,"Set"),Rt="[object Map]",Ct="[object Promise]",St="[object Set]",Pt="[object WeakMap]",Lt="[object DataView]",Mt=j(kt),Dt=j(vt),It=j(At),Nt=j(xt),Bt=j(M),Vt=_;(kt&&Vt(new kt(new ArrayBuffer(1)))!=Lt||vt&&Vt(new vt)!=Rt||At&&Vt(At.resolve())!=Ct||xt&&Vt(new xt)!=St||M&&Vt(new M)!=Pt)&&(Vt=function(t){var e=_(t),r="[object Object]"==e?t.constructor:void 0,n=r?j(r):"";if(n)switch(n){case Mt:return Lt;case Dt:return Rt;case It:return Ct;case Nt:return St;case Bt:return Pt}return e});var Ut=Vt,$t=c.Uint8Array;function qt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new bt;++e<r;)this.add(t[e])}function Ft(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}qt.prototype.add=qt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},qt.prototype.has=function(t){return this.__data__.has(t)};function zt(t,e,r,n,o,s){var i=1&r,a=t.length,c=e.length;if(a!=c&&!(i&&c>a))return!1;var u=s.get(t),h=s.get(e);if(u&&h)return u==e&&h==t;var l=-1,p=!0,d=2&r?new qt:void 0;for(s.set(t,e),s.set(e,t);++l<a;){var f=t[l],m=e[l];if(n)var _=i?n(m,f,l,e,t,s):n(f,m,l,t,e,s);if(void 0!==_){if(_)continue;p=!1;break}if(d){if(!Ft(e,(function(t,e){if(i=e,!d.has(i)&&(f===t||o(f,t,r,n,s)))return d.push(e);var i}))){p=!1;break}}else if(f!==m&&!o(f,m,r,n,s)){p=!1;break}}return s.delete(t),s.delete(e),p}function Gt(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function Yt(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var Ht=u?u.prototype:void 0,Xt=Ht?Ht.valueOf:void 0;var Jt=Object.prototype.hasOwnProperty;var Qt,Wt="[object Arguments]",Kt="[object Array]",Zt="[object Object]",te=Object.prototype.hasOwnProperty;function ee(t,e,r,n,o,s){var i=v(t),a=v(e),c=i?Kt:Ut(t),u=a?Kt:Ut(e),h=(c=c==Wt?Zt:c)==Zt,l=(u=u==Wt?Zt:u)==Zt,p=c==u;if(p&&J(t)){if(!J(e))return!1;i=!0,h=!1}if(p&&!h)return s||(s=new Et),i||nt(t)?zt(t,e,r,n,o,s):function(t,e,r,n,o,s,i){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||!s(new $t(t),new $t(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return N(+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=Gt;case"[object Set]":var c=1&n;if(a||(a=Yt),t.size!=e.size&&!c)return!1;var u=i.get(t);if(u)return u==e;n|=2,i.set(t,e);var h=zt(a(t),a(e),n,o,s,i);return i.delete(t),h;case"[object Symbol]":if(Xt)return Xt.call(t)==Xt.call(e)}return!1}(t,e,c,r,n,o,s);if(!(1&r)){var d=h&&te.call(t,"__wrapped__"),f=l&&te.call(e,"__wrapped__");if(d||f){var m=d?t.value():t,_=f?e.value():e;return s||(s=new Et),o(m,_,r,n,s)}}return!!p&&(s||(s=new Et),function(t,e,r,n,o,s){var i=1&r,a=jt(t),c=a.length;if(c!=jt(e).length&&!i)return!1;for(var u=c;u--;){var h=a[u];if(!(i?h in e:Jt.call(e,h)))return!1}var l=s.get(t),p=s.get(e);if(l&&p)return l==e&&p==t;var d=!0;s.set(t,e),s.set(e,t);for(var f=i;++u<c;){var m=t[h=a[u]],_=e[h];if(n)var y=i?n(_,m,h,e,t,s):n(m,_,h,t,e,s);if(!(void 0===y?m===_||o(m,_,r,n,s):y)){d=!1;break}f||(f="constructor"==h)}if(d&&!f){var v=t.constructor,g=e.constructor;v==g||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof g&&g instanceof g||(d=!1)}return s.delete(t),s.delete(e),d}(t,e,r,n,o,s))}function re(t,e,r,n,o){return t===e||(null==t||null==e||!y(t)&&!y(e)?t!=t&&e!=e:ee(t,e,r,n,re,o))}function ne(t,e){return re(t,e)}t.OBSERVER_TYPE=void 0,(Qt=t.OBSERVER_TYPE||(t.OBSERVER_TYPE={})).ADD="ADD",Qt.REMOVE="REMOVE",Qt.CHANGE="CHANGE";const oe={},se={},ie={},ae={};function ce(t,e){oe[t.gameObject.id]||(oe[t.gameObject.id]={});const r=oe[t.gameObject.id],n=t.name+"_"+e.join(",");if(r[n])return r[n];const o=e.length-1;let s=t;for(let t=0;t<o;t++)s=s[e[t]];return r[n]={property:s,key:e[o]},r[n]}function ue({systemName:t,componentName:e,component:r,prop:n,type:o}){var s,i;null===(i=null===(s=se[t])||void 0===s?void 0:s.componentObserver)||void 0===i||i.add({component:r,prop:n,type:o,componentName:e})}function he({obj:e,key:r,prop:n,component:o,componentName:s}){if(void 0!==e)if(r in e){if(Object.defineProperty(e,`_${r}`,{enumerable:!1,writable:!0,value:e[r]}),n.deep&&g(e[r]))for(const t of Object.keys(e[r]))he({obj:e[r],key:t,prop:n,component:o,componentName:s});Object.defineProperty(e,r,{enumerable:!0,set(i){e[`_${r}`]!==i&&(e[`_${r}`]=i,function({prop:e,component:r,componentName:n}){for(const o in ie){const s=(ie[o]||{})[n];s&&(s.findIndex((t=>ne(t,e)))>-1&&ue({systemName:o,componentName:n,component:r,prop:e,type:t.OBSERVER_TYPE.CHANGE}))}}({prop:n,component:o,componentName:s}))},get:()=>e[`_${r}`]})}else console.error(`prop ${r} not in component: ${s}, Can not observer`)}function le(e,r=e.name){var n,o;for(const s in ie){(ie[s]||{})[r]&&(null===(o=null===(n=se[s])||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 oe[t.gameObject.id]}(e)}function pe(t,e,r,n){var o,s=arguments.length,i=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(i=(s<3?o(i):s>3?o(e,r,i):o(e,r))||i);return s>3&&i&&Object.defineProperty(e,r,i),i}function de(t,e,r,n){return new(r||(r=Promise))((function(o,s){function i(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(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(i,a)}c((n=n.apply(t,e||[])).next())}))}function fe(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function me(t){return function(e,r){var n=fe(e,r);n.key=r,n.type=t}}function _e(t){return function(e,r){fe(e,r).step=t}}class ye extends s{constructor(){super(...arguments),this.name="Transform",this._parent=null,this.inScene=!1,this.children=[],this.position={x:0,y:0},this.size={width:0,height:0},this.origin={x:0,y:0},this.anchor={x:0,y:0},this.scale={x:1,y:1},this.skew={x:0,y:0},this.rotation=0}init(t={}){const e=["position","size","origin","anchor","scale","skew"];for(const r of e)_extends(this[r],t[r]);this.rotation=t.rotation||this.rotation}set parent(t){t?t.addChild(this):this.parent&&this.parent.removeChild(this)}get parent(){return this._parent}addChild(t){if(t.parent===this){const e=this.children.findIndex((e=>e===t));this.children.splice(e,1)}else t.parent&&t.parent.removeChild(t);t._parent=this,this.children.push(t)}removeChild(t){const e=this.children.findIndex((e=>e===t));e>-1&&(this.children.splice(e,1),t._parent=null)}clearChildren(){this.children.length=0}}ye.componentName="Transform",pe([me("vector2"),_e(1)],ye.prototype,"position",void 0),pe([me("size"),_e(1)],ye.prototype,"size",void 0),pe([me("vector2"),_e(.1)],ye.prototype,"origin",void 0),pe([me("vector2"),_e(.1)],ye.prototype,"anchor",void 0),pe([me("vector2"),_e(.1)],ye.prototype,"scale",void 0),pe([me("vector2"),_e(.1)],ye.prototype,"skew",void 0),pe([me("number"),_e(.1)],ye.prototype,"rotation",void 0);var ve=ye;let ge=0;class be{constructor(t,e){this._componentCache={},this.components=[],this.destroyed=!1,this._name=t,this.id=++ge,this.addComponent(ve,e)}get transform(){return this.getComponent(ve)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get name(){return this._name}set scene(t){if(this._scene===t)return;const e=this._scene;if(this._scene=t,this.transform&&this.transform.children)for(const e of this.transform.children)e.gameObject.scene=t;t?t.addGameObject(this):e&&e.removeGameObject(this)}get scene(){return this._scene}addChild(t){if(t&&t.transform&&t!==this){if(!(t instanceof be))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}}removeChild(t){return t instanceof be&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t}addComponent(e,r){if(this.destroyed)return;const n=function(t){return t instanceof o?t.name:t instanceof Function?t.componentName:void 0}(e);if(this._componentCache[n])return;let i;if(e instanceof Function)i=new e(r);else{if(!(e instanceof s))throw new Error("addComponent recieve Component and Component Constructor");i=e}if(i.gameObject)throw new Error(`component has been added on gameObject ${i.gameObject.name}`);return i.gameObject=this,i.init&&i.init(i.__componentDefaultParams),function(e,r=e.name){var n,o;for(const s in ie)(ie[s]||{})[r]&&(null===(o=null===(n=se[s])||void 0===n?void 0:n.componentObserver)||void 0===o||o.add({component:e,type:t.OBSERVER_TYPE.ADD,componentName:r}))}(i,i.name),function(t,e=t.name){if(e&&ae[e]){if(!(t&&(r=t,r&&r.constructor&&"componentName"in r.constructor)))throw new Error("component param must be an instance of Component");var r;if(!t.gameObject||!t.gameObject.id)throw new Error("component should be add to a gameObject");for(const r of ae[e]){const{property:n,key:o}=ce(t,r.prop);he({obj:n,key:o,prop:r,component:t,componentName:e})}}}(i,i.name),this.components.push(i),this._componentCache[n]=i,i.awake&&i.awake(),i}removeComponent(t){let e;if("string"==typeof t?e=t:t instanceof s?e=t.name:t.componentName&&(e=t.componentName),"Transform"===e)throw new Error("Transform can't be removed");return this._removeComponent(e)}_removeComponent(t){const e=this.components.findIndex((({name:e})=>e===t));if(-1===e)return;const r=this.components.splice(e,1)[0];return delete this._componentCache[t],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),le(r,t),r.gameObject=void 0,r}getComponent(t){let e;return"string"==typeof t?e=t:t instanceof s?e=t.name:t.componentName&&(e=t.componentName),void 0!==this._componentCache[e]?this._componentCache[e]:void 0}remove(){if(this.parent)return this.parent.removeChild(this)}destroy(){if(this.transform){Array.from(this.transform.children).forEach((({gameObject:t})=>{t.destroy()})),this.remove(),this.transform.clearChildren();for(const t in this._componentCache)this._removeComponent(t);this.components.length=0,this.destroyed=!0}else console.error("Cannot destroy gameObject that have already been destroyed.")}}var Ee=be;var Oe=class{constructor(){this.events=[]}add({component:e,prop:r,type:n,componentName:o}){if(n===t.OBSERVER_TYPE.REMOVE){if(this.events.find((r=>r.component===e&&r.type===t.OBSERVER_TYPE.ADD)))return void(this.events=this.events.filter((t=>t.component!==e)));this.events=this.events.filter((t=>t.component!==e))}const s=this.events.findIndex((t=>t.component===e&&ne(t.prop,r)&&t.type===n));s>-1&&this.events.splice(s,1),this.events.push({gameObject:e.gameObject,component:e,prop:r,type:n,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const t=this.events;return this.events=[],t}};var we=class{constructor(t){this.started=!1,this.componentObserver=new Oe,this.__systemDefaultParams=t,this.name=this.constructor.systemName}destroy(){var t;this.componentObserver=null,this.__systemDefaultParams=null,null===(t=this.onDestroy)||void 0===t||t.call(this)}};const Te=function(){let t=null;return t=Date.now?Date.now:()=>(new Date).getTime(),t}(),je={originTime:0,playbackRate:1};class ke{constructor(t,e){t instanceof ke&&(e=t,t={}),t=_extends({},je,t),e&&(this._parent=e),this._createTime=Te(),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}get globalTime(){return this.parent?this.parent.currentTime:Te()-this._createTime}get parent(){return this._parent}get lastTimeMark(){return this._timeMark[this._timeMark.length-1]}markTime({time:t=this.currentTime,entropy:e=this.entropy,playbackRate:r=this.playbackRate}={}){const n={globalTime:this.globalTime,localTime:t,entropy:e,playbackRate:r,globalEntropy:this.globalEntropy};this._timeMark.push(n)}get currentTime(){const{localTime:t,globalTime:e}=this.lastTimeMark;return t+(this.globalTime-e)*this.playbackRate}set currentTime(t){this.markTime({time:t})}get globalEntropy(){return this._parent?this._parent.entropy:this.globalTime}get entropy(){const{entropy:t,globalEntropy:e}=this.lastTimeMark;return t+Math.abs((this.globalEntropy-e)*this.playbackRate)}set entropy(t){if(this.entropy>t){const e=this.seekTimeMark(t);this._timeMark.length=e+1}this.markTime({entropy:t})}fork(t){return new ke(t,this)}seekGlobalTime(t){const e=this.seekTimeMark(t),r=this._timeMark[e],{entropy:n,playbackRate:o,globalTime:s}=r;return s+(t-n)/Math.abs(o)}seekLocalTime(t){const e=this.seekTimeMark(t),r=this._timeMark[e],{localTime:n,entropy:o,playbackRate:s}=r;return s>0?n+(t-o):n-(t-o)}seekTimeMark(t){const e=this._timeMark;let r=0,n=e.length-1;if(t<=e[r].entropy)return r;if(t>=e[n].entropy)return n;let o=Math.floor((r+n)/2);for(;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}get playbackRate(){return this._playbackRate}set playbackRate(t){t!==this.playbackRate&&(this.markTime({playbackRate:t}),this._playbackRate=t)}get paused(){if(0===this.playbackRate)return!0;let t=this.parent;for(;t;){if(0===t.playbackRate)return!0;t=t.parent}return!1}}var Ae=ke;const xe={autoStart:!0,frameRate:60};var Re=class{constructor(t){t=_extends({},xe,t),this._frameCount=0,this._frameDuration=1e3/t.frameRate,this.autoStart=t.autoStart,this.frameRate=t.frameRate,this.timeline=new Ae({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=()=>{this._started&&(this._requestId=requestAnimationFrame(this._ticker),this.update())},this.autoStart&&this.start()}update(){const t=this.timeline.currentTime,e=t-this._lastFrameTime;if(e>=this._frameDuration){const r=t-e%this._frameDuration,n=r-this._lastFrameTime;this._lastFrameTime=r;const o={deltaTime:n,time:r,currentTime:r,frameCount:++this._frameCount,fps:Math.round(1e3/n)};for(const t of this._tickers)"function"==typeof t&&t(o)}}add(t){this._tickers.add(t)}remove(t){this._tickers.delete(t)}start(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))}pause(){this._started=!1,this.timeline.playbackRate=0}setPlaybackRate(t){this.timeline.playbackRate=t}};var Ce,Se=class extends Ee{constructor(t,e){super(t,e),this.gameObjects=[],this.scene=this}addGameObject(t){this.gameObjects.push(t),t.transform&&(t.transform.inScene=!0)}removeGameObject(t){const e=this.gameObjects.indexOf(t);-1!==e&&(t.transform&&(t.transform.inScene=!1),this.gameObjects.splice(e,1))}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null}};t.LOAD_SCENE_MODE=void 0,(Ce=t.LOAD_SCENE_MODE||(t.LOAD_SCENE_MODE={})).SINGLE="SINGLE",Ce.MULTI_CANVAS="MULTI_CANVAS";const Pe=t=>{if((t instanceof we||t instanceof s)&&!t.started){t.started=!0;try{t.start&&t.start()}catch(e){t instanceof s?console.error(`${t.constructor.componentName} start error`,e):console.error(`${t.constructor.systemName} start error`,e)}}};var Le=class extends n{constructor(){super(...arguments),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[]}init({systems:t,frameRate:e=60,autoStart:r=!0,needScene:n=!0}={}){return de(this,void 0,void 0,(function*(){if(window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new Re({autoStart:!1,frameRate:e}),this.initTicker(),t&&t.length)for(const e of t)yield this.addSystem(e);n&&this.loadScene(new Se("scene")),r&&this.start()}))}get scene(){return this._scene}set scene(t){this._scene=t}get gameObjects(){return(t=>{var e;const r=(null===(e=null==t?void 0:t.scene)||void 0===e?void 0:e.gameObjects)||[],n=null==t?void 0:t.multiScenes.map((({gameObjects:t})=>t));let o=[];for(const t of n)o=[...o,...t];return[...r,...o]})(this)}addSystem(t,e){return de(this,void 0,void 0,(function*(){let 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((t=>t.constructor===r.constructor))){r.game=this,r.init&&(yield r.init(r.__systemDefaultParams)),function(t,e){ie[e.systemName]=e.observerInfo,se[e.systemName]=t}(r,r.constructor),function(t){const e=[];t instanceof Array?e.push(...t):e.push(t);for(const t of e)for(const e in t.observerInfo){ae[e]=ae[e]||[];const r=ae[e];for(const n of t.observerInfo[e])-1===r.findIndex((t=>ne(t,n)))&&ae[e].push(n)}}(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`)}))}removeSystem(t){if(!t)return;let e=-1;"string"==typeof t?e=this.systems.findIndex((e=>e.name===t)):t instanceof Function?e=this.systems.findIndex((e=>e.constructor===t)):t instanceof we&&(e=this.systems.findIndex((e=>e===t))),e>-1&&(this.systems[e].destroy&&this.systems[e].destroy(),this.systems.splice(e,1))}getSystem(t){return this.systems.find((e=>"string"==typeof t?e.name===t:e instanceof t))}pause(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())}start(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())}resume(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())}initTicker(){this.ticker.add((t=>{this.scene&&((t,e=[])=>{for(const r of e)for(const e of r.components)try{Pe(e),e.update&&e.update(t)}catch(t){console.error(`gameObject: ${r.name} ${e.name} update error`,t)}for(const r of e)for(const e of r.components)try{e.lateUpdate&&e.lateUpdate(t)}catch(t){console.error(`gameObject: ${r.name} ${e.name} lateUpdate error`,t)}})(t,this.gameObjects);for(const e of this.systems)try{Pe(e),e.update&&e.update(t)}catch(t){console.error(`${e.constructor.systemName} update error`,t)}for(const e of this.systems)try{e.lateUpdate&&e.lateUpdate(t)}catch(t){console.error(`${e.constructor.systemName} lateUpdate error`,t)}}))}triggerResume(){(t=>{for(const e of t)for(const t of e.components)try{t.onResume&&t.onResume()}catch(r){console.error(`gameObject: ${e.name}, ${t.name}, onResume error`,r)}})(this.gameObjects);for(const t of this.systems)try{t.onResume&&t.onResume()}catch(e){console.error(`${t.constructor.systemName}, onResume error`,e)}}triggerPause(){(t=>{for(const e of t)for(const t of e.components)try{t.onPause&&t.onPause()}catch(r){console.error(`gameObject: ${e.name}, ${t.name}, onResume error`,r)}})(this.gameObjects);for(const t of this.systems)try{t.onPause&&t.onPause()}catch(e){console.error(`${t.constructor.systemName}, onPause error`,e)}}destroySystems(){for(const t of[...this.systems])this.removeSystem(t);this.systems.length=0}destroy(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:e,mode:r=t.LOAD_SCENE_MODE.SINGLE,params:n={}}){if(e){switch(r){case t.LOAD_SCENE_MODE.SINGLE:this.scene=e;break;case t.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(e)}this.emit("sceneChanged",{scene:e,mode:r,params:n})}}};function Me(t,e){t.constructor.IDEProps||(t.constructor.IDEProps=[]),t.constructor.IDEProps.push(e)}function De(t={}){return function(e){if(!e.observerInfo){for(const e in t)for(const r in t[e]){let n;"string"==typeof t[e][r]&&(t[e][r]=[t[e][r]]),Array.isArray(t[e][r])&&(n={prop:t[e][r],deep:!1},t[e][r]=n),n=t[e][r],"string"==typeof n.prop&&(n.prop=[n.prop])}e.observerInfo=t}}}class Ie extends n{constructor({resource:e,resourceTotal:r}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=e,this.resourceTotal=r,0===r&&this.resource.emit(t.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(t.LOAD_EVENT.START,this)}onProgress(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)}}var Ne,Be,Ve=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}(),Ue=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 Ve(t,!1,e))},t.prototype.once=function(t,e){return void 0===e&&(e=null),this._addSignalBinding(new Ve(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}(),$e=(t,e={})=>{if(!t)return;const 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={};let s=14;for(;s--;)o[r.key[s]]=n[s]||"";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},qe=function(t){this.config=t,this.onError=new Ue,this.onComplete=new Ue,this.onProgress=new Ue},Fe=function(t,e){return Fe=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])},Fe(t,e)};function ze(t,e){function r(){this.constructor=t}Fe(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}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("#"),s=Math.min(n>-1?n:t.length,o>-1?o:t.length);e=(t=t.substring(0,s)).substring(t.lastIndexOf(".")+1)}return e.toLowerCase()}function Ye(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 He,Xe=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 s=document.createElement("source");s.src=n,s.type=o,this._element.appendChild(s)}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:Ye(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}(qe),Je=function(t){function e(e){return t.call(this,e,"audio")||this}return ze(e,t),e}(Xe),Qe=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}(qe),We=function(t){function e(e){return t.call(this,e,"video")||this}return ze(e,t),e}(Xe),Ke=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest);function Ze(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"}(He||(He={}));var tr=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=He.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||He.Default,Ke?(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===He.Json||t.xhrType===He.Document?r.responseType=He.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(){Ke?(this._clearEvents(),this._xhr.abort(),this._onAbort()):this._xhr.abort()},e.prototype._createRequest=function(){return Ke?new window.XDomainRequest:new XMLHttpRequest},e.prototype._determineXhrType=function(t){return e._xhrTypeMap[t]||He.Default},e.prototype._clearEvents=function(){Ke?(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===He.Buffer)?r=200:1223===r&&(r=204),200===100*Math.floor(r/100))switch(this._xhrType){case He.Buffer:this._complete(Ne.Buffer,t.response);break;case He.Blob:this._complete(Ne.Blob,t.response);break;case He.Document:this._parseDocument(e);break;case He.Json:this._parseJson(e);break;case He.Default:case He.Text:this._complete(Ne.Text,e);break;default:Ye(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(Ze(t)+" Request was aborted by the user.")},e.prototype._onError=function(){var t=this._xhr;this._error(Ze(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},e.prototype._onTimeout=function(){var t=this._xhr;this._error(Ze(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=He,e._xhrTypeMap={xhtml:He.Document,html:He.Document,htm:He.Document,xml:He.Document,tmx:He.Document,svg:He.Document,tsx:He.Document,gif:He.Blob,png:He.Blob,bmp:He.Blob,jpg:He.Blob,jpeg:He.Blob,tif:He.Blob,tiff:He.Blob,webp:He.Blob,tga:He.Blob,json:He.Json,text:He.Text,txt:He.Text,ttf:He.Buffer,otf:He.Buffer},e}(qe);function er(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 rr=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 Ue,this.onUnsaturated=new Ue,this.onEmpty=new Ue,this.onDrain=new Ue,this.onError=new Ue,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,er(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,function(){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 s=arguments[e],i=0,a=s.length;i<a;i++,o++)n[o]=s[i];return n}([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}(),nr=function(){function t(e,r){if(this.children=[],this.onStart=new Ue,this.onProgress=new Ue,this.onComplete=new Ue,this.onAfterMiddleware=new Ue,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=$e(t._tempAnchor.href,{strictMode:!0}),o=!n.port&&""===r.port||n.port===r.port,s=n.protocol?n.protocol+":":"";return n.host===r.hostname&&o&&s===r.protocol?"":"anonymous"},t._tempAnchor=null,t._defaultLoadStrategy=tr,t._loadStrategyMap={gif:Qe,png:Qe,bmp:Qe,jpg:Qe,jpeg:Qe,tif:Qe,tiff:Qe,webp:Qe,tga:Qe,svg:Qe,"svg+xml":Qe,mp3:Je,ogg:Je,wav:Je,mp4:We,webm:We,mov:We},t}();var or=/(#[\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 Ue,this.onLoad=new Ue,this.onStart=new Ue,this.onComplete=new Ue,this.onProgress=new Ue,this._baseUrl="",this._urlResolvers=[],this._middleware=[],this._resourcesParsing=[],this._boundLoadResource=this._loadResource.bind(this),this.baseUrl=e,this._queue=new rr(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="",s=this._baseUrl,i={url:""};if("object"==typeof t?(n=t.url,o=t.name||t.url,s=t.baseUrl||s,i=t):(o=t,n="string"==typeof e?e:o),!n)throw new Error("You must specify the `url` property.");if(this.loading&&!i.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,s),i.url=n;var a=new nr(o,i);if(this.resources[o]=a,"function"==typeof i.onComplete&&a.onAfterMiddleware.once(i.onComplete),this.loading){var c=i.parentResource,u=[];for(r=0;r<c.children.length;++r)c.children[r].isComplete||u.push(c.children[r]);var h=c.progressChunk*(u.length+1)/(u.length+2);c.children.push(a),c.progressChunk=h;for(r=0;r<u.length;++r)u[r].progressChunk=h;a.progressChunk=h}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=$e(t,{strictMode:!0});if(this._urlResolvers.forEach((function(e){t=e(t,r),r=$e(t,{strictMode:!0})})),r.protocol||0===t.indexOf("//")||(t=e.length&&"/"!==t.charAt(0)?e+"/"+t:e+t),this.defaultQueryString){var n=or.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,s=t.length;!function i(a){a||o===s?r&&r(a):n?setTimeout((function(){return e(t[o++],i)}),1):e(t[o++],i)}()}(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}();const ir={AbstractLoadStrategy:qe,AudioLoadStrategy:Je,ImageLoadStrategy:Qe,XhrResponseType:He,MediaElementLoadStrategy:Xe,VideoLoadStrategy:We,Loader:sr,Resource:nr,ResourceType:Ne,ResourceState:Be};var ar,cr;t.LOAD_EVENT=void 0,(ar=t.LOAD_EVENT||(t.LOAD_EVENT={})).START="start",ar.PROGRESS="progress",ar.LOADED="loaded",ar.COMPLETE="complete",ar.ERROR="error",t.RESOURCE_TYPE=void 0,(cr=t.RESOURCE_TYPE||(t.RESOURCE_TYPE={})).IMAGE="IMAGE",cr.SPRITE="SPRITE",cr.SPRITE_ANIMATION="SPRITE_ANIMATION",cr.AUDIO="AUDIO",cr.VIDEO="VIDEO";const ur=new class extends n{constructor(t){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},t&&"number"==typeof t.timeout&&(this.timeout=t.timeout)}loadConfig(t){this.addResource(t),this.preload()}loadSingle(t){return this.addResource([t]),this.getResource(t.name)}addResource(t){if(!t||t.length<1)console.warn("no resources");else for(const e of t)this.resourcesMap[e.name]?console.warn(e.name+" was already added"):(this.resourcesMap[e.name]=e,this.resourcesMap[e.name].data={})}addPreProcessResourceHandler(t){this.preProcessResourceHandlers.push(t)}removePreProcessResourceHandler(t){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(t),1)}preload(){const t=[];for(const e in this.resourcesMap){const r=this.resourcesMap[e];!r.preload||r.complete||this.promiseMap[e]||t.push(r.name)}this.progress=new Ie({resource:this,resourceTotal:t.length}),this.loadResource({names:t,preload:!0})}getResource(t){return de(this,void 0,void 0,(function*(){return this.loadResource({names:[t]}),this.promiseMap[t]||Promise.resolve({})}))}instance(t){return de(this,void 0,void 0,(function*(){const e=this.resourcesMap[t];return this.makeInstanceFunctions[e.type]&&(yield this.makeInstanceFunctions[e.type](e))}))}destroy(t){return de(this,void 0,void 0,(function*(){yield this._destroy(t)}))}_destroy(t,e=!1){return de(this,void 0,void 0,(function*(){const r=this.resourcesMap[t];if(r){if(!e)try{this.destroyInstanceFunctions[r.type]&&(yield this.destroyInstanceFunctions[r.type](r))}catch(t){console.warn(`destroy resource ${r.name} error with '${t.message}'`)}delete this.promiseMap[t],r.data={},r.complete=!1,r.instance=void 0}}))}registerResourceType(e,r=e){if(t.RESOURCE_TYPE[e])throw new Error(`The type ${e} already exists in RESOURCE_TYPE`);t.RESOURCE_TYPE[e]=r}registerInstance(t,e){this.makeInstanceFunctions[t]=e}registerDestroy(t,e){this.destroyInstanceFunctions[t]=e}loadResource({names:t=[],preload:r=!1}){const n=t.filter((t=>!this.promiseMap[t]&&this.resourcesMap[t]));if(!n.length)return;const o={};n.forEach((t=>{var n;this.promiseMap[t]=new Promise((e=>o[t]=e));const s=this.resourcesMap[t];for(const t of this.preProcessResourceHandlers)t(s);for(const i in s.src){if("data"===s.src[i].type)s.data[i]=s.src[i].data,this.doComplete(t,o[t],r);else{let a=null===(n=s.src[i])||void 0===n?void 0:n.url;"string"==typeof a&&a.startsWith("//")&&(a=`${window.location.protocol}${s.src[i].url}`),"atlas"===i?e.Assets.add({alias:a,src:a,data:{resolve:()=>e.Assets.load(s.src.image.url)}}):e.Assets.add({alias:a,src:a}),e.Assets.load(a).then((e=>{this.onLoad({preload:r,resource:{metadata:{key:i,name:t,resolves:o},data:e}})})).catch((e=>{console.log(">>>E",e),this.onError({preload:r,errMsg:e.message,resource:{metadata:{key:i,name:t,resolves:o}}})}))}}}))}doComplete(t,e,r=!1){return de(this,void 0,void 0,(function*(){const n=this.resourcesMap[t],o={name:t,resource:this.resourcesMap[t],success:!0};if(this.checkAllLoaded(t))try{n.instance=yield this.instance(t),n.complete=!0,r&&this.progress.onProgress(o),e(n)}catch(t){console.error(t),n.complete=!1,r&&(o.errMsg=t.message,o.success=!1,this.progress.onProgress(o)),e({})}}))}checkAllLoaded(t){const e=this.resourcesMap[t];return Array.from(Object.keys(e.src)).every((t=>e.data[t]))}getLoader(t=!1){}onLoad({preload:t=!1,resource:e}){return de(this,void 0,void 0,(function*(){const{metadata:{key:r,name:n,resolves:o},data:s}=e;this.resourcesMap[n].data[r]=s,this.doComplete(n,o[n],t)}))}onError({errMsg:t,preload:e=!1,resource:r}){return de(this,void 0,void 0,(function*(){const{metadata:{name:n,resolves:o}}=r;if(this._destroy(n,!0),o[n]({}),e){const e={name:n,resource:this.resourcesMap[n],success:!1,errMsg:t};this.progress.onProgress(e)}}))}},hr={IDEProp:Me,componentObserver:De},lr="2.0.0-beta.11";console.log(`Eva.js version: ${lr}`);return t.Component=s,t.Game=Le,t.GameObject=Ee,t.IDEProp=Me,t.RESOURCE_TYPE_STRATEGY={},t.Scene=Se,t.System=we,t.Transform=ve,t.componentObserver=De,t.decorators=hr,t.resource=ur,t.resourceLoader=ir,t.version=lr,Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI);window.EVA=window.EVA||_EVA_IIFE_EVA; |
{ | ||
"name": "@eva/eva.js", | ||
"version": "2.0.0-beta.10", | ||
"version": "2.0.0-beta.11", | ||
"description": "@eva/eva.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display