@microsoft/omnichannel-chat-widget 1.0.3-main.c4c1ef7 → 1.0.3
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.
|
@@ -6,20 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.LiveChatWidgetStateful = void 0;
|
|
7
7
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
var _botframeworkWebchat = require("botframework-webchat");
|
|
10
|
+
var _Constants = require("../../../common/Constants");
|
|
9
11
|
var _react = require("@fluentui/react");
|
|
10
12
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
11
13
|
var _startChat = require("../common/startChat");
|
|
12
14
|
var _utils = require("../../../common/utils");
|
|
13
15
|
var _endChat = require("../common/endChat");
|
|
16
|
+
var _reconnectChatHelper = require("../common/reconnectChatHelper");
|
|
14
17
|
var _componentController = require("../../../controller/componentController");
|
|
15
18
|
var _ActivityStreamHandler = require("../common/ActivityStreamHandler");
|
|
16
19
|
var _CallingContainerStateful = _interopRequireDefault(require("../../callingcontainerstateful/CallingContainerStateful"));
|
|
17
20
|
var _ChatButtonStateful = _interopRequireDefault(require("../../chatbuttonstateful/ChatButtonStateful"));
|
|
18
|
-
var _botframeworkWebchat = require("botframework-webchat");
|
|
19
21
|
var _ConfirmationPaneStateful = _interopRequireDefault(require("../../confirmationpanestateful/ConfirmationPaneStateful"));
|
|
20
22
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
21
23
|
var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
|
|
22
|
-
var _Constants = require("../../../common/Constants");
|
|
23
24
|
var _EmailTranscriptPaneStateful = _interopRequireDefault(require("../../emailtranscriptpanestateful/EmailTranscriptPaneStateful"));
|
|
24
25
|
var _HeaderStateful = _interopRequireDefault(require("../../headerstateful/HeaderStateful"));
|
|
25
26
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
@@ -51,13 +52,12 @@ var _startProactiveChat = require("../common/startProactiveChat");
|
|
|
51
52
|
var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
|
|
52
53
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
53
54
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
54
|
-
var _reconnectChatHelper = require("../common/reconnectChatHelper");
|
|
55
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
56
56
|
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); }
|
|
57
57
|
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; }
|
|
58
58
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
59
59
|
const LiveChatWidgetStateful = props => {
|
|
60
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$
|
|
60
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$styleProps2, _props$controlProps11, _props$controlProps12, _props$componentOverr, _props$controlProps13, _props$componentOverr2, _props$controlProps14, _props$componentOverr3, _props$controlProps15, _props$componentOverr4, _props$controlProps16, _props$componentOverr5, _props$controlProps17, _props$componentOverr6, _props$controlProps18, _props$componentOverr7, _props$controlProps19, _props$controlProps20, _props$componentOverr8, _props$controlProps21, _props$componentOverr9, _props$controlProps22, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
61
61
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
62
62
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
63
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -368,7 +368,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
368
368
|
// This is to ensure to get latest state from cache in multitab
|
|
369
369
|
const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
370
370
|
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
371
|
-
(
|
|
371
|
+
dispatch({
|
|
372
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
373
|
+
payload: _Constants.ConversationEndEntity.Customer
|
|
374
|
+
});
|
|
372
375
|
} else {
|
|
373
376
|
const skipEndChatSDK = true;
|
|
374
377
|
const skipCloseChat = false;
|
|
@@ -506,36 +509,33 @@ const LiveChatWidgetStateful = props => {
|
|
|
506
509
|
}
|
|
507
510
|
}, [state.domainStates.confirmationState]);
|
|
508
511
|
(0, _react2.useEffect)(() => {
|
|
509
|
-
var _state$appStates8, _state$appStates9;
|
|
510
|
-
if ((state === null || state === void 0 ? void 0 : (_state$appStates8 = state.appStates) === null || _state$appStates8 === void 0 ? void 0 : _state$appStates8.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates9 = state.appStates) === null || _state$appStates9 === void 0 ? void 0 : _state$appStates9.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
|
|
511
|
-
dispatch({
|
|
512
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
513
|
-
payload: _ConversationState.ConversationState.InActive
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
}, [state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationEndedBy]);
|
|
517
|
-
(0, _react2.useEffect)(() => {
|
|
518
|
-
var _state$appStates11, _state$appStates12, _state$appStates13, _state$appStates14;
|
|
512
|
+
var _state$appStates8, _state$appStates9, _state$appStates10, _state$appStates11, _state$appStates12, _state$appStates13;
|
|
519
513
|
// Do not process anything during initialization
|
|
520
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
514
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates8 = state.appStates) === null || _state$appStates8 === void 0 ? void 0 : _state$appStates8.conversationEndedBy) === _Constants.ConversationEndEntity.NotSet) {
|
|
521
515
|
return;
|
|
522
516
|
}
|
|
523
517
|
|
|
524
518
|
// If start chat failed, and C2 is trying to close chat widget
|
|
525
|
-
if (state !== null && state !== void 0 && (_state$
|
|
519
|
+
if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed) {
|
|
526
520
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
|
|
527
521
|
return;
|
|
528
522
|
}
|
|
529
523
|
|
|
530
524
|
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
531
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
525
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === _ConversationState.ConversationState.Postchat || (state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === _ConversationState.ConversationState.InActive) {
|
|
532
526
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
|
|
533
527
|
return;
|
|
534
528
|
}
|
|
529
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
|
|
530
|
+
dispatch({
|
|
531
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
532
|
+
payload: _ConversationState.ConversationState.InActive
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
535
|
|
|
536
|
-
//All other cases
|
|
536
|
+
// All other cases
|
|
537
537
|
(0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
|
|
538
|
-
}, [state === null || state === void 0 ? void 0 : (_state$
|
|
538
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationEndedBy]);
|
|
539
539
|
|
|
540
540
|
// Publish chat widget state
|
|
541
541
|
(0, _react2.useEffect)(() => {
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { BroadcastService, BroadcastServiceInitialize, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
|
+
import { Components } from "botframework-webchat";
|
|
5
|
+
import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveWorkItemState, StorageType } from "../../../common/Constants";
|
|
4
6
|
import { Stack } from "@fluentui/react";
|
|
5
7
|
import React, { useEffect, useRef, useState } from "react";
|
|
6
8
|
import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
|
|
7
|
-
import { createTimer, getBroadcastChannelName, getLocaleDirection, getStateFromCache, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty,
|
|
9
|
+
import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty, newGuid } from "../../../common/utils";
|
|
8
10
|
import { endChat, prepareEndChat } from "../common/endChat";
|
|
11
|
+
import { handleChatReconnect, isReconnectEnabled } from "../common/reconnectChatHelper";
|
|
9
12
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
10
13
|
import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
|
|
11
14
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
12
15
|
import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
|
|
13
|
-
import { Components } from "botframework-webchat";
|
|
14
16
|
import ConfirmationPaneStateful from "../../confirmationpanestateful/ConfirmationPaneStateful";
|
|
15
17
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
16
18
|
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
17
|
-
import { Constants, E2VVOptions, StorageType, LiveWorkItemState, ConversationEndEntity, ConfirmationState } from "../../../common/Constants";
|
|
18
19
|
import { ElementType } from "@microsoft/omnichannel-chat-components";
|
|
19
20
|
import EmailTranscriptPaneStateful from "../../emailtranscriptpanestateful/EmailTranscriptPaneStateful";
|
|
20
21
|
import HeaderStateful from "../../headerstateful/HeaderStateful";
|
|
@@ -47,9 +48,8 @@ import { startProactiveChat } from "../common/startProactiveChat";
|
|
|
47
48
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
48
49
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
49
50
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
50
|
-
import { handleChatReconnect, isReconnectEnabled } from "../common/reconnectChatHelper";
|
|
51
51
|
export const LiveChatWidgetStateful = props => {
|
|
52
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$
|
|
52
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$styleProps2, _props$controlProps11, _props$controlProps12, _props$componentOverr, _props$controlProps13, _props$componentOverr2, _props$controlProps14, _props$componentOverr3, _props$controlProps15, _props$componentOverr4, _props$controlProps16, _props$componentOverr5, _props$controlProps17, _props$componentOverr6, _props$controlProps18, _props$componentOverr7, _props$controlProps19, _props$controlProps20, _props$componentOverr8, _props$controlProps21, _props$componentOverr9, _props$controlProps22, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
53
53
|
const [state, dispatch] = useChatContextStore();
|
|
54
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
55
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -360,7 +360,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
360
360
|
// This is to ensure to get latest state from cache in multitab
|
|
361
361
|
const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
|
|
362
362
|
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
363
|
-
|
|
363
|
+
dispatch({
|
|
364
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
365
|
+
payload: ConversationEndEntity.Customer
|
|
366
|
+
});
|
|
364
367
|
} else {
|
|
365
368
|
const skipEndChatSDK = true;
|
|
366
369
|
const skipCloseChat = false;
|
|
@@ -498,36 +501,33 @@ export const LiveChatWidgetStateful = props => {
|
|
|
498
501
|
}
|
|
499
502
|
}, [state.domainStates.confirmationState]);
|
|
500
503
|
useEffect(() => {
|
|
501
|
-
var _state$appStates8, _state$appStates9;
|
|
502
|
-
if ((state === null || state === void 0 ? void 0 : (_state$appStates8 = state.appStates) === null || _state$appStates8 === void 0 ? void 0 : _state$appStates8.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates9 = state.appStates) === null || _state$appStates9 === void 0 ? void 0 : _state$appStates9.conversationEndedBy) === ConversationEndEntity.Bot) {
|
|
503
|
-
dispatch({
|
|
504
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
505
|
-
payload: ConversationState.InActive
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
}, [state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationEndedBy]);
|
|
509
|
-
useEffect(() => {
|
|
510
|
-
var _state$appStates11, _state$appStates12, _state$appStates13, _state$appStates14;
|
|
504
|
+
var _state$appStates8, _state$appStates9, _state$appStates10, _state$appStates11, _state$appStates12, _state$appStates13;
|
|
511
505
|
// Do not process anything during initialization
|
|
512
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
506
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates8 = state.appStates) === null || _state$appStates8 === void 0 ? void 0 : _state$appStates8.conversationEndedBy) === ConversationEndEntity.NotSet) {
|
|
513
507
|
return;
|
|
514
508
|
}
|
|
515
509
|
|
|
516
510
|
// If start chat failed, and C2 is trying to close chat widget
|
|
517
|
-
if (state !== null && state !== void 0 && (_state$
|
|
511
|
+
if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed) {
|
|
518
512
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
|
|
519
513
|
return;
|
|
520
514
|
}
|
|
521
515
|
|
|
522
516
|
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
523
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
517
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === ConversationState.Postchat || (state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === ConversationState.InActive) {
|
|
524
518
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
|
|
525
519
|
return;
|
|
526
520
|
}
|
|
521
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === ConversationEndEntity.Bot) {
|
|
522
|
+
dispatch({
|
|
523
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
524
|
+
payload: ConversationState.InActive
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
527
|
|
|
528
|
-
//All other cases
|
|
528
|
+
// All other cases
|
|
529
529
|
prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
|
|
530
|
-
}, [state === null || state === void 0 ? void 0 : (_state$
|
|
530
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationEndedBy]);
|
|
531
531
|
|
|
532
532
|
// Publish chat widget state
|
|
533
533
|
useEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.0.3
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -111,4 +111,4 @@
|
|
|
111
111
|
"**/abort-controller-es5": "^2.0.1",
|
|
112
112
|
"**/minimist": "1.2.6"
|
|
113
113
|
}
|
|
114
|
-
}
|
|
114
|
+
}
|