@microsoft/omnichannel-chat-widget 0.1.0-main.9e62ed8 → 0.1.0-main.a27ec4b
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/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +12 -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/footerstateful/FooterStateful.js +1 -8
- 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 +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +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 +153 -85
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -116
- 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 +16 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +12 -5
- 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/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +12 -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/footerstateful/FooterStateful.js +1 -8
- 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 +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +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 +148 -86
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -117
- 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 +14 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -5
- 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/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +11 -2
- 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 +5 -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 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.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/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +4 -3
|
@@ -33,6 +33,10 @@ var _Constants = require("../../common/Constants");
|
|
|
33
33
|
|
|
34
34
|
var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
|
|
35
35
|
|
|
36
|
+
var _defaultAdaptiveCardStyles = require("./common/defaultStyles/defaultAdaptiveCardStyles");
|
|
37
|
+
|
|
38
|
+
var _defaultReceivedMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles");
|
|
39
|
+
|
|
36
40
|
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); }
|
|
37
41
|
|
|
38
42
|
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; }
|
|
@@ -66,6 +70,8 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
66
70
|
};
|
|
67
71
|
|
|
68
72
|
const WebChatContainerStateful = props => {
|
|
73
|
+
var _props$adaptiveCardSt, _props$adaptiveCardSt2, _props$renderingMiddl, _props$renderingMiddl2, _props$renderingMiddl3, _props$renderingMiddl4;
|
|
74
|
+
|
|
69
75
|
const {
|
|
70
76
|
BasicWebChat
|
|
71
77
|
} = _botframeworkWebchat.Components;
|
|
@@ -139,10 +145,18 @@ const WebChatContainerStateful = props => {
|
|
|
139
145
|
magicCodeBroadcastChannel.addEventListener(broadcastChannelMessageEvent, eventListener);
|
|
140
146
|
}, []);
|
|
141
147
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
148
|
+
|
|
149
|
+
.webchat__bubble__content>div#ms_lcw_webchat_adaptive_card {
|
|
150
|
+
background: ${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt = props.adaptiveCardStyles) === null || _props$adaptiveCardSt === void 0 ? void 0 : _props$adaptiveCardSt.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
div[class="ac-textBlock"]>p{color:${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt2 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt2 === void 0 ? void 0 : _props$adaptiveCardSt2.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color};}
|
|
154
|
+
|
|
142
155
|
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
143
156
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
144
157
|
height: '.75em';
|
|
145
|
-
marginLeft: '.25em';
|
|
158
|
+
marginLeft: '.25em';
|
|
159
|
+
filter:${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl = props.renderingMiddlewareProps) === null || _props$renderingMiddl === void 0 ? void 0 : (_props$renderingMiddl2 = _props$renderingMiddl.receivedMessageAnchorStyles) === null || _props$renderingMiddl2 === void 0 ? void 0 : _props$renderingMiddl2.filter) ?? "none"};
|
|
146
160
|
}
|
|
147
161
|
pre {
|
|
148
162
|
white-space: pre-wrap;
|
|
@@ -155,7 +169,7 @@ const WebChatContainerStateful = props => {
|
|
|
155
169
|
.ms_lcw_webchat_received_message a:visited,
|
|
156
170
|
.ms_lcw_webchat_received_message a:hover,
|
|
157
171
|
.ms_lcw_webchat_received_message a:active {
|
|
158
|
-
color:
|
|
172
|
+
color: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl3 = props.renderingMiddlewareProps) === null || _props$renderingMiddl3 === void 0 ? void 0 : (_props$renderingMiddl4 = _props$renderingMiddl3.receivedMessageAnchorStyles) === null || _props$renderingMiddl4 === void 0 ? void 0 : _props$renderingMiddl4.color) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.color)};
|
|
159
173
|
} `), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
160
174
|
styles: containerStyles
|
|
161
175
|
}, /*#__PURE__*/_react2.default.createElement(BasicWebChat, null)));
|
|
@@ -13,6 +13,8 @@ var _defaultWebChatStatefulProps = require("./defaultWebChatStatefulProps");
|
|
|
13
13
|
|
|
14
14
|
var _defaultWebChatContainerStatefulStyles = require("../defaultStyles/defaultWebChatContainerStatefulStyles");
|
|
15
15
|
|
|
16
|
+
var _defaultAdaptiveCardStyles = require("../defaultStyles/defaultAdaptiveCardStyles");
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
20
|
const defaultWebChatContainerStatefulProps = {
|
|
@@ -21,6 +23,7 @@ const defaultWebChatContainerStatefulProps = {
|
|
|
21
23
|
containerStyles: _defaultWebChatStatefulContainerStyles.defaultWebChatStatefulContainerStyles,
|
|
22
24
|
disableNewLineMarkdownSupport: false,
|
|
23
25
|
disableMarkdownMessageFormatting: false,
|
|
24
|
-
directLine: new _mockadapter.default()
|
|
26
|
+
directLine: new _mockadapter.default(),
|
|
27
|
+
adaptiveCardStyles: _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles
|
|
25
28
|
};
|
|
26
29
|
exports.defaultWebChatContainerStatefulProps = defaultWebChatContainerStatefulProps;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultAdaptiveCardStyles = void 0;
|
|
7
|
+
const defaultAdaptiveCardStyles = {
|
|
8
|
+
background: "white",
|
|
9
|
+
color: "black"
|
|
10
|
+
};
|
|
11
|
+
exports.defaultAdaptiveCardStyles = defaultAdaptiveCardStyles;
|
|
@@ -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";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultReceivedMessageAnchorStyles = void 0;
|
|
7
|
+
const defaultReceivedMessageAnchorStyles = {
|
|
8
|
+
color: "white"
|
|
9
|
+
};
|
|
10
|
+
exports.defaultReceivedMessageAnchorStyles = defaultReceivedMessageAnchorStyles;
|
|
@@ -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 = {}));
|
|
@@ -9,11 +9,18 @@ var _ConversationState = require("./ConversationState");
|
|
|
9
9
|
|
|
10
10
|
var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
11
11
|
|
|
12
|
+
var _utils = require("../../common/utils");
|
|
13
|
+
|
|
14
|
+
var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
|
|
15
|
+
|
|
12
16
|
const getLiveChatWidgetContextInitialState = props => {
|
|
13
|
-
var _props$webChatContain;
|
|
17
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$webChatContain;
|
|
18
|
+
|
|
19
|
+
const widgetCacheId = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
20
|
+
const initialState = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)().getData(widgetCacheId, "localStorage");
|
|
14
21
|
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
22
|
+
if (!(0, _utils.isNullOrUndefined)(initialState)) {
|
|
23
|
+
return JSON.parse(initialState);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
const LiveChatWidgetContextInitialState = {
|
|
@@ -29,14 +36,14 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
29
36
|
globalDir: "ltr",
|
|
30
37
|
liveChatContext: undefined,
|
|
31
38
|
customContext: undefined,
|
|
32
|
-
widgetSize: undefined
|
|
39
|
+
widgetSize: undefined,
|
|
40
|
+
widgetInstanceId: ""
|
|
33
41
|
},
|
|
34
42
|
appStates: {
|
|
35
43
|
conversationState: _ConversationState.ConversationState.Closed,
|
|
36
44
|
isMinimized: false,
|
|
37
45
|
previousElementOnFocusBeforeModalOpen: null,
|
|
38
46
|
outsideOperatingHours: false,
|
|
39
|
-
shouldShowPostChat: false,
|
|
40
47
|
preChatResponseEmail: "",
|
|
41
48
|
isAudioMuted: null,
|
|
42
49
|
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
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
|
+
import { getWidgetCacheId } from "../../utils";
|
|
5
|
+
import { defaultClientDataStoreProvider } from "./defaultClientDataStoreProvider";
|
|
6
|
+
export class defaultCacheManager {}
|
|
7
|
+
|
|
8
|
+
_defineProperty(defaultCacheManager, "InternalCache", {});
|
|
9
|
+
|
|
10
|
+
export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
|
|
11
|
+
const widgetCacheId = getWidgetCacheId(orgid, widgetId, widgetInstanceId);
|
|
12
|
+
BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
|
|
13
|
+
try {
|
|
14
|
+
defaultClientDataStoreProvider().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("Error in setting data to localstorage", error);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { inMemoryDataStore } from "./defaultInMemoryDataStore";
|
|
2
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
3
|
+
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
4
|
+
export const defaultClientDataStoreProvider = () => {
|
|
5
|
+
const isCookieAllowed = () => {
|
|
6
|
+
try {
|
|
7
|
+
localStorage;
|
|
8
|
+
sessionStorage;
|
|
9
|
+
return true;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error("Third party cookie blocked");
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const TtlInMs = 15 * 60 * 1000; // 15 mins
|
|
17
|
+
|
|
18
|
+
const dataStoreProvider = {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
setData: (key, data, type) => {
|
|
21
|
+
if (isCookieAllowed()) {
|
|
22
|
+
try {
|
|
23
|
+
if (key) {
|
|
24
|
+
const now = new Date();
|
|
25
|
+
const item = {
|
|
26
|
+
data: data,
|
|
27
|
+
expiry: now.getTime() + TtlInMs
|
|
28
|
+
};
|
|
29
|
+
const strItem = JSON.stringify(item);
|
|
30
|
+
|
|
31
|
+
if (type === "localStorage") {
|
|
32
|
+
localStorage.setItem(key, strItem);
|
|
33
|
+
} else {
|
|
34
|
+
sessionStorage.setItem(key, strItem);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
39
|
+
Event: TelemetryEvent.ClientDataStoreProviderFailed,
|
|
40
|
+
ExceptionDetails: error,
|
|
41
|
+
Description: "Unable to store data in localStorage."
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
const dataToCache = {
|
|
46
|
+
key: key,
|
|
47
|
+
data: data,
|
|
48
|
+
type: type
|
|
49
|
+
};
|
|
50
|
+
parent.postMessage(dataToCache, "*");
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
getData: (key, type) => {
|
|
55
|
+
if (isCookieAllowed()) {
|
|
56
|
+
let item;
|
|
57
|
+
|
|
58
|
+
if (type === "localStorage") {
|
|
59
|
+
item = localStorage.getItem(key);
|
|
60
|
+
} else {
|
|
61
|
+
item = sessionStorage.getItem(key);
|
|
62
|
+
} //Return item if not expired
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
let itemInJson = undefined;
|
|
66
|
+
|
|
67
|
+
if (item !== null) {
|
|
68
|
+
itemInJson = JSON.parse(item);
|
|
69
|
+
const now = new Date(); // compare the expiry time of the item with the current time
|
|
70
|
+
|
|
71
|
+
if (now.getTime() > itemInJson.expiry) {
|
|
72
|
+
// If the item is expired, delete the item from storage
|
|
73
|
+
// and return null
|
|
74
|
+
localStorage.removeItem(key);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return itemInJson.data;
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
// get data from in memory db when cookie is disabled
|
|
82
|
+
return inMemoryDataStore().getData(key);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
removeData: (key, type) => {
|
|
87
|
+
if (isCookieAllowed()) {
|
|
88
|
+
if (key) {
|
|
89
|
+
if (type === "localStorage") {
|
|
90
|
+
return localStorage.removeItem(key);
|
|
91
|
+
} else {
|
|
92
|
+
return sessionStorage.removeItem(key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
// get data from in memory db when cookie is disabled
|
|
97
|
+
return inMemoryDataStore().removeData(key);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return dataStoreProvider;
|
|
102
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
2
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
3
|
+
import { defaultCacheManager } from "./defaultCacheManager";
|
|
4
|
+
export const defaultInitializeInMemoryDataStore = widgetId => {
|
|
5
|
+
try {
|
|
6
|
+
localStorage;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
// Register below events when localStorage is not accessible
|
|
9
|
+
// Listening to event raised from client browser
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
window.addEventListener("message", function (e) {
|
|
12
|
+
try {
|
|
13
|
+
if (e.data.key) {
|
|
14
|
+
const browserData = e.data;
|
|
15
|
+
|
|
16
|
+
if (defaultCacheManager.InternalCache[browserData.key]) {
|
|
17
|
+
delete defaultCacheManager.InternalCache[browserData.key];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
defaultCacheManager.InternalCache[browserData.key] = browserData.data;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
24
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
25
|
+
ExceptionDetails: error,
|
|
26
|
+
Description: "Unable to register default in-memory cache."
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}); // send cache initialize message to client
|
|
30
|
+
|
|
31
|
+
if (defaultCacheManager.InternalCache === undefined || {}) {
|
|
32
|
+
parent.postMessage({
|
|
33
|
+
data: "cacheinitialize",
|
|
34
|
+
widgetId: widgetId
|
|
35
|
+
}, "*");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const inMemoryDataStore = () => {
|
|
40
|
+
const dataStoreProvider = {
|
|
41
|
+
getData: key => {
|
|
42
|
+
if (defaultCacheManager.InternalCache && defaultCacheManager.InternalCache[key]) {
|
|
43
|
+
return defaultCacheManager.InternalCache[key];
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
setData: (key, data) => {
|
|
48
|
+
try {
|
|
49
|
+
defaultCacheManager.InternalCache[key] = data;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
52
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
53
|
+
ExceptionDetails: error,
|
|
54
|
+
Description: "Unable to set data in default in-memory cache."
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
removeData: key => {
|
|
59
|
+
try {
|
|
60
|
+
defaultCacheManager.InternalCache[key] = {};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
63
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
64
|
+
ExceptionDetails: error,
|
|
65
|
+
Description: "Unable to remove data from default in-memory cache."
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return dataStoreProvider;
|
|
71
|
+
};
|
|
@@ -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;
|
|
@@ -88,6 +89,8 @@ export let TelemetryEvent;
|
|
|
88
89
|
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
89
90
|
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
90
91
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
92
|
+
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
93
|
+
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
91
94
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
92
95
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
93
96
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -128,6 +131,10 @@ export let TelemetryEvent;
|
|
|
128
131
|
TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
|
|
129
132
|
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
130
133
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
134
|
+
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
135
|
+
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
136
|
+
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
137
|
+
TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
|
|
131
138
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
132
139
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
133
140
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -154,6 +161,8 @@ export let TelemetryEvent;
|
|
|
154
161
|
TelemetryEvent["MessageSent"] = "MessageSent";
|
|
155
162
|
TelemetryEvent["MessageReceived"] = "MessageReceived";
|
|
156
163
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
164
|
+
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
165
|
+
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
157
166
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
158
167
|
|
|
159
168
|
export class TelemetryConstants {
|
|
@@ -199,6 +208,9 @@ export class TelemetryConstants {
|
|
|
199
208
|
case TelemetryEvent.MessageSent:
|
|
200
209
|
case TelemetryEvent.MessageReceived:
|
|
201
210
|
case TelemetryEvent.CustomContextReceived:
|
|
211
|
+
case TelemetryEvent.BrowserUnloadEventStarted:
|
|
212
|
+
case TelemetryEvent.NetworkDisconnected:
|
|
213
|
+
case TelemetryEvent.NetworkReconnected:
|
|
202
214
|
return ScenarioType.ACTIONS;
|
|
203
215
|
|
|
204
216
|
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 = {
|
|
@@ -84,14 +84,7 @@ export const FooterStateful = props => {
|
|
|
84
84
|
isAudioMuted: state.appStates.isAudioMuted
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
const footer = document.getElementById(footerId);
|
|
89
|
-
|
|
90
|
-
if (footer) {
|
|
91
|
-
footer.style.display = hideFooterDisplay ? "none" : "";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Footer, {
|
|
87
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !hideFooterDisplay && /*#__PURE__*/React.createElement(Footer, {
|
|
95
88
|
componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
|
|
96
89
|
controlProps: controlProps,
|
|
97
90
|
styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
|
|
@@ -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 {};
|