@microsoft/omnichannel-chat-widget 0.1.0-main.24bd1e6 → 0.1.0-main.306098a
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/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +15 -0
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +31 -18
- package/lib/cjs/common/utils.js +20 -7
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -4
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/cjs/components/footerstateful/FooterStateful.js +5 -13
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -7
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +5 -2
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +54 -21
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +139 -57
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +20 -4
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -1
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +13 -5
- package/lib/cjs/contexts/createReducer.js +10 -2
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +15 -0
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +29 -13
- package/lib/esm/common/utils.js +14 -5
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -4
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/esm/components/footerstateful/FooterStateful.js +5 -13
- package/lib/esm/components/headerstateful/HeaderStateful.js +14 -7
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +3 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +5 -2
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +50 -22
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +138 -59
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +15 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -1
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +11 -5
- package/lib/esm/contexts/createReducer.js +10 -2
- package/lib/types/common/Constants.d.ts +1 -0
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +7 -1
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
- package/lib/types/common/utils.d.ts +5 -4
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -2
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -2
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +5 -4
|
@@ -9,11 +9,18 @@ var _ConversationState = require("./ConversationState");
|
|
|
9
9
|
|
|
10
10
|
var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
11
11
|
|
|
12
|
+
var _utils = require("../../common/utils");
|
|
13
|
+
|
|
14
|
+
var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
|
|
15
|
+
|
|
12
16
|
const getLiveChatWidgetContextInitialState = props => {
|
|
13
|
-
var _props$webChatContain;
|
|
17
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$webChatContain;
|
|
18
|
+
|
|
19
|
+
const widgetCacheId = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
20
|
+
const initialState = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)().getData(widgetCacheId, "localStorage");
|
|
14
21
|
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
22
|
+
if (!(0, _utils.isNullOrUndefined)(initialState)) {
|
|
23
|
+
return JSON.parse(initialState);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
const LiveChatWidgetContextInitialState = {
|
|
@@ -29,12 +36,13 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
29
36
|
globalDir: "ltr",
|
|
30
37
|
liveChatContext: undefined,
|
|
31
38
|
customContext: undefined,
|
|
32
|
-
widgetSize: undefined
|
|
39
|
+
widgetSize: undefined,
|
|
40
|
+
widgetInstanceId: ""
|
|
33
41
|
},
|
|
34
42
|
appStates: {
|
|
35
43
|
conversationState: _ConversationState.ConversationState.Closed,
|
|
36
44
|
isMinimized: false,
|
|
37
|
-
|
|
45
|
+
previousElementIdOnFocusBeforeModalOpen: null,
|
|
38
46
|
outsideOperatingHours: false,
|
|
39
47
|
preChatResponseEmail: "",
|
|
40
48
|
isAudioMuted: null,
|
|
@@ -77,10 +77,10 @@ const createReducer = () => {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
80
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID:
|
|
81
81
|
return { ...state,
|
|
82
82
|
appStates: { ...state.appStates,
|
|
83
|
-
|
|
83
|
+
previousElementIdOnFocusBeforeModalOpen: action.payload
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
|
|
@@ -243,6 +243,14 @@ const createReducer = () => {
|
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
|
|
246
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID:
|
|
247
|
+
return { ...state,
|
|
248
|
+
domainStates: { ...state.domainStates,
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
widgetInstanceId: action.payload
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
246
254
|
default:
|
|
247
255
|
return state;
|
|
248
256
|
}
|
|
@@ -160,6 +160,8 @@ _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChang
|
|
|
160
160
|
|
|
161
161
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
162
162
|
|
|
163
|
+
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
164
|
+
|
|
163
165
|
export 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);
|
|
164
166
|
export class HtmlIdNames {}
|
|
165
167
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
|
+
import { getWidgetCacheId } from "../../utils";
|
|
5
|
+
import { defaultClientDataStoreProvider } from "./defaultClientDataStoreProvider";
|
|
6
|
+
export class defaultCacheManager {}
|
|
7
|
+
|
|
8
|
+
_defineProperty(defaultCacheManager, "InternalCache", {});
|
|
9
|
+
|
|
10
|
+
export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
|
|
11
|
+
const widgetCacheId = getWidgetCacheId(orgid, widgetId, widgetInstanceId);
|
|
12
|
+
BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
|
|
13
|
+
try {
|
|
14
|
+
defaultClientDataStoreProvider().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("Error in setting data to localstorage", error);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { inMemoryDataStore } from "./defaultInMemoryDataStore";
|
|
2
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
3
|
+
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
4
|
+
export const defaultClientDataStoreProvider = () => {
|
|
5
|
+
const isCookieAllowed = () => {
|
|
6
|
+
try {
|
|
7
|
+
localStorage;
|
|
8
|
+
sessionStorage;
|
|
9
|
+
return true;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error("Third party cookie blocked");
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const TtlInMs = 15 * 60 * 1000; // 15 mins
|
|
17
|
+
|
|
18
|
+
const dataStoreProvider = {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
setData: (key, data, type) => {
|
|
21
|
+
if (isCookieAllowed()) {
|
|
22
|
+
try {
|
|
23
|
+
if (key) {
|
|
24
|
+
const now = new Date();
|
|
25
|
+
const item = {
|
|
26
|
+
data: data,
|
|
27
|
+
expiry: now.getTime() + TtlInMs
|
|
28
|
+
};
|
|
29
|
+
const strItem = JSON.stringify(item);
|
|
30
|
+
|
|
31
|
+
if (type === "localStorage") {
|
|
32
|
+
localStorage.setItem(key, strItem);
|
|
33
|
+
} else {
|
|
34
|
+
sessionStorage.setItem(key, strItem);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
39
|
+
Event: TelemetryEvent.ClientDataStoreProviderFailed,
|
|
40
|
+
ExceptionDetails: error,
|
|
41
|
+
Description: "Unable to store data in localStorage."
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
const dataToCache = {
|
|
46
|
+
key: key,
|
|
47
|
+
data: data,
|
|
48
|
+
type: type
|
|
49
|
+
};
|
|
50
|
+
parent.postMessage(dataToCache, "*");
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
getData: (key, type) => {
|
|
55
|
+
if (isCookieAllowed()) {
|
|
56
|
+
let item;
|
|
57
|
+
|
|
58
|
+
if (type === "localStorage") {
|
|
59
|
+
item = localStorage.getItem(key);
|
|
60
|
+
} else {
|
|
61
|
+
item = sessionStorage.getItem(key);
|
|
62
|
+
} //Return item if not expired
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
let itemInJson = undefined;
|
|
66
|
+
|
|
67
|
+
if (item !== null) {
|
|
68
|
+
itemInJson = JSON.parse(item);
|
|
69
|
+
const now = new Date(); // compare the expiry time of the item with the current time
|
|
70
|
+
|
|
71
|
+
if (now.getTime() > itemInJson.expiry) {
|
|
72
|
+
// If the item is expired, delete the item from storage
|
|
73
|
+
// and return null
|
|
74
|
+
localStorage.removeItem(key);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return itemInJson.data;
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
// get data from in memory db when cookie is disabled
|
|
82
|
+
return inMemoryDataStore().getData(key);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
removeData: (key, type) => {
|
|
87
|
+
if (isCookieAllowed()) {
|
|
88
|
+
if (key) {
|
|
89
|
+
if (type === "localStorage") {
|
|
90
|
+
return localStorage.removeItem(key);
|
|
91
|
+
} else {
|
|
92
|
+
return sessionStorage.removeItem(key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
// get data from in memory db when cookie is disabled
|
|
97
|
+
return inMemoryDataStore().removeData(key);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return dataStoreProvider;
|
|
102
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
2
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
3
|
+
import { defaultCacheManager } from "./defaultCacheManager";
|
|
4
|
+
export const defaultInitializeInMemoryDataStore = widgetId => {
|
|
5
|
+
try {
|
|
6
|
+
localStorage;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
// Register below events when localStorage is not accessible
|
|
9
|
+
// Listening to event raised from client browser
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
window.addEventListener("message", function (e) {
|
|
12
|
+
try {
|
|
13
|
+
if (e.data.key) {
|
|
14
|
+
const browserData = e.data;
|
|
15
|
+
|
|
16
|
+
if (defaultCacheManager.InternalCache[browserData.key]) {
|
|
17
|
+
delete defaultCacheManager.InternalCache[browserData.key];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
defaultCacheManager.InternalCache[browserData.key] = browserData.data;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
24
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
25
|
+
ExceptionDetails: error,
|
|
26
|
+
Description: "Unable to register default in-memory cache."
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}); // send cache initialize message to client
|
|
30
|
+
|
|
31
|
+
if (defaultCacheManager.InternalCache === undefined || {}) {
|
|
32
|
+
parent.postMessage({
|
|
33
|
+
data: "cacheinitialize",
|
|
34
|
+
widgetId: widgetId
|
|
35
|
+
}, "*");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const inMemoryDataStore = () => {
|
|
40
|
+
const dataStoreProvider = {
|
|
41
|
+
getData: key => {
|
|
42
|
+
if (defaultCacheManager.InternalCache && defaultCacheManager.InternalCache[key]) {
|
|
43
|
+
return defaultCacheManager.InternalCache[key];
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
setData: (key, data) => {
|
|
48
|
+
try {
|
|
49
|
+
defaultCacheManager.InternalCache[key] = data;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
52
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
53
|
+
ExceptionDetails: error,
|
|
54
|
+
Description: "Unable to set data in default in-memory cache."
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
removeData: key => {
|
|
59
|
+
try {
|
|
60
|
+
defaultCacheManager.InternalCache[key] = {};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
63
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
64
|
+
ExceptionDetails: error,
|
|
65
|
+
Description: "Unable to remove data from default in-memory cache."
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return dataStoreProvider;
|
|
71
|
+
};
|
|
@@ -89,6 +89,8 @@ export let TelemetryEvent;
|
|
|
89
89
|
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
90
90
|
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
91
91
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
92
|
+
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
93
|
+
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
92
94
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
93
95
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
94
96
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -131,6 +133,8 @@ export let TelemetryEvent;
|
|
|
131
133
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
132
134
|
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
133
135
|
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
136
|
+
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
137
|
+
TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
|
|
134
138
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
135
139
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
136
140
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -157,12 +161,18 @@ export let TelemetryEvent;
|
|
|
157
161
|
TelemetryEvent["MessageSent"] = "MessageSent";
|
|
158
162
|
TelemetryEvent["MessageReceived"] = "MessageReceived";
|
|
159
163
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
164
|
+
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
165
|
+
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
160
166
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
161
167
|
|
|
162
168
|
export class TelemetryConstants {
|
|
163
169
|
static map(eventTypeOrScenarioType) {
|
|
164
170
|
switch (eventTypeOrScenarioType) {
|
|
165
171
|
case TelemetryEvent.ParseAdaptiveCardFailed:
|
|
172
|
+
case TelemetryEvent.ReceivedNullOrEmptyToken:
|
|
173
|
+
case TelemetryEvent.GetAuthTokenCalled:
|
|
174
|
+
case TelemetryEvent.SuppressBotMagicCodeSucceeded:
|
|
175
|
+
case TelemetryEvent.SuppressBotMagicCodeFailed:
|
|
166
176
|
return ScenarioType.CONFIG_VALIDATION;
|
|
167
177
|
|
|
168
178
|
case TelemetryEvent.WebChatLoaded:
|
|
@@ -203,6 +213,10 @@ export class TelemetryConstants {
|
|
|
203
213
|
case TelemetryEvent.MessageReceived:
|
|
204
214
|
case TelemetryEvent.CustomContextReceived:
|
|
205
215
|
case TelemetryEvent.BrowserUnloadEventStarted:
|
|
216
|
+
case TelemetryEvent.NetworkDisconnected:
|
|
217
|
+
case TelemetryEvent.NetworkReconnected:
|
|
218
|
+
case TelemetryEvent.AudioToggleButtonClicked:
|
|
219
|
+
case TelemetryEvent.EmailTranscriptCancelButtonClicked:
|
|
206
220
|
return ScenarioType.ACTIONS;
|
|
207
221
|
|
|
208
222
|
case TelemetryEvent.StartChatSDKCall:
|
|
@@ -219,6 +233,7 @@ export class TelemetryConstants {
|
|
|
219
233
|
case TelemetryEvent.EndChatSDKCallFailed:
|
|
220
234
|
case TelemetryEvent.PostChatContextCallFailed:
|
|
221
235
|
case TelemetryEvent.PostChatContextCallSucceed:
|
|
236
|
+
case TelemetryEvent.GetConversationDetailsException:
|
|
222
237
|
return ScenarioType.SDK;
|
|
223
238
|
|
|
224
239
|
case TelemetryEvent.VideoCallAcceptButtonClick:
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getDomain, isNullOrEmptyString, isNullOrUndefined } from "../../utils";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { AWTPiiKind } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
|
|
2
|
+
import { AWTLogManager } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AriaSDK";
|
|
3
|
+
import { AWTCustomerContentKind, AWTPiiKind, AWTPropertyType } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
|
|
5
4
|
import { Constants, AriaTelemetryConstants, EnvironmentVersion } from "../../Constants";
|
|
6
5
|
import { TelemetryManager } from "../TelemetryManager";
|
|
7
6
|
export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUriForTelemetry, ariaTelemetryApplicationName) => {
|
|
@@ -49,18 +48,35 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
|
|
|
49
48
|
const ariaLogger = {
|
|
50
49
|
log: (logLevel, telemetryInput) => {
|
|
51
50
|
try {
|
|
52
|
-
|
|
53
|
-
const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo;
|
|
54
|
-
const eventProperties = new AWTEventProperties();
|
|
55
|
-
eventProperties.setName(telemetryInput.scenarioType);
|
|
51
|
+
var _telemetryInput$telem;
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
53
|
+
const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$telem = telemetryInput.telemetryInfo) === null || _telemetryInput$telem === void 0 ? void 0 : _telemetryInput$telem.telemetryInfo; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
|
|
55
|
+
const eventProperties = {
|
|
56
|
+
name: telemetryInput.scenarioType,
|
|
57
|
+
properties: {}
|
|
58
|
+
};
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
if (telemetryInfo) {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
Object.keys(telemetryInfo).forEach((key, index) => {
|
|
63
|
+
if (!isNullOrUndefined(telemetryInfo[key]) && !isNullOrEmptyString(telemetryInfo[key])) {
|
|
64
|
+
const property = {
|
|
65
|
+
value: typeof telemetryInfo[key] === "object" ? JSON.stringify(telemetryInfo[key]) : telemetryInfo[key],
|
|
66
|
+
type: typeof telemetryInfo[key] === "number" ? AWTPropertyType.Double : AWTPropertyType.String,
|
|
67
|
+
pii: AWTPiiKind.NotSet,
|
|
68
|
+
cc: AWTCustomerContentKind.NotSet
|
|
69
|
+
};
|
|
70
|
+
eventProperties.properties[key] = property;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const nameProperty = {
|
|
74
|
+
value: Constants.LiveChatWidget,
|
|
75
|
+
type: AWTPropertyType.String,
|
|
76
|
+
pii: AWTPiiKind.GenericData,
|
|
77
|
+
cc: AWTCustomerContentKind.NotSet
|
|
78
|
+
};
|
|
79
|
+
eventProperties.properties[ariaTelemetryApplicationName] = nameProperty;
|
|
64
80
|
}
|
|
65
81
|
|
|
66
82
|
logger() ? logger().logEvent(eventProperties) : console.log("Unable to initialize aria logger");
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -2,6 +2,7 @@ import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants"
|
|
|
2
2
|
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
3
3
|
import { KeyCodes } from "./KeyCodes";
|
|
4
4
|
import { BroadcastEvent } from "./telemetry/TelemetryConstants";
|
|
5
|
+
import { Md5 } from "md5-typescript";
|
|
5
6
|
|
|
6
7
|
const getElementBySelector = selector => {
|
|
7
8
|
let element;
|
|
@@ -290,20 +291,25 @@ export const getDomain = hostValue => {
|
|
|
290
291
|
|
|
291
292
|
return AriaTelemetryConstants.Public;
|
|
292
293
|
};
|
|
293
|
-
export const getWidgetCacheId = (orgId, widgetId) => {
|
|
294
|
-
|
|
294
|
+
export const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
|
|
295
|
+
const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
296
|
+
return Md5.init(widgetCacheId);
|
|
295
297
|
};
|
|
296
|
-
export const getWidgetEndChatEventName = (orgId, widgetId) => {
|
|
298
|
+
export const getWidgetEndChatEventName = (orgId, widgetId, widgetInstanceId) => {
|
|
299
|
+
if (!isNullOrEmptyString(widgetInstanceId)) {
|
|
300
|
+
return `${BroadcastEvent.ChatEnded}_${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
301
|
+
}
|
|
302
|
+
|
|
297
303
|
return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
298
304
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
305
|
|
|
300
|
-
export const getStateFromCache = (orgId, widgetId) => {
|
|
306
|
+
export const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
|
|
301
307
|
// Getting updated state from cache
|
|
302
308
|
try {
|
|
303
309
|
if (DataStoreManager.clientDataStore) {
|
|
304
310
|
var _DataStoreManager$cli;
|
|
305
311
|
|
|
306
|
-
const widgetStateEventName = getWidgetCacheId(orgId, widgetId);
|
|
312
|
+
const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
|
|
307
313
|
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
308
314
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
309
315
|
return persistedState;
|
|
@@ -330,4 +336,7 @@ export const isUndefinedOrEmpty = object => {
|
|
|
330
336
|
|
|
331
337
|
export const addDelayInMs = ms => {
|
|
332
338
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
339
|
+
};
|
|
340
|
+
export const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
341
|
+
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
333
342
|
};
|
|
@@ -54,12 +54,12 @@ export const ConfirmationPaneStateful = props => {
|
|
|
54
54
|
type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
|
|
55
55
|
payload: false
|
|
56
56
|
});
|
|
57
|
-
const
|
|
57
|
+
const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
|
|
58
58
|
|
|
59
|
-
if (
|
|
60
|
-
setFocusOnElement(
|
|
59
|
+
if (previousFocusedElementId) {
|
|
60
|
+
setFocusOnElement("#" + previousFocusedElementId);
|
|
61
61
|
dispatch({
|
|
62
|
-
type: LiveChatWidgetActionType.
|
|
62
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
63
63
|
payload: null
|
|
64
64
|
});
|
|
65
65
|
} else {
|
|
@@ -25,16 +25,16 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
25
25
|
type: LiveChatWidgetActionType.SET_SHOW_EMAIL_TRANSCRIPT_PANE,
|
|
26
26
|
payload: false
|
|
27
27
|
});
|
|
28
|
-
const
|
|
28
|
+
const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
|
|
29
29
|
|
|
30
|
-
if (
|
|
31
|
-
setFocusOnElement(
|
|
30
|
+
if (previousFocusedElementId) {
|
|
31
|
+
setFocusOnElement("#" + previousFocusedElementId);
|
|
32
32
|
} else {
|
|
33
33
|
setFocusOnSendBox();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
dispatch({
|
|
37
|
-
type: LiveChatWidgetActionType.
|
|
37
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
38
38
|
payload: null
|
|
39
39
|
});
|
|
40
40
|
setTabIndices(elements, initialTabIndexMap, true);
|
|
@@ -54,13 +54,12 @@ export const FooterStateful = props => {
|
|
|
54
54
|
Event: TelemetryEvent.EmailTranscriptButtonClicked,
|
|
55
55
|
Description: "Email Transcript button clicked."
|
|
56
56
|
});
|
|
57
|
-
const emailTranscriptButtonId = (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP = footerProps.controlProps) === null || _footerProps$controlP === void 0 ? void 0 : (_footerProps$controlP2 = _footerProps$controlP.emailTranscriptButtonProps) === null || _footerProps$controlP2 === void 0 ? void 0 : _footerProps$controlP2.id) ??
|
|
58
|
-
const emailTranscriptButton = document.getElementById(emailTranscriptButtonId);
|
|
57
|
+
const emailTranscriptButtonId = (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP = footerProps.controlProps) === null || _footerProps$controlP === void 0 ? void 0 : (_footerProps$controlP2 = _footerProps$controlP.emailTranscriptButtonProps) === null || _footerProps$controlP2 === void 0 ? void 0 : _footerProps$controlP2.id) ?? `${controlProps.id}-emailtranscript-button`;
|
|
59
58
|
|
|
60
|
-
if (
|
|
59
|
+
if (emailTranscriptButtonId) {
|
|
61
60
|
dispatch({
|
|
62
|
-
type: LiveChatWidgetActionType.
|
|
63
|
-
payload:
|
|
61
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
62
|
+
payload: emailTranscriptButtonId
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
65
|
|
|
@@ -84,14 +83,7 @@ export const FooterStateful = props => {
|
|
|
84
83
|
isAudioMuted: state.appStates.isAudioMuted
|
|
85
84
|
}
|
|
86
85
|
};
|
|
87
|
-
|
|
88
|
-
const footer = document.getElementById(footerId);
|
|
89
|
-
|
|
90
|
-
if (footer) {
|
|
91
|
-
footer.style.display = hideFooterDisplay ? "none" : "";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Footer, {
|
|
86
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !hideFooterDisplay && /*#__PURE__*/React.createElement(Footer, {
|
|
95
87
|
componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
|
|
96
88
|
controlProps: controlProps,
|
|
97
89
|
styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
|
|
@@ -36,6 +36,8 @@ export const HeaderStateful = props => {
|
|
|
36
36
|
});
|
|
37
37
|
},
|
|
38
38
|
onCloseClick: async () => {
|
|
39
|
+
var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
|
|
40
|
+
|
|
39
41
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
40
42
|
Event: TelemetryEvent.HeaderCloseButtonClicked,
|
|
41
43
|
Description: "Header Close button clicked."
|
|
@@ -49,17 +51,22 @@ export const HeaderStateful = props => {
|
|
|
49
51
|
} else {
|
|
50
52
|
const skipEndChatSDK = true;
|
|
51
53
|
const skipCloseChat = false;
|
|
52
|
-
|
|
54
|
+
const postMessageToOtherTabs = true;
|
|
55
|
+
await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const closeButtonId = ((_props$headerProps = props.headerProps) === null || _props$headerProps === void 0 ? void 0 : (_props$headerProps$co = _props$headerProps.controlProps) === null || _props$headerProps$co === void 0 ? void 0 : (_props$headerProps$co2 = _props$headerProps$co.closeButtonProps) === null || _props$headerProps$co2 === void 0 ? void 0 : _props$headerProps$co2.id) ?? `${controlProps.id}-close-button`;
|
|
59
|
+
|
|
60
|
+
if (closeButtonId) {
|
|
61
|
+
dispatch({
|
|
62
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
63
|
+
payload: closeButtonId
|
|
64
|
+
});
|
|
65
|
+
}
|
|
59
66
|
},
|
|
60
67
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
61
|
-
hideTitle: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
62
|
-
hideIcon: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
68
|
+
hideTitle: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
69
|
+
hideIcon: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
63
70
|
hideCloseButton: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
64
71
|
};
|
|
65
72
|
const outOfOfficeControlProps = {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import { Deferred } from "./Deferred";
|
|
4
|
+
export class ActivityStreamHandler {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Use of a deferred pattern, to hold the execution of the activity.
|
|
10
|
+
*
|
|
11
|
+
* */
|
|
12
|
+
static cork() {
|
|
13
|
+
ActivityStreamHandler.restoreDeferred = new Deferred();
|
|
14
|
+
ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the promise, releasing it to continue with the execution of the activity.
|
|
18
|
+
*
|
|
19
|
+
* */
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
static uncork() {
|
|
23
|
+
ActivityStreamHandler.restoreDeferred.resolve();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_defineProperty(ActivityStreamHandler, "restoreDeferred", {
|
|
29
|
+
resolve: () => {
|
|
30
|
+
return "initialState";
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
_defineProperty(ActivityStreamHandler, "restorePromise", void 0);
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
export class DefaultActivitySubscriber {
|
|
4
|
+
constructor() {
|
|
5
|
+
_defineProperty(this, "observer", void 0);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
async next(activity) {
|
|
10
|
+
this.observer.next(activity);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import { ActivityStreamHandler } from "../ActivityStreamHandler";
|
|
4
|
+
export class PauseActivitySubscriber {
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "observer", void 0);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
async apply(activity) {
|
|
11
|
+
await ActivityStreamHandler.restorePromise;
|
|
12
|
+
return activity;
|
|
13
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
applicable(activity) {
|
|
17
|
+
return true;
|
|
18
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
async next(activity) {
|
|
22
|
+
if (this.applicable(activity)) {
|
|
23
|
+
return await this.apply(activity);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return activity;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|