@eva/eva.js 1.3.0-alpha.1 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EVA.js +499 -1456
- package/dist/EVA.min.js +1 -1
- package/dist/eva.js.cjs.js +157 -134
- package/dist/eva.js.cjs.prod.js +2 -2
- package/dist/eva.js.esm.js +158 -135
- package/dist/packages/eva.js/lib/core/Component.d.ts +35 -0
- package/dist/packages/eva.js/lib/core/Component.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/core/ComponentObserver.d.ts +22 -0
- package/dist/packages/eva.js/lib/core/ComponentObserver.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/core/GameObject.d.ts +31 -0
- package/dist/packages/eva.js/lib/core/GameObject.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/core/System.d.ts +30 -0
- package/dist/packages/eva.js/lib/core/System.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/core/Transform.d.ts +51 -0
- package/dist/packages/eva.js/lib/core/Transform.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/core/observer.d.ts +23 -0
- package/dist/packages/eva.js/lib/core/observer.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/decorators/ide.d.ts +2 -0
- package/dist/packages/eva.js/lib/decorators/ide.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/decorators/system.d.ts +11 -0
- package/dist/packages/eva.js/lib/decorators/system.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/game/Game.d.ts +72 -0
- package/dist/packages/eva.js/lib/game/Game.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/game/Scene.d.ts +12 -0
- package/dist/packages/eva.js/lib/game/Scene.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/game/Ticker.d.ts +25 -0
- package/dist/packages/eva.js/lib/game/Ticker.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/index.d.ts +26 -0
- package/dist/packages/eva.js/lib/index.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/loader/Progress.d.ts +21 -0
- package/dist/packages/eva.js/lib/loader/Progress.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/loader/Resource.d.ts +99 -0
- package/dist/packages/eva.js/lib/loader/Resource.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/loader/resourceLoader.d.ts +14 -0
- package/dist/packages/eva.js/lib/loader/resourceLoader.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/timeline/index.d.ts +40 -0
- package/dist/packages/eva.js/lib/timeline/index.d.ts.map +1 -0
- package/dist/packages/eva.js/lib/timeline/utils.d.ts +2 -0
- package/dist/packages/eva.js/lib/timeline/utils.d.ts.map +1 -0
- package/dist/packages/plugin-a11y/lib/A11y.d.ts +26 -0
- package/dist/packages/plugin-a11y/lib/A11y.d.ts.map +1 -0
- package/dist/packages/plugin-a11y/lib/A11ySystem.d.ts +54 -0
- package/dist/packages/plugin-a11y/lib/A11ySystem.d.ts.map +1 -0
- package/dist/packages/plugin-a11y/lib/constant.d.ts +34 -0
- package/dist/packages/plugin-a11y/lib/constant.d.ts.map +1 -0
- package/dist/packages/plugin-a11y/lib/index.d.ts +4 -0
- package/dist/packages/plugin-a11y/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-a11y/lib/utils.d.ts +6 -0
- package/dist/packages/plugin-a11y/lib/utils.d.ts.map +1 -0
- package/dist/packages/plugin-evax/lib/EvaXComponent.d.ts +20 -0
- package/dist/packages/plugin-evax/lib/EvaXComponent.d.ts.map +1 -0
- package/dist/packages/plugin-evax/lib/EvaXSystem.d.ts +33 -0
- package/dist/packages/plugin-evax/lib/EvaXSystem.d.ts.map +1 -0
- package/dist/packages/plugin-evax/lib/index.d.ts +10 -0
- package/dist/packages/plugin-evax/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-evax/lib/utils.d.ts +3 -0
- package/dist/packages/plugin-evax/lib/utils.d.ts.map +1 -0
- package/dist/packages/plugin-matterjs/lib/BodiesFactory.d.ts +31 -0
- package/dist/packages/plugin-matterjs/lib/BodiesFactory.d.ts.map +1 -0
- package/dist/packages/plugin-matterjs/lib/Physics.d.ts +32 -0
- package/dist/packages/plugin-matterjs/lib/Physics.d.ts.map +1 -0
- package/dist/packages/plugin-matterjs/lib/PhysicsEngine.d.ts +35 -0
- package/dist/packages/plugin-matterjs/lib/PhysicsEngine.d.ts.map +1 -0
- package/dist/packages/plugin-matterjs/lib/PhysicsSystem.d.ts +32 -0
- package/dist/packages/plugin-matterjs/lib/PhysicsSystem.d.ts.map +1 -0
- package/dist/packages/plugin-matterjs/lib/index.d.ts +5 -0
- package/dist/packages/plugin-matterjs/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-matterjs/lib/matter.d.ts +3 -0
- package/dist/packages/plugin-matterjs/lib/matter.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/Renderer.d.ts +19 -0
- package/dist/packages/plugin-renderer/lib/Renderer.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/System.d.ts +40 -0
- package/dist/packages/plugin-renderer/lib/System.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/Transform.d.ts +28 -0
- package/dist/packages/plugin-renderer/lib/Transform.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/compressedTexture/ability.d.ts +20 -0
- package/dist/packages/plugin-renderer/lib/compressedTexture/ability.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/compressedTexture/fix/loader.d.ts +2 -0
- package/dist/packages/plugin-renderer/lib/compressedTexture/fix/loader.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/compressedTexture/index.d.ts +7 -0
- package/dist/packages/plugin-renderer/lib/compressedTexture/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/index.d.ts +8 -0
- package/dist/packages/plugin-renderer/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/manager/ContainerManager.d.ts +18 -0
- package/dist/packages/plugin-renderer/lib/manager/ContainerManager.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/manager/RendererManager.d.ts +17 -0
- package/dist/packages/plugin-renderer/lib/manager/RendererManager.d.ts.map +1 -0
- package/dist/packages/plugin-renderer/lib/mixin.d.ts +2 -0
- package/dist/packages/plugin-renderer/lib/mixin.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/component.d.ts +26 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/db.d.ts +3 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/db.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/engine.d.ts +10 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/engine.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/system.d.ts +24 -0
- package/dist/packages/plugin-renderer-dragonbone/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-event/lib/component.d.ts +52 -0
- package/dist/packages/plugin-renderer-event/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-event/lib/index.d.ts +5 -0
- package/dist/packages/plugin-renderer-event/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-event/lib/system.d.ts +19 -0
- package/dist/packages/plugin-renderer-event/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-graphics/lib/component.d.ts +8 -0
- package/dist/packages/plugin-renderer-graphics/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-graphics/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-graphics/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-graphics/lib/system.d.ts +12 -0
- package/dist/packages/plugin-renderer-graphics/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-img/lib/component.d.ts +10 -0
- package/dist/packages/plugin-renderer-img/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-img/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-img/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-img/lib/system.d.ts +18 -0
- package/dist/packages/plugin-renderer-img/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-lottie/lib/Lottie.d.ts +27 -0
- package/dist/packages/plugin-renderer-lottie/lib/Lottie.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-lottie/lib/LottieSystem.d.ts +18 -0
- package/dist/packages/plugin-renderer-lottie/lib/LottieSystem.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-lottie/lib/index.d.ts +3 -0
- package/dist/packages/plugin-renderer-lottie/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-lottie/lib/lottie-pixi.d.ts +180 -0
- package/dist/packages/plugin-renderer-lottie/lib/lottie-pixi.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-lottie/lib/types.d.ts +18 -0
- package/dist/packages/plugin-renderer-lottie/lib/types.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-lottie/lib/utils.d.ts +2 -0
- package/dist/packages/plugin-renderer-lottie/lib/utils.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-mask/lib/component.d.ts +33 -0
- package/dist/packages/plugin-renderer-mask/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-mask/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-mask/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-mask/lib/system.d.ts +31 -0
- package/dist/packages/plugin-renderer-mask/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-nine-patch/lib/component.d.ts +22 -0
- package/dist/packages/plugin-renderer-nine-patch/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-nine-patch/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-nine-patch/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-nine-patch/lib/system.d.ts +19 -0
- package/dist/packages/plugin-renderer-nine-patch/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-render/lib/component.d.ts +17 -0
- package/dist/packages/plugin-renderer-render/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-render/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-render/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-render/lib/system.d.ts +17 -0
- package/dist/packages/plugin-renderer-render/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-spine/lib/Spine.d.ts +4 -0
- package/dist/packages/plugin-renderer-spine/lib/Spine.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-spine/lib/SpineSystem.d.ts +5 -0
- package/dist/packages/plugin-renderer-spine/lib/SpineSystem.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-spine/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-spine/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-sprite/lib/component.d.ts +12 -0
- package/dist/packages/plugin-renderer-sprite/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-sprite/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-sprite/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-sprite/lib/system.d.ts +17 -0
- package/dist/packages/plugin-renderer-sprite/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-sprite-animation/lib/component.d.ts +31 -0
- package/dist/packages/plugin-renderer-sprite-animation/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-sprite-animation/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-sprite-animation/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-sprite-animation/lib/system.d.ts +31 -0
- package/dist/packages/plugin-renderer-sprite-animation/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-test/lib/component.d.ts +20 -0
- package/dist/packages/plugin-renderer-test/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-test/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-test/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-test/lib/system.d.ts +21 -0
- package/dist/packages/plugin-renderer-test/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-test/lib/system2.d.ts +12 -0
- package/dist/packages/plugin-renderer-test/lib/system2.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-text/lib/component.d.ts +43 -0
- package/dist/packages/plugin-renderer-text/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-text/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-text/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-text/lib/system.d.ts +22 -0
- package/dist/packages/plugin-renderer-text/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-tiling-sprite/lib/component.d.ts +20 -0
- package/dist/packages/plugin-renderer-tiling-sprite/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-tiling-sprite/lib/index.d.ts +4 -0
- package/dist/packages/plugin-renderer-tiling-sprite/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-renderer-tiling-sprite/lib/system.d.ts +18 -0
- package/dist/packages/plugin-renderer-tiling-sprite/lib/system.d.ts.map +1 -0
- package/dist/packages/plugin-sound/lib/Sound.d.ts +44 -0
- package/dist/packages/plugin-sound/lib/Sound.d.ts.map +1 -0
- package/dist/packages/plugin-sound/lib/SoundSystem.d.ts +37 -0
- package/dist/packages/plugin-sound/lib/SoundSystem.d.ts.map +1 -0
- package/dist/packages/plugin-sound/lib/index.d.ts +3 -0
- package/dist/packages/plugin-sound/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-stats/lib/Stats.d.ts +19 -0
- package/dist/packages/plugin-stats/lib/Stats.d.ts.map +1 -0
- package/dist/packages/plugin-stats/lib/StatsComponent.d.ts +7 -0
- package/dist/packages/plugin-stats/lib/StatsComponent.d.ts.map +1 -0
- package/dist/packages/plugin-stats/lib/StatsSystem.d.ts +28 -0
- package/dist/packages/plugin-stats/lib/StatsSystem.d.ts.map +1 -0
- package/dist/packages/plugin-stats/lib/hooks/BaseHooks.d.ts +18 -0
- package/dist/packages/plugin-stats/lib/hooks/BaseHooks.d.ts.map +1 -0
- package/dist/packages/plugin-stats/lib/hooks/GLHook.d.ts +11 -0
- package/dist/packages/plugin-stats/lib/hooks/GLHook.d.ts.map +1 -0
- package/dist/packages/plugin-stats/lib/hooks/TextureHook.d.ts +16 -0
- package/dist/packages/plugin-stats/lib/hooks/TextureHook.d.ts.map +1 -0
- package/dist/packages/plugin-stats/lib/index.d.ts +9 -0
- package/dist/packages/plugin-stats/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-transition/lib/Animation.d.ts +38 -0
- package/dist/packages/plugin-transition/lib/Animation.d.ts.map +1 -0
- package/dist/packages/plugin-transition/lib/component.d.ts +35 -0
- package/dist/packages/plugin-transition/lib/component.d.ts.map +1 -0
- package/dist/packages/plugin-transition/lib/index.d.ts +3 -0
- package/dist/packages/plugin-transition/lib/index.d.ts.map +1 -0
- package/dist/packages/plugin-transition/lib/system.d.ts +6 -0
- package/dist/packages/plugin-transition/lib/system.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/Application.d.ts +3 -0
- package/dist/packages/renderer-adapter/lib/Application.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/Container.d.ts +5 -0
- package/dist/packages/renderer-adapter/lib/Container.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/Graphics.d.ts +5 -0
- package/dist/packages/renderer-adapter/lib/Graphics.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/NinePatch.d.ts +5 -0
- package/dist/packages/renderer-adapter/lib/NinePatch.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/Sprite.d.ts +9 -0
- package/dist/packages/renderer-adapter/lib/Sprite.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/SpriteAnimation.d.ts +14 -0
- package/dist/packages/renderer-adapter/lib/SpriteAnimation.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/Text.d.ts +6 -0
- package/dist/packages/renderer-adapter/lib/Text.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/TilingSprite.d.ts +9 -0
- package/dist/packages/renderer-adapter/lib/TilingSprite.d.ts.map +1 -0
- package/dist/packages/renderer-adapter/lib/index.d.ts +9 -0
- package/dist/packages/renderer-adapter/lib/index.d.ts.map +1 -0
- package/dist/packages/spine-base/lib/Spine.d.ts +32 -0
- package/dist/packages/spine-base/lib/Spine.d.ts.map +1 -0
- package/dist/packages/spine-base/lib/SpineData.d.ts +5 -0
- package/dist/packages/spine-base/lib/SpineData.d.ts.map +1 -0
- package/dist/packages/spine-base/lib/SpineSystem.d.ts +20 -0
- package/dist/packages/spine-base/lib/SpineSystem.d.ts.map +1 -0
- package/dist/packages/spine-base/lib/TexCache.d.ts +10 -0
- package/dist/packages/spine-base/lib/TexCache.d.ts.map +1 -0
- package/dist/packages/spine-base/lib/index.d.ts +4 -0
- package/dist/packages/spine-base/lib/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/eva.js.d.ts +0 -458
package/dist/eva.js.cjs.js
CHANGED
|
@@ -5,9 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var EventEmitter = require('eventemitter3');
|
|
6
6
|
var lodashEs = require('lodash-es');
|
|
7
7
|
var inspectorDecorator = require('@eva/inspector-decorator');
|
|
8
|
+
var pixi_js = require('pixi.js');
|
|
8
9
|
var resourceLoader$1 = require('resource-loader');
|
|
9
10
|
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e[
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
11
12
|
|
|
12
13
|
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
13
14
|
|
|
@@ -172,8 +173,9 @@ function removeObjectCache(component) {
|
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
function addObserver(_a) {
|
|
176
|
+
var _b, _c;
|
|
175
177
|
var systemName = _a.systemName, componentName = _a.componentName, component = _a.component, prop = _a.prop, type = _a.type;
|
|
176
|
-
systemInstance[systemName].componentObserver.add({
|
|
178
|
+
(_c = (_b = systemInstance[systemName]) === null || _b === void 0 ? void 0 : _b.componentObserver) === null || _c === void 0 ? void 0 : _c.add({
|
|
177
179
|
component: component,
|
|
178
180
|
prop: prop,
|
|
179
181
|
type: type,
|
|
@@ -334,12 +336,13 @@ function observer(component, componentName) {
|
|
|
334
336
|
}
|
|
335
337
|
}
|
|
336
338
|
function observerAdded(component, componentName) {
|
|
339
|
+
var _a, _b;
|
|
337
340
|
if (componentName === void 0) { componentName = component.name; }
|
|
338
341
|
for (var systemName in observerInfos) {
|
|
339
342
|
var observerInfo = observerInfos[systemName] || {};
|
|
340
343
|
var info = observerInfo[componentName];
|
|
341
344
|
if (info) {
|
|
342
|
-
systemInstance[systemName].componentObserver.add({
|
|
345
|
+
(_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
|
|
343
346
|
component: component,
|
|
344
347
|
type: exports.OBSERVER_TYPE.ADD,
|
|
345
348
|
componentName: componentName,
|
|
@@ -348,12 +351,13 @@ function observerAdded(component, componentName) {
|
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
353
|
function observerRemoved(component, componentName) {
|
|
354
|
+
var _a, _b;
|
|
351
355
|
if (componentName === void 0) { componentName = component.name; }
|
|
352
356
|
for (var systemName in observerInfos) {
|
|
353
357
|
var observerInfo = observerInfos[systemName] || {};
|
|
354
358
|
var info = observerInfo[componentName];
|
|
355
359
|
if (info) {
|
|
356
|
-
systemInstance[systemName].componentObserver.add({
|
|
360
|
+
(_b = (_a = systemInstance[systemName]) === null || _a === void 0 ? void 0 : _a.componentObserver) === null || _b === void 0 ? void 0 : _b.add({
|
|
357
361
|
component: component,
|
|
358
362
|
type: exports.OBSERVER_TYPE.REMOVE,
|
|
359
363
|
componentName: componentName,
|
|
@@ -480,6 +484,7 @@ var GameObject = (function () {
|
|
|
480
484
|
function GameObject(name, obj) {
|
|
481
485
|
this._componentCache = {};
|
|
482
486
|
this.components = [];
|
|
487
|
+
this.destroyed = false;
|
|
483
488
|
this._name = name;
|
|
484
489
|
this.id = getId();
|
|
485
490
|
this.addComponent(Transform$1, obj);
|
|
@@ -561,6 +566,8 @@ var GameObject = (function () {
|
|
|
561
566
|
return gameObject;
|
|
562
567
|
};
|
|
563
568
|
GameObject.prototype.addComponent = function (C, obj) {
|
|
569
|
+
if (this.destroyed)
|
|
570
|
+
return;
|
|
564
571
|
var componentName = getComponentName(C);
|
|
565
572
|
if (this._componentCache[componentName])
|
|
566
573
|
return;
|
|
@@ -640,6 +647,10 @@ var GameObject = (function () {
|
|
|
640
647
|
return this.parent.removeChild(this);
|
|
641
648
|
};
|
|
642
649
|
GameObject.prototype.destroy = function () {
|
|
650
|
+
if (!this.transform) {
|
|
651
|
+
console.error('Cannot destroy gameObject that have already been destroyed.');
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
643
654
|
Array.from(this.transform.children).forEach(function (_a) {
|
|
644
655
|
var gameObject = _a.gameObject;
|
|
645
656
|
gameObject.destroy();
|
|
@@ -650,6 +661,7 @@ var GameObject = (function () {
|
|
|
650
661
|
this._removeComponent(key);
|
|
651
662
|
}
|
|
652
663
|
this.components.length = 0;
|
|
664
|
+
this.destroyed = true;
|
|
653
665
|
};
|
|
654
666
|
return GameObject;
|
|
655
667
|
}());
|
|
@@ -663,6 +675,7 @@ var ComponentObserver = (function () {
|
|
|
663
675
|
var component = _a.component, prop = _a.prop, type = _a.type, componentName = _a.componentName;
|
|
664
676
|
if (type === exports.OBSERVER_TYPE.REMOVE) {
|
|
665
677
|
if (this.events.find(function (changed) { return changed.component === component && changed.type === exports.OBSERVER_TYPE.ADD; })) {
|
|
678
|
+
this.events = this.events.filter(function (changed) { return changed.component !== component; });
|
|
666
679
|
return;
|
|
667
680
|
}
|
|
668
681
|
this.events = this.events.filter(function (changed) { return changed.component !== component; });
|
|
@@ -1188,42 +1201,66 @@ var gameObjectPause = function (gameObjects) {
|
|
|
1188
1201
|
};
|
|
1189
1202
|
var Game = (function (_super) {
|
|
1190
1203
|
__extends(Game, _super);
|
|
1191
|
-
function Game(
|
|
1192
|
-
var
|
|
1193
|
-
var _c = _a === void 0 ? {} : _a, systems = _c.systems, _d = _c.frameRate, frameRate = _d === void 0 ? 60 : _d, _e = _c.autoStart, autoStart = _e === void 0 ? true : _e, _f = _c.needScene, needScene = _f === void 0 ? true : _f;
|
|
1194
|
-
var _this = _super.call(this) || this;
|
|
1204
|
+
function Game() {
|
|
1205
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
1195
1206
|
_this.playing = false;
|
|
1196
1207
|
_this.started = false;
|
|
1197
1208
|
_this.multiScenes = [];
|
|
1198
1209
|
_this.systems = [];
|
|
1199
|
-
if (window.__EVA_INSPECTOR_ENV__) {
|
|
1200
|
-
window.__EVA_GAME_INSTANCE__ = _this;
|
|
1201
|
-
}
|
|
1202
|
-
_this.ticker = new Ticker$1({ autoStart: false, frameRate: frameRate });
|
|
1203
|
-
_this.initTicker();
|
|
1204
|
-
if (systems && systems.length) {
|
|
1205
|
-
try {
|
|
1206
|
-
for (var systems_1 = __values(systems), systems_1_1 = systems_1.next(); !systems_1_1.done; systems_1_1 = systems_1.next()) {
|
|
1207
|
-
var system = systems_1_1.value;
|
|
1208
|
-
_this.addSystem(system);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1212
|
-
finally {
|
|
1213
|
-
try {
|
|
1214
|
-
if (systems_1_1 && !systems_1_1.done && (_b = systems_1.return)) _b.call(systems_1);
|
|
1215
|
-
}
|
|
1216
|
-
finally { if (e_10) throw e_10.error; }
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
if (needScene) {
|
|
1220
|
-
_this.loadScene(new Scene$1('scene'));
|
|
1221
|
-
}
|
|
1222
|
-
if (autoStart) {
|
|
1223
|
-
_this.start();
|
|
1224
|
-
}
|
|
1225
1210
|
return _this;
|
|
1226
1211
|
}
|
|
1212
|
+
Game.prototype.init = function (_a) {
|
|
1213
|
+
var _b = _a === void 0 ? {} : _a, systems = _b.systems, _c = _b.frameRate, frameRate = _c === void 0 ? 60 : _c, _d = _b.autoStart, autoStart = _d === void 0 ? true : _d, _e = _b.needScene, needScene = _e === void 0 ? true : _e;
|
|
1214
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1215
|
+
var systems_1, systems_1_1, system, e_10_1;
|
|
1216
|
+
var e_10, _f;
|
|
1217
|
+
return __generator(this, function (_g) {
|
|
1218
|
+
switch (_g.label) {
|
|
1219
|
+
case 0:
|
|
1220
|
+
if (window.__EVA_INSPECTOR_ENV__) {
|
|
1221
|
+
window.__EVA_GAME_INSTANCE__ = this;
|
|
1222
|
+
}
|
|
1223
|
+
this.ticker = new Ticker$1({ autoStart: false, frameRate: frameRate });
|
|
1224
|
+
this.initTicker();
|
|
1225
|
+
if (!(systems && systems.length)) return [3, 8];
|
|
1226
|
+
_g.label = 1;
|
|
1227
|
+
case 1:
|
|
1228
|
+
_g.trys.push([1, 6, 7, 8]);
|
|
1229
|
+
systems_1 = __values(systems), systems_1_1 = systems_1.next();
|
|
1230
|
+
_g.label = 2;
|
|
1231
|
+
case 2:
|
|
1232
|
+
if (!!systems_1_1.done) return [3, 5];
|
|
1233
|
+
system = systems_1_1.value;
|
|
1234
|
+
return [4, this.addSystem(system)];
|
|
1235
|
+
case 3:
|
|
1236
|
+
_g.sent();
|
|
1237
|
+
_g.label = 4;
|
|
1238
|
+
case 4:
|
|
1239
|
+
systems_1_1 = systems_1.next();
|
|
1240
|
+
return [3, 2];
|
|
1241
|
+
case 5: return [3, 8];
|
|
1242
|
+
case 6:
|
|
1243
|
+
e_10_1 = _g.sent();
|
|
1244
|
+
e_10 = { error: e_10_1 };
|
|
1245
|
+
return [3, 8];
|
|
1246
|
+
case 7:
|
|
1247
|
+
try {
|
|
1248
|
+
if (systems_1_1 && !systems_1_1.done && (_f = systems_1.return)) _f.call(systems_1);
|
|
1249
|
+
}
|
|
1250
|
+
finally { if (e_10) throw e_10.error; }
|
|
1251
|
+
return [7];
|
|
1252
|
+
case 8:
|
|
1253
|
+
if (needScene) {
|
|
1254
|
+
this.loadScene(new Scene$1('scene'));
|
|
1255
|
+
}
|
|
1256
|
+
if (autoStart) {
|
|
1257
|
+
this.start();
|
|
1258
|
+
}
|
|
1259
|
+
return [2];
|
|
1260
|
+
}
|
|
1261
|
+
});
|
|
1262
|
+
});
|
|
1263
|
+
};
|
|
1227
1264
|
Object.defineProperty(Game.prototype, "scene", {
|
|
1228
1265
|
get: function () {
|
|
1229
1266
|
return this._scene;
|
|
@@ -1242,36 +1279,49 @@ var Game = (function (_super) {
|
|
|
1242
1279
|
configurable: true
|
|
1243
1280
|
});
|
|
1244
1281
|
Game.prototype.addSystem = function (S, obj) {
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1282
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1283
|
+
var system, hasTheSystem, _a;
|
|
1284
|
+
return __generator(this, function (_b) {
|
|
1285
|
+
switch (_b.label) {
|
|
1286
|
+
case 0:
|
|
1287
|
+
if (S instanceof Function) {
|
|
1288
|
+
system = new S(obj);
|
|
1289
|
+
}
|
|
1290
|
+
else if (S instanceof System$1) {
|
|
1291
|
+
system = S;
|
|
1292
|
+
}
|
|
1293
|
+
else {
|
|
1294
|
+
console.warn('can only add System');
|
|
1295
|
+
return [2];
|
|
1296
|
+
}
|
|
1297
|
+
hasTheSystem = this.systems.find(function (item) {
|
|
1298
|
+
return item.constructor === system.constructor;
|
|
1299
|
+
});
|
|
1300
|
+
if (hasTheSystem) {
|
|
1301
|
+
console.warn(system.constructor.systemName + " System has been added");
|
|
1302
|
+
return [2];
|
|
1303
|
+
}
|
|
1304
|
+
system.game = this;
|
|
1305
|
+
_a = system.init;
|
|
1306
|
+
if (!_a) return [3, 2];
|
|
1307
|
+
return [4, system.init(system.__systemDefaultParams)];
|
|
1308
|
+
case 1:
|
|
1309
|
+
_a = (_b.sent());
|
|
1310
|
+
_b.label = 2;
|
|
1311
|
+
case 2:
|
|
1312
|
+
setSystemObserver(system, system.constructor);
|
|
1313
|
+
initObserver(system.constructor);
|
|
1314
|
+
try {
|
|
1315
|
+
system.awake && system.awake();
|
|
1316
|
+
}
|
|
1317
|
+
catch (e) {
|
|
1318
|
+
console.error(system.constructor.systemName + " awake error", e);
|
|
1319
|
+
}
|
|
1320
|
+
this.systems.push(system);
|
|
1321
|
+
return [2, system];
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1258
1324
|
});
|
|
1259
|
-
if (hasTheSystem) {
|
|
1260
|
-
console.warn(system.constructor.systemName + " System has been added");
|
|
1261
|
-
return;
|
|
1262
|
-
}
|
|
1263
|
-
system.game = this;
|
|
1264
|
-
system.init && system.init(system.__systemDefaultParams);
|
|
1265
|
-
setSystemObserver(system, system.constructor);
|
|
1266
|
-
initObserver(system.constructor);
|
|
1267
|
-
try {
|
|
1268
|
-
system.awake && system.awake();
|
|
1269
|
-
}
|
|
1270
|
-
catch (e) {
|
|
1271
|
-
console.error(system.constructor.systemName + " awake error", e);
|
|
1272
|
-
}
|
|
1273
|
-
this.systems.push(system);
|
|
1274
|
-
return system;
|
|
1275
1325
|
};
|
|
1276
1326
|
Game.prototype.removeSystem = function (system) {
|
|
1277
1327
|
if (!system)
|
|
@@ -1534,11 +1584,10 @@ var resourceLoader = {
|
|
|
1534
1584
|
XhrResponseType: resourceLoader$1.XhrResponseType,
|
|
1535
1585
|
MediaElementLoadStrategy: resourceLoader$1.MediaElementLoadStrategy,
|
|
1536
1586
|
VideoLoadStrategy: resourceLoader$1.VideoLoadStrategy,
|
|
1537
|
-
XhrLoadStrategy: resourceLoader$1.XhrLoadStrategy,
|
|
1538
1587
|
Loader: resourceLoader$1.Loader,
|
|
1539
1588
|
Resource: resourceLoader$1.Resource,
|
|
1540
1589
|
ResourceType: resourceLoader$1.ResourceType,
|
|
1541
|
-
ResourceState: resourceLoader$1.ResourceState
|
|
1590
|
+
ResourceState: resourceLoader$1.ResourceState,
|
|
1542
1591
|
};
|
|
1543
1592
|
|
|
1544
1593
|
exports.LOAD_EVENT = void 0;
|
|
@@ -1554,31 +1603,9 @@ exports.RESOURCE_TYPE = void 0;
|
|
|
1554
1603
|
RESOURCE_TYPE["IMAGE"] = "IMAGE";
|
|
1555
1604
|
RESOURCE_TYPE["SPRITE"] = "SPRITE";
|
|
1556
1605
|
RESOURCE_TYPE["SPRITE_ANIMATION"] = "SPRITE_ANIMATION";
|
|
1557
|
-
RESOURCE_TYPE["DRAGONBONE"] = "DRAGONBONE";
|
|
1558
|
-
RESOURCE_TYPE["PARTICLES"] = "PARTICLES";
|
|
1559
|
-
RESOURCE_TYPE["LOTTIE"] = "LOTTIE";
|
|
1560
|
-
RESOURCE_TYPE["SPINE"] = "SPINE";
|
|
1561
1606
|
RESOURCE_TYPE["AUDIO"] = "AUDIO";
|
|
1562
1607
|
RESOURCE_TYPE["VIDEO"] = "VIDEO";
|
|
1563
1608
|
})(exports.RESOURCE_TYPE || (exports.RESOURCE_TYPE = {}));
|
|
1564
|
-
resourceLoader$1.XhrLoadStrategy.setExtensionXhrType('json', resourceLoader$1.XhrResponseType.Json);
|
|
1565
|
-
resourceLoader$1.XhrLoadStrategy.setExtensionXhrType('tex', resourceLoader$1.XhrResponseType.Json);
|
|
1566
|
-
resourceLoader$1.XhrLoadStrategy.setExtensionXhrType('ske', resourceLoader$1.XhrResponseType.Json);
|
|
1567
|
-
resourceLoader$1.XhrLoadStrategy.setExtensionXhrType('mp3', resourceLoader$1.XhrResponseType.Buffer);
|
|
1568
|
-
resourceLoader$1.XhrLoadStrategy.setExtensionXhrType('wav', resourceLoader$1.XhrResponseType.Buffer);
|
|
1569
|
-
resourceLoader$1.XhrLoadStrategy.setExtensionXhrType('aac', resourceLoader$1.XhrResponseType.Buffer);
|
|
1570
|
-
resourceLoader$1.XhrLoadStrategy.setExtensionXhrType('ogg', resourceLoader$1.XhrResponseType.Buffer);
|
|
1571
|
-
var RESOURCE_TYPE_STRATEGY = {
|
|
1572
|
-
png: resourceLoader$1.ImageLoadStrategy,
|
|
1573
|
-
jpg: resourceLoader$1.ImageLoadStrategy,
|
|
1574
|
-
jpeg: resourceLoader$1.ImageLoadStrategy,
|
|
1575
|
-
webp: resourceLoader$1.ImageLoadStrategy,
|
|
1576
|
-
json: resourceLoader$1.XhrLoadStrategy,
|
|
1577
|
-
tex: resourceLoader$1.XhrLoadStrategy,
|
|
1578
|
-
ske: resourceLoader$1.XhrLoadStrategy,
|
|
1579
|
-
audio: resourceLoader$1.XhrLoadStrategy,
|
|
1580
|
-
video: resourceLoader$1.VideoLoadStrategy,
|
|
1581
|
-
};
|
|
1582
1609
|
var Resource = (function (_super) {
|
|
1583
1610
|
__extends(Resource, _super);
|
|
1584
1611
|
function Resource(options) {
|
|
@@ -1589,7 +1616,6 @@ var Resource = (function (_super) {
|
|
|
1589
1616
|
_this.makeInstanceFunctions = {};
|
|
1590
1617
|
_this.destroyInstanceFunctions = {};
|
|
1591
1618
|
_this.promiseMap = {};
|
|
1592
|
-
_this.loaders = [];
|
|
1593
1619
|
if (options && typeof options.timeout === 'number') {
|
|
1594
1620
|
_this.timeout = options.timeout;
|
|
1595
1621
|
}
|
|
@@ -1638,7 +1664,7 @@ var Resource = (function (_super) {
|
|
|
1638
1664
|
var names = [];
|
|
1639
1665
|
for (var key in this.resourcesMap) {
|
|
1640
1666
|
var resource_1 = this.resourcesMap[key];
|
|
1641
|
-
if (resource_1.preload && !resource_1.complete) {
|
|
1667
|
+
if (resource_1.preload && !resource_1.complete && !this.promiseMap[key]) {
|
|
1642
1668
|
names.push(resource_1.name);
|
|
1643
1669
|
}
|
|
1644
1670
|
}
|
|
@@ -1720,6 +1746,13 @@ var Resource = (function (_super) {
|
|
|
1720
1746
|
});
|
|
1721
1747
|
});
|
|
1722
1748
|
};
|
|
1749
|
+
Resource.prototype.registerResourceType = function (type, value) {
|
|
1750
|
+
if (value === void 0) { value = type; }
|
|
1751
|
+
if (exports.RESOURCE_TYPE[type]) {
|
|
1752
|
+
throw new Error("The type " + type + " already exists in RESOURCE_TYPE");
|
|
1753
|
+
}
|
|
1754
|
+
exports.RESOURCE_TYPE[type] = value;
|
|
1755
|
+
};
|
|
1723
1756
|
Resource.prototype.registerInstance = function (type, callback) {
|
|
1724
1757
|
this.makeInstanceFunctions[type] = callback;
|
|
1725
1758
|
};
|
|
@@ -1733,45 +1766,61 @@ var Resource = (function (_super) {
|
|
|
1733
1766
|
if (!unLoadNames.length)
|
|
1734
1767
|
return;
|
|
1735
1768
|
var resolves = {};
|
|
1736
|
-
var loader = this.getLoader(preload);
|
|
1737
1769
|
unLoadNames.forEach(function (name) {
|
|
1738
1770
|
var e_3, _a;
|
|
1771
|
+
var _b;
|
|
1739
1772
|
_this.promiseMap[name] = new Promise(function (r) { return (resolves[name] = r); });
|
|
1740
1773
|
var res = _this.resourcesMap[name];
|
|
1741
1774
|
try {
|
|
1742
|
-
for (var
|
|
1743
|
-
var handler =
|
|
1775
|
+
for (var _c = __values(_this.preProcessResourceHandlers), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1776
|
+
var handler = _d.value;
|
|
1744
1777
|
handler(res);
|
|
1745
1778
|
}
|
|
1746
1779
|
}
|
|
1747
1780
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1748
1781
|
finally {
|
|
1749
1782
|
try {
|
|
1750
|
-
if (
|
|
1783
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1751
1784
|
}
|
|
1752
1785
|
finally { if (e_3) throw e_3.error; }
|
|
1753
1786
|
}
|
|
1754
|
-
|
|
1787
|
+
var _loop_1 = function (key) {
|
|
1755
1788
|
var resourceType = res.src[key].type;
|
|
1756
1789
|
if (resourceType === 'data') {
|
|
1757
1790
|
res.data[key] = res.src[key].data;
|
|
1758
1791
|
_this.doComplete(name, resolves[name], preload);
|
|
1759
1792
|
}
|
|
1760
1793
|
else {
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1794
|
+
var url = (_b = res.src[key]) === null || _b === void 0 ? void 0 : _b.url;
|
|
1795
|
+
if (typeof url === 'string' && url.startsWith('//')) {
|
|
1796
|
+
url = "" + window.location.protocol + res.src[key].url;
|
|
1797
|
+
}
|
|
1798
|
+
pixi_js.Assets.load(url)
|
|
1799
|
+
.then(function (data) {
|
|
1800
|
+
_this.onLoad({
|
|
1801
|
+
preload: preload,
|
|
1802
|
+
resource: {
|
|
1803
|
+
metadata: { key: key, name: name, resolves: resolves },
|
|
1804
|
+
data: data,
|
|
1805
|
+
},
|
|
1806
|
+
});
|
|
1807
|
+
})
|
|
1808
|
+
.catch(function (e) {
|
|
1809
|
+
console.log('>>>E', e);
|
|
1810
|
+
_this.onError({
|
|
1811
|
+
preload: preload,
|
|
1812
|
+
errMsg: e.message,
|
|
1813
|
+
resource: {
|
|
1814
|
+
metadata: { key: key, name: name, resolves: resolves },
|
|
1815
|
+
},
|
|
1816
|
+
});
|
|
1770
1817
|
});
|
|
1771
1818
|
}
|
|
1819
|
+
};
|
|
1820
|
+
for (var key in res.src) {
|
|
1821
|
+
_loop_1(key);
|
|
1772
1822
|
}
|
|
1773
1823
|
});
|
|
1774
|
-
loader.load();
|
|
1775
1824
|
};
|
|
1776
1825
|
Resource.prototype.doComplete = function (name, resolve, preload) {
|
|
1777
1826
|
if (preload === void 0) { preload = false; }
|
|
@@ -1820,34 +1869,7 @@ var Resource = (function (_super) {
|
|
|
1820
1869
|
var res = this.resourcesMap[name];
|
|
1821
1870
|
return Array.from(Object.keys(res.src)).every(function (resourceKey) { return res.data[resourceKey]; });
|
|
1822
1871
|
};
|
|
1823
|
-
Resource.prototype.getLoader = function (
|
|
1824
|
-
var _this = this;
|
|
1825
|
-
if (preload === void 0) { preload = false; }
|
|
1826
|
-
var loader = this.loaders.find(function (_a) {
|
|
1827
|
-
var loading = _a.loading;
|
|
1828
|
-
return !loading;
|
|
1829
|
-
});
|
|
1830
|
-
if (!loader) {
|
|
1831
|
-
loader = new resourceLoader$1.Loader();
|
|
1832
|
-
this.loaders.push(loader);
|
|
1833
|
-
}
|
|
1834
|
-
if (preload) {
|
|
1835
|
-
loader.onStart.once(function () {
|
|
1836
|
-
_this.progress.onStart();
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
loader.onLoad.add(function (_, resource) {
|
|
1840
|
-
_this.onLoad({ preload: preload, resource: resource });
|
|
1841
|
-
});
|
|
1842
|
-
loader.onError.add(function (errMsg, _, resource) {
|
|
1843
|
-
_this.onError({ errMsg: errMsg, resource: resource, preload: preload });
|
|
1844
|
-
});
|
|
1845
|
-
loader.onComplete.once(function () {
|
|
1846
|
-
loader.onLoad.detachAll();
|
|
1847
|
-
loader.onError.detachAll();
|
|
1848
|
-
loader.reset();
|
|
1849
|
-
});
|
|
1850
|
-
return loader;
|
|
1872
|
+
Resource.prototype.getLoader = function (_preload) {
|
|
1851
1873
|
};
|
|
1852
1874
|
Resource.prototype.onLoad = function (_a) {
|
|
1853
1875
|
var _b = _a.preload, preload = _b === void 0 ? false : _b, resource = _a.resource;
|
|
@@ -1891,8 +1913,9 @@ var decorators = {
|
|
|
1891
1913
|
IDEProp: IDEProp,
|
|
1892
1914
|
componentObserver: componentObserver,
|
|
1893
1915
|
};
|
|
1894
|
-
var version = '
|
|
1895
|
-
console.log("Eva.js version: " + version);
|
|
1916
|
+
var version = '2.0.0-beta.0';
|
|
1917
|
+
console.log("Eva.js version: " + version);
|
|
1918
|
+
var RESOURCE_TYPE_STRATEGY = {};
|
|
1896
1919
|
|
|
1897
1920
|
exports.Component = Component$1;
|
|
1898
1921
|
exports.Game = Game$1;
|
package/dist/eva.js.cjs.prod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("lodash-es"),r=require("@eva/inspector-decorator"),o=require("resource-loader");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("lodash-es"),r=require("@eva/inspector-decorator"),n=require("pixi.js"),o=require("resource-loader");function a(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=a(e),s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},s(e,t)};
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
@@ -12,4 +12,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
12
12
|
|
|
13
13
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
14
|
and limitations under the License.
|
|
15
|
-
***************************************************************************** */function i(e,t){function r(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function c(e,t,r,o){var n,a=arguments.length,s=a<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(s=(a<3?n(s):a>3?n(t,r,s):n(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}function u(e,t,r,o){return new(r||(r=Promise))((function(n,a){function s(e){try{c(o.next(e))}catch(e){a(e)}}function i(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):new r((function(t){t(e.value)})).then(s,i)}c((o=o.apply(e,t||[])).next())}))}function p(e,t){var r,o,n,a,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function l(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function f(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,a=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=a.next()).done;)s.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return s}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}var y,m=function(e){function t(t){var r=e.call(this)||this;return r.started=!1,r.name=r.constructor.componentName,r.__componentDefaultParams=t,r}return i(t,e),t}(a),d=m;exports.OBSERVER_TYPE=void 0,(y=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",y.REMOVE="REMOVE",y.CHANGE="CHANGE";var v={},g={},b={},E={};function _(e,t){v[e.gameObject.id]||(v[e.gameObject.id]={});var r=v[e.gameObject.id],o=e.name+"_"+t.join(",");if(r[o])return r[o];for(var n=t.length-1,a=e,s=0;s<n;s++)a=a[t[s]];return r[o]={property:a,key:t[n]},r[o]}function O(e){var t=e.systemName,r=e.componentName,o=e.component,n=e.prop,a=e.type;g[t].componentObserver.add({component:o,prop:n,type:a,componentName:r})}function T(e){var r,o,n=e.obj,a=e.key,s=e.prop,i=e.component,c=e.componentName;if(void 0!==n)if(a in n){if(Object.defineProperty(n,"_"+a,{enumerable:!1,writable:!0,value:n[a]}),s.deep&&t.isObject(n[a]))try{for(var u=l(Object.keys(n[a])),p=u.next();!p.done;p=u.next()){var f=p.value;T({obj:n[a],key:f,prop:s,component:i,componentName:c})}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}Object.defineProperty(n,a,{enumerable:!0,set:function(e){n["_"+a]!==e&&(n["_"+a]=e,function(e){var r=e.prop,o=e.component,n=e.componentName;for(var a in b){var s=(b[a]||{})[n];s&&s.findIndex((function(e){return t.isEqual(e,r)}))>-1&&O({systemName:a,componentName:n,component:o,prop:r,type:exports.OBSERVER_TYPE.CHANGE})}}({prop:s,component:i,componentName:c}))},get:function(){return n["_"+a]}})}else console.error("prop "+a+" not in component: "+c+", Can not observer")}function R(e,t){for(var r in void 0===t&&(t=e.name),b){(b[r]||{})[t]&&g[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t})}!function(e){e.gameObject&&delete v[e.gameObject.id]}(e)}var x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Transform",t._parent=null,t.inScene=!1,t.children=[],t.position={x:0,y:0},t.size={width:0,height:0},t.origin={x:0,y:0},t.anchor={x:0,y:0},t.scale={x:1,y:1},t.skew={x:0,y:0},t.rotation=0,t}return i(t,e),t.prototype.init=function(e){var t,r;void 0===e&&(e={});try{for(var o=l(["position","size","origin","anchor","scale","skew"]),n=o.next();!n.done;n=o.next()){var a=n.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",c([r.type("vector2"),r.step(1)],t.prototype,"position",void 0),c([r.type("size"),r.step(1)],t.prototype,"size",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"origin",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"anchor",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"scale",void 0),c([r.type("vector2"),r.step(.1)],t.prototype,"skew",void 0),c([r.type("number"),r.step(.1)],t.prototype,"rotation",void 0),t}(d),S=0;var k=function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++S,this.addComponent(x,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(x)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t,r;if(this._scene!==e){var o=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var n=l(this.transform.children),a=n.next();!a.done;a=n.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e?e.addGameObject(this):o&&o.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error("gameObject '"+this.name+"' has been destroy");t.transform.parent=this.transform,t.scene=this.scene}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var r=function(e){return e instanceof m?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[r]){var o;if(e instanceof Function)o=new e(t);else{if(!(e instanceof d))throw new Error("addComponent recieve Component and Component Constructor");o=e}if(o.gameObject)throw new Error("component has been added on gameObject "+o.gameObject.name);return o.gameObject=this,o.init&&o.init(o.__componentDefaultParams),function(e,t){for(var r in void 0===t&&(t=e.name),b)(b[r]||{})[t]&&g[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t})}(o,o.name),function(e,t){var r,o;if(void 0===t&&(t=e.name),t&&E[t]){if(!(e&&(n=e,n&&n.constructor&&"componentName"in n.constructor)))throw new Error("component param must be an instance of Component");var n;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=l(E[t]),s=a.next();!s.done;s=a.next()){var i=s.value,c=_(e,i.prop);T({obj:c.property,key:c.key,prop:i,component:e,componentName:t})}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}(o,o.name),this.components.push(o),this._componentCache[r]=o,o.awake&&o.awake(),o}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof d?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var r=this.components.splice(t,1)[0];return delete this._componentCache[e],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),R(r,e),r.gameObject=void 0,r}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof d?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}(),w=function(){function e(){this.events=[]}return e.prototype.add=function(e){var r=e.component,o=e.prop,n=e.type,a=e.componentName;if(n===exports.OBSERVER_TYPE.REMOVE){if(this.events.find((function(e){return e.component===r&&e.type===exports.OBSERVER_TYPE.ADD})))return;this.events=this.events.filter((function(e){return e.component!==r}))}var s=this.events.findIndex((function(e){return e.component===r&&t.isEqual(e.prop,o)&&e.type===n}));s>-1&&this.events.splice(s,1),this.events.push({gameObject:r.gameObject,component:r,prop:o,type:n,componentName:a})},e.prototype.getChanged=function(){return this.events},Object.defineProperty(e.prototype,"changed",{get:function(){return this.events},enumerable:!1,configurable:!0}),e.prototype.clear=function(){var e=this.events;return this.events=[],e},e}(),P=function(){function e(e){this.started=!1,this.componentObserver=new w,this.__systemDefaultParams=e,this.name=this.constructor.systemName}return e.prototype.destroy=function(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)},e}();var j,L=Date.now?Date.now:function(){return(new Date).getTime()},N={originTime:0,playbackRate:1},C=function(){function e(t,r){t instanceof e&&(r=t,t={}),t=Object.assign({},N,t),r&&(this._parent=r),this._createTime=L(),this._timeMark=[{globalTime:this.globalTime,localTime:-t.originTime,entropy:-t.originTime,playbackRate:t.playbackRate,globalEntropy:0}],this._parent&&(this._timeMark[0].globalEntropy=this._parent.entropy),this._playbackRate=t.playbackRate}return Object.defineProperty(e.prototype,"globalTime",{get:function(){return this.parent?this.parent.currentTime:L()-this._createTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastTimeMark",{get:function(){return this._timeMark[this._timeMark.length-1]},enumerable:!1,configurable:!0}),e.prototype.markTime=function(e){var t=void 0===e?{}:e,r=t.time,o=void 0===r?this.currentTime:r,n=t.entropy,a=void 0===n?this.entropy:n,s=t.playbackRate,i=void 0===s?this.playbackRate:s,c={globalTime:this.globalTime,localTime:o,entropy:a,playbackRate:i,globalEntropy:this.globalEntropy};this._timeMark.push(c)},Object.defineProperty(e.prototype,"currentTime",{get:function(){var e=this.lastTimeMark,t=e.localTime,r=e.globalTime;return t+(this.globalTime-r)*this.playbackRate},set:function(e){this.markTime({time:e})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalEntropy",{get:function(){return this._parent?this._parent.entropy:this.globalTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"entropy",{get:function(){var e=this.lastTimeMark,t=e.entropy,r=e.globalEntropy;return t+Math.abs((this.globalEntropy-r)*this.playbackRate)},set:function(e){if(this.entropy>e){var t=this.seekTimeMark(e);this._timeMark.length=t+1}this.markTime({entropy:e})},enumerable:!1,configurable:!0}),e.prototype.fork=function(t){return new e(t,this)},e.prototype.seekGlobalTime=function(e){var t=this.seekTimeMark(e),r=this._timeMark[t],o=r.entropy,n=r.playbackRate;return r.globalTime+(e-o)/Math.abs(n)},e.prototype.seekLocalTime=function(e){var t=this.seekTimeMark(e),r=this._timeMark[t],o=r.localTime,n=r.entropy;return r.playbackRate>0?o+(e-n):o-(e-n)},e.prototype.seekTimeMark=function(e){var t=this._timeMark,r=0,o=t.length-1;if(e<=t[r].entropy)return r;if(e>=t[o].entropy)return o;for(var n=Math.floor((r+o)/2);n>r&&n<o;){if(e===t[n].entropy)return n;e<t[n].entropy?o=n:e>t[n].entropy&&(r=n),n=Math.floor((r+o)/2)}return r},Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this._playbackRate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){if(0===this.playbackRate)return!0;for(var e=this.parent;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1},enumerable:!1,configurable:!0}),e}(),M={autoStart:!0,frameRate:60},A=function(){function e(e){var t=this;e=Object.assign({},M,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=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start()}return e.prototype.update=function(){var e,t,r=this.timeline.currentTime,o=r-this._lastFrameTime;if(o>=this._frameDuration){var n=r-o%this._frameDuration,a=n-this._lastFrameTime;this._lastFrameTime=n;var s={deltaTime:a,time:n,currentTime:n,frameCount:++this._frameCount,fps:Math.round(1e3/a)};try{for(var i=l(this._tickers),c=i.next();!c.done;c=i.next()){var u=c.value;"function"==typeof u&&u(s)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}}},e.prototype.add=function(e){this._tickers.add(e)},e.prototype.remove=function(e){this._tickers.delete(e)},e.prototype.start=function(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this.timeline.playbackRate=0},e.prototype.setPlaybackRate=function(e){this.timeline.playbackRate=e},e}(),I=function(e){function t(t,r){var o=e.call(this,t,r)||this;return o.gameObjects=[],o.scene=o,o}return i(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(k);exports.LOAD_SCENE_MODE=void 0,(j=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",j.MULTI_CANVAS="MULTI_CANVAS";var D=function(e){if((e instanceof P||e instanceof d)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof d?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}}},V=function(e){function r(t){var r,o,n=void 0===t?{}:t,a=n.systems,s=n.frameRate,i=void 0===s?60:s,c=n.autoStart,u=void 0===c||c,p=n.needScene,f=void 0===p||p,h=e.call(this)||this;if(h.playing=!1,h.started=!1,h.multiScenes=[],h.systems=[],window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=h),h.ticker=new A({autoStart:!1,frameRate:i}),h.initTicker(),a&&a.length)try{for(var y=l(a),m=y.next();!m.done;m=y.next()){var d=m.value;h.addSystem(d)}}catch(e){r={error:e}}finally{try{m&&!m.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}return f&&h.loadScene(new I("scene")),u&&h.start(),h}return i(r,e),Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"gameObjects",{get:function(){return function(e){var t,r,o,n=(null===(o=null==e?void 0:e.scene)||void 0===o?void 0:o.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),s=[];try{for(var i=l(a),c=i.next();!c.done;c=i.next())s=h(s,c.value)}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return h(n,s)}(this)},enumerable:!1,configurable:!0}),r.prototype.addSystem=function(e,r){var o;if(e instanceof Function)o=new e(r);else{if(!(e instanceof P))return void console.warn("can only add System");o=e}if(!this.systems.find((function(e){return e.constructor===o.constructor}))){o.game=this,o.init&&o.init(o.__systemDefaultParams),function(e,t){b[t.systemName]=t.observerInfo,g[t.systemName]=e}(o,o.constructor),function(e){var r,o,n,a,s=[];e instanceof Array?s.push.apply(s,h(e)):s.push(e);try{for(var i=l(s),c=i.next();!c.done;c=i.next()){var u=c.value;for(var p in u.observerInfo){E[p]=E[p]||[];var f=E[p],y=function(e){-1===f.findIndex((function(r){return t.isEqual(r,e)}))&&E[p].push(e)};try{for(var m=(n=void 0,l(u.observerInfo[p])),d=m.next();!d.done;d=m.next())y(d.value)}catch(e){n={error:e}}finally{try{d&&!d.done&&(a=m.return)&&a.call(m)}finally{if(n)throw n.error}}}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}(o.constructor);try{o.awake&&o.awake()}catch(e){console.error(o.constructor.systemName+" awake error",e)}return this.systems.push(o),o}console.warn(o.constructor.systemName+" System has been added")},r.prototype.removeSystem=function(e){if(e){var t=-1;"string"==typeof e?t=this.systems.findIndex((function(t){return t.name===e})):e instanceof Function?t=this.systems.findIndex((function(t){return t.constructor===e})):e instanceof P&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},r.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},r.prototype.pause=function(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},r.prototype.start=function(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())},r.prototype.resume=function(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())},r.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var r,o,n,a;e.scene&&function(e,t){var r,o,n,a,s,i,c,u;void 0===t&&(t=[]);try{for(var p=l(t),f=p.next();!f.done;f=p.next()){var h=f.value;try{for(var y=(n=void 0,l(h.components)),m=y.next();!m.done;m=y.next()){var d=m.value;try{D(d),d.update&&d.update(e)}catch(e){console.error("gameObject: "+h.name+" "+d.name+" update error",e)}}}catch(e){n={error:e}}finally{try{m&&!m.done&&(a=y.return)&&a.call(y)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}try{for(var v=l(t),g=v.next();!g.done;g=v.next()){h=g.value;try{for(var b=(c=void 0,l(h.components)),E=b.next();!E.done;E=b.next()){d=E.value;try{d.lateUpdate&&d.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+d.name+" lateUpdate error",e)}}}catch(e){c={error:e}}finally{try{E&&!E.done&&(u=b.return)&&u.call(b)}finally{if(c)throw c.error}}}}catch(e){s={error:e}}finally{try{g&&!g.done&&(i=v.return)&&i.call(v)}finally{if(s)throw s.error}}}(t,e.gameObjects);try{for(var s=l(e.systems),i=s.next();!i.done;i=s.next()){var c=i.value;try{D(c),c.update&&c.update(t)}catch(t){console.error(c.constructor.systemName+" update error",t)}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}try{for(var u=l(e.systems),p=u.next();!p.done;p=u.next()){c=p.value;try{c.lateUpdate&&c.lateUpdate(t)}catch(t){console.error(c.constructor.systemName+" lateUpdate error",t)}}}catch(e){n={error:e}}finally{try{p&&!p.done&&(a=u.return)&&a.call(u)}finally{if(n)throw n.error}}}))},r.prototype.triggerResume=function(){var e,t;!function(e){var t,r,o,n;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(o=void 0,l(i.components)),u=c.next();!u.done;u=c.next()){var p=u.value;try{p.onResume&&p.onResume()}catch(e){console.error("gameObject: "+i.name+", "+p.name+", onResume error",e)}}}catch(e){o={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(o)throw o.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=l(this.systems),o=r.next();!o.done;o=r.next()){var n=o.value;try{n.onResume&&n.onResume()}catch(e){console.error(n.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},r.prototype.triggerPause=function(){var e,t;!function(e){var t,r,o,n;try{for(var a=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(o=void 0,l(i.components)),u=c.next();!u.done;u=c.next()){var p=u.value;try{p.onPause&&p.onPause()}catch(e){console.error("gameObject: "+i.name+", "+p.name+", onResume error",e)}}}catch(e){o={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(o)throw o.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=l(this.systems),o=r.next();!o.done;o=r.next()){var n=o.value;try{n.onPause&&n.onPause()}catch(e){console.error(n.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},r.prototype.destroySystems=function(){var e,t;try{for(var r=l(h(this.systems)),o=r.next();!o.done;o=r.next()){var n=o.value;this.removeSystem(n)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}this.systems.length=0},r.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},r.prototype.loadScene=function(e){var t=e.scene,r=e.mode,o=void 0===r?exports.LOAD_SCENE_MODE.SINGLE:r,n=e.params,a=void 0===n?{}:n;if(t){switch(o){case exports.LOAD_SCENE_MODE.SINGLE:this.scene=t;break;case exports.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:o,params:a})}},r}(a);function X(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function G(e){return void 0===e&&(e={}),function(t){if(!t.observerInfo){for(var r in e)for(var o in e[r]){"string"==typeof e[r][o]&&(e[r][o]=[e[r][o]]);var n=void 0;Array.isArray(e[r][o])&&(n={prop:e[r][o],deep:!1},e[r][o]=n),"string"==typeof(n=e[r][o]).prop&&(n.prop=[n.prop])}t.observerInfo=e}}}var F,U,B=function(e){function t(t){var r=t.resource,o=t.resourceTotal,n=e.call(this)||this;return n.progress=0,n.resourceTotal=0,n.resourceLoadedCount=0,n.resource=r,n.resourceTotal=o,0===o&&n.resource.emit(exports.LOAD_EVENT.COMPLETE,n),n}return i(t,e),t.prototype.onStart=function(){this.resource.emit(exports.LOAD_EVENT.START,this)},t.prototype.onProgress=function(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(exports.LOAD_EVENT.LOADED,this,e):this.resource.emit(exports.LOAD_EVENT.ERROR,this,e),this.resource.emit(exports.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)},t}(a),Y={AbstractLoadStrategy:o.AbstractLoadStrategy,AudioLoadStrategy:o.AudioLoadStrategy,ImageLoadStrategy:o.ImageLoadStrategy,XhrResponseType:o.XhrResponseType,MediaElementLoadStrategy:o.MediaElementLoadStrategy,VideoLoadStrategy:o.VideoLoadStrategy,XhrLoadStrategy:o.XhrLoadStrategy,Loader:o.Loader,Resource:o.Resource,ResourceType:o.ResourceType,ResourceState:o.ResourceState};exports.LOAD_EVENT=void 0,(F=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",F.PROGRESS="progress",F.LOADED="loaded",F.COMPLETE="complete",F.ERROR="error",exports.RESOURCE_TYPE=void 0,(U=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",U.SPRITE="SPRITE",U.SPRITE_ANIMATION="SPRITE_ANIMATION",U.DRAGONBONE="DRAGONBONE",U.PARTICLES="PARTICLES",U.LOTTIE="LOTTIE",U.SPINE="SPINE",U.AUDIO="AUDIO",U.VIDEO="VIDEO",o.XhrLoadStrategy.setExtensionXhrType("json",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("tex",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("ske",o.XhrResponseType.Json),o.XhrLoadStrategy.setExtensionXhrType("mp3",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("wav",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("aac",o.XhrResponseType.Buffer),o.XhrLoadStrategy.setExtensionXhrType("ogg",o.XhrResponseType.Buffer);var q={png:o.ImageLoadStrategy,jpg:o.ImageLoadStrategy,jpeg:o.ImageLoadStrategy,webp:o.ImageLoadStrategy,json:o.XhrLoadStrategy,tex:o.XhrLoadStrategy,ske:o.XhrLoadStrategy,audio:o.XhrLoadStrategy,video:o.VideoLoadStrategy},H=new(function(e){function t(t){var r=e.call(this)||this;return r.timeout=6e3,r.preProcessResourceHandlers=[],r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return i(t,e),t.prototype.loadConfig=function(e){this.addResource(e),this.preload()},t.prototype.loadSingle=function(e){return this.addResource([e]),this.getResource(e.name)},t.prototype.addResource=function(e){var t,r;if(!e||e.length<1)console.warn("no resources");else try{for(var o=l(e),n=o.next();!n.done;n=o.next()){var a=n.value;this.resourcesMap[a.name]?console.warn(a.name+" was already added"):(this.resourcesMap[a.name]=a,this.resourcesMap[a.name].data={})}}catch(e){t={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},t.prototype.addPreProcessResourceHandler=function(e){this.preProcessResourceHandlers.push(e)},t.prototype.removePreProcessResourceHandler=function(e){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(e),1)},t.prototype.preload=function(){var e=[];for(var t in this.resourcesMap){var r=this.resourcesMap[t];r.preload&&!r.complete&&e.push(r.name)}this.progress=new B({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})},t.prototype.getResource=function(e){return u(this,void 0,void 0,(function(){return p(this,(function(t){return this.loadResource({names:[e]}),[2,this.promiseMap[e]||Promise.resolve({})]}))}))},t.prototype.instance=function(e){return u(this,void 0,void 0,(function(){var t,r;return p(this,(function(o){switch(o.label){case 0:return t=this.resourcesMap[e],(r=this.makeInstanceFunctions[t.type])?[4,this.makeInstanceFunctions[t.type](t)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return[2,r]}}))}))},t.prototype.destroy=function(e){return u(this,void 0,void 0,(function(){return p(this,(function(t){switch(t.label){case 0:return[4,this._destroy(e)];case 1:return t.sent(),[2]}}))}))},t.prototype._destroy=function(e,t){return void 0===t&&(t=!1),u(this,void 0,void 0,(function(){var r,o;return p(this,(function(n){switch(n.label){case 0:if(!(r=this.resourcesMap[e]))return[2];if(t)return[3,5];n.label=1;case 1:return n.trys.push([1,4,,5]),this.destroyInstanceFunctions[r.type]?[4,this.destroyInstanceFunctions[r.type](r)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:return o=n.sent(),console.warn("destroy resource "+r.name+" error with '"+o.message+"'"),[3,5];case 5:return delete this.promiseMap[e],r.data={},r.complete=!1,r.instance=void 0,[2]}}))}))},t.prototype.registerInstance=function(e,t){this.makeInstanceFunctions[e]=t},t.prototype.registerDestroy=function(e,t){this.destroyInstanceFunctions[e]=t},t.prototype.loadResource=function(e){var t=this,r=e.names,o=void 0===r?[]:r,n=e.preload,a=void 0!==n&&n,s=o.filter((function(e){return!t.promiseMap[e]&&t.resourcesMap[e]}));if(s.length){var i={},c=this.getLoader(a);s.forEach((function(e){var r,o;t.promiseMap[e]=new Promise((function(t){return i[e]=t}));var n=t.resourcesMap[e];try{for(var s=l(t.preProcessResourceHandlers),u=s.next();!u.done;u=s.next()){(0,u.value)(n)}}catch(e){r={error:e}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(r)throw r.error}}for(var p in n.src){var f=n.src[p].type;"data"===f?(n.data[p]=n.src[p].data,t.doComplete(e,i[e],a)):c.add({url:n.src[p].url,name:n.name+"_"+p,strategy:q[f],metadata:{key:p,name:n.name,resolves:i}})}})),c.load()}},t.prototype.doComplete=function(e,t,r){return void 0===r&&(r=!1),u(this,void 0,void 0,(function(){var o,n,a,s;return p(this,(function(i){switch(i.label){case 0:if(o=this.resourcesMap[e],n={name:e,resource:this.resourcesMap[e],success:!0},!this.checkAllLoaded(e))return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),a=o,[4,this.instance(e)];case 2:return a.instance=i.sent(),o.complete=!0,r&&this.progress.onProgress(n),t(o),[3,4];case 3:return s=i.sent(),console.error(s),o.complete=!1,r&&(n.errMsg=s.message,n.success=!1,this.progress.onProgress(n)),t({}),[3,4];case 4:return[2]}}))}))},t.prototype.checkAllLoaded=function(e){var t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((function(e){return t.data[e]}))},t.prototype.getLoader=function(e){var t=this;void 0===e&&(e=!1);var r=this.loaders.find((function(e){return!e.loading}));return r||(r=new o.Loader,this.loaders.push(r)),e&&r.onStart.once((function(){t.progress.onStart()})),r.onLoad.add((function(r,o){t.onLoad({preload:e,resource:o})})),r.onError.add((function(r,o,n){t.onError({errMsg:r,resource:n,preload:e})})),r.onComplete.once((function(){r.onLoad.detachAll(),r.onError.detachAll(),r.reset()})),r},t.prototype.onLoad=function(e){var t=e.preload,r=void 0!==t&&t,o=e.resource;return u(this,void 0,void 0,(function(){var e,t,n,a,s;return p(this,(function(i){return e=o.metadata,t=e.key,n=e.name,a=e.resolves,s=o.data,this.resourcesMap[n].data[t]=s,this.doComplete(n,a[n],r),[2]}))}))},t.prototype.onError=function(e){var t=e.errMsg,r=e.preload,o=void 0!==r&&r,n=e.resource;return u(this,void 0,void 0,(function(){var e,r,a,s;return p(this,(function(i){return e=n.metadata,r=e.name,a=e.resolves,this._destroy(r,!0),a[r]({}),o&&(s={name:r,resource:this.resourcesMap[r],success:!1,errMsg:t},this.progress.onProgress(s)),[2]}))}))},t}(a)),z={IDEProp:X,componentObserver:G};console.log("Eva.js version: 1.3.0-alpha.1"),exports.Component=d,exports.Game=V,exports.GameObject=k,exports.IDEProp=X,exports.RESOURCE_TYPE_STRATEGY=q,exports.Scene=I,exports.System=P,exports.Transform=x,exports.componentObserver=G,exports.decorators=z,exports.resource=H,exports.resourceLoader=Y,exports.version="1.3.0-alpha.1";
|
|
15
|
+
***************************************************************************** */function c(e,t){function r(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function u(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function p(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{c(n.next(e))}catch(e){a(e)}}function s(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(i,s)}c((n=n.apply(e,t||[])).next())}))}function l(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function f(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function h(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function m(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e}var y,d=function(e){function t(t){var r=e.call(this)||this;return r.started=!1,r.name=r.constructor.componentName,r.__componentDefaultParams=t,r}return c(t,e),t}(i),v=d;exports.OBSERVER_TYPE=void 0,(y=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",y.REMOVE="REMOVE",y.CHANGE="CHANGE";var b={},g={},E={},_={};function O(e,t){b[e.gameObject.id]||(b[e.gameObject.id]={});var r=b[e.gameObject.id],n=e.name+"_"+t.join(",");if(r[n])return r[n];for(var o=t.length-1,a=e,i=0;i<o;i++)a=a[t[i]];return r[n]={property:a,key:t[o]},r[n]}function R(e){var t,r,n=e.systemName,o=e.componentName,a=e.component,i=e.prop,s=e.type;null===(r=null===(t=g[n])||void 0===t?void 0:t.componentObserver)||void 0===r||r.add({component:a,prop:i,type:s,componentName:o})}function x(e){var r,n,o=e.obj,a=e.key,i=e.prop,s=e.component,c=e.componentName;if(void 0!==o)if(a in o){if(Object.defineProperty(o,"_"+a,{enumerable:!1,writable:!0,value:o[a]}),i.deep&&t.isObject(o[a]))try{for(var u=f(Object.keys(o[a])),p=u.next();!p.done;p=u.next()){var l=p.value;x({obj:o[a],key:l,prop:i,component:s,componentName:c})}}catch(e){r={error:e}}finally{try{p&&!p.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}Object.defineProperty(o,a,{enumerable:!0,set:function(e){o["_"+a]!==e&&(o["_"+a]=e,function(e){var r=e.prop,n=e.component,o=e.componentName;for(var a in E){var i=(E[a]||{})[o];i&&i.findIndex((function(e){return t.isEqual(e,r)}))>-1&&R({systemName:a,componentName:o,component:n,prop:r,type:exports.OBSERVER_TYPE.CHANGE})}}({prop:i,component:s,componentName:c}))},get:function(){return o["_"+a]}})}else console.error("prop "+a+" not in component: "+c+", Can not observer")}function T(e,t){var r,n;for(var o in void 0===t&&(t=e.name),E){(E[o]||{})[t]&&(null===(n=null===(r=g[o])||void 0===r?void 0:r.componentObserver)||void 0===n||n.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t}))}!function(e){e.gameObject&&delete b[e.gameObject.id]}(e)}var w=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="Transform",t._parent=null,t.inScene=!1,t.children=[],t.position={x:0,y:0},t.size={width:0,height:0},t.origin={x:0,y:0},t.anchor={x:0,y:0},t.scale={x:1,y:1},t.skew={x:0,y:0},t.rotation=0,t}return c(t,e),t.prototype.init=function(e){var t,r;void 0===e&&(e={});try{for(var n=f(["position","size","origin","anchor","scale","skew"]),o=n.next();!o.done;o=n.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",u([r.type("vector2"),r.step(1)],t.prototype,"position",void 0),u([r.type("size"),r.step(1)],t.prototype,"size",void 0),u([r.type("vector2"),r.step(.1)],t.prototype,"origin",void 0),u([r.type("vector2"),r.step(.1)],t.prototype,"anchor",void 0),u([r.type("vector2"),r.step(.1)],t.prototype,"scale",void 0),u([r.type("vector2"),r.step(.1)],t.prototype,"skew",void 0),u([r.type("number"),r.step(.1)],t.prototype,"rotation",void 0),t}(v),k=0;var S=function(){function e(e,t){this._componentCache={},this.components=[],this.destroyed=!1,this._name=e,this.id=++k,this.addComponent(w,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(w)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform&&this.transform.parent&&this.transform.parent.gameObject},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t,r;if(this._scene!==e){var n=this._scene;if(this._scene=e,this.transform&&this.transform.children)try{for(var o=f(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):n&&n.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error("gameObject '"+this.name+"' has been destroy");t.transform.parent=this.transform,t.scene=this.scene}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){if(!this.destroyed){var r=function(e){return e instanceof d?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[r]){var n;if(e instanceof Function)n=new e(t);else{if(!(e instanceof v))throw new Error("addComponent recieve Component and Component Constructor");n=e}if(n.gameObject)throw new Error("component has been added on gameObject "+n.gameObject.name);return n.gameObject=this,n.init&&n.init(n.__componentDefaultParams),function(e,t){var r,n;for(var o in void 0===t&&(t=e.name),E)(E[o]||{})[t]&&(null===(n=null===(r=g[o])||void 0===r?void 0:r.componentObserver)||void 0===n||n.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t}))}(n,n.name),function(e,t){var r,n;if(void 0===t&&(t=e.name),t&&_[t]){if(!(e&&(o=e,o&&o.constructor&&"componentName"in o.constructor)))throw new Error("component param must be an instance of Component");var o;if(!e.gameObject||!e.gameObject.id)throw new Error("component should be add to a gameObject");try{for(var a=f(_[t]),i=a.next();!i.done;i=a.next()){var s=i.value,c=O(e,s.prop);x({obj:c.property,key:c.key,prop:s,component:e,componentName:t})}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}}(n,n.name),this.components.push(n),this._componentCache[r]=n,n.awake&&n.awake(),n}}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof v?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var r=this.components.splice(t,1)[0];return delete this._componentCache[e],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),T(r,e),r.gameObject=void 0,r}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof v?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){if(this.transform){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0,this.destroyed=!0}else console.error("Cannot destroy gameObject that have already been destroyed.")},e}(),P=function(){function e(){this.events=[]}return e.prototype.add=function(e){var r=e.component,n=e.prop,o=e.type,a=e.componentName;if(o===exports.OBSERVER_TYPE.REMOVE){if(this.events.find((function(e){return e.component===r&&e.type===exports.OBSERVER_TYPE.ADD})))return void(this.events=this.events.filter((function(e){return e.component!==r})));this.events=this.events.filter((function(e){return e.component!==r}))}var i=this.events.findIndex((function(e){return e.component===r&&t.isEqual(e.prop,n)&&e.type===o}));i>-1&&this.events.splice(i,1),this.events.push({gameObject:r.gameObject,component:r,prop:n,type:o,componentName:a})},e.prototype.getChanged=function(){return this.events},Object.defineProperty(e.prototype,"changed",{get:function(){return this.events},enumerable:!1,configurable:!0}),e.prototype.clear=function(){var e=this.events;return this.events=[],e},e}(),j=function(){function e(e){this.started=!1,this.componentObserver=new P,this.__systemDefaultParams=e,this.name=this.constructor.systemName}return e.prototype.destroy=function(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)},e}();var C,M=Date.now?Date.now:function(){return(new Date).getTime()},N={originTime:0,playbackRate:1},A=function(){function e(t,r){t instanceof e&&(r=t,t={}),t=Object.assign({},N,t),r&&(this._parent=r),this._createTime=M(),this._timeMark=[{globalTime:this.globalTime,localTime:-t.originTime,entropy:-t.originTime,playbackRate:t.playbackRate,globalEntropy:0}],this._parent&&(this._timeMark[0].globalEntropy=this._parent.entropy),this._playbackRate=t.playbackRate}return Object.defineProperty(e.prototype,"globalTime",{get:function(){return this.parent?this.parent.currentTime:M()-this._createTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastTimeMark",{get:function(){return this._timeMark[this._timeMark.length-1]},enumerable:!1,configurable:!0}),e.prototype.markTime=function(e){var t=void 0===e?{}:e,r=t.time,n=void 0===r?this.currentTime:r,o=t.entropy,a=void 0===o?this.entropy:o,i=t.playbackRate,s=void 0===i?this.playbackRate:i,c={globalTime:this.globalTime,localTime:n,entropy:a,playbackRate:s,globalEntropy:this.globalEntropy};this._timeMark.push(c)},Object.defineProperty(e.prototype,"currentTime",{get:function(){var e=this.lastTimeMark,t=e.localTime,r=e.globalTime;return t+(this.globalTime-r)*this.playbackRate},set:function(e){this.markTime({time:e})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalEntropy",{get:function(){return this._parent?this._parent.entropy:this.globalTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"entropy",{get:function(){var e=this.lastTimeMark,t=e.entropy,r=e.globalEntropy;return t+Math.abs((this.globalEntropy-r)*this.playbackRate)},set:function(e){if(this.entropy>e){var t=this.seekTimeMark(e);this._timeMark.length=t+1}this.markTime({entropy:e})},enumerable:!1,configurable:!0}),e.prototype.fork=function(t){return new e(t,this)},e.prototype.seekGlobalTime=function(e){var t=this.seekTimeMark(e),r=this._timeMark[t],n=r.entropy,o=r.playbackRate;return r.globalTime+(e-n)/Math.abs(o)},e.prototype.seekLocalTime=function(e){var t=this.seekTimeMark(e),r=this._timeMark[t],n=r.localTime,o=r.entropy;return r.playbackRate>0?n+(e-o):n-(e-o)},e.prototype.seekTimeMark=function(e){var t=this._timeMark,r=0,n=t.length-1;if(e<=t[r].entropy)return r;if(e>=t[n].entropy)return n;for(var o=Math.floor((r+n)/2);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},Object.defineProperty(e.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this._playbackRate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){if(0===this.playbackRate)return!0;for(var e=this.parent;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1},enumerable:!1,configurable:!0}),e}(),D={autoStart:!0,frameRate:60},I=function(){function e(e){var t=this;e=Object.assign({},D,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new A({originTime:0,playbackRate:1}),this._lastFrameTime=this.timeline.currentTime,this._tickers=new Set,this._requestId=null,this._ticker=function(){t._started&&(t._requestId=requestAnimationFrame(t._ticker),t.update())},this.autoStart&&this.start()}return e.prototype.update=function(){var e,t,r=this.timeline.currentTime,n=r-this._lastFrameTime;if(n>=this._frameDuration){var o=r-n%this._frameDuration,a=o-this._lastFrameTime;this._lastFrameTime=o;var i={deltaTime:a,time:o,currentTime:o,frameCount:++this._frameCount,fps:Math.round(1e3/a)};try{for(var s=f(this._tickers),c=s.next();!c.done;c=s.next()){var u=c.value;"function"==typeof u&&u(i)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}}},e.prototype.add=function(e){this._tickers.add(e)},e.prototype.remove=function(e){this._tickers.delete(e)},e.prototype.start=function(){this._started||(this._started=!0,this.timeline.playbackRate=1,this._requestId=requestAnimationFrame(this._ticker))},e.prototype.pause=function(){this._started=!1,this.timeline.playbackRate=0},e.prototype.setPlaybackRate=function(e){this.timeline.playbackRate=e},e}(),L=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.gameObjects=[],n.scene=n,n}return c(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(S);exports.LOAD_SCENE_MODE=void 0,(C=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",C.MULTI_CANVAS="MULTI_CANVAS";var V=function(e){if((e instanceof j||e instanceof v)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof v?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}}},G=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.playing=!1,t.started=!1,t.multiScenes=[],t.systems=[],t}return c(r,e),r.prototype.init=function(e){var t=void 0===e?{}:e,r=t.systems,n=t.frameRate,o=void 0===n?60:n,a=t.autoStart,i=void 0===a||a,s=t.needScene,c=void 0===s||s;return p(this,void 0,void 0,(function(){var e,t,n,a,s,u;return l(this,(function(p){switch(p.label){case 0:if(window.__EVA_INSPECTOR_ENV__&&(window.__EVA_GAME_INSTANCE__=this),this.ticker=new I({autoStart:!1,frameRate:o}),this.initTicker(),!r||!r.length)return[3,8];p.label=1;case 1:p.trys.push([1,6,7,8]),e=f(r),t=e.next(),p.label=2;case 2:return t.done?[3,5]:(n=t.value,[4,this.addSystem(n)]);case 3:p.sent(),p.label=4;case 4:return t=e.next(),[3,2];case 5:return[3,8];case 6:return a=p.sent(),s={error:a},[3,8];case 7:try{t&&!t.done&&(u=e.return)&&u.call(e)}finally{if(s)throw s.error}return[7];case 8:return c&&this.loadScene(new L("scene")),i&&this.start(),[2]}}))}))},Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},set:function(e){this._scene=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"gameObjects",{get:function(){return function(e){var t,r,n,o=(null===(n=null==e?void 0:e.scene)||void 0===n?void 0:n.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),i=[];try{for(var s=f(a),c=s.next();!c.done;c=s.next())i=m(i,c.value)}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return m(o,i)}(this)},enumerable:!1,configurable:!0}),r.prototype.addSystem=function(e,r){return p(this,void 0,void 0,(function(){var n;return l(this,(function(o){switch(o.label){case 0:if(e instanceof Function)n=new e(r);else{if(!(e instanceof j))return console.warn("can only add System"),[2];n=e}return this.systems.find((function(e){return e.constructor===n.constructor}))?(console.warn(n.constructor.systemName+" System has been added"),[2]):(n.game=this,n.init?[4,n.init(n.__systemDefaultParams)]:[3,2]);case 1:o.sent(),o.label=2;case 2:!function(e,t){E[t.systemName]=t.observerInfo,g[t.systemName]=e}(n,n.constructor),function(e){var r,n,o,a,i=[];e instanceof Array?i.push.apply(i,m(e)):i.push(e);try{for(var s=f(i),c=s.next();!c.done;c=s.next()){var u=c.value;for(var p in u.observerInfo){_[p]=_[p]||[];var l=_[p],h=function(e){-1===l.findIndex((function(r){return t.isEqual(r,e)}))&&_[p].push(e)};try{for(var y=(o=void 0,f(u.observerInfo[p])),d=y.next();!d.done;d=y.next())h(d.value)}catch(e){o={error:e}}finally{try{d&&!d.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}}}}catch(e){r={error:e}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}}(n.constructor);try{n.awake&&n.awake()}catch(e){console.error(n.constructor.systemName+" awake error",e)}return this.systems.push(n),[2,n]}}))}))},r.prototype.removeSystem=function(e){if(e){var t=-1;"string"==typeof e?t=this.systems.findIndex((function(t){return t.name===e})):e instanceof Function?t=this.systems.findIndex((function(t){return t.constructor===e})):e instanceof j&&(t=this.systems.findIndex((function(t){return t===e}))),t>-1&&(this.systems[t].destroy&&this.systems[t].destroy(),this.systems.splice(t,1))}},r.prototype.getSystem=function(e){return this.systems.find((function(t){return"string"==typeof e?t.name===e:t instanceof e}))},r.prototype.pause=function(){this.playing&&(this.playing=!1,this.ticker.pause(),this.triggerPause())},r.prototype.start=function(){this.playing||(this.playing=!0,this.started=!0,this.ticker.start())},r.prototype.resume=function(){this.playing||(this.playing=!0,this.ticker.start(),this.triggerResume())},r.prototype.initTicker=function(){var e=this;this.ticker.add((function(t){var r,n,o,a;e.scene&&function(e,t){var r,n,o,a,i,s,c,u;void 0===t&&(t=[]);try{for(var p=f(t),l=p.next();!l.done;l=p.next()){var h=l.value;try{for(var m=(o=void 0,f(h.components)),y=m.next();!y.done;y=m.next()){var d=y.value;try{V(d),d.update&&d.update(e)}catch(e){console.error("gameObject: "+h.name+" "+d.name+" update error",e)}}}catch(e){o={error:e}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var v=f(t),b=v.next();!b.done;b=v.next()){h=b.value;try{for(var g=(c=void 0,f(h.components)),E=g.next();!E.done;E=g.next()){d=E.value;try{d.lateUpdate&&d.lateUpdate(e)}catch(e){console.error("gameObject: "+h.name+" "+d.name+" lateUpdate error",e)}}}catch(e){c={error:e}}finally{try{E&&!E.done&&(u=g.return)&&u.call(g)}finally{if(c)throw c.error}}}}catch(e){i={error:e}}finally{try{b&&!b.done&&(s=v.return)&&s.call(v)}finally{if(i)throw i.error}}}(t,e.gameObjects);try{for(var i=f(e.systems),s=i.next();!s.done;s=i.next()){var c=s.value;try{V(c),c.update&&c.update(t)}catch(t){console.error(c.constructor.systemName+" update error",t)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}try{for(var u=f(e.systems),p=u.next();!p.done;p=u.next()){c=p.value;try{c.lateUpdate&&c.lateUpdate(t)}catch(t){console.error(c.constructor.systemName+" lateUpdate error",t)}}}catch(e){o={error:e}}finally{try{p&&!p.done&&(a=u.return)&&a.call(u)}finally{if(o)throw o.error}}}))},r.prototype.triggerResume=function(){var e,t;!function(e){var t,r,n,o;try{for(var a=f(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(n=void 0,f(s.components)),u=c.next();!u.done;u=c.next()){var p=u.value;try{p.onResume&&p.onResume()}catch(e){console.error("gameObject: "+s.name+", "+p.name+", onResume error",e)}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=f(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onResume&&o.onResume()}catch(e){console.error(o.constructor.systemName+", onResume error",e)}}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},r.prototype.triggerPause=function(){var e,t;!function(e){var t,r,n,o;try{for(var a=f(e),i=a.next();!i.done;i=a.next()){var s=i.value;try{for(var c=(n=void 0,f(s.components)),u=c.next();!u.done;u=c.next()){var p=u.value;try{p.onPause&&p.onPause()}catch(e){console.error("gameObject: "+s.name+", "+p.name+", onResume error",e)}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=f(this.systems),n=r.next();!n.done;n=r.next()){var o=n.value;try{o.onPause&&o.onPause()}catch(e){console.error(o.constructor.systemName+", onPause error",e)}}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},r.prototype.destroySystems=function(){var e,t;try{for(var r=f(m(this.systems)),n=r.next();!n.done;n=r.next()){var o=n.value;this.removeSystem(o)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}this.systems.length=0},r.prototype.destroy=function(){this.removeAllListeners(),this.pause(),this.scene.destroy(),this.destroySystems(),this.ticker=null,this.scene=null,this.canvas=null,this.multiScenes=null},r.prototype.loadScene=function(e){var t=e.scene,r=e.mode,n=void 0===r?exports.LOAD_SCENE_MODE.SINGLE:r,o=e.params,a=void 0===o?{}:o;if(t){switch(n){case exports.LOAD_SCENE_MODE.SINGLE:this.scene=t;break;case exports.LOAD_SCENE_MODE.MULTI_CANVAS:this.multiScenes.push(t)}this.emit("sceneChanged",{scene:t,mode:n,params:a})}},r}(i);function F(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}function U(e){return void 0===e&&(e={}),function(t){if(!t.observerInfo){for(var r in e)for(var n in e[r]){"string"==typeof e[r][n]&&(e[r][n]=[e[r][n]]);var o=void 0;Array.isArray(e[r][n])&&(o={prop:e[r][n],deep:!1},e[r][n]=o),"string"==typeof(o=e[r][n]).prop&&(o.prop=[o.prop])}t.observerInfo=e}}}var Y,q,H=function(e){function t(t){var r=t.resource,n=t.resourceTotal,o=e.call(this)||this;return o.progress=0,o.resourceTotal=0,o.resourceLoadedCount=0,o.resource=r,o.resourceTotal=n,0===n&&o.resource.emit(exports.LOAD_EVENT.COMPLETE,o),o}return c(t,e),t.prototype.onStart=function(){this.resource.emit(exports.LOAD_EVENT.START,this)},t.prototype.onProgress=function(e){this.resourceLoadedCount++,this.progress=Math.floor(this.resourceLoadedCount/this.resourceTotal*100)/100,e.success?this.resource.emit(exports.LOAD_EVENT.LOADED,this,e):this.resource.emit(exports.LOAD_EVENT.ERROR,this,e),this.resource.emit(exports.LOAD_EVENT.PROGRESS,this,e),this.resourceLoadedCount===this.resourceTotal&&this.resource.emit(exports.LOAD_EVENT.COMPLETE,this)},t}(i),B=H,z={AbstractLoadStrategy:o.AbstractLoadStrategy,AudioLoadStrategy:o.AudioLoadStrategy,ImageLoadStrategy:o.ImageLoadStrategy,XhrResponseType:o.XhrResponseType,MediaElementLoadStrategy:o.MediaElementLoadStrategy,VideoLoadStrategy:o.VideoLoadStrategy,Loader:o.Loader,Resource:o.Resource,ResourceType:o.ResourceType,ResourceState:o.ResourceState};exports.LOAD_EVENT=void 0,(Y=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",Y.PROGRESS="progress",Y.LOADED="loaded",Y.COMPLETE="complete",Y.ERROR="error",exports.RESOURCE_TYPE=void 0,(q=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",q.SPRITE="SPRITE",q.SPRITE_ANIMATION="SPRITE_ANIMATION",q.AUDIO="AUDIO",q.VIDEO="VIDEO";var X=function(e){function t(t){var r=e.call(this)||this;return r.timeout=6e3,r.preProcessResourceHandlers=[],r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return c(t,e),t.prototype.loadConfig=function(e){this.addResource(e),this.preload()},t.prototype.loadSingle=function(e){return this.addResource([e]),this.getResource(e.name)},t.prototype.addResource=function(e){var t,r;if(!e||e.length<1)console.warn("no resources");else try{for(var n=f(e),o=n.next();!o.done;o=n.next()){var a=o.value;this.resourcesMap[a.name]?console.warn(a.name+" was already added"):(this.resourcesMap[a.name]=a,this.resourcesMap[a.name].data={})}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},t.prototype.addPreProcessResourceHandler=function(e){this.preProcessResourceHandlers.push(e)},t.prototype.removePreProcessResourceHandler=function(e){this.preProcessResourceHandlers.splice(this.preProcessResourceHandlers.indexOf(e),1)},t.prototype.preload=function(){var e=[];for(var t in this.resourcesMap){var r=this.resourcesMap[t];!r.preload||r.complete||this.promiseMap[t]||e.push(r.name)}this.progress=new B({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})},t.prototype.getResource=function(e){return p(this,void 0,void 0,(function(){return l(this,(function(t){return this.loadResource({names:[e]}),[2,this.promiseMap[e]||Promise.resolve({})]}))}))},t.prototype.instance=function(e){return p(this,void 0,void 0,(function(){var t,r;return l(this,(function(n){switch(n.label){case 0:return t=this.resourcesMap[e],(r=this.makeInstanceFunctions[t.type])?[4,this.makeInstanceFunctions[t.type](t)]:[3,2];case 1:r=n.sent(),n.label=2;case 2:return[2,r]}}))}))},t.prototype.destroy=function(e){return p(this,void 0,void 0,(function(){return l(this,(function(t){switch(t.label){case 0:return[4,this._destroy(e)];case 1:return t.sent(),[2]}}))}))},t.prototype._destroy=function(e,t){return void 0===t&&(t=!1),p(this,void 0,void 0,(function(){var r,n;return l(this,(function(o){switch(o.label){case 0:if(!(r=this.resourcesMap[e]))return[2];if(t)return[3,5];o.label=1;case 1:return o.trys.push([1,4,,5]),this.destroyInstanceFunctions[r.type]?[4,this.destroyInstanceFunctions[r.type](r)]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return n=o.sent(),console.warn("destroy resource "+r.name+" error with '"+n.message+"'"),[3,5];case 5:return delete this.promiseMap[e],r.data={},r.complete=!1,r.instance=void 0,[2]}}))}))},t.prototype.registerResourceType=function(e,t){if(void 0===t&&(t=e),exports.RESOURCE_TYPE[e])throw new Error("The type "+e+" already exists in RESOURCE_TYPE");exports.RESOURCE_TYPE[e]=t},t.prototype.registerInstance=function(e,t){this.makeInstanceFunctions[e]=t},t.prototype.registerDestroy=function(e,t){this.destroyInstanceFunctions[e]=t},t.prototype.loadResource=function(e){var t=this,r=e.names,o=void 0===r?[]:r,a=e.preload,i=void 0!==a&&a,s=o.filter((function(e){return!t.promiseMap[e]&&t.resourcesMap[e]}));if(s.length){var c={};s.forEach((function(e){var r,o,a;t.promiseMap[e]=new Promise((function(t){return c[e]=t}));var s=t.resourcesMap[e];try{for(var u=f(t.preProcessResourceHandlers),p=u.next();!p.done;p=u.next()){(0,p.value)(s)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}var l=function(r){if("data"===s.src[r].type)s.data[r]=s.src[r].data,t.doComplete(e,c[e],i);else{var o=null===(a=s.src[r])||void 0===a?void 0:a.url;"string"==typeof o&&o.startsWith("//")&&(o=""+window.location.protocol+s.src[r].url),n.Assets.load(o).then((function(n){t.onLoad({preload:i,resource:{metadata:{key:r,name:e,resolves:c},data:n}})})).catch((function(n){console.log(">>>E",n),t.onError({preload:i,errMsg:n.message,resource:{metadata:{key:r,name:e,resolves:c}}})}))}};for(var h in s.src)l(h)}))}},t.prototype.doComplete=function(e,t,r){return void 0===r&&(r=!1),p(this,void 0,void 0,(function(){var n,o,a,i;return l(this,(function(s){switch(s.label){case 0:if(n=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0},!this.checkAllLoaded(e))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),a=n,[4,this.instance(e)];case 2:return a.instance=s.sent(),n.complete=!0,r&&this.progress.onProgress(o),t(n),[3,4];case 3:return i=s.sent(),console.error(i),n.complete=!1,r&&(o.errMsg=i.message,o.success=!1,this.progress.onProgress(o)),t({}),[3,4];case 4:return[2]}}))}))},t.prototype.checkAllLoaded=function(e){var t=this.resourcesMap[e];return Array.from(Object.keys(t.src)).every((function(e){return t.data[e]}))},t.prototype.getLoader=function(e){},t.prototype.onLoad=function(e){var t=e.preload,r=void 0!==t&&t,n=e.resource;return p(this,void 0,void 0,(function(){var e,t,o,a,i;return l(this,(function(s){return e=n.metadata,t=e.key,o=e.name,a=e.resolves,i=n.data,this.resourcesMap[o].data[t]=i,this.doComplete(o,a[o],r),[2]}))}))},t.prototype.onError=function(e){var t=e.errMsg,r=e.preload,n=void 0!==r&&r,o=e.resource;return p(this,void 0,void 0,(function(){var e,r,a,i;return l(this,(function(s){return e=o.metadata,r=e.name,a=e.resolves,this._destroy(r,!0),a[r]({}),n&&(i={name:r,resource:this.resourcesMap[r],success:!1,errMsg:t},this.progress.onProgress(i)),[2]}))}))},t}(i),W=new X,J={IDEProp:F,componentObserver:U},K="2.0.0-beta.0";console.log("Eva.js version: "+K);exports.Component=v,exports.Game=G,exports.GameObject=S,exports.IDEProp=F,exports.RESOURCE_TYPE_STRATEGY={},exports.Scene=L,exports.System=j,exports.Transform=w,exports.componentObserver=U,exports.decorators=J,exports.resource=W,exports.resourceLoader=z,exports.version=K;
|