@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.7bdb634
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 +6 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -0
- package/lib/cjs/common/utils/SecureEventBus.js +307 -0
- package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
- package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
- package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
- package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +28 -3
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -6
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/cjs/components/livechatwidget/common/startChat.js +5 -4
- package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
- package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +122 -11
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
- package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +4 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/index.js +9 -1
- package/lib/esm/common/Constants.js +6 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +34 -0
- package/lib/esm/common/utils/SecureEventBus.js +328 -0
- package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
- package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
- package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
- package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +29 -4
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -6
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/esm/components/livechatwidget/common/startChat.js +5 -4
- package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
- package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +29 -5
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +125 -12
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/index.js +1 -0
- package/lib/types/common/Constants.d.ts +5 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +33 -2
- package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
- package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
- package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
- package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
- package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
- package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
- package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
- package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
- package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
- package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
- package/lib/types/index.d.ts +1 -0
- package/package.json +3 -3
- /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultCitationPaneStyles = exports.defaultCitationContentCSS = exports.default = void 0;
|
|
7
|
+
const defaultCitationPaneStyles = {
|
|
8
|
+
pane: {
|
|
9
|
+
position: "fixed",
|
|
10
|
+
left: "50%",
|
|
11
|
+
top: "18%",
|
|
12
|
+
transform: "translateX(-50%)",
|
|
13
|
+
background: "#fff",
|
|
14
|
+
width: "85%",
|
|
15
|
+
height: "85%",
|
|
16
|
+
overflowY: "auto",
|
|
17
|
+
overflowX: "hidden",
|
|
18
|
+
padding: 16,
|
|
19
|
+
borderRadius: 6,
|
|
20
|
+
zIndex: 10001,
|
|
21
|
+
boxSizing: "border-box"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.defaultCitationPaneStyles = defaultCitationPaneStyles;
|
|
25
|
+
const defaultCitationContentCSS = controlId => `
|
|
26
|
+
#${controlId} .citation-content {
|
|
27
|
+
flex: 1;
|
|
28
|
+
min-height: 0; /* allow flex child to scroll */
|
|
29
|
+
overflow-y: auto;
|
|
30
|
+
overflow-x: auto;
|
|
31
|
+
margin-bottom: 12px;
|
|
32
|
+
white-space: normal; /* wrap normal text */
|
|
33
|
+
word-break: break-word;
|
|
34
|
+
-webkit-overflow-scrolling: touch;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#${controlId} .citation-content pre,
|
|
38
|
+
#${controlId} .citation-content code {
|
|
39
|
+
white-space: pre; /* preserve formatting */
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#${controlId} .citation-content table {
|
|
43
|
+
width: 100%;
|
|
44
|
+
border-collapse: collapse;
|
|
45
|
+
margin-bottom: 12px;
|
|
46
|
+
table-layout: auto;
|
|
47
|
+
overflow-x: auto;
|
|
48
|
+
display: block;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#${controlId} .citation-content table th,
|
|
52
|
+
#${controlId} .citation-content table td {
|
|
53
|
+
padding: 8px 12px;
|
|
54
|
+
border: 1px solid rgba(0,0,0,0.08);
|
|
55
|
+
text-align: left;
|
|
56
|
+
vertical-align: top;
|
|
57
|
+
word-break: break-word;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#${controlId} .citation-content img {
|
|
61
|
+
max-width: 100%;
|
|
62
|
+
height: auto;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
exports.defaultCitationContentCSS = defaultCitationContentCSS;
|
|
66
|
+
var _default = {
|
|
67
|
+
defaultCitationPaneStyles,
|
|
68
|
+
defaultCitationContentCSS
|
|
69
|
+
};
|
|
70
|
+
exports.default = _default;
|
package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -22,13 +22,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
22
22
|
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); }
|
|
23
23
|
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; }
|
|
24
24
|
const LiveChatWidget = props => {
|
|
25
|
-
var _props$
|
|
25
|
+
var _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
|
|
26
26
|
const reducer = (0, _createReducer.createReducer)();
|
|
27
27
|
const [state, dispatch] = (0, _react.useReducer)(reducer, (0, _LiveChatWidgetContextInitialState.getLiveChatWidgetContextInitialState)(props));
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
29
|
const [adapter, setAdapter] = (0, _react.useState)(undefined);
|
|
30
30
|
const [facadeChatSDK, setFacadeChatSDK] = (0, _react.useState)(undefined);
|
|
31
|
-
const chatSDK = (0, _getMockChatSDKIfApplicable.getMockChatSDKIfApplicable)(props.chatSDK, props === null || props === void 0 ? void 0 :
|
|
31
|
+
const chatSDK = (0, _getMockChatSDKIfApplicable.getMockChatSDKIfApplicable)(props.chatSDK, props === null || props === void 0 ? void 0 : props.mock);
|
|
32
32
|
const disableReauthentication = ((_props$featureConfigP = props.featureConfigProps) === null || _props$featureConfigP === void 0 ? void 0 : _props$featureConfigP.disableReauthentication) === true;
|
|
33
33
|
(0, _overridePropsOnMockIfApplicable.default)(props);
|
|
34
34
|
if (!props.chatConfig) {
|
|
@@ -38,14 +38,14 @@ const LiveChatWidget = props => {
|
|
|
38
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
39
|
const isAuthenticatedChat = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction) || (0, _liveChatConfigUtils.isPersistentChatEnabled)((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_conversationmode);
|
|
40
40
|
if (!facadeChatSDK) {
|
|
41
|
-
var _props$
|
|
41
|
+
var _props$mock;
|
|
42
42
|
setFacadeChatSDK(new _FacadeChatSDK.FacadeChatSDK({
|
|
43
43
|
"chatSDK": chatSDK,
|
|
44
44
|
"chatConfig": props.chatConfig,
|
|
45
45
|
"isAuthenticated": isAuthenticatedChat,
|
|
46
46
|
"getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
|
|
47
47
|
//when type is not undefined, it means the SDK is mocked
|
|
48
|
-
"isSDKMocked": !(0, _utils.isNullOrUndefined)(props === null || props === void 0 ? void 0 : (_props$
|
|
48
|
+
"isSDKMocked": !(0, _utils.isNullOrUndefined)(props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type)
|
|
49
49
|
}, disableReauthentication));
|
|
50
50
|
}
|
|
51
51
|
(0, _react.useEffect)(() => {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AddActivitySubscriber = void 0;
|
|
7
|
+
var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstants");
|
|
8
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
var _ChatWidgetEvents = _interopRequireDefault(require("../ChatWidgetEvents"));
|
|
10
|
+
var _SecureEventBus = _interopRequireDefault(require("../../../../common/utils/SecureEventBus"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
|
+
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); }
|
|
18
|
+
/**
|
|
19
|
+
* The `AddActivitySubscriber` class is responsible for subscribing to the `ADD_ACTIVITY` event
|
|
20
|
+
* from the `ChatWidgetEvents` and notifying an observer when a new activity is added.
|
|
21
|
+
*
|
|
22
|
+
* This class implements the `IActivitySubscriber` interface and acts as a bridge between
|
|
23
|
+
* the event system and the observer pattern.
|
|
24
|
+
*/
|
|
25
|
+
let AddActivitySubscriber = /*#__PURE__*/function () {
|
|
26
|
+
/**
|
|
27
|
+
* The observer that will be notified when a new activity is added.
|
|
28
|
+
* This is expected to be an object with a `next` method, such as an RxJS `Observer`.
|
|
29
|
+
*/
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Set to track processed activity IDs to prevent duplicate processing.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Unsubscribe function for the secure event listener
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Subscription for PersistentConversationReset event
|
|
42
|
+
*/
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Constructor initializes the `AddActivitySubscriber` and sets up a secure event listener
|
|
47
|
+
* for the `ChatWidgetEvents.ADD_ACTIVITY` event. When the event is triggered, it checks
|
|
48
|
+
* if the event payload contains an `activity` and notifies the observer.
|
|
49
|
+
*/
|
|
50
|
+
function AddActivitySubscriber() {
|
|
51
|
+
_classCallCheck(this, AddActivitySubscriber);
|
|
52
|
+
_defineProperty(this, "observer", void 0);
|
|
53
|
+
_defineProperty(this, "processedActivityIds", new Set());
|
|
54
|
+
_defineProperty(this, "unsubscribeFromSecureEvent", null);
|
|
55
|
+
_defineProperty(this, "resetEventListener", void 0);
|
|
56
|
+
const eventBus = _SecureEventBus.default.getInstance();
|
|
57
|
+
|
|
58
|
+
// Subscribe to the secure event bus instead of global window events
|
|
59
|
+
this.unsubscribeFromSecureEvent = eventBus.subscribe(_ChatWidgetEvents.default.ADD_ACTIVITY, payload => {
|
|
60
|
+
if (payload !== null && payload !== void 0 && payload.activity) {
|
|
61
|
+
var _this$observer;
|
|
62
|
+
const activity = payload.activity;
|
|
63
|
+
const activityId = activity.id;
|
|
64
|
+
if (activity.identifier) {
|
|
65
|
+
if (this.processedActivityIds.has(activity === null || activity === void 0 ? void 0 : activity.identifier)) {
|
|
66
|
+
return; // Skip processing if already handled
|
|
67
|
+
}
|
|
68
|
+
// Add the activity ID to the processed set
|
|
69
|
+
this.processedActivityIds.add(activity === null || activity === void 0 ? void 0 : activity.identifier);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check if activity has an ID and if it has already been processed
|
|
73
|
+
if (activityId) {
|
|
74
|
+
if (this.processedActivityIds.has(activityId)) {
|
|
75
|
+
return; // Skip processing if already handled
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Add the activity ID to the processed set
|
|
79
|
+
this.processedActivityIds.add(activityId);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Notify the observer with the new activity
|
|
83
|
+
(_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.next(activity);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Subscribe to reset events for cleanup
|
|
88
|
+
this.resetEventListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(() => {
|
|
89
|
+
this.reset();
|
|
90
|
+
// Clean up the secure event listener when conversation resets
|
|
91
|
+
if (this.unsubscribeFromSecureEvent) {
|
|
92
|
+
this.unsubscribeFromSecureEvent();
|
|
93
|
+
this.unsubscribeFromSecureEvent = null;
|
|
94
|
+
}
|
|
95
|
+
// Unsubscribe from the reset event to prevent accumulation
|
|
96
|
+
if (this.resetEventListener) {
|
|
97
|
+
this.resetEventListener.unsubscribe();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The `next` method is a placeholder for processing the activity.
|
|
104
|
+
* This method can be overridden or extended as needed.
|
|
105
|
+
*
|
|
106
|
+
* @param activity - The activity object to process.
|
|
107
|
+
* @returns The activity object (asynchronously).
|
|
108
|
+
*/
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
+
_createClass(AddActivitySubscriber, [{
|
|
111
|
+
key: "next",
|
|
112
|
+
value: async function next(activity) {
|
|
113
|
+
return activity;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Reset the processed activity IDs when a conversation resets
|
|
118
|
+
*/
|
|
119
|
+
}, {
|
|
120
|
+
key: "reset",
|
|
121
|
+
value: function reset() {
|
|
122
|
+
this.processedActivityIds.clear();
|
|
123
|
+
}
|
|
124
|
+
}]);
|
|
125
|
+
return AddActivitySubscriber;
|
|
126
|
+
}();
|
|
127
|
+
exports.AddActivitySubscriber = AddActivitySubscriber;
|
package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -17,7 +17,6 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
17
17
|
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
18
18
|
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
19
19
|
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
20
|
-
let response;
|
|
21
20
|
const extractSignInId = signInUrl => {
|
|
22
21
|
const result = botOauthUrlRegex.exec(signInUrl);
|
|
23
22
|
if (result && result[1]) {
|
|
@@ -53,20 +52,20 @@ const fetchBotAuthConfig = async (retries, interval) => {
|
|
|
53
52
|
eventName: _TelemetryConstants.BroadcastEvent.BotAuthConfigRequest
|
|
54
53
|
};
|
|
55
54
|
_omnichannelChatComponents.BroadcastService.postMessage(botAuthConfigRequestEvent);
|
|
55
|
+
let response;
|
|
56
56
|
const listener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.BotAuthConfigResponse).subscribe(data => {
|
|
57
57
|
var _data$payload, _data$payload2;
|
|
58
58
|
response = ((_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.response) !== undefined ? (_data$payload2 = data.payload) === null || _data$payload2 === void 0 ? void 0 : _data$payload2.response : response;
|
|
59
59
|
listener.unsubscribe();
|
|
60
60
|
});
|
|
61
|
-
if (response !== undefined) {
|
|
62
|
-
//return response;
|
|
63
|
-
return response;
|
|
64
|
-
}
|
|
65
61
|
if (retries === 1) {
|
|
66
62
|
// Base Case
|
|
67
63
|
throw new Error();
|
|
68
64
|
}
|
|
69
65
|
await delay(interval);
|
|
66
|
+
if (response !== undefined) {
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
70
69
|
return await fetchBotAuthConfig(--retries, interval);
|
|
71
70
|
};
|
|
72
71
|
let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var ChatWidgetEvents;
|
|
8
|
+
(function (ChatWidgetEvents) {
|
|
9
|
+
ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
|
|
10
|
+
ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
|
|
11
|
+
ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
|
|
12
|
+
ChatWidgetEvents["HIDE_LOADING_BANNER"] = "CHAT_WIDGET/HIDE_LOADING_BANNER";
|
|
13
|
+
})(ChatWidgetEvents || (ChatWidgetEvents = {}));
|
|
14
|
+
var _default = ChatWidgetEvents;
|
|
15
|
+
exports.default = _default;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
var _ChatWidgetEvents = _interopRequireDefault(require("./ChatWidgetEvents"));
|
|
10
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
|
+
var _conversationDividerActivity = _interopRequireDefault(require("../../webchatcontainerstateful/common/activities/conversationDividerActivity"));
|
|
12
|
+
var _convertPersistentChatHistoryMessageToActivity = _interopRequireDefault(require("../../webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity"));
|
|
13
|
+
var _utils = require("../../../common/utils");
|
|
14
|
+
var _defaultPersistentChatHistoryProps = require("./defaultProps/defaultPersistentChatHistoryProps");
|
|
15
|
+
var _dispatchCustomEvent = _interopRequireDefault(require("../../../common/utils/dispatchCustomEvent"));
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
19
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
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; }
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
22
|
+
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); }
|
|
23
|
+
/**
|
|
24
|
+
* Class responsible for handling persistent conversation history
|
|
25
|
+
*/
|
|
26
|
+
let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
|
|
29
|
+
function PersistentConversationHandler(facadeChatSDK, props) {
|
|
30
|
+
_classCallCheck(this, PersistentConversationHandler);
|
|
31
|
+
_defineProperty(this, "appliedProps", {
|
|
32
|
+
..._defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps
|
|
33
|
+
});
|
|
34
|
+
_defineProperty(this, "isLastPull", false);
|
|
35
|
+
_defineProperty(this, "pageToken", null);
|
|
36
|
+
_defineProperty(this, "facadeChatSDK", void 0);
|
|
37
|
+
_defineProperty(this, "lastMessage", null);
|
|
38
|
+
_defineProperty(this, "count", 0);
|
|
39
|
+
_defineProperty(this, "pageSize", 4);
|
|
40
|
+
_defineProperty(this, "isCurrentlyPulling", false);
|
|
41
|
+
_defineProperty(this, "pageTokenInTransitSet", new Set());
|
|
42
|
+
_defineProperty(this, "resetEventListener", _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(() => {
|
|
43
|
+
this.reset();
|
|
44
|
+
}));
|
|
45
|
+
this.facadeChatSDK = facadeChatSDK;
|
|
46
|
+
this.appliedPropsHandler(props);
|
|
47
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
48
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWPersistentConversationHandlerInitialized,
|
|
49
|
+
Description: "PersistentConversationHandler initialized",
|
|
50
|
+
CustomProperties: {
|
|
51
|
+
pageSize: this.pageSize
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
_createClass(PersistentConversationHandler, [{
|
|
56
|
+
key: "appliedPropsHandler",
|
|
57
|
+
value: function appliedPropsHandler(props) {
|
|
58
|
+
this.appliedProps = {
|
|
59
|
+
..._defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps,
|
|
60
|
+
...props
|
|
61
|
+
};
|
|
62
|
+
this.pageSize = this.appliedProps.pageSize || 4;
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "reset",
|
|
66
|
+
value: function reset() {
|
|
67
|
+
this.isLastPull = false;
|
|
68
|
+
this.pageToken = null;
|
|
69
|
+
this.lastMessage = null;
|
|
70
|
+
this.count = 0;
|
|
71
|
+
this.isCurrentlyPulling = false;
|
|
72
|
+
this.pageTokenInTransitSet.clear();
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "destroy",
|
|
76
|
+
value: function destroy() {
|
|
77
|
+
// Only unsubscribe when the handler is being destroyed completely
|
|
78
|
+
this.resetEventListener.unsubscribe();
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "pullHistory",
|
|
82
|
+
value: async function pullHistory() {
|
|
83
|
+
const pullTimer = (0, _utils.createTimer)();
|
|
84
|
+
|
|
85
|
+
// Prevent concurrent pulls regardless of pageToken
|
|
86
|
+
if (this.isCurrentlyPulling) {
|
|
87
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
88
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullBlocked,
|
|
89
|
+
Description: "History pull blocked - already in progress"
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Additional check for specific pageToken duplicates
|
|
95
|
+
if (this.pageToken && this.pageTokenInTransitSet.has(this.pageToken)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Mark as currently pulling
|
|
100
|
+
this.isCurrentlyPulling = true;
|
|
101
|
+
if (this.pageToken) {
|
|
102
|
+
this.pageTokenInTransitSet.add(this.pageToken);
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
var _ref;
|
|
106
|
+
const messages = await this.fetchHistoryMessages();
|
|
107
|
+
if (messages === null || (messages === null || messages === void 0 ? void 0 : messages.length) === 0) {
|
|
108
|
+
this.isLastPull = true;
|
|
109
|
+
// Dispatch event to notify UI that no more history is available
|
|
110
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
|
|
111
|
+
// Also hide the loading banner
|
|
112
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
|
|
113
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
114
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
115
|
+
Description: "History pull completed - no more messages",
|
|
116
|
+
ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
|
|
121
|
+
this.processHistoryMessages(messagesDescOrder);
|
|
122
|
+
|
|
123
|
+
// Dispatch event to hide the loading banner after messages are processed
|
|
124
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
|
|
125
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
126
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
127
|
+
Description: "History pull completed successfully",
|
|
128
|
+
ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed,
|
|
129
|
+
CustomProperties: {
|
|
130
|
+
messageCount: messages.length,
|
|
131
|
+
totalProcessed: this.count
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
} finally {
|
|
135
|
+
// Always clear the pulling flag when done
|
|
136
|
+
this.isCurrentlyPulling = false;
|
|
137
|
+
|
|
138
|
+
// Remove pageToken from transit set if it was added
|
|
139
|
+
if (this.pageToken) {
|
|
140
|
+
this.pageTokenInTransitSet.delete(this.pageToken);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
+
}, {
|
|
147
|
+
key: "processHistoryMessages",
|
|
148
|
+
value: function processHistoryMessages(messagesDescOrder) {
|
|
149
|
+
for (const message of messagesDescOrder) {
|
|
150
|
+
try {
|
|
151
|
+
const activity = this.processMessageToActivity(message);
|
|
152
|
+
if (activity) {
|
|
153
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.ADD_ACTIVITY, {
|
|
154
|
+
activity
|
|
155
|
+
});
|
|
156
|
+
const dividerActivity = this.createDividerActivity(activity);
|
|
157
|
+
if (dividerActivity) {
|
|
158
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.ADD_ACTIVITY, {
|
|
159
|
+
activity: dividerActivity
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
this.lastMessage = activity;
|
|
163
|
+
}
|
|
164
|
+
} catch (error) {
|
|
165
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
166
|
+
Event: _TelemetryConstants.TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
|
|
167
|
+
ExceptionDetails: error
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
|
+
}, {
|
|
175
|
+
key: "fetchHistoryMessages",
|
|
176
|
+
value: async function fetchHistoryMessages() {
|
|
177
|
+
if (!this.shouldPull()) {
|
|
178
|
+
// Dispatch event to ensure banner is hidden when no more pulls are needed
|
|
179
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
|
|
180
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
const options = {
|
|
184
|
+
pageSize: this.pageSize,
|
|
185
|
+
pageToken: this.pageToken || undefined
|
|
186
|
+
};
|
|
187
|
+
try {
|
|
188
|
+
var _this$facadeChatSDK;
|
|
189
|
+
const response = await ((_this$facadeChatSDK = this.facadeChatSDK) === null || _this$facadeChatSDK === void 0 ? void 0 : _this$facadeChatSDK.fetchPersistentConversationHistory(options));
|
|
190
|
+
const {
|
|
191
|
+
chatMessages: messages,
|
|
192
|
+
nextPageToken: pageToken
|
|
193
|
+
} = response;
|
|
194
|
+
this.pageToken = pageToken || null;
|
|
195
|
+
if (pageToken === null) {
|
|
196
|
+
this.isLastPull = true;
|
|
197
|
+
// Dispatch event when we reach the end of available history
|
|
198
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// if chatMessages is null, return empty array
|
|
202
|
+
if (!messages) {
|
|
203
|
+
this.isLastPull = true;
|
|
204
|
+
// Dispatch event when we reach the end of available history
|
|
205
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
|
|
206
|
+
// Also hide the loading banner
|
|
207
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
|
|
211
|
+
return messages;
|
|
212
|
+
} catch (error) {
|
|
213
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
214
|
+
Event: _TelemetryConstants.TelemetryEvent.FetchPersistentChatHistoryFailed,
|
|
215
|
+
ExceptionDetails: error
|
|
216
|
+
});
|
|
217
|
+
this.isLastPull = true;
|
|
218
|
+
this.pageToken = null;
|
|
219
|
+
// Dispatch event when there's an error to stop loading banner
|
|
220
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
|
|
221
|
+
// Also hide the loading banner
|
|
222
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
|
|
223
|
+
return [];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
key: "shouldPull",
|
|
228
|
+
value: function shouldPull() {
|
|
229
|
+
return !this.isLastPull;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
233
|
+
}, {
|
|
234
|
+
key: "processMessageToActivity",
|
|
235
|
+
value: function processMessageToActivity(message) {
|
|
236
|
+
try {
|
|
237
|
+
const activity = (0, _convertPersistentChatHistoryMessageToActivity.default)(message);
|
|
238
|
+
activity.id = activity.id || `activity-${this.count}`;
|
|
239
|
+
activity.channelData = {
|
|
240
|
+
...activity.channelData,
|
|
241
|
+
metadata: {
|
|
242
|
+
count: this.count
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Increment the count after assigning it to the activity
|
|
247
|
+
this.count += 1;
|
|
248
|
+
return activity;
|
|
249
|
+
} catch (error) {
|
|
250
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
251
|
+
Event: _TelemetryConstants.TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
|
|
252
|
+
ExceptionDetails: error
|
|
253
|
+
});
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
259
|
+
}, {
|
|
260
|
+
key: "createDividerActivity",
|
|
261
|
+
value: function createDividerActivity(activity) {
|
|
262
|
+
var _this$lastMessage, _this$lastMessage$cha;
|
|
263
|
+
if (((_this$lastMessage = this.lastMessage) === null || _this$lastMessage === void 0 ? void 0 : (_this$lastMessage$cha = _this$lastMessage.channelData) === null || _this$lastMessage$cha === void 0 ? void 0 : _this$lastMessage$cha.conversationId) !== activity.channelData.conversationId) {
|
|
264
|
+
const rawSequenceId = activity.channelData["webchat:sequence-id"];
|
|
265
|
+
const sequenceId = typeof rawSequenceId === "number" && !isNaN(rawSequenceId) ? rawSequenceId + 1 : 1;
|
|
266
|
+
const timestamp = new Date(activity.timestamp).getTime() + 1;
|
|
267
|
+
return {
|
|
268
|
+
..._conversationDividerActivity.default,
|
|
269
|
+
channelData: {
|
|
270
|
+
..._conversationDividerActivity.default.channelData,
|
|
271
|
+
conversationId: activity.channelData.conversationId,
|
|
272
|
+
"webchat:sequence-id": sequenceId
|
|
273
|
+
},
|
|
274
|
+
timestamp: new Date(timestamp).toISOString(),
|
|
275
|
+
identifier: `divider-${activity.channelData.conversationId}`
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
}]);
|
|
281
|
+
return PersistentConversationHandler;
|
|
282
|
+
}();
|
|
283
|
+
var _default = PersistentConversationHandler;
|
|
284
|
+
exports.default = _default;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createAdapter = void 0;
|
|
7
|
+
var _AddActivitySubscriber = require("./ActivitySubscriber/AddActivitySubscriber");
|
|
7
8
|
var _BotAuthActivitySubscriber = require("./ActivitySubscriber/BotAuthActivitySubscriber");
|
|
8
9
|
var _ChatAdapterShim = require("./ChatAdapterShim");
|
|
9
10
|
var _HiddenAdaptiveCardActivitySubscriber = require("./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber");
|
|
@@ -50,6 +51,7 @@ const createAdapter = async (facadeChatSDK, props) => {
|
|
|
50
51
|
fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
|
|
51
52
|
};
|
|
52
53
|
adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
|
|
54
|
+
adapter.addSubscriber(new _AddActivitySubscriber.AddActivitySubscriber());
|
|
53
55
|
adapter.addSubscriber(new _PauseActivitySubscriber.PauseActivitySubscriber());
|
|
54
56
|
adapter.addSubscriber(new _BotAuthActivitySubscriber.BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
|
|
55
57
|
// Remove this code after ICM ID:544623085 is fixed
|
package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultPersistentChatHistoryProps = void 0;
|
|
7
|
+
const defaultPersistentChatHistoryProps = {
|
|
8
|
+
persistentChatHistoryEnabled: true,
|
|
9
|
+
pageSize: 4,
|
|
10
|
+
dividerActivityStyle: {
|
|
11
|
+
border: "1px solid rgb(96, 94, 92, 0.5)",
|
|
12
|
+
margin: "10px 20%"
|
|
13
|
+
},
|
|
14
|
+
bannerStyle: {
|
|
15
|
+
margin: "10px auto"
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.defaultPersistentChatHistoryProps = defaultPersistentChatHistoryProps;
|