@galacean/engine-loader 2.0.0-alpha.14 → 2.0.0-alpha.15

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
@@ -803,6 +803,29 @@ var ReflectionParser = /*#__PURE__*/ function() {
803
803
  }
804
804
  });
805
805
  };
806
+ _proto.parseSignal = function parseSignal(signalRef) {
807
+ var _this = this;
808
+ var signal = new engineCore.Signal();
809
+ return Promise.all(signalRef.listeners.map(function(listener) {
810
+ return Promise.all([
811
+ _this.parseBasicType(listener.target),
812
+ listener.arguments ? Promise.all(listener.arguments.map(function(a) {
813
+ return _this.parseBasicType(a);
814
+ })) : Promise.resolve([])
815
+ ]).then(function(param) {
816
+ var target = param[0], resolvedArgs = param[1];
817
+ if (target) {
818
+ var _signal;
819
+ (_signal = signal).on.apply(_signal, [].concat([
820
+ target,
821
+ listener.methodName
822
+ ], resolvedArgs));
823
+ }
824
+ });
825
+ })).then(function() {
826
+ return signal;
827
+ });
828
+ };
806
829
  _proto.parseBasicType = function parseBasicType(value, originValue) {
807
830
  var _this = this;
808
831
  if (Array.isArray(value)) {
@@ -832,6 +855,8 @@ var ReflectionParser = /*#__PURE__*/ function() {
832
855
  } else if (ReflectionParser._isEntityRef(value)) {
833
856
  // entity reference
834
857
  return Promise.resolve(this._context.entityMap.get(value.entityId));
858
+ } else if (ReflectionParser._isSignalRef(value)) {
859
+ return this.parseSignal(value);
835
860
  } else if (originValue) {
836
861
  var _this2, _loop = function(key) {
837
862
  if (key === "methods") {
@@ -902,6 +927,9 @@ var ReflectionParser = /*#__PURE__*/ function() {
902
927
  ReflectionParser._isComponentRef = function _isComponentRef(value) {
903
928
  return value["ownerId"] !== undefined && value["componentId"] !== undefined;
904
929
  };
930
+ ReflectionParser._isSignalRef = function _isSignalRef(value) {
931
+ return value["listeners"] !== undefined;
932
+ };
905
933
  ReflectionParser._isMethodObject = function _isMethodObject(value) {
906
934
  return Array.isArray(value == null ? void 0 : value.params);
907
935
  };