@microsoft/omnichannel-chat-widget 1.0.3-main.527f8c3 → 1.0.3-main.8b82e52
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 +54 -1
- package/lib/cjs/common/storage/default/defaultCacheManager.js +7 -6
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -1
- package/lib/cjs/common/utils.js +27 -5
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +1 -10
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +197 -99
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +41 -21
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +139 -0
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +2 -255
- package/lib/cjs/components/livechatwidget/common/startChat.js +70 -57
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +162 -100
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +15 -5
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +62 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +25 -12
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +16 -13
- package/lib/cjs/contexts/createReducer.js +13 -23
- package/lib/cjs/controller/componentController.js +2 -1
- package/lib/cjs/index.js +20 -0
- package/lib/esm/common/Constants.js +49 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +5 -4
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/esm/common/telemetry/TelemetryConstants.js +6 -1
- package/lib/esm/common/utils.js +25 -4
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -13
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +196 -99
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +41 -21
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +130 -0
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -255
- package/lib/esm/components/livechatwidget/common/startChat.js +71 -58
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +164 -102
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +15 -5
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +54 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +25 -12
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -15
- package/lib/esm/contexts/createReducer.js +13 -23
- package/lib/esm/controller/componentController.js +2 -1
- package/lib/esm/index.js +4 -1
- package/lib/types/common/Constants.d.ts +21 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +3 -3
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +2 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -1
- package/lib/types/common/utils.d.ts +3 -2
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +6 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -6
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.d.ts +9 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +8 -7
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +2 -1
- package/lib/types/index.d.ts +3 -0
- package/package.json +2 -1
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +0 -36
- package/lib/cjs/contexts/common/ConversationEndEntity.js +0 -12
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +0 -30
- package/lib/esm/contexts/common/ConversationEndEntity.js +0 -5
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +0 -6
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +0 -4
|
@@ -13,21 +13,31 @@ var _utils = require("../../common/utils");
|
|
|
13
13
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
14
14
|
var _PostChatSurveyMode = require("./enums/PostChatSurveyMode");
|
|
15
15
|
var _CustomerVoiceEvents = require("./enums/CustomerVoiceEvents");
|
|
16
|
+
var _Constants = require("../../common/Constants");
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
18
|
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); }
|
|
18
19
|
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; }
|
|
20
|
+
const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact) {
|
|
21
|
+
let showMultiLingual = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
22
|
+
const surveyLink = `${surveyInviteLink}
|
|
23
|
+
&embed=${isEmbed.toString()}
|
|
24
|
+
&compact=${compact.toString() ?? "true"}
|
|
25
|
+
&lang=${locale ?? "en-us"}
|
|
26
|
+
&showmultilingual=${showMultiLingual.toString() ?? "false"}`;
|
|
27
|
+
return surveyLink;
|
|
28
|
+
};
|
|
19
29
|
const PostChatSurveyPaneStateful = props => {
|
|
20
|
-
var
|
|
30
|
+
var _props$styleProps, _state$appStates, _state$appStates2, _props$controlProps;
|
|
21
31
|
const [state] = (0, _useChatContextStore.default)();
|
|
22
|
-
const postChatSurveyMode = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveymode;
|
|
23
32
|
const generalStyleProps = Object.assign({}, _defaultgeneralPostChatSurveyPaneStyleProps.defaultGeneralPostChatSurveyPaneStyleProps, (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps, {
|
|
24
33
|
display: state.appStates.isMinimized ? "none" : ""
|
|
25
34
|
});
|
|
26
35
|
let surveyInviteLink = "";
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
const surveyMode = (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.selectedSurveyMode) === _PostChatSurveyMode.PostChatSurveyMode.Embed;
|
|
37
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === _Constants.ConversationEndEntity.Bot && state.domainStates.postChatContext.botSurveyInviteLink) {
|
|
38
|
+
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
29
39
|
} else {
|
|
30
|
-
surveyInviteLink = state.domainStates.postChatContext.surveyInviteLink
|
|
40
|
+
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
31
41
|
}
|
|
32
42
|
const styleProps = {
|
|
33
43
|
...props.styleProps,
|
|
@@ -7,8 +7,8 @@ exports.default = exports.PreChatSurveyPaneStateful = void 0;
|
|
|
7
7
|
var _Constants = require("../../common/Constants");
|
|
8
8
|
var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _markdownIt = _interopRequireDefault(require("markdown-it"));
|
|
11
10
|
var _utils = require("../../common/utils");
|
|
11
|
+
var _markdownIt = _interopRequireDefault(require("markdown-it"));
|
|
12
12
|
var _ConversationState = require("../../contexts/common/ConversationState");
|
|
13
13
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
14
14
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -75,12 +75,13 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
75
75
|
payload: _ConversationState.ConversationState.Loading
|
|
76
76
|
});
|
|
77
77
|
try {
|
|
78
|
-
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
|
|
79
|
-
const
|
|
78
|
+
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt, _state$appStates;
|
|
79
|
+
const widgetInstanceId = (0, _utils.getWidgetCacheId)(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "", state.domainStates.widgetInstanceId ?? "");
|
|
80
|
+
const persistedState = (0, _utils.getStateFromCache)(widgetInstanceId);
|
|
80
81
|
let optionalParams = {};
|
|
81
82
|
|
|
82
83
|
//Connect to Active chats and chat is not popout
|
|
83
|
-
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : _persistedState$domai.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === _ConversationState.ConversationState.Active && state.appStates.hideStartChatButton === false) {
|
|
84
|
+
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : _persistedState$domai.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === _ConversationState.ConversationState.Active && (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.hideStartChatButton) === false) {
|
|
84
85
|
var _persistedState$domai2;
|
|
85
86
|
optionalParams = {
|
|
86
87
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai2 = persistedState.domainStates) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.liveChatContext
|
|
@@ -40,7 +40,10 @@ const ReconnectChatPaneStateful = props => {
|
|
|
40
40
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
41
41
|
payload: undefined
|
|
42
42
|
});
|
|
43
|
-
|
|
43
|
+
if (state !== null && state !== void 0 && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.initialChatSdkRequestId) {
|
|
44
|
+
var _state$domainStates2;
|
|
45
|
+
chatSDK.requestId = state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.initialChatSdkRequestId;
|
|
46
|
+
}
|
|
44
47
|
const parseToJson = false;
|
|
45
48
|
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
46
49
|
if (preChatSurveyResponse) {
|
|
@@ -16,6 +16,7 @@ const defaultWebChatContainerStatefulProps = {
|
|
|
16
16
|
containerStyles: _defaultWebChatStatefulContainerStyles.defaultWebChatStatefulContainerStyles,
|
|
17
17
|
disableNewLineMarkdownSupport: false,
|
|
18
18
|
disableMarkdownMessageFormatting: false,
|
|
19
|
+
hyperlinkTextOverride: false,
|
|
19
20
|
directLine: new _mockadapter.default(),
|
|
20
21
|
adaptiveCardStyles: _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles
|
|
21
22
|
};
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MockChatSDK = void 0;
|
|
7
|
+
var _Constants = require("../../../common/Constants");
|
|
7
8
|
var _mockadapter = _interopRequireDefault(require("./mockadapter"));
|
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
10
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -11,6 +12,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
11
12
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
13
|
class MockChatSDK {
|
|
13
14
|
constructor() {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
16
|
_defineProperty(this, "sleep", ms => new Promise(r => setTimeout(r, ms)));
|
|
15
17
|
_defineProperty(this, "isMockModeOn", true);
|
|
16
18
|
}
|
|
@@ -33,7 +35,10 @@ class MockChatSDK {
|
|
|
33
35
|
}
|
|
34
36
|
getConversationDetails() {
|
|
35
37
|
return {
|
|
36
|
-
State: "Active"
|
|
38
|
+
State: "Active",
|
|
39
|
+
conversationId: "",
|
|
40
|
+
canRenderPostChat: "",
|
|
41
|
+
participantType: _Constants.ParticipantType.User
|
|
37
42
|
};
|
|
38
43
|
}
|
|
39
44
|
getCurrentLiveChatContext() {
|
|
@@ -9,4 +9,5 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
9
9
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
10
10
|
class WebChatStoreLoader {}
|
|
11
11
|
exports.WebChatStoreLoader = WebChatStoreLoader;
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
13
|
_defineProperty(WebChatStoreLoader, "store", void 0);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
8
|
+
var _Constants = require("../../../../common/Constants");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
class HyperlinkTextOverrideRenderer {
|
|
14
|
+
constructor(hyperlinkTextOverride) {
|
|
15
|
+
_defineProperty(this, "hyperlinkTextOverride", void 0);
|
|
16
|
+
this.hyperlinkTextOverride = hyperlinkTextOverride;
|
|
17
|
+
}
|
|
18
|
+
convertTextToHtmlNode(text) {
|
|
19
|
+
const htmlNode = document.createElement(_Constants.HtmlAttributeNames.div);
|
|
20
|
+
try {
|
|
21
|
+
text = _dompurify.default.sanitize(text); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
22
|
+
htmlNode.innerHTML = text;
|
|
23
|
+
} catch {
|
|
24
|
+
return htmlNode;
|
|
25
|
+
}
|
|
26
|
+
return htmlNode;
|
|
27
|
+
}
|
|
28
|
+
processANode(htmlNode) {
|
|
29
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
30
|
+
const aTags = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
|
|
31
|
+
for (let index = 0; index < aTags.length; index++) {
|
|
32
|
+
const aNode = aTags[index];
|
|
33
|
+
if (!aNode || !aNode.tagName || aNode.tagName.toLowerCase() !== _Constants.HtmlAttributeNames.aTagName || !aNode.href) continue;
|
|
34
|
+
if (aNode.href !== aNode.text.trim()) {
|
|
35
|
+
aNode.text = aNode.href;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
applicable(text) {
|
|
40
|
+
if (!this.hyperlinkTextOverride) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const htmlNode = this.convertTextToHtmlNode(text);
|
|
45
|
+
const aNodes = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
|
|
46
|
+
return !!aNodes && aNodes.length && aNodes.length > 0;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
render(text) {
|
|
52
|
+
if (!this.applicable(text)) {
|
|
53
|
+
return text;
|
|
54
|
+
}
|
|
55
|
+
const htmlNode = this.convertTextToHtmlNode(text);
|
|
56
|
+
this.processANode(htmlNode);
|
|
57
|
+
text = htmlNode.innerHTML;
|
|
58
|
+
return text;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
var _default = HyperlinkTextOverrideRenderer;
|
|
62
|
+
exports.default = _default;
|
|
@@ -23,13 +23,15 @@ const createConversationEndMiddleware = conversationEndCallback => _ref => {
|
|
|
23
23
|
return next => action => {
|
|
24
24
|
var _action$payload;
|
|
25
25
|
if ((action === null || action === void 0 ? void 0 : action.type) == _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
|
|
26
|
-
var _activity$
|
|
26
|
+
var _activity$from2, _activity$channelData7, _activity$channelData8;
|
|
27
27
|
const activity = action.payload.activity;
|
|
28
|
-
if (
|
|
29
|
-
var _activity$
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
if (activity.channelId === "ACS_CHANNEL") {
|
|
29
|
+
var _activity$from;
|
|
30
|
+
if (((_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Bot) {
|
|
31
|
+
var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6;
|
|
32
|
+
if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(_Constants.Constants.systemMessageTag) && ((_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(_Constants.Constants.agentEndConversationMessageTag) || (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.supervisorForceCloseMessageTag))) {
|
|
33
|
+
conversationEndCallback();
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
36
|
} else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel && ((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.type) === _MessageType.MessageTypes.Thread && (_activity$channelData8 = activity.channelData) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.properties) {
|
|
35
37
|
var _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12;
|
|
@@ -28,22 +28,25 @@ const applyDataMasking = (action, regexCollection) => {
|
|
|
28
28
|
});
|
|
29
29
|
return action;
|
|
30
30
|
}
|
|
31
|
-
let isRuleMatched = false;
|
|
32
31
|
for (const ruleId of Object.keys(regexCollection)) {
|
|
33
32
|
const item = regexCollection[ruleId];
|
|
34
33
|
if (item) {
|
|
34
|
+
let ruleInfiniteException = false;
|
|
35
|
+
let ruleApplied = false;
|
|
35
36
|
try {
|
|
36
37
|
const regex = new RegExp(item, "gi");
|
|
37
38
|
let match;
|
|
38
39
|
// eslint-disable-next-line no-cond-assign
|
|
39
40
|
while (match = regex.exec(text)) {
|
|
40
41
|
const replaceStr = match[0].replace(/./gi, maskedChar);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const modifiedText = text.replace(match[0], replaceStr);
|
|
43
|
+
if (modifiedText == text) {
|
|
44
|
+
ruleInfiniteException = true;
|
|
45
|
+
console.warn(`The data masking rule ${item} is ignored because it matches empty strings. Please modify this rule.`);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
ruleApplied = true;
|
|
49
|
+
text = modifiedText;
|
|
47
50
|
}
|
|
48
51
|
} catch (err) {
|
|
49
52
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -54,11 +57,21 @@ const applyDataMasking = (action, regexCollection) => {
|
|
|
54
57
|
}
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (ruleApplied) {
|
|
61
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
62
|
+
Event: _TelemetryConstants.TelemetryEvent.DataMaskingRuleApplied,
|
|
63
|
+
Description: `Data Masking Rule Id: ${ruleId} applied.`
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (ruleInfiniteException) {
|
|
67
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
68
|
+
Event: _TelemetryConstants.TelemetryEvent.DataMaskingRuleApplyFailed,
|
|
69
|
+
ExceptionDetails: {
|
|
70
|
+
RuleId: ruleId,
|
|
71
|
+
Exception: "The data masking rule matches empty strings."
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
62
75
|
}
|
|
63
76
|
}
|
|
64
77
|
action.payload.text = text;
|
|
@@ -7,12 +7,15 @@ exports.createWebChatTelemetry = createWebChatTelemetry;
|
|
|
7
7
|
var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _TelemetryHelper = require("../../../../common/telemetry/TelemetryHelper");
|
|
9
9
|
function createWebChatTelemetry() {
|
|
10
|
+
let isInitEventLogged = false;
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
12
|
const handleTelemetry = event => {
|
|
12
13
|
const {
|
|
13
|
-
level
|
|
14
|
+
level,
|
|
15
|
+
name
|
|
14
16
|
} = event;
|
|
15
17
|
const loglevel = level ? level.toUpperCase() : "";
|
|
18
|
+
if ((name === null || name === void 0 ? void 0 : name.toLowerCase()) === "init" && isInitEventLogged) return;
|
|
16
19
|
switch (loglevel) {
|
|
17
20
|
case _TelemetryConstants.LogLevel.DEBUG:
|
|
18
21
|
_TelemetryHelper.TelemetryHelper.logWebChatEvent(_TelemetryConstants.LogLevel.DEBUG, event);
|
|
@@ -28,6 +31,9 @@ function createWebChatTelemetry() {
|
|
|
28
31
|
_TelemetryHelper.TelemetryHelper.logWebChatEvent(_TelemetryConstants.LogLevel.INFO, event);
|
|
29
32
|
break;
|
|
30
33
|
}
|
|
34
|
+
if ((name === null || name === void 0 ? void 0 : name.toLowerCase()) === "init") {
|
|
35
|
+
isInitEventLogged = true;
|
|
36
|
+
}
|
|
31
37
|
};
|
|
32
38
|
return handleTelemetry;
|
|
33
39
|
}
|
|
@@ -48,4 +48,6 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
48
48
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INITIAL_CHAT_SDK_REQUEST_ID"] = 38] = "SET_INITIAL_CHAT_SDK_REQUEST_ID";
|
|
49
49
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOULD_USE_BOT_SURVEY"] = 39] = "SET_SHOULD_USE_BOT_SURVEY";
|
|
50
50
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_DISCONNECT_EVENT_RECEIVED"] = 40] = "SET_CHAT_DISCONNECT_EVENT_RECEIVED";
|
|
51
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 41] = "SET_SURVEY_MODE";
|
|
52
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 42] = "SET_CONFIRMATION_STATE";
|
|
51
53
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -10,12 +10,14 @@ var _utils = require("../../common/utils");
|
|
|
10
10
|
var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
|
|
11
11
|
var _Constants = require("../../common/Constants");
|
|
12
12
|
const getLiveChatWidgetContextInitialState = props => {
|
|
13
|
-
var _props$
|
|
14
|
-
const widgetCacheId = (0, _utils.
|
|
15
|
-
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$
|
|
16
|
-
const
|
|
13
|
+
var _props$controlProps, _props$webChatContain;
|
|
14
|
+
const widgetCacheId = (0, _utils.getWidgetCacheIdfromProps)(props);
|
|
15
|
+
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.cacheTtlInMins) ?? _Constants.Constants.CacheTtlInMinutes;
|
|
16
|
+
const storageType = (props === null || props === void 0 ? void 0 : props.useSessionStorage) === true ? _Constants.StorageType.sessionStorage : _Constants.StorageType.localStorage;
|
|
17
|
+
const initialState = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)(cacheTtlInMins, storageType).getData(widgetCacheId);
|
|
17
18
|
if (!(0, _utils.isNullOrUndefined)(initialState)) {
|
|
18
|
-
|
|
19
|
+
const initialStateFromCache = JSON.parse(initialState);
|
|
20
|
+
return initialStateFromCache;
|
|
19
21
|
}
|
|
20
22
|
const LiveChatWidgetContextInitialState = {
|
|
21
23
|
domainStates: {
|
|
@@ -32,13 +34,16 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
32
34
|
customContext: undefined,
|
|
33
35
|
widgetSize: undefined,
|
|
34
36
|
widgetInstanceId: "",
|
|
35
|
-
initialChatSdkRequestId: ""
|
|
37
|
+
initialChatSdkRequestId: "",
|
|
38
|
+
transcriptRequestId: "",
|
|
39
|
+
confirmationPaneConfirmedOptionClicked: false,
|
|
40
|
+
confirmationState: _Constants.ConfirmationState.NotSet
|
|
36
41
|
},
|
|
37
42
|
appStates: {
|
|
38
43
|
conversationState: _ConversationState.ConversationState.Closed,
|
|
39
|
-
isMinimized:
|
|
44
|
+
isMinimized: undefined,
|
|
40
45
|
previousElementIdOnFocusBeforeModalOpen: null,
|
|
41
|
-
|
|
46
|
+
startChatFailed: false,
|
|
42
47
|
outsideOperatingHours: false,
|
|
43
48
|
preChatResponseEmail: "",
|
|
44
49
|
isAudioMuted: null,
|
|
@@ -52,11 +57,9 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
52
57
|
},
|
|
53
58
|
e2vvEnabled: false,
|
|
54
59
|
unreadMessageCount: 0,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
shouldUseBotSurvey: false,
|
|
59
|
-
chatDisconnectEventReceived: false
|
|
60
|
+
conversationEndedBy: _Constants.ConversationEndEntity.NotSet,
|
|
61
|
+
chatDisconnectEventReceived: false,
|
|
62
|
+
selectedSurveyMode: null
|
|
60
63
|
},
|
|
61
64
|
uiStates: {
|
|
62
65
|
showConfirmationPane: false,
|
|
@@ -64,7 +64,7 @@ const createReducer = () => {
|
|
|
64
64
|
...state,
|
|
65
65
|
appStates: {
|
|
66
66
|
...state.appStates,
|
|
67
|
-
|
|
67
|
+
startChatFailed: action.payload
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS:
|
|
@@ -264,14 +264,6 @@ const createReducer = () => {
|
|
|
264
264
|
return {
|
|
265
265
|
...action.payload
|
|
266
266
|
};
|
|
267
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED:
|
|
268
|
-
return {
|
|
269
|
-
...state,
|
|
270
|
-
appStates: {
|
|
271
|
-
...state.appStates,
|
|
272
|
-
conversationEndedByAgentEventReceived: action.payload
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
267
|
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY:
|
|
276
268
|
return {
|
|
277
269
|
...state,
|
|
@@ -307,15 +299,6 @@ const createReducer = () => {
|
|
|
307
299
|
liveChatConfig: action.payload
|
|
308
300
|
}
|
|
309
301
|
};
|
|
310
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS:
|
|
311
|
-
return {
|
|
312
|
-
...state,
|
|
313
|
-
appStates: {
|
|
314
|
-
...state.appStates,
|
|
315
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
316
|
-
postChatWorkflowInProgress: action.payload
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
302
|
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID:
|
|
320
303
|
return {
|
|
321
304
|
...state,
|
|
@@ -324,21 +307,28 @@ const createReducer = () => {
|
|
|
324
307
|
initialChatSdkRequestId: action.payload
|
|
325
308
|
}
|
|
326
309
|
};
|
|
327
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
310
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED:
|
|
328
311
|
return {
|
|
329
312
|
...state,
|
|
330
313
|
appStates: {
|
|
331
314
|
...state.appStates,
|
|
332
|
-
|
|
333
|
-
shouldUseBotSurvey: action.payload
|
|
315
|
+
chatDisconnectEventReceived: action.payload
|
|
334
316
|
}
|
|
335
317
|
};
|
|
336
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
318
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SURVEY_MODE:
|
|
337
319
|
return {
|
|
338
320
|
...state,
|
|
339
321
|
appStates: {
|
|
340
322
|
...state.appStates,
|
|
341
|
-
|
|
323
|
+
selectedSurveyMode: action.payload
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONFIRMATION_STATE:
|
|
327
|
+
return {
|
|
328
|
+
...state,
|
|
329
|
+
domainStates: {
|
|
330
|
+
...state.domainStates,
|
|
331
|
+
confirmationState: action.payload
|
|
342
332
|
}
|
|
343
333
|
};
|
|
344
334
|
default:
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.shouldShowWebChatContainer = exports.shouldShowReconnectChatPane = exports.shouldShowProactiveChatPane = exports.shouldShowPreChatSurveyPane = exports.shouldShowPostChatSurveyPane = exports.shouldShowPostChatLoadingPane = exports.shouldShowOutOfOfficeHoursPane = exports.shouldShowLoadingPane = exports.shouldShowHeader = exports.shouldShowFooter = exports.shouldShowEmailTranscriptPane = exports.shouldShowConfirmationPane = exports.shouldShowChatButton = exports.shouldShowCallingContainer = void 0;
|
|
7
7
|
var _ConversationState = require("../contexts/common/ConversationState");
|
|
8
8
|
const shouldShowChatButton = state => {
|
|
9
|
-
|
|
9
|
+
var _state$appStates;
|
|
10
|
+
return (state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed) && (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.hideStartChatButton) === false; // Do not show chat button in case of popout
|
|
10
11
|
};
|
|
11
12
|
exports.shouldShowChatButton = shouldShowChatButton;
|
|
12
13
|
const shouldShowProactiveChatPane = state => {
|
package/lib/cjs/index.js
CHANGED
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "BroadcastService", {
|
|
|
9
9
|
return _omnichannelChatComponents.BroadcastService;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "ConversationState", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _ConversationState.ConversationState;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "LiveChatWidget", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function () {
|
|
@@ -27,6 +33,18 @@ Object.defineProperty(exports, "encodeComponentString", {
|
|
|
27
33
|
return _omnichannelChatComponents.encodeComponentString;
|
|
28
34
|
}
|
|
29
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "getWidgetCacheId", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _utils.getWidgetCacheId;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "getWidgetEndChatEventName", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _utils.getWidgetEndChatEventName;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
30
48
|
Object.defineProperty(exports, "useChatContextStore", {
|
|
31
49
|
enumerable: true,
|
|
32
50
|
get: function () {
|
|
@@ -42,5 +60,7 @@ Object.defineProperty(exports, "useChatSDKStore", {
|
|
|
42
60
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
43
61
|
var _useChatContextStore = _interopRequireDefault(require("./hooks/useChatContextStore"));
|
|
44
62
|
var _useChatSDKStore = _interopRequireDefault(require("./hooks/useChatSDKStore"));
|
|
63
|
+
var _utils = require("./common/utils");
|
|
64
|
+
var _ConversationState = require("./contexts/common/ConversationState");
|
|
45
65
|
var _LiveChatWidget = _interopRequireDefault(require("./components/livechatwidget/LiveChatWidget"));
|
|
46
66
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|