@one-commerce/sdk-core 1.11.0 → 1.12.0-alpha.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.
@@ -201,6 +201,8 @@ exports.Errors = exports.Message = void 0;
201
201
  Message["METHOD_CALL_ERROR"] = "one:method:error";
202
202
  Message["METHOD_RESULT"] = "one:method:result";
203
203
  Message["NAVIGATION_PUSH"] = "one:navigation:push";
204
+ Message["FRAME_HEIGHT_REQUEST"] = "one:frameheight:request";
205
+ Message["FRAME_HEIGHT_CHANGE"] = "one:frameheight:change";
204
206
  })(exports.Message || (exports.Message = {}));
205
207
  (function (Errors) {
206
208
  Errors["METHOD_DOES_NOT_EXISTS"] = "Method does not exists";
@@ -723,6 +725,8 @@ var Sdk = /*#__PURE__*/function (_Events) {
723
725
 
724
726
  _defineProperty(_assertThisInitialized(_this), "channel", void 0);
725
727
 
728
+ _defineProperty(_assertThisInitialized(_this), "autoheight", true);
729
+
726
730
  _defineProperty(_assertThisInitialized(_this), "origin", void 0);
727
731
 
728
732
  _defineProperty(_assertThisInitialized(_this), "isInitialized", false);
@@ -769,6 +773,17 @@ var Sdk = /*#__PURE__*/function (_Events) {
769
773
  _this.emit(SdkInternalEvents.UPDATE, payload);
770
774
  });
771
775
 
776
+ _this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, function (payload) {
777
+ if (_this.autoheight) {
778
+ Sdk.log('Request for iframe height');
779
+ var body = document.body,
780
+ html = document.documentElement;
781
+ var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
782
+
783
+ _this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
784
+ }
785
+ });
786
+
772
787
  _this.channel.connect().then(function () {
773
788
  Sdk.log('Connected with ONe SDK');
774
789
  });
@@ -801,6 +816,10 @@ var Sdk = /*#__PURE__*/function (_Events) {
801
816
  if (typeof options.debug !== 'undefined') {
802
817
  Sdk.debug = options.debug;
803
818
  }
819
+
820
+ if (typeof options.autoheight !== 'undefined') {
821
+ this.autoheight = options.autoheight;
822
+ }
804
823
  }
805
824
  }
806
825
  }, {