@galacean/engine-loader 1.1.0-beta.17 → 1.1.0-beta.19

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/main.js CHANGED
@@ -542,11 +542,17 @@ var ReflectionParser = /*#__PURE__*/ function() {
542
542
  });
543
543
  };
544
544
  _proto.parseClassObject = function parseClassObject(item) {
545
+ var _this = this;
545
546
  var Class = engineCore.Loader.getClass(item.class);
546
547
  var _item_constructParams;
547
548
  var params = (_item_constructParams = item.constructParams) != null ? _item_constructParams : [];
548
- var instance = _construct(Class, [].concat(params));
549
- return this.parsePropsAndMethods(instance, item);
549
+ return Promise.all(params.map(function(param) {
550
+ return _this.parseBasicType(param);
551
+ })).then(function(resultParams) {
552
+ return _construct(Class, [].concat(resultParams));
553
+ }).then(function(instance) {
554
+ return _this.parsePropsAndMethods(instance, item);
555
+ });
550
556
  };
551
557
  _proto.parsePropsAndMethods = function parsePropsAndMethods(instance, item) {
552
558
  var promises = [];
@@ -554,16 +560,14 @@ var ReflectionParser = /*#__PURE__*/ function() {
554
560
  for(var methodName in item.methods){
555
561
  var methodParams = item.methods[methodName];
556
562
  for(var i = 0, count = methodParams.length; i < count; i++){
557
- var params = methodParams[i];
558
- var promise = this.parseMethod(instance, methodName, params);
559
- promises.push(promise);
563
+ promises.push(this.parseMethod(instance, methodName, methodParams[i]));
560
564
  }
561
565
  }
562
566
  }
563
567
  if (item.props) {
564
568
  var _this = this, _loop = function(key) {
565
569
  var value = item.props[key];
566
- var promise = _this.parseBasicType(value).then(function(v) {
570
+ var promise = _this.parseBasicType(value, instance[key]).then(function(v) {
567
571
  return instance[key] = v;
568
572
  });
569
573
  promises.push(promise);
@@ -585,7 +589,7 @@ var ReflectionParser = /*#__PURE__*/ function() {
585
589
  return (_instance = instance)[methodName].apply(_instance, [].concat(result));
586
590
  });
587
591
  };
588
- _proto.parseBasicType = function parseBasicType(value) {
592
+ _proto.parseBasicType = function parseBasicType(value, originValue) {
589
593
  var _this = this;
590
594
  if (Array.isArray(value)) {
591
595
  return Promise.all(value.map(function(item) {
@@ -602,13 +606,33 @@ var ReflectionParser = /*#__PURE__*/ function() {
602
606
  } else if (ReflectionParser._isEntityRef(value)) {
603
607
  // entity reference
604
608
  return Promise.resolve(this._context.entityMap.get(value.entityId));
605
- } else {
606
- // basic type
607
- return Promise.resolve(value);
609
+ } else if (originValue) {
610
+ var _this1 = this, _loop = function(key) {
611
+ if (key === "methods") {
612
+ var methods = value[key];
613
+ for(var methodName in methods){
614
+ var methodParams = methods[methodName];
615
+ for(var i = 0, count = methodParams.length; i < count; i++){
616
+ var params = methodParams[i];
617
+ var promise = _this1.parseMethod(originValue, methodName, params);
618
+ promises.push(promise);
619
+ }
620
+ }
621
+ } else {
622
+ promises.push(_this1.parseBasicType(value[key], originValue[key]).then(function(v) {
623
+ return originValue[key] = v;
624
+ }));
625
+ }
626
+ };
627
+ var promises = [];
628
+ for(var key in value)_loop(key);
629
+ return Promise.all(promises).then(function() {
630
+ return originValue;
631
+ });
608
632
  }
609
- } else {
610
- return Promise.resolve(value);
611
633
  }
634
+ // primitive type
635
+ return Promise.resolve(value);
612
636
  };
613
637
  _proto._getEntityByConfig = function _getEntityByConfig(entityConfig) {
614
638
  // @ts-ignore