@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
|
@@ -201,6 +201,8 @@ exports.Errors = exports.Message = void 0;
|
|
|
201
201
|
Message["METHOD_CALL_ERROR"] = "one:method:error";
|
|
202
202
|
Message["METHOD_RESULT"] = "one:method:result";
|
|
203
203
|
Message["NAVIGATION_PUSH"] = "one:navigation:push";
|
|
204
|
+
Message["FRAME_HEIGHT_REQUEST"] = "one:frameheight:request";
|
|
205
|
+
Message["FRAME_HEIGHT_CHANGE"] = "one:frameheight:change";
|
|
204
206
|
})(exports.Message || (exports.Message = {}));
|
|
205
207
|
(function (Errors) {
|
|
206
208
|
Errors["METHOD_DOES_NOT_EXISTS"] = "Method does not exists";
|
|
@@ -354,15 +356,15 @@ var BackofficeUser = /*#__PURE__*/function (_BaseCallClass2) {
|
|
|
354
356
|
|
|
355
357
|
return _createClass(BackofficeUser);
|
|
356
358
|
}(BaseCallClass);
|
|
357
|
-
var
|
|
358
|
-
_inherits(
|
|
359
|
+
var BackofficeTenant = /*#__PURE__*/function (_BaseCallClass3) {
|
|
360
|
+
_inherits(BackofficeTenant, _BaseCallClass3);
|
|
359
361
|
|
|
360
|
-
var _super3 = _createSuper(
|
|
362
|
+
var _super3 = _createSuper(BackofficeTenant);
|
|
361
363
|
|
|
362
|
-
function
|
|
364
|
+
function BackofficeTenant() {
|
|
363
365
|
var _this3;
|
|
364
366
|
|
|
365
|
-
_classCallCheck(this,
|
|
367
|
+
_classCallCheck(this, BackofficeTenant);
|
|
366
368
|
|
|
367
369
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
368
370
|
args[_key3] = arguments[_key3];
|
|
@@ -370,22 +372,28 @@ var BackofficeOrderpath = /*#__PURE__*/function (_BaseCallClass3) {
|
|
|
370
372
|
|
|
371
373
|
_this3 = _super3.call.apply(_super3, [this].concat(args));
|
|
372
374
|
|
|
373
|
-
_defineProperty(_assertThisInitialized(_this3), "serviceName", '
|
|
375
|
+
_defineProperty(_assertThisInitialized(_this3), "serviceName", 'tenant');
|
|
376
|
+
|
|
377
|
+
_defineProperty(_assertThisInitialized(_this3), "tenantKey", void 0);
|
|
378
|
+
|
|
379
|
+
_defineProperty(_assertThisInitialized(_this3), "language", void 0);
|
|
380
|
+
|
|
381
|
+
_defineProperty(_assertThisInitialized(_this3), "currency", void 0);
|
|
374
382
|
|
|
375
383
|
return _this3;
|
|
376
384
|
}
|
|
377
385
|
|
|
378
|
-
return _createClass(
|
|
386
|
+
return _createClass(BackofficeTenant);
|
|
379
387
|
}(BaseCallClass);
|
|
380
|
-
var
|
|
381
|
-
_inherits(
|
|
388
|
+
var BackofficeOrderpath = /*#__PURE__*/function (_BaseCallClass4) {
|
|
389
|
+
_inherits(BackofficeOrderpath, _BaseCallClass4);
|
|
382
390
|
|
|
383
|
-
var _super4 = _createSuper(
|
|
391
|
+
var _super4 = _createSuper(BackofficeOrderpath);
|
|
384
392
|
|
|
385
|
-
function
|
|
393
|
+
function BackofficeOrderpath() {
|
|
386
394
|
var _this4;
|
|
387
395
|
|
|
388
|
-
_classCallCheck(this,
|
|
396
|
+
_classCallCheck(this, BackofficeOrderpath);
|
|
389
397
|
|
|
390
398
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
391
399
|
args[_key4] = arguments[_key4];
|
|
@@ -393,13 +401,36 @@ var BackofficeLayout = /*#__PURE__*/function (_BaseCallClass4) {
|
|
|
393
401
|
|
|
394
402
|
_this4 = _super4.call.apply(_super4, [this].concat(args));
|
|
395
403
|
|
|
396
|
-
_defineProperty(_assertThisInitialized(_this4), "serviceName", '
|
|
397
|
-
|
|
398
|
-
_defineProperty(_assertThisInitialized(_this4), "isAsideOpened", void 0);
|
|
404
|
+
_defineProperty(_assertThisInitialized(_this4), "serviceName", 'orderpath');
|
|
399
405
|
|
|
400
406
|
return _this4;
|
|
401
407
|
}
|
|
402
408
|
|
|
409
|
+
return _createClass(BackofficeOrderpath);
|
|
410
|
+
}(BaseCallClass);
|
|
411
|
+
var BackofficeLayout = /*#__PURE__*/function (_BaseCallClass5) {
|
|
412
|
+
_inherits(BackofficeLayout, _BaseCallClass5);
|
|
413
|
+
|
|
414
|
+
var _super5 = _createSuper(BackofficeLayout);
|
|
415
|
+
|
|
416
|
+
function BackofficeLayout() {
|
|
417
|
+
var _this5;
|
|
418
|
+
|
|
419
|
+
_classCallCheck(this, BackofficeLayout);
|
|
420
|
+
|
|
421
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
422
|
+
args[_key5] = arguments[_key5];
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
_this5 = _super5.call.apply(_super5, [this].concat(args));
|
|
426
|
+
|
|
427
|
+
_defineProperty(_assertThisInitialized(_this5), "serviceName", 'layout');
|
|
428
|
+
|
|
429
|
+
_defineProperty(_assertThisInitialized(_this5), "isAsideOpened", void 0);
|
|
430
|
+
|
|
431
|
+
return _this5;
|
|
432
|
+
}
|
|
433
|
+
|
|
403
434
|
return _createClass(BackofficeLayout);
|
|
404
435
|
}(BaseCallClass);
|
|
405
436
|
|
|
@@ -694,6 +725,10 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
694
725
|
|
|
695
726
|
_defineProperty(_assertThisInitialized(_this), "channel", void 0);
|
|
696
727
|
|
|
728
|
+
_defineProperty(_assertThisInitialized(_this), "autoheight", true);
|
|
729
|
+
|
|
730
|
+
_defineProperty(_assertThisInitialized(_this), "heightMutationObserver", null);
|
|
731
|
+
|
|
697
732
|
_defineProperty(_assertThisInitialized(_this), "origin", void 0);
|
|
698
733
|
|
|
699
734
|
_defineProperty(_assertThisInitialized(_this), "isInitialized", false);
|
|
@@ -740,8 +775,20 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
740
775
|
_this.emit(SdkInternalEvents.UPDATE, payload);
|
|
741
776
|
});
|
|
742
777
|
|
|
778
|
+
_this.channel.subscribe(main.Message.FRAME_HEIGHT_REQUEST, function (payload) {
|
|
779
|
+
if (_this.autoheight) {
|
|
780
|
+
Sdk.log('Request for iframe height');
|
|
781
|
+
|
|
782
|
+
_this.sendFrameHeight();
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
|
|
743
786
|
_this.channel.connect().then(function () {
|
|
744
787
|
Sdk.log('Connected with ONe SDK');
|
|
788
|
+
|
|
789
|
+
if (_this.autoheight) {
|
|
790
|
+
_this.initializeHeightObserver();
|
|
791
|
+
}
|
|
745
792
|
});
|
|
746
793
|
|
|
747
794
|
_this.setupOptions(options);
|
|
@@ -765,6 +812,40 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
765
812
|
});
|
|
766
813
|
}
|
|
767
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
|
+
}
|
|
768
849
|
}, {
|
|
769
850
|
key: "setupOptions",
|
|
770
851
|
value: function setupOptions(options) {
|
|
@@ -772,12 +853,16 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
772
853
|
if (typeof options.debug !== 'undefined') {
|
|
773
854
|
Sdk.debug = options.debug;
|
|
774
855
|
}
|
|
856
|
+
|
|
857
|
+
if (typeof options.autoheight !== 'undefined') {
|
|
858
|
+
this.autoheight = options.autoheight;
|
|
859
|
+
}
|
|
775
860
|
}
|
|
776
861
|
}
|
|
777
862
|
}, {
|
|
778
863
|
key: "callFunction",
|
|
779
864
|
value: function callFunction(service, fun) {
|
|
780
|
-
var
|
|
865
|
+
var _this4 = this;
|
|
781
866
|
|
|
782
867
|
var callId = generateCallId();
|
|
783
868
|
|
|
@@ -796,13 +881,13 @@ var Sdk = /*#__PURE__*/function (_Events) {
|
|
|
796
881
|
return new Promise(function (resolve) {
|
|
797
882
|
var onChannelMessage = function onChannelMessage(response) {
|
|
798
883
|
if (response.callId === callId) {
|
|
799
|
-
|
|
884
|
+
_this4.channel.unsubscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
800
885
|
|
|
801
886
|
return resolve(response.result);
|
|
802
887
|
}
|
|
803
888
|
};
|
|
804
889
|
|
|
805
|
-
|
|
890
|
+
_this4.channel.subscribe(main.Message.METHOD_RESULT, onChannelMessage);
|
|
806
891
|
});
|
|
807
892
|
}
|
|
808
893
|
|
|
@@ -849,7 +934,7 @@ var BackofficeSdk = /*#__PURE__*/function (_Sdk) {
|
|
|
849
934
|
var _super2 = _createSuper(BackofficeSdk);
|
|
850
935
|
|
|
851
936
|
function BackofficeSdk() {
|
|
852
|
-
var
|
|
937
|
+
var _this5;
|
|
853
938
|
|
|
854
939
|
_classCallCheck(this, BackofficeSdk);
|
|
855
940
|
|
|
@@ -857,20 +942,21 @@ var BackofficeSdk = /*#__PURE__*/function (_Sdk) {
|
|
|
857
942
|
args[_key4] = arguments[_key4];
|
|
858
943
|
}
|
|
859
944
|
|
|
860
|
-
|
|
945
|
+
_this5 = _super2.call.apply(_super2, [this].concat(args));
|
|
861
946
|
|
|
862
|
-
_defineProperty(_assertThisInitialized(
|
|
947
|
+
_defineProperty(_assertThisInitialized(_this5), "instances", {
|
|
863
948
|
route: {
|
|
864
949
|
hash: '',
|
|
865
950
|
query: {}
|
|
866
951
|
},
|
|
867
|
-
orderpath: new BackofficeOrderpath(
|
|
868
|
-
catalog: new BackofficeCatalog(
|
|
869
|
-
user: new BackofficeUser(
|
|
870
|
-
|
|
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)))
|
|
871
957
|
});
|
|
872
958
|
|
|
873
|
-
return
|
|
959
|
+
return _this5;
|
|
874
960
|
}
|
|
875
961
|
|
|
876
962
|
return _createClass(BackofficeSdk);
|
|
@@ -881,7 +967,7 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
|
|
|
881
967
|
var _super3 = _createSuper(ShopSdk);
|
|
882
968
|
|
|
883
969
|
function ShopSdk() {
|
|
884
|
-
var
|
|
970
|
+
var _this6;
|
|
885
971
|
|
|
886
972
|
_classCallCheck(this, ShopSdk);
|
|
887
973
|
|
|
@@ -889,21 +975,21 @@ var ShopSdk = /*#__PURE__*/function (_Sdk2) {
|
|
|
889
975
|
args[_key5] = arguments[_key5];
|
|
890
976
|
}
|
|
891
977
|
|
|
892
|
-
|
|
978
|
+
_this6 = _super3.call.apply(_super3, [this].concat(args));
|
|
893
979
|
|
|
894
|
-
_defineProperty(_assertThisInitialized(
|
|
980
|
+
_defineProperty(_assertThisInitialized(_this6), "instances", {
|
|
895
981
|
route: {
|
|
896
982
|
hash: '',
|
|
897
983
|
query: {}
|
|
898
984
|
},
|
|
899
|
-
cart: new ShopCart(
|
|
900
|
-
catalog: new ShopCatalog(
|
|
901
|
-
account: new ShopAccount(
|
|
902
|
-
utils: new ShopUtils(
|
|
903
|
-
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)))
|
|
904
990
|
});
|
|
905
991
|
|
|
906
|
-
return
|
|
992
|
+
return _this6;
|
|
907
993
|
}
|
|
908
994
|
|
|
909
995
|
return _createClass(ShopSdk);
|