@galacean/engine-loader 1.4.0-alpha.3 → 1.4.0-beta.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.
package/dist/module.js CHANGED
@@ -649,11 +649,18 @@ var ReflectionParser = /*#__PURE__*/ function() {
649
649
  };
650
650
  _proto.parseMethod = function parseMethod(instance, methodName, methodParams) {
651
651
  var _this = this;
652
- return Promise.all(methodParams.map(function(param) {
652
+ var isMethodObject = ReflectionParser._isMethodObject(methodParams);
653
+ var params = isMethodObject ? methodParams.params : methodParams;
654
+ return Promise.all(params.map(function(param) {
653
655
  return _this.parseBasicType(param);
654
656
  })).then(function(result) {
655
657
  var _instance;
656
- return (_instance = instance)[methodName].apply(_instance, [].concat(result));
658
+ var methodResult = (_instance = instance)[methodName].apply(_instance, [].concat(result));
659
+ if (isMethodObject && methodParams.result) {
660
+ return _this.parsePropsAndMethods(methodResult, methodParams.result);
661
+ } else {
662
+ return methodResult;
663
+ }
657
664
  });
658
665
  };
659
666
  _proto.parseBasicType = function parseBasicType(value, originValue) {
@@ -663,7 +670,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
663
670
  return _this.parseBasicType(item);
664
671
  }));
665
672
  } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value != null) {
666
- if (ReflectionParser._isClass(value)) {
673
+ if (ReflectionParser._isClassType(value)) {
674
+ return Promise.resolve(Loader.getClass(value["classType"]));
675
+ } else if (ReflectionParser._isClass(value)) {
667
676
  // class object
668
677
  return this.parseClassObject(value);
669
678
  } else if (ReflectionParser._isAssetRef(value)) {
@@ -742,6 +751,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
742
751
  ReflectionParser._isClass = function _isClass(value) {
743
752
  return value["class"] !== undefined;
744
753
  };
754
+ ReflectionParser._isClassType = function _isClassType(value) {
755
+ return value["classType"] !== undefined;
756
+ };
745
757
  ReflectionParser._isAssetRef = function _isAssetRef(value) {
746
758
  return value["refId"] !== undefined;
747
759
  };
@@ -751,6 +763,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
751
763
  ReflectionParser._isComponentRef = function _isComponentRef(value) {
752
764
  return value["ownerId"] !== undefined && value["componentId"] !== undefined;
753
765
  };
766
+ ReflectionParser._isMethodObject = function _isMethodObject(value) {
767
+ return Array.isArray(value == null ? void 0 : value.params);
768
+ };
754
769
  return ReflectionParser;
755
770
  }();
756
771
  ReflectionParser.customParseComponentHandles = new Map();
@@ -6179,8 +6194,8 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
6179
6194
  }
6180
6195
  config.atlasRotated && (sprite.atlasRotated = true);
6181
6196
  }
6182
- isNaN(width) || (sprite.width = width);
6183
- isNaN(height) || (sprite.height = height);
6197
+ width === undefined || (sprite.width = width);
6198
+ height === undefined || (sprite.height = height);
6184
6199
  return sprite;
6185
6200
  };
6186
6201
  return SpriteAtlasLoader;
@@ -6219,16 +6234,16 @@ var SpriteLoader = /*#__PURE__*/ function(Loader) {
6219
6234
  .getResourceByRef(data.texture).then(function(texture) {
6220
6235
  var sprite = new Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border);
6221
6236
  var width = data.width, height = data.height;
6222
- isNaN(width) || (sprite.width = width);
6223
- isNaN(height) || (sprite.height = height);
6237
+ width === undefined || (sprite.width = width);
6238
+ height === undefined || (sprite.height = height);
6224
6239
  return sprite;
6225
6240
  });
6226
6241
  } else {
6227
6242
  return new AssetPromise(function(resolve) {
6228
6243
  var sprite = new Sprite(resourceManager.engine, null, data.region, data.pivot, data.border);
6229
6244
  var width = data.width, height = data.height;
6230
- isNaN(width) || (sprite.width = width);
6231
- isNaN(height) || (sprite.height = height);
6245
+ width === undefined || (sprite.width = width);
6246
+ height === undefined || (sprite.height = height);
6232
6247
  resolve(sprite);
6233
6248
  });
6234
6249
  }