dialogshift-webchat-sdk 2.9.6 → 2.9.8
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/bundles/dialogshift-webchat-sdk.umd.js +51 -34
- package/bundles/dialogshift-webchat-sdk.umd.js.map +1 -1
- package/dist/core/app.js +10 -6
- package/dist/core/app.js.map +1 -1
- package/dist/core/base-widget.d.ts +2 -2
- package/dist/core/base-widget.js +22 -10
- package/dist/core/base-widget.js.map +1 -1
- package/dist/core/utils.js +5 -4
- package/dist/core/utils.js.map +1 -1
- package/dist/core/widget-manager.js +4 -3
- package/dist/core/widget-manager.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/models/action-button.js +1 -1
- package/dist/models/action-button.js.map +1 -1
- package/dist/services/api.service.d.ts +2 -2
- package/dist/services/user.service.js +1 -1
- package/dist/services/user.service.js.map +1 -1
- package/dist/services/webchat.service.js +6 -2
- package/dist/services/webchat.service.js.map +1 -1
- package/dist/widgets/iframe-box.widget.d.ts +0 -1
- package/dist/widgets/iframe-box.widget.js +2 -4
- package/dist/widgets/iframe-box.widget.js.map +1 -1
- package/dist/widgets/iframe.widget.d.ts +0 -1
- package/dist/widgets/iframe.widget.js +0 -3
- package/dist/widgets/iframe.widget.js.map +1 -1
- package/dist/widgets/teaser.widget.js.map +1 -1
- package/dist/widgets/whatsapp-window.widget.js.map +1 -1
- package/package.json +15 -15
|
@@ -191,7 +191,9 @@ var App = /** @class */ (function () {
|
|
|
191
191
|
}
|
|
192
192
|
App.prototype.init = function () {
|
|
193
193
|
var _this = this;
|
|
194
|
-
this.options.context
|
|
194
|
+
if (this.options.context !== undefined) {
|
|
195
|
+
this.options.context['hostUrl'] = encodeURI(window.location.href);
|
|
196
|
+
}
|
|
195
197
|
if ((0,_utils__WEBPACK_IMPORTED_MODULE_4__.parseUrlParam)(window.location.href, 'ctrl') === 'forcenew') {
|
|
196
198
|
_services__WEBPACK_IMPORTED_MODULE_3__.UserService.deleteUser();
|
|
197
199
|
_services__WEBPACK_IMPORTED_MODULE_3__.TokenService.deleteToken();
|
|
@@ -383,7 +385,8 @@ var App = /** @class */ (function () {
|
|
|
383
385
|
};
|
|
384
386
|
App.prototype.loadConfig = function () {
|
|
385
387
|
var _this = this;
|
|
386
|
-
var
|
|
388
|
+
var _a;
|
|
389
|
+
var channel = ((_a = this.options.context) === null || _a === void 0 ? void 0 : _a.channel)
|
|
387
390
|
? this.options.context.channel
|
|
388
391
|
: 'pwa-embed';
|
|
389
392
|
return _services__WEBPACK_IMPORTED_MODULE_3__.ApiService.getConfig(this.options.id, _services__WEBPACK_IMPORTED_MODULE_3__.UserService.getCustomerId(), window.location.host, window.location.pathname, channel).then(function (data) {
|
|
@@ -395,7 +398,7 @@ var App = /** @class */ (function () {
|
|
|
395
398
|
_this.chatConfig.defaultLocale = _this.chatConfig.defaultLg;
|
|
396
399
|
delete _this.chatConfig.defaultLg;
|
|
397
400
|
}
|
|
398
|
-
if (_this.chatConfig.channelOverride) {
|
|
401
|
+
if (_this.chatConfig.channelOverride && _this.options.context !== undefined) {
|
|
399
402
|
_this.options.context.channel = _this.chatConfig.channelOverride;
|
|
400
403
|
}
|
|
401
404
|
_this.applyConfig();
|
|
@@ -471,7 +474,7 @@ var App = /** @class */ (function () {
|
|
|
471
474
|
if (_services__WEBPACK_IMPORTED_MODULE_3__.UserService.getCustomerId()) {
|
|
472
475
|
_services__WEBPACK_IMPORTED_MODULE_3__.ApiService.setContext(_services__WEBPACK_IMPORTED_MODULE_3__.UserService.getCustomerId(), key, value).then(resolve, reject);
|
|
473
476
|
}
|
|
474
|
-
else {
|
|
477
|
+
else if (_this.options.context !== undefined) {
|
|
475
478
|
_this.options.context[key] = value;
|
|
476
479
|
}
|
|
477
480
|
});
|
|
@@ -543,6 +546,7 @@ var App = /** @class */ (function () {
|
|
|
543
546
|
};
|
|
544
547
|
App.prototype.loadChat = function () {
|
|
545
548
|
var _this = this;
|
|
549
|
+
var _a;
|
|
546
550
|
var load = function () {
|
|
547
551
|
var iframeWidget = _this.widgetManager.getIframeWidget();
|
|
548
552
|
if (!iframeWidget.isLoaded()) {
|
|
@@ -557,10 +561,10 @@ var App = /** @class */ (function () {
|
|
|
557
561
|
};
|
|
558
562
|
var iframeWidget = this.widgetManager.getIframeWidget();
|
|
559
563
|
if (!iframeWidget || !iframeWidget.isRendered()) {
|
|
560
|
-
var channel = this.options.context.channel
|
|
564
|
+
var channel = ((_a = this.options.context) === null || _a === void 0 ? void 0 : _a.channel)
|
|
561
565
|
? this.options.context.channel
|
|
562
566
|
: 'pwa-embed';
|
|
563
|
-
var
|
|
567
|
+
var _b = this.options, id = _b.id, initialElement = _b.initialElement, locale = _b.locale;
|
|
564
568
|
this.widgetManager.renderIframeWidget({
|
|
565
569
|
id: id,
|
|
566
570
|
initialElement: initialElement,
|
|
@@ -710,10 +714,14 @@ var BaseWidget = /** @class */ (function (_super) {
|
|
|
710
714
|
var handler = function () {
|
|
711
715
|
boxElem.removeEventListener('animationend', handler);
|
|
712
716
|
boxElem.classList.add(config.visibleCls);
|
|
713
|
-
|
|
717
|
+
if (_this.effects.appear) {
|
|
718
|
+
boxElem.classList.remove(config.fxCls[_this.effects.appear]);
|
|
719
|
+
}
|
|
714
720
|
};
|
|
715
721
|
boxElem.addEventListener('animationend', handler);
|
|
716
|
-
|
|
722
|
+
if (_this.effects.appear) {
|
|
723
|
+
boxElem.classList.add(config.fxCls[_this.effects.appear]);
|
|
724
|
+
}
|
|
717
725
|
if (_this.effects.sound) {
|
|
718
726
|
_services_audio_service__WEBPACK_IMPORTED_MODULE_1__.AudioService.playSound(_this.effects.sound);
|
|
719
727
|
}
|
|
@@ -721,7 +729,9 @@ var BaseWidget = /** @class */ (function (_super) {
|
|
|
721
729
|
};
|
|
722
730
|
BaseWidget.prototype.hideAnimateNode = function (boxElem) {
|
|
723
731
|
boxElem.style.removeProperty('animationDelay');
|
|
724
|
-
|
|
732
|
+
if (this.effects.appear) {
|
|
733
|
+
boxElem.classList.remove(config.fxCls[this.effects.appear]);
|
|
734
|
+
}
|
|
725
735
|
};
|
|
726
736
|
BaseWidget.prototype.startAttention = function () {
|
|
727
737
|
var _this = this;
|
|
@@ -729,16 +739,22 @@ var BaseWidget = /** @class */ (function (_super) {
|
|
|
729
739
|
var boxElem = _this.getBoxElem();
|
|
730
740
|
var handler = function () {
|
|
731
741
|
boxElem.removeEventListener('animationend', handler);
|
|
732
|
-
|
|
742
|
+
if (_this.effects.attention) {
|
|
743
|
+
boxElem.classList.remove(config.fxCls[_this.effects.attention]);
|
|
744
|
+
}
|
|
733
745
|
};
|
|
734
746
|
boxElem.addEventListener('animationend', handler);
|
|
735
|
-
|
|
747
|
+
if (_this.effects.attention) {
|
|
748
|
+
boxElem.classList.add(config.fxCls[_this.effects.attention]);
|
|
749
|
+
}
|
|
736
750
|
}, this.effects.attentionInterval);
|
|
737
751
|
};
|
|
738
752
|
BaseWidget.prototype.stopAttention = function () {
|
|
739
753
|
this.attentionInterval && clearInterval(this.attentionInterval);
|
|
740
754
|
var boxElem = this.getBoxElem();
|
|
741
|
-
|
|
755
|
+
if (this.effects.attention) {
|
|
756
|
+
boxElem.classList.remove(config.fxCls[this.effects.attention]);
|
|
757
|
+
}
|
|
742
758
|
};
|
|
743
759
|
BaseWidget.prototype.isDestroyed = function () {
|
|
744
760
|
return this.destroyed;
|
|
@@ -769,7 +785,7 @@ var BaseWidget = /** @class */ (function (_super) {
|
|
|
769
785
|
else {
|
|
770
786
|
classes = __spreadArray(__spreadArray([], classes, true), baseCls, true);
|
|
771
787
|
}
|
|
772
|
-
classes.forEach(function (item) { return _this.boxElem.classList.add(item); });
|
|
788
|
+
classes.forEach(function (item) { var _a; return (_a = _this.boxElem) === null || _a === void 0 ? void 0 : _a.classList.add(item); });
|
|
773
789
|
}
|
|
774
790
|
return this.boxElem;
|
|
775
791
|
};
|
|
@@ -810,7 +826,7 @@ var BaseWidget = /** @class */ (function (_super) {
|
|
|
810
826
|
}
|
|
811
827
|
};
|
|
812
828
|
BaseWidget.prototype.isRendered = function () {
|
|
813
|
-
return this.boxElem && document.body.contains(this.boxElem);
|
|
829
|
+
return this.boxElem !== undefined && document.body.contains(this.boxElem);
|
|
814
830
|
};
|
|
815
831
|
BaseWidget.prototype.show = function () {
|
|
816
832
|
var _this = this;
|
|
@@ -854,12 +870,12 @@ var BaseWidget = /** @class */ (function (_super) {
|
|
|
854
870
|
if (contentElem && contentElem.parentNode) {
|
|
855
871
|
contentElem.parentNode.removeChild(contentElem);
|
|
856
872
|
}
|
|
857
|
-
this.contentElem =
|
|
873
|
+
this.contentElem = undefined;
|
|
858
874
|
var boxElem = this.getBoxElem();
|
|
859
875
|
if (boxElem && boxElem.parentNode) {
|
|
860
876
|
boxElem.parentNode.removeChild(boxElem);
|
|
861
877
|
}
|
|
862
|
-
this.boxElem =
|
|
878
|
+
this.boxElem = undefined;
|
|
863
879
|
this.destroyed = true;
|
|
864
880
|
this.fire('destroy');
|
|
865
881
|
};
|
|
@@ -1376,15 +1392,15 @@ var isFontLoaded = function (fontName) {
|
|
|
1376
1392
|
var canvas = document.createElement('canvas');
|
|
1377
1393
|
var context = canvas.getContext('2d');
|
|
1378
1394
|
var text = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
1395
|
+
if (context === null) {
|
|
1396
|
+
return false;
|
|
1397
|
+
}
|
|
1379
1398
|
context.font = '72px monospace';
|
|
1380
1399
|
var baselineSize = context.measureText(text).width;
|
|
1381
1400
|
context.font = "72px ".concat(fontName, ", monospace");
|
|
1382
1401
|
var newSize = context.measureText(text).width;
|
|
1383
1402
|
canvas = null;
|
|
1384
|
-
|
|
1385
|
-
return false;
|
|
1386
|
-
}
|
|
1387
|
-
return true;
|
|
1403
|
+
return newSize !== baselineSize;
|
|
1388
1404
|
};
|
|
1389
1405
|
var loadOpenSans = function () { };
|
|
1390
1406
|
var isObject = function (item) {
|
|
@@ -1393,6 +1409,7 @@ var isObject = function (item) {
|
|
|
1393
1409
|
var mergeDeep = function (target, source) {
|
|
1394
1410
|
var output = Object.assign({}, target);
|
|
1395
1411
|
if (isObject(target) && isObject(source)) {
|
|
1412
|
+
// @ts-ignore
|
|
1396
1413
|
Object.keys(source).forEach(function (key) {
|
|
1397
1414
|
var _a, _b;
|
|
1398
1415
|
if (isObject(source[key])) {
|
|
@@ -1464,7 +1481,7 @@ var __assign = (undefined && undefined.__assign) || function () {
|
|
|
1464
1481
|
var getTeaserText = function (_a) {
|
|
1465
1482
|
var teaserText = _a.teaserText, locale = _a.locale, defaultLocale = _a.defaultLocale;
|
|
1466
1483
|
var content = 'Can I help you?';
|
|
1467
|
-
if (teaserText) {
|
|
1484
|
+
if (teaserText && locale !== undefined) {
|
|
1468
1485
|
if (teaserText[locale]) {
|
|
1469
1486
|
content = teaserText[locale];
|
|
1470
1487
|
}
|
|
@@ -1536,7 +1553,7 @@ var WidgetManager = /** @class */ (function () {
|
|
|
1536
1553
|
var locale = options.locale;
|
|
1537
1554
|
var buttonText = chatConfig.buttonText, defaultLocale = chatConfig.defaultLocale, effects = chatConfig.effects;
|
|
1538
1555
|
var content = '';
|
|
1539
|
-
if (buttonText) {
|
|
1556
|
+
if (buttonText && locale !== undefined) {
|
|
1540
1557
|
if (buttonText[locale]) {
|
|
1541
1558
|
content = buttonText[locale];
|
|
1542
1559
|
}
|
|
@@ -1651,9 +1668,10 @@ var WidgetManager = /** @class */ (function () {
|
|
|
1651
1668
|
});
|
|
1652
1669
|
};
|
|
1653
1670
|
WidgetManager.prototype.renderUnreadWidget = function (options, chatConfig) {
|
|
1671
|
+
var _a;
|
|
1654
1672
|
var effects = chatConfig.effects;
|
|
1655
1673
|
this.unreadWidget = new _widgets_index__WEBPACK_IMPORTED_MODULE_0__.UnreadWidget({
|
|
1656
|
-
visible: options.unreadCounter
|
|
1674
|
+
visible: ((_a = options.unreadCounter) !== null && _a !== void 0 ? _a : 0) > 0,
|
|
1657
1675
|
renderTo: this.wrapperWidget.getBoxElem(),
|
|
1658
1676
|
unreadCounter: options.unreadCounter,
|
|
1659
1677
|
effects: effects === null || effects === void 0 ? void 0 : effects.unreadCounter,
|
|
@@ -1968,7 +1986,7 @@ var ActionButtonNormalizer = /** @class */ (function () {
|
|
|
1968
1986
|
function ActionButtonNormalizer() {
|
|
1969
1987
|
}
|
|
1970
1988
|
ActionButtonNormalizer.normalize = function (data) {
|
|
1971
|
-
var locales = ['en', 'de', 'fr', 'it', 'ru', 'ar', 'nl', 'cz', 'hu', 'ro', 'es', 'da', 'pl', 'cs'];
|
|
1989
|
+
var locales = ['en', 'de', 'fr', 'it', 'ru', 'ar', 'nl', 'cz', 'hu', 'ro', 'es', 'da', 'pl', 'cs', 'sv', 'pt', 'sk'];
|
|
1972
1990
|
var result = {
|
|
1973
1991
|
type: data.type,
|
|
1974
1992
|
successor: data.successor,
|
|
@@ -2523,7 +2541,7 @@ var UserService = /** @class */ (function () {
|
|
|
2523
2541
|
}
|
|
2524
2542
|
if (_this.loadGaContext) {
|
|
2525
2543
|
var ga = _ga_service__WEBPACK_IMPORTED_MODULE_3__.GaService.getGaValue();
|
|
2526
|
-
if (ga !== null) {
|
|
2544
|
+
if (ga !== null && context) {
|
|
2527
2545
|
context['_ga'] = ga;
|
|
2528
2546
|
}
|
|
2529
2547
|
}
|
|
@@ -2608,14 +2626,18 @@ var WebchatService = /** @class */ (function () {
|
|
|
2608
2626
|
if (options.teaserButton) {
|
|
2609
2627
|
message.teaserButton = options.teaserButton;
|
|
2610
2628
|
}
|
|
2611
|
-
this.targetWindow.contentWindow
|
|
2629
|
+
if (this.targetWindow.contentWindow) {
|
|
2630
|
+
this.targetWindow.contentWindow.postMessage(message, '*');
|
|
2631
|
+
}
|
|
2612
2632
|
};
|
|
2613
2633
|
WebchatService.prototype.setMinimized = function (isMinimized) {
|
|
2614
2634
|
var message = {
|
|
2615
2635
|
isMinimized: isMinimized,
|
|
2616
2636
|
type: 'setMinimized',
|
|
2617
2637
|
};
|
|
2618
|
-
this.targetWindow.contentWindow
|
|
2638
|
+
if (this.targetWindow.contentWindow) {
|
|
2639
|
+
this.targetWindow.contentWindow.postMessage(message, '*');
|
|
2640
|
+
}
|
|
2619
2641
|
};
|
|
2620
2642
|
return WebchatService;
|
|
2621
2643
|
}());
|
|
@@ -3260,9 +3282,6 @@ var IframeBoxWidget = /** @class */ (function (_super) {
|
|
|
3260
3282
|
IframeBoxWidget.prototype.setContent = function () {
|
|
3261
3283
|
throw new Error('Method is not allowed for an iframe');
|
|
3262
3284
|
};
|
|
3263
|
-
IframeBoxWidget.prototype.getContentElem = function () {
|
|
3264
|
-
return null;
|
|
3265
|
-
};
|
|
3266
3285
|
IframeBoxWidget.prototype.render = function () {
|
|
3267
3286
|
this.crossElem = this.createNode();
|
|
3268
3287
|
this.crossElem.classList.add(config.crossCls);
|
|
@@ -3273,8 +3292,9 @@ var IframeBoxWidget = /** @class */ (function (_super) {
|
|
|
3273
3292
|
IframeBoxWidget.prototype.bindEvents = function () {
|
|
3274
3293
|
var _this = this;
|
|
3275
3294
|
this.crossElem.addEventListener('click', function (event) {
|
|
3295
|
+
var _a, _b;
|
|
3276
3296
|
event.stopPropagation();
|
|
3277
|
-
_this.iframe.parentNode.removeChild(_this.iframe);
|
|
3297
|
+
(_b = (_a = _this.iframe) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(_this.iframe);
|
|
3278
3298
|
_this.iframe = null;
|
|
3279
3299
|
_this.hide();
|
|
3280
3300
|
});
|
|
@@ -3374,9 +3394,6 @@ var IframeWidget = /** @class */ (function (_super) {
|
|
|
3374
3394
|
IframeWidget.prototype.setContent = function () {
|
|
3375
3395
|
throw new Error('Method is not allowed for an iframe');
|
|
3376
3396
|
};
|
|
3377
|
-
IframeWidget.prototype.getContentElem = function () {
|
|
3378
|
-
return null;
|
|
3379
|
-
};
|
|
3380
3397
|
IframeWidget.prototype.getInitialElement = function () {
|
|
3381
3398
|
return this.initialElement;
|
|
3382
3399
|
};
|