@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.
- package/lib/bundles/bundle.esm.js +93 -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 +93 -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/backofficeServices.js +34 -1
- package/lib/cjs/backofficeServices.js.map +1 -1
- package/lib/cjs/index.js +63 -25
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/backofficeServices.js +12 -0
- package/lib/esm/backofficeServices.js.map +1 -1
- package/lib/esm/index.js +40 -6
- package/lib/esm/index.js.map +1 -1
- package/lib/types/backofficeServices.d.ts +4 -0
- package/lib/types/backofficeServices.d.ts.map +1 -1
- package/lib/types/index.d.ts +6 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -433,6 +433,36 @@ var BackofficeLayout = /*#__PURE__*/function (_BaseCallClass5) {
|
|
|
433
433
|
|
|
434
434
|
return _createClass(BackofficeLayout);
|
|
435
435
|
}(BaseCallClass);
|
|
436
|
+
var BackofficeAuthorization = /*#__PURE__*/function (_BaseCallClass6) {
|
|
437
|
+
_inherits(BackofficeAuthorization, _BaseCallClass6);
|
|
438
|
+
|
|
439
|
+
var _super6 = _createSuper(BackofficeAuthorization);
|
|
440
|
+
|
|
441
|
+
function BackofficeAuthorization() {
|
|
442
|
+
var _this6;
|
|
443
|
+
|
|
444
|
+
_classCallCheck(this, BackofficeAuthorization);
|
|
445
|
+
|
|
446
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
447
|
+
args[_key6] = arguments[_key6];
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
_this6 = _super6.call.apply(_super6, [this].concat(args));
|
|
451
|
+
|
|
452
|
+
_defineProperty(_assertThisInitialized(_this6), "serviceName", 'authorization');
|
|
453
|
+
|
|
454
|
+
return _this6;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
_createClass(BackofficeAuthorization, [{
|
|
458
|
+
key: "getAuthToken",
|
|
459
|
+
value: function getAuthToken() {
|
|
460
|
+
return this.call('getAuthToken');
|
|
461
|
+
}
|
|
462
|
+
}]);
|
|
463
|
+
|
|
464
|
+
return BackofficeAuthorization;
|
|
465
|
+
}(BaseCallClass);
|
|
436
466
|
|
|
437
467
|
var Events = /*#__PURE__*/function () {
|
|
438
468
|
function Events() {
|
|
@@ -727,6 +757,8 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
727
757
|
|
|
728
758
|
_defineProperty(_assertThisInitialized(_this), "autoheight", true);
|
|
729
759
|
|
|
760
|
+
_defineProperty(_assertThisInitialized(_this), "heightMutationObserver", null);
|
|
761
|
+
|
|
730
762
|
_defineProperty(_assertThisInitialized(_this), "origin", void 0);
|
|
731
763
|
|
|
732
764
|
_defineProperty(_assertThisInitialized(_this), "isInitialized", false);
|
|
@@ -776,16 +808,17 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
776
808
|
_this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, function (payload) {
|
|
777
809
|
if (_this.autoheight) {
|
|
778
810
|
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
811
|
|
|
783
|
-
_this.
|
|
812
|
+
_this.sendFrameHeight();
|
|
784
813
|
}
|
|
785
814
|
});
|
|
786
815
|
|
|
787
816
|
_this.channel.connect().then(function () {
|
|
788
817
|
Sdk.log('Connected with ONe SDK');
|
|
818
|
+
|
|
819
|
+
if (_this.autoheight) {
|
|
820
|
+
_this.initializeHeightObserver();
|
|
821
|
+
}
|
|
789
822
|
});
|
|
790
823
|
|
|
791
824
|
_this.setupOptions(options);
|
|
@@ -809,6 +842,40 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
809
842
|
});
|
|
810
843
|
}
|
|
811
844
|
}
|
|
845
|
+
}, {
|
|
846
|
+
key: "sendFrameHeight",
|
|
847
|
+
value: function sendFrameHeight() {
|
|
848
|
+
var body = document.body,
|
|
849
|
+
html = document.documentElement;
|
|
850
|
+
var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
|
|
851
|
+
this.channel.postMessage(main.Message.FRAME_HEIGHT_CHANGE, height);
|
|
852
|
+
}
|
|
853
|
+
}, {
|
|
854
|
+
key: "initializeHeightObserver",
|
|
855
|
+
value: function initializeHeightObserver() {
|
|
856
|
+
var _this3 = this;
|
|
857
|
+
|
|
858
|
+
if ("MutationObserver" in window) {
|
|
859
|
+
var onMutationObserved = function onMutationObserved() {
|
|
860
|
+
_this3.sendFrameHeight();
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
var target = document.querySelector('body'),
|
|
864
|
+
config = {
|
|
865
|
+
attributes: true,
|
|
866
|
+
attributeOldValue: false,
|
|
867
|
+
characterData: true,
|
|
868
|
+
characterDataOldValue: false,
|
|
869
|
+
childList: true,
|
|
870
|
+
subtree: true
|
|
871
|
+
};
|
|
872
|
+
this.heightMutationObserver = new MutationObserver(onMutationObserved);
|
|
873
|
+
Sdk.log('Create body MutationObserver');
|
|
874
|
+
this.heightMutationObserver.observe(target, config);
|
|
875
|
+
} else {
|
|
876
|
+
Sdk.warn('MutationObserver not available. Auto-height functionality disabled.');
|
|
877
|
+
}
|
|
878
|
+
}
|
|
812
879
|
}, {
|
|
813
880
|
key: "setupOptions",
|
|
814
881
|
value: function setupOptions(options) {
|
|
@@ -825,7 +892,7 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
825
892
|
}, {
|
|
826
893
|
key: "callFunction",
|
|
827
894
|
value: function callFunction(service, fun) {
|
|
828
|
-
var
|
|
895
|
+
var _this4 = this;
|
|
829
896
|
|
|
830
897
|
var callId = generateCallId();
|
|
831
898
|
|
|
@@ -844,13 +911,13 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
844
911
|
return new Promise(function (resolve) {
|
|
845
912
|
var onChannelMessage = function onChannelMessage(response) {
|
|
846
913
|
if (response.callId === callId) {
|
|
847
|
-
|
|
914
|
+
_this4.channel.unsubscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
848
915
|
|
|
849
916
|
return resolve(response.result);
|
|
850
917
|
}
|
|
851
918
|
};
|
|
852
919
|
|
|
853
|
-
|
|
920
|
+
_this4.channel.subscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
854
921
|
});
|
|
855
922
|
}
|
|
856
923
|
|
|
@@ -897,7 +964,7 @@ var BackofficeSdk = /*#__PURE__*/function (_Sdk) {
|
|
|
897
964
|
var _super2 = _createSuper(BackofficeSdk);
|
|
898
965
|
|
|
899
966
|
function BackofficeSdk() {
|
|
900
|
-
var
|
|
967
|
+
var _this5;
|
|
901
968
|
|
|
902
969
|
_classCallCheck(this, BackofficeSdk);
|
|
903
970
|
|
|
@@ -905,21 +972,22 @@ var BackofficeSdk = /*#__PURE__*/function (_Sdk) {
|
|
|
905
972
|
args[_key4] = arguments[_key4];
|
|
906
973
|
}
|
|
907
974
|
|
|
908
|
-
|
|
975
|
+
_this5 = _super2.call.apply(_super2, [this].concat(args));
|
|
909
976
|
|
|
910
|
-
_defineProperty(_assertThisInitialized(
|
|
977
|
+
_defineProperty(_assertThisInitialized(_this5), "instances", {
|
|
911
978
|
route: {
|
|
912
979
|
hash: '',
|
|
913
980
|
query: {}
|
|
914
981
|
},
|
|
915
|
-
orderpath: new BackofficeOrderpath(
|
|
916
|
-
catalog: new BackofficeCatalog(
|
|
917
|
-
user: new BackofficeUser(
|
|
918
|
-
tenant: new BackofficeTenant(
|
|
919
|
-
layout: new BackofficeLayout(
|
|
982
|
+
orderpath: new BackofficeOrderpath(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
983
|
+
catalog: new BackofficeCatalog(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
984
|
+
user: new BackofficeUser(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
985
|
+
tenant: new BackofficeTenant(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
986
|
+
layout: new BackofficeLayout(_this5.callFunction.bind(_assertThisInitialized(_this5))),
|
|
987
|
+
authorization: new BackofficeAuthorization(_this5.callFunction.bind(_assertThisInitialized(_this5)))
|
|
920
988
|
});
|
|
921
989
|
|
|
922
|
-
return
|
|
990
|
+
return _this5;
|
|
923
991
|
}
|
|
924
992
|
|
|
925
993
|
return _createClass(BackofficeSdk);
|
|
@@ -930,7 +998,7 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
|
|
|
930
998
|
var _super3 = _createSuper(ShopSdk);
|
|
931
999
|
|
|
932
1000
|
function ShopSdk() {
|
|
933
|
-
var
|
|
1001
|
+
var _this6;
|
|
934
1002
|
|
|
935
1003
|
_classCallCheck(this, ShopSdk);
|
|
936
1004
|
|
|
@@ -938,21 +1006,21 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
|
|
|
938
1006
|
args[_key5] = arguments[_key5];
|
|
939
1007
|
}
|
|
940
1008
|
|
|
941
|
-
|
|
1009
|
+
_this6 = _super3.call.apply(_super3, [this].concat(args));
|
|
942
1010
|
|
|
943
|
-
_defineProperty(_assertThisInitialized(
|
|
1011
|
+
_defineProperty(_assertThisInitialized(_this6), "instances", {
|
|
944
1012
|
route: {
|
|
945
1013
|
hash: '',
|
|
946
1014
|
query: {}
|
|
947
1015
|
},
|
|
948
|
-
cart: new ShopCart(
|
|
949
|
-
catalog: new ShopCatalog(
|
|
950
|
-
account: new ShopAccount(
|
|
951
|
-
utils: new ShopUtils(
|
|
952
|
-
config: new ShopConfig(
|
|
1016
|
+
cart: new ShopCart(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
1017
|
+
catalog: new ShopCatalog(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
1018
|
+
account: new ShopAccount(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
1019
|
+
utils: new ShopUtils(_this6.callFunction.bind(_assertThisInitialized(_this6))),
|
|
1020
|
+
config: new ShopConfig(_this6.callFunction.bind(_assertThisInitialized(_this6)))
|
|
953
1021
|
});
|
|
954
1022
|
|
|
955
|
-
return
|
|
1023
|
+
return _this6;
|
|
956
1024
|
}
|
|
957
1025
|
|
|
958
1026
|
return _createClass(ShopSdk);
|