@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
|
@@ -727,6 +727,8 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
727
727
|
|
|
728
728
|
_defineProperty(_assertThisInitialized(_this), "autoheight", true);
|
|
729
729
|
|
|
730
|
+
_defineProperty(_assertThisInitialized(_this), "heightMutationObserver", null);
|
|
731
|
+
|
|
730
732
|
_defineProperty(_assertThisInitialized(_this), "origin", void 0);
|
|
731
733
|
|
|
732
734
|
_defineProperty(_assertThisInitialized(_this), "isInitialized", false);
|
|
@@ -776,16 +778,17 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
776
778
|
_this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, function (payload) {
|
|
777
779
|
if (_this.autoheight) {
|
|
778
780
|
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
781
|
|
|
783
|
-
_this.
|
|
782
|
+
_this.sendFrameHeight();
|
|
784
783
|
}
|
|
785
784
|
});
|
|
786
785
|
|
|
787
786
|
_this.channel.connect().then(function () {
|
|
788
787
|
Sdk.log('Connected with ONe SDK');
|
|
788
|
+
|
|
789
|
+
if (_this.autoheight) {
|
|
790
|
+
_this.initializeHeightObserver();
|
|
791
|
+
}
|
|
789
792
|
});
|
|
790
793
|
|
|
791
794
|
_this.setupOptions(options);
|
|
@@ -809,6 +812,40 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
809
812
|
});
|
|
810
813
|
}
|
|
811
814
|
}
|
|
815
|
+
}, {
|
|
816
|
+
key: "sendFrameHeight",
|
|
817
|
+
value: function sendFrameHeight() {
|
|
818
|
+
var body = document.body,
|
|
819
|
+
html = document.documentElement;
|
|
820
|
+
var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
821
|
+
this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
|
|
822
|
+
}
|
|
823
|
+
}, {
|
|
824
|
+
key: "initializeHeightObserver",
|
|
825
|
+
value: function initializeHeightObserver() {
|
|
826
|
+
var _this3 = this;
|
|
827
|
+
|
|
828
|
+
if ("MutationObserver" in window) {
|
|
829
|
+
var onMutationObserved = function onMutationObserved() {
|
|
830
|
+
_this3.sendFrameHeight();
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
var target = document.querySelector('body'),
|
|
834
|
+
config = {
|
|
835
|
+
attributes: true,
|
|
836
|
+
attributeOldValue: false,
|
|
837
|
+
characterData: true,
|
|
838
|
+
characterDataOldValue: false,
|
|
839
|
+
childList: true,
|
|
840
|
+
subtree: true
|
|
841
|
+
};
|
|
842
|
+
this.heightMutationObserver = new MutationObserver(onMutationObserved);
|
|
843
|
+
Sdk.log('Create body MutationObserver');
|
|
844
|
+
this.heightMutationObserver.observe(target, config);
|
|
845
|
+
} else {
|
|
846
|
+
Sdk.warn('MutationObserver not available. Auto-height functionality disabled.');
|
|
847
|
+
}
|
|
848
|
+
}
|
|
812
849
|
}, {
|
|
813
850
|
key: "setupOptions",
|
|
814
851
|
value: function setupOptions(options) {
|
|
@@ -825,7 +862,7 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
825
862
|
}, {
|
|
826
863
|
key: "callFunction",
|
|
827
864
|
value: function callFunction(service, fun) {
|
|
828
|
-
var
|
|
865
|
+
var _this4 = this;
|
|
829
866
|
|
|
830
867
|
var callId = generateCallId();
|
|
831
868
|
|
|
@@ -844,13 +881,13 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
844
881
|
return new Promise(function (resolve) {
|
|
845
882
|
var onChannelMessage = function onChannelMessage(response) {
|
|
846
883
|
if (response.callId === callId) {
|
|
847
|
-
|
|
884
|
+
_this4.channel.unsubscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
848
885
|
|
|
849
886
|
return resolve(response.result);
|
|
850
887
|
}
|
|
851
888
|
};
|
|
852
889
|
|
|
853
|
-
|
|
890
|
+
_this4.channel.subscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
854
891
|
});
|
|
855
892
|
}
|
|
856
893
|
|
|
@@ -897,7 +934,7 @@ var BackofficeSdk = /*#__PURE__*/function (_Sdk) {
|
|
|
897
934
|
var _super2 = _createSuper(BackofficeSdk);
|
|
898
935
|
|
|
899
936
|
function BackofficeSdk() {
|
|
900
|
-
var
|
|
937
|
+
var _this5;
|
|
901
938
|
|
|
902
939
|
_classCallCheck(this, BackofficeSdk);
|
|
903
940
|
|
|
@@ -905,21 +942,21 @@ var BackofficeSdk = /*#__PURE__*/function (_Sdk) {
|
|
|
905
942
|
args[_key4] = arguments[_key4];
|
|
906
943
|
}
|
|
907
944
|
|
|
908
|
-
|
|
945
|
+
_this5 = _super2.call.apply(_super2, [this].concat(args));
|
|
909
946
|
|
|
910
|
-
_defineProperty(_assertThisInitialized(
|
|
947
|
+
_defineProperty(_assertThisInitialized(_this5), "instances", {
|
|
911
948
|
route: {
|
|
912
949
|
hash: '',
|
|
913
950
|
query: {}
|
|
914
951
|
},
|
|
915
|
-
orderpath: new BackofficeOrderpath(
|
|
916
|
-
catalog: new BackofficeCatalog(
|
|
917
|
-
user: new BackofficeUser(
|
|
918
|
-
tenant: new BackofficeTenant(
|
|
919
|
-
layout: new BackofficeLayout(
|
|
952
|
+
orderpath: new BackofficeOrderpath(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
953
|
+
catalog: new BackofficeCatalog(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
954
|
+
user: new BackofficeUser(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
955
|
+
tenant: new BackofficeTenant(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
956
|
+
layout: new BackofficeLayout(_this5.callFunction.bind(_assertThisInitialized(_this5)))
|
|
920
957
|
});
|
|
921
958
|
|
|
922
|
-
return
|
|
959
|
+
return _this5;
|
|
923
960
|
}
|
|
924
961
|
|
|
925
962
|
return _createClass(BackofficeSdk);
|
|
@@ -930,7 +967,7 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
|
|
|
930
967
|
var _super3 = _createSuper(ShopSdk);
|
|
931
968
|
|
|
932
969
|
function ShopSdk() {
|
|
933
|
-
var
|
|
970
|
+
var _this6;
|
|
934
971
|
|
|
935
972
|
_classCallCheck(this, ShopSdk);
|
|
936
973
|
|
|
@@ -938,21 +975,21 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
|
|
|
938
975
|
args[_key5] = arguments[_key5];
|
|
939
976
|
}
|
|
940
977
|
|
|
941
|
-
|
|
978
|
+
_this6 = _super3.call.apply(_super3, [this].concat(args));
|
|
942
979
|
|
|
943
|
-
_defineProperty(_assertThisInitialized(
|
|
980
|
+
_defineProperty(_assertThisInitialized(_this6), "instances", {
|
|
944
981
|
route: {
|
|
945
982
|
hash: '',
|
|
946
983
|
query: {}
|
|
947
984
|
},
|
|
948
|
-
cart: new ShopCart(
|
|
949
|
-
catalog: new ShopCatalog(
|
|
950
|
-
account: new ShopAccount(
|
|
951
|
-
utils: new ShopUtils(
|
|
952
|
-
config: new ShopConfig(
|
|
985
|
+
cart: new ShopCart(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
986
|
+
catalog: new ShopCatalog(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
987
|
+
account: new ShopAccount(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
988
|
+
utils: new ShopUtils(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
989
|
+
config: new ShopConfig(_this6.callFunction.bind(_assertThisInitialized(_this6)))
|
|
953
990
|
});
|
|
954
991
|
|
|
955
|
-
return
|
|
992
|
+
return _this6;
|
|
956
993
|
}
|
|
957
994
|
|
|
958
995
|
return _createClass(ShopSdk);
|