@microsoft/omnichannel-chat-widget 0.1.0-main.ceb1702 → 0.1.0-main.d4c1f9e
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 +4 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/cjs/common/utils.js +64 -5
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
- 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 +52 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +8 -3
- package/lib/cjs/components/livechatwidget/common/endChat.js +52 -20
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +131 -80
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +153 -110
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -0
- 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/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -2
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/controller/componentController.js +2 -2
- package/lib/esm/common/Constants.js +4 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/esm/common/utils.js +48 -3
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
- 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 +39 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +8 -3
- package/lib/esm/components/livechatwidget/common/endChat.js +53 -21
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -2
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +127 -80
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +153 -112
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +10 -0
- 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/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -2
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/controller/componentController.js +2 -2
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -1
- package/lib/types/common/utils.d.ts +7 -3
- 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 +4 -0
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -3
- 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/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +4 -3
|
@@ -14,6 +14,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
14
14
|
class MockChatSDK {
|
|
15
15
|
constructor() {
|
|
16
16
|
_defineProperty(this, "sleep", ms => new Promise(r => setTimeout(r, ms)));
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "isMockModeOn", true);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
async startChat() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -15,6 +15,7 @@ exports.ConversationState = ConversationState;
|
|
|
15
15
|
ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
|
|
16
16
|
ConversationState[ConversationState["Active"] = 5] = "Active";
|
|
17
17
|
ConversationState[ConversationState["InActive"] = 6] = "InActive";
|
|
18
|
-
ConversationState[ConversationState["
|
|
19
|
-
ConversationState[ConversationState["
|
|
18
|
+
ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
|
|
19
|
+
ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
|
|
20
|
+
ConversationState[ConversationState["Closed"] = 9] = "Closed";
|
|
20
21
|
})(ConversationState || (exports.ConversationState = ConversationState = {}));
|
|
@@ -41,4 +41,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
41
41
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
|
|
42
42
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 31] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
43
43
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 32] = "SET_WIDGET_SIZE";
|
|
44
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 33] = "SET_WIDGET_INSTANCE_ID";
|
|
44
45
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -29,14 +29,14 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
29
29
|
globalDir: "ltr",
|
|
30
30
|
liveChatContext: undefined,
|
|
31
31
|
customContext: undefined,
|
|
32
|
-
widgetSize: undefined
|
|
32
|
+
widgetSize: undefined,
|
|
33
|
+
widgetInstanceId: ""
|
|
33
34
|
},
|
|
34
35
|
appStates: {
|
|
35
36
|
conversationState: _ConversationState.ConversationState.Closed,
|
|
36
37
|
isMinimized: false,
|
|
37
38
|
previousElementOnFocusBeforeModalOpen: null,
|
|
38
39
|
outsideOperatingHours: false,
|
|
39
|
-
shouldShowPostChat: false,
|
|
40
40
|
preChatResponseEmail: "",
|
|
41
41
|
isAudioMuted: null,
|
|
42
42
|
newMessage: false,
|
|
@@ -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
|
}
|
|
@@ -44,7 +44,7 @@ const shouldShowWebChatContainer = state => {
|
|
|
44
44
|
exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
|
|
45
45
|
|
|
46
46
|
const shouldShowLoadingPane = state => {
|
|
47
|
-
return !state.appStates.isMinimized &&
|
|
47
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
exports.shouldShowLoadingPane = shouldShowLoadingPane;
|
|
@@ -56,7 +56,7 @@ const shouldShowReconnectChatPane = state => {
|
|
|
56
56
|
exports.shouldShowReconnectChatPane = shouldShowReconnectChatPane;
|
|
57
57
|
|
|
58
58
|
const shouldShowPostChatLoadingPane = state => {
|
|
59
|
-
return !state.appStates.isMinimized && state.appStates.
|
|
59
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
exports.shouldShowPostChatLoadingPane = shouldShowPostChatLoadingPane;
|
|
@@ -158,6 +158,10 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
|
|
|
158
158
|
|
|
159
159
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
160
160
|
|
|
161
|
+
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
162
|
+
|
|
163
|
+
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
164
|
+
|
|
161
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);
|
|
162
166
|
export class HtmlIdNames {}
|
|
163
167
|
|
|
@@ -48,6 +48,7 @@ export let BroadcastEvent; // Events being logged
|
|
|
48
48
|
BroadcastEvent["ChatInitiated"] = "ChatInitiated";
|
|
49
49
|
BroadcastEvent["CloseChat"] = "CloseChat";
|
|
50
50
|
BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
|
|
51
|
+
BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
|
|
51
52
|
})(BroadcastEvent || (BroadcastEvent = {}));
|
|
52
53
|
|
|
53
54
|
export let TelemetryEvent;
|
|
@@ -128,6 +129,10 @@ export let TelemetryEvent;
|
|
|
128
129
|
TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
|
|
129
130
|
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
130
131
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
132
|
+
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
133
|
+
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
134
|
+
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
135
|
+
TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
|
|
131
136
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
132
137
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
133
138
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -199,6 +204,7 @@ export class TelemetryConstants {
|
|
|
199
204
|
case TelemetryEvent.MessageSent:
|
|
200
205
|
case TelemetryEvent.MessageReceived:
|
|
201
206
|
case TelemetryEvent.CustomContextReceived:
|
|
207
|
+
case TelemetryEvent.BrowserUnloadEventStarted:
|
|
202
208
|
return ScenarioType.ACTIONS;
|
|
203
209
|
|
|
204
210
|
case TelemetryEvent.StartChatSDKCall:
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
|
|
2
|
+
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
2
3
|
import { KeyCodes } from "./KeyCodes";
|
|
3
4
|
import { BroadcastEvent } from "./telemetry/TelemetryConstants";
|
|
5
|
+
import { Md5 } from "md5-typescript";
|
|
4
6
|
|
|
5
7
|
const getElementBySelector = selector => {
|
|
6
8
|
let element;
|
|
@@ -289,9 +291,52 @@ export const getDomain = hostValue => {
|
|
|
289
291
|
|
|
290
292
|
return AriaTelemetryConstants.Public;
|
|
291
293
|
};
|
|
292
|
-
export const getWidgetCacheId = (orgId, widgetId) => {
|
|
293
|
-
|
|
294
|
+
export const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
|
|
295
|
+
const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
296
|
+
return Md5.init(widgetCacheId);
|
|
294
297
|
};
|
|
295
|
-
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
|
+
|
|
296
303
|
return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
304
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
305
|
+
|
|
306
|
+
export const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
|
|
307
|
+
// Getting updated state from cache
|
|
308
|
+
try {
|
|
309
|
+
if (DataStoreManager.clientDataStore) {
|
|
310
|
+
var _DataStoreManager$cli;
|
|
311
|
+
|
|
312
|
+
const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
|
|
313
|
+
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
314
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
315
|
+
return persistedState;
|
|
316
|
+
} else {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
} catch (error) {
|
|
320
|
+
console.log(error);
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
|
+
|
|
325
|
+
export const isUndefinedOrEmpty = object => {
|
|
326
|
+
if (object) {
|
|
327
|
+
if (Object.keys(object).length === 0) {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return false;
|
|
332
|
+
} else {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
336
|
+
|
|
337
|
+
export const addDelayInMs = ms => {
|
|
338
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
339
|
+
};
|
|
340
|
+
export const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
341
|
+
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
297
342
|
};
|
|
@@ -57,6 +57,10 @@ export const ChatButtonStateful = props => {
|
|
|
57
57
|
titleText: "We're Offline",
|
|
58
58
|
subtitleText: "No agents available",
|
|
59
59
|
onClick: async () => {
|
|
60
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
61
|
+
Event: TelemetryEvent.LCWChatButtonClicked
|
|
62
|
+
});
|
|
63
|
+
|
|
60
64
|
if (state.appStates.isMinimized) {
|
|
61
65
|
dispatch({
|
|
62
66
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -17,7 +17,6 @@ export const ConfirmationPaneStateful = props => {
|
|
|
17
17
|
const {
|
|
18
18
|
prepareEndChat
|
|
19
19
|
} = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
|
|
22
21
|
const [adapter] = useChatAdapterStore();
|
|
23
22
|
const controlProps = {
|
|
@@ -49,7 +49,8 @@ export const HeaderStateful = props => {
|
|
|
49
49
|
} else {
|
|
50
50
|
const skipEndChatSDK = true;
|
|
51
51
|
const skipCloseChat = false;
|
|
52
|
-
|
|
52
|
+
const postMessageToOtherTabs = true;
|
|
53
|
+
await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
dispatch({
|
|
@@ -58,8 +59,8 @@ export const HeaderStateful = props => {
|
|
|
58
59
|
});
|
|
59
60
|
},
|
|
60
61
|
...(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),
|
|
62
|
+
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),
|
|
63
|
+
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
64
|
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
65
|
};
|
|
65
66
|
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
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { DefaultActivitySubscriber } from "./ActivitySubscriber/DefaultActivitySubscriber";
|
|
4
|
+
import { shareObservable } from "./shareObservable";
|
|
5
|
+
export class ChatAdapterShim {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
constructor(chatAdapter) {
|
|
11
|
+
_defineProperty(this, "chatAdapter", void 0);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "activityObserver", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "subscribers", void 0);
|
|
16
|
+
|
|
17
|
+
this.subscribers = [];
|
|
18
|
+
this.chatAdapter = { ...chatAdapter,
|
|
19
|
+
activity$: shareObservable( // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
new window.Observable(observer => {
|
|
21
|
+
this.activityObserver = observer; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
|
|
23
|
+
const abortController = new window.AbortController();
|
|
24
|
+
|
|
25
|
+
(async () => {
|
|
26
|
+
try {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
for await (let activity of chatAdapter.activities({
|
|
29
|
+
signal: abortController.signal
|
|
30
|
+
})) {
|
|
31
|
+
for (const subscriber of [...this.subscribers, new DefaultActivitySubscriber()]) {
|
|
32
|
+
subscriber.observer = this.activityObserver;
|
|
33
|
+
activity = await subscriber.next(activity);
|
|
34
|
+
|
|
35
|
+
if (!activity) {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
observer.complete();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
observer.error(error);
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
abortController.abort();
|
|
49
|
+
};
|
|
50
|
+
}))
|
|
51
|
+
};
|
|
52
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
addSubscriber(subscriber) {
|
|
56
|
+
this.subscribers.push(subscriber);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 Deferred {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "_promise", void 0);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "_resolve", void 0);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "_reject", () => {
|
|
11
|
+
return;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "resolve", value => {
|
|
15
|
+
this._resolve(value);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "reject", value => {
|
|
19
|
+
this._reject(value);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
this._promise = new Promise((resolve, reject) => {
|
|
23
|
+
this._resolve = resolve;
|
|
24
|
+
this._reject = reject;
|
|
25
|
+
});
|
|
26
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
get promise() {
|
|
30
|
+
return this._promise;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
3
|
+
import { isNullOrEmptyString } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
|
|
5
|
+
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
6
|
+
let authClientFunction = undefined;
|
|
7
|
+
|
|
8
|
+
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
9
|
+
var _chatConfig$LiveChatC;
|
|
10
|
+
|
|
11
|
+
authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (getAuthToken && authClientFunction) {
|
|
15
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
16
|
+
Event: TelemetryEvent.GetAuthTokenCalled
|
|
17
|
+
});
|
|
18
|
+
const token = await getAuthToken(authClientFunction);
|
|
19
|
+
|
|
20
|
+
if (!isNullOrEmptyString(token)) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
chatSDK.setAuthTokenProvider(async () => {
|
|
23
|
+
return token;
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
27
|
+
Event: TelemetryEvent.ReceivedNullOrEmptyToken
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const removeAuthTokenProvider = chatSDK => {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
chatSDK.authenticatedUserToken = null;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { handleAuthentication, removeAuthTokenProvider };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
2
2
|
import { NotificationLevel } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationLevel";
|
|
3
3
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
|
-
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
4
|
+
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
|
+
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
6
|
+
import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
7
|
|
|
6
8
|
export const createAdapter = async chatSDK => {
|
|
7
9
|
const chatAdapterOptionalParams = {
|
|
@@ -23,5 +25,13 @@ export const createAdapter = async chatSDK => {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
};
|
|
26
|
-
|
|
28
|
+
let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams); //so far, there is no need to convert to the shim adapter when using visual tests
|
|
29
|
+
|
|
30
|
+
if (chatSDK.isMockModeOn !== true) {
|
|
31
|
+
adapter = new ChatAdapterShim(adapter);
|
|
32
|
+
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
33
|
+
return adapter.chatAdapter;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return adapter;
|
|
27
37
|
};
|
|
@@ -13,26 +13,40 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
|
|
|
13
13
|
breaks: !disableNewLineMarkdownSupport
|
|
14
14
|
}); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
|
|
15
15
|
// markdown.use(MarkdownSlack);
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
} else {
|
|
17
|
+
markdown = new MarkdownIt(Constants.Zero, {
|
|
18
|
+
html: true,
|
|
19
|
+
linkify: true,
|
|
20
|
+
breaks: !disableNewLineMarkdownSupport
|
|
21
|
+
});
|
|
22
|
+
markdown.enable(["entity", // Rule to process html entity - {, ¯, "
|
|
23
|
+
"linkify", // Rule to replace link-like texts with link nodes
|
|
24
|
+
"html_block", // Rule to process html blocks and paragraphs
|
|
25
|
+
"html_inline", // Rule to process html tags
|
|
26
|
+
"newline" // Rule to proceess '\n'
|
|
27
|
+
]);
|
|
28
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
29
|
|
|
19
|
-
markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
|
|
20
|
-
const targetAttrIndex = tokens[idx].attrIndex(Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
|
|
32
|
+
const targetAttrIndex = tokens[idx].attrIndex(Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
35
|
+
|
|
36
|
+
if (~targetAttrIndex) {
|
|
37
|
+
tokens[idx].attrs[targetAttrIndex][1] = Constants.Blank;
|
|
38
|
+
} else {
|
|
39
|
+
tokens[idx].attrPush([Constants.Target, Constants.Blank]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const relAttrIndex = tokens[idx].attrIndex(Constants.TargetRelationship);
|
|
29
43
|
|
|
30
|
-
|
|
44
|
+
if (~relAttrIndex) {
|
|
45
|
+
tokens[idx].attrs[relAttrIndex][1] = Constants.TargetRelationshipAttributes;
|
|
46
|
+
} else {
|
|
47
|
+
tokens[idx].attrPush([Constants.TargetRelationship, Constants.TargetRelationshipAttributes]);
|
|
31
48
|
|
|
32
|
-
if (
|
|
33
|
-
tokens[idx].attrs[relAttrIndex][1] = Constants.TargetRelationshipAttributes;
|
|
34
|
-
} else {
|
|
35
|
-
tokens[idx].attrPush([Constants.TargetRelationship, Constants.TargetRelationshipAttributes]);
|
|
49
|
+
if (!disableMarkdownMessageFormatting) {
|
|
36
50
|
tokens[idx].attrPush([Constants.Title, defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT]); // eslint-disable-next-line quotes
|
|
37
51
|
|
|
38
52
|
const iconTokens = markdown.parseInline(``, env)[0].children;
|
|
@@ -42,20 +56,7 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
|
|
|
42
56
|
tokens.splice(idx + 2, 0, ...iconTokens);
|
|
43
57
|
}
|
|
44
58
|
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
markdown = new MarkdownIt(Constants.Zero, {
|
|
48
|
-
html: true,
|
|
49
|
-
linkify: true,
|
|
50
|
-
breaks: !disableNewLineMarkdownSupport
|
|
51
|
-
});
|
|
52
|
-
markdown.enable(["entity", // Rule to process html entity - {, ¯, "
|
|
53
|
-
"linkify", // Rule to replace link-like texts with link nodes
|
|
54
|
-
"html_block", // Rule to process html blocks and paragraphs
|
|
55
|
-
"html_inline", // Rule to process html tags
|
|
56
|
-
"newline" // Rule to proceess '\n'
|
|
57
|
-
]);
|
|
58
|
-
}
|
|
59
|
-
|
|
59
|
+
}
|
|
60
|
+
});
|
|
60
61
|
return markdown;
|
|
61
62
|
};
|
|
@@ -318,7 +318,8 @@ export const dummyDefaultProps = {
|
|
|
318
318
|
hideChatTitle: false,
|
|
319
319
|
hideNotificationBubble: true,
|
|
320
320
|
unreadMessageString: "new messages",
|
|
321
|
-
largeUnreadMessageString: "99+"
|
|
321
|
+
largeUnreadMessageString: "99+",
|
|
322
|
+
ariaLabelUnreadMessageString: "you have new messages"
|
|
322
323
|
},
|
|
323
324
|
styleProps: {
|
|
324
325
|
generalStyleProps: {
|
|
@@ -1413,7 +1414,6 @@ export const dummyDefaultProps = {
|
|
|
1413
1414
|
startNewChatButtonClassName: undefined
|
|
1414
1415
|
}
|
|
1415
1416
|
},
|
|
1416
|
-
authClientFunction: undefined,
|
|
1417
1417
|
isReconnectEnabled: undefined,
|
|
1418
1418
|
reconnectId: undefined,
|
|
1419
1419
|
redirectInSameWindow: undefined
|
|
@@ -1682,7 +1682,12 @@ export const dummyDefaultProps = {
|
|
|
1682
1682
|
botMagicCode: {
|
|
1683
1683
|
disabled: false,
|
|
1684
1684
|
fwdUrl: ""
|
|
1685
|
+
},
|
|
1686
|
+
adaptiveCardStyles: {
|
|
1687
|
+
background: "white",
|
|
1688
|
+
color: "black"
|
|
1685
1689
|
}
|
|
1686
1690
|
},
|
|
1687
|
-
telemetryConfig: undefined
|
|
1691
|
+
telemetryConfig: undefined,
|
|
1692
|
+
getAuthToken: undefined
|
|
1688
1693
|
};
|