@galacean/engine-loader 1.4.0-alpha.3 → 1.4.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/main.js +24 -9
- package/dist/main.js.map +1 -1
- package/dist/module.js +24 -9
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +6 -4
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +16 -13
package/dist/main.js
CHANGED
|
@@ -653,11 +653,18 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
653
653
|
};
|
|
654
654
|
_proto.parseMethod = function parseMethod(instance, methodName, methodParams) {
|
|
655
655
|
var _this = this;
|
|
656
|
-
|
|
656
|
+
var isMethodObject = ReflectionParser._isMethodObject(methodParams);
|
|
657
|
+
var params = isMethodObject ? methodParams.params : methodParams;
|
|
658
|
+
return Promise.all(params.map(function(param) {
|
|
657
659
|
return _this.parseBasicType(param);
|
|
658
660
|
})).then(function(result) {
|
|
659
661
|
var _instance;
|
|
660
|
-
|
|
662
|
+
var methodResult = (_instance = instance)[methodName].apply(_instance, [].concat(result));
|
|
663
|
+
if (isMethodObject && methodParams.result) {
|
|
664
|
+
return _this.parsePropsAndMethods(methodResult, methodParams.result);
|
|
665
|
+
} else {
|
|
666
|
+
return methodResult;
|
|
667
|
+
}
|
|
661
668
|
});
|
|
662
669
|
};
|
|
663
670
|
_proto.parseBasicType = function parseBasicType(value, originValue) {
|
|
@@ -667,7 +674,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
667
674
|
return _this.parseBasicType(item);
|
|
668
675
|
}));
|
|
669
676
|
} else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value != null) {
|
|
670
|
-
if (ReflectionParser.
|
|
677
|
+
if (ReflectionParser._isClassType(value)) {
|
|
678
|
+
return Promise.resolve(engineCore.Loader.getClass(value["classType"]));
|
|
679
|
+
} else if (ReflectionParser._isClass(value)) {
|
|
671
680
|
// class object
|
|
672
681
|
return this.parseClassObject(value);
|
|
673
682
|
} else if (ReflectionParser._isAssetRef(value)) {
|
|
@@ -746,6 +755,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
746
755
|
ReflectionParser._isClass = function _isClass(value) {
|
|
747
756
|
return value["class"] !== undefined;
|
|
748
757
|
};
|
|
758
|
+
ReflectionParser._isClassType = function _isClassType(value) {
|
|
759
|
+
return value["classType"] !== undefined;
|
|
760
|
+
};
|
|
749
761
|
ReflectionParser._isAssetRef = function _isAssetRef(value) {
|
|
750
762
|
return value["refId"] !== undefined;
|
|
751
763
|
};
|
|
@@ -755,6 +767,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
|
|
|
755
767
|
ReflectionParser._isComponentRef = function _isComponentRef(value) {
|
|
756
768
|
return value["ownerId"] !== undefined && value["componentId"] !== undefined;
|
|
757
769
|
};
|
|
770
|
+
ReflectionParser._isMethodObject = function _isMethodObject(value) {
|
|
771
|
+
return Array.isArray(value == null ? void 0 : value.params);
|
|
772
|
+
};
|
|
758
773
|
return ReflectionParser;
|
|
759
774
|
}();
|
|
760
775
|
ReflectionParser.customParseComponentHandles = new Map();
|
|
@@ -6183,8 +6198,8 @@ var SpriteAtlasLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6183
6198
|
}
|
|
6184
6199
|
config.atlasRotated && (sprite.atlasRotated = true);
|
|
6185
6200
|
}
|
|
6186
|
-
|
|
6187
|
-
|
|
6201
|
+
width === undefined || (sprite.width = width);
|
|
6202
|
+
height === undefined || (sprite.height = height);
|
|
6188
6203
|
return sprite;
|
|
6189
6204
|
};
|
|
6190
6205
|
return SpriteAtlasLoader;
|
|
@@ -6223,16 +6238,16 @@ var SpriteLoader = /*#__PURE__*/ function(Loader) {
|
|
|
6223
6238
|
.getResourceByRef(data.texture).then(function(texture) {
|
|
6224
6239
|
var sprite = new engineCore.Sprite(resourceManager.engine, texture, data.region, data.pivot, data.border);
|
|
6225
6240
|
var width = data.width, height = data.height;
|
|
6226
|
-
|
|
6227
|
-
|
|
6241
|
+
width === undefined || (sprite.width = width);
|
|
6242
|
+
height === undefined || (sprite.height = height);
|
|
6228
6243
|
return sprite;
|
|
6229
6244
|
});
|
|
6230
6245
|
} else {
|
|
6231
6246
|
return new engineCore.AssetPromise(function(resolve) {
|
|
6232
6247
|
var sprite = new engineCore.Sprite(resourceManager.engine, null, data.region, data.pivot, data.border);
|
|
6233
6248
|
var width = data.width, height = data.height;
|
|
6234
|
-
|
|
6235
|
-
|
|
6249
|
+
width === undefined || (sprite.width = width);
|
|
6250
|
+
height === undefined || (sprite.height = height);
|
|
6236
6251
|
resolve(sprite);
|
|
6237
6252
|
});
|
|
6238
6253
|
}
|