@one-commerce/sdk-core 1.12.0-alpha.0 → 1.12.1-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.
- package/lib/bundles/bundle.esm.js +62 -25
- package/lib/bundles/bundle.esm.js.map +1 -1
- package/lib/bundles/bundle.esm.min.js +1 -1
- package/lib/bundles/bundle.esm.min.js.map +1 -1
- package/lib/bundles/bundle.umd.js +62 -25
- package/lib/bundles/bundle.umd.js.map +1 -1
- package/lib/bundles/bundle.umd.min.js +1 -1
- package/lib/bundles/bundle.umd.min.js.map +1 -1
- package/lib/cjs/index.js +62 -25
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.js +37 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -733,6 +733,8 @@
|
|
|
733
733
|
|
|
734
734
|
_defineProperty(_assertThisInitialized(_this), "autoheight", true);
|
|
735
735
|
|
|
736
|
+
_defineProperty(_assertThisInitialized(_this), "heightMutationObserver", null);
|
|
737
|
+
|
|
736
738
|
_defineProperty(_assertThisInitialized(_this), "origin", void 0);
|
|
737
739
|
|
|
738
740
|
_defineProperty(_assertThisInitialized(_this), "isInitialized", false);
|
|
@@ -782,16 +784,17 @@
|
|
|
782
784
|
_this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, function (payload) {
|
|
783
785
|
if (_this.autoheight) {
|
|
784
786
|
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
787
|
|
|
789
|
-
_this.
|
|
788
|
+
_this.sendFrameHeight();
|
|
790
789
|
}
|
|
791
790
|
});
|
|
792
791
|
|
|
793
792
|
_this.channel.connect().then(function () {
|
|
794
793
|
Sdk.log('Connected with ONe SDK');
|
|
794
|
+
|
|
795
|
+
if (_this.autoheight) {
|
|
796
|
+
_this.initializeHeightObserver();
|
|
797
|
+
}
|
|
795
798
|
});
|
|
796
799
|
|
|
797
800
|
_this.setupOptions(options);
|
|
@@ -815,6 +818,40 @@
|
|
|
815
818
|
});
|
|
816
819
|
}
|
|
817
820
|
}
|
|
821
|
+
}, {
|
|
822
|
+
key: "sendFrameHeight",
|
|
823
|
+
value: function sendFrameHeight() {
|
|
824
|
+
var body = document.body,
|
|
825
|
+
html = document.documentElement;
|
|
826
|
+
var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
827
|
+
this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
|
|
828
|
+
}
|
|
829
|
+
}, {
|
|
830
|
+
key: "initializeHeightObserver",
|
|
831
|
+
value: function initializeHeightObserver() {
|
|
832
|
+
var _this3 = this;
|
|
833
|
+
|
|
834
|
+
if ("MutationObserver" in window) {
|
|
835
|
+
var onMutationObserved = function onMutationObserved() {
|
|
836
|
+
_this3.sendFrameHeight();
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
var target = document.querySelector('body'),
|
|
840
|
+
config = {
|
|
841
|
+
attributes: true,
|
|
842
|
+
attributeOldValue: false,
|
|
843
|
+
characterData: true,
|
|
844
|
+
characterDataOldValue: false,
|
|
845
|
+
childList: true,
|
|
846
|
+
subtree: true
|
|
847
|
+
};
|
|
848
|
+
this.heightMutationObserver = new MutationObserver(onMutationObserved);
|
|
849
|
+
Sdk.log('Create body MutationObserver');
|
|
850
|
+
this.heightMutationObserver.observe(target, config);
|
|
851
|
+
} else {
|
|
852
|
+
Sdk.warn('MutationObserver not available. Auto-height functionality disabled.');
|
|
853
|
+
}
|
|
854
|
+
}
|
|
818
855
|
}, {
|
|
819
856
|
key: "setupOptions",
|
|
820
857
|
value: function setupOptions(options) {
|
|
@@ -831,7 +868,7 @@
|
|
|
831
868
|
}, {
|
|
832
869
|
key: "callFunction",
|
|
833
870
|
value: function callFunction(service, fun) {
|
|
834
|
-
var
|
|
871
|
+
var _this4 = this;
|
|
835
872
|
|
|
836
873
|
var callId = generateCallId();
|
|
837
874
|
|
|
@@ -850,13 +887,13 @@
|
|
|
850
887
|
return new Promise(function (resolve) {
|
|
851
888
|
var onChannelMessage = function onChannelMessage(response) {
|
|
852
889
|
if (response.callId === callId) {
|
|
853
|
-
|
|
890
|
+
_this4.channel.unsubscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
854
891
|
|
|
855
892
|
return resolve(response.result);
|
|
856
893
|
}
|
|
857
894
|
};
|
|
858
895
|
|
|
859
|
-
|
|
896
|
+
_this4.channel.subscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
860
897
|
});
|
|
861
898
|
}
|
|
862
899
|
|
|
@@ -903,7 +940,7 @@
|
|
|
903
940
|
var _super2 = _createSuper(BackofficeSdk);
|
|
904
941
|
|
|
905
942
|
function BackofficeSdk() {
|
|
906
|
-
var
|
|
943
|
+
var _this5;
|
|
907
944
|
|
|
908
945
|
_classCallCheck(this, BackofficeSdk);
|
|
909
946
|
|
|
@@ -911,21 +948,21 @@
|
|
|
911
948
|
args[_key4] = arguments[_key4];
|
|
912
949
|
}
|
|
913
950
|
|
|
914
|
-
|
|
951
|
+
_this5 = _super2.call.apply(_super2, [this].concat(args));
|
|
915
952
|
|
|
916
|
-
_defineProperty(_assertThisInitialized(
|
|
953
|
+
_defineProperty(_assertThisInitialized(_this5), "instances", {
|
|
917
954
|
route: {
|
|
918
955
|
hash: '',
|
|
919
956
|
query: {}
|
|
920
957
|
},
|
|
921
|
-
orderpath: new BackofficeOrderpath(
|
|
922
|
-
catalog: new BackofficeCatalog(
|
|
923
|
-
user: new BackofficeUser(
|
|
924
|
-
tenant: new BackofficeTenant(
|
|
925
|
-
layout: new BackofficeLayout(
|
|
958
|
+
orderpath: new BackofficeOrderpath(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
959
|
+
catalog: new BackofficeCatalog(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
960
|
+
user: new BackofficeUser(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
961
|
+
tenant: new BackofficeTenant(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
962
|
+
layout: new BackofficeLayout(_this5.callFunction.bind(_assertThisInitialized(_this5)))
|
|
926
963
|
});
|
|
927
964
|
|
|
928
|
-
return
|
|
965
|
+
return _this5;
|
|
929
966
|
}
|
|
930
967
|
|
|
931
968
|
return _createClass(BackofficeSdk);
|
|
@@ -936,7 +973,7 @@
|
|
|
936
973
|
var _super3 = _createSuper(ShopSdk);
|
|
937
974
|
|
|
938
975
|
function ShopSdk() {
|
|
939
|
-
var
|
|
976
|
+
var _this6;
|
|
940
977
|
|
|
941
978
|
_classCallCheck(this, ShopSdk);
|
|
942
979
|
|
|
@@ -944,21 +981,21 @@
|
|
|
944
981
|
args[_key5] = arguments[_key5];
|
|
945
982
|
}
|
|
946
983
|
|
|
947
|
-
|
|
984
|
+
_this6 = _super3.call.apply(_super3, [this].concat(args));
|
|
948
985
|
|
|
949
|
-
_defineProperty(_assertThisInitialized(
|
|
986
|
+
_defineProperty(_assertThisInitialized(_this6), "instances", {
|
|
950
987
|
route: {
|
|
951
988
|
hash: '',
|
|
952
989
|
query: {}
|
|
953
990
|
},
|
|
954
|
-
cart: new ShopCart(
|
|
955
|
-
catalog: new ShopCatalog(
|
|
956
|
-
account: new ShopAccount(
|
|
957
|
-
utils: new ShopUtils(
|
|
958
|
-
config: new ShopConfig(
|
|
991
|
+
cart: new ShopCart(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
992
|
+
catalog: new ShopCatalog(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
993
|
+
account: new ShopAccount(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
994
|
+
utils: new ShopUtils(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
995
|
+
config: new ShopConfig(_this6.callFunction.bind(_assertThisInitialized(_this6)))
|
|
959
996
|
});
|
|
960
997
|
|
|
961
|
-
return
|
|
998
|
+
return _this6;
|
|
962
999
|
}
|
|
963
1000
|
|
|
964
1001
|
return _createClass(ShopSdk);
|