@one-commerce/sdk-core 1.10.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 +121 -35
- 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 +122 -36
- 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 +49 -17
- package/lib/cjs/backofficeServices.js.map +1 -1
- package/lib/cjs/index.js +75 -20
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/backofficeServices.js +14 -0
- package/lib/esm/backofficeServices.js.map +1 -1
- package/lib/esm/index.js +50 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/types/backofficeServices.d.ts +6 -0
- package/lib/types/backofficeServices.d.ts.map +1 -1
- package/lib/types/index.d.ts +8 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SdkCore = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _classCallCheck(instance, Constructor) {
|
|
@@ -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";
|
|
@@ -360,15 +362,15 @@
|
|
|
360
362
|
|
|
361
363
|
return _createClass(BackofficeUser);
|
|
362
364
|
}(BaseCallClass);
|
|
363
|
-
var
|
|
364
|
-
_inherits(
|
|
365
|
+
var BackofficeTenant = /*#__PURE__*/function (_BaseCallClass3) {
|
|
366
|
+
_inherits(BackofficeTenant, _BaseCallClass3);
|
|
365
367
|
|
|
366
|
-
var _super3 = _createSuper(
|
|
368
|
+
var _super3 = _createSuper(BackofficeTenant);
|
|
367
369
|
|
|
368
|
-
function
|
|
370
|
+
function BackofficeTenant() {
|
|
369
371
|
var _this3;
|
|
370
372
|
|
|
371
|
-
_classCallCheck(this,
|
|
373
|
+
_classCallCheck(this, BackofficeTenant);
|
|
372
374
|
|
|
373
375
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
374
376
|
args[_key3] = arguments[_key3];
|
|
@@ -376,22 +378,28 @@
|
|
|
376
378
|
|
|
377
379
|
_this3 = _super3.call.apply(_super3, [this].concat(args));
|
|
378
380
|
|
|
379
|
-
_defineProperty(_assertThisInitialized(_this3), "serviceName", '
|
|
381
|
+
_defineProperty(_assertThisInitialized(_this3), "serviceName", 'tenant');
|
|
382
|
+
|
|
383
|
+
_defineProperty(_assertThisInitialized(_this3), "tenantKey", void 0);
|
|
384
|
+
|
|
385
|
+
_defineProperty(_assertThisInitialized(_this3), "language", void 0);
|
|
386
|
+
|
|
387
|
+
_defineProperty(_assertThisInitialized(_this3), "currency", void 0);
|
|
380
388
|
|
|
381
389
|
return _this3;
|
|
382
390
|
}
|
|
383
391
|
|
|
384
|
-
return _createClass(
|
|
392
|
+
return _createClass(BackofficeTenant);
|
|
385
393
|
}(BaseCallClass);
|
|
386
|
-
var
|
|
387
|
-
_inherits(
|
|
394
|
+
var BackofficeOrderpath = /*#__PURE__*/function (_BaseCallClass4) {
|
|
395
|
+
_inherits(BackofficeOrderpath, _BaseCallClass4);
|
|
388
396
|
|
|
389
|
-
var _super4 = _createSuper(
|
|
397
|
+
var _super4 = _createSuper(BackofficeOrderpath);
|
|
390
398
|
|
|
391
|
-
function
|
|
399
|
+
function BackofficeOrderpath() {
|
|
392
400
|
var _this4;
|
|
393
401
|
|
|
394
|
-
_classCallCheck(this,
|
|
402
|
+
_classCallCheck(this, BackofficeOrderpath);
|
|
395
403
|
|
|
396
404
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
397
405
|
args[_key4] = arguments[_key4];
|
|
@@ -399,13 +407,36 @@
|
|
|
399
407
|
|
|
400
408
|
_this4 = _super4.call.apply(_super4, [this].concat(args));
|
|
401
409
|
|
|
402
|
-
_defineProperty(_assertThisInitialized(_this4), "serviceName", '
|
|
403
|
-
|
|
404
|
-
_defineProperty(_assertThisInitialized(_this4), "isAsideOpened", void 0);
|
|
410
|
+
_defineProperty(_assertThisInitialized(_this4), "serviceName", 'orderpath');
|
|
405
411
|
|
|
406
412
|
return _this4;
|
|
407
413
|
}
|
|
408
414
|
|
|
415
|
+
return _createClass(BackofficeOrderpath);
|
|
416
|
+
}(BaseCallClass);
|
|
417
|
+
var BackofficeLayout = /*#__PURE__*/function (_BaseCallClass5) {
|
|
418
|
+
_inherits(BackofficeLayout, _BaseCallClass5);
|
|
419
|
+
|
|
420
|
+
var _super5 = _createSuper(BackofficeLayout);
|
|
421
|
+
|
|
422
|
+
function BackofficeLayout() {
|
|
423
|
+
var _this5;
|
|
424
|
+
|
|
425
|
+
_classCallCheck(this, BackofficeLayout);
|
|
426
|
+
|
|
427
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
428
|
+
args[_key5] = arguments[_key5];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
_this5 = _super5.call.apply(_super5, [this].concat(args));
|
|
432
|
+
|
|
433
|
+
_defineProperty(_assertThisInitialized(_this5), "serviceName", 'layout');
|
|
434
|
+
|
|
435
|
+
_defineProperty(_assertThisInitialized(_this5), "isAsideOpened", void 0);
|
|
436
|
+
|
|
437
|
+
return _this5;
|
|
438
|
+
}
|
|
439
|
+
|
|
409
440
|
return _createClass(BackofficeLayout);
|
|
410
441
|
}(BaseCallClass);
|
|
411
442
|
|
|
@@ -700,6 +731,10 @@
|
|
|
700
731
|
|
|
701
732
|
_defineProperty(_assertThisInitialized(_this), "channel", void 0);
|
|
702
733
|
|
|
734
|
+
_defineProperty(_assertThisInitialized(_this), "autoheight", true);
|
|
735
|
+
|
|
736
|
+
_defineProperty(_assertThisInitialized(_this), "heightMutationObserver", null);
|
|
737
|
+
|
|
703
738
|
_defineProperty(_assertThisInitialized(_this), "origin", void 0);
|
|
704
739
|
|
|
705
740
|
_defineProperty(_assertThisInitialized(_this), "isInitialized", false);
|
|
@@ -746,8 +781,20 @@
|
|
|
746
781
|
_this.emit(SdkInternalEvents.UPDATE, payload);
|
|
747
782
|
});
|
|
748
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
|
+
|
|
749
792
|
_this.channel.connect().then(function () {
|
|
750
793
|
Sdk.log('Connected with ONe SDK');
|
|
794
|
+
|
|
795
|
+
if (_this.autoheight) {
|
|
796
|
+
_this.initializeHeightObserver();
|
|
797
|
+
}
|
|
751
798
|
});
|
|
752
799
|
|
|
753
800
|
_this.setupOptions(options);
|
|
@@ -771,6 +818,40 @@
|
|
|
771
818
|
});
|
|
772
819
|
}
|
|
773
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
|
+
}
|
|
774
855
|
}, {
|
|
775
856
|
key: "setupOptions",
|
|
776
857
|
value: function setupOptions(options) {
|
|
@@ -778,12 +859,16 @@
|
|
|
778
859
|
if (typeof options.debug !== 'undefined') {
|
|
779
860
|
Sdk.debug = options.debug;
|
|
780
861
|
}
|
|
862
|
+
|
|
863
|
+
if (typeof options.autoheight !== 'undefined') {
|
|
864
|
+
this.autoheight = options.autoheight;
|
|
865
|
+
}
|
|
781
866
|
}
|
|
782
867
|
}
|
|
783
868
|
}, {
|
|
784
869
|
key: "callFunction",
|
|
785
870
|
value: function callFunction(service, fun) {
|
|
786
|
-
var
|
|
871
|
+
var _this4 = this;
|
|
787
872
|
|
|
788
873
|
var callId = generateCallId();
|
|
789
874
|
|
|
@@ -802,13 +887,13 @@
|
|
|
802
887
|
return new Promise(function (resolve) {
|
|
803
888
|
var onChannelMessage = function onChannelMessage(response) {
|
|
804
889
|
if (response.callId === callId) {
|
|
805
|
-
|
|
890
|
+
_this4.channel.unsubscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
806
891
|
|
|
807
892
|
return resolve(response.result);
|
|
808
893
|
}
|
|
809
894
|
};
|
|
810
895
|
|
|
811
|
-
|
|
896
|
+
_this4.channel.subscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
812
897
|
});
|
|
813
898
|
}
|
|
814
899
|
|
|
@@ -855,7 +940,7 @@
|
|
|
855
940
|
var _super2 = _createSuper(BackofficeSdk);
|
|
856
941
|
|
|
857
942
|
function BackofficeSdk() {
|
|
858
|
-
var
|
|
943
|
+
var _this5;
|
|
859
944
|
|
|
860
945
|
_classCallCheck(this, BackofficeSdk);
|
|
861
946
|
|
|
@@ -863,20 +948,21 @@
|
|
|
863
948
|
args[_key4] = arguments[_key4];
|
|
864
949
|
}
|
|
865
950
|
|
|
866
|
-
|
|
951
|
+
_this5 = _super2.call.apply(_super2, [this].concat(args));
|
|
867
952
|
|
|
868
|
-
_defineProperty(_assertThisInitialized(
|
|
953
|
+
_defineProperty(_assertThisInitialized(_this5), "instances", {
|
|
869
954
|
route: {
|
|
870
955
|
hash: '',
|
|
871
956
|
query: {}
|
|
872
957
|
},
|
|
873
|
-
orderpath: new BackofficeOrderpath(
|
|
874
|
-
catalog: new BackofficeCatalog(
|
|
875
|
-
user: new BackofficeUser(
|
|
876
|
-
|
|
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)))
|
|
877
963
|
});
|
|
878
964
|
|
|
879
|
-
return
|
|
965
|
+
return _this5;
|
|
880
966
|
}
|
|
881
967
|
|
|
882
968
|
return _createClass(BackofficeSdk);
|
|
@@ -887,7 +973,7 @@
|
|
|
887
973
|
var _super3 = _createSuper(ShopSdk);
|
|
888
974
|
|
|
889
975
|
function ShopSdk() {
|
|
890
|
-
var
|
|
976
|
+
var _this6;
|
|
891
977
|
|
|
892
978
|
_classCallCheck(this, ShopSdk);
|
|
893
979
|
|
|
@@ -895,21 +981,21 @@
|
|
|
895
981
|
args[_key5] = arguments[_key5];
|
|
896
982
|
}
|
|
897
983
|
|
|
898
|
-
|
|
984
|
+
_this6 = _super3.call.apply(_super3, [this].concat(args));
|
|
899
985
|
|
|
900
|
-
_defineProperty(_assertThisInitialized(
|
|
986
|
+
_defineProperty(_assertThisInitialized(_this6), "instances", {
|
|
901
987
|
route: {
|
|
902
988
|
hash: '',
|
|
903
989
|
query: {}
|
|
904
990
|
},
|
|
905
|
-
cart: new ShopCart(
|
|
906
|
-
catalog: new ShopCatalog(
|
|
907
|
-
account: new ShopAccount(
|
|
908
|
-
utils: new ShopUtils(
|
|
909
|
-
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)))
|
|
910
996
|
});
|
|
911
997
|
|
|
912
|
-
return
|
|
998
|
+
return _this6;
|
|
913
999
|
}
|
|
914
1000
|
|
|
915
1001
|
return _createClass(ShopSdk);
|