@one-commerce/sdk-core 1.12.0-alpha.0 → 1.14.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.
@@ -439,6 +439,36 @@
439
439
 
440
440
  return _createClass(BackofficeLayout);
441
441
  }(BaseCallClass);
442
+ var BackofficeAuthorization = /*#__PURE__*/function (_BaseCallClass6) {
443
+ _inherits(BackofficeAuthorization, _BaseCallClass6);
444
+
445
+ var _super6 = _createSuper(BackofficeAuthorization);
446
+
447
+ function BackofficeAuthorization() {
448
+ var _this6;
449
+
450
+ _classCallCheck(this, BackofficeAuthorization);
451
+
452
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
453
+ args[_key6] = arguments[_key6];
454
+ }
455
+
456
+ _this6 = _super6.call.apply(_super6, [this].concat(args));
457
+
458
+ _defineProperty(_assertThisInitialized(_this6), "serviceName", 'authorization');
459
+
460
+ return _this6;
461
+ }
462
+
463
+ _createClass(BackofficeAuthorization, [{
464
+ key: "getAuthToken",
465
+ value: function getAuthToken() {
466
+ return this.call('getAuthToken');
467
+ }
468
+ }]);
469
+
470
+ return BackofficeAuthorization;
471
+ }(BaseCallClass);
442
472
 
443
473
  var Events = /*#__PURE__*/function () {
444
474
  function Events() {
@@ -733,6 +763,8 @@
733
763
 
734
764
  _defineProperty(_assertThisInitialized(_this), "autoheight", true);
735
765
 
766
+ _defineProperty(_assertThisInitialized(_this), "heightMutationObserver", null);
767
+
736
768
  _defineProperty(_assertThisInitialized(_this), "origin", void 0);
737
769
 
738
770
  _defineProperty(_assertThisInitialized(_this), "isInitialized", false);
@@ -782,16 +814,17 @@
782
814
  _this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, function (payload) {
783
815
  if (_this.autoheight) {
784
816
  Sdk.log('Request for iframe height');
785
- var body = document.body,
786
- html = document.documentElement;
787
- var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
788
817
 
789
- _this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
818
+ _this.sendFrameHeight();
790
819
  }
791
820
  });
792
821
 
793
822
  _this.channel.connect().then(function () {
794
823
  Sdk.log('Connected with ONe SDK');
824
+
825
+ if (_this.autoheight) {
826
+ _this.initializeHeightObserver();
827
+ }
795
828
  });
796
829
 
797
830
  _this.setupOptions(options);
@@ -815,6 +848,40 @@
815
848
  });
816
849
  }
817
850
  }
851
+ }, {
852
+ key: "sendFrameHeight",
853
+ value: function sendFrameHeight() {
854
+ var body = document.body,
855
+ html = document.documentElement;
856
+ var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
857
+ this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
858
+ }
859
+ }, {
860
+ key: "initializeHeightObserver",
861
+ value: function initializeHeightObserver() {
862
+ var _this3 = this;
863
+
864
+ if ("MutationObserver" in window) {
865
+ var onMutationObserved = function onMutationObserved() {
866
+ _this3.sendFrameHeight();
867
+ };
868
+
869
+ var target = document.querySelector('body'),
870
+ config = {
871
+ attributes: true,
872
+ attributeOldValue: false,
873
+ characterData: true,
874
+ characterDataOldValue: false,
875
+ childList: true,
876
+ subtree: true
877
+ };
878
+ this.heightMutationObserver = new MutationObserver(onMutationObserved);
879
+ Sdk.log('Create body MutationObserver');
880
+ this.heightMutationObserver.observe(target, config);
881
+ } else {
882
+ Sdk.warn('MutationObserver not available. Auto-height functionality disabled.');
883
+ }
884
+ }
818
885
  }, {
819
886
  key: "setupOptions",
820
887
  value: function setupOptions(options) {
@@ -831,7 +898,7 @@
831
898
  }, {
832
899
  key: "callFunction",
833
900
  value: function callFunction(service, fun) {
834
- var _this3 = this;
901
+ var _this4 = this;
835
902
 
836
903
  var callId = generateCallId();
837
904
 
@@ -850,13 +917,13 @@
850
917
  return new Promise(function (resolve) {
851
918
  var onChannelMessage = function onChannelMessage(response) {
852
919
  if (response.callId === callId) {
853
- _this3.channel.unsubscribe(main.Message.METHOD_RESULT, onChannelMessage);
920
+ _this4.channel.unsubscribe(main.Message.METHOD_RESULT, onChannelMessage);
854
921
 
855
922
  return resolve(response.result);
856
923
  }
857
924
  };
858
925
 
859
- _this3.channel.subscribe(main.Message.METHOD_RESULT, onChannelMessage);
926
+ _this4.channel.subscribe(main.Message.METHOD_RESULT, onChannelMessage);
860
927
  });
861
928
  }
862
929
 
@@ -903,7 +970,7 @@
903
970
  var _super2 = _createSuper(BackofficeSdk);
904
971
 
905
972
  function BackofficeSdk() {
906
- var _this4;
973
+ var _this5;
907
974
 
908
975
  _classCallCheck(this, BackofficeSdk);
909
976
 
@@ -911,21 +978,22 @@
911
978
  args[_key4] = arguments[_key4];
912
979
  }
913
980
 
914
- _this4 = _super2.call.apply(_super2, [this].concat(args));
981
+ _this5 = _super2.call.apply(_super2, [this].concat(args));
915
982
 
916
- _defineProperty(_assertThisInitialized(_this4), "instances", {
983
+ _defineProperty(_assertThisInitialized(_this5), "instances", {
917
984
  route: {
918
985
  hash: '',
919
986
  query: {}
920
987
  },
921
- orderpath: new BackofficeOrderpath(_this4.callFunction.bind(_assertThisInitialized(_this4))),
922
- catalog: new BackofficeCatalog(_this4.callFunction.bind(_assertThisInitialized(_this4))),
923
- user: new BackofficeUser(_this4.callFunction.bind(_assertThisInitialized(_this4))),
924
- tenant: new BackofficeTenant(_this4.callFunction.bind(_assertThisInitialized(_this4))),
925
- layout: new BackofficeLayout(_this4.callFunction.bind(_assertThisInitialized(_this4)))
988
+ orderpath: new BackofficeOrderpath(_this5.callFunction.bind(_assertThisInitialized(_this5))),
989
+ catalog: new BackofficeCatalog(_this5.callFunction.bind(_assertThisInitialized(_this5))),
990
+ user: new BackofficeUser(_this5.callFunction.bind(_assertThisInitialized(_this5))),
991
+ tenant: new BackofficeTenant(_this5.callFunction.bind(_assertThisInitialized(_this5))),
992
+ layout: new BackofficeLayout(_this5.callFunction.bind(_assertThisInitialized(_this5))),
993
+ authorization: new BackofficeAuthorization(_this5.callFunction.bind(_assertThisInitialized(_this5)))
926
994
  });
927
995
 
928
- return _this4;
996
+ return _this5;
929
997
  }
930
998
 
931
999
  return _createClass(BackofficeSdk);
@@ -936,7 +1004,7 @@
936
1004
  var _super3 = _createSuper(ShopSdk);
937
1005
 
938
1006
  function ShopSdk() {
939
- var _this5;
1007
+ var _this6;
940
1008
 
941
1009
  _classCallCheck(this, ShopSdk);
942
1010
 
@@ -944,21 +1012,21 @@
944
1012
  args[_key5] = arguments[_key5];
945
1013
  }
946
1014
 
947
- _this5 = _super3.call.apply(_super3, [this].concat(args));
1015
+ _this6 = _super3.call.apply(_super3, [this].concat(args));
948
1016
 
949
- _defineProperty(_assertThisInitialized(_this5), "instances", {
1017
+ _defineProperty(_assertThisInitialized(_this6), "instances", {
950
1018
  route: {
951
1019
  hash: '',
952
1020
  query: {}
953
1021
  },
954
- cart: new ShopCart(_this5.callFunction.bind(_assertThisInitialized(_this5))),
955
- catalog: new ShopCatalog(_this5.callFunction.bind(_assertThisInitialized(_this5))),
956
- account: new ShopAccount(_this5.callFunction.bind(_assertThisInitialized(_this5))),
957
- utils: new ShopUtils(_this5.callFunction.bind(_assertThisInitialized(_this5))),
958
- config: new ShopConfig(_this5.callFunction.bind(_assertThisInitialized(_this5)))
1022
+ cart: new ShopCart(_this6.callFunction.bind(_assertThisInitialized(_this6))),
1023
+ catalog: new ShopCatalog(_this6.callFunction.bind(_assertThisInitialized(_this6))),
1024
+ account: new ShopAccount(_this6.callFunction.bind(_assertThisInitialized(_this6))),
1025
+ utils: new ShopUtils(_this6.callFunction.bind(_assertThisInitialized(_this6))),
1026
+ config: new ShopConfig(_this6.callFunction.bind(_assertThisInitialized(_this6)))
959
1027
  });
960
1028
 
961
- return _this5;
1029
+ return _this6;
962
1030
  }
963
1031
 
964
1032
  return _createClass(ShopSdk);