@microsoft/omnichannel-chat-widget 1.0.6-main.ffb4e2a → 1.1.1-main.1f4a6a7
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/cjs/common/Constants.js +2 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +20 -15
- package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +25 -15
- package/lib/cjs/common/utils.js +17 -2
- package/lib/cjs/components/draggable/DraggableChatWidget.js +168 -0
- package/lib/cjs/components/draggable/DraggableEventEmitter.js +74 -0
- package/lib/cjs/components/draggable/DraggableEventNames.js +14 -0
- package/lib/cjs/components/draggable/DraggableEventReceiver.js +34 -0
- package/lib/cjs/components/draggable/IDraggableElementPosition.js +1 -0
- package/lib/cjs/components/draggable/IDraggableElementPositionDelta.js +1 -0
- package/lib/cjs/components/draggable/IDraggableEvent.js +1 -0
- package/lib/cjs/components/footerstateful/FooterStateful.js +2 -2
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +21 -12
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/interfaces/IWebChatTranscriptConfig.js +1 -0
- package/lib/cjs/components/headerstateful/HeaderStateful.js +27 -0
- package/lib/cjs/components/livechatwidget/common/createDownloadTranscriptProps.js +27 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +13 -2
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +15 -5
- package/lib/cjs/components/livechatwidget/common/startChat.js +1 -1
- package/lib/cjs/components/livechatwidget/interfaces/IDraggableChatWidgetProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +58 -30
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +6 -0
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +48 -13
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +5 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles.js +10 -0
- package/lib/cjs/plugins/createChatTranscript.js +548 -0
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +18 -14
- package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +25 -15
- package/lib/esm/common/utils.js +15 -1
- package/lib/esm/components/draggable/DraggableChatWidget.js +158 -0
- package/lib/esm/components/draggable/DraggableEventEmitter.js +64 -0
- package/lib/esm/components/draggable/DraggableEventNames.js +7 -0
- package/lib/esm/components/draggable/DraggableEventReceiver.js +25 -0
- package/lib/esm/components/draggable/IDraggableElementPosition.js +1 -0
- package/lib/esm/components/draggable/IDraggableElementPositionDelta.js +1 -0
- package/lib/esm/components/draggable/IDraggableEvent.js +1 -0
- package/lib/esm/components/footerstateful/FooterStateful.js +2 -2
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +22 -13
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/interfaces/IWebChatTranscriptConfig.js +1 -0
- package/lib/esm/components/headerstateful/HeaderStateful.js +27 -0
- package/lib/esm/components/livechatwidget/common/createDownloadTranscriptProps.js +20 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +13 -2
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +15 -5
- package/lib/esm/components/livechatwidget/common/startChat.js +1 -1
- package/lib/esm/components/livechatwidget/interfaces/IDraggableChatWidgetProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +58 -30
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +6 -0
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +48 -13
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles.js +3 -0
- package/lib/esm/plugins/createChatTranscript.js +543 -0
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +1 -0
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/draggable/DraggableChatWidget.d.ts +9 -0
- package/lib/types/components/draggable/DraggableEventEmitter.d.ts +27 -0
- package/lib/types/components/draggable/DraggableEventNames.d.ts +6 -0
- package/lib/types/components/draggable/DraggableEventReceiver.d.ts +27 -0
- package/lib/types/components/draggable/IDraggableElementPosition.d.ts +5 -0
- package/lib/types/components/draggable/IDraggableElementPositionDelta.d.ts +5 -0
- package/lib/types/components/draggable/IDraggableEvent.d.ts +12 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +2 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/interfaces/IDownloadTranscriptProps.d.ts +5 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/interfaces/IWebChatTranscriptConfig.d.ts +13 -0
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +12 -0
- package/lib/types/components/livechatwidget/common/createDownloadTranscriptProps.d.ts +24 -0
- package/lib/types/components/livechatwidget/interfaces/IDraggableChatWidgetProps.d.ts +10 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/WebChatContainerStateful.d.ts +2 -2
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +3 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSentMessageAnchorStyles.d.ts +2 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
- package/lib/types/plugins/createChatTranscript.d.ts +2 -0
- package/package.json +4 -4
|
@@ -114,6 +114,7 @@ _defineProperty(Constants, "PopoutCacheSuffix", "popout");
|
|
|
114
114
|
_defineProperty(Constants, "LWICheckOnVisibilityTimeout", 3 * 60 * 1000);
|
|
115
115
|
// 3 minute
|
|
116
116
|
// Popup mode custom context response event message name
|
|
117
|
+
_defineProperty(Constants, "InitContextParamsRequest", "initContextParamsRequest");
|
|
117
118
|
_defineProperty(Constants, "InitContextParamsResponse", "initContextParamsResponse");
|
|
118
119
|
const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
119
120
|
exports.Regex = Regex;
|
|
@@ -155,6 +156,7 @@ _defineProperty(HtmlAttributeNames, "listItem", "LI");
|
|
|
155
156
|
_defineProperty(HtmlAttributeNames, "unorderedList", "UL");
|
|
156
157
|
_defineProperty(HtmlAttributeNames, "div", "div");
|
|
157
158
|
_defineProperty(HtmlAttributeNames, "aTagName", "a");
|
|
159
|
+
_defineProperty(HtmlAttributeNames, "pTagName", "p");
|
|
158
160
|
_defineProperty(HtmlAttributeNames, "noopenerTag", "noopener");
|
|
159
161
|
_defineProperty(HtmlAttributeNames, "noreferrerTag", "noreferrer");
|
|
160
162
|
_defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
|
|
@@ -3,30 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.defaultClientDataStoreProvider = void 0;
|
|
6
|
+
exports.isCookieAllowed = exports.defaultClientDataStoreProvider = void 0;
|
|
7
7
|
var _TelemetryConstants = require("../../telemetry/TelemetryConstants");
|
|
8
|
+
var _Constants = require("../../Constants");
|
|
8
9
|
var _TelemetryHelper = require("../../telemetry/TelemetryHelper");
|
|
9
10
|
var _defaultInMemoryDataStore = require("./defaultInMemoryDataStore");
|
|
10
|
-
var _Constants = require("../../Constants");
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
12
|
|
|
13
|
+
const isCookieAllowed = () => {
|
|
14
|
+
try {
|
|
15
|
+
localStorage;
|
|
16
|
+
sessionStorage;
|
|
17
|
+
return true;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (!window.TPCWarningLogged) {
|
|
20
|
+
console.warn("Third party cookies blocked.");
|
|
21
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
22
|
+
Event: _TelemetryConstants.TelemetryEvent.ThirdPartyCookiesBlocked,
|
|
23
|
+
Description: "Third party cookies are blocked. Cannot access local storage or session storage."
|
|
24
|
+
});
|
|
25
|
+
window.TPCWarningLogged = true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.isCookieAllowed = isCookieAllowed;
|
|
13
31
|
const defaultClientDataStoreProvider = function () {
|
|
14
32
|
let cacheTtlinMins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
15
33
|
let storageType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _Constants.StorageType.localStorage;
|
|
16
34
|
let ttlInMs = 0;
|
|
17
|
-
const isCookieAllowed = () => {
|
|
18
|
-
try {
|
|
19
|
-
localStorage;
|
|
20
|
-
sessionStorage;
|
|
21
|
-
return true;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (!window.TPCWarningShown) {
|
|
24
|
-
console.warn("Third party cookies blocked.");
|
|
25
|
-
window.TPCWarningShown = true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
35
|
if (ttlInMs == 0) {
|
|
31
36
|
ttlInMs = cacheTtlinMins * 60 * 1000;
|
|
32
37
|
}
|
|
@@ -164,6 +164,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
164
164
|
TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
|
|
165
165
|
TelemetryEvent["SetBotAuthProviderDisplayCard"] = "SetBotAuthProviderDisplayCard";
|
|
166
166
|
TelemetryEvent["SetBotAuthProviderNotFound"] = "SetBotAuthProviderNotFound";
|
|
167
|
+
TelemetryEvent["ThirdPartyCookiesBlocked"] = "ThirdPartyCookiesBlocked";
|
|
167
168
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
168
169
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
169
170
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -231,6 +232,7 @@ class TelemetryConstants {
|
|
|
231
232
|
case TelemetryEvent.OutOfOfficePaneLoaded:
|
|
232
233
|
case TelemetryEvent.ConfirmationPaneLoaded:
|
|
233
234
|
case TelemetryEvent.ProactiveChatPaneLoaded:
|
|
235
|
+
case TelemetryEvent.ThirdPartyCookiesBlocked:
|
|
234
236
|
return ScenarioType.LOAD;
|
|
235
237
|
case TelemetryEvent.PrechatSubmitted:
|
|
236
238
|
case TelemetryEvent.LCWChatButtonClicked:
|
|
@@ -36,15 +36,16 @@ class TelemetryHelper {
|
|
|
36
36
|
static populateBasicProperties(level,
|
|
37
37
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
38
|
telemetryData) {
|
|
39
|
-
var _TelemetryManager$Int, _TelemetryManager$Int2, _TelemetryManager$Int3, _TelemetryManager$Int4, _TelemetryManager$Int5, _TelemetryManager$Int6, _TelemetryManager$Int7;
|
|
39
|
+
var _TelemetryManager$Int, _TelemetryManager$Int2, _TelemetryManager$Int3, _TelemetryManager$Int4, _TelemetryManager$Int5, _TelemetryManager$Int6, _TelemetryManager$Int7, _TelemetryManager$Int8;
|
|
40
40
|
return {
|
|
41
41
|
WidgetId: ((_TelemetryManager$Int = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.widgetId) ?? "",
|
|
42
42
|
ChatId: ((_TelemetryManager$Int2 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.chatId) ?? "",
|
|
43
43
|
ChannelId: ((_TelemetryManager$Int3 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int3 === void 0 ? void 0 : _TelemetryManager$Int3.channelId) ?? "lcw2.0",
|
|
44
44
|
ConversationId: ((_TelemetryManager$Int4 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int4 === void 0 ? void 0 : _TelemetryManager$Int4.conversationId) ?? "",
|
|
45
45
|
OrganizationId: ((_TelemetryManager$Int5 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int5 === void 0 ? void 0 : _TelemetryManager$Int5.orgId) ?? "",
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
OrganizationUrl: ((_TelemetryManager$Int6 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int6 === void 0 ? void 0 : _TelemetryManager$Int6.orgUrl) ?? "",
|
|
47
|
+
LCWRuntimeId: ((_TelemetryManager$Int7 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int7 === void 0 ? void 0 : _TelemetryManager$Int7.lcwRuntimeId) ?? "",
|
|
48
|
+
CurrentRequestId: ((_TelemetryManager$Int8 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int8 === void 0 ? void 0 : _TelemetryManager$Int8.currentRequestId) ?? "",
|
|
48
49
|
LogLevel: level
|
|
49
50
|
};
|
|
50
51
|
}
|
|
@@ -79,22 +80,22 @@ class TelemetryHelper {
|
|
|
79
80
|
static conformToConfigValidationContract(level, input) {
|
|
80
81
|
const payload = input.payload;
|
|
81
82
|
return TelemetryHelper.populate(level, payload, event => {
|
|
82
|
-
var _TelemetryManager$
|
|
83
|
+
var _TelemetryManager$Int9, _TelemetryManager$Int10, _TelemetryManager$Int11;
|
|
83
84
|
event.Event = payload.Event;
|
|
84
85
|
event.RequestId = payload.RequestId;
|
|
85
|
-
event.LCWVersion = (_TelemetryManager$
|
|
86
|
+
event.LCWVersion = (_TelemetryManager$Int9 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int9 === void 0 ? void 0 : _TelemetryManager$Int9.environmentVersion;
|
|
86
87
|
event.CloudType = payload.CloudType;
|
|
87
|
-
event.Domain = (_TelemetryManager$
|
|
88
|
+
event.Domain = (_TelemetryManager$Int10 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int10 === void 0 ? void 0 : _TelemetryManager$Int10.hostName;
|
|
88
89
|
event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
|
|
89
90
|
event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
|
|
90
|
-
event.Language = ((_TelemetryManager$
|
|
91
|
+
event.Language = ((_TelemetryManager$Int11 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int11 === void 0 ? void 0 : _TelemetryManager$Int11.chatWidgetLocaleLCID) || "";
|
|
91
92
|
event.Description = payload.Data;
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
static conformToLoadContract(level, input) {
|
|
95
96
|
const payload = input.payload;
|
|
96
97
|
return TelemetryHelper.populate(level, payload, event => {
|
|
97
|
-
var _TelemetryManager$
|
|
98
|
+
var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14;
|
|
98
99
|
event.Event = payload.Event;
|
|
99
100
|
event.Description = payload.Description;
|
|
100
101
|
event.ResourcePath = payload.ResourcePath;
|
|
@@ -103,17 +104,17 @@ class TelemetryHelper {
|
|
|
103
104
|
event.ChatType = payload.ChatType;
|
|
104
105
|
event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
|
|
105
106
|
event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
|
|
106
|
-
event.OCChatSDKVersion = ((_TelemetryManager$
|
|
107
|
-
event.OCChatWidgetVersion = ((_TelemetryManager$
|
|
108
|
-
event.OCChatComponentsVersion = ((_TelemetryManager$
|
|
107
|
+
event.OCChatSDKVersion = ((_TelemetryManager$Int12 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : _TelemetryManager$Int12.OCChatSDKVersion) ?? "";
|
|
108
|
+
event.OCChatWidgetVersion = ((_TelemetryManager$Int13 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.chatWidgetVersion) ?? "";
|
|
109
|
+
event.OCChatComponentsVersion = ((_TelemetryManager$Int14 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : _TelemetryManager$Int14.chatComponentVersion) ?? "";
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
static conformToIC3ClientContract(level, input) {
|
|
112
113
|
const payload = input.payload;
|
|
113
114
|
return TelemetryHelper.populate(level, payload, event => {
|
|
114
|
-
var _TelemetryManager$
|
|
115
|
+
var _TelemetryManager$Int15;
|
|
115
116
|
event.Event = payload.Event;
|
|
116
|
-
event.IC3ClientVersion = (_TelemetryManager$
|
|
117
|
+
event.IC3ClientVersion = (_TelemetryManager$Int15 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int15 === void 0 ? void 0 : _TelemetryManager$Int15.IC3ClientVersion;
|
|
117
118
|
event.SubscriptionId = payload.SubscriptionId;
|
|
118
119
|
event.EndpointUrl = payload.EndpointUrl;
|
|
119
120
|
event.EndpointId = payload.EndpointId;
|
|
@@ -166,6 +167,15 @@ class TelemetryHelper {
|
|
|
166
167
|
}
|
|
167
168
|
static addWidgetDataToTelemetry(telemetryConfig, telemetryInternalData) {
|
|
168
169
|
const telemetryDataLocal = telemetryInternalData;
|
|
170
|
+
if (!(telemetryConfig !== null && telemetryConfig !== void 0 && telemetryConfig.appId) || (telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.appId.trim()) === "") {
|
|
171
|
+
throw new Error("TelemetryConfig.appId is not set");
|
|
172
|
+
}
|
|
173
|
+
if (!(telemetryConfig !== null && telemetryConfig !== void 0 && telemetryConfig.orgId) || (telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgId.trim()) === "") {
|
|
174
|
+
throw new Error("TelemetryConfig.orgId is not set");
|
|
175
|
+
}
|
|
176
|
+
if (!(telemetryConfig !== null && telemetryConfig !== void 0 && telemetryConfig.orgUrl) || (telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgUrl.trim()) === "") {
|
|
177
|
+
throw new Error("TelemetryConfig.orgUrl is not set");
|
|
178
|
+
}
|
|
169
179
|
telemetryDataLocal.widgetId = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.appId;
|
|
170
180
|
telemetryDataLocal.orgId = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgId;
|
|
171
181
|
telemetryDataLocal.orgUrl = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgUrl;
|
|
@@ -220,14 +230,14 @@ _defineProperty(TelemetryHelper, "logActionEvent", (logLevel, payload) => {
|
|
|
220
230
|
_omnichannelChatComponents.BroadcastService.postMessage(telemetryEvent);
|
|
221
231
|
});
|
|
222
232
|
_defineProperty(TelemetryHelper, "logSDKEvent", (logLevel, payload) => {
|
|
223
|
-
var _TelemetryManager$
|
|
233
|
+
var _TelemetryManager$Int16;
|
|
224
234
|
const telemetryEvent = {
|
|
225
235
|
eventName: (payload === null || payload === void 0 ? void 0 : payload.Event) ?? "",
|
|
226
236
|
logLevel: logLevel,
|
|
227
237
|
payload: {
|
|
228
238
|
...payload,
|
|
229
239
|
TransactionId: (0, _utils.newGuid)(),
|
|
230
|
-
RequestId: (_TelemetryManager$
|
|
240
|
+
RequestId: (_TelemetryManager$Int16 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int16 === void 0 ? void 0 : _TelemetryManager$Int16.currentRequestId
|
|
231
241
|
}
|
|
232
242
|
};
|
|
233
243
|
_omnichannelChatComponents.BroadcastService.postMessage(telemetryEvent);
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
6
|
+
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
var _Constants = require("./Constants");
|
|
8
8
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
9
9
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -416,4 +416,19 @@ const checkContactIdError = e => {
|
|
|
416
416
|
_omnichannelChatComponents.BroadcastService.postMessage(contactIdNotFoundErrorEvent);
|
|
417
417
|
}
|
|
418
418
|
};
|
|
419
|
-
exports.checkContactIdError = checkContactIdError;
|
|
419
|
+
exports.checkContactIdError = checkContactIdError;
|
|
420
|
+
const createFileAndDownload = (fileName, blobData, mimeType) => {
|
|
421
|
+
const aElement = document.createElement("a");
|
|
422
|
+
const blob = new Blob([blobData], {
|
|
423
|
+
type: mimeType
|
|
424
|
+
});
|
|
425
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
426
|
+
aElement.setAttribute(_Constants.HtmlAttributeNames.href, objectUrl);
|
|
427
|
+
aElement.setAttribute(_Constants.HtmlAttributeNames.download, fileName);
|
|
428
|
+
aElement.setAttribute(_Constants.HtmlAttributeNames.ariaHidden, "true");
|
|
429
|
+
aElement.style.display = "none";
|
|
430
|
+
document.body.appendChild(aElement);
|
|
431
|
+
aElement.click();
|
|
432
|
+
document.body.removeChild(aElement);
|
|
433
|
+
};
|
|
434
|
+
exports.createFileAndDownload = createFileAndDownload;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _DraggableEventReceiver = _interopRequireDefault(require("./DraggableEventReceiver"));
|
|
9
|
+
var _DraggableEventNames = _interopRequireDefault(require("./DraggableEventNames"));
|
|
10
|
+
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
11
|
+
var _ConversationState = require("../../contexts/common/ConversationState");
|
|
12
|
+
var _utils = require("../../common/utils");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
const DraggableChatWidget = props => {
|
|
17
|
+
const [state] = (0, _useChatContextStore.default)();
|
|
18
|
+
const [initialPosition, setInitialPosition] = (0, _react.useState)({
|
|
19
|
+
offsetLeft: 0,
|
|
20
|
+
offsetTop: 0
|
|
21
|
+
});
|
|
22
|
+
const [cachedPosition, setCachedPosition] = (0, _react.useState)(undefined);
|
|
23
|
+
const [position, setPosition] = (0, _react.useState)({
|
|
24
|
+
offsetLeft: 0,
|
|
25
|
+
offsetTop: 0
|
|
26
|
+
});
|
|
27
|
+
const [delta, setDelta] = (0, _react.useState)({
|
|
28
|
+
left: 0,
|
|
29
|
+
top: 0
|
|
30
|
+
});
|
|
31
|
+
const repositionElement = (draggableElement, offsetLeft, offsetTop) => {
|
|
32
|
+
draggableElement.style.left = `${offsetLeft}px`;
|
|
33
|
+
draggableElement.style.top = `${offsetTop}px`;
|
|
34
|
+
};
|
|
35
|
+
const calculateOffsetsWithinViewport = (0, _react.useCallback)((id, offset, delta) => {
|
|
36
|
+
const draggableElement = document.getElementById(id);
|
|
37
|
+
const positionRelativeToViewport = draggableElement.getBoundingClientRect();
|
|
38
|
+
if ((0, _utils.isNullOrUndefined)(draggableElement) || (0, _utils.isNullOrUndefined)(positionRelativeToViewport) || (0, _utils.isNullOrUndefined)(offset.offsetLeft) || (0, _utils.isNullOrUndefined)(offset.offsetTop)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let offsetLeft = offset.offsetLeft;
|
|
42
|
+
let offsetTop = offset.offsetTop;
|
|
43
|
+
|
|
44
|
+
// Widget size larger than viewport would not have any restriction
|
|
45
|
+
if (positionRelativeToViewport.width > window.innerWidth) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (positionRelativeToViewport.height > window.innerHeight) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Ensures widget is within viewport
|
|
53
|
+
if (positionRelativeToViewport.x < 0) {
|
|
54
|
+
offsetLeft = 0 - delta.left;
|
|
55
|
+
}
|
|
56
|
+
if (positionRelativeToViewport.y < 0) {
|
|
57
|
+
offsetTop = 0 - delta.top;
|
|
58
|
+
}
|
|
59
|
+
if (positionRelativeToViewport.x + positionRelativeToViewport.width > window.innerWidth) {
|
|
60
|
+
offsetLeft = window.innerWidth - positionRelativeToViewport.width - delta.left;
|
|
61
|
+
}
|
|
62
|
+
if (positionRelativeToViewport.y + positionRelativeToViewport.height > window.innerHeight) {
|
|
63
|
+
offsetTop = window.innerHeight - positionRelativeToViewport.height - delta.top;
|
|
64
|
+
}
|
|
65
|
+
repositionElement(draggableElement, offsetLeft, offsetTop);
|
|
66
|
+
setPosition({
|
|
67
|
+
offsetLeft,
|
|
68
|
+
offsetTop
|
|
69
|
+
});
|
|
70
|
+
}, []);
|
|
71
|
+
const resetPosition = (0, _react.useCallback)(targetPosition => {
|
|
72
|
+
calculateOffsetsWithinViewport(props.elementId, targetPosition, delta); // Ensure viewport restriction
|
|
73
|
+
}, [delta]);
|
|
74
|
+
(0, _react.useEffect)(() => {
|
|
75
|
+
if (props.disabled === true) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const cacheInitialPosition = () => {
|
|
79
|
+
const draggableElement = document.getElementById(props.elementId);
|
|
80
|
+
const offsetLeft = draggableElement.offsetLeft;
|
|
81
|
+
const offsetTop = draggableElement.offsetTop;
|
|
82
|
+
setInitialPosition({
|
|
83
|
+
offsetLeft,
|
|
84
|
+
offsetTop
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const calculateOffsets = () => {
|
|
88
|
+
const draggableElement = document.getElementById(props.elementId);
|
|
89
|
+
const offsetLeft = draggableElement.offsetLeft;
|
|
90
|
+
const offsetTop = draggableElement.offsetTop;
|
|
91
|
+
|
|
92
|
+
// Calculates the delta between the position of the widget and the position of the widget relative to the viewport which will be used for repositioning
|
|
93
|
+
const positionRelativeToViewport = draggableElement.getBoundingClientRect();
|
|
94
|
+
const left = positionRelativeToViewport.left - offsetLeft;
|
|
95
|
+
const top = positionRelativeToViewport.top - offsetTop;
|
|
96
|
+
setDelta({
|
|
97
|
+
left,
|
|
98
|
+
top
|
|
99
|
+
});
|
|
100
|
+
calculateOffsetsWithinViewport(props.elementId, {
|
|
101
|
+
offsetLeft,
|
|
102
|
+
offsetTop
|
|
103
|
+
}, {
|
|
104
|
+
left,
|
|
105
|
+
top
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
calculateOffsets();
|
|
109
|
+
cacheInitialPosition();
|
|
110
|
+
window.addEventListener("resize", calculateOffsets);
|
|
111
|
+
return () => {
|
|
112
|
+
window.removeEventListener("resize", calculateOffsets);
|
|
113
|
+
};
|
|
114
|
+
}, [props.disabled]);
|
|
115
|
+
(0, _react.useEffect)(() => {
|
|
116
|
+
if (props.disabled === true) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (state.appStates.conversationState == _ConversationState.ConversationState.Closed) {
|
|
120
|
+
resetPosition(initialPosition);
|
|
121
|
+
} else if (state.appStates.isMinimized) {
|
|
122
|
+
const draggableElement = document.getElementById(props.elementId);
|
|
123
|
+
const offsetLeft = draggableElement.offsetLeft;
|
|
124
|
+
const offsetTop = draggableElement.offsetTop;
|
|
125
|
+
if (!cachedPosition) {
|
|
126
|
+
setCachedPosition({
|
|
127
|
+
offsetLeft,
|
|
128
|
+
offsetTop
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
resetPosition(initialPosition);
|
|
132
|
+
} else if (!(0, _utils.isNullOrUndefined)(state.appStates.isMinimized) && !state.appStates.isMinimized) {
|
|
133
|
+
if (cachedPosition) {
|
|
134
|
+
resetPosition(cachedPosition);
|
|
135
|
+
setCachedPosition(undefined);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, [props.disabled, state.appStates.isMinimized, state.appStates.conversationState, initialPosition, cachedPosition]);
|
|
139
|
+
const onEvent = (0, _react.useCallback)(event => {
|
|
140
|
+
if (event.eventName === _DraggableEventNames.default.Dragging) {
|
|
141
|
+
if (event.offset) {
|
|
142
|
+
const offsetLeft = position.offsetLeft + event.offset.x;
|
|
143
|
+
const offsetTop = position.offsetTop + event.offset.y;
|
|
144
|
+
|
|
145
|
+
// Update position via DOM manipulation to prevent <Stack/> continuously rendering on style change causing high CPU spike
|
|
146
|
+
const draggableElement = document.getElementById(props.elementId);
|
|
147
|
+
repositionElement(draggableElement, offsetLeft, offsetTop);
|
|
148
|
+
setPosition({
|
|
149
|
+
offsetLeft,
|
|
150
|
+
offsetTop
|
|
151
|
+
});
|
|
152
|
+
calculateOffsetsWithinViewport(props.elementId, {
|
|
153
|
+
offsetLeft,
|
|
154
|
+
offsetTop
|
|
155
|
+
}, delta);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, [position, delta]);
|
|
159
|
+
if (props.disabled === true) {
|
|
160
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.children);
|
|
161
|
+
}
|
|
162
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_DraggableEventReceiver.default, {
|
|
163
|
+
channel: props.channel ?? "lcw",
|
|
164
|
+
onEvent: onEvent
|
|
165
|
+
}, props.children));
|
|
166
|
+
};
|
|
167
|
+
var _default = DraggableChatWidget;
|
|
168
|
+
exports.default = _default;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _DraggableEventNames = _interopRequireDefault(require("./DraggableEventNames"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
+
/**
|
|
13
|
+
* Trigger component which would send IDraggableEvent to the receiver to update the draggable component position
|
|
14
|
+
*
|
|
15
|
+
* @param props IDraggableEventEmitterProps
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
const DraggableEventEmitter = props => {
|
|
19
|
+
const [initialized, setInitialized] = (0, _react.useState)(false);
|
|
20
|
+
const postMessage = (0, _react.useCallback)(data => {
|
|
21
|
+
const targetWindow = props.targetWindow ?? window;
|
|
22
|
+
targetWindow.postMessage(data, "*");
|
|
23
|
+
}, [props.targetWindow]);
|
|
24
|
+
const dragStart = (0, _react.useCallback)(event => {
|
|
25
|
+
postMessage({
|
|
26
|
+
channel: props.channel,
|
|
27
|
+
eventName: _DraggableEventNames.default.DragStart
|
|
28
|
+
});
|
|
29
|
+
let cursor = {
|
|
30
|
+
x: event.screenX,
|
|
31
|
+
y: event.screenY
|
|
32
|
+
}; // Cursor init position
|
|
33
|
+
const dragging = event => {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
const newX = event.screenX;
|
|
36
|
+
const newY = event.screenY;
|
|
37
|
+
const offset = {
|
|
38
|
+
x: newX - cursor.x,
|
|
39
|
+
y: newY - cursor.y
|
|
40
|
+
}; // Calculate cursor position diff
|
|
41
|
+
cursor = {
|
|
42
|
+
...cursor,
|
|
43
|
+
x: newX,
|
|
44
|
+
y: newY
|
|
45
|
+
}; // Update cursor new position
|
|
46
|
+
|
|
47
|
+
postMessage({
|
|
48
|
+
channel: props.channel,
|
|
49
|
+
eventName: _DraggableEventNames.default.Dragging,
|
|
50
|
+
offset
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const dragEnd = () => {
|
|
54
|
+
postMessage({
|
|
55
|
+
channel: props.channel,
|
|
56
|
+
eventName: _DraggableEventNames.default.DragEnd
|
|
57
|
+
});
|
|
58
|
+
document.removeEventListener("mousemove", dragging);
|
|
59
|
+
document.removeEventListener("mouseup", dragEnd);
|
|
60
|
+
};
|
|
61
|
+
document.addEventListener("mousemove", dragging);
|
|
62
|
+
document.addEventListener("mouseup", dragEnd);
|
|
63
|
+
}, [props.channel]);
|
|
64
|
+
(0, _react.useEffect)(() => {
|
|
65
|
+
if (!initialized && props.elementId) {
|
|
66
|
+
const element = document.getElementById(props.elementId);
|
|
67
|
+
element === null || element === void 0 ? void 0 : element.addEventListener("mousedown", dragStart);
|
|
68
|
+
setInitialized(true);
|
|
69
|
+
}
|
|
70
|
+
}, [dragStart, props.elementId, initialized]);
|
|
71
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", props.children, " ");
|
|
72
|
+
};
|
|
73
|
+
var _default = DraggableEventEmitter;
|
|
74
|
+
exports.default = _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var DraggableEventNames;
|
|
8
|
+
(function (DraggableEventNames) {
|
|
9
|
+
DraggableEventNames["DragStart"] = "DragStart";
|
|
10
|
+
DraggableEventNames["Dragging"] = "Dragging";
|
|
11
|
+
DraggableEventNames["DragEnd"] = "DragEnd";
|
|
12
|
+
})(DraggableEventNames || (DraggableEventNames = {}));
|
|
13
|
+
var _default = DraggableEventNames;
|
|
14
|
+
exports.default = _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
+
/**
|
|
11
|
+
* Component which would listen to DraggableEvent, update the component position or react accordingly.
|
|
12
|
+
*
|
|
13
|
+
* @param props IDraggableEventReceiverProps
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
const DraggableEventReceiver = props => {
|
|
17
|
+
(0, _react.useEffect)(() => {
|
|
18
|
+
const listener = event => {
|
|
19
|
+
const {
|
|
20
|
+
data
|
|
21
|
+
} = event;
|
|
22
|
+
if (data.channel && props.channel && data.channel === props.channel) {
|
|
23
|
+
props.onEvent(data);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
window.addEventListener("message", listener);
|
|
27
|
+
return () => {
|
|
28
|
+
window.removeEventListener("message", listener);
|
|
29
|
+
};
|
|
30
|
+
}, [props]);
|
|
31
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", props.children, " ");
|
|
32
|
+
};
|
|
33
|
+
var _default = DraggableEventReceiver;
|
|
34
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -22,7 +22,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
22
22
|
const FooterStateful = props => {
|
|
23
23
|
var _footerProps$controlP3, _footerProps$controlP4;
|
|
24
24
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
25
|
-
// hideFooterDisplay - the purpose of this is to keep the footer always "active",
|
|
25
|
+
// hideFooterDisplay - the purpose of this is to keep the footer always "active",
|
|
26
26
|
// but hide it visually in certain states (e.g., loading state) and show in some other states (e.g. active state).
|
|
27
27
|
// The reason for this approach is to make sure that state variables for audio notification work correctly after minimizing
|
|
28
28
|
const {
|
|
@@ -42,7 +42,7 @@ const FooterStateful = props => {
|
|
|
42
42
|
Event: _TelemetryConstants.TelemetryEvent.DownloadTranscriptButtonClicked,
|
|
43
43
|
Description: "Download Transcript button clicked."
|
|
44
44
|
});
|
|
45
|
-
await (0, _DownloadTranscriptStateful.downloadTranscript)(chatSDK, downloadTranscriptProps
|
|
45
|
+
await (0, _DownloadTranscriptStateful.downloadTranscript)(chatSDK, downloadTranscriptProps, state);
|
|
46
46
|
} catch (ex) {
|
|
47
47
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
48
48
|
Event: _TelemetryConstants.TelemetryEvent.DownloadTranscriptFailed,
|
package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -9,7 +9,9 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
|
|
|
9
9
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
10
10
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
11
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
12
|
+
var _createChatTranscript = _interopRequireDefault(require("../../../plugins/createChatTranscript"));
|
|
12
13
|
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
14
|
+
var _utils = require("../../../common/utils");
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
16
|
const processDisplayName = displayName => {
|
|
15
17
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
@@ -161,7 +163,7 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
161
163
|
};
|
|
162
164
|
|
|
163
165
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
164
|
-
const downloadTranscript = async (chatSDK,
|
|
166
|
+
const downloadTranscript = async (chatSDK, downloadTranscriptProps, state) => {
|
|
165
167
|
var _state$domainStates, _state$domainStates2, _state$domainStates2$;
|
|
166
168
|
// Need to keep existing request id for scenarios when trnascript is downloaded after endchat
|
|
167
169
|
const liveChatContext = {
|
|
@@ -174,18 +176,25 @@ const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError,
|
|
|
174
176
|
if (typeof data === _Constants.Constants.String) {
|
|
175
177
|
data = JSON.parse(data);
|
|
176
178
|
}
|
|
179
|
+
const {
|
|
180
|
+
bannerMessageOnError,
|
|
181
|
+
renderMarkDown,
|
|
182
|
+
attachmentMessage,
|
|
183
|
+
webChatTranscript
|
|
184
|
+
} = downloadTranscriptProps;
|
|
177
185
|
if (data[_Constants.Constants.ChatMessagesJson] !== null && data[_Constants.Constants.ChatMessagesJson] !== undefined) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
const useWebChatTranscript = (0, _utils.isNullOrUndefined)(webChatTranscript === null || webChatTranscript === void 0 ? void 0 : webChatTranscript.disabled) || (webChatTranscript === null || webChatTranscript === void 0 ? void 0 : webChatTranscript.disabled) === false;
|
|
187
|
+
if (useWebChatTranscript) {
|
|
188
|
+
const transcriptOptions = {
|
|
189
|
+
...webChatTranscript
|
|
190
|
+
};
|
|
191
|
+
await (0, _createChatTranscript.default)(data[_Constants.Constants.ChatMessagesJson], chatSDK, false, transcriptOptions);
|
|
192
|
+
} else {
|
|
193
|
+
// Legacy Transcript
|
|
194
|
+
const chatTranscripts = window.btoa(encodeURIComponent(beautifyChatTranscripts(data[_Constants.Constants.ChatMessagesJson], renderMarkDown, attachmentMessage)));
|
|
195
|
+
const byteCharacters = decodeURIComponent(window.atob(chatTranscripts));
|
|
196
|
+
(0, _utils.createFileAndDownload)(_Constants.TranscriptConstants.ChatTranscriptDownloadFile, byteCharacters, "text/html;charset=utf-8");
|
|
197
|
+
}
|
|
189
198
|
} else {
|
|
190
199
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
191
200
|
Event: _TelemetryConstants.TelemetryEvent.DownloadTranscriptResponseNullOrUndefined,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|