@eva/eva.js 1.1.1-alpha.0 → 1.1.1-fix.1

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.
Files changed (51) hide show
  1. package/README.md +1 -2
  2. package/dist/eva.js.cjs.js +71 -71
  3. package/dist/eva.js.cjs.prod.js +2 -2
  4. package/dist/eva.js.esm.js +65 -65
  5. package/index.js +3 -3
  6. package/package.json +1 -1
  7. package/dist/EVA.js +0 -5564
  8. package/dist/EVA.min.js +0 -1
  9. package/dist/eva.js.d.ts +0 -382
  10. package/dist/examples/index.d.ts +0 -2
  11. package/dist/examples/index.d.ts.map +0 -1
  12. package/dist/examples/src/a11y.d.ts +0 -3
  13. package/dist/examples/src/a11y.d.ts.map +0 -1
  14. package/dist/examples/src/component.d.ts +0 -3
  15. package/dist/examples/src/component.d.ts.map +0 -1
  16. package/dist/examples/src/compressed-texture.d.ts +0 -1
  17. package/dist/examples/src/compressed-texture.d.ts.map +0 -1
  18. package/dist/examples/src/dragonbone.d.ts +0 -3
  19. package/dist/examples/src/dragonbone.d.ts.map +0 -1
  20. package/dist/examples/src/event.d.ts +0 -3
  21. package/dist/examples/src/event.d.ts.map +0 -1
  22. package/dist/examples/src/graphics.d.ts +0 -3
  23. package/dist/examples/src/graphics.d.ts.map +0 -1
  24. package/dist/examples/src/image.d.ts +0 -3
  25. package/dist/examples/src/image.d.ts.map +0 -1
  26. package/dist/examples/src/loader.d.ts +0 -3
  27. package/dist/examples/src/loader.d.ts.map +0 -1
  28. package/dist/examples/src/lottie.d.ts +0 -3
  29. package/dist/examples/src/lottie.d.ts.map +0 -1
  30. package/dist/examples/src/mask.d.ts +0 -4
  31. package/dist/examples/src/mask.d.ts.map +0 -1
  32. package/dist/examples/src/matter.d.ts +0 -3
  33. package/dist/examples/src/matter.d.ts.map +0 -1
  34. package/dist/examples/src/multi-canvas.d.ts +0 -3
  35. package/dist/examples/src/multi-canvas.d.ts.map +0 -1
  36. package/dist/examples/src/ninePatch.d.ts +0 -3
  37. package/dist/examples/src/ninePatch.d.ts.map +0 -1
  38. package/dist/examples/src/sound.d.ts +0 -3
  39. package/dist/examples/src/sound.d.ts.map +0 -1
  40. package/dist/examples/src/spine.d.ts +0 -3
  41. package/dist/examples/src/spine.d.ts.map +0 -1
  42. package/dist/examples/src/sprite.d.ts +0 -3
  43. package/dist/examples/src/sprite.d.ts.map +0 -1
  44. package/dist/examples/src/spriteAnimation.d.ts +0 -3
  45. package/dist/examples/src/spriteAnimation.d.ts.map +0 -1
  46. package/dist/examples/src/text.d.ts +0 -3
  47. package/dist/examples/src/text.d.ts.map +0 -1
  48. package/dist/examples/src/tilingSprite.d.ts +0 -3
  49. package/dist/examples/src/tilingSprite.d.ts.map +0 -1
  50. package/dist/examples/src/transition.d.ts +0 -3
  51. package/dist/examples/src/transition.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
-
2
1
  # @eva/eva.js
3
2
 
4
3
  More Introduction
4
+
5
5
  - [EN](https://eva.js.org)
6
6
  - [中文](https://eva-engine.gitee.io)
7
-
@@ -6,7 +6,7 @@ var EventEmitter = require('eventemitter3');
6
6
  var lodashEs = require('lodash-es');
7
7
  var resourceLoader = require('resource-loader');
8
8
 
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
10
10
 
11
11
  var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
12
12
 
@@ -135,7 +135,8 @@ var Component = (function (_super) {
135
135
  return _this;
136
136
  }
137
137
  return Component;
138
- }(EventEmitter__default));
138
+ }(EventEmitter__default));
139
+ var Component$1 = Component;
139
140
 
140
141
  exports.OBSERVER_TYPE = void 0;
141
142
  (function (ObserverType) {
@@ -467,7 +468,8 @@ var Transform = (function (_super) {
467
468
  IDEProp
468
469
  ], Transform.prototype, "rotation", void 0);
469
470
  return Transform;
470
- }(Component));
471
+ }(Component$1));
472
+ var Transform$1 = Transform;
471
473
 
472
474
  var _id = 0;
473
475
  function getId() {
@@ -479,20 +481,18 @@ var GameObject = (function () {
479
481
  this.components = [];
480
482
  this._name = name;
481
483
  this.id = getId();
482
- this.addComponent(Transform, obj);
484
+ this.addComponent(Transform$1, obj);
483
485
  }
484
486
  Object.defineProperty(GameObject.prototype, "transform", {
485
487
  get: function () {
486
- return this.getComponent(Transform);
488
+ return this.getComponent(Transform$1);
487
489
  },
488
490
  enumerable: false,
489
491
  configurable: true
490
492
  });
491
493
  Object.defineProperty(GameObject.prototype, "parent", {
492
494
  get: function () {
493
- return (this.transform &&
494
- this.transform.parent &&
495
- this.transform.parent.gameObject);
495
+ return this.transform && this.transform.parent && this.transform.parent.gameObject;
496
496
  },
497
497
  enumerable: false,
498
498
  configurable: true
@@ -552,9 +552,7 @@ var GameObject = (function () {
552
552
  gameObject.scene = this.scene;
553
553
  };
554
554
  GameObject.prototype.removeChild = function (gameObject) {
555
- if (!(gameObject instanceof GameObject) ||
556
- !gameObject.parent ||
557
- gameObject.parent !== this) {
555
+ if (!(gameObject instanceof GameObject) || !gameObject.parent || gameObject.parent !== this) {
558
556
  return gameObject;
559
557
  }
560
558
  gameObject.transform.parent = null;
@@ -569,7 +567,7 @@ var GameObject = (function () {
569
567
  if (C instanceof Function) {
570
568
  component = new C(obj);
571
569
  }
572
- else if (C instanceof Component) {
570
+ else if (C instanceof Component$1) {
573
571
  component = C;
574
572
  }
575
573
  else {
@@ -592,14 +590,14 @@ var GameObject = (function () {
592
590
  if (typeof c === 'string') {
593
591
  componentName = c;
594
592
  }
595
- else if (c instanceof Component) {
593
+ else if (c instanceof Component$1) {
596
594
  componentName = c.name;
597
595
  }
598
596
  else if (c.componentName) {
599
597
  componentName = c.componentName;
600
598
  }
601
599
  if (componentName === 'Transform') {
602
- throw new Error('Transform can\'t be removed');
600
+ throw new Error("Transform can't be removed");
603
601
  }
604
602
  return this._removeComponent(componentName);
605
603
  };
@@ -623,7 +621,7 @@ var GameObject = (function () {
623
621
  if (typeof c === 'string') {
624
622
  componentName = c;
625
623
  }
626
- else if (c instanceof Component) {
624
+ else if (c instanceof Component$1) {
627
625
  componentName = c.name;
628
626
  }
629
627
  else if (c.componentName) {
@@ -653,7 +651,8 @@ var GameObject = (function () {
653
651
  this.components.length = 0;
654
652
  };
655
653
  return GameObject;
656
- }());
654
+ }());
655
+ var GameObject$1 = GameObject;
657
656
 
658
657
  var ComponentObserver = (function () {
659
658
  function ComponentObserver() {
@@ -664,11 +663,7 @@ var ComponentObserver = (function () {
664
663
  if (type === exports.OBSERVER_TYPE.REMOVE) {
665
664
  this.events = this.events.filter(function (changed) { return changed.component !== component; });
666
665
  }
667
- var index = this.events.findIndex(function (changed) {
668
- return changed.component === component &&
669
- lodashEs.isEqual(changed.prop, prop) &&
670
- changed.type === type;
671
- });
666
+ var index = this.events.findIndex(function (changed) { return changed.component === component && lodashEs.isEqual(changed.prop, prop) && changed.type === type; });
672
667
  if (index > -1) {
673
668
  this.events.splice(index, 1);
674
669
  }
@@ -696,12 +691,13 @@ var ComponentObserver = (function () {
696
691
  return events;
697
692
  };
698
693
  return ComponentObserver;
699
- }());
694
+ }());
695
+ var ComponentObserver$1 = ComponentObserver;
700
696
 
701
697
  var System = (function () {
702
698
  function System(params) {
703
699
  this.started = false;
704
- this.componentObserver = new ComponentObserver();
700
+ this.componentObserver = new ComponentObserver$1();
705
701
  this.__systemDefaultParams = params;
706
702
  this.name = this.constructor.systemName;
707
703
  }
@@ -712,7 +708,8 @@ var System = (function () {
712
708
  (_a = this.onDestroy) === null || _a === void 0 ? void 0 : _a.call(this);
713
709
  };
714
710
  return System;
715
- }());
711
+ }());
712
+ var System$1 = System;
716
713
 
717
714
  function createNowTime(syncLocker = true) {
718
715
  let nowtime = null;
@@ -731,9 +728,9 @@ function createNowTime(syncLocker = true) {
731
728
  */
732
729
  function formatDelay(delay) {
733
730
  if (typeof delay === 'number') {
734
- delay = {delay};
731
+ delay = { delay };
735
732
  } else if ('entropy' in delay) {
736
- delay = {delay: delay.entropy, isEntropy: true};
733
+ delay = { delay: delay.entropy, isEntropy: true };
737
734
  }
738
735
  return delay;
739
736
  }
@@ -814,7 +811,7 @@ class Timeline {
814
811
  return this[_timeMark][this[_timeMark].length - 1];
815
812
  }
816
813
 
817
- markTime({time = this.currentTime, entropy = this.entropy, playbackRate = this.playbackRate} = {}) {
814
+ markTime({ time = this.currentTime, entropy = this.entropy, playbackRate = this.playbackRate } = {}) {
818
815
  const timeMark = {
819
816
  globalTime: this.globalTime,
820
817
  localTime: time,
@@ -826,7 +823,7 @@ class Timeline {
826
823
  }
827
824
 
828
825
  get currentTime() {
829
- const {localTime, globalTime} = this.lastTimeMark;
826
+ const { localTime, globalTime } = this.lastTimeMark;
830
827
  return localTime + (this.globalTime - globalTime) * this.playbackRate;
831
828
  }
832
829
 
@@ -835,11 +832,11 @@ class Timeline {
835
832
  to = time,
836
833
  timers = this[_timers];
837
834
 
838
- this.markTime({time});
835
+ this.markTime({ time });
839
836
  Array.from(Object.entries(timers)).forEach(([id, timer]) => {
840
837
  if (!timers.has(id)) return; // Need check because it maybe clearTimeout by former handler().
841
- const {isEntropy, delay, heading} = timer.time,
842
- {handler, startTime} = timer;
838
+ const { isEntropy, delay, heading } = timer.time,
839
+ { handler, startTime } = timer;
843
840
 
844
841
  if (!isEntropy) {
845
842
  const endTime = startTime + delay;
@@ -865,7 +862,7 @@ class Timeline {
865
862
  // while the entropy remain to go forwards.
866
863
  // Both of the initial values is set to -originTime
867
864
  get entropy() {
868
- const {entropy, globalEntropy} = this.lastTimeMark;
865
+ const { entropy, globalEntropy } = this.lastTimeMark;
869
866
  return entropy + Math.abs((this.globalEntropy - globalEntropy) * this.playbackRate);
870
867
  }
871
868
 
@@ -890,7 +887,7 @@ class Timeline {
890
887
  const idx = this.seekTimeMark(entropy);
891
888
  this[_timeMark].length = idx + 1;
892
889
  }
893
- this.markTime({entropy});
890
+ this.markTime({ entropy });
894
891
  this.updateTimers();
895
892
  }
896
893
 
@@ -902,7 +899,7 @@ class Timeline {
902
899
  const idx = this.seekTimeMark(seekEntropy),
903
900
  timeMark = this[_timeMark][idx];
904
901
 
905
- const {entropy, playbackRate, globalTime} = timeMark;
902
+ const { entropy, playbackRate, globalTime } = timeMark;
906
903
 
907
904
  return globalTime + (seekEntropy - entropy) / Math.abs(playbackRate);
908
905
  }
@@ -911,7 +908,7 @@ class Timeline {
911
908
  const idx = this.seekTimeMark(seekEntropy),
912
909
  timeMark = this[_timeMark][idx];
913
910
 
914
- const {localTime, entropy, playbackRate} = timeMark;
911
+ const { localTime, entropy, playbackRate } = timeMark;
915
912
 
916
913
  if (playbackRate > 0) {
917
914
  return localTime + (seekEntropy - entropy);
@@ -955,7 +952,7 @@ class Timeline {
955
952
 
956
953
  set playbackRate(rate) {
957
954
  if (rate !== this.playbackRate) {
958
- this.markTime({playbackRate: rate});
955
+ this.markTime({ playbackRate: rate });
959
956
  this[_playbackRate] = rate;
960
957
  this.updateTimers();
961
958
  }
@@ -1008,11 +1005,11 @@ class Timeline {
1008
1005
  setTimeout(func, {entropy: 100})
1009
1006
  setTimeout(func, 100})
1010
1007
  */
1011
- setTimeout(handler, time = {delay: 0}) {
1008
+ setTimeout(handler, time = { delay: 0 }) {
1012
1009
  return this[_setTimer](handler, time);
1013
1010
  }
1014
1011
 
1015
- setInterval(handler, time = {delay: 0}) {
1012
+ setInterval(handler, time = { delay: 0 }) {
1016
1013
  const that = this;
1017
1014
  const id = this[_setTimer](function step() {
1018
1015
  // reset timer before handler cause we may clearTimeout in handler()
@@ -1062,7 +1059,7 @@ class Timeline {
1062
1059
  // eslint-disable-line no-restricted-globals
1063
1060
  delay = Math.ceil(delay);
1064
1061
  if (globalTimeout !== setTimeout) {
1065
- delay = {delay, heading};
1062
+ delay = { delay, heading };
1066
1063
  }
1067
1064
  timerID = globalTimeout(() => {
1068
1065
  this[_timers].delete(id);
@@ -1082,9 +1079,11 @@ class Timeline {
1082
1079
  }
1083
1080
  }
1084
1081
 
1082
+ var Timeline$1 = Timeline;
1083
+
1085
1084
  var defaultOptions = {
1086
1085
  autoStart: true,
1087
- frameRate: 60
1086
+ frameRate: 60,
1088
1087
  };
1089
1088
  var Ticker = (function () {
1090
1089
  function Ticker(options) {
@@ -1094,7 +1093,7 @@ var Ticker = (function () {
1094
1093
  this._frameDuration = 1000 / options.frameRate;
1095
1094
  this.autoStart = options.autoStart;
1096
1095
  this.frameRate = options.frameRate;
1097
- this.timeline = new Timeline({ originTime: 0, playbackRate: 1.0 });
1096
+ this.timeline = new Timeline$1({ originTime: 0, playbackRate: 1.0 });
1098
1097
  this._lastFrameTime = this.timeline.currentTime;
1099
1098
  this._tickers = new Set();
1100
1099
  this._requestId = null;
@@ -1121,7 +1120,7 @@ var Ticker = (function () {
1121
1120
  time: currentTime,
1122
1121
  currentTime: currentTime,
1123
1122
  frameCount: ++this._frameCount,
1124
- fps: Math.round(1000 / deltaTime)
1123
+ fps: Math.round(1000 / deltaTime),
1125
1124
  };
1126
1125
  try {
1127
1126
  for (var _b = __values(this._tickers), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -1158,7 +1157,8 @@ var Ticker = (function () {
1158
1157
  this.timeline.playbackRate = 0;
1159
1158
  };
1160
1159
  return Ticker;
1161
- }());
1160
+ }());
1161
+ var Ticker$1 = Ticker;
1162
1162
 
1163
1163
  var Scene = (function (_super) {
1164
1164
  __extends(Scene, _super);
@@ -1190,7 +1190,8 @@ var Scene = (function (_super) {
1190
1190
  this.canvas = null;
1191
1191
  };
1192
1192
  return Scene;
1193
- }(GameObject));
1193
+ }(GameObject$1));
1194
+ var Scene$1 = Scene;
1194
1195
 
1195
1196
  exports.LOAD_SCENE_MODE = void 0;
1196
1197
  (function (LOAD_SCENE_MODE) {
@@ -1198,7 +1199,7 @@ exports.LOAD_SCENE_MODE = void 0;
1198
1199
  LOAD_SCENE_MODE["MULTI_CANVAS"] = "MULTI_CANVAS";
1199
1200
  })(exports.LOAD_SCENE_MODE || (exports.LOAD_SCENE_MODE = {}));
1200
1201
  var triggerStart = function (obj) {
1201
- if (!(obj instanceof System) && !(obj instanceof Component))
1202
+ if (!(obj instanceof System$1) && !(obj instanceof Component$1))
1202
1203
  return;
1203
1204
  if (obj.started)
1204
1205
  return;
@@ -1207,7 +1208,7 @@ var triggerStart = function (obj) {
1207
1208
  obj.start && obj.start();
1208
1209
  }
1209
1210
  catch (e) {
1210
- if (obj instanceof Component) {
1211
+ if (obj instanceof Component$1) {
1211
1212
  console.error(obj.constructor.componentName + " start error", e);
1212
1213
  }
1213
1214
  else {
@@ -1380,7 +1381,7 @@ var Game = (function (_super) {
1380
1381
  _this.started = false;
1381
1382
  _this.multiScenes = [];
1382
1383
  _this.systems = [];
1383
- _this.ticker = new Ticker({ autoStart: false, frameRate: frameRate });
1384
+ _this.ticker = new Ticker$1({ autoStart: false, frameRate: frameRate });
1384
1385
  _this.initTicker();
1385
1386
  if (systems && systems.length) {
1386
1387
  try {
@@ -1398,7 +1399,7 @@ var Game = (function (_super) {
1398
1399
  }
1399
1400
  }
1400
1401
  if (needScene) {
1401
- _this.loadScene(new Scene('scene'));
1402
+ _this.loadScene(new Scene$1('scene'));
1402
1403
  }
1403
1404
  if (autoStart) {
1404
1405
  _this.start();
@@ -1427,7 +1428,7 @@ var Game = (function (_super) {
1427
1428
  if (S instanceof Function) {
1428
1429
  system = new S(obj);
1429
1430
  }
1430
- else if (S instanceof System) {
1431
+ else if (S instanceof System$1) {
1431
1432
  system = S;
1432
1433
  }
1433
1434
  else {
@@ -1464,7 +1465,7 @@ var Game = (function (_super) {
1464
1465
  else if (system instanceof Function) {
1465
1466
  index = this.systems.findIndex(function (s) { return s.constructor === system; });
1466
1467
  }
1467
- else if (system instanceof System) {
1468
+ else if (system instanceof System$1) {
1468
1469
  index = this.systems.findIndex(function (s) { return s === system; });
1469
1470
  }
1470
1471
  if (index > -1) {
@@ -1634,7 +1635,8 @@ var Game = (function (_super) {
1634
1635
  this.emit('sceneChanged', { scene: scene, mode: mode, params: params });
1635
1636
  };
1636
1637
  return Game;
1637
- }(EventEmitter__default));
1638
+ }(EventEmitter__default));
1639
+ var Game$1 = Game;
1638
1640
 
1639
1641
  function componentObserver(observerInfo) {
1640
1642
  if (observerInfo === void 0) { observerInfo = {}; }
@@ -1684,8 +1686,7 @@ var Progress = (function (_super) {
1684
1686
  };
1685
1687
  Progress.prototype.onProgress = function (param) {
1686
1688
  this.resourceLoadedCount++;
1687
- this.progress =
1688
- Math.floor((this.resourceLoadedCount / this.resourceTotal) * 100) / 100;
1689
+ this.progress = Math.floor((this.resourceLoadedCount / this.resourceTotal) * 100) / 100;
1689
1690
  if (param.success) {
1690
1691
  this.resource.emit(exports.LOAD_EVENT.LOADED, this, param);
1691
1692
  }
@@ -1698,7 +1699,8 @@ var Progress = (function (_super) {
1698
1699
  }
1699
1700
  };
1700
1701
  return Progress;
1701
- }(EventEmitter__default));
1702
+ }(EventEmitter__default));
1703
+ var Progress$1 = Progress;
1702
1704
 
1703
1705
  exports.LOAD_EVENT = void 0;
1704
1706
  (function (LOAD_EVENT) {
@@ -1734,7 +1736,7 @@ var STRATEGY = {
1734
1736
  tex: resourceLoader.XhrLoadStrategy,
1735
1737
  ske: resourceLoader.XhrLoadStrategy,
1736
1738
  audio: resourceLoader.XhrLoadStrategy,
1737
- video: resourceLoader.VideoLoadStrategy
1739
+ video: resourceLoader.VideoLoadStrategy,
1738
1740
  };
1739
1741
  var Resource = (function (_super) {
1740
1742
  __extends(Resource, _super);
@@ -1785,16 +1787,14 @@ var Resource = (function (_super) {
1785
1787
  }
1786
1788
  };
1787
1789
  Resource.prototype.preload = function () {
1788
- var names = Object.values(this.resourcesMap)
1789
- .filter(function (_a) {
1790
- var preload = _a.preload;
1791
- return preload;
1792
- })
1793
- .map(function (_a) {
1794
- var name = _a.name;
1795
- return name;
1796
- });
1797
- this.progress = new Progress({
1790
+ var names = [];
1791
+ for (var key in this.resourcesMap) {
1792
+ var resource_1 = this.resourcesMap[key];
1793
+ if (resource_1.preload) {
1794
+ names.push(resource_1.name);
1795
+ }
1796
+ }
1797
+ this.progress = new Progress$1({
1798
1798
  resource: this,
1799
1799
  resourceTotal: names.length,
1800
1800
  });
@@ -2029,13 +2029,13 @@ var decorators = {
2029
2029
  componentObserver: componentObserver,
2030
2030
  };
2031
2031
 
2032
- exports.Component = Component;
2033
- exports.Game = Game;
2034
- exports.GameObject = GameObject;
2032
+ exports.Component = Component$1;
2033
+ exports.Game = Game$1;
2034
+ exports.GameObject = GameObject$1;
2035
2035
  exports.IDEProp = IDEProp;
2036
- exports.Scene = Scene;
2037
- exports.System = System;
2038
- exports.Transform = Transform;
2036
+ exports.Scene = Scene$1;
2037
+ exports.System = System$1;
2038
+ exports.Transform = Transform$1;
2039
2039
  exports.componentObserver = componentObserver;
2040
2040
  exports.decorators = decorators;
2041
2041
  exports.resource = resource;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("lodash-es"),r=require("resource-loader");function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var o=n(e),a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("eventemitter3"),t=require("lodash-es"),r=require("resource-loader");function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var o=n(e),a=function(e,t){return a=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])},a(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 s(e,t){function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function i(e,t,r,n){var o,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(s=(a<3?o(s):a>3?o(t,r,s):o(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}function c(e,t,r,n){return new(r||(r=Promise))((function(o,a){function s(e){try{c(n.next(e))}catch(e){a(e)}}function i(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(s,i)}c((n=n.apply(e,t||[])).next())}))}function u(e,t){var r,n,o,a,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function 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 p(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return s}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(p(arguments[t]));return e}var m,f=function(e){function t(t){var r=e.call(this)||this;return r.started=!1,r.name=r.constructor.componentName,r.__componentDefaultParams=t,r}return s(t,e),t}(o);exports.OBSERVER_TYPE=void 0,(m=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",m.REMOVE="REMOVE",m.CHANGE="CHANGE";var y={},d={},v={},g={};function b(e,t){y[e.gameObject.id]||(y[e.gameObject.id]={});var r=y[e.gameObject.id],n=e.name+"_"+t.join(",");if(r[n])return r[n];for(var o=t.length-1,a=e,s=0;s<o;s++)a=a[t[s]];return r[n]={property:a,key:t[o]},r[n]}function E(e){var t=e.systemName,r=e.componentName,n=e.component,o=e.prop,a=e.type;d[t].componentObserver.add({component:n,prop:o,type:a,componentName:r})}function T(e){var r,n,o=e.obj,a=e.key,s=e.prop,i=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]}),s.deep&&t.isObject(o[a]))try{for(var u=l(Object.keys(o[a])),p=u.next();!p.done;p=u.next()){var h=p.value;T({obj:o[a],key:h,prop:s,component:i,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 v){var s=(v[a]||{})[o];s&&s.findIndex((function(e){return t.isEqual(e,r)}))>-1&&E({systemName:a,componentName:o,component:n,prop:r,type:exports.OBSERVER_TYPE.CHANGE})}}({prop:s,component:i,componentName:c}))},get:function(){return o["_"+a]}})}else console.error("prop "+a+" not in component: "+c+", Can not observer")}function O(e,t){for(var r in void 0===t&&(t=e.name),v){(v[r]||{})[t]&&d[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t})}!function(e){e.gameObject&&delete y[e.gameObject.id]}(e)}function x(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}var _=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 s(t,e),t.prototype.init=function(e){var t,r;void 0===e&&(e={});try{for(var n=l(["position","size","origin","anchor","scale","skew"]),o=n.next();!o.done;o=n.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",i([x],t.prototype,"position",void 0),i([x],t.prototype,"size",void 0),i([x],t.prototype,"origin",void 0),i([x],t.prototype,"anchor",void 0),i([x],t.prototype,"scale",void 0),i([x],t.prototype,"skew",void 0),i([x],t.prototype,"rotation",void 0),t}(f),R=0;var S=function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++R,this.addComponent(_,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(_)},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=l(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):n&&n.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error("gameObject '"+this.name+"' has been destroy");t.transform.parent=this.transform,t.scene=this.scene}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var r=function(e){return e instanceof f?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[r]){var n;if(e instanceof Function)n=new e(t);else{if(!(e instanceof f))throw new Error("addComponent recieve Component and Component Constructor");n=e}if(n.gameObject)throw new Error("component has been added on gameObject "+n.gameObject.name);return n.gameObject=this,n.init&&n.init(n.__componentDefaultParams),function(e,t){for(var r in void 0===t&&(t=e.name),v)(v[r]||{})[t]&&d[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t})}(n,n.name),function(e,t){var r,n;if(void 0===t&&(t=e.name),t&&g[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=l(g[t]),s=a.next();!s.done;s=a.next()){var i=s.value,c=b(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&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}}(n,n.name),this.components.push(n),this._componentCache[r]=n,n.awake&&n.awake(),n}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof f?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var r=this.components.splice(t,1)[0];return delete this._componentCache[e],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),O(r,e),r.gameObject=void 0,r}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof f?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}(),w=function(){function e(){this.events=[]}return e.prototype.add=function(e){var r=e.component,n=e.prop,o=e.type,a=e.componentName;o===exports.OBSERVER_TYPE.REMOVE&&(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,n)&&e.type===o}));s>-1&&this.events.splice(s,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}(),k=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}();const j=function(e=!0){let t=null;return t=Date.now?Date.now:()=>(new Date).getTime(),t}(),N={originTime:0,playbackRate:1},C=Symbol("timeMark"),I=Symbol("playbackRate"),D=Symbol("timers"),P=Symbol("originTime"),M=Symbol("setTimer"),L=Symbol("parent");class A{constructor(e,t){e instanceof A&&(t=e,e={}),e=Object.assign({},N,e),t&&(this[L]=t);const r=e.nowtime||j;if(t)Object.defineProperty(this,"globalTime",{get:()=>t.currentTime});else{const e=r();Object.defineProperty(this,"globalTime",{get:()=>r()-e})}this[C]=[{globalTime:this.globalTime,localTime:-e.originTime,entropy:-e.originTime,playbackRate:e.playbackRate,globalEntropy:0}],this[L]&&(this[C][0].globalEntropy=this[L].entropy),this[P]=e.originTime,this[I]=e.playbackRate,this[D]=new Map}get parent(){return this[L]}get lastTimeMark(){return this[C][this[C].length-1]}markTime({time:e=this.currentTime,entropy:t=this.entropy,playbackRate:r=this.playbackRate}={}){const n={globalTime:this.globalTime,localTime:e,entropy:t,playbackRate:r,globalEntropy:this.globalEntropy};this[C].push(n)}get currentTime(){const{localTime:e,globalTime:t}=this.lastTimeMark;return e+(this.globalTime-t)*this.playbackRate}set currentTime(e){const t=this.currentTime,r=e,n=this[D];this.markTime({time:e}),Array.from(Object.entries(n)).forEach((([e,o])=>{if(!n.has(e))return;const{isEntropy:a,delay:s,heading:i}=o.time,{handler:c,startTime:u}=o;if(a)0===s&&(c(),this.clearTimeout(e));else{const n=u+s;(0===s||!1!==i&&(r-t)*s<=0||t<=n&&n<=r||t>=n&&n>=r)&&(c(),this.clearTimeout(e))}})),this.updateTimers()}get entropy(){const{entropy:e,globalEntropy:t}=this.lastTimeMark;return e+Math.abs((this.globalEntropy-t)*this.playbackRate)}get globalEntropy(){return this[L]?this[L].entropy:this.globalTime}set entropy(e){if(this.entropy>e){const t=this.seekTimeMark(e);this[C].length=t+1}this.markTime({entropy:e}),this.updateTimers()}fork(e){return new A(e,this)}seekGlobalTime(e){const t=this.seekTimeMark(e),r=this[C][t],{entropy:n,playbackRate:o,globalTime:a}=r;return a+(e-n)/Math.abs(o)}seekLocalTime(e){const t=this.seekTimeMark(e),r=this[C][t],{localTime:n,entropy:o,playbackRate:a}=r;return a>0?n+(e-o):n-(e-o)}seekTimeMark(e){const t=this[C];let r=0,n=t.length-1;if(e<=t[r].entropy)return r;if(e>=t[n].entropy)return n;let o=Math.floor((r+n)/2);for(;o>r&&o<n;){if(e===t[o].entropy)return o;e<t[o].entropy?n=o:e>t[o].entropy&&(r=o),o=Math.floor((r+n)/2)}return r}get playbackRate(){return this[I]}set playbackRate(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this[I]=e,this.updateTimers())}get paused(){if(0===this.playbackRate)return!0;let e=this.parent;for(;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1}updateTimers(){Array.from(this[D].entries()).forEach((([e,t])=>{this[M](t.handler,t.time,e)}))}clearTimeout(e){const t=this[D].get(e);t&&null!=t.timerID&&(this[L]?this[L].clearTimeout(t.timerID):clearTimeout(t.timerID)),this[D].delete(e)}clearInterval(e){return this.clearTimeout(e)}clear(){const e=this[D];Array.from(Object.keys(e)).forEach((e=>{this.clearTimeout(e)}))}setTimeout(e,t={delay:0}){return this[M](e,t)}setInterval(e,t={delay:0}){const r=this,n=this[M]((function o(){r[M](o,t,n),e()}),t);return n}[M](e,t,r=Symbol("timerID")){t=function(e){return"number"==typeof e?e={delay:e}:"entropy"in e&&(e={delay:e.entropy,isEntropy:!0}),e}(t);const n=this[D].get(r);let o,a,s,i=null;n?(this.clearTimeout(r),o=t.isEntropy?(t.delay-(this.entropy-n.startEntropy))/Math.abs(this.playbackRate):(t.delay-(this.currentTime-n.startTime))/this.playbackRate,a=n.startTime,s=n.startEntropy):(o=t.delay/(t.isEntropy?Math.abs(this.playbackRate):this.playbackRate),a=this.currentTime,s=this.entropy);const c=this[L],u=c?c.setTimeout.bind(c):setTimeout,l=t.heading;return!c&&!1===l&&o<0&&(o=1/0),(isFinite(o)||c)&&(o=Math.ceil(o),u!==setTimeout&&(o={delay:o,heading:l}),i=u((()=>{this[D].delete(r),e()}),o)),this[D].set(r,{timerID:i,handler:e,time:t,startTime:a,startEntropy:s}),r}}var V,X={autoStart:!0,frameRate:60},G=function(){function e(e){var t=this;e=Object.assign({},X,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 s={deltaTime:a,time:r,currentTime:r,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}(),F=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.gameObjects=[],n.scene=n,n}return s(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,(V=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",V.MULTI_CANVAS="MULTI_CANVAS";var U=function(e){if((e instanceof k||e instanceof f)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof f?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}}},B=function(e){function r(t){var r,n,o=void 0===t?{}:t,a=o.systems,s=o.frameRate,i=void 0===s?60:s,c=o.autoStart,u=void 0===c||c,p=o.needScene,h=void 0===p||p,m=e.call(this)||this;if(m.playing=!1,m.started=!1,m.multiScenes=[],m.systems=[],m.ticker=new G({autoStart:!1,frameRate:i}),m.initTicker(),a&&a.length)try{for(var f=l(a),y=f.next();!y.done;y=f.next()){var d=y.value;m.addSystem(d)}}catch(e){r={error:e}}finally{try{y&&!y.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}return h&&m.loadScene(new F("scene")),u&&m.start(),m}return s(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,n,o=(null===(n=null==e?void 0:e.scene)||void 0===n?void 0:n.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),s=[];try{for(var i=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(o,s)}(this)},enumerable:!1,configurable:!0}),r.prototype.addSystem=function(e,r){var n;if(e instanceof Function)n=new e(r);else{if(!(e instanceof k))return void console.warn("can only add System");n=e}if(!this.systems.find((function(e){return e.constructor===n.constructor}))){n.game=this,n.init&&n.init(n.__systemDefaultParams),function(e,t){v[t.systemName]=t.observerInfo,d[t.systemName]=e}(n,n.constructor),function(e){var r,n,o,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){g[p]=g[p]||[];var m=g[p],f=function(e){-1===m.findIndex((function(r){return t.isEqual(r,e)}))&&g[p].push(e)};try{for(var y=(o=void 0,l(u.observerInfo[p])),d=y.next();!d.done;d=y.next())f(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=i.return)&&n.call(i)}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),n}console.warn(n.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 k&&(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,s,i,c,u;void 0===t&&(t=[]);try{for(var p=l(t),h=p.next();!h.done;h=p.next()){var m=h.value;try{for(var f=(o=void 0,l(m.components)),y=f.next();!y.done;y=f.next()){var d=y.value;try{U(d),d.update&&d.update(e)}catch(e){console.error("gameObject: "+m.name+" "+d.name+" update error",e)}}}catch(e){o={error:e}}finally{try{y&&!y.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var v=l(t),g=v.next();!g.done;g=v.next()){m=g.value;try{for(var b=(c=void 0,l(m.components)),E=b.next();!E.done;E=b.next()){d=E.value;try{d.lateUpdate&&d.lateUpdate(e)}catch(e){console.error("gameObject: "+m.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{U(c),c.update&&c.update(t)}catch(t){console.error(c.constructor.systemName+" update error",t)}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}try{for(var 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){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=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(n=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){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{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=l(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=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(n=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){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{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=l(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=l(h(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}(o);function q(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,z,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 s(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}(o);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,(z=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",z.SPRITE="SPRITE",z.SPRITE_ANIMATION="SPRITE_ANIMATION",z.DRAGONBONE="DRAGONBONE",z.SPINE="SPINE",z.AUDIO="AUDIO",z.VIDEO="VIDEO",r.XhrLoadStrategy.setExtensionXhrType("json",r.XhrResponseType.Json),r.XhrLoadStrategy.setExtensionXhrType("tex",r.XhrResponseType.Json),r.XhrLoadStrategy.setExtensionXhrType("ske",r.XhrResponseType.Json),r.XhrLoadStrategy.setExtensionXhrType("mp3",r.XhrResponseType.Buffer),r.XhrLoadStrategy.setExtensionXhrType("wav",r.XhrResponseType.Buffer),r.XhrLoadStrategy.setExtensionXhrType("aac",r.XhrResponseType.Buffer),r.XhrLoadStrategy.setExtensionXhrType("ogg",r.XhrResponseType.Buffer);var J={png:r.ImageLoadStrategy,jpg:r.ImageLoadStrategy,jpeg:r.ImageLoadStrategy,webp:r.ImageLoadStrategy,json:r.XhrLoadStrategy,tex:r.XhrLoadStrategy,ske:r.XhrLoadStrategy,audio:r.XhrLoadStrategy,video:r.VideoLoadStrategy},K=new(function(e){function t(t){var r=e.call(this)||this;return r.timeout=6e3,r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return s(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=l(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.preload=function(){var e=Object.values(this.resourcesMap).filter((function(e){return e.preload})).map((function(e){return e.name}));this.progress=new H({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})},t.prototype.getResource=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return this.loadResource({names:[e]}),[2,this.promiseMap[e]||Promise.resolve({})]}))}))},t.prototype.instance=function(e){return c(this,void 0,void 0,(function(){var t,r;return u(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 c(this,void 0,void 0,(function(){return u(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),c(this,void 0,void 0,(function(){var r,n;return u(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.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,n=void 0===r?[]:r,o=e.preload,a=void 0!==o&&o,s=n.filter((function(e){return!t.promiseMap[e]&&t.resourcesMap[e]}));if(s.length){var i={},c=this.getLoader(a);s.forEach((function(e){t.promiseMap[e]=new Promise((function(t){return i[e]=t}));var r=t.resourcesMap[e];for(var n in r.src){var o=r.src[n].type;"data"===o?(r.data[n]=r.src[n].data,t.doComplete(e,i[e],a)):c.add({url:r.src[n].url,name:r.name+"_"+n,strategy:J[o],metadata:{key:n,name:r.name,resolves:i}})}})),c.load()}},t.prototype.doComplete=function(e,t,r){return void 0===r&&(r=!1),c(this,void 0,void 0,(function(){var n,o,a,s;return u(this,(function(i){switch(i.label){case 0:if(n=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0},!this.checkAllLoaded(e))return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),a=n,[4,this.instance(e)];case 2:return a.instance=i.sent(),n.complete=!0,r&&this.progress.onProgress(o),t(n),[3,4];case 3:return s=i.sent(),n.complete=!1,r&&(o.errMsg=s.message,o.success=!1,this.progress.onProgress(o)),t({}),[3,4];case 4:return[2]}}))}))},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 n=this.loaders.find((function(e){return!e.loading}));return n||(n=new r.Loader,this.loaders.push(n)),e&&n.onStart.once((function(){t.progress.onStart()})),n.onLoad.add((function(r,n){t.onLoad({preload:e,resource:n})})),n.onError.add((function(r,n,o){t.onError({errMsg:r,resource:o,preload:e})})),n.onComplete.once((function(){n.onLoad.detachAll(),n.onError.detachAll(),n.reset()})),n},t.prototype.onLoad=function(e){var t=e.preload,r=void 0!==t&&t,n=e.resource;return c(this,void 0,void 0,(function(){var e,t,o,a,s;return u(this,(function(i){return e=n.metadata,t=e.key,o=e.name,a=e.resolves,s=n.data,this.resourcesMap[o].data[t]=s,this.doComplete(o,a[o],r),[2]}))}))},t.prototype.onError=function(e){var t=e.errMsg,r=e.preload,n=void 0!==r&&r,o=e.resource;return c(this,void 0,void 0,(function(){var e,r,a,s;return u(this,(function(i){return e=o.metadata,r=e.name,a=e.resolves,this._destroy(r,!0),a[r]({}),n&&(s={name:r,resource:this.resourcesMap[r],success:!1,errMsg:t},this.progress.onProgress(s)),[2]}))}))},t}(o)),Q={IDEProp:x,componentObserver:q};exports.Component=f,exports.Game=B,exports.GameObject=S,exports.IDEProp=x,exports.Scene=F,exports.System=k,exports.Transform=_,exports.componentObserver=q,exports.decorators=Q,exports.resource=K;
15
+ ***************************************************************************** */function s(e,t){function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function i(e,t,r,n){var o,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var i=e.length-1;i>=0;i--)(o=e[i])&&(s=(a<3?o(s):a>3?o(t,r,s):o(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}function c(e,t,r,n){return new(r||(r=Promise))((function(o,a){function s(e){try{c(n.next(e))}catch(e){a(e)}}function i(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(s,i)}c((n=n.apply(e,t||[])).next())}))}function u(e,t){var r,n,o,a,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function 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 p(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return s}function h(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(p(arguments[t]));return e}var m,f=function(e){function t(t){var r=e.call(this)||this;return r.started=!1,r.name=r.constructor.componentName,r.__componentDefaultParams=t,r}return s(t,e),t}(o),y=f;exports.OBSERVER_TYPE=void 0,(m=exports.OBSERVER_TYPE||(exports.OBSERVER_TYPE={})).ADD="ADD",m.REMOVE="REMOVE",m.CHANGE="CHANGE";var d={},v={},g={},b={};function E(e,t){d[e.gameObject.id]||(d[e.gameObject.id]={});var r=d[e.gameObject.id],n=e.name+"_"+t.join(",");if(r[n])return r[n];for(var o=t.length-1,a=e,s=0;s<o;s++)a=a[t[s]];return r[n]={property:a,key:t[o]},r[n]}function T(e){var t=e.systemName,r=e.componentName,n=e.component,o=e.prop,a=e.type;v[t].componentObserver.add({component:n,prop:o,type:a,componentName:r})}function O(e){var r,n,o=e.obj,a=e.key,s=e.prop,i=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]}),s.deep&&t.isObject(o[a]))try{for(var u=l(Object.keys(o[a])),p=u.next();!p.done;p=u.next()){var h=p.value;O({obj:o[a],key:h,prop:s,component:i,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 g){var s=(g[a]||{})[o];s&&s.findIndex((function(e){return t.isEqual(e,r)}))>-1&&T({systemName:a,componentName:o,component:n,prop:r,type:exports.OBSERVER_TYPE.CHANGE})}}({prop:s,component:i,componentName:c}))},get:function(){return o["_"+a]}})}else console.error("prop "+a+" not in component: "+c+", Can not observer")}function x(e,t){for(var r in void 0===t&&(t=e.name),g){(g[r]||{})[t]&&v[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.REMOVE,componentName:t})}!function(e){e.gameObject&&delete d[e.gameObject.id]}(e)}function _(e,t){e.constructor.IDEProps||(e.constructor.IDEProps=[]),e.constructor.IDEProps.push(t)}var R=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 s(t,e),t.prototype.init=function(e){var t,r;void 0===e&&(e={});try{for(var n=l(["position","size","origin","anchor","scale","skew"]),o=n.next();!o.done;o=n.next()){var a=o.value;Object.assign(this[a],e[a])}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.rotation=e.rotation||this.rotation},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(e){e?e.addChild(this):this.parent&&this.parent.removeChild(this)},enumerable:!1,configurable:!0}),t.prototype.addChild=function(e){if(e.parent===this){var t=this.children.findIndex((function(t){return t===e}));this.children.splice(t,1)}else e.parent&&e.parent.removeChild(e);e._parent=this,this.children.push(e)},t.prototype.removeChild=function(e){var t=this.children.findIndex((function(t){return t===e}));t>-1&&(this.children.splice(t,1),e._parent=null)},t.prototype.clearChildren=function(){this.children.length=0},t.componentName="Transform",i([_],t.prototype,"position",void 0),i([_],t.prototype,"size",void 0),i([_],t.prototype,"origin",void 0),i([_],t.prototype,"anchor",void 0),i([_],t.prototype,"scale",void 0),i([_],t.prototype,"skew",void 0),i([_],t.prototype,"rotation",void 0),t}(y),S=0;var w=function(){function e(e,t){this._componentCache={},this.components=[],this._name=e,this.id=++S,this.addComponent(R,t)}return Object.defineProperty(e.prototype,"transform",{get:function(){return this.getComponent(R)},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=l(this.transform.children),a=o.next();!a.done;a=o.next()){a.value.gameObject.scene=e}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}e?e.addGameObject(this):n&&n.removeGameObject(this)}},enumerable:!1,configurable:!0}),e.prototype.addChild=function(t){if(t&&t.transform&&t!==this){if(!(t instanceof e))throw new Error("addChild only receive GameObject");if(!this.transform)throw new Error("gameObject '"+this.name+"' has been destroy");t.transform.parent=this.transform,t.scene=this.scene}},e.prototype.removeChild=function(t){return t instanceof e&&t.parent&&t.parent===this?(t.transform.parent=null,t.scene=null,t):t},e.prototype.addComponent=function(e,t){var r=function(e){return e instanceof f?e.name:e instanceof Function?e.componentName:void 0}(e);if(!this._componentCache[r]){var n;if(e instanceof Function)n=new e(t);else{if(!(e instanceof y))throw new Error("addComponent recieve Component and Component Constructor");n=e}if(n.gameObject)throw new Error("component has been added on gameObject "+n.gameObject.name);return n.gameObject=this,n.init&&n.init(n.__componentDefaultParams),function(e,t){for(var r in void 0===t&&(t=e.name),g)(g[r]||{})[t]&&v[r].componentObserver.add({component:e,type:exports.OBSERVER_TYPE.ADD,componentName:t})}(n,n.name),function(e,t){var r,n;if(void 0===t&&(t=e.name),t&&b[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=l(b[t]),s=a.next();!s.done;s=a.next()){var i=s.value,c=E(e,i.prop);O({obj:c.property,key:c.key,prop:i,component:e,componentName:t})}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}}(n,n.name),this.components.push(n),this._componentCache[r]=n,n.awake&&n.awake(),n}},e.prototype.removeComponent=function(e){var t;if("string"==typeof e?t=e:e instanceof y?t=e.name:e.componentName&&(t=e.componentName),"Transform"===t)throw new Error("Transform can't be removed");return this._removeComponent(t)},e.prototype._removeComponent=function(e){var t=this.components.findIndex((function(t){return t.name===e}));if(-1!==t){var r=this.components.splice(t,1)[0];return delete this._componentCache[e],delete r.__componentDefaultParams,r.onDestroy&&r.onDestroy(),x(r,e),r.gameObject=void 0,r}},e.prototype.getComponent=function(e){var t;return"string"==typeof e?t=e:e instanceof y?t=e.name:e.componentName&&(t=e.componentName),void 0!==this._componentCache[t]?this._componentCache[t]:void 0},e.prototype.remove=function(){if(this.parent)return this.parent.removeChild(this)},e.prototype.destroy=function(){for(var e in Array.from(this.transform.children).forEach((function(e){e.gameObject.destroy()})),this.remove(),this.transform.clearChildren(),this._componentCache)this._removeComponent(e);this.components.length=0},e}(),k=function(){function e(){this.events=[]}return e.prototype.add=function(e){var r=e.component,n=e.prop,o=e.type,a=e.componentName;o===exports.OBSERVER_TYPE.REMOVE&&(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,n)&&e.type===o}));s>-1&&this.events.splice(s,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 k,this.__systemDefaultParams=e,this.name=this.constructor.systemName}return e.prototype.destroy=function(){var e;this.componentObserver=null,this.__systemDefaultParams=null,null===(e=this.onDestroy)||void 0===e||e.call(this)},e}();const N=function(e=!0){let t=null;return t=Date.now?Date.now:()=>(new Date).getTime(),t}(),C={originTime:0,playbackRate:1},I=Symbol("timeMark"),D=Symbol("playbackRate"),M=Symbol("timers"),P=Symbol("originTime"),L=Symbol("setTimer"),A=Symbol("parent");class V{constructor(e,t){e instanceof V&&(t=e,e={}),e=Object.assign({},C,e),t&&(this[A]=t);const r=e.nowtime||N;if(t)Object.defineProperty(this,"globalTime",{get:()=>t.currentTime});else{const e=r();Object.defineProperty(this,"globalTime",{get:()=>r()-e})}this[I]=[{globalTime:this.globalTime,localTime:-e.originTime,entropy:-e.originTime,playbackRate:e.playbackRate,globalEntropy:0}],this[A]&&(this[I][0].globalEntropy=this[A].entropy),this[P]=e.originTime,this[D]=e.playbackRate,this[M]=new Map}get parent(){return this[A]}get lastTimeMark(){return this[I][this[I].length-1]}markTime({time:e=this.currentTime,entropy:t=this.entropy,playbackRate:r=this.playbackRate}={}){const n={globalTime:this.globalTime,localTime:e,entropy:t,playbackRate:r,globalEntropy:this.globalEntropy};this[I].push(n)}get currentTime(){const{localTime:e,globalTime:t}=this.lastTimeMark;return e+(this.globalTime-t)*this.playbackRate}set currentTime(e){const t=this.currentTime,r=e,n=this[M];this.markTime({time:e}),Array.from(Object.entries(n)).forEach((([e,o])=>{if(!n.has(e))return;const{isEntropy:a,delay:s,heading:i}=o.time,{handler:c,startTime:u}=o;if(a)0===s&&(c(),this.clearTimeout(e));else{const n=u+s;(0===s||!1!==i&&(r-t)*s<=0||t<=n&&n<=r||t>=n&&n>=r)&&(c(),this.clearTimeout(e))}})),this.updateTimers()}get entropy(){const{entropy:e,globalEntropy:t}=this.lastTimeMark;return e+Math.abs((this.globalEntropy-t)*this.playbackRate)}get globalEntropy(){return this[A]?this[A].entropy:this.globalTime}set entropy(e){if(this.entropy>e){const t=this.seekTimeMark(e);this[I].length=t+1}this.markTime({entropy:e}),this.updateTimers()}fork(e){return new V(e,this)}seekGlobalTime(e){const t=this.seekTimeMark(e),r=this[I][t],{entropy:n,playbackRate:o,globalTime:a}=r;return a+(e-n)/Math.abs(o)}seekLocalTime(e){const t=this.seekTimeMark(e),r=this[I][t],{localTime:n,entropy:o,playbackRate:a}=r;return a>0?n+(e-o):n-(e-o)}seekTimeMark(e){const t=this[I];let r=0,n=t.length-1;if(e<=t[r].entropy)return r;if(e>=t[n].entropy)return n;let o=Math.floor((r+n)/2);for(;o>r&&o<n;){if(e===t[o].entropy)return o;e<t[o].entropy?n=o:e>t[o].entropy&&(r=o),o=Math.floor((r+n)/2)}return r}get playbackRate(){return this[D]}set playbackRate(e){e!==this.playbackRate&&(this.markTime({playbackRate:e}),this[D]=e,this.updateTimers())}get paused(){if(0===this.playbackRate)return!0;let e=this.parent;for(;e;){if(0===e.playbackRate)return!0;e=e.parent}return!1}updateTimers(){Array.from(this[M].entries()).forEach((([e,t])=>{this[L](t.handler,t.time,e)}))}clearTimeout(e){const t=this[M].get(e);t&&null!=t.timerID&&(this[A]?this[A].clearTimeout(t.timerID):clearTimeout(t.timerID)),this[M].delete(e)}clearInterval(e){return this.clearTimeout(e)}clear(){const e=this[M];Array.from(Object.keys(e)).forEach((e=>{this.clearTimeout(e)}))}setTimeout(e,t={delay:0}){return this[L](e,t)}setInterval(e,t={delay:0}){const r=this,n=this[L]((function o(){r[L](o,t,n),e()}),t);return n}[L](e,t,r=Symbol("timerID")){t=function(e){return"number"==typeof e?e={delay:e}:"entropy"in e&&(e={delay:e.entropy,isEntropy:!0}),e}(t);const n=this[M].get(r);let o,a,s,i=null;n?(this.clearTimeout(r),o=t.isEntropy?(t.delay-(this.entropy-n.startEntropy))/Math.abs(this.playbackRate):(t.delay-(this.currentTime-n.startTime))/this.playbackRate,a=n.startTime,s=n.startEntropy):(o=t.delay/(t.isEntropy?Math.abs(this.playbackRate):this.playbackRate),a=this.currentTime,s=this.entropy);const c=this[A],u=c?c.setTimeout.bind(c):setTimeout,l=t.heading;return!c&&!1===l&&o<0&&(o=1/0),(isFinite(o)||c)&&(o=Math.ceil(o),u!==setTimeout&&(o={delay:o,heading:l}),i=u((()=>{this[M].delete(r),e()}),o)),this[M].set(r,{timerID:i,handler:e,time:t,startTime:a,startEntropy:s}),r}}var X,G=V,F={autoStart:!0,frameRate:60},U=function(){function e(e){var t=this;e=Object.assign({},F,e),this._frameCount=0,this._frameDuration=1e3/e.frameRate,this.autoStart=e.autoStart,this.frameRate=e.frameRate,this.timeline=new G({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 s={deltaTime:a,time:r,currentTime:r,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}(),B=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.gameObjects=[],n.scene=n,n}return s(t,e),t.prototype.addGameObject=function(e){this.gameObjects.push(e),e.transform&&(e.transform.inScene=!0)},t.prototype.removeGameObject=function(e){var t=this.gameObjects.indexOf(e);-1!==t&&(e.transform&&(e.transform.inScene=!1),this.gameObjects.splice(t,1))},t.prototype.destroy=function(){this.scene=null,e.prototype.destroy.call(this),this.gameObjects=null,this.canvas=null},t}(w);exports.LOAD_SCENE_MODE=void 0,(X=exports.LOAD_SCENE_MODE||(exports.LOAD_SCENE_MODE={})).SINGLE="SINGLE",X.MULTI_CANVAS="MULTI_CANVAS";var q=function(e){if((e instanceof j||e instanceof y)&&!e.started){e.started=!0;try{e.start&&e.start()}catch(t){e instanceof y?console.error(e.constructor.componentName+" start error",t):console.error(e.constructor.systemName+" start error",t)}}},Y=function(e){function r(t){var r,n,o=void 0===t?{}:t,a=o.systems,s=o.frameRate,i=void 0===s?60:s,c=o.autoStart,u=void 0===c||c,p=o.needScene,h=void 0===p||p,m=e.call(this)||this;if(m.playing=!1,m.started=!1,m.multiScenes=[],m.systems=[],m.ticker=new U({autoStart:!1,frameRate:i}),m.initTicker(),a&&a.length)try{for(var f=l(a),y=f.next();!y.done;y=f.next()){var d=y.value;m.addSystem(d)}}catch(e){r={error:e}}finally{try{y&&!y.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}return h&&m.loadScene(new B("scene")),u&&m.start(),m}return s(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,n,o=(null===(n=null==e?void 0:e.scene)||void 0===n?void 0:n.gameObjects)||[],a=null==e?void 0:e.multiScenes.map((function(e){return e.gameObjects})),s=[];try{for(var i=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(o,s)}(this)},enumerable:!1,configurable:!0}),r.prototype.addSystem=function(e,r){var n;if(e instanceof Function)n=new e(r);else{if(!(e instanceof j))return void console.warn("can only add System");n=e}if(!this.systems.find((function(e){return e.constructor===n.constructor}))){n.game=this,n.init&&n.init(n.__systemDefaultParams),function(e,t){g[t.systemName]=t.observerInfo,v[t.systemName]=e}(n,n.constructor),function(e){var r,n,o,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){b[p]=b[p]||[];var m=b[p],f=function(e){-1===m.findIndex((function(r){return t.isEqual(r,e)}))&&b[p].push(e)};try{for(var y=(o=void 0,l(u.observerInfo[p])),d=y.next();!d.done;d=y.next())f(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=i.return)&&n.call(i)}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),n}console.warn(n.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 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,s,i,c,u;void 0===t&&(t=[]);try{for(var p=l(t),h=p.next();!h.done;h=p.next()){var m=h.value;try{for(var f=(o=void 0,l(m.components)),y=f.next();!y.done;y=f.next()){var d=y.value;try{q(d),d.update&&d.update(e)}catch(e){console.error("gameObject: "+m.name+" "+d.name+" update error",e)}}}catch(e){o={error:e}}finally{try{y&&!y.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var v=l(t),g=v.next();!g.done;g=v.next()){m=g.value;try{for(var b=(c=void 0,l(m.components)),E=b.next();!E.done;E=b.next()){d=E.value;try{d.lateUpdate&&d.lateUpdate(e)}catch(e){console.error("gameObject: "+m.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{q(c),c.update&&c.update(t)}catch(t){console.error(c.constructor.systemName+" update error",t)}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}try{for(var 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){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=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(n=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){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{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=l(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=l(e),s=a.next();!s.done;s=a.next()){var i=s.value;try{for(var c=(n=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){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{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}(this.gameObjects);try{for(var r=l(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=l(h(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}(o);function z(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 H,J,K=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 s(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}(o),Q=K;exports.LOAD_EVENT=void 0,(H=exports.LOAD_EVENT||(exports.LOAD_EVENT={})).START="start",H.PROGRESS="progress",H.LOADED="loaded",H.COMPLETE="complete",H.ERROR="error",exports.RESOURCE_TYPE=void 0,(J=exports.RESOURCE_TYPE||(exports.RESOURCE_TYPE={})).IMAGE="IMAGE",J.SPRITE="SPRITE",J.SPRITE_ANIMATION="SPRITE_ANIMATION",J.DRAGONBONE="DRAGONBONE",J.SPINE="SPINE",J.AUDIO="AUDIO",J.VIDEO="VIDEO",r.XhrLoadStrategy.setExtensionXhrType("json",r.XhrResponseType.Json),r.XhrLoadStrategy.setExtensionXhrType("tex",r.XhrResponseType.Json),r.XhrLoadStrategy.setExtensionXhrType("ske",r.XhrResponseType.Json),r.XhrLoadStrategy.setExtensionXhrType("mp3",r.XhrResponseType.Buffer),r.XhrLoadStrategy.setExtensionXhrType("wav",r.XhrResponseType.Buffer),r.XhrLoadStrategy.setExtensionXhrType("aac",r.XhrResponseType.Buffer),r.XhrLoadStrategy.setExtensionXhrType("ogg",r.XhrResponseType.Buffer);var W={png:r.ImageLoadStrategy,jpg:r.ImageLoadStrategy,jpeg:r.ImageLoadStrategy,webp:r.ImageLoadStrategy,json:r.XhrLoadStrategy,tex:r.XhrLoadStrategy,ske:r.XhrLoadStrategy,audio:r.XhrLoadStrategy,video:r.VideoLoadStrategy},Z=function(e){function t(t){var r=e.call(this)||this;return r.timeout=6e3,r.resourcesMap={},r.makeInstanceFunctions={},r.destroyInstanceFunctions={},r.promiseMap={},r.loaders=[],t&&"number"==typeof t.timeout&&(r.timeout=t.timeout),r}return s(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=l(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.preload=function(){var e=[];for(var t in this.resourcesMap){var r=this.resourcesMap[t];r.preload&&e.push(r.name)}this.progress=new Q({resource:this,resourceTotal:e.length}),this.loadResource({names:e,preload:!0})},t.prototype.getResource=function(e){return c(this,void 0,void 0,(function(){return u(this,(function(t){return this.loadResource({names:[e]}),[2,this.promiseMap[e]||Promise.resolve({})]}))}))},t.prototype.instance=function(e){return c(this,void 0,void 0,(function(){var t,r;return u(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 c(this,void 0,void 0,(function(){return u(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),c(this,void 0,void 0,(function(){var r,n;return u(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.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,n=void 0===r?[]:r,o=e.preload,a=void 0!==o&&o,s=n.filter((function(e){return!t.promiseMap[e]&&t.resourcesMap[e]}));if(s.length){var i={},c=this.getLoader(a);s.forEach((function(e){t.promiseMap[e]=new Promise((function(t){return i[e]=t}));var r=t.resourcesMap[e];for(var n in r.src){var o=r.src[n].type;"data"===o?(r.data[n]=r.src[n].data,t.doComplete(e,i[e],a)):c.add({url:r.src[n].url,name:r.name+"_"+n,strategy:W[o],metadata:{key:n,name:r.name,resolves:i}})}})),c.load()}},t.prototype.doComplete=function(e,t,r){return void 0===r&&(r=!1),c(this,void 0,void 0,(function(){var n,o,a,s;return u(this,(function(i){switch(i.label){case 0:if(n=this.resourcesMap[e],o={name:e,resource:this.resourcesMap[e],success:!0},!this.checkAllLoaded(e))return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),a=n,[4,this.instance(e)];case 2:return a.instance=i.sent(),n.complete=!0,r&&this.progress.onProgress(o),t(n),[3,4];case 3:return s=i.sent(),n.complete=!1,r&&(o.errMsg=s.message,o.success=!1,this.progress.onProgress(o)),t({}),[3,4];case 4:return[2]}}))}))},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 n=this.loaders.find((function(e){return!e.loading}));return n||(n=new r.Loader,this.loaders.push(n)),e&&n.onStart.once((function(){t.progress.onStart()})),n.onLoad.add((function(r,n){t.onLoad({preload:e,resource:n})})),n.onError.add((function(r,n,o){t.onError({errMsg:r,resource:o,preload:e})})),n.onComplete.once((function(){n.onLoad.detachAll(),n.onError.detachAll(),n.reset()})),n},t.prototype.onLoad=function(e){var t=e.preload,r=void 0!==t&&t,n=e.resource;return c(this,void 0,void 0,(function(){var e,t,o,a,s;return u(this,(function(i){return e=n.metadata,t=e.key,o=e.name,a=e.resolves,s=n.data,this.resourcesMap[o].data[t]=s,this.doComplete(o,a[o],r),[2]}))}))},t.prototype.onError=function(e){var t=e.errMsg,r=e.preload,n=void 0!==r&&r,o=e.resource;return c(this,void 0,void 0,(function(){var e,r,a,s;return u(this,(function(i){return e=o.metadata,r=e.name,a=e.resolves,this._destroy(r,!0),a[r]({}),n&&(s={name:r,resource:this.resourcesMap[r],success:!1,errMsg:t},this.progress.onProgress(s)),[2]}))}))},t}(o),$=new Z,ee={IDEProp:_,componentObserver:z};exports.Component=y,exports.Game=Y,exports.GameObject=w,exports.IDEProp=_,exports.Scene=B,exports.System=j,exports.Transform=R,exports.componentObserver=z,exports.decorators=ee,exports.resource=$;