@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.1bfa518
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/README.md +27 -0
- package/lib/cjs/common/Constants.js +9 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +49 -2
- package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +29 -13
- package/lib/cjs/common/utils/SecureEventBus.js +307 -0
- package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
- package/lib/cjs/common/utils.js +14 -1
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +218 -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/headerstateful/HeaderStateful.js +8 -2
- 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 +290 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +17 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +54 -12
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +10 -5
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -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 +152 -33
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +135 -26
- 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 +103 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -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 +57 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +121 -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 +47 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1058 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +50 -1
- 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 +5 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +102 -30
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +47 -45
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +9 -1
- package/lib/cjs/contexts/createReducer.js +30 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/cjs/index.js +9 -1
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
- package/lib/esm/common/Constants.js +9 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/esm/common/telemetry/TelemetryConstants.js +47 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
- package/lib/esm/common/utils/SecureEventBus.js +328 -0
- package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
- package/lib/esm/common/utils.js +11 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
- package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +207 -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/headerstateful/HeaderStateful.js +9 -3
- 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 +283 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +10 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +55 -13
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +12 -7
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -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 +153 -34
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +135 -27
- 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 +96 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -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 +49 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +114 -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 +39 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1080 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +48 -1
- 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 +3 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +103 -30
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +47 -45
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +9 -1
- package/lib/esm/contexts/createReducer.js +30 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/esm/index.js +1 -0
- package/lib/esm/plugins/newMessageEventHandler.js +4 -1
- package/lib/types/common/Constants.d.ts +8 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +44 -2
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
- package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
- package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
- package/lib/types/common/utils.d.ts +9 -1
- 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/common/liveChatConfigUtils.d.ts +11 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- 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 +11 -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/interfaces/IExtendedChatConffig.d.ts +15 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +6 -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/activityMiddleware.d.ts +2 -1
- 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/localizedStringsBotInitialsMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +6 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +47 -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/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const defaultCitationPaneStyles = {
|
|
2
|
+
pane: {
|
|
3
|
+
position: "fixed",
|
|
4
|
+
left: "50%",
|
|
5
|
+
top: "18%",
|
|
6
|
+
transform: "translateX(-50%)",
|
|
7
|
+
background: "#fff",
|
|
8
|
+
width: "85%",
|
|
9
|
+
height: "85%",
|
|
10
|
+
overflowY: "auto",
|
|
11
|
+
overflowX: "hidden",
|
|
12
|
+
padding: 16,
|
|
13
|
+
borderRadius: 6,
|
|
14
|
+
zIndex: 10001,
|
|
15
|
+
boxSizing: "border-box"
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const defaultCitationContentCSS = controlId => `
|
|
19
|
+
#${controlId} .citation-content {
|
|
20
|
+
flex: 1;
|
|
21
|
+
min-height: 0; /* allow flex child to scroll */
|
|
22
|
+
overflow-y: auto;
|
|
23
|
+
overflow-x: auto;
|
|
24
|
+
margin-bottom: 12px;
|
|
25
|
+
white-space: normal; /* wrap normal text */
|
|
26
|
+
word-break: break-word;
|
|
27
|
+
-webkit-overflow-scrolling: touch;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#${controlId} .citation-content pre,
|
|
31
|
+
#${controlId} .citation-content code {
|
|
32
|
+
white-space: pre; /* preserve formatting */
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#${controlId} .citation-content table {
|
|
36
|
+
width: 100%;
|
|
37
|
+
border-collapse: collapse;
|
|
38
|
+
margin-bottom: 12px;
|
|
39
|
+
table-layout: auto;
|
|
40
|
+
overflow-x: auto;
|
|
41
|
+
display: block;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#${controlId} .citation-content table th,
|
|
45
|
+
#${controlId} .citation-content table td {
|
|
46
|
+
padding: 8px 12px;
|
|
47
|
+
border: 1px solid rgba(0,0,0,0.08);
|
|
48
|
+
text-align: left;
|
|
49
|
+
vertical-align: top;
|
|
50
|
+
word-break: break-word;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#${controlId} .citation-content img {
|
|
54
|
+
max-width: 100%;
|
|
55
|
+
height: auto;
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
export default {
|
|
59
|
+
defaultCitationPaneStyles,
|
|
60
|
+
defaultCitationContentCSS
|
|
61
|
+
};
|
package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
1
|
+
import { ConversationStage, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { ConfirmationState } from "../../common/Constants";
|
|
4
4
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
@@ -61,7 +61,10 @@ export const HeaderStateful = props => {
|
|
|
61
61
|
var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
|
|
62
62
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
63
63
|
Event: TelemetryEvent.HeaderCloseButtonClicked,
|
|
64
|
-
Description: "Header Close action started."
|
|
64
|
+
Description: "Header Close action started.",
|
|
65
|
+
CustomProperties: {
|
|
66
|
+
ConversationStage: ConversationStage.ConversationEnd
|
|
67
|
+
}
|
|
65
68
|
});
|
|
66
69
|
if (localConfirmationPaneState.current !== ConfirmationState.Ok) {
|
|
67
70
|
dispatch({
|
|
@@ -76,7 +79,10 @@ export const HeaderStateful = props => {
|
|
|
76
79
|
}
|
|
77
80
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
78
81
|
Event: TelemetryEvent.CloseChatActionCompleted,
|
|
79
|
-
Description: "Header Close action completed."
|
|
82
|
+
Description: "Header Close action completed.",
|
|
83
|
+
CustomProperties: {
|
|
84
|
+
ConversationStage: ConversationStage.ConversationEnd
|
|
85
|
+
}
|
|
80
86
|
});
|
|
81
87
|
const closeButtonId = ((_props$headerProps = props.headerProps) === null || _props$headerProps === void 0 ? void 0 : (_props$headerProps$co = _props$headerProps.controlProps) === null || _props$headerProps$co === void 0 ? void 0 : (_props$headerProps$co2 = _props$headerProps$co.closeButtonProps) === null || _props$headerProps$co2 === void 0 ? void 0 : _props$headerProps$co2.id) ?? `${controlProps.id}-close-button`;
|
|
82
88
|
if (closeButtonId) {
|
|
@@ -13,13 +13,13 @@ import { isPersistentChatEnabled } from "./common/liveChatConfigUtils";
|
|
|
13
13
|
import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
|
|
14
14
|
import { registerTelemetryLoggers } from "./common/registerTelemetryLoggers";
|
|
15
15
|
export const LiveChatWidget = props => {
|
|
16
|
-
var _props$
|
|
16
|
+
var _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
|
|
17
17
|
const reducer = createReducer();
|
|
18
18
|
const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
const [adapter, setAdapter] = useState(undefined);
|
|
21
21
|
const [facadeChatSDK, setFacadeChatSDK] = useState(undefined);
|
|
22
|
-
const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 :
|
|
22
|
+
const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : props.mock);
|
|
23
23
|
const disableReauthentication = ((_props$featureConfigP = props.featureConfigProps) === null || _props$featureConfigP === void 0 ? void 0 : _props$featureConfigP.disableReauthentication) === true;
|
|
24
24
|
overridePropsOnMockIfApplicable(props);
|
|
25
25
|
if (!props.chatConfig) {
|
|
@@ -29,14 +29,14 @@ export const LiveChatWidget = props => {
|
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
30
|
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) || 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);
|
|
31
31
|
if (!facadeChatSDK) {
|
|
32
|
-
var _props$
|
|
32
|
+
var _props$mock;
|
|
33
33
|
setFacadeChatSDK(new FacadeChatSDK({
|
|
34
34
|
"chatSDK": chatSDK,
|
|
35
35
|
"chatConfig": props.chatConfig,
|
|
36
36
|
"isAuthenticated": isAuthenticatedChat,
|
|
37
37
|
"getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
|
|
38
38
|
//when type is not undefined, it means the SDK is mocked
|
|
39
|
-
"isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$
|
|
39
|
+
"isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type)
|
|
40
40
|
}, disableReauthentication));
|
|
41
41
|
}
|
|
42
42
|
useEffect(() => {
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
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); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
|
+
import { BroadcastEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
8
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
9
|
+
import ChatWidgetEvents from "../ChatWidgetEvents";
|
|
10
|
+
import SecureEventBus from "../../../../common/utils/SecureEventBus";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `AddActivitySubscriber` class is responsible for subscribing to the `ADD_ACTIVITY` event
|
|
14
|
+
* from the `ChatWidgetEvents` and notifying an observer when a new activity is added.
|
|
15
|
+
*
|
|
16
|
+
* This class implements the `IActivitySubscriber` interface and acts as a bridge between
|
|
17
|
+
* the event system and the observer pattern.
|
|
18
|
+
*/
|
|
19
|
+
export let AddActivitySubscriber = /*#__PURE__*/function () {
|
|
20
|
+
/**
|
|
21
|
+
* The observer that will be notified when a new activity is added.
|
|
22
|
+
* This is expected to be an object with a `next` method, such as an RxJS `Observer`.
|
|
23
|
+
*/
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Set to track processed activity IDs to prevent duplicate processing.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Unsubscribe function for the secure event listener
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Subscription for PersistentConversationReset event
|
|
36
|
+
*/
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Constructor initializes the `AddActivitySubscriber` and sets up a secure event listener
|
|
41
|
+
* for the `ChatWidgetEvents.ADD_ACTIVITY` event. When the event is triggered, it checks
|
|
42
|
+
* if the event payload contains an `activity` and notifies the observer.
|
|
43
|
+
*/
|
|
44
|
+
function AddActivitySubscriber() {
|
|
45
|
+
_classCallCheck(this, AddActivitySubscriber);
|
|
46
|
+
_defineProperty(this, "observer", void 0);
|
|
47
|
+
_defineProperty(this, "processedActivityIds", new Set());
|
|
48
|
+
_defineProperty(this, "unsubscribeFromSecureEvent", null);
|
|
49
|
+
_defineProperty(this, "resetEventListener", void 0);
|
|
50
|
+
const eventBus = SecureEventBus.getInstance();
|
|
51
|
+
|
|
52
|
+
// Subscribe to the secure event bus instead of global window events
|
|
53
|
+
this.unsubscribeFromSecureEvent = eventBus.subscribe(ChatWidgetEvents.ADD_ACTIVITY, payload => {
|
|
54
|
+
if (payload !== null && payload !== void 0 && payload.activity) {
|
|
55
|
+
var _this$observer;
|
|
56
|
+
const activity = payload.activity;
|
|
57
|
+
const activityId = activity.id;
|
|
58
|
+
if (activity.identifier) {
|
|
59
|
+
if (this.processedActivityIds.has(activity === null || activity === void 0 ? void 0 : activity.identifier)) {
|
|
60
|
+
return; // Skip processing if already handled
|
|
61
|
+
}
|
|
62
|
+
// Add the activity ID to the processed set
|
|
63
|
+
this.processedActivityIds.add(activity === null || activity === void 0 ? void 0 : activity.identifier);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Check if activity has an ID and if it has already been processed
|
|
67
|
+
if (activityId) {
|
|
68
|
+
if (this.processedActivityIds.has(activityId)) {
|
|
69
|
+
return; // Skip processing if already handled
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Add the activity ID to the processed set
|
|
73
|
+
this.processedActivityIds.add(activityId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Notify the observer with the new activity
|
|
77
|
+
(_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.next(activity);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Subscribe to reset events for cleanup
|
|
82
|
+
this.resetEventListener = BroadcastService.getMessageByEventName(BroadcastEvent.PersistentConversationReset).subscribe(() => {
|
|
83
|
+
this.reset();
|
|
84
|
+
// Clean up the secure event listener when conversation resets
|
|
85
|
+
if (this.unsubscribeFromSecureEvent) {
|
|
86
|
+
this.unsubscribeFromSecureEvent();
|
|
87
|
+
this.unsubscribeFromSecureEvent = null;
|
|
88
|
+
}
|
|
89
|
+
// Unsubscribe from the reset event to prevent accumulation
|
|
90
|
+
if (this.resetEventListener) {
|
|
91
|
+
this.resetEventListener.unsubscribe();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The `next` method is a placeholder for processing the activity.
|
|
98
|
+
* This method can be overridden or extended as needed.
|
|
99
|
+
*
|
|
100
|
+
* @param activity - The activity object to process.
|
|
101
|
+
* @returns The activity object (asynchronously).
|
|
102
|
+
*/
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
_createClass(AddActivitySubscriber, [{
|
|
105
|
+
key: "next",
|
|
106
|
+
value: async function next(activity) {
|
|
107
|
+
return activity;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Reset the processed activity IDs when a conversation resets
|
|
112
|
+
*/
|
|
113
|
+
}, {
|
|
114
|
+
key: "reset",
|
|
115
|
+
value: function reset() {
|
|
116
|
+
this.processedActivityIds.clear();
|
|
117
|
+
}
|
|
118
|
+
}]);
|
|
119
|
+
return AddActivitySubscriber;
|
|
120
|
+
}();
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -13,7 +13,6 @@ import { TelemetryManager } from "../../../../common/telemetry/TelemetryManager"
|
|
|
13
13
|
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
14
14
|
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
15
15
|
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
16
|
-
let response;
|
|
17
16
|
const extractSignInId = signInUrl => {
|
|
18
17
|
const result = botOauthUrlRegex.exec(signInUrl);
|
|
19
18
|
if (result && result[1]) {
|
|
@@ -49,20 +48,20 @@ const fetchBotAuthConfig = async (retries, interval) => {
|
|
|
49
48
|
eventName: BroadcastEvent.BotAuthConfigRequest
|
|
50
49
|
};
|
|
51
50
|
BroadcastService.postMessage(botAuthConfigRequestEvent);
|
|
51
|
+
let response;
|
|
52
52
|
const listener = BroadcastService.getMessageByEventName(BroadcastEvent.BotAuthConfigResponse).subscribe(data => {
|
|
53
53
|
var _data$payload, _data$payload2;
|
|
54
54
|
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;
|
|
55
55
|
listener.unsubscribe();
|
|
56
56
|
});
|
|
57
|
-
if (response !== undefined) {
|
|
58
|
-
//return response;
|
|
59
|
-
return response;
|
|
60
|
-
}
|
|
61
57
|
if (retries === 1) {
|
|
62
58
|
// Base Case
|
|
63
59
|
throw new Error();
|
|
64
60
|
}
|
|
65
61
|
await delay(interval);
|
|
62
|
+
if (response !== undefined) {
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
66
65
|
return await fetchBotAuthConfig(--retries, interval);
|
|
67
66
|
};
|
|
68
67
|
export let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var ChatWidgetEvents;
|
|
2
|
+
(function (ChatWidgetEvents) {
|
|
3
|
+
ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
|
|
4
|
+
ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
|
|
5
|
+
ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
|
|
6
|
+
ChatWidgetEvents["HISTORY_LOAD_ERROR"] = "CHAT_WIDGET/HISTORY_LOAD_ERROR";
|
|
7
|
+
})(ChatWidgetEvents || (ChatWidgetEvents = {}));
|
|
8
|
+
export default ChatWidgetEvents;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
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); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
8
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
9
|
+
import ChatWidgetEvents from "./ChatWidgetEvents";
|
|
10
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
11
|
+
import conversationDividerActivity from "../../webchatcontainerstateful/common/activities/conversationDividerActivity";
|
|
12
|
+
import convertPersistentChatHistoryMessageToActivity from "../../webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity";
|
|
13
|
+
import { createTimer } from "../../../common/utils";
|
|
14
|
+
import { defaultPersistentChatHistoryProps } from "./defaultProps/defaultPersistentChatHistoryProps";
|
|
15
|
+
import dispatchCustomEvent from "../../../common/utils/dispatchCustomEvent";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Class responsible for handling persistent conversation history
|
|
19
|
+
*/
|
|
20
|
+
let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
|
|
23
|
+
function PersistentConversationHandler(facadeChatSDK, props) {
|
|
24
|
+
_classCallCheck(this, PersistentConversationHandler);
|
|
25
|
+
_defineProperty(this, "appliedProps", {
|
|
26
|
+
...defaultPersistentChatHistoryProps
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(this, "isLastPull", false);
|
|
29
|
+
_defineProperty(this, "pageToken", null);
|
|
30
|
+
_defineProperty(this, "facadeChatSDK", void 0);
|
|
31
|
+
_defineProperty(this, "lastMessage", null);
|
|
32
|
+
_defineProperty(this, "count", 0);
|
|
33
|
+
_defineProperty(this, "pageSize", defaultPersistentChatHistoryProps.pageSize);
|
|
34
|
+
_defineProperty(this, "isCurrentlyPulling", false);
|
|
35
|
+
_defineProperty(this, "pageTokenInTransitSet", new Set());
|
|
36
|
+
_defineProperty(this, "resetEventListener", BroadcastService.getMessageByEventName(BroadcastEvent.PersistentConversationReset).subscribe(() => {
|
|
37
|
+
this.reset();
|
|
38
|
+
}));
|
|
39
|
+
this.facadeChatSDK = facadeChatSDK;
|
|
40
|
+
this.appliedPropsHandler(props);
|
|
41
|
+
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
42
|
+
Event: TelemetryEvent.LCWPersistentConversationHandlerInitialized,
|
|
43
|
+
Description: "PersistentConversationHandler initialized",
|
|
44
|
+
CustomProperties: {
|
|
45
|
+
pageSize: defaultPersistentChatHistoryProps.pageSize
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
_createClass(PersistentConversationHandler, [{
|
|
50
|
+
key: "appliedPropsHandler",
|
|
51
|
+
value: function appliedPropsHandler(props) {
|
|
52
|
+
var _this$appliedProps;
|
|
53
|
+
this.appliedProps = {
|
|
54
|
+
...defaultPersistentChatHistoryProps,
|
|
55
|
+
...props
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// if the props is not existent or is not a number then default to defaultPersistentChatHistoryProps.pageSize
|
|
59
|
+
this.pageSize = ((_this$appliedProps = this.appliedProps) === null || _this$appliedProps === void 0 ? void 0 : _this$appliedProps.pageSize) !== undefined && !isNaN(this.appliedProps.pageSize) ? this.appliedProps.pageSize : defaultPersistentChatHistoryProps.pageSize;
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "reset",
|
|
63
|
+
value: function reset() {
|
|
64
|
+
this.isLastPull = false;
|
|
65
|
+
this.pageToken = null;
|
|
66
|
+
this.lastMessage = null;
|
|
67
|
+
this.count = 0;
|
|
68
|
+
this.isCurrentlyPulling = false;
|
|
69
|
+
this.pageTokenInTransitSet.clear();
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "destroy",
|
|
73
|
+
value: function destroy() {
|
|
74
|
+
// Only unsubscribe when the handler is being destroyed completely
|
|
75
|
+
this.resetEventListener.unsubscribe();
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "pullHistory",
|
|
79
|
+
value: async function pullHistory() {
|
|
80
|
+
const pullTimer = createTimer();
|
|
81
|
+
|
|
82
|
+
// Prevent concurrent pulls regardless of pageToken
|
|
83
|
+
if (this.isCurrentlyPulling) {
|
|
84
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
85
|
+
Event: TelemetryEvent.LCWPersistentHistoryPullBlocked,
|
|
86
|
+
Description: "History pull blocked - already in progress"
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Additional check for specific pageToken duplicates
|
|
92
|
+
if (this.pageToken && this.pageTokenInTransitSet.has(this.pageToken)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Mark as currently pulling
|
|
97
|
+
this.isCurrentlyPulling = true;
|
|
98
|
+
if (this.pageToken) {
|
|
99
|
+
this.pageTokenInTransitSet.add(this.pageToken);
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
var _ref;
|
|
103
|
+
const messages = await this.fetchHistoryMessages();
|
|
104
|
+
|
|
105
|
+
// Handle error case - null indicates an error occurred
|
|
106
|
+
// Don't mark as last pull to allow retry on next attempt
|
|
107
|
+
if (messages == null) {
|
|
108
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
109
|
+
Event: TelemetryEvent.LCWPersistentHistoryReturnedNull,
|
|
110
|
+
Description: "History pull returned null - Possible error occurred, will retry on next scroll",
|
|
111
|
+
ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Handle legitimate end of history - empty array
|
|
117
|
+
if (messages.length === 0) {
|
|
118
|
+
this.isLastPull = true;
|
|
119
|
+
// Dispatch event to notify UI that no more history is available
|
|
120
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
121
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
122
|
+
Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
123
|
+
Description: "History pull completed - no more messages",
|
|
124
|
+
ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
|
|
129
|
+
this.processHistoryMessages(messagesDescOrder);
|
|
130
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
131
|
+
Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
132
|
+
Description: "History pull completed successfully",
|
|
133
|
+
ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed,
|
|
134
|
+
CustomProperties: {
|
|
135
|
+
messageCount: messages.length,
|
|
136
|
+
totalProcessed: this.count
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
} finally {
|
|
140
|
+
// Always clear the pulling flag when done
|
|
141
|
+
this.isCurrentlyPulling = false;
|
|
142
|
+
|
|
143
|
+
// Remove pageToken from transit set if it was added
|
|
144
|
+
if (this.pageToken) {
|
|
145
|
+
this.pageTokenInTransitSet.delete(this.pageToken);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
151
|
+
}, {
|
|
152
|
+
key: "processHistoryMessages",
|
|
153
|
+
value: function processHistoryMessages(messagesDescOrder) {
|
|
154
|
+
for (const message of messagesDescOrder) {
|
|
155
|
+
try {
|
|
156
|
+
const activity = this.processMessageToActivity(message);
|
|
157
|
+
if (activity) {
|
|
158
|
+
dispatchCustomEvent(ChatWidgetEvents.ADD_ACTIVITY, {
|
|
159
|
+
activity
|
|
160
|
+
});
|
|
161
|
+
const dividerActivity = this.createDividerActivity(activity);
|
|
162
|
+
if (dividerActivity) {
|
|
163
|
+
dispatchCustomEvent(ChatWidgetEvents.ADD_ACTIVITY, {
|
|
164
|
+
activity: dividerActivity
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
this.lastMessage = activity;
|
|
168
|
+
}
|
|
169
|
+
} catch (error) {
|
|
170
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
171
|
+
Event: TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
|
|
172
|
+
ExceptionDetails: error
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
|
+
}, {
|
|
180
|
+
key: "fetchHistoryMessages",
|
|
181
|
+
value: async function fetchHistoryMessages() {
|
|
182
|
+
if (!this.shouldPull()) {
|
|
183
|
+
// Dispatch event to ensure banner is hidden when no more pulls are needed
|
|
184
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
const options = {
|
|
188
|
+
pageSize: this.pageSize,
|
|
189
|
+
pageToken: this.pageToken || undefined
|
|
190
|
+
};
|
|
191
|
+
try {
|
|
192
|
+
var _this$facadeChatSDK;
|
|
193
|
+
const response = await ((_this$facadeChatSDK = this.facadeChatSDK) === null || _this$facadeChatSDK === void 0 ? void 0 : _this$facadeChatSDK.fetchPersistentConversationHistory(options));
|
|
194
|
+
const {
|
|
195
|
+
chatMessages: messages,
|
|
196
|
+
nextPageToken: pageToken
|
|
197
|
+
} = response;
|
|
198
|
+
this.pageToken = pageToken || null;
|
|
199
|
+
if (pageToken === null) {
|
|
200
|
+
this.isLastPull = true;
|
|
201
|
+
// Dispatch event when we reach the end of available history
|
|
202
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// if chatMessages is null, return empty array
|
|
206
|
+
if (!messages) {
|
|
207
|
+
this.isLastPull = true;
|
|
208
|
+
// Dispatch event when we reach the end of available history
|
|
209
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
return messages;
|
|
213
|
+
} catch (error) {
|
|
214
|
+
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
215
|
+
Event: TelemetryEvent.FetchPersistentChatHistoryFailed,
|
|
216
|
+
ExceptionDetails: error
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// On error, dispatch HISTORY_LOAD_ERROR to hide loading banner without marking conversation as ended
|
|
220
|
+
// This allows recovery on the next attempt (e.g., transient network errors)
|
|
221
|
+
// Return null to distinguish error from legitimate empty history
|
|
222
|
+
dispatchCustomEvent(ChatWidgetEvents.HISTORY_LOAD_ERROR);
|
|
223
|
+
return null;
|
|
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 = convertPersistentChatHistoryMessageToActivity(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.logActionEvent(LogLevel.ERROR, {
|
|
251
|
+
Event: 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,
|
|
269
|
+
channelData: {
|
|
270
|
+
...conversationDividerActivity.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
|
+
export default PersistentConversationHandler;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AddActivitySubscriber } from "./ActivitySubscriber/AddActivitySubscriber";
|
|
1
2
|
import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
|
|
2
3
|
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
3
4
|
import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
|
|
@@ -44,6 +45,7 @@ export const createAdapter = async (facadeChatSDK, props) => {
|
|
|
44
45
|
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
|
|
45
46
|
};
|
|
46
47
|
adapter = new ChatAdapterShim(adapter);
|
|
48
|
+
adapter.addSubscriber(new AddActivitySubscriber());
|
|
47
49
|
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
48
50
|
adapter.addSubscriber(new BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
|
|
49
51
|
// Remove this code after ICM ID:544623085 is fixed
|