dialogshift-webchat-sdk 2.9.7 → 2.9.9
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 +54 -35
- 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 +7 -4
- 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 +18 -18
|
@@ -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,
|
|
@@ -1696,7 +1714,9 @@ var WidgetManager = /** @class */ (function () {
|
|
|
1696
1714
|
if (_this.iframeBoxWidget.isVisible()) {
|
|
1697
1715
|
_this.iframeBoxWidget.hide();
|
|
1698
1716
|
}
|
|
1699
|
-
_this.chatButtonWidget
|
|
1717
|
+
if (_this.chatButtonWidget) {
|
|
1718
|
+
_this.chatButtonWidget.toggle(false);
|
|
1719
|
+
}
|
|
1700
1720
|
if (_this.getWebchatService()) {
|
|
1701
1721
|
_this.getWebchatService().setMinimized(true);
|
|
1702
1722
|
}
|
|
@@ -1968,7 +1988,7 @@ var ActionButtonNormalizer = /** @class */ (function () {
|
|
|
1968
1988
|
function ActionButtonNormalizer() {
|
|
1969
1989
|
}
|
|
1970
1990
|
ActionButtonNormalizer.normalize = function (data) {
|
|
1971
|
-
var locales = ['en', 'de', 'fr', 'it', 'ru', 'ar', 'nl', 'cz', 'hu', 'ro', 'es', 'da', 'pl', 'cs', 'sv'];
|
|
1991
|
+
var locales = ['en', 'de', 'fr', 'it', 'ru', 'ar', 'nl', 'cz', 'hu', 'ro', 'es', 'da', 'pl', 'cs', 'sv', 'pt', 'sk'];
|
|
1972
1992
|
var result = {
|
|
1973
1993
|
type: data.type,
|
|
1974
1994
|
successor: data.successor,
|
|
@@ -2523,7 +2543,7 @@ var UserService = /** @class */ (function () {
|
|
|
2523
2543
|
}
|
|
2524
2544
|
if (_this.loadGaContext) {
|
|
2525
2545
|
var ga = _ga_service__WEBPACK_IMPORTED_MODULE_3__.GaService.getGaValue();
|
|
2526
|
-
if (ga !== null) {
|
|
2546
|
+
if (ga !== null && context) {
|
|
2527
2547
|
context['_ga'] = ga;
|
|
2528
2548
|
}
|
|
2529
2549
|
}
|
|
@@ -2608,14 +2628,18 @@ var WebchatService = /** @class */ (function () {
|
|
|
2608
2628
|
if (options.teaserButton) {
|
|
2609
2629
|
message.teaserButton = options.teaserButton;
|
|
2610
2630
|
}
|
|
2611
|
-
this.targetWindow.contentWindow
|
|
2631
|
+
if (this.targetWindow.contentWindow) {
|
|
2632
|
+
this.targetWindow.contentWindow.postMessage(message, '*');
|
|
2633
|
+
}
|
|
2612
2634
|
};
|
|
2613
2635
|
WebchatService.prototype.setMinimized = function (isMinimized) {
|
|
2614
2636
|
var message = {
|
|
2615
2637
|
isMinimized: isMinimized,
|
|
2616
2638
|
type: 'setMinimized',
|
|
2617
2639
|
};
|
|
2618
|
-
this.targetWindow.contentWindow
|
|
2640
|
+
if (this.targetWindow.contentWindow) {
|
|
2641
|
+
this.targetWindow.contentWindow.postMessage(message, '*');
|
|
2642
|
+
}
|
|
2619
2643
|
};
|
|
2620
2644
|
return WebchatService;
|
|
2621
2645
|
}());
|
|
@@ -3260,9 +3284,6 @@ var IframeBoxWidget = /** @class */ (function (_super) {
|
|
|
3260
3284
|
IframeBoxWidget.prototype.setContent = function () {
|
|
3261
3285
|
throw new Error('Method is not allowed for an iframe');
|
|
3262
3286
|
};
|
|
3263
|
-
IframeBoxWidget.prototype.getContentElem = function () {
|
|
3264
|
-
return null;
|
|
3265
|
-
};
|
|
3266
3287
|
IframeBoxWidget.prototype.render = function () {
|
|
3267
3288
|
this.crossElem = this.createNode();
|
|
3268
3289
|
this.crossElem.classList.add(config.crossCls);
|
|
@@ -3273,8 +3294,9 @@ var IframeBoxWidget = /** @class */ (function (_super) {
|
|
|
3273
3294
|
IframeBoxWidget.prototype.bindEvents = function () {
|
|
3274
3295
|
var _this = this;
|
|
3275
3296
|
this.crossElem.addEventListener('click', function (event) {
|
|
3297
|
+
var _a, _b;
|
|
3276
3298
|
event.stopPropagation();
|
|
3277
|
-
_this.iframe.parentNode.removeChild(_this.iframe);
|
|
3299
|
+
(_b = (_a = _this.iframe) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(_this.iframe);
|
|
3278
3300
|
_this.iframe = null;
|
|
3279
3301
|
_this.hide();
|
|
3280
3302
|
});
|
|
@@ -3374,9 +3396,6 @@ var IframeWidget = /** @class */ (function (_super) {
|
|
|
3374
3396
|
IframeWidget.prototype.setContent = function () {
|
|
3375
3397
|
throw new Error('Method is not allowed for an iframe');
|
|
3376
3398
|
};
|
|
3377
|
-
IframeWidget.prototype.getContentElem = function () {
|
|
3378
|
-
return null;
|
|
3379
|
-
};
|
|
3380
3399
|
IframeWidget.prototype.getInitialElement = function () {
|
|
3381
3400
|
return this.initialElement;
|
|
3382
3401
|
};
|