@one-commerce/sdk-core 1.11.0 → 1.13.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 +77 -21
- 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 +77 -21
- 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 +75 -21
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.js +48 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -207,6 +207,8 @@
|
|
|
207
207
|
Message["METHOD_CALL_ERROR"] = "one:method:error";
|
|
208
208
|
Message["METHOD_RESULT"] = "one:method:result";
|
|
209
209
|
Message["NAVIGATION_PUSH"] = "one:navigation:push";
|
|
210
|
+
Message["FRAME_HEIGHT_REQUEST"] = "one:frameheight:request";
|
|
211
|
+
Message["FRAME_HEIGHT_CHANGE"] = "one:frameheight:change";
|
|
210
212
|
})(exports.Message || (exports.Message = {}));
|
|
211
213
|
(function (Errors) {
|
|
212
214
|
Errors["METHOD_DOES_NOT_EXISTS"] = "Method does not exists";
|
|
@@ -729,6 +731,10 @@
|
|
|
729
731
|
|
|
730
732
|
_defineProperty(_assertThisInitialized(_this), "channel", void 0);
|
|
731
733
|
|
|
734
|
+
_defineProperty(_assertThisInitialized(_this), "autoheight", true);
|
|
735
|
+
|
|
736
|
+
_defineProperty(_assertThisInitialized(_this), "heightMutationObserver", null);
|
|
737
|
+
|
|
732
738
|
_defineProperty(_assertThisInitialized(_this), "origin", void 0);
|
|
733
739
|
|
|
734
740
|
_defineProperty(_assertThisInitialized(_this), "isInitialized", false);
|
|
@@ -775,8 +781,20 @@
|
|
|
775
781
|
_this.emit(SdkInternalEvents.UPDATE, payload);
|
|
776
782
|
});
|
|
777
783
|
|
|
784
|
+
_this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, function (payload) {
|
|
785
|
+
if (_this.autoheight) {
|
|
786
|
+
Sdk.log('Request for iframe height');
|
|
787
|
+
|
|
788
|
+
_this.sendFrameHeight();
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
|
|
778
792
|
_this.channel.connect().then(function () {
|
|
779
793
|
Sdk.log('Connected with ONe SDK');
|
|
794
|
+
|
|
795
|
+
if (_this.autoheight) {
|
|
796
|
+
_this.initializeHeightObserver();
|
|
797
|
+
}
|
|
780
798
|
});
|
|
781
799
|
|
|
782
800
|
_this.setupOptions(options);
|
|
@@ -800,6 +818,40 @@
|
|
|
800
818
|
});
|
|
801
819
|
}
|
|
802
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
|
+
}
|
|
803
855
|
}, {
|
|
804
856
|
key: "setupOptions",
|
|
805
857
|
value: function setupOptions(options) {
|
|
@@ -807,12 +859,16 @@
|
|
|
807
859
|
if (typeof options.debug !== 'undefined') {
|
|
808
860
|
Sdk.debug = options.debug;
|
|
809
861
|
}
|
|
862
|
+
|
|
863
|
+
if (typeof options.autoheight !== 'undefined') {
|
|
864
|
+
this.autoheight = options.autoheight;
|
|
865
|
+
}
|
|
810
866
|
}
|
|
811
867
|
}
|
|
812
868
|
}, {
|
|
813
869
|
key: "callFunction",
|
|
814
870
|
value: function callFunction(service, fun) {
|
|
815
|
-
var
|
|
871
|
+
var _this4 = this;
|
|
816
872
|
|
|
817
873
|
var callId = generateCallId();
|
|
818
874
|
|
|
@@ -831,13 +887,13 @@
|
|
|
831
887
|
return new Promise(function (resolve) {
|
|
832
888
|
var onChannelMessage = function onChannelMessage(response) {
|
|
833
889
|
if (response.callId === callId) {
|
|
834
|
-
|
|
890
|
+
_this4.channel.unsubscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
835
891
|
|
|
836
892
|
return resolve(response.result);
|
|
837
893
|
}
|
|
838
894
|
};
|
|
839
895
|
|
|
840
|
-
|
|
896
|
+
_this4.channel.subscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
841
897
|
});
|
|
842
898
|
}
|
|
843
899
|
|
|
@@ -884,7 +940,7 @@
|
|
|
884
940
|
var _super2 = _createSuper(BackofficeSdk);
|
|
885
941
|
|
|
886
942
|
function BackofficeSdk() {
|
|
887
|
-
var
|
|
943
|
+
var _this5;
|
|
888
944
|
|
|
889
945
|
_classCallCheck(this, BackofficeSdk);
|
|
890
946
|
|
|
@@ -892,21 +948,21 @@
|
|
|
892
948
|
args[_key4] = arguments[_key4];
|
|
893
949
|
}
|
|
894
950
|
|
|
895
|
-
|
|
951
|
+
_this5 = _super2.call.apply(_super2, [this].concat(args));
|
|
896
952
|
|
|
897
|
-
_defineProperty(_assertThisInitialized(
|
|
953
|
+
_defineProperty(_assertThisInitialized(_this5), "instances", {
|
|
898
954
|
route: {
|
|
899
955
|
hash: '',
|
|
900
956
|
query: {}
|
|
901
957
|
},
|
|
902
|
-
orderpath: new BackofficeOrderpath(
|
|
903
|
-
catalog: new BackofficeCatalog(
|
|
904
|
-
user: new BackofficeUser(
|
|
905
|
-
tenant: new BackofficeTenant(
|
|
906
|
-
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)))
|
|
907
963
|
});
|
|
908
964
|
|
|
909
|
-
return
|
|
965
|
+
return _this5;
|
|
910
966
|
}
|
|
911
967
|
|
|
912
968
|
return _createClass(BackofficeSdk);
|
|
@@ -917,7 +973,7 @@
|
|
|
917
973
|
var _super3 = _createSuper(ShopSdk);
|
|
918
974
|
|
|
919
975
|
function ShopSdk() {
|
|
920
|
-
var
|
|
976
|
+
var _this6;
|
|
921
977
|
|
|
922
978
|
_classCallCheck(this, ShopSdk);
|
|
923
979
|
|
|
@@ -925,21 +981,21 @@
|
|
|
925
981
|
args[_key5] = arguments[_key5];
|
|
926
982
|
}
|
|
927
983
|
|
|
928
|
-
|
|
984
|
+
_this6 = _super3.call.apply(_super3, [this].concat(args));
|
|
929
985
|
|
|
930
|
-
_defineProperty(_assertThisInitialized(
|
|
986
|
+
_defineProperty(_assertThisInitialized(_this6), "instances", {
|
|
931
987
|
route: {
|
|
932
988
|
hash: '',
|
|
933
989
|
query: {}
|
|
934
990
|
},
|
|
935
|
-
cart: new ShopCart(
|
|
936
|
-
catalog: new ShopCatalog(
|
|
937
|
-
account: new ShopAccount(
|
|
938
|
-
utils: new ShopUtils(
|
|
939
|
-
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)))
|
|
940
996
|
});
|
|
941
997
|
|
|
942
|
-
return
|
|
998
|
+
return _this6;
|
|
943
999
|
}
|
|
944
1000
|
|
|
945
1001
|
return _createClass(ShopSdk);
|