@microsoft/omnichannel-chat-widget 1.8.7 → 2.0.0-main.5ebd4eb

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.
Files changed (251) hide show
  1. package/README.md +52 -5
  2. package/lib/cjs/common/Constants.js +5 -0
  3. package/lib/cjs/common/facades/FacadeChatSDK.js +234 -9
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +19 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +2 -3
  7. package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +91 -0
  8. package/lib/cjs/common/utils.js +93 -17
  9. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +16 -6
  10. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -10
  11. package/lib/cjs/components/citationpanestateful/CitationDim.js +2 -3
  12. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +27 -5
  13. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +23 -3
  14. package/lib/cjs/components/dimlayer/DimLayer.js +1 -3
  15. package/lib/cjs/components/draggable/DraggableChatWidget.js +35 -15
  16. package/lib/cjs/components/draggable/DraggableEventEmitter.js +10 -1
  17. package/lib/cjs/components/draggable/DraggableEventReceiver.js +1 -3
  18. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +54 -17
  19. package/lib/cjs/components/errorboundary/ErrorBoundary.js +4 -12
  20. package/lib/cjs/components/footerstateful/FooterStateful.js +18 -9
  21. package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +2 -4
  22. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -6
  23. package/lib/cjs/components/headerstateful/HeaderStateful.js +24 -12
  24. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +27 -4
  25. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +5 -11
  26. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  27. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +11 -4
  28. package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
  29. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
  30. package/lib/cjs/components/livechatwidget/common/endChat.js +12 -9
  31. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +182 -1
  32. package/lib/cjs/components/livechatwidget/common/recoveryEligibilityTelemetry.js +60 -0
  33. package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
  34. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +160 -21
  35. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +16 -11
  36. package/lib/cjs/components/notificationpanestateful/NotificationPaneStateful.js +19 -12
  37. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +13 -6
  38. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +28 -5
  39. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +12 -5
  40. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +105 -11
  41. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +12 -1
  42. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -7
  43. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +16 -7
  44. package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +10 -2
  45. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +154 -29
  46. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  47. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +115 -10
  48. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  49. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  50. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
  51. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  52. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  53. package/lib/cjs/components/webchatcontainerstateful/common/utils/citationA11y.js +195 -0
  54. package/lib/cjs/components/webchatcontainerstateful/interfaces/IWebChatAction.js +17 -1
  55. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +27 -4
  56. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +1 -3
  57. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +1 -3
  58. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +180 -190
  59. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +3 -5
  60. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +22 -6
  61. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -23
  62. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -35
  63. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +199 -0
  64. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +29 -15
  65. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +5 -12
  66. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +1 -1
  67. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  68. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  69. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  70. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +5 -8
  71. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +6 -4
  72. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +6 -4
  73. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +14 -12
  74. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +16 -14
  75. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +18 -30
  76. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +10 -2
  77. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +1 -3
  78. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +16 -12
  79. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +6 -6
  80. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +83 -0
  81. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +36 -8
  82. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +5 -1
  83. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +10 -7
  84. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +4 -0
  85. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -4
  86. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +5 -1
  87. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +7 -7
  88. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +10 -14
  89. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +6 -4
  90. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -10
  91. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +57 -11
  92. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +6 -4
  93. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +25 -30
  94. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +10 -7
  95. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +6 -4
  96. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  97. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +2 -4
  98. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +5 -0
  99. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  100. package/lib/cjs/contexts/createReducer.js +15 -0
  101. package/lib/cjs/controller/componentController.js +13 -1
  102. package/lib/cjs/hooks/useWindowDimensions.js +13 -5
  103. package/lib/cjs/package.json +1 -0
  104. package/lib/cjs/plugins/createChatTranscript.js +3 -4
  105. package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
  106. package/lib/esm/common/Constants.js +5 -0
  107. package/lib/esm/common/facades/FacadeChatSDK.js +235 -10
  108. package/lib/esm/common/telemetry/TelemetryConstants.js +19 -0
  109. package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
  110. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +2 -3
  111. package/lib/esm/common/telemetry/sanitizeSasInPayload.js +84 -0
  112. package/lib/esm/common/utils.js +88 -14
  113. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +15 -5
  114. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +19 -9
  115. package/lib/esm/components/citationpanestateful/CitationDim.js +2 -3
  116. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +26 -4
  117. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +22 -2
  118. package/lib/esm/components/dimlayer/DimLayer.js +1 -3
  119. package/lib/esm/components/draggable/DraggableChatWidget.js +34 -14
  120. package/lib/esm/components/draggable/DraggableEventEmitter.js +10 -1
  121. package/lib/esm/components/draggable/DraggableEventReceiver.js +1 -3
  122. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +54 -17
  123. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -12
  124. package/lib/esm/components/footerstateful/FooterStateful.js +17 -8
  125. package/lib/esm/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +2 -4
  126. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -6
  127. package/lib/esm/components/headerstateful/HeaderStateful.js +22 -10
  128. package/lib/esm/components/livechatwidget/LiveChatWidget.js +27 -4
  129. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +5 -11
  130. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  131. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +11 -4
  132. package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
  133. package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
  134. package/lib/esm/components/livechatwidget/common/endChat.js +12 -9
  135. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +182 -1
  136. package/lib/esm/components/livechatwidget/common/recoveryEligibilityTelemetry.js +52 -0
  137. package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
  138. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +159 -20
  139. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +14 -9
  140. package/lib/esm/components/notificationpanestateful/NotificationPaneStateful.js +17 -10
  141. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +12 -5
  142. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +28 -5
  143. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +11 -4
  144. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +105 -11
  145. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +12 -1
  146. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -6
  147. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +15 -6
  148. package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +9 -1
  149. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +154 -29
  150. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  151. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +115 -10
  152. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  153. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  154. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
  155. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  156. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  157. package/lib/esm/components/webchatcontainerstateful/common/utils/citationA11y.js +188 -0
  158. package/lib/esm/components/webchatcontainerstateful/interfaces/IWebChatAction.js +10 -1
  159. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +27 -4
  160. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +1 -3
  161. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +1 -3
  162. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +180 -190
  163. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +3 -5
  164. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +19 -4
  165. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -23
  166. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -32
  167. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +193 -0
  168. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +28 -14
  169. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +5 -12
  170. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +1 -1
  171. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  172. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  173. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  174. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +5 -8
  175. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +6 -4
  176. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +6 -4
  177. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +13 -11
  178. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +15 -13
  179. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +17 -27
  180. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +9 -1
  181. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +1 -3
  182. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +16 -10
  183. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +6 -6
  184. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +77 -0
  185. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +36 -8
  186. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +5 -2
  187. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +10 -7
  188. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +4 -0
  189. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -4
  190. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +5 -1
  191. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +7 -7
  192. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +10 -14
  193. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +6 -4
  194. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -10
  195. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +57 -11
  196. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +6 -4
  197. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +25 -31
  198. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +10 -7
  199. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +6 -4
  200. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  201. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +2 -4
  202. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +5 -0
  203. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  204. package/lib/esm/contexts/createReducer.js +15 -0
  205. package/lib/esm/controller/componentController.js +13 -1
  206. package/lib/esm/hooks/useWindowDimensions.js +13 -5
  207. package/lib/esm/plugins/createChatTranscript.js +3 -4
  208. package/lib/esm/plugins/newMessageEventHandler.js +20 -3
  209. package/lib/types/common/Constants.d.ts +4 -0
  210. package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
  211. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
  212. package/lib/types/common/telemetry/TelemetryConstants.d.ts +15 -2
  213. package/lib/types/common/telemetry/sanitizeSasInPayload.d.ts +24 -0
  214. package/lib/types/common/utils.d.ts +3 -1
  215. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
  216. package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
  217. package/lib/types/components/livechatwidget/common/recoveryEligibilityTelemetry.d.ts +17 -0
  218. package/lib/types/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.d.ts +6 -0
  219. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +1 -1
  220. package/lib/types/components/webchatcontainerstateful/common/utils/citationA11y.d.ts +1 -0
  221. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
  222. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatAction.d.ts +16 -1
  223. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +7 -0
  224. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
  225. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
  226. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.d.ts +18 -0
  227. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
  228. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.d.ts +2 -4
  229. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +2 -4
  230. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.d.ts +2 -4
  231. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +10 -0
  232. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +2 -4
  233. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.d.ts +2 -2
  234. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +2 -4
  235. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +2 -2
  236. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +2 -4
  237. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +2 -2
  238. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.d.ts +2 -4
  239. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.d.ts +2 -4
  240. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.d.ts +2 -4
  241. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.d.ts +2 -4
  242. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +2 -4
  243. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.d.ts +2 -4
  244. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.d.ts +2 -4
  245. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  246. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.d.ts +2 -4
  247. package/lib/types/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.d.ts +7 -0
  248. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  249. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +17 -0
  250. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  251. package/package.json +71 -57
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _Constants = require("../../../../../common/Constants");
8
+ var _IWebChatAction = require("../../../interfaces/IWebChatAction");
8
9
  var _WebChatActionType = require("../../enums/WebChatActionType");
9
10
  /******
10
11
  * GIFUploadMiddleware
@@ -12,28 +13,23 @@ var _WebChatActionType = require("../../enums/WebChatActionType");
12
13
  * Ensures that GIF are properly uploaded.
13
14
  ******/
14
15
 
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
16
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
17
  const gifUploadMiddleware = _ref => {
17
- let {
18
- dispatch
19
- } = _ref;
18
+ let dispatch = _ref.dispatch;
20
19
  return next => action => {
20
+ if (!(0, _IWebChatAction.isWebChatAction)(action)) {
21
+ return next(action);
22
+ }
21
23
  if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
22
24
  var _activity$attachments, _activity$channelData;
23
- const {
24
- payload: {
25
- activity
26
- }
27
- } = action;
25
+ const activity = action.payload.activity;
28
26
  if ((activity === null || activity === void 0 || (_activity$attachments = activity.attachments) === null || _activity$attachments === void 0 ? void 0 : _activity$attachments.length) === (activity === null || activity === void 0 || (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 || (_activity$channelData = _activity$channelData.attachmentSizes) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.length)) {
29
27
  var _activity$attachments2;
30
28
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
29
  activity === null || activity === void 0 || (_activity$attachments2 = activity.attachments) === null || _activity$attachments2 === void 0 || _activity$attachments2.forEach(attachment => {
32
- const {
33
- thumbnailUrl,
34
- contentUrl,
35
- contentType
36
- } = attachment;
30
+ const thumbnailUrl = attachment.thumbnailUrl,
31
+ contentUrl = attachment.contentUrl,
32
+ contentType = attachment.contentType;
37
33
  if (contentType === _Constants.Constants.GifContentType && thumbnailUrl !== contentUrl) {
38
34
  attachment.thumbnailUrl = contentUrl;
39
35
  }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _Constants = require("../../../../../common/Constants");
8
+ var _IWebChatAction = require("../../../interfaces/IWebChatAction");
8
9
  var _WebChatActionType = require("../../enums/WebChatActionType");
9
10
  /******
10
11
  * HTMLPlayerMiddleware
@@ -29,13 +30,14 @@ const disableHTMLPlayerDownloadButton = htmlTag => {
29
30
  }, 500);
30
31
  };
31
32
 
32
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
33
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
34
  const htmlPlayerMiddleware = _ref => {
34
- let {
35
- dispatch
36
- } = _ref;
35
+ let dispatch = _ref.dispatch;
37
36
  return next => action => {
38
37
  var _action$payload;
38
+ if (!(0, _IWebChatAction.isWebChatAction)(action)) {
39
+ return next(action);
40
+ }
39
41
  if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && ((_action$payload = action.payload) === null || _action$payload === void 0 || (_action$payload = _action$payload.activity) === null || _action$payload === void 0 || (_action$payload = _action$payload.attachments) === null || _action$payload === void 0 ? void 0 : _action$payload.length) > 0) {
40
42
  disableHTMLPlayerDownloadButton(_Constants.Constants.video);
41
43
  disableHTMLPlayerDownloadButton(_Constants.Constants.audio);
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _Constants = require("../../../../../common/Constants");
8
8
  var _dompurify = _interopRequireDefault(require("dompurify"));
9
+ var _IWebChatAction = require("../../../interfaces/IWebChatAction");
9
10
  var _WebChatActionType = require("../../enums/WebChatActionType");
10
11
  var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
11
12
  var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
@@ -96,23 +97,25 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
96
97
  return action;
97
98
  };
98
99
 
99
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
100
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
100
101
  const htmlTextMiddleware = honorsTargetInHTMLLinks => _ref => {
101
- let {
102
- dispatch
103
- } = _ref;
102
+ let dispatch = _ref.dispatch;
104
103
  return next => action => {
105
- if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
104
+ if (!(0, _IWebChatAction.isWebChatAction)(action)) {
105
+ return next(action);
106
+ }
107
+ let currentAction = action;
108
+ if (currentAction.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
106
109
  try {
107
- var _action$payload;
108
- const text = (_action$payload = action.payload) === null || _action$payload === void 0 || (_action$payload = _action$payload.activity) === null || _action$payload === void 0 ? void 0 : _action$payload.text;
110
+ var _currentAction$payloa;
111
+ const text = (_currentAction$payloa = currentAction.payload) === null || _currentAction$payloa === void 0 || (_currentAction$payloa = _currentAction$payloa.activity) === null || _currentAction$payloa === void 0 ? void 0 : _currentAction$payloa.text;
109
112
  if (text) {
110
- action = processHTMLText(action, text, honorsTargetInHTMLLinks ?? false);
113
+ currentAction = processHTMLText(currentAction, text, honorsTargetInHTMLLinks ?? false);
111
114
  }
112
115
  } catch (e) {
113
116
  let errorMessage = "Failed to validate action.";
114
117
  try {
115
- errorMessage += JSON.stringify(action);
118
+ errorMessage += JSON.stringify(currentAction);
116
119
  } catch (e) {
117
120
  errorMessage += " (unable to stringify action)";
118
121
  }
@@ -125,7 +128,7 @@ const htmlTextMiddleware = honorsTargetInHTMLLinks => _ref => {
125
128
  });
126
129
  }
127
130
  }
128
- return next(action);
131
+ return next(currentAction);
129
132
  };
130
133
  };
131
134
  var _default = exports.default = htmlTextMiddleware;
@@ -6,20 +6,49 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.localizedStringsBotInitialsMiddleware = exports.getOverriddenLocalizedStrings = void 0;
7
7
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
8
8
  var _Constants = require("../../../../../common/Constants");
9
+ var _IWebChatAction = require("../../../interfaces/IWebChatAction");
9
10
  var _WebChatActionType = require("../../enums/WebChatActionType");
10
11
  var _defaultWebChatStyles = require("../../../common/defaultStyles/defaultWebChatStyles");
11
12
  var _utils = require("../../../../../common/utils");
12
13
  /* eslint-disable @typescript-eslint/no-explicit-any */
13
14
 
14
15
  let currentAgentInitials = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
16
+ let currentAgentName = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
15
17
 
16
18
  // Optional external updater (React context dispatch wrapper) set at runtime
17
19
  let externalInitialsUpdater;
20
+ const hasTransferTag = activity => {
21
+ var _activity$channelData;
22
+ const tags = [...(Array.isArray(activity === null || activity === void 0 || (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) ? activity.channelData.tags : []), ...(Array.isArray(activity === null || activity === void 0 ? void 0 : activity.tags) ? activity.tags : [])];
23
+ return tags.some(tag => typeof tag === "string" && tag.toLowerCase().includes("transfer"));
24
+ };
25
+ const isTransferSystemMessage = activity => {
26
+ const text = ((activity === null || activity === void 0 ? void 0 : activity.text) || "").toString();
27
+ return hasTransferTag(activity) || /\btransfer(?:red|ring)?\b/i.test(text);
28
+ };
29
+ const resetCachedAgentName = dispatch => {
30
+ if (currentAgentName !== _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials || currentAgentInitials !== _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials) {
31
+ var _externalInitialsUpda;
32
+ currentAgentName = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
33
+ currentAgentInitials = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
34
+ (_externalInitialsUpda = externalInitialsUpdater) === null || _externalInitialsUpda === void 0 || _externalInitialsUpda(currentAgentInitials || "");
35
+ _omnichannelChatComponents.BroadcastService.postMessage({
36
+ eventName: "BotAvatarInitialsUpdated",
37
+ payload: {
38
+ initials: currentAgentInitials
39
+ }
40
+ });
41
+ dispatch({
42
+ type: "__BOT_INITIALS_UPDATED__"
43
+ });
44
+ }
45
+ };
18
46
  const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref => {
19
- let {
20
- dispatch
21
- } = _ref;
47
+ let dispatch = _ref.dispatch;
22
48
  return next => action => {
49
+ if (!(0, _IWebChatAction.isWebChatAction)(action)) {
50
+ return next(action);
51
+ }
23
52
  if (onInitialsChange && !externalInitialsUpdater) {
24
53
  externalInitialsUpdater = onInitialsChange; // capture once
25
54
  }
@@ -27,16 +56,31 @@ const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref => {
27
56
  var _action$payload, _activity$from;
28
57
  const activity = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
29
58
  if (activity !== null && activity !== void 0 && (_activity$from = activity.from) !== null && _activity$from !== void 0 && _activity$from.name && activity.from.role !== _Constants.Constants.userMessageTag && activity.from.name !== _Constants.Constants.userMessageTag) {
30
- var _activity$channelData, _activity$tags;
59
+ var _activity$channelData2, _activity$tags;
31
60
  const agentName = activity.from.name.trim();
32
- const isSystemMessage = agentName === "__agent__" || agentName.startsWith("__") || ((_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 || (_activity$channelData = _activity$channelData.tags) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.includes(_Constants.Constants.systemMessageTag)) || ((_activity$tags = activity.tags) === null || _activity$tags === void 0 ? void 0 : _activity$tags.includes(_Constants.Constants.systemMessageTag));
33
- if (!isSystemMessage && agentName) {
61
+ const isSystemMessage = agentName === "__agent__" || agentName.startsWith("__") || ((_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 || (_activity$channelData2 = _activity$channelData2.tags) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.includes(_Constants.Constants.systemMessageTag)) || ((_activity$tags = activity.tags) === null || _activity$tags === void 0 ? void 0 : _activity$tags.includes(_Constants.Constants.systemMessageTag));
62
+ if (isSystemMessage) {
63
+ // transfer-stale-bot-name: when a transfer system message indicates the
64
+ // conversation has been routed to a different agent, the
65
+ // previously-cached agent name must NOT linger. Otherwise the
66
+ // next non-system activity (e.g. typing indicator, welcome
67
+ // message, or the new agent's first turn before their name
68
+ // is observed) is announced to screen readers as the OLD
69
+ // agent. Reset to defaults so the next observed name takes
70
+ // effect cleanly.
71
+ if (isTransferSystemMessage(activity)) {
72
+ resetCachedAgentName(dispatch);
73
+ }
74
+ } else if (agentName) {
34
75
  const newInitials = (0, _utils.getIconText)(agentName) || currentAgentInitials;
35
- if (newInitials !== currentAgentInitials) {
36
- var _externalInitialsUpda;
76
+ const hasInitialsChanged = newInitials !== currentAgentInitials;
77
+ const hasNameChanged = agentName !== currentAgentName;
78
+ currentAgentName = agentName;
79
+ if (hasInitialsChanged) {
80
+ var _externalInitialsUpda2;
37
81
  currentAgentInitials = newInitials;
38
82
  // Notify external React context if provided
39
- (_externalInitialsUpda = externalInitialsUpdater) === null || _externalInitialsUpda === void 0 || _externalInitialsUpda(currentAgentInitials || "");
83
+ (_externalInitialsUpda2 = externalInitialsUpdater) === null || _externalInitialsUpda2 === void 0 || _externalInitialsUpda2(currentAgentInitials || "");
40
84
  // Broadcast (optional) for multi-tab sync without forcing consumers
41
85
  _omnichannelChatComponents.BroadcastService.postMessage({
42
86
  eventName: "BotAvatarInitialsUpdated",
@@ -44,6 +88,8 @@ const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref => {
44
88
  initials: currentAgentInitials
45
89
  }
46
90
  });
91
+ }
92
+ if (hasInitialsChanged || hasNameChanged) {
47
93
  // Also dispatch a no-op action into WebChat store to encourage re-render (cheap)
48
94
  dispatch({
49
95
  type: "__BOT_INITIALS_UPDATED__"
@@ -64,10 +110,10 @@ const getOverriddenLocalizedStrings = existingOverrides => {
64
110
  };
65
111
  // Apply dynamic bot initials to alt text if not already overridden through props
66
112
  if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_SAID_ALT)) {
67
- result.ACTIVITY_BOT_SAID_ALT = `${currentAgentInitials} said:`;
113
+ result.ACTIVITY_BOT_SAID_ALT = `${currentAgentName} said:`;
68
114
  }
69
115
  if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_ATTACHED_ALT)) {
70
- result.ACTIVITY_BOT_ATTACHED_ALT = `${currentAgentInitials} attached:`;
116
+ result.ACTIVITY_BOT_ATTACHED_ALT = `${currentAgentName} attached:`;
71
117
  }
72
118
  return result;
73
119
  };
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _IWebChatAction = require("../../../interfaces/IWebChatAction");
7
8
  var _NotificationHandler = require("../../notification/NotificationHandler");
8
9
  var _NotificationScenarios = require("../../enums/NotificationScenarios");
9
10
  var _WebChatActionType = require("../../enums/WebChatActionType");
@@ -14,12 +15,13 @@ var _Constants = require("../../../../../common/Constants");
14
15
  * Enforces a max character limit that the sender can send to comply to Omnichannel chat services' limitation.
15
16
  ******/
16
17
 
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
18
19
  const createMaxMessageSizeValidator = localizedTexts => _ref => {
19
- let {
20
- dispatch
21
- } = _ref;
20
+ let dispatch = _ref.dispatch;
22
21
  return next => action => {
22
+ if (!(0, _IWebChatAction.isWebChatAction)(action)) {
23
+ return next(action);
24
+ }
23
25
  if (action.type === _WebChatActionType.WebChatActionType.WEB_CHAT_SET_SEND_BOX) {
24
26
  var _action$payload;
25
27
  const textLength = ((_action$payload = action.payload) === null || _action$payload === void 0 || (_action$payload = _action$payload.text) === null || _action$payload === void 0 ? void 0 : _action$payload.length) || 0;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _IWebChatAction = require("../../../interfaces/IWebChatAction");
7
8
  var _Constants = require("../../../../../common/Constants");
8
9
  var _WebChatActionType = require("../../enums/WebChatActionType");
9
10
  /******
@@ -12,38 +13,32 @@ var _WebChatActionType = require("../../enums/WebChatActionType");
12
13
  * Adds necessary fields for the activity for the other middlewares to function as expected.
13
14
  ******/
14
15
 
15
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
16
- const preProcessingMiddleware = _ref => {
17
- let {
18
- dispatch
19
- } = _ref;
20
- return next => async action => {
21
- if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
22
- const {
23
- activity
24
- } = action.payload;
25
- if (!activity.from || activity.from.role === _Constants.Constants.userMessageTag) {
26
- action = {
27
- ...action,
28
- payload: {
29
- ...action.payload,
30
- activity: {
31
- ...action.payload.activity,
32
- textFormat: _Constants.Constants.markdown
33
- }
16
+ const preProcessingMiddleware = () => next => async action => {
17
+ if (!(0, _IWebChatAction.isWebChatAction)(action)) {
18
+ return next(action);
19
+ }
20
+ let currentAction = action;
21
+ if (currentAction.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
22
+ const activity = currentAction.payload.activity;
23
+ if (!activity.from || activity.from.role === _Constants.Constants.userMessageTag) {
24
+ currentAction = {
25
+ ...currentAction,
26
+ payload: {
27
+ ...currentAction.payload,
28
+ activity: {
29
+ ...currentAction.payload.activity,
30
+ textFormat: _Constants.Constants.markdown
34
31
  }
35
- };
36
- }
32
+ }
33
+ };
37
34
  }
38
- if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
39
- const {
40
- activity
41
- } = action.payload;
42
- if (activity) {
43
- action.payload.activity[_Constants.Constants.actionType] = _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY;
44
- }
35
+ }
36
+ if (currentAction.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
37
+ const activity = currentAction.payload.activity;
38
+ if (activity) {
39
+ currentAction.payload.activity[_Constants.Constants.actionType] = _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY;
45
40
  }
46
- return next(action);
47
- };
41
+ }
42
+ return next(currentAction);
48
43
  };
49
44
  var _default = exports.default = preProcessingMiddleware;
@@ -5,18 +5,18 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createQueueOverflowMiddleware = void 0;
7
7
  var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
8
+ var _IWebChatAction = require("../../../interfaces/IWebChatAction");
8
9
  var _LiveChatWidgetActionType = require("../../../../../contexts/common/LiveChatWidgetActionType");
9
10
  var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
10
11
  var _WebChatActionType = require("../../enums/WebChatActionType");
11
12
  var _createReducer = require("../../../../../contexts/createReducer");
12
13
  var _utils = require("../../../../../common/utils");
13
14
  const queueOverflowHandlingHelper = async (state, dispatch) => {
14
- const {
15
- appStates
16
- } = (0, _createReducer.executeReducer)(state, {
17
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
18
- payload: undefined
19
- });
15
+ const _executeReducer = (0, _createReducer.executeReducer)(state, {
16
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
17
+ payload: undefined
18
+ }),
19
+ appStates = _executeReducer.appStates;
20
20
  if (!appStates.chatDisconnectEventReceived) {
21
21
  dispatch({
22
22
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
@@ -30,7 +30,10 @@ const queueOverflowHandlingHelper = async (state, dispatch) => {
30
30
  };
31
31
  const createQueueOverflowMiddleware = (state, dispatch) => () => next => action => {
32
32
  var _action$payload;
33
- if ((action === null || action === void 0 ? void 0 : action.type) == _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
33
+ if (!(0, _IWebChatAction.isWebChatAction)(action)) {
34
+ return next(action);
35
+ }
36
+ if (action.type == _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
34
37
  const activity = action.payload.activity;
35
38
  if ((0, _utils.isEndConversationDueToOverflowActivity)(activity)) {
36
39
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  var _dompurify = _interopRequireDefault(require("dompurify"));
8
8
  var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
9
9
  var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
10
+ var _IWebChatAction = require("../../../interfaces/IWebChatAction");
10
11
  var _WebChatActionType = require("../../enums/WebChatActionType");
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
13
  /******
@@ -15,12 +16,13 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
15
16
  * Sanitizes the text.
16
17
  ******/
17
18
 
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
20
  const sanitizationMiddleware = _ref => {
20
- let {
21
- dispatch
22
- } = _ref;
21
+ let dispatch = _ref.dispatch;
23
22
  return next => action => {
23
+ if (!(0, _IWebChatAction.isWebChatAction)(action)) {
24
+ return next(action);
25
+ }
24
26
  if (action.type === _WebChatActionType.WebChatActionType.WEB_CHAT_SEND_MESSAGE) {
25
27
  try {
26
28
  var _action$payload;
@@ -14,8 +14,11 @@ var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstan
14
14
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
15
15
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
16
16
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
17
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
18
19
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ const LIVE_REGION_ID = "oc-lcw-notification-live-region";
21
+ const LIVE_REGION_CLEAR_DELAY_MS = 1000;
19
22
  let NotificationHandler = exports.NotificationHandler = /*#__PURE__*/function () {
20
23
  function NotificationHandler() {
21
24
  _classCallCheck(this, NotificationHandler);
@@ -32,9 +35,59 @@ let NotificationHandler = exports.NotificationHandler = /*#__PURE__*/function ()
32
35
  message
33
36
  }
34
37
  });
38
+ NotificationHandler.announceToScreenReader(message);
35
39
  NotificationHandler.setFocusOnNotificationCloseButton();
36
40
  }
37
41
  }
42
+
43
+ /**
44
+ * Announces a message immediately to screen readers via an aria-live="assertive" region.
45
+ * This ensures notifications interrupt the current screen reader output
46
+ * instead of waiting for it to finish reading other content.
47
+ */
48
+ }, {
49
+ key: "announceToScreenReader",
50
+ value: function announceToScreenReader(message) {
51
+ let liveRegion = document.getElementById(LIVE_REGION_ID);
52
+ if (!liveRegion) {
53
+ liveRegion = document.createElement("div");
54
+ liveRegion.id = LIVE_REGION_ID;
55
+ liveRegion.setAttribute("aria-live", "assertive");
56
+ liveRegion.setAttribute("role", "alert");
57
+ liveRegion.setAttribute("aria-atomic", "true");
58
+ // Visually hidden but accessible to screen readers
59
+ liveRegion.style.position = "absolute";
60
+ liveRegion.style.width = "1px";
61
+ liveRegion.style.height = "1px";
62
+ liveRegion.style.overflow = "hidden";
63
+ liveRegion.style.clip = "rect(0 0 0 0)";
64
+ liveRegion.style.clipPath = "inset(50%)";
65
+ liveRegion.style.whiteSpace = "nowrap";
66
+ const widgetContainer = document.getElementById(_Constants.HtmlIdNames.MSLiveChatWidget);
67
+ (widgetContainer || document.body).appendChild(liveRegion);
68
+ }
69
+
70
+ // Clear first, then set after a microtask so the browser detects the change
71
+ // even when the same message is announced consecutively.
72
+ liveRegion.textContent = "";
73
+ requestAnimationFrame(() => {
74
+ if (liveRegion) {
75
+ liveRegion.textContent = message;
76
+ }
77
+ });
78
+
79
+ // Cancel any previous clear timer to avoid prematurely clearing a newer message
80
+ if (NotificationHandler.clearTimeoutId) {
81
+ clearTimeout(NotificationHandler.clearTimeoutId);
82
+ }
83
+
84
+ // Clear the live region after a delay so repeated identical messages still trigger
85
+ NotificationHandler.clearTimeoutId = setTimeout(() => {
86
+ if (liveRegion) {
87
+ liveRegion.textContent = "";
88
+ }
89
+ }, LIVE_REGION_CLEAR_DELAY_MS);
90
+ }
38
91
  }, {
39
92
  key: "dismissNotification",
40
93
  value: function dismissNotification(id) {
@@ -107,4 +160,5 @@ let NotificationHandler = exports.NotificationHandler = /*#__PURE__*/function ()
107
160
  };
108
161
  }
109
162
  }]);
110
- }();
163
+ }();
164
+ _defineProperty(NotificationHandler, "clearTimeoutId", void 0);
@@ -10,10 +10,8 @@ function createWebChatTelemetry() {
10
10
  let isInitEventLogged = false;
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  const handleTelemetry = event => {
13
- const {
14
- level,
15
- name
16
- } = event;
13
+ const level = event.level,
14
+ name = event.name;
17
15
  const loglevel = level ? level.toUpperCase() : "";
18
16
  if ((name === null || name === void 0 ? void 0 : name.toLowerCase()) === "init" && isInitEventLogged) return;
19
17
  switch (loglevel) {
@@ -263,5 +263,10 @@ let LiveChatWidgetActionType = exports.LiveChatWidgetActionType = /*#__PURE__*/f
263
263
  string: Sets/updates current bot avatar initials (used for dynamic refresh of persistent messages)
264
264
  */
265
265
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_AVATAR_INITIALS"] = 49] = "SET_BOT_AVATAR_INITIALS";
266
+ /*
267
+ Parameters:
268
+ true/false: Tracks if user has authenticated (pre-auth or mid-conversation) for reconnect support
269
+ */
270
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_USER_AUTHENTICATED"] = 50] = "SET_USER_AUTHENTICATED";
266
271
  return LiveChatWidgetActionType;
267
272
  }({});
@@ -44,6 +44,21 @@ const getLiveChatWidgetContextInitialState = props => {
44
44
  if (!initialStateFromCache.domainStates.botAvatarInitials) {
45
45
  initialStateFromCache.domainStates.botAvatarInitials = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
46
46
  }
47
+ // Default isUserAuthenticated to false if not present in cache
48
+ if (initialStateFromCache.appStates.isUserAuthenticated === undefined) {
49
+ initialStateFromCache.appStates.isUserAuthenticated = false;
50
+ }
51
+ // internal tracking: transient modal pane visibility must NOT survive a page
52
+ // reload. If `showConfirmationPane` / `showEmailTranscriptPane` are
53
+ // restored as `true`, the corresponding pane re-mounts and installs
54
+ // its focus trap (and sets sibling tabindex=-1). The user has no
55
+ // context for why the modal appeared and Tab from the host page can
56
+ // no longer traverse out of the widget. Always start cold for these
57
+ // ephemeral UI flags.
58
+ if (initialStateFromCache.uiStates) {
59
+ initialStateFromCache.uiStates.showConfirmationPane = false;
60
+ initialStateFromCache.uiStates.showEmailTranscriptPane = false;
61
+ }
47
62
  return initialStateFromCache;
48
63
  }
49
64
  const LiveChatWidgetContextInitialState = {
@@ -93,7 +108,8 @@ const getLiveChatWidgetContextInitialState = props => {
93
108
  selectedSurveyMode: null,
94
109
  postChatParticipantType: undefined,
95
110
  isConversationalSurvey: false,
96
- isConversationalSurveyEnabled: false
111
+ isConversationalSurveyEnabled: false,
112
+ isUserAuthenticated: false
97
113
  },
98
114
  uiStates: {
99
115
  showConfirmationPane: false,
@@ -716,6 +716,21 @@ const reducer = (state, action) => {
716
716
  isConversationalSurvey: action.payload
717
717
  }
718
718
  };
719
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_USER_AUTHENTICATED:
720
+ inMemory = {
721
+ ...inMemory,
722
+ appStates: {
723
+ ...inMemory.appStates,
724
+ isUserAuthenticated: action.payload
725
+ }
726
+ };
727
+ return {
728
+ ...state,
729
+ appStates: {
730
+ ...state.appStates,
731
+ isUserAuthenticated: action.payload
732
+ }
733
+ };
719
734
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE:
720
735
  return inMemory;
721
736
  default:
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.shouldShowWebChatContainer = exports.shouldShowStartChatErrorPane = exports.shouldShowReconnectChatPane = exports.shouldShowProactiveChatPane = exports.shouldShowPreChatSurveyPane = exports.shouldShowPostChatSurveyPane = exports.shouldShowPostChatLoadingPane = exports.shouldShowOutOfOfficeHoursPane = exports.shouldShowLoadingPane = exports.shouldShowHeader = exports.shouldShowFooter = exports.shouldShowEmailTranscriptPane = exports.shouldShowConfirmationPane = exports.shouldShowChatButton = exports.shouldShowCallingContainer = void 0;
7
7
  var _ConversationState = require("../contexts/common/ConversationState");
8
+ var _liveChatConfigUtils = require("../components/livechatwidget/common/liveChatConfigUtils");
8
9
  const shouldShowChatButton = state => {
9
10
  var _state$appStates;
10
11
  return (state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed) && (state === null || state === void 0 || (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.hideStartChatButton) === false; // Do not show chat button in case of popout
@@ -27,7 +28,18 @@ const shouldShowEmailTranscriptPane = state => {
27
28
  };
28
29
  exports.shouldShowEmailTranscriptPane = shouldShowEmailTranscriptPane;
29
30
  const shouldShowWebChatContainer = state => {
30
- return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.InActive || state.appStates.conversationState === _ConversationState.ConversationState.Postchat && state.appStates.isConversationalSurveyEnabled && state.appStates.isConversationalSurvey;
31
+ var _state$domainStates;
32
+ const extendedChatConfig = state === null || state === void 0 || (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatConfig;
33
+ const persistentHistoryEnabled = (0, _liveChatConfigUtils.shouldLoadPersistentChatHistory)(extendedChatConfig);
34
+ const isActiveOrInactive = state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.InActive;
35
+ const isPostchatSurvey = state.appStates.conversationState === _ConversationState.ConversationState.Postchat && state.appStates.isConversationalSurveyEnabled && state.appStates.isConversationalSurvey;
36
+ if (persistentHistoryEnabled) {
37
+ // Keep WebChat in DOM even when minimized (CSS hides it via visibility)
38
+ // This preserves scroll position across minimize/maximize cycles
39
+ return isActiveOrInactive || isPostchatSurvey;
40
+ }
41
+ // Original behavior - hide WebChat when minimized
42
+ return !state.appStates.isMinimized && (isActiveOrInactive || isPostchatSurvey);
31
43
  };
32
44
  exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
33
45
  const shouldShowLoadingPane = state => {
@@ -7,11 +7,16 @@ exports.default = useWindowDimensions;
7
7
  var _react = require("react");
8
8
  var _useDebounce = _interopRequireDefault(require("./useDebounce"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
10
16
  function getWindowDimensions() {
11
- const {
12
- innerWidth: width,
13
- innerHeight: height
14
- } = window;
17
+ const _window = window,
18
+ width = _window.innerWidth,
19
+ height = _window.innerHeight;
15
20
  return {
16
21
  width,
17
22
  height
@@ -19,7 +24,10 @@ function getWindowDimensions() {
19
24
  }
20
25
  function useWindowDimensions() {
21
26
  let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 200;
22
- const [windowDimensions, setWindowDimensions] = (0, _react.useState)(getWindowDimensions());
27
+ const _useState = (0, _react.useState)(getWindowDimensions()),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ windowDimensions = _useState2[0],
30
+ setWindowDimensions = _useState2[1];
23
31
  const handleResize = () => setWindowDimensions(getWindowDimensions());
24
32
  const debouncedHandleResize = (0, _useDebounce.default)(handleResize, delay);
25
33
  (0, _react.useEffect)(() => {
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}