🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@eva/eva.js

Package Overview
Dependencies
Maintainers
6
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eva/eva.js - npm Package Compare versions

Comparing version
2.0.2
to
2.1.0-beta.1
+1
-1
dist/eva.js.cjs.prod.js

@@ -1,1 +0,1 @@

"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");function o(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var n=o(e);class i extends n{constructor(e){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=e}}var a,c=i;exports.OBSERVER_TYPE=void 0,(a=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",a.REMOVE="REMOVE",a.CHANGE="CHANGE";const m={},h={},p={},l={};function u(e,t){m[e.gameObject.id]||(m[e.gameObject.id]={});const s=m[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 d({systemName:e,componentName:t,component:s,prop:r,type:o}){var n,i;null===(i=null===(n=h[e])||void 0===n?void 0:n.componentObserver)||void 0===i||i.add({component:s,prop:r,type:o,componentName:t})}function f({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]))f({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 p){const n=(p[o]||{})[r];n&&(n.findIndex(s=>t.isEqual(s,e))>-1&&d({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 y(e,t=e.name){var s,r;for(const o in p){(p[o]||{})[t]&&(null===(r=null===(s=h[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 m[e.gameObject.id]}(e)}function g(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 E(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){var t;e.done?o(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(i,a)}c((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class _ extends c{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",g([s.type("vector2"),s.step(1)],_.prototype,"position",void 0),g([s.type("size"),s.step(1)],_.prototype,"size",void 0),g([s.type("vector2"),s.step(.1)],_.prototype,"origin",void 0),g([s.type("vector2"),s.step(.1)],_.prototype,"anchor",void 0),g([s.type("vector2"),s.step(.1)],_.prototype,"scale",void 0),g([s.type("vector2"),s.step(.1)],_.prototype,"skew",void 0),g([s.type("number"),s.step(.1)],_.prototype,"rotation",void 0);var v=_;let b=0;class O{constructor(e,t){this._componentCache={},this.components=[],this.destroyed=!1,this._name=e,this.id=++b,this.addComponent(v,t)}get transform(){return this.getComponent(v)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get children(){return this.transform.children.map(e=>e.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 i?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 c))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 p)(p[o]||{})[t]&&(null===(r=null===(s=h[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&&l[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 l[t]){const{property:r,key:o}=u(e,s.prop);f({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 c?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(),y(s,e),s.gameObject=void 0,s}getComponent(e){let t;return"string"==typeof e?t=e:e instanceof c?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}}}var R=O;var T=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 k=class{constructor(e){this.started=!1,this.componentObserver=new T,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 S=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=S(),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:S()-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 C=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;let t=0;for(;e-this._lastFrameTime>=this._frameDuration&&t<5;){this._lastFrameTime+=this._frameDuration,t++;const e={deltaTime:this._frameDuration,time:this._lastFrameTime,currentTime:this._lastFrameTime,frameCount:++this._frameCount,fps:this.frameRate};for(const t of this._tickers)"function"==typeof t&&t(e)}e-this._lastFrameTime>=this._frameDuration&&(this._lastFrameTime=e)}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 A,I=class extends R{constructor(e,t){super(e,t),this.gameObjects=[],this._nameIndex=new Map,this.scene=this}addGameObject(e){if(this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0),e.name){let t=this._nameIndex.get(e.name);t||(t=new Set,this._nameIndex.set(e.name,t)),t.add(e)}}removeGameObject(e){const t=this.gameObjects.indexOf(e);if(-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1),e.name)){const t=this._nameIndex.get(e.name);t&&(t.delete(e),0===t.size&&this._nameIndex.delete(e.name))}}findByName(e){const t=this._nameIndex.get(e);if(!t)return null;for(const e of t)if(!e.destroyed)return e;return null}findAllByName(e){const t=this._nameIndex.get(e);if(!t)return[];const s=[];for(const e of t)e.destroyed||s.push(e);return s}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null,this._nameIndex=null}};exports.LOAD_SCENE_MODE=void 0,(A=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",A.MULTI_CANVAS="MULTI_CANVAS";const w=e=>{if((e instanceof k||e instanceof c)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof c?console.error(`${e.constructor.componentName} start error`,t):console.error(`${e.constructor.systemName} start error`,t)}}};var D,j,L=class extends n{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 E(this,void 0,void 0,function*(){if("undefined"!=typeof window&&window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new C({autoStart:!1,frameRate:t}),this.initTicker(),e&&e.length)for(const t of e)yield this.addSystem(t);r&&this.loadScene(new I("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)}findByName(e){var t;const s=null===(t=this._scene)||void 0===t?void 0:t.findByName(e);if(s)return s;for(const t of this.multiScenes){const s=t.findByName(e);if(s)return s}return null}findAllByName(e){var t;const s=(null===(t=this._scene)||void 0===t?void 0:t.findAllByName(e))||[];for(const t of this.multiScenes){const r=t.findAllByName(e);for(const e of r)s.push(e)}return s}addSystem(e,s){return E(this,void 0,void 0,function*(){let r;if(e instanceof Function)r=new e(s);else{if(!(e instanceof k))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){p[t.systemName]=t.observerInfo,h[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){l[s]=l[s]||[];const r=l[s];for(const o of e.observerInfo[s])-1===r.findIndex(e=>t.isEqual(e,o))&&l[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 k&&(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.scene.destroy(),requestAnimationFrame(()=>{this.pause(),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})}}pauseScene({scene:e}){this.emit("pauseScene",{scene:e})}startScene({scene:e}){this.emit("startScene",{scene:e})}destroyScene({scene:e}){const t=this.multiScenes.findIndex(t=>t===e);if(t>-1){const e=this.multiScenes.splice(t,1)[0];this.emit("sceneDestroyed",{scene:e})}}};function $(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function U(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 V extends n{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)}}exports.LOAD_EVENT=void 0,(D=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",D.PROGRESS="progress",D.LOADED="loaded",D.COMPLETE="complete",D.ERROR="error",exports.RESOURCE_TYPE=void 0,(j=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",j.SPRITE="SPRITE",j.SPRITE_ANIMATION="SPRITE_ANIMATION",j.AUDIO="AUDIO",j.VIDEO="VIDEO",j.FONT="FONT";const F=new class extends n{constructor(e){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},this.resourceUrlsMap={},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"):t&&(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 V({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})}getResource(e){return E(this,void 0,void 0,function*(){return this.loadResource({names:[e]}),this.promiseMap[e]||Promise.resolve({})})}instance(e){return E(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 E(this,void 0,void 0,function*(){yield this._destroy(e)})}_destroy(e,t=!1){var s;return E(this,void 0,void 0,function*(){const o=this.resourcesMap[e];if(!o)return;if(!t)try{this.destroyInstanceFunctions[o.type]&&(yield this.destroyInstanceFunctions[o.type](o))}catch(e){console.warn(`destroy resource ${o.name} error with '${e.message}'`)}const n=this.resourceUrlsMap[e]||[];if(0===n.length&&o.src)for(const e in o.src){let t=null===(s=o.src[e])||void 0===s?void 0:s.url;t&&("string"==typeof t&&t.startsWith("//")&&(t=`https:${t}`),n.push(t))}if(n.length>0)try{yield r.Assets.unload(n);for(const e of n)try{const t=r.Assets.resolver||r.Assets._resolver;t&&t._assetMap&&(delete t._assetMap[e],delete t._resolverHash[e])}catch(e){}}catch(t){console.warn(`Failed to unload assets for ${e}: ${t.message}`)}delete this.promiseMap[e],delete this.resourceUrlsMap[e],o.data={},o.complete=!1,o.instance=void 0,delete this.resourcesMap[e]})}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=>E(this,void 0,void 0,function*(){var s;this.promiseMap[e]=new Promise(t=>o[e]=t);const n=this.resourcesMap[e];this.resourceUrlsMap[e]||(this.resourceUrlsMap[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;if("string"==typeof a&&a.startsWith("//")&&(a=`https:${n.src[i].url}`),a&&this.resourceUrlsMap[e]&&!this.resourceUrlsMap[e].includes(a)&&this.resourceUrlsMap[e].push(a),"atlas"===i){const s=r.Assets.load(n.src.image.url).catch(s=>{this.onError({preload:t,errMsg:s.message,resource:{metadata:{key:i,name:e,resolves:o}}})});r.Assets.add({alias:a,src:a,loadParser:n.src[i].loadParser,data:{resolve:()=>s,imageTexture:yield s}})}else{const s={alias:a,src:a};if(n.src[i].loadParser&&(s.loadParser=n.src[i].loadParser),n.type===exports.RESOURCE_TYPE.SPRITE||n.type===exports.RESOURCE_TYPE.SPRITE_ANIMATION){if("json"===n.src[i].type)try{const e=yield r.Assets.load(n.src.image.url);s.data={texture:e}}catch(s){console.log(">>>E",s),this.onError({preload:t,errMsg:s.message,resource:{metadata:{key:i,name:e,resolves:o}}})}}else n.type===exports.RESOURCE_TYPE.FONT&&(s.data={family:e});r.Assets.add(s)}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 E(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 E(this,void 0,void 0,function*(){const{metadata:{key:s,name:r,resolves:o},data:n}=t,i=this.resourcesMap[r];i?(i.data[s]=n,this.doComplete(r,o[r],e)):console.warn("no resource data found")})}onError({errMsg:e,preload:t=!1,resource:s}){return E(this,void 0,void 0,function*(){const{metadata:{name:r,resolves:o}}=s;if(delete this.promiseMap[r],delete this.resourceUrlsMap[r],o[r]({}),t){const t={name:r,resource:this.resourcesMap[r],success:!1,errMsg:e};this.progress.onProgress(t)}})}},G={IDEProp:$,componentObserver:U},Y="2.0.2-beta.3";console.log(`Eva.js version: ${Y}`);exports.Component=c,exports.Game=L,exports.GameObject=R,exports.IDEProp=$,exports.RESOURCE_TYPE_STRATEGY={},exports.Scene=I,exports.System=k,exports.Transform=v,exports.componentObserver=U,exports.decorators=G,exports.resource=F,exports.version=Y;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("@eva/inspector-decorator"),s=require("lodash-es"),r=require("pixi.js");function o(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var n=o(e);function a(e={}){return t.Field(e)}class i extends n{static getInspectorMetadata(){return t.getPropertiesOf(this)}constructor(e){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=e}getInspectorMetadata(){return this.constructor.getInspectorMetadata()}}var c,l=i;exports.OBSERVER_TYPE=void 0,(c=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",c.REMOVE="REMOVE",c.CHANGE="CHANGE";const m={},p={},d={},u={};function h(e,t){m[e.gameObject.id]||(m[e.gameObject.id]={});const s=m[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,a;null===(a=null===(n=p[e])||void 0===n?void 0:n.componentObserver)||void 0===a||a.add({component:s,prop:r,type:o,componentName:t})}function y({obj:e,key:t,prop:r,component:o,componentName:n}){if(void 0!==e)if(t in e){if(Object.defineProperty(e,`_${t}`,{enumerable:!1,writable:!0,value:e[t]}),r.deep&&s.isObject(e[t]))for(const s of Object.keys(e[t]))y({obj:e[t],key:s,prop:r,component:o,componentName:n});Object.defineProperty(e,t,{enumerable:!0,set(a){e[`_${t}`]!==a&&(e[`_${t}`]=a,function({prop:e,component:t,componentName:r}){for(const o in d){const n=(d[o]||{})[r];n&&(n.findIndex(t=>s.isEqual(t,e))>-1&&f({systemName:o,componentName:r,component:t,prop:e,type:exports.OBSERVER_TYPE.CHANGE}))}}({prop:r,component:o,componentName:n}))},get:()=>e[`_${t}`]})}else console.error(`prop ${t} not in component: ${n}, Can not observer`)}function g(e,t=e.name){var s,r;for(const o in d){(d[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 m[e.gameObject.id]}(e)}function v(e,t,s,r){var o,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,s,r);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(a=(n<3?o(a):n>3?o(t,s,a):o(t,s))||a);return n>3&&a&&Object.defineProperty(t,s,a),a}function E(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function b(e,t,s,r){return new(s||(s=Promise))(function(o,n){function a(e){try{c(r.next(e))}catch(e){n(e)}}function i(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(a,i)}c((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class _ extends l{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",v([t.type("vector2"),t.step(1),E("design:type",Object)],_.prototype,"position",void 0),v([t.type("size"),t.step(1),E("design:type",Object)],_.prototype,"size",void 0),v([t.type("vector2"),t.step(.1),E("design:type",Object)],_.prototype,"origin",void 0),v([t.type("vector2"),t.step(.1),E("design:type",Object)],_.prototype,"anchor",void 0),v([t.type("vector2"),t.step(.1),E("design:type",Object)],_.prototype,"scale",void 0),v([t.type("vector2"),t.step(.1),E("design:type",Object)],_.prototype,"skew",void 0),v([t.type("number"),t.step(.1),E("design:type",Number)],_.prototype,"rotation",void 0);var O=_;let M=0;class R{constructor(e,t){this._componentCache={},this.components=[],this.destroyed=!1,this._name=e,this.id=++M,this.addComponent(O,t)}get transform(){return this.getComponent(O)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get children(){return this.transform.children.map(e=>e.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 R))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 R&&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 i?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 l))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 d)(d[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}=h(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 l?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 l?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}}}var T=R;var x=class{constructor(){this.events=[]}add({component:e,prop:t,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&&s.isEqual(o.prop,t)&&o.type===r);n>-1&&this.events.splice(n,1),this.events.push({gameObject:e.gameObject,component:e,prop:t,type:r,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const e=this.events;return this.events=[],e}};var k=class{constructor(e){this.started=!1,this.componentObserver=new x,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 S=function(){let e=null;return e=Date.now?Date.now:()=>(new Date).getTime(),e}(),j={originTime:0,playbackRate:1};class P{constructor(e,t){e instanceof P&&(t=e,e={}),e=Object.assign({},j,e),t&&(this._parent=t),this._createTime=S(),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:S()-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 P(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 C=P;const I={autoStart:!0,frameRate:60};var N=class{constructor(e){e=Object.assign({},I,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new C({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;let t=0;for(;e-this._lastFrameTime>=this._frameDuration&&t<5;){this._lastFrameTime+=this._frameDuration,t++;const e={deltaTime:this._frameDuration,time:this._lastFrameTime,currentTime:this._lastFrameTime,frameCount:++this._frameCount,fps:this.frameRate};for(const t of this._tickers)"function"==typeof t&&t(e)}e-this._lastFrameTime>=this._frameDuration&&(this._lastFrameTime=e)}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,null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null),this.timeline.playbackRate=0}setPlaybackRate(e){this.timeline.playbackRate=e}};var w,A=class extends T{constructor(e,t){super(e,t),this.gameObjects=[],this._nameIndex=new Map,this.scene=this}addGameObject(e){if(this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0),e.name){let t=this._nameIndex.get(e.name);t||(t=new Set,this._nameIndex.set(e.name,t)),t.add(e)}}removeGameObject(e){const t=this.gameObjects.indexOf(e);if(-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1),e.name)){const t=this._nameIndex.get(e.name);t&&(t.delete(e),0===t.size&&this._nameIndex.delete(e.name))}}findByName(e){const t=this._nameIndex.get(e);if(!t)return null;for(const e of t)if(!e.destroyed)return e;return null}findAllByName(e){const t=this._nameIndex.get(e);if(!t)return[];const s=[];for(const e of t)e.destroyed||s.push(e);return s}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null,this._nameIndex=null}};exports.LOAD_SCENE_MODE=void 0,(w=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",w.MULTI_CANVAS="MULTI_CANVAS";const D=e=>{if((e instanceof k||e instanceof l)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof l?console.error(`${e.constructor.componentName} start error`,t):console.error(`${e.constructor.systemName} start error`,t)}}};var U,F,L=class extends n{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 b(this,void 0,void 0,function*(){if("undefined"!=typeof window&&window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new N({autoStart:!1,frameRate:t}),this.initTicker(),e&&e.length)for(const t of e)yield this.addSystem(t);r&&this.loadScene(new A("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)}findByName(e){var t;const s=null===(t=this._scene)||void 0===t?void 0:t.findByName(e);if(s)return s;for(const t of this.multiScenes){const s=t.findByName(e);if(s)return s}return null}findAllByName(e){var t;const s=(null===(t=this._scene)||void 0===t?void 0:t.findAllByName(e))||[];for(const t of this.multiScenes){const r=t.findAllByName(e);for(const e of r)s.push(e)}return s}addSystem(e,t){return b(this,void 0,void 0,function*(){let r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof k))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){d[t.systemName]=t.observerInfo,p[t.systemName]=e}(r,r.constructor),function(e){const t=[];e instanceof Array?t.push(...e):t.push(e);for(const e of t)for(const t in e.observerInfo){u[t]=u[t]||[];const r=u[t];for(const o of e.observerInfo[t])-1===r.findIndex(e=>s.isEqual(e,o))&&u[t].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 k&&(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{D(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{D(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(){var e,t;this.removeAllListeners(),this.playing?this.pause():null===(e=this.ticker)||void 0===e||e.pause(),null===(t=this.scene)||void 0===t||t.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})}}pauseScene({scene:e}){this.emit("pauseScene",{scene:e})}startScene({scene:e}){this.emit("startScene",{scene:e})}destroyScene({scene:e}){const t=this.multiScenes.findIndex(t=>t===e);if(t>-1){const e=this.multiScenes.splice(t,1)[0];this.emit("sceneDestroyed",{scene:e})}}};function $(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 G extends n{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)}}exports.LOAD_EVENT=void 0,(U=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",U.PROGRESS="progress",U.LOADED="loaded",U.COMPLETE="complete",U.ERROR="error",exports.RESOURCE_TYPE=void 0,(F=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",F.SPRITE="SPRITE",F.SPRITE_ANIMATION="SPRITE_ANIMATION",F.AUDIO="AUDIO",F.VIDEO="VIDEO",F.FONT="FONT";const Y=new class extends n{constructor(e){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},this.resourceUrlsMap={},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"):t&&(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 G({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})}getResource(e){return b(this,void 0,void 0,function*(){return this.loadResource({names:[e]}),this.promiseMap[e]||Promise.resolve({})})}instance(e){return b(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 b(this,void 0,void 0,function*(){yield this._destroy(e)})}_destroy(e,t=!1){var s;return b(this,void 0,void 0,function*(){const o=this.resourcesMap[e];if(!o)return;if(!t)try{this.destroyInstanceFunctions[o.type]&&(yield this.destroyInstanceFunctions[o.type](o))}catch(e){console.warn(`destroy resource ${o.name} error with '${e.message}'`)}const n=this.resourceUrlsMap[e]||[];if(0===n.length&&o.src)for(const e in o.src){let t=null===(s=o.src[e])||void 0===s?void 0:s.url;t&&("string"==typeof t&&t.startsWith("//")&&(t=`https:${t}`),n.push(t))}if(n.length>0)try{yield r.Assets.unload(n);for(const e of n)try{const t=r.Assets.resolver||r.Assets._resolver;t&&t._assetMap&&(delete t._assetMap[e],delete t._resolverHash[e])}catch(e){}}catch(t){console.warn(`Failed to unload assets for ${e}: ${t.message}`)}delete this.promiseMap[e],delete this.resourceUrlsMap[e],o.data={},o.complete=!1,o.instance=void 0,delete this.resourcesMap[e]})}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=>b(this,void 0,void 0,function*(){var s;this.promiseMap[e]=new Promise(t=>o[e]=t);const n=this.resourcesMap[e];this.resourceUrlsMap[e]||(this.resourceUrlsMap[e]=[]);for(const e of this.preProcessResourceHandlers)e(n);for(const a in n.src){if("data"===n.src[a].type)n.data[a]=n.src[a].data,this.doComplete(e,o[e],t);else{let i=null===(s=n.src[a])||void 0===s?void 0:s.url;if("string"==typeof i&&i.startsWith("//")&&(i=`https:${n.src[a].url}`),i&&this.resourceUrlsMap[e]&&!this.resourceUrlsMap[e].includes(i)&&this.resourceUrlsMap[e].push(i),"atlas"===a){const s=r.Assets.load(n.src.image.url).catch(s=>{this.onError({preload:t,errMsg:s.message,resource:{metadata:{key:a,name:e,resolves:o}}})});r.Assets.add({alias:i,src:i,loadParser:n.src[a].loadParser,data:{resolve:()=>s,imageTexture:yield s}})}else{const s={alias:i,src:i};if(n.src[a].loadParser&&(s.loadParser=n.src[a].loadParser),n.type===exports.RESOURCE_TYPE.SPRITE||n.type===exports.RESOURCE_TYPE.SPRITE_ANIMATION){if("json"===n.src[a].type)try{const e=yield r.Assets.load(n.src.image.url);s.data={texture:e}}catch(s){console.log(">>>E",s),this.onError({preload:t,errMsg:s.message,resource:{metadata:{key:a,name:e,resolves:o}}})}}else n.type===exports.RESOURCE_TYPE.FONT&&(s.data={family:e});r.Assets.add(s)}r.Assets.load(i).then(s=>{this.onLoad({preload:t,resource:{metadata:{key:a,name:e,resolves:o},data:s}})}).catch(s=>{console.log(">>>E",s),this.onError({preload:t,errMsg:s.message,resource:{metadata:{key:a,name:e,resolves:o}}})})}}}))}doComplete(e,t,s=!1){return b(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 b(this,void 0,void 0,function*(){const{metadata:{key:s,name:r,resolves:o},data:n}=t,a=this.resourcesMap[r];a?(a.data[s]=n,this.doComplete(r,o[r],e)):console.warn("no resource data found")})}onError({errMsg:e,preload:t=!1,resource:s}){return b(this,void 0,void 0,function*(){const{metadata:{name:r,resolves:o}}=s;if(delete this.promiseMap[r],delete this.resourceUrlsMap[r],o[r]({}),t){const t={name:r,resource:this.resourcesMap[r],success:!1,errMsg:e};this.progress.onProgress(t)}})}},B=(()=>{const e=globalThis.performance;return e&&"function"==typeof e.now?e.now.bind(e):()=>Date.now()})();const q={IDEProp:$,componentObserver:V,ExecuteInEditMode:t.ExecuteInEditMode,Field:t.Field,getPropertiesOf:t.getPropertiesOf,inspectorField:a,shouldExecuteInEditMode:t.shouldExecuteInEditMode,step:t.step,type:t.type},H="2.1.0-beta.0";console.log(`Eva.js version: ${H}`);exports.ExecuteInEditMode=t.ExecuteInEditMode,exports.Field=t.Field,exports.getPropertiesOf=t.getPropertiesOf,exports.shouldExecuteInEditMode=t.shouldExecuteInEditMode,exports.step=t.step,exports.type=t.type,exports.Component=l,exports.Game=L,exports.GameObject=T,exports.IDEProp=$,exports.RESOURCE_TYPE_STRATEGY={},exports.Scene=A,exports.System=k,exports.Transform=O,exports.componentObserver=V,exports.decorators=q,exports.inspectorField=a,exports.installPerfProbes=function(e,t={}){var s,r,o,n,a,i,c,l,m,p,d;const u=null!==(s=t.sampleSize)&&void 0!==s?s:60,h=null===(r=t.warnOnViolation)||void 0===r||r,f={maxFrameMs:null!==(n=null===(o=t.budget)||void 0===o?void 0:o.maxFrameMs)&&void 0!==n?n:16.67,minFps:null!==(i=null===(a=t.budget)||void 0===a?void 0:a.minFps)&&void 0!==i?i:30,sustainedFrames:null!==(l=null===(c=t.budget)||void 0===c?void 0:c.sustainedFrames)&&void 0!==l?l:60,maxSystemMs:null===(m=t.budget)||void 0===m?void 0:m.maxSystemMs,maxGameObjects:null===(p=t.budget)||void 0===p?void 0:p.maxGameObjects},y=new Map;let g=0;const v=[];let E=null;const b=new Map,_=new Set,O=new Set,M=new Map;let R=!1;function T(e){var t,s,r;if(b.has(e))return;const o=null!==(t=Object.getPrototypeOf(e))&&void 0!==t?t:{},n=Object.prototype.hasOwnProperty.call(e,"update"),a=Object.prototype.hasOwnProperty.call(e,"lateUpdate"),i=null!==(s=e.update)&&void 0!==s?s:o.update,c=null!==(r=e.lateUpdate)&&void 0!==r?r:o.lateUpdate;if("function"==typeof i){const t=i;e.update=function(s){var r;const o=B();try{return t.call(this,s)}finally{const t=B()-o,s=null!==(r=y.get(e))&&void 0!==r?r:{updateMs:0,lateUpdateMs:0};s.updateMs+=t,y.set(e,s)}}}if("function"==typeof c){const t=c;e.lateUpdate=function(s){var r;const o=B();try{return t.call(this,s)}finally{const t=B()-o,s=null!==(r=y.get(e))&&void 0!==r?r:{updateMs:0,lateUpdateMs:0};s.lateUpdateMs+=t,y.set(e,s)}}}b.set(e,{system:e,origUpdate:i,origLateUpdate:c,hadOwnUpdate:n,hadOwnLateUpdate:a})}function x(e){const{system:t,origUpdate:s,origLateUpdate:r,hadOwnUpdate:o,hadOwnLateUpdate:n}=e;"function"==typeof s&&(o?t.update=s:delete t.update),"function"==typeof r&&(n?t.lateUpdate=r:delete t.lateUpdate)}const k=t=>{var s;g=B(),y.clear();for(const t of null!==(s=e.systems)&&void 0!==s?s:[])b.has(t)||T(t)},S=t=>{var s,r;const o=B(),n=Math.max(0,o-g),a=(null!==(s=e.systems)&&void 0!==s?s:[]).map(e=>{var t,s,r;const o=null!==(t=y.get(e))&&void 0!==t?t:{updateMs:0,lateUpdateMs:0};return{name:e.name||(null===(s=e.constructor)||void 0===s?void 0:s.systemName)||(null===(r=e.constructor)||void 0===r?void 0:r.name)||"UnknownSystem",updateMs:o.updateMs,lateUpdateMs:o.lateUpdateMs}}),i=a.reduce((e,t)=>e+t.updateMs+t.lateUpdateMs,0),c=Math.max(0,n-i),l=(null!==(r=e.gameObjects)&&void 0!==r?r:[]).length,m=t&&"number"==typeof t.frameCount?t.frameCount:0;v.push({frameCount:m,fps:0,frameMs:n,systems:a,gameObjectsMs:c,gameObjectCount:l}),v.length>u&&v.shift();const p=v.reduce((e,t)=>e+t.frameMs,0),d=p>0?Math.min(1e3,1e3*v.length/p):1e3,b=v[v.length-1];if(b.fps=d,E=b,_.size)for(const e of Array.from(_))try{e(b)}catch(e){console.error("[perf-probes] onFrame callback error",e)}!function(e){var t;const s=[];"number"==typeof f.maxFrameMs&&s.push({name:"frameMs",actual:e.frameMs,threshold:f.maxFrameMs,over:e.frameMs>f.maxFrameMs});"number"==typeof f.minFps&&s.push({name:"fps",actual:e.fps,threshold:f.minFps,over:e.fps<f.minFps});"number"==typeof f.maxGameObjects&&s.push({name:"gameObjects",actual:e.gameObjectCount,threshold:f.maxGameObjects,over:e.gameObjectCount>f.maxGameObjects});if(f.maxSystemMs)for(const t of e.systems){const e=f.maxSystemMs[t.name];if("number"==typeof e){const r=t.updateMs+t.lateUpdateMs;s.push({name:`system:${t.name}`,actual:r,threshold:e,over:r>e})}}for(const r of s){let s=M.get(r.name);if(s||(s={consec:0,count:0,last:r.actual},M.set(r.name,s)),s.last=r.actual,r.over){if(s.consec+=1,s.consec>=(null!==(t=f.sustainedFrames)&&void 0!==t?t:60)){s.count+=1,s.consec=0;const t={name:r.name,actual:r.actual,threshold:r.threshold,frame:e};if(h&&console.warn(`[perf-probes] sustained violation ${r.name}: actual=${r.actual.toFixed(2)} threshold=${r.threshold}`),O.size)for(const e of Array.from(O))try{e(t)}catch(e){console.error("[perf-probes] onViolation callback error",e)}}}else s.consec=0}}(b)},j=(()=>{const t=e.ticker;return t?t._tickers:null})();let P=[];if(j){P=Array.from(j),j.clear(),j.add(k);for(const e of P)j.add(e);j.add(S)}for(const t of null!==(d=e.systems)&&void 0!==d?d:[])T(t);return{current:()=>E,average:function(){var e;if(0===v.length)return null;const t=v.length;let s=0,r=0,o=0,n=0,a=0;const i=v[t-1],c=new Map;for(const t of v){s+=t.frameMs,r+=t.fps,o+=t.gameObjectsMs,n+=t.gameObjectCount,a=t.frameCount;for(const s of t.systems){const t=null!==(e=c.get(s.name))&&void 0!==e?e:{updateMs:0,lateUpdateMs:0,n:0};t.updateMs+=s.updateMs,t.lateUpdateMs+=s.lateUpdateMs,t.n+=1,c.set(s.name,t)}}const l=i.systems.map(e=>{var t;const s=null!==(t=c.get(e.name))&&void 0!==t?t:{updateMs:0,lateUpdateMs:0,n:1};return{name:e.name,updateMs:s.updateMs/s.n,lateUpdateMs:s.lateUpdateMs/s.n}});return{frameCount:a,fps:r/t,frameMs:s/t,systems:l,gameObjectsMs:o/t,gameObjectCount:n/t}},violations(){const e=[];for(const[t,s]of M)0!==s.count&&e.push({name:t,count:s.count,last:s.last});return e},onFrame:e=>(_.add(e),()=>{_.delete(e)}),onViolation:e=>(O.add(e),()=>{O.delete(e)}),uninstall(){if(!R){if(R=!0,j){const e=Array.from(j).filter(e=>e!==k&&e!==S&&!P.includes(e));j.clear();for(const e of P)j.add(e);for(const t of e)j.add(t)}for(const e of b.values())x(e);b.clear(),v.length=0,E=null,_.clear(),O.clear(),M.clear(),y.clear()}}}},exports.resource=Y,exports.version=H;

@@ -0,4 +1,14 @@

import type { ClassType } from '@eva/inspector-decorator';
import EE from 'eventemitter3';
import EventEmitter from 'eventemitter3';
import { ExecuteInEditMode } from '@eva/inspector-decorator';
import { Field } from '@eva/inspector-decorator';
import type { FieldMetadata } from '@eva/inspector-decorator';
import type { FieldOptions } from '@eva/inspector-decorator';
import { getPropertiesOf } from '@eva/inspector-decorator';
import { LoadParserName } from 'pixi.js';
import { shouldExecuteInEditMode } from '@eva/inspector-decorator';
import { step } from '@eva/inspector-decorator';
import { type } from '@eva/inspector-decorator';
export { ClassType }

@@ -32,2 +42,9 @@ /**

static componentName: string;
/**
* 获取当前组件类的 Inspector 元数据。
*
* 该方法读取 `@eva/inspector-decorator` 生成的 metadata,
* 同时兼容没有字段装饰器、但定义了 componentName 的组件。
*/
static getInspectorMetadata(): FieldMetadata;
/** 组件实例的名称 */

@@ -55,2 +72,6 @@ readonly name: string;

/**
* 获取当前组件实例所属组件类的 Inspector 元数据。
*/
getInspectorMetadata(): FieldMetadata;
/**
* 组件构造期间调用的初始化方法

@@ -189,6 +210,15 @@ *

/** Decorators util */
export declare const decorators: {
export declare const decorators: DecoratorsUtil;
declare interface DecoratorsUtil {
IDEProp: typeof IDEProp;
componentObserver: typeof componentObserver;
};
ExecuteInEditMode: typeof ExecuteInEditMode;
Field: typeof Field;
getPropertiesOf: typeof getPropertiesOf;
inspectorField: typeof inspectorField;
shouldExecuteInEditMode: (target: ClassType<any>) => boolean;
step: typeof step;
type: typeof type;
}

@@ -205,2 +235,6 @@ declare interface DestroySceneParams {

}
export { ExecuteInEditMode }
export { Field }
export { FieldMetadata }
export { FieldOptions }

@@ -488,2 +522,3 @@ /**

}
export { getPropertiesOf }

@@ -497,2 +532,17 @@ /**

/**
* Backward-compatible alias for `Field`.
*/
export declare function inspectorField(options?: FieldOptions): PropertyDecorator;
/**
* 给一个 Game 实例装上性能探针。
*
* - 必须在 game 已经 init 之后调用(否则 game.ticker 还没有,会拒绝并打 warn)。
* - install 之后再 addSystem 的 system,probes 会在每帧 epilogue 自动 patch。
* - 同一 game 多次 install:旧 handle 应先 uninstall;否则两套 hook 会串扰。
* - uninstall 后 install 必须能正常工作。
*/
export declare function installPerfProbes(game: Game, options?: PerfProbeOptions): PerfProbesHandle;
/** Load event */

@@ -572,2 +622,81 @@ export declare enum LOAD_EVENT {

/**
* 性能预算配置。任一字段缺省即不检查该项。
*/
export declare interface PerfBudget {
/** 单帧总耗时上限(ms),默认 16.67 */
maxFrameMs?: number;
/** 各 system 单独上限 — key 为 system.constructor.systemName 或 system.name */
maxSystemMs?: {
[name: string]: number;
};
/** gameObject 数量上限(瞬时) */
maxGameObjects?: number;
/** 真实 FPS 下限,默认 30 */
minFps?: number;
/** 连续 N 帧超标才告警,默认 60 */
sustainedFrames?: number;
}
/**
* 单帧采样数据。
*/
export declare interface PerfFrame {
/** Ticker 给出的 frameCount */
frameCount: number;
/** 滑动窗口估算的真实 FPS(基于 frameMs 累计) */
fps: number;
/** 本帧总耗时(systems update+lateUpdate + gameObjects 循环),毫秒 */
frameMs: number;
/** 各 system 本帧的 update / lateUpdate 时长,毫秒 */
systems: {
name: string;
updateMs: number;
lateUpdateMs: number;
}[];
/** 本帧 gameObjects 循环耗时,毫秒(估算 = frameMs - sum(systems)) */
gameObjectsMs: number;
/** 本帧 game.gameObjects 数量 */
gameObjectCount: number;
}
/**
* installPerfProbes 选项。
*/
export declare interface PerfProbeOptions {
budget?: PerfBudget;
/** 滑动窗口大小(帧),默认 60(约 1 秒) */
sampleSize?: number;
/** 触发 violation 时是否 console.warn,默认 true */
warnOnViolation?: boolean;
}
/** Probe 句柄。 */
export declare interface PerfProbesHandle {
/** 最近一帧采样,无则返回 null */
current(): PerfFrame | null;
/** 滑动窗口平均(每帧字段独立平均),无则返回 null */
average(): PerfFrame | null;
/** 本次 install 周期内累计违规计数 */
violations(): {
name: string;
count: number;
last: number;
}[];
/** 订阅每帧采样,返回 dispose 句柄 */
onFrame(fn: (frame: PerfFrame) => void): () => void;
/** 订阅 violation 触发,返回 dispose 句柄 */
onViolation(fn: (v: PerfViolation) => void): () => void;
/** 卸载所有 hook,把 system update 和 ticker._tickers 还原 */
uninstall(): void;
}
/** Violation 回调 payload。 */
export declare interface PerfViolation {
name: string;
actual: number;
threshold: number;
frame: PerfFrame;
}
/** eva plugin struct */

@@ -833,2 +962,3 @@ export declare interface PluginStruct {

}
export { shouldExecuteInEditMode }

@@ -857,2 +987,3 @@ /**

}
export { step }

@@ -1038,3 +1169,3 @@ /**

/** requestAnimationFrame 的句柄 ID */
_requestId: number;
_requestId: number | null;
/** 上一帧的渲染时间 */

@@ -1222,2 +1353,3 @@ private _lastFrameTime;

}
export { type }

@@ -1246,4 +1378,4 @@ /** 传递给 `Component.update` 方法的帧信息 */

export declare const version = "2.0.2-beta.3";
export declare const version = "2.1.0-beta.0";
export { }

@@ -1,1 +0,1 @@

function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(null,arguments)}var _EVA_IIFE_EVA=function(e,t){"use strict";var r=function(e){var t={exports:{}};return e(t,t.exports),t.exports}(function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new s(n,o||e,i),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function i(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}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 e,n,s=[];if(0===this._eventsCount)return s;for(n in e=this._events)t.call(e,n)&&s.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var s=0,o=n.length,i=new Array(o);s<o;s++)i[s]=n[s].fn;return i},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,s,o,i){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(e,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,n),!0;case 4:return h.fn.call(h.context,t,n,s),!0;case 5:return h.fn.call(h.context,t,n,s,o),!0;case 6:return h.fn.call(h.context,t,n,s,o,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,f=h.length;for(u=0;u<f;u++)switch(h[u].once&&this.removeListener(e,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,t);break;case 3:h[u].fn.call(h[u].context,t,n);break;case 4:h[u].fn.call(h[u].context,t,n,s);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(e,t,r){return o(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,s){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return i(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||s&&!a.once||n&&a.context!==n||i(this,o);else{for(var c=0,u=[],h=a.length;c<h;c++)(a[c].fn!==t||s&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[o]=1===u.length?u[0]:u:i(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&i(this,t)):(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,e.exports=a}),n=r;class s extends n{constructor(e){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=e}}var o=s,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,f=u?u.toStringTag:void 0;var m=Object.prototype.toString;var d=u?u.toStringTag:void 0;function y(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":d&&d in Object(e)?function(e){var t=l.call(e,f),r=e[f];try{e[f]=void 0;var n=!0}catch(e){}var s=p.call(e);return n&&(t?e[f]=r:delete e[f]),s}(e):function(e){return m.call(e)}(e)}function _(e){return null!=e&&"object"==typeof e}var v=Array.isArray;function b(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function g(e){if(!b(e))return!1;var t=y(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var E,O=c["__core-js_shared__"],j=(E=/[^.]+$/.exec(O&&O.keys&&O.keys.IE_PROTO||""))?"Symbol(src)_1."+E:"";var T=Function.prototype.toString;function R(e){if(null!=e){try{return T.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var w=/^\[object .+?Constructor\]$/,k=Function.prototype,A=Object.prototype,S=k.toString,P=A.hasOwnProperty,M=RegExp("^"+S.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function I(e){return!(!b(e)||(t=e,j&&j in t))&&(g(e)?M:w).test(R(e));var t}function N(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return I(r)?r:void 0}var C=N(c,"WeakMap"),D=/^(?:0|[1-9]\d*)$/;function x(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&D.test(e))&&e>-1&&e%1==0&&e<t}function L(e,t){return e===t||e!=e&&t!=t}function V(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var $=Object.prototype;function F(e){return _(e)&&"[object Arguments]"==y(e)}var U=Object.prototype,z=U.hasOwnProperty,B=U.propertyIsEnumerable,G=F(function(){return arguments}())?F:function(e){return _(e)&&z.call(e,"callee")&&!B.call(e,"callee")},Y=G;var H="object"==typeof e&&e&&!e.nodeType&&e,q=H&&"object"==typeof module&&module&&!module.nodeType&&module,W=q&&q.exports===H?c.Buffer:void 0,X=(W?W.isBuffer:void 0)||function(){return!1},J={};J["[object Float32Array]"]=J["[object Float64Array]"]=J["[object Int8Array]"]=J["[object Int16Array]"]=J["[object Int32Array]"]=J["[object Uint8Array]"]=J["[object Uint8ClampedArray]"]=J["[object Uint16Array]"]=J["[object Uint32Array]"]=!0,J["[object Arguments]"]=J["[object Array]"]=J["[object ArrayBuffer]"]=J["[object Boolean]"]=J["[object DataView]"]=J["[object Date]"]=J["[object Error]"]=J["[object Function]"]=J["[object Map]"]=J["[object Number]"]=J["[object Object]"]=J["[object RegExp]"]=J["[object Set]"]=J["[object String]"]=J["[object WeakMap]"]=!1;var K,Q="object"==typeof e&&e&&!e.nodeType&&e,Z=Q&&"object"==typeof module&&module&&!module.nodeType&&module,ee=Z&&Z.exports===Q&&i.process,te=function(){try{var e=Z&&Z.require&&Z.require("util").types;return e||ee&&ee.binding&&ee.binding("util")}catch(e){}}(),re=te&&te.isTypedArray,ne=re?(K=re,function(e){return K(e)}):function(e){return _(e)&&V(e.length)&&!!J[y(e)]},se=Object.prototype.hasOwnProperty;function oe(e,t){var r=v(e),n=!r&&Y(e),s=!r&&!n&&X(e),o=!r&&!n&&!s&&ne(e),i=r||n||s||o,a=i?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=a.length;for(var u in e)!t&&!se.call(e,u)||i&&("length"==u||s&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||x(u,c))||a.push(u);return a}var ie=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),ae=ie,ce=Object.prototype.hasOwnProperty;function ue(e){if(r=(t=e)&&t.constructor,t!==("function"==typeof r&&r.prototype||$))return ae(e);var t,r,n=[];for(var s in Object(e))ce.call(e,s)&&"constructor"!=s&&n.push(s);return n}function he(e){return null!=(t=e)&&V(t.length)&&!g(t)?oe(e):ue(e);var t}var le=N(Object,"create");var pe=Object.prototype.hasOwnProperty;var fe=Object.prototype.hasOwnProperty;function me(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function de(e,t){for(var r=e.length;r--;)if(L(e[r][0],t))return r;return-1}me.prototype.clear=function(){this.__data__=le?le(null):{},this.size=0},me.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},me.prototype.get=function(e){var t=this.__data__;if(le){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return pe.call(t,e)?t[e]:void 0},me.prototype.has=function(e){var t=this.__data__;return le?void 0!==t[e]:fe.call(t,e)},me.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=le&&void 0===t?"__lodash_hash_undefined__":t,this};var ye=Array.prototype.splice;function _e(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}_e.prototype.clear=function(){this.__data__=[],this.size=0},_e.prototype.delete=function(e){var t=this.__data__,r=de(t,e);return!(r<0)&&(r==t.length-1?t.pop():ye.call(t,r,1),--this.size,!0)},_e.prototype.get=function(e){var t=this.__data__,r=de(t,e);return r<0?void 0:t[r][1]},_e.prototype.has=function(e){return de(this.__data__,e)>-1},_e.prototype.set=function(e,t){var r=this.__data__,n=de(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var ve=N(c,"Map");function be(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function ge(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ge.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(ve||_e),string:new me}},ge.prototype.delete=function(e){var t=be(this,e).delete(e);return this.size-=t?1:0,t},ge.prototype.get=function(e){return be(this,e).get(e)},ge.prototype.has=function(e){return be(this,e).has(e)},ge.prototype.set=function(e,t){var r=be(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function Ee(e){var t=this.__data__=new _e(e);this.size=t.size}Ee.prototype.clear=function(){this.__data__=new _e,this.size=0},Ee.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Ee.prototype.get=function(e){return this.__data__.get(e)},Ee.prototype.has=function(e){return this.__data__.has(e)},Ee.prototype.set=function(e,t){var r=this.__data__;if(r instanceof _e){var n=r.__data__;if(!ve||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new ge(n)}return r.set(e,t),this.size=r.size,this};var Oe=Object.prototype.propertyIsEnumerable,je=Object.getOwnPropertySymbols,Te=je?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,s=0,o=[];++r<n;){var i=e[r];t(i,r,e)&&(o[s++]=i)}return o}(je(e),function(t){return Oe.call(e,t)}))}:function(){return[]};function Re(e){return function(e,t,r){var n=t(e);return v(e)?n:function(e,t){for(var r=-1,n=t.length,s=e.length;++r<n;)e[s+r]=t[r];return e}(n,r(e))}(e,he,Te)}var we=N(c,"DataView"),ke=N(c,"Promise"),Ae=N(c,"Set"),Se="[object Map]",Pe="[object Promise]",Me="[object Set]",Ie="[object WeakMap]",Ne="[object DataView]",Ce=R(we),De=R(ve),xe=R(ke),Le=R(Ae),Ve=R(C),$e=y;(we&&$e(new we(new ArrayBuffer(1)))!=Ne||ve&&$e(new ve)!=Se||ke&&$e(ke.resolve())!=Pe||Ae&&$e(new Ae)!=Me||C&&$e(new C)!=Ie)&&($e=function(e){var t=y(e),r="[object Object]"==t?e.constructor:void 0,n=r?R(r):"";if(n)switch(n){case Ce:return Ne;case De:return Se;case xe:return Pe;case Le:return Me;case Ve:return Ie}return t});var Fe=$e,Ue=c.Uint8Array;function ze(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new ge;++t<r;)this.add(e[t])}function Be(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}ze.prototype.add=ze.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},ze.prototype.has=function(e){return this.__data__.has(e)};function Ge(e,t,r,n,s,o){var i=1&r,a=e.length,c=t.length;if(a!=c&&!(i&&c>a))return!1;var u=o.get(e),h=o.get(t);if(u&&h)return u==t&&h==e;var l=-1,p=!0,f=2&r?new ze:void 0;for(o.set(e,t),o.set(t,e);++l<a;){var m=e[l],d=t[l];if(n)var y=i?n(d,m,l,t,e,o):n(m,d,l,e,t,o);if(void 0!==y){if(y)continue;p=!1;break}if(f){if(!Be(t,function(e,t){if(i=t,!f.has(i)&&(m===e||s(m,e,r,n,o)))return f.push(t);var i})){p=!1;break}}else if(m!==d&&!s(m,d,r,n,o)){p=!1;break}}return o.delete(e),o.delete(t),p}function Ye(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function He(e){var t=-1,r=Array(e.size);return e.forEach(function(e){r[++t]=e}),r}var qe=u?u.prototype:void 0,We=qe?qe.valueOf:void 0;var Xe=Object.prototype.hasOwnProperty;var Je,Ke="[object Arguments]",Qe="[object Array]",Ze="[object Object]",et=Object.prototype.hasOwnProperty;function tt(e,t,r,n,s,o){var i=v(e),a=v(t),c=i?Qe:Fe(e),u=a?Qe:Fe(t),h=(c=c==Ke?Ze:c)==Ze,l=(u=u==Ke?Ze:u)==Ze,p=c==u;if(p&&X(e)){if(!X(t))return!1;i=!0,h=!1}if(p&&!h)return o||(o=new Ee),i||ne(e)?Ge(e,t,r,n,s,o):function(e,t,r,n,s,o,i){switch(r){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!o(new Ue(e),new Ue(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return L(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=Ye;case"[object Set]":var c=1&n;if(a||(a=He),e.size!=t.size&&!c)return!1;var u=i.get(e);if(u)return u==t;n|=2,i.set(e,t);var h=Ge(a(e),a(t),n,s,o,i);return i.delete(e),h;case"[object Symbol]":if(We)return We.call(e)==We.call(t)}return!1}(e,t,c,r,n,s,o);if(!(1&r)){var f=h&&et.call(e,"__wrapped__"),m=l&&et.call(t,"__wrapped__");if(f||m){var d=f?e.value():e,y=m?t.value():t;return o||(o=new Ee),s(d,y,r,n,o)}}return!!p&&(o||(o=new Ee),function(e,t,r,n,s,o){var i=1&r,a=Re(e),c=a.length;if(c!=Re(t).length&&!i)return!1;for(var u=c;u--;){var h=a[u];if(!(i?h in t:Xe.call(t,h)))return!1}var l=o.get(e),p=o.get(t);if(l&&p)return l==t&&p==e;var f=!0;o.set(e,t),o.set(t,e);for(var m=i;++u<c;){var d=e[h=a[u]],y=t[h];if(n)var _=i?n(y,d,h,t,e,o):n(d,y,h,e,t,o);if(!(void 0===_?d===y||s(d,y,r,n,o):_)){f=!1;break}m||(m="constructor"==h)}if(f&&!m){var v=e.constructor,b=t.constructor;v==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b||(f=!1)}return o.delete(e),o.delete(t),f}(e,t,r,n,s,o))}function rt(e,t,r,n,s){return e===t||(null==e||null==t||!_(e)&&!_(t)?e!=e&&t!=t:tt(e,t,r,n,rt,s))}function nt(e,t){return rt(e,t)}e.OBSERVER_TYPE=void 0,(Je=e.OBSERVER_TYPE||(e.OBSERVER_TYPE={})).ADD="ADD",Je.REMOVE="REMOVE",Je.CHANGE="CHANGE";const st={},ot={},it={},at={};function ct(e,t){st[e.gameObject.id]||(st[e.gameObject.id]={});const r=st[e.gameObject.id],n=e.name+"_"+t.join(",");if(r[n])return r[n];const s=t.length-1;let o=e;for(let e=0;e<s;e++)o=o[t[e]];return r[n]={property:o,key:t[s]},r[n]}function ut({systemName:e,componentName:t,component:r,prop:n,type:s}){var o,i;null===(i=null===(o=ot[e])||void 0===o?void 0:o.componentObserver)||void 0===i||i.add({component:r,prop:n,type:s,componentName:t})}function ht({obj:t,key:r,prop:n,component:s,componentName:o}){if(void 0!==t)if(r in t){if(Object.defineProperty(t,`_${r}`,{enumerable:!1,writable:!0,value:t[r]}),n.deep&&b(t[r]))for(const e of Object.keys(t[r]))ht({obj:t[r],key:e,prop:n,component:s,componentName:o});Object.defineProperty(t,r,{enumerable:!0,set(i){t[`_${r}`]!==i&&(t[`_${r}`]=i,function({prop:t,component:r,componentName:n}){for(const s in it){const o=(it[s]||{})[n];o&&(o.findIndex(e=>nt(e,t))>-1&&ut({systemName:s,componentName:n,component:r,prop:t,type:e.OBSERVER_TYPE.CHANGE}))}}({prop:n,component:s,componentName:o}))},get:()=>t[`_${r}`]})}else console.error(`prop ${r} not in component: ${o}, Can not observer`)}function lt(t,r=t.name){var n,s;for(const o in it){(it[o]||{})[r]&&(null===(s=null===(n=ot[o])||void 0===n?void 0:n.componentObserver)||void 0===s||s.add({component:t,type:e.OBSERVER_TYPE.REMOVE,componentName:r}))}!function(e){e.gameObject&&delete st[e.gameObject.id]}(t)}function pt(e,t,r,n){var s,o=arguments.length,i=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(o<3?s(i):o>3?s(t,r,i):s(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i}function ft(e,t,r,n){return new(r||(r=Promise))(function(s,o){function i(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,a)}c((n=n.apply(e,t||[])).next())})}function mt(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function dt(e){return function(t,r){var n=mt(t,r);n.key=r,n.type=e}}function yt(e){return function(t,r){mt(t,r).step=e}}class _t extends o{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 r of t)_extends(this[r],e[r]);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}}_t.componentName="Transform",pt([dt("vector2"),yt(1)],_t.prototype,"position",void 0),pt([dt("size"),yt(1)],_t.prototype,"size",void 0),pt([dt("vector2"),yt(.1)],_t.prototype,"origin",void 0),pt([dt("vector2"),yt(.1)],_t.prototype,"anchor",void 0),pt([dt("vector2"),yt(.1)],_t.prototype,"scale",void 0),pt([dt("vector2"),yt(.1)],_t.prototype,"skew",void 0),pt([dt("number"),yt(.1)],_t.prototype,"rotation",void 0);var vt=_t;let bt=0;class gt{constructor(e,t){this._componentCache={},this.components=[],this.destroyed=!1,this._name=e,this.id=++bt,this.addComponent(vt,t)}get transform(){return this.getComponent(vt)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get children(){return this.transform.children.map(e=>e.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 gt))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 gt&&e.parent&&e.parent===this?(e.transform.parent=null,e.scene=null,e):e}addComponent(t,r){if(this.destroyed)return;const n=function(e){return e instanceof s?e.name:e instanceof Function?e.componentName:void 0}(t);if(this._componentCache[n])return;let i;if(t instanceof Function)i=new t(r);else{if(!(t instanceof o))throw new Error("addComponent recieve Component and Component Constructor");i=t}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(t,r=t.name){var n,s;for(const o in it)(it[o]||{})[r]&&(null===(s=null===(n=ot[o])||void 0===n?void 0:n.componentObserver)||void 0===s||s.add({component:t,type:e.OBSERVER_TYPE.ADD,componentName:r}))}(i,i.name),function(e,t=e.name){if(t&&at[t]){if(!(e&&(r=e,r&&r.constructor&&"componentName"in r.constructor)))throw new Error("component param must be an instance of Component");var r;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");for(const r of at[t]){const{property:n,key:s}=ct(e,r.prop);ht({obj:n,key:s,prop:r,component:e,componentName:t})}}}(i,i.name),this.components.push(i),this._componentCache[n]=i,i.awake&&i.awake(),i}removeComponent(e){let t;if("string"==typeof e?t=e:e instanceof o?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 r=this.components.splice(t,1)[0];return delete this._componentCache[e],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),lt(r,e),r.gameObject=void 0,r}getComponent(e){let t;return"string"==typeof e?t=e:e instanceof o?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}}}var Et=gt;var Ot=class{constructor(){this.events=[]}add({component:t,prop:r,type:n,componentName:s}){if(n===e.OBSERVER_TYPE.REMOVE){if(this.events.find(r=>r.component===t&&r.type===e.OBSERVER_TYPE.ADD))return void(this.events=this.events.filter(e=>e.component!==t));this.events=this.events.filter(e=>e.component!==t)}const o=this.events.findIndex(e=>e.component===t&&nt(e.prop,r)&&e.type===n);o>-1&&this.events.splice(o,1),this.events.push({gameObject:t.gameObject,component:t,prop:r,type:n,componentName:s})}getChanged(){return this.events}get changed(){return this.events}clear(){const e=this.events;return this.events=[],e}};var jt=class{constructor(e){this.started=!1,this.componentObserver=new Ot,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 Tt=function(){let e=null;return e=Date.now?Date.now:()=>(new Date).getTime(),e}(),Rt={originTime:0,playbackRate:1};class wt{constructor(e,t){e instanceof wt&&(t=e,e={}),e=_extends({},Rt,e),t&&(this._parent=t),this._createTime=Tt(),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:Tt()-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:r=this.playbackRate}={}){const n={globalTime:this.globalTime,localTime:e,entropy:t,playbackRate:r,globalEntropy:this.globalEntropy};this._timeMark.push(n)}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 wt(e,this)}seekGlobalTime(e){const t=this.seekTimeMark(e),r=this._timeMark[t],{entropy:n,playbackRate:s,globalTime:o}=r;return o+(e-n)/Math.abs(s)}seekLocalTime(e){const t=this.seekTimeMark(e),r=this._timeMark[t],{localTime:n,entropy:s,playbackRate:o}=r;return o>0?n+(e-s):n-(e-s)}seekTimeMark(e){const t=this._timeMark;let r=0,n=t.length-1;if(e<=t[r].entropy)return r;if(e>=t[n].entropy)return n;let s=Math.floor((r+n)/2);for(;s>r&&s<n;){if(e===t[s].entropy)return s;e<t[s].entropy?n=s:e>t[s].entropy&&(r=s),s=Math.floor((r+n)/2)}return r}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 kt=wt;const At={autoStart:!0,frameRate:60};var St=class{constructor(e){e=_extends({},At,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new kt({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;let t=0;for(;e-this._lastFrameTime>=this._frameDuration&&t<5;){this._lastFrameTime+=this._frameDuration,t++;const e={deltaTime:this._frameDuration,time:this._lastFrameTime,currentTime:this._lastFrameTime,frameCount:++this._frameCount,fps:this.frameRate};for(const t of this._tickers)"function"==typeof t&&t(e)}e-this._lastFrameTime>=this._frameDuration&&(this._lastFrameTime=e)}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 Pt,Mt=class extends Et{constructor(e,t){super(e,t),this.gameObjects=[],this._nameIndex=new Map,this.scene=this}addGameObject(e){if(this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0),e.name){let t=this._nameIndex.get(e.name);t||(t=new Set,this._nameIndex.set(e.name,t)),t.add(e)}}removeGameObject(e){const t=this.gameObjects.indexOf(e);if(-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1),e.name)){const t=this._nameIndex.get(e.name);t&&(t.delete(e),0===t.size&&this._nameIndex.delete(e.name))}}findByName(e){const t=this._nameIndex.get(e);if(!t)return null;for(const e of t)if(!e.destroyed)return e;return null}findAllByName(e){const t=this._nameIndex.get(e);if(!t)return[];const r=[];for(const e of t)e.destroyed||r.push(e);return r}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null,this._nameIndex=null}};e.LOAD_SCENE_MODE=void 0,(Pt=e.LOAD_SCENE_MODE||(e.LOAD_SCENE_MODE={})).SINGLE="SINGLE",Pt.MULTI_CANVAS="MULTI_CANVAS";const It=e=>{if((e instanceof jt||e instanceof o)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof o?console.error(`${e.constructor.componentName} start error`,t):console.error(`${e.constructor.systemName} start error`,t)}}};var Nt,Ct,Dt=class extends n{constructor(){super(...arguments),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[]}init({systems:e,frameRate:t=60,autoStart:r=!0,needScene:n=!0}={}){return ft(this,void 0,void 0,function*(){if("undefined"!=typeof window&&window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new St({autoStart:!1,frameRate:t}),this.initTicker(),e&&e.length)for(const t of e)yield this.addSystem(t);n&&this.loadScene(new Mt("scene")),r&&this.start()})}get scene(){return this._scene}set scene(e){this._scene=e}get gameObjects(){return(e=>{var t;const r=(null===(t=null==e?void 0:e.scene)||void 0===t?void 0:t.gameObjects)||[],n=null==e?void 0:e.multiScenes.map(({gameObjects:e})=>e);let s=[];for(const e of n)s=[...s,...e];return[...r,...s]})(this)}findByName(e){var t;const r=null===(t=this._scene)||void 0===t?void 0:t.findByName(e);if(r)return r;for(const t of this.multiScenes){const r=t.findByName(e);if(r)return r}return null}findAllByName(e){var t;const r=(null===(t=this._scene)||void 0===t?void 0:t.findAllByName(e))||[];for(const t of this.multiScenes){const n=t.findAllByName(e);for(const e of n)r.push(e)}return r}addSystem(e,t){return ft(this,void 0,void 0,function*(){let r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof jt))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){it[t.systemName]=t.observerInfo,ot[t.systemName]=e}(r,r.constructor),function(e){const t=[];e instanceof Array?t.push(...e):t.push(e);for(const e of t)for(const t in e.observerInfo){at[t]=at[t]||[];const r=at[t];for(const n of e.observerInfo[t])-1===r.findIndex(e=>nt(e,n))&&at[t].push(n)}}(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 jt&&(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 r of t)for(const t of r.components)try{It(t),t.update&&t.update(e)}catch(e){console.error(`gameObject: ${r.name} ${t.name} update error`,e)}for(const r of t)for(const t of r.components)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`gameObject: ${r.name} ${t.name} lateUpdate error`,e)}})(e,this.gameObjects);for(const t of this.systems)try{It(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(r){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,r)}})(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(r){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,r)}})(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.scene.destroy(),requestAnimationFrame(()=>{this.pause(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null})}loadScene({scene:t,mode:r=e.LOAD_SCENE_MODE.SINGLE,params:n={}}){if(t){switch(r){case e.LOAD_SCENE_MODE.SINGLE:this.scene=t;break;case e.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:r,params:n})}}pauseScene({scene:e}){this.emit("pauseScene",{scene:e})}startScene({scene:e}){this.emit("startScene",{scene:e})}destroyScene({scene:e}){const t=this.multiScenes.findIndex(t=>t===e);if(t>-1){const e=this.multiScenes.splice(t,1)[0];this.emit("sceneDestroyed",{scene:e})}}};function xt(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function Lt(e={}){return function(t){if(!t.observerInfo){for(const t in e)for(const r in e[t]){let n;"string"==typeof e[t][r]&&(e[t][r]=[e[t][r]]),Array.isArray(e[t][r])&&(n={prop:e[t][r],deep:!1},e[t][r]=n),n=e[t][r],"string"==typeof n.prop&&(n.prop=[n.prop])}t.observerInfo=e}}}class Vt extends n{constructor({resource:t,resourceTotal:r}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=t,this.resourceTotal=r,0===r&&this.resource.emit(e.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(e.LOAD_EVENT.START,this)}onProgress(t){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,t.success?this.resource.emit(e.LOAD_EVENT.LOADED,this,t):this.resource.emit(e.LOAD_EVENT.ERROR,this,t),this.resource.emit(e.LOAD_EVENT.PROGRESS,this,t),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(e.LOAD_EVENT.COMPLETE,this)}}e.LOAD_EVENT=void 0,(Nt=e.LOAD_EVENT||(e.LOAD_EVENT={})).START="start",Nt.PROGRESS="progress",Nt.LOADED="loaded",Nt.COMPLETE="complete",Nt.ERROR="error",e.RESOURCE_TYPE=void 0,(Ct=e.RESOURCE_TYPE||(e.RESOURCE_TYPE={})).IMAGE="IMAGE",Ct.SPRITE="SPRITE",Ct.SPRITE_ANIMATION="SPRITE_ANIMATION",Ct.AUDIO="AUDIO",Ct.VIDEO="VIDEO",Ct.FONT="FONT";const $t=new class extends n{constructor(e){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},this.resourceUrlsMap={},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"):t&&(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 r=this.resourcesMap[t];!r.preload||r.complete||this.promiseMap[t]||e.push(r.name)}this.progress=new Vt({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})}getResource(e){return ft(this,void 0,void 0,function*(){return this.loadResource({names:[e]}),this.promiseMap[e]||Promise.resolve({})})}instance(e){return ft(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 ft(this,void 0,void 0,function*(){yield this._destroy(e)})}_destroy(e,r=!1){var n;return ft(this,void 0,void 0,function*(){const s=this.resourcesMap[e];if(!s)return;if(!r)try{this.destroyInstanceFunctions[s.type]&&(yield this.destroyInstanceFunctions[s.type](s))}catch(e){console.warn(`destroy resource ${s.name} error with '${e.message}'`)}const o=this.resourceUrlsMap[e]||[];if(0===o.length&&s.src)for(const e in s.src){let t=null===(n=s.src[e])||void 0===n?void 0:n.url;t&&("string"==typeof t&&t.startsWith("//")&&(t=`https:${t}`),o.push(t))}if(o.length>0)try{yield t.Assets.unload(o);for(const e of o)try{const r=t.Assets.resolver||t.Assets._resolver;r&&r._assetMap&&(delete r._assetMap[e],delete r._resolverHash[e])}catch(e){}}catch(t){console.warn(`Failed to unload assets for ${e}: ${t.message}`)}delete this.promiseMap[e],delete this.resourceUrlsMap[e],s.data={},s.complete=!1,s.instance=void 0,delete this.resourcesMap[e]})}registerResourceType(t,r=t){if(e.RESOURCE_TYPE[t])throw new Error(`The type ${t} already exists in RESOURCE_TYPE`);e.RESOURCE_TYPE[t]=r}registerInstance(e,t){this.makeInstanceFunctions[e]=t}registerDestroy(e,t){this.destroyInstanceFunctions[e]=t}loadResource({names:r=[],preload:n=!1}){const s=r.filter(e=>!this.promiseMap[e]&&this.resourcesMap[e]);if(!s.length)return;const o={};s.forEach(r=>ft(this,void 0,void 0,function*(){var s;this.promiseMap[r]=new Promise(e=>o[r]=e);const i=this.resourcesMap[r];this.resourceUrlsMap[r]||(this.resourceUrlsMap[r]=[]);for(const e of this.preProcessResourceHandlers)e(i);for(const a in i.src){if("data"===i.src[a].type)i.data[a]=i.src[a].data,this.doComplete(r,o[r],n);else{let c=null===(s=i.src[a])||void 0===s?void 0:s.url;if("string"==typeof c&&c.startsWith("//")&&(c=`https:${i.src[a].url}`),c&&this.resourceUrlsMap[r]&&!this.resourceUrlsMap[r].includes(c)&&this.resourceUrlsMap[r].push(c),"atlas"===a){const e=t.Assets.load(i.src.image.url).catch(e=>{this.onError({preload:n,errMsg:e.message,resource:{metadata:{key:a,name:r,resolves:o}}})});t.Assets.add({alias:c,src:c,loadParser:i.src[a].loadParser,data:{resolve:()=>e,imageTexture:yield e}})}else{const s={alias:c,src:c};if(i.src[a].loadParser&&(s.loadParser=i.src[a].loadParser),i.type===e.RESOURCE_TYPE.SPRITE||i.type===e.RESOURCE_TYPE.SPRITE_ANIMATION){if("json"===i.src[a].type)try{const e=yield t.Assets.load(i.src.image.url);s.data={texture:e}}catch(e){console.log(">>>E",e),this.onError({preload:n,errMsg:e.message,resource:{metadata:{key:a,name:r,resolves:o}}})}}else i.type===e.RESOURCE_TYPE.FONT&&(s.data={family:r});t.Assets.add(s)}t.Assets.load(c).then(e=>{this.onLoad({preload:n,resource:{metadata:{key:a,name:r,resolves:o},data:e}})}).catch(e=>{console.log(">>>E",e),this.onError({preload:n,errMsg:e.message,resource:{metadata:{key:a,name:r,resolves:o}}})})}}}))}doComplete(e,t,r=!1){return ft(this,void 0,void 0,function*(){const n=this.resourcesMap[e],s={name:e,resource:this.resourcesMap[e],success:!0};if(this.checkAllLoaded(e))try{n.instance=yield this.instance(e),n.complete=!0,r&&this.progress.onProgress(s),t(n)}catch(e){console.error(e),n.complete=!1,r&&(s.errMsg=e.message,s.success=!1,this.progress.onProgress(s)),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 ft(this,void 0,void 0,function*(){const{metadata:{key:r,name:n,resolves:s},data:o}=t,i=this.resourcesMap[n];i?(i.data[r]=o,this.doComplete(n,s[n],e)):console.warn("no resource data found")})}onError({errMsg:e,preload:t=!1,resource:r}){return ft(this,void 0,void 0,function*(){const{metadata:{name:n,resolves:s}}=r;if(delete this.promiseMap[n],delete this.resourceUrlsMap[n],s[n]({}),t){const t={name:n,resource:this.resourcesMap[n],success:!1,errMsg:e};this.progress.onProgress(t)}})}},Ft={IDEProp:xt,componentObserver:Lt},Ut="2.0.2-beta.3";console.log(`Eva.js version: ${Ut}`);return e.Component=o,e.Game=Dt,e.GameObject=Et,e.IDEProp=xt,e.RESOURCE_TYPE_STRATEGY={},e.Scene=Mt,e.System=jt,e.Transform=vt,e.componentObserver=Lt,e.decorators=Ft,e.resource=$t,e.version=Ut,Object.defineProperty(e,"__esModule",{value:!0}),e}({},PIXI);globalThis.EVA=globalThis.EVA||_EVA_IIFE_EVA;
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},_extends.apply(null,arguments)}var _EVA_IIFE_EVA=function(e,t){"use strict";var r=function(e){var t={exports:{}};return e(t,t.exports),t.exports}(function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var i=new o(n,s||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function i(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),i.prototype.eventNames=function(){var e,n,o=[];if(0===this._eventsCount)return o;for(n in e=this._events)t.call(e,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},i.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,a=new Array(s);o<s;o++)a[o]=n[o].fn;return a},i.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},i.prototype.emit=function(e,t,n,o,s,a){var i=r?r+e:e;if(!this._events[i])return!1;var c,u,l=this._events[i],p=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),p){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,o),!0;case 5:return l.fn.call(l.context,t,n,o,s),!0;case 6:return l.fn.call(l.context,t,n,o,s,a),!0}for(u=1,c=new Array(p-1);u<p;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),p){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,o);break;default:if(!c)for(h=1,c=new Array(p-1);h<p;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},i.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},i.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},i.prototype.removeListener=function(e,t,n,o){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var i=this._events[s];if(i.fn)i.fn!==t||o&&!i.once||n&&i.context!==n||a(this,s);else{for(var c=0,u=[],l=i.length;c<l;c++)(i[c].fn!==t||o&&!i[c].once||n&&i[c].context!==n)&&u.push(i[c]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=r,i.EventEmitter=i,e.exports=i}),n=r;"function"==typeof SuppressedError&&SuppressedError;class o extends Error{constructor(){super("Symbol keys are not supported yet!"),Object.setPrototypeOf(this,new.target.prototype)}}const s="IDE_PROPERTY_METADATA",a="COMPONENT_EXECUTE_MODE_METADATA";function i(e){return e===String?"string":e===Number?"number":e===Boolean?"boolean":"unknown"}function c(e,t,r,n){let o=Reflect.getMetadata("design:type",e,t),a=o===Array;const c=i(o);if("unknown"!==c&&(o=c),n){const e=n();Array.isArray(e)?(a=!0,o=e[0]):o=e}const u=Reflect.getMetadata(s,e.constructor)||{},l=_extends(_extends(_extends({},u[t]||{}),{type:o,isArray:a}),r);u[t]=l,Reflect.defineMetadata(s,u,e.constructor);!function(e,t,r){const n=e.constructor,o=n.IDEProps||{};o[t]=_extends(_extends({key:t},o[t]),r),n.IDEProps=o}(e,t,function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(l,["isArray"]))}function u(e){return p({type:e})}function l(e){return p({step:e})}function p(e,t){return(r,n)=>{if("symbol"==typeof n)throw new o;const{options:s,returnTypeFunc:a}=function(e,t){return"function"==typeof e?{returnTypeFunc:e,options:t||{}}:{options:e||{}}}(e,t);c(r,n,s,a)}}function h(e,t=!0){const r=Reflect.getMetadata(s,e)||{},n=e.componentName,o={name:n,type:n,isArray:!1};return t&&(o.isFolder=!0),!Object.keys(r).length&&e.componentName||(o.type="object",o.children=[],Object.keys(r).forEach(e=>{if("function"==typeof r[e].type){const t=i(r[e].type);if("unknown"!==t)r[e].type=t;else{const t=h(r[e].type,!1);r[e].type="object",r[e].children||(r[e].children=[]),r[e].children.push(...t.children)}}r[e].name||(r[e].name=e),r[e].isArray&&(r[e].addable=!0),o.children.push(r[e])})),o}var f;!function(e){e[e.Edit=2]="Edit",e[e.Game=4]="Game",e[e.All=6]="All"}(f||(f={}));const d=e=>{Reflect.defineMetadata(a,f.Edit,e)},m=e=>!!(Reflect.getMetadata(a,e)&f.Edit);function y(e={}){return p(e)}class v extends n{static getInspectorMetadata(){return h(this)}constructor(e){super(),this.started=!1,this.name=this.constructor.componentName,this.__componentDefaultParams=e}getInspectorMetadata(){return this.constructor.getInspectorMetadata()}}var _=v,b="object"==typeof global&&global&&global.Object===Object&&global,g="object"==typeof self&&self&&self.Object===Object&&self,O=b||g||Function("return this")(),E=O.Symbol,j=Object.prototype,M=j.hasOwnProperty,w=j.toString,T=E?E.toStringTag:void 0;var R=Object.prototype.toString;var A=E?E.toStringTag:void 0;function k(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":A&&A in Object(e)?function(e){var t=M.call(e,T),r=e[T];try{e[T]=void 0;var n=!0}catch(e){}var o=w.call(e);return n&&(t?e[T]=r:delete e[T]),o}(e):function(e){return R.call(e)}(e)}function S(e){return null!=e&&"object"==typeof e}var P=Array.isArray;function x(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function C(e){if(!x(e))return!1;var t=k(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var I,N=O["__core-js_shared__"],D=(I=/[^.]+$/.exec(N&&N.keys&&N.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"";var U=Function.prototype.toString;function F(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var L=/^\[object .+?Constructor\]$/,$=Function.prototype,V=Object.prototype,z=$.toString,G=V.hasOwnProperty,B=RegExp("^"+z.call(G).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Y(e){return!(!x(e)||(t=e,D&&D in t))&&(C(e)?B:L).test(F(e));var t}function H(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Y(r)?r:void 0}var q=H(O,"WeakMap"),W=/^(?:0|[1-9]\d*)$/;function X(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&W.test(e))&&e>-1&&e%1==0&&e<t}function J(e,t){return e===t||e!=e&&t!=t}function K(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var Q=Object.prototype;function Z(e){return S(e)&&"[object Arguments]"==k(e)}var ee=Object.prototype,te=ee.hasOwnProperty,re=ee.propertyIsEnumerable,ne=Z(function(){return arguments}())?Z:function(e){return S(e)&&te.call(e,"callee")&&!re.call(e,"callee")},oe=ne;var se="object"==typeof e&&e&&!e.nodeType&&e,ae=se&&"object"==typeof module&&module&&!module.nodeType&&module,ie=ae&&ae.exports===se?O.Buffer:void 0,ce=(ie?ie.isBuffer:void 0)||function(){return!1},ue={};ue["[object Float32Array]"]=ue["[object Float64Array]"]=ue["[object Int8Array]"]=ue["[object Int16Array]"]=ue["[object Int32Array]"]=ue["[object Uint8Array]"]=ue["[object Uint8ClampedArray]"]=ue["[object Uint16Array]"]=ue["[object Uint32Array]"]=!0,ue["[object Arguments]"]=ue["[object Array]"]=ue["[object ArrayBuffer]"]=ue["[object Boolean]"]=ue["[object DataView]"]=ue["[object Date]"]=ue["[object Error]"]=ue["[object Function]"]=ue["[object Map]"]=ue["[object Number]"]=ue["[object Object]"]=ue["[object RegExp]"]=ue["[object Set]"]=ue["[object String]"]=ue["[object WeakMap]"]=!1;var le,pe="object"==typeof e&&e&&!e.nodeType&&e,he=pe&&"object"==typeof module&&module&&!module.nodeType&&module,fe=he&&he.exports===pe&&b.process,de=function(){try{var e=he&&he.require&&he.require("util").types;return e||fe&&fe.binding&&fe.binding("util")}catch(e){}}(),me=de&&de.isTypedArray,ye=me?(le=me,function(e){return le(e)}):function(e){return S(e)&&K(e.length)&&!!ue[k(e)]},ve=Object.prototype.hasOwnProperty;function _e(e,t){var r=P(e),n=!r&&oe(e),o=!r&&!n&&ce(e),s=!r&&!n&&!o&&ye(e),a=r||n||o||s,i=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=i.length;for(var u in e)!t&&!ve.call(e,u)||a&&("length"==u||o&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||X(u,c))||i.push(u);return i}var be=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),ge=be,Oe=Object.prototype.hasOwnProperty;function Ee(e){if(r=(t=e)&&t.constructor,t!==("function"==typeof r&&r.prototype||Q))return ge(e);var t,r,n=[];for(var o in Object(e))Oe.call(e,o)&&"constructor"!=o&&n.push(o);return n}function je(e){return null!=(t=e)&&K(t.length)&&!C(t)?_e(e):Ee(e);var t}var Me=H(Object,"create");var we=Object.prototype.hasOwnProperty;var Te=Object.prototype.hasOwnProperty;function Re(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ae(e,t){for(var r=e.length;r--;)if(J(e[r][0],t))return r;return-1}Re.prototype.clear=function(){this.__data__=Me?Me(null):{},this.size=0},Re.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Re.prototype.get=function(e){var t=this.__data__;if(Me){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return we.call(t,e)?t[e]:void 0},Re.prototype.has=function(e){var t=this.__data__;return Me?void 0!==t[e]:Te.call(t,e)},Re.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Me&&void 0===t?"__lodash_hash_undefined__":t,this};var ke=Array.prototype.splice;function Se(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Se.prototype.clear=function(){this.__data__=[],this.size=0},Se.prototype.delete=function(e){var t=this.__data__,r=Ae(t,e);return!(r<0)&&(r==t.length-1?t.pop():ke.call(t,r,1),--this.size,!0)},Se.prototype.get=function(e){var t=this.__data__,r=Ae(t,e);return r<0?void 0:t[r][1]},Se.prototype.has=function(e){return Ae(this.__data__,e)>-1},Se.prototype.set=function(e,t){var r=this.__data__,n=Ae(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var Pe=H(O,"Map");function xe(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function Ce(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ce.prototype.clear=function(){this.size=0,this.__data__={hash:new Re,map:new(Pe||Se),string:new Re}},Ce.prototype.delete=function(e){var t=xe(this,e).delete(e);return this.size-=t?1:0,t},Ce.prototype.get=function(e){return xe(this,e).get(e)},Ce.prototype.has=function(e){return xe(this,e).has(e)},Ce.prototype.set=function(e,t){var r=xe(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};function Ie(e){var t=this.__data__=new Se(e);this.size=t.size}Ie.prototype.clear=function(){this.__data__=new Se,this.size=0},Ie.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Ie.prototype.get=function(e){return this.__data__.get(e)},Ie.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Se){var n=r.__data__;if(!Pe||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Ce(n)}return r.set(e,t),this.size=r.size,this};var Ne=Object.prototype.propertyIsEnumerable,De=Object.getOwnPropertySymbols,Ue=De?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,o=0,s=[];++r<n;){var a=e[r];t(a,r,e)&&(s[o++]=a)}return s}(De(e),function(t){return Ne.call(e,t)}))}:function(){return[]};function Fe(e){return function(e,t,r){var n=t(e);return P(e)?n:function(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}(n,r(e))}(e,je,Ue)}var Le=H(O,"DataView"),$e=H(O,"Promise"),Ve=H(O,"Set"),ze="[object Map]",Ge="[object Promise]",Be="[object Set]",Ye="[object WeakMap]",He="[object DataView]",qe=F(Le),We=F(Pe),Xe=F($e),Je=F(Ve),Ke=F(q),Qe=k;(Le&&Qe(new Le(new ArrayBuffer(1)))!=He||Pe&&Qe(new Pe)!=ze||$e&&Qe($e.resolve())!=Ge||Ve&&Qe(new Ve)!=Be||q&&Qe(new q)!=Ye)&&(Qe=function(e){var t=k(e),r="[object Object]"==t?e.constructor:void 0,n=r?F(r):"";if(n)switch(n){case qe:return He;case We:return ze;case Xe:return Ge;case Je:return Be;case Ke:return Ye}return t});var Ze=Qe,et=O.Uint8Array;function tt(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Ce;++t<r;)this.add(e[t])}function rt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}tt.prototype.add=tt.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},tt.prototype.has=function(e){return this.__data__.has(e)};function nt(e,t,r,n,o,s){var a=1&r,i=e.length,c=t.length;if(i!=c&&!(a&&c>i))return!1;var u=s.get(e),l=s.get(t);if(u&&l)return u==t&&l==e;var p=-1,h=!0,f=2&r?new tt:void 0;for(s.set(e,t),s.set(t,e);++p<i;){var d=e[p],m=t[p];if(n)var y=a?n(m,d,p,t,e,s):n(d,m,p,e,t,s);if(void 0!==y){if(y)continue;h=!1;break}if(f){if(!rt(t,function(e,t){if(a=t,!f.has(a)&&(d===e||o(d,e,r,n,s)))return f.push(t);var a})){h=!1;break}}else if(d!==m&&!o(d,m,r,n,s)){h=!1;break}}return s.delete(e),s.delete(t),h}function ot(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function st(e){var t=-1,r=Array(e.size);return e.forEach(function(e){r[++t]=e}),r}var at=E?E.prototype:void 0,it=at?at.valueOf:void 0;var ct=Object.prototype.hasOwnProperty;var ut,lt="[object Arguments]",pt="[object Array]",ht="[object Object]",ft=Object.prototype.hasOwnProperty;function dt(e,t,r,n,o,s){var a=P(e),i=P(t),c=a?pt:Ze(e),u=i?pt:Ze(t),l=(c=c==lt?ht:c)==ht,p=(u=u==lt?ht:u)==ht,h=c==u;if(h&&ce(e)){if(!ce(t))return!1;a=!0,l=!1}if(h&&!l)return s||(s=new Ie),a||ye(e)?nt(e,t,r,n,o,s):function(e,t,r,n,o,s,a){switch(r){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!s(new et(e),new et(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return J(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var i=ot;case"[object Set]":var c=1&n;if(i||(i=st),e.size!=t.size&&!c)return!1;var u=a.get(e);if(u)return u==t;n|=2,a.set(e,t);var l=nt(i(e),i(t),n,o,s,a);return a.delete(e),l;case"[object Symbol]":if(it)return it.call(e)==it.call(t)}return!1}(e,t,c,r,n,o,s);if(!(1&r)){var f=l&&ft.call(e,"__wrapped__"),d=p&&ft.call(t,"__wrapped__");if(f||d){var m=f?e.value():e,y=d?t.value():t;return s||(s=new Ie),o(m,y,r,n,s)}}return!!h&&(s||(s=new Ie),function(e,t,r,n,o,s){var a=1&r,i=Fe(e),c=i.length;if(c!=Fe(t).length&&!a)return!1;for(var u=c;u--;){var l=i[u];if(!(a?l in t:ct.call(t,l)))return!1}var p=s.get(e),h=s.get(t);if(p&&h)return p==t&&h==e;var f=!0;s.set(e,t),s.set(t,e);for(var d=a;++u<c;){var m=e[l=i[u]],y=t[l];if(n)var v=a?n(y,m,l,t,e,s):n(m,y,l,e,t,s);if(!(void 0===v?m===y||o(m,y,r,n,s):v)){f=!1;break}d||(d="constructor"==l)}if(f&&!d){var _=e.constructor,b=t.constructor;_==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof _&&_ instanceof _&&"function"==typeof b&&b instanceof b||(f=!1)}return s.delete(e),s.delete(t),f}(e,t,r,n,o,s))}function mt(e,t,r,n,o){return e===t||(null==e||null==t||!S(e)&&!S(t)?e!=e&&t!=t:dt(e,t,r,n,mt,o))}function yt(e,t){return mt(e,t)}e.OBSERVER_TYPE=void 0,(ut=e.OBSERVER_TYPE||(e.OBSERVER_TYPE={})).ADD="ADD",ut.REMOVE="REMOVE",ut.CHANGE="CHANGE";const vt={},_t={},bt={},gt={};function Ot(e,t){vt[e.gameObject.id]||(vt[e.gameObject.id]={});const r=vt[e.gameObject.id],n=e.name+"_"+t.join(",");if(r[n])return r[n];const o=t.length-1;let s=e;for(let e=0;e<o;e++)s=s[t[e]];return r[n]={property:s,key:t[o]},r[n]}function Et({systemName:e,componentName:t,component:r,prop:n,type:o}){var s,a;null===(a=null===(s=_t[e])||void 0===s?void 0:s.componentObserver)||void 0===a||a.add({component:r,prop:n,type:o,componentName:t})}function jt({obj:t,key:r,prop:n,component:o,componentName:s}){if(void 0!==t)if(r in t){if(Object.defineProperty(t,`_${r}`,{enumerable:!1,writable:!0,value:t[r]}),n.deep&&x(t[r]))for(const e of Object.keys(t[r]))jt({obj:t[r],key:e,prop:n,component:o,componentName:s});Object.defineProperty(t,r,{enumerable:!0,set(a){t[`_${r}`]!==a&&(t[`_${r}`]=a,function({prop:t,component:r,componentName:n}){for(const o in bt){const s=(bt[o]||{})[n];s&&(s.findIndex(e=>yt(e,t))>-1&&Et({systemName:o,componentName:n,component:r,prop:t,type:e.OBSERVER_TYPE.CHANGE}))}}({prop:n,component:o,componentName:s}))},get:()=>t[`_${r}`]})}else console.error(`prop ${r} not in component: ${s}, Can not observer`)}function Mt(t,r=t.name){var n,o;for(const s in bt){(bt[s]||{})[r]&&(null===(o=null===(n=_t[s])||void 0===n?void 0:n.componentObserver)||void 0===o||o.add({component:t,type:e.OBSERVER_TYPE.REMOVE,componentName:r}))}!function(e){e.gameObject&&delete vt[e.gameObject.id]}(t)}function wt(e,t,r,n){var o,s=arguments.length,a=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(a=(s<3?o(a):s>3?o(t,r,a):o(t,r))||a);return s>3&&a&&Object.defineProperty(t,r,a),a}function Tt(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function Rt(e,t,r,n){return new(r||(r=Promise))(function(o,s){function a(e){try{c(n.next(e))}catch(e){s(e)}}function i(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,i)}c((n=n.apply(e,t||[])).next())})}class At extends _{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 r of t)_extends(this[r],e[r]);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}}At.componentName="Transform",wt([u("vector2"),l(1),Tt("design:type",Object)],At.prototype,"position",void 0),wt([u("size"),l(1),Tt("design:type",Object)],At.prototype,"size",void 0),wt([u("vector2"),l(.1),Tt("design:type",Object)],At.prototype,"origin",void 0),wt([u("vector2"),l(.1),Tt("design:type",Object)],At.prototype,"anchor",void 0),wt([u("vector2"),l(.1),Tt("design:type",Object)],At.prototype,"scale",void 0),wt([u("vector2"),l(.1),Tt("design:type",Object)],At.prototype,"skew",void 0),wt([u("number"),l(.1),Tt("design:type",Number)],At.prototype,"rotation",void 0);var kt=At;let St=0;class Pt{constructor(e,t){this._componentCache={},this.components=[],this.destroyed=!1,this._name=e,this.id=++St,this.addComponent(kt,t)}get transform(){return this.getComponent(kt)}get parent(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject}get children(){return this.transform.children.map(e=>e.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 Pt))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 Pt&&e.parent&&e.parent===this?(e.transform.parent=null,e.scene=null,e):e}addComponent(t,r){if(this.destroyed)return;const n=function(e){return e instanceof v?e.name:e instanceof Function?e.componentName:void 0}(t);if(this._componentCache[n])return;let o;if(t instanceof Function)o=new t(r);else{if(!(t instanceof _))throw new Error("addComponent recieve Component and Component Constructor");o=t}if(o.gameObject)throw new Error(`component has been added on gameObject ${o.gameObject.name}`);return o.gameObject=this,o.init&&o.init(o.__componentDefaultParams),function(t,r=t.name){var n,o;for(const s in bt)(bt[s]||{})[r]&&(null===(o=null===(n=_t[s])||void 0===n?void 0:n.componentObserver)||void 0===o||o.add({component:t,type:e.OBSERVER_TYPE.ADD,componentName:r}))}(o,o.name),function(e,t=e.name){if(t&&gt[t]){if(!(e&&(r=e,r&&r.constructor&&"componentName"in r.constructor)))throw new Error("component param must be an instance of Component");var r;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");for(const r of gt[t]){const{property:n,key:o}=Ot(e,r.prop);jt({obj:n,key:o,prop:r,component:e,componentName:t})}}}(o,o.name),this.components.push(o),this._componentCache[n]=o,o.awake&&o.awake(),o}removeComponent(e){let t;if("string"==typeof e?t=e:e instanceof _?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 r=this.components.splice(t,1)[0];return delete this._componentCache[e],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),Mt(r,e),r.gameObject=void 0,r}getComponent(e){let t;return"string"==typeof e?t=e:e instanceof _?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}}}var xt=Pt;var Ct=class{constructor(){this.events=[]}add({component:t,prop:r,type:n,componentName:o}){if(n===e.OBSERVER_TYPE.REMOVE){if(this.events.find(r=>r.component===t&&r.type===e.OBSERVER_TYPE.ADD))return void(this.events=this.events.filter(e=>e.component!==t));this.events=this.events.filter(e=>e.component!==t)}const s=this.events.findIndex(e=>e.component===t&&yt(e.prop,r)&&e.type===n);s>-1&&this.events.splice(s,1),this.events.push({gameObject:t.gameObject,component:t,prop:r,type:n,componentName:o})}getChanged(){return this.events}get changed(){return this.events}clear(){const e=this.events;return this.events=[],e}};var It=class{constructor(e){this.started=!1,this.componentObserver=new Ct,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 Nt=function(){let e=null;return e=Date.now?Date.now:()=>(new Date).getTime(),e}(),Dt={originTime:0,playbackRate:1};class Ut{constructor(e,t){e instanceof Ut&&(t=e,e={}),e=_extends({},Dt,e),t&&(this._parent=t),this._createTime=Nt(),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:Nt()-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:r=this.playbackRate}={}){const n={globalTime:this.globalTime,localTime:e,entropy:t,playbackRate:r,globalEntropy:this.globalEntropy};this._timeMark.push(n)}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 Ut(e,this)}seekGlobalTime(e){const t=this.seekTimeMark(e),r=this._timeMark[t],{entropy:n,playbackRate:o,globalTime:s}=r;return s+(e-n)/Math.abs(o)}seekLocalTime(e){const t=this.seekTimeMark(e),r=this._timeMark[t],{localTime:n,entropy:o,playbackRate:s}=r;return s>0?n+(e-o):n-(e-o)}seekTimeMark(e){const t=this._timeMark;let r=0,n=t.length-1;if(e<=t[r].entropy)return r;if(e>=t[n].entropy)return n;let o=Math.floor((r+n)/2);for(;o>r&&o<n;){if(e===t[o].entropy)return o;e<t[o].entropy?n=o:e>t[o].entropy&&(r=o),o=Math.floor((r+n)/2)}return r}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 Ft=Ut;const Lt={autoStart:!0,frameRate:60};var $t=class{constructor(e){e=_extends({},Lt,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new Ft({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;let t=0;for(;e-this._lastFrameTime>=this._frameDuration&&t<5;){this._lastFrameTime+=this._frameDuration,t++;const e={deltaTime:this._frameDuration,time:this._lastFrameTime,currentTime:this._lastFrameTime,frameCount:++this._frameCount,fps:this.frameRate};for(const t of this._tickers)"function"==typeof t&&t(e)}e-this._lastFrameTime>=this._frameDuration&&(this._lastFrameTime=e)}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,null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null),this.timeline.playbackRate=0}setPlaybackRate(e){this.timeline.playbackRate=e}};var Vt,zt=class extends xt{constructor(e,t){super(e,t),this.gameObjects=[],this._nameIndex=new Map,this.scene=this}addGameObject(e){if(this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0),e.name){let t=this._nameIndex.get(e.name);t||(t=new Set,this._nameIndex.set(e.name,t)),t.add(e)}}removeGameObject(e){const t=this.gameObjects.indexOf(e);if(-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1),e.name)){const t=this._nameIndex.get(e.name);t&&(t.delete(e),0===t.size&&this._nameIndex.delete(e.name))}}findByName(e){const t=this._nameIndex.get(e);if(!t)return null;for(const e of t)if(!e.destroyed)return e;return null}findAllByName(e){const t=this._nameIndex.get(e);if(!t)return[];const r=[];for(const e of t)e.destroyed||r.push(e);return r}destroy(){this.scene=null,super.destroy(),this.gameObjects=null,this.canvas=null,this._nameIndex=null}};e.LOAD_SCENE_MODE=void 0,(Vt=e.LOAD_SCENE_MODE||(e.LOAD_SCENE_MODE={})).SINGLE="SINGLE",Vt.MULTI_CANVAS="MULTI_CANVAS";const Gt=e=>{if((e instanceof It||e instanceof _)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof _?console.error(`${e.constructor.componentName} start error`,t):console.error(`${e.constructor.systemName} start error`,t)}}};var Bt,Yt,Ht=class extends n{constructor(){super(...arguments),this.playing=!1,this.started=!1,this.multiScenes=[],this.systems=[]}init({systems:e,frameRate:t=60,autoStart:r=!0,needScene:n=!0}={}){return Rt(this,void 0,void 0,function*(){if("undefined"!=typeof window&&window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new $t({autoStart:!1,frameRate:t}),this.initTicker(),e&&e.length)for(const t of e)yield this.addSystem(t);n&&this.loadScene(new zt("scene")),r&&this.start()})}get scene(){return this._scene}set scene(e){this._scene=e}get gameObjects(){return(e=>{var t;const r=(null===(t=null==e?void 0:e.scene)||void 0===t?void 0:t.gameObjects)||[],n=null==e?void 0:e.multiScenes.map(({gameObjects:e})=>e);let o=[];for(const e of n)o=[...o,...e];return[...r,...o]})(this)}findByName(e){var t;const r=null===(t=this._scene)||void 0===t?void 0:t.findByName(e);if(r)return r;for(const t of this.multiScenes){const r=t.findByName(e);if(r)return r}return null}findAllByName(e){var t;const r=(null===(t=this._scene)||void 0===t?void 0:t.findAllByName(e))||[];for(const t of this.multiScenes){const n=t.findAllByName(e);for(const e of n)r.push(e)}return r}addSystem(e,t){return Rt(this,void 0,void 0,function*(){let r;if(e instanceof Function)r=new e(t);else{if(!(e instanceof It))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){bt[t.systemName]=t.observerInfo,_t[t.systemName]=e}(r,r.constructor),function(e){const t=[];e instanceof Array?t.push(...e):t.push(e);for(const e of t)for(const t in e.observerInfo){gt[t]=gt[t]||[];const r=gt[t];for(const n of e.observerInfo[t])-1===r.findIndex(e=>yt(e,n))&&gt[t].push(n)}}(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 It&&(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 r of t)for(const t of r.components)try{Gt(t),t.update&&t.update(e)}catch(e){console.error(`gameObject: ${r.name} ${t.name} update error`,e)}for(const r of t)for(const t of r.components)try{t.lateUpdate&&t.lateUpdate(e)}catch(e){console.error(`gameObject: ${r.name} ${t.name} lateUpdate error`,e)}})(e,this.gameObjects);for(const t of this.systems)try{Gt(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(r){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,r)}})(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(r){console.error(`gameObject: ${t.name}, ${e.name}, onResume error`,r)}})(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(){var e,t;this.removeAllListeners(),this.playing?this.pause():null===(e=this.ticker)||void 0===e||e.pause(),null===(t=this.scene)||void 0===t||t.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null}loadScene({scene:t,mode:r=e.LOAD_SCENE_MODE.SINGLE,params:n={}}){if(t){switch(r){case e.LOAD_SCENE_MODE.SINGLE:this.scene=t;break;case e.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:r,params:n})}}pauseScene({scene:e}){this.emit("pauseScene",{scene:e})}startScene({scene:e}){this.emit("startScene",{scene:e})}destroyScene({scene:e}){const t=this.multiScenes.findIndex(t=>t===e);if(t>-1){const e=this.multiScenes.splice(t,1)[0];this.emit("sceneDestroyed",{scene:e})}}};function qt(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function Wt(e={}){return function(t){if(!t.observerInfo){for(const t in e)for(const r in e[t]){let n;"string"==typeof e[t][r]&&(e[t][r]=[e[t][r]]),Array.isArray(e[t][r])&&(n={prop:e[t][r],deep:!1},e[t][r]=n),n=e[t][r],"string"==typeof n.prop&&(n.prop=[n.prop])}t.observerInfo=e}}}class Xt extends n{constructor({resource:t,resourceTotal:r}){super(),this.progress=0,this.resourceTotal=0,this.resourceLoadedCount=0,this.resource=t,this.resourceTotal=r,0===r&&this.resource.emit(e.LOAD_EVENT.COMPLETE,this)}onStart(){this.resource.emit(e.LOAD_EVENT.START,this)}onProgress(t){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,t.success?this.resource.emit(e.LOAD_EVENT.LOADED,this,t):this.resource.emit(e.LOAD_EVENT.ERROR,this,t),this.resource.emit(e.LOAD_EVENT.PROGRESS,this,t),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(e.LOAD_EVENT.COMPLETE,this)}}e.LOAD_EVENT=void 0,(Bt=e.LOAD_EVENT||(e.LOAD_EVENT={})).START="start",Bt.PROGRESS="progress",Bt.LOADED="loaded",Bt.COMPLETE="complete",Bt.ERROR="error",e.RESOURCE_TYPE=void 0,(Yt=e.RESOURCE_TYPE||(e.RESOURCE_TYPE={})).IMAGE="IMAGE",Yt.SPRITE="SPRITE",Yt.SPRITE_ANIMATION="SPRITE_ANIMATION",Yt.AUDIO="AUDIO",Yt.VIDEO="VIDEO",Yt.FONT="FONT";const Jt=new class extends n{constructor(e){super(),this.timeout=6e3,this.preProcessResourceHandlers=[],this.resourcesMap={},this.makeInstanceFunctions={},this.destroyInstanceFunctions={},this.promiseMap={},this.resourceUrlsMap={},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"):t&&(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 r=this.resourcesMap[t];!r.preload||r.complete||this.promiseMap[t]||e.push(r.name)}this.progress=new Xt({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})}getResource(e){return Rt(this,void 0,void 0,function*(){return this.loadResource({names:[e]}),this.promiseMap[e]||Promise.resolve({})})}instance(e){return Rt(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 Rt(this,void 0,void 0,function*(){yield this._destroy(e)})}_destroy(e,r=!1){var n;return Rt(this,void 0,void 0,function*(){const o=this.resourcesMap[e];if(!o)return;if(!r)try{this.destroyInstanceFunctions[o.type]&&(yield this.destroyInstanceFunctions[o.type](o))}catch(e){console.warn(`destroy resource ${o.name} error with '${e.message}'`)}const s=this.resourceUrlsMap[e]||[];if(0===s.length&&o.src)for(const e in o.src){let t=null===(n=o.src[e])||void 0===n?void 0:n.url;t&&("string"==typeof t&&t.startsWith("//")&&(t=`https:${t}`),s.push(t))}if(s.length>0)try{yield t.Assets.unload(s);for(const e of s)try{const r=t.Assets.resolver||t.Assets._resolver;r&&r._assetMap&&(delete r._assetMap[e],delete r._resolverHash[e])}catch(e){}}catch(t){console.warn(`Failed to unload assets for ${e}: ${t.message}`)}delete this.promiseMap[e],delete this.resourceUrlsMap[e],o.data={},o.complete=!1,o.instance=void 0,delete this.resourcesMap[e]})}registerResourceType(t,r=t){if(e.RESOURCE_TYPE[t])throw new Error(`The type ${t} already exists in RESOURCE_TYPE`);e.RESOURCE_TYPE[t]=r}registerInstance(e,t){this.makeInstanceFunctions[e]=t}registerDestroy(e,t){this.destroyInstanceFunctions[e]=t}loadResource({names:r=[],preload:n=!1}){const o=r.filter(e=>!this.promiseMap[e]&&this.resourcesMap[e]);if(!o.length)return;const s={};o.forEach(r=>Rt(this,void 0,void 0,function*(){var o;this.promiseMap[r]=new Promise(e=>s[r]=e);const a=this.resourcesMap[r];this.resourceUrlsMap[r]||(this.resourceUrlsMap[r]=[]);for(const e of this.preProcessResourceHandlers)e(a);for(const i in a.src){if("data"===a.src[i].type)a.data[i]=a.src[i].data,this.doComplete(r,s[r],n);else{let c=null===(o=a.src[i])||void 0===o?void 0:o.url;if("string"==typeof c&&c.startsWith("//")&&(c=`https:${a.src[i].url}`),c&&this.resourceUrlsMap[r]&&!this.resourceUrlsMap[r].includes(c)&&this.resourceUrlsMap[r].push(c),"atlas"===i){const e=t.Assets.load(a.src.image.url).catch(e=>{this.onError({preload:n,errMsg:e.message,resource:{metadata:{key:i,name:r,resolves:s}}})});t.Assets.add({alias:c,src:c,loadParser:a.src[i].loadParser,data:{resolve:()=>e,imageTexture:yield e}})}else{const o={alias:c,src:c};if(a.src[i].loadParser&&(o.loadParser=a.src[i].loadParser),a.type===e.RESOURCE_TYPE.SPRITE||a.type===e.RESOURCE_TYPE.SPRITE_ANIMATION){if("json"===a.src[i].type)try{const e=yield t.Assets.load(a.src.image.url);o.data={texture:e}}catch(e){console.log(">>>E",e),this.onError({preload:n,errMsg:e.message,resource:{metadata:{key:i,name:r,resolves:s}}})}}else a.type===e.RESOURCE_TYPE.FONT&&(o.data={family:r});t.Assets.add(o)}t.Assets.load(c).then(e=>{this.onLoad({preload:n,resource:{metadata:{key:i,name:r,resolves:s},data:e}})}).catch(e=>{console.log(">>>E",e),this.onError({preload:n,errMsg:e.message,resource:{metadata:{key:i,name:r,resolves:s}}})})}}}))}doComplete(e,t,r=!1){return Rt(this,void 0,void 0,function*(){const n=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0};if(this.checkAllLoaded(e))try{n.instance=yield this.instance(e),n.complete=!0,r&&this.progress.onProgress(o),t(n)}catch(e){console.error(e),n.complete=!1,r&&(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 Rt(this,void 0,void 0,function*(){const{metadata:{key:r,name:n,resolves:o},data:s}=t,a=this.resourcesMap[n];a?(a.data[r]=s,this.doComplete(n,o[n],e)):console.warn("no resource data found")})}onError({errMsg:e,preload:t=!1,resource:r}){return Rt(this,void 0,void 0,function*(){const{metadata:{name:n,resolves:o}}=r;if(delete this.promiseMap[n],delete this.resourceUrlsMap[n],o[n]({}),t){const t={name:n,resource:this.resourcesMap[n],success:!1,errMsg:e};this.progress.onProgress(t)}})}},Kt=(()=>{const e=globalThis.performance;return e&&"function"==typeof e.now?e.now.bind(e):()=>Date.now()})();const Qt={IDEProp:qt,componentObserver:Wt,ExecuteInEditMode:d,Field:p,getPropertiesOf:h,inspectorField:y,shouldExecuteInEditMode:m,step:l,type:u},Zt="2.1.0-beta.0";console.log(`Eva.js version: ${Zt}`);return e.Component=_,e.ExecuteInEditMode=d,e.Field=p,e.Game=Ht,e.GameObject=xt,e.IDEProp=qt,e.RESOURCE_TYPE_STRATEGY={},e.Scene=zt,e.System=It,e.Transform=kt,e.componentObserver=Wt,e.decorators=Qt,e.getPropertiesOf=h,e.inspectorField=y,e.installPerfProbes=function(e,t={}){var r,n,o,s,a,i,c,u,l,p,h;const f=null!==(r=t.sampleSize)&&void 0!==r?r:60,d=null===(n=t.warnOnViolation)||void 0===n||n,m={maxFrameMs:null!==(s=null===(o=t.budget)||void 0===o?void 0:o.maxFrameMs)&&void 0!==s?s:16.67,minFps:null!==(i=null===(a=t.budget)||void 0===a?void 0:a.minFps)&&void 0!==i?i:30,sustainedFrames:null!==(u=null===(c=t.budget)||void 0===c?void 0:c.sustainedFrames)&&void 0!==u?u:60,maxSystemMs:null===(l=t.budget)||void 0===l?void 0:l.maxSystemMs,maxGameObjects:null===(p=t.budget)||void 0===p?void 0:p.maxGameObjects},y=new Map;let v=0;const _=[];let b=null;const g=new Map,O=new Set,E=new Set,j=new Map;let M=!1;function w(e){var t,r,n;if(g.has(e))return;const o=null!==(t=Object.getPrototypeOf(e))&&void 0!==t?t:{},s=Object.prototype.hasOwnProperty.call(e,"update"),a=Object.prototype.hasOwnProperty.call(e,"lateUpdate"),i=null!==(r=e.update)&&void 0!==r?r:o.update,c=null!==(n=e.lateUpdate)&&void 0!==n?n:o.lateUpdate;if("function"==typeof i){const t=i;e.update=function(r){var n;const o=Kt();try{return t.call(this,r)}finally{const t=Kt()-o,r=null!==(n=y.get(e))&&void 0!==n?n:{updateMs:0,lateUpdateMs:0};r.updateMs+=t,y.set(e,r)}}}if("function"==typeof c){const t=c;e.lateUpdate=function(r){var n;const o=Kt();try{return t.call(this,r)}finally{const t=Kt()-o,r=null!==(n=y.get(e))&&void 0!==n?n:{updateMs:0,lateUpdateMs:0};r.lateUpdateMs+=t,y.set(e,r)}}}g.set(e,{system:e,origUpdate:i,origLateUpdate:c,hadOwnUpdate:s,hadOwnLateUpdate:a})}function T(e){const{system:t,origUpdate:r,origLateUpdate:n,hadOwnUpdate:o,hadOwnLateUpdate:s}=e;"function"==typeof r&&(o?t.update=r:delete t.update),"function"==typeof n&&(s?t.lateUpdate=n:delete t.lateUpdate)}const R=t=>{var r;v=Kt(),y.clear();for(const t of null!==(r=e.systems)&&void 0!==r?r:[])g.has(t)||w(t)},A=t=>{var r,n;const o=Kt(),s=Math.max(0,o-v),a=(null!==(r=e.systems)&&void 0!==r?r:[]).map(e=>{var t,r,n;const o=null!==(t=y.get(e))&&void 0!==t?t:{updateMs:0,lateUpdateMs:0};return{name:e.name||(null===(r=e.constructor)||void 0===r?void 0:r.systemName)||(null===(n=e.constructor)||void 0===n?void 0:n.name)||"UnknownSystem",updateMs:o.updateMs,lateUpdateMs:o.lateUpdateMs}}),i=a.reduce((e,t)=>e+t.updateMs+t.lateUpdateMs,0),c=Math.max(0,s-i),u=(null!==(n=e.gameObjects)&&void 0!==n?n:[]).length,l=t&&"number"==typeof t.frameCount?t.frameCount:0;_.push({frameCount:l,fps:0,frameMs:s,systems:a,gameObjectsMs:c,gameObjectCount:u}),_.length>f&&_.shift();const p=_.reduce((e,t)=>e+t.frameMs,0),h=p>0?Math.min(1e3,1e3*_.length/p):1e3,g=_[_.length-1];if(g.fps=h,b=g,O.size)for(const e of Array.from(O))try{e(g)}catch(e){console.error("[perf-probes] onFrame callback error",e)}!function(e){var t;const r=[];"number"==typeof m.maxFrameMs&&r.push({name:"frameMs",actual:e.frameMs,threshold:m.maxFrameMs,over:e.frameMs>m.maxFrameMs});"number"==typeof m.minFps&&r.push({name:"fps",actual:e.fps,threshold:m.minFps,over:e.fps<m.minFps});"number"==typeof m.maxGameObjects&&r.push({name:"gameObjects",actual:e.gameObjectCount,threshold:m.maxGameObjects,over:e.gameObjectCount>m.maxGameObjects});if(m.maxSystemMs)for(const t of e.systems){const e=m.maxSystemMs[t.name];if("number"==typeof e){const n=t.updateMs+t.lateUpdateMs;r.push({name:`system:${t.name}`,actual:n,threshold:e,over:n>e})}}for(const n of r){let r=j.get(n.name);if(r||(r={consec:0,count:0,last:n.actual},j.set(n.name,r)),r.last=n.actual,n.over){if(r.consec+=1,r.consec>=(null!==(t=m.sustainedFrames)&&void 0!==t?t:60)){r.count+=1,r.consec=0;const t={name:n.name,actual:n.actual,threshold:n.threshold,frame:e};if(d&&console.warn(`[perf-probes] sustained violation ${n.name}: actual=${n.actual.toFixed(2)} threshold=${n.threshold}`),E.size)for(const e of Array.from(E))try{e(t)}catch(e){console.error("[perf-probes] onViolation callback error",e)}}}else r.consec=0}}(g)},k=(()=>{const t=e.ticker;return t?t._tickers:null})();let S=[];if(k){S=Array.from(k),k.clear(),k.add(R);for(const e of S)k.add(e);k.add(A)}for(const t of null!==(h=e.systems)&&void 0!==h?h:[])w(t);return{current:()=>b,average:function(){var e;if(0===_.length)return null;const t=_.length;let r=0,n=0,o=0,s=0,a=0;const i=_[t-1],c=new Map;for(const t of _){r+=t.frameMs,n+=t.fps,o+=t.gameObjectsMs,s+=t.gameObjectCount,a=t.frameCount;for(const r of t.systems){const t=null!==(e=c.get(r.name))&&void 0!==e?e:{updateMs:0,lateUpdateMs:0,n:0};t.updateMs+=r.updateMs,t.lateUpdateMs+=r.lateUpdateMs,t.n+=1,c.set(r.name,t)}}const u=i.systems.map(e=>{var t;const r=null!==(t=c.get(e.name))&&void 0!==t?t:{updateMs:0,lateUpdateMs:0,n:1};return{name:e.name,updateMs:r.updateMs/r.n,lateUpdateMs:r.lateUpdateMs/r.n}});return{frameCount:a,fps:n/t,frameMs:r/t,systems:u,gameObjectsMs:o/t,gameObjectCount:s/t}},violations(){const e=[];for(const[t,r]of j)0!==r.count&&e.push({name:t,count:r.count,last:r.last});return e},onFrame:e=>(O.add(e),()=>{O.delete(e)}),onViolation:e=>(E.add(e),()=>{E.delete(e)}),uninstall(){if(!M){if(M=!0,k){const e=Array.from(k).filter(e=>e!==R&&e!==A&&!S.includes(e));k.clear();for(const e of S)k.add(e);for(const t of e)k.add(t)}for(const e of g.values())T(e);g.clear(),_.length=0,b=null,O.clear(),E.clear(),j.clear(),y.clear()}}}},e.resource=Jt,e.shouldExecuteInEditMode=m,e.step=l,e.type=u,e.version=Zt,Object.defineProperty(e,"__esModule",{value:!0}),e}({},PIXI);globalThis.EVA=globalThis.EVA||_EVA_IIFE_EVA;
{
"name": "@eva/eva.js",
"version": "2.0.2",
"version": "2.1.0-beta.1",
"description": "@eva/eva.js",

@@ -21,3 +21,3 @@ "main": "index.js",

"dependencies": {
"@eva/inspector-decorator": "^0.0.5",
"@eva/inspector-decorator": "^2.0.0-beta.0",
"eventemitter3": "^5.0.4",

@@ -27,2 +27,3 @@ "lodash-es": "^4.17.21",

"parse-uri": "^1.0.3",
"reflect-metadata": "^0.1.13",
"resource-loader": "^4.0.0-rc4",

@@ -29,0 +30,0 @@ "sprite-timeline": "^1.10.2"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display